[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKgze5aZTocPbn8SDYWJ+wLK7zJFP95=vHU-U+BBF1bc1gPOsg@mail.gmail.com>
Date: Tue, 8 Feb 2022 11:39:50 -0300
From: Martin Fernandez <martin.fernandez@...ypsium.com>
To: Kees Cook <keescook@...omium.org>
Cc: linux-kernel@...r.kernel.org, linux-efi@...r.kernel.org,
platform-driver-x86@...r.kernel.org, linux-mm@...ck.org,
tglx@...utronix.de, mingo@...hat.com, bp@...en8.de,
dave.hansen@...ux.intel.com, x86@...nel.org, hpa@...or.com,
ardb@...nel.org, dvhart@...radead.org, andy@...radead.org,
gregkh@...uxfoundation.org, rafael@...nel.org, rppt@...nel.org,
akpm@...ux-foundation.org, daniel.gutson@...ypsium.com,
hughsient@...il.com, alex.bazhaniuk@...ypsium.com,
alison.schofield@...el.com
Subject: Re: [PATCH v6 1/6] mm/memblock: Tag memblocks with crypto capabilities
On 2/7/22, Kees Cook <keescook@...omium.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.
Powered by blists - more mailing lists