Linux-RISC-V Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Clément Léger" <cleger@rivosinc.com>
To: Alexandre Ghiti <alex@ghiti.fr>,
	Paul Walmsley <paul.walmsley@sifive.com>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	"open list:RISC-V ARCHITECTURE" <linux-riscv@lists.infradead.org>,
	open list <linux-kernel@vger.kernel.org>
Cc: Conor Dooley <conor@kernel.org>,
	Alexandre Ghiti <alexghiti@rivosinc.com>
Subject: Re: [PATCH] riscv: cpufeature: use bitmap_equal() instead of memcmp()
Date: Tue, 11 Feb 2025 09:15:37 +0100	[thread overview]
Message-ID: <56d2e34f-56cf-4141-b85f-1b11f560feaa@rivosinc.com> (raw)
In-Reply-To: <968ff88f-ae77-43b4-a5b4-1a4b0bf61098@ghiti.fr>



On 11/02/2025 08:41, Alexandre Ghiti wrote:
> Hi Clément,
> 
> On 10/02/2025 16:56, Clément Léger wrote:
>> Comparison of bitmaps should be done using bitmap_equal(), not memcmp(),
>> use the former one to compare isa bitmaps.
>>
>> Signed-off-by: Clément Léger <cleger@rivosinc.com>
>> ---
>>   arch/riscv/kernel/cpufeature.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/
>> cpufeature.c
>> index c6ba750536c3..40ac72e407b6 100644
>> --- a/arch/riscv/kernel/cpufeature.c
>> +++ b/arch/riscv/kernel/cpufeature.c
>> @@ -479,7 +479,7 @@ static void __init riscv_resolve_isa(unsigned long
>> *source_isa,
>>               if (bit < RISCV_ISA_EXT_BASE)
>>                   *this_hwcap |= isa2hwcap[bit];
>>           }
>> -    } while (loop && memcmp(prev_resolved_isa, resolved_isa,
>> sizeof(prev_resolved_isa)));
>> +    } while (loop && !bitmap_equal(prev_resolved_isa, resolved_isa,
>> RISCV_ISA_EXT_MAX));
>>   }
>>     static void __init match_isa_ext(const char *name, const char
>> *name_end, unsigned long *bitmap)
> 
> 
> Since bitmap does not guarantee the value of the 'extra' bits (https://
> elixir.bootlin.com/linux/v6.13.1/source/lib/bitmap.c#L24), this is a fix
> so I would add a Fixes tag:
> 
> Fixes: 625034abd52a8c ("riscv: add ISA extensions validation callback")

Yeah, I wasn't sure since it does not fix anything per se. We aligned
the ISA size to a multiple of 64 (128) so we actually do not have any
extra undefined bits. But I agree that it's better to track it correctly
as a fix.

That makes me think that we could actually size RISCV_ISA_EXT_MAX to be
exactly the number of ISA extensions we support rather than a larger
arbitrary value.

> 
> You can also add:
> 
> Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>

Thanks !

Clément

> 
> Thanks,
> 
> Alex
> 


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

  reply	other threads:[~2025-02-11  8:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-10 15:56 [PATCH] riscv: cpufeature: use bitmap_equal() instead of memcmp() Clément Léger
2025-02-11  7:41 ` Alexandre Ghiti
2025-02-11  8:15   ` Clément Léger [this message]
2025-02-13 18:30 ` patchwork-bot+linux-riscv

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56d2e34f-56cf-4141-b85f-1b11f560feaa@rivosinc.com \
    --to=cleger@rivosinc.com \
    --cc=alex@ghiti.fr \
    --cc=alexghiti@rivosinc.com \
    --cc=conor@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox