Re: [PATCH v1 6/9] RISC-V: add single letter extensions to riscv_isa_ext

From: Evan Green
Date: Wed Jun 28 2023 - 13:51:39 EST


On Wed, Jun 28, 2023 at 10:43 AM Conor Dooley <conor@xxxxxxxxxx> wrote:
>
> On Wed, Jun 28, 2023 at 10:33:20AM -0700, Evan Green wrote:
> > On Mon, Jun 26, 2023 at 4:21 AM Conor Dooley <conor.dooley@xxxxxxxxxxxxx> wrote:
> > >
> > > So that riscv_fill_hwcap() can use riscv_isa_ext to probe for single
> > > letter extensions, add them to it. riscv_isa_ext_data grows a new
> > > member, signifying whether an extension is multi-letter & thus requiring
> > > special handling.
> > > As a result, what gets spat out in /proc/cpuinfo will become borked, as
> > > single letter extensions will be printed as part of the base extensions
> > > and while printing from riscv_isa_arr. Take the opportunity to unify the
> > > printing of the isa string, using the new member of riscv_isa_ext_data
> > > in the process.
> > >
> > > Signed-off-by: Conor Dooley <conor.dooley@xxxxxxxxxxxxx>
> > > ---
> > > arch/riscv/include/asm/hwcap.h | 1 +
> > > arch/riscv/kernel/cpu.c | 36 ++++++----------------
> > > arch/riscv/kernel/cpufeature.c | 56 +++++++++++++++++++++-------------
> > > 3 files changed, 46 insertions(+), 47 deletions(-)
> > >
> > > diff --git a/arch/riscv/include/asm/hwcap.h b/arch/riscv/include/asm/hwcap.h
> > > index a35bee219dd7..6ad896dc4342 100644
> > > --- a/arch/riscv/include/asm/hwcap.h
> > > +++ b/arch/riscv/include/asm/hwcap.h
> > > @@ -77,6 +77,7 @@ unsigned long riscv_get_elf_hwcap(void);
> > > struct riscv_isa_ext_data {
> > > const unsigned int id;
> > > const char *name;
> > > + const bool multi_letter;
> >
> > Instead of defining a new member, could we just infer this by making a
> > macro like #define MULTI_LETTER(name) (name[0] && name[1])?
>
> Or don't even try to be clever like this and just call strnlen on the
> name & check if it is 1? It's only used in 2 places.

Sounds good to me!