lkml.org 
[lkml]   [2022]   [Feb]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v6 1/6] mm/memblock: Tag memblocks with crypto capabilities
On 2/7/22, Kees Cook <keescook@chromium.org> wrote:
> On Thu, Feb 03, 2022 at 01:43:23PM -0300, Martin Fernandez wrote:
>> +/**
>> + * memblock_node_is_crypto_capable - get if whole node is capable
>> + * of encryption
>> + * @nid: number of node
>> + *
>> + * Iterate over all memory memblock_type and find if all regions under
>> + * node @nid are capable of hardware encryption.
>> + *
>> + * Return:
>> + * true if every region in memory memblock_type is capable of
>> + * encryption, false otherwise.
>> + */
>> +bool __init_memblock memblock_node_is_crypto_capable(int nid)
>> +{
>> + struct memblock_region *region;
>> + bool crypto_capable = false;
>> + bool not_crypto_capable = false;
>> +
>> + for_each_mem_region(region) {
>> + if (memblock_get_region_node(region) == nid) {
>> + crypto_capable =
>> + crypto_capable ||
>> + (region->flags & MEMBLOCK_CRYPTO_CAPABLE);
>
> This was already mentioned, but I just thought I'd add: this made me
> double-take, given the "||" (instead of "|") in an assignment. It looked
> like a typo, but yes it's correct. I was expecting something like:
>
> crypto_capable |=
> !!(region->flags & MEMBLOCK_CRYPTO_CAPABLE);
>
>> + not_crypto_capable =
>> + not_crypto_capable ||
>> + !(region->flags & MEMBLOCK_CRYPTO_CAPABLE);
>
> not_crypto_capable |=
> !(region->flags & MEMBLOCK_CRYPTO_CAPABLE);
>

Yes, this also works. Thanks.

\
 
 \ /
  Last update: 2022-02-08 15:41    [W:0.113 / U:0.044 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site