Re: [RFC PATCH v1 04/11] riscv: Add B to hwcap
From: Andrew Jones
Date: Tue Feb 24 2026 - 18:09:55 EST
On Sat, Feb 21, 2026 at 06:49:18PM +0800, Guodong Xu wrote:
> Hi, Drew
>
> On Fri, Feb 6, 2026 at 8:24 AM Andrew Jones
> <andrew.jones@xxxxxxxxxxxxxxxx> wrote:
> >
> > Add B to hwcap and ensure when B is present that Zba, Zbb, and Zbs
> > are all set.
> >
> > Signed-off-by: Andrew Jones <andrew.jones@xxxxxxxxxxxxxxxx>
> > ---
> > arch/riscv/include/asm/hwcap.h | 1 +
> > arch/riscv/include/uapi/asm/hwcap.h | 1 +
> > arch/riscv/kernel/cpufeature.c | 8 ++++++++
> > 3 files changed, 10 insertions(+)
>
> I saw you chose not to add B to hwprobe in this series, per
> your review of my patch [1]. I have a different opinion.
>
> As you said, FD, C, and V are all exported through both hwcap
> and hwprobe. Adding B to hwprobe too keeps things consistent,
> users can query all the single-letter extensions from one
> interface without needing to know that B is missing in hwprobe
> and that they'd have to check Zba/Zbb/Zbs to infer B support.
>
> Relying on the rva23u64 base bit to imply B also doesn't cover
> chips that implement B without being rva23u64 compliant. Eg. my
> patchset [2] adds support for existing (non-rva23u64) SoCs.
>
I think we need to come up with some sort of policy as to what goes to
hwprobe and what doesn't. IMO, hwcap is easy. If RISC-V defines a single
letter extension, such as V or B, then we should add it to hwcap. However,
for hwprobe, we can go two ways:
1. Add every extension, including 'bundle' extensions, which are nothing
more than an alias for a collection of extensions. This includes single
letter bundle extensions like B.
2. Add only unique extensions, i.e. no purely bundle extensions get
added.
If we go with (2), then userspace will need to use the base behaviors
(profiles) in order to get any sort of bundling, but I think most people
agree that userspace will target profiles, so (2) seems sufficient. I'm
not sure about applications that won't target profiles but will want to
check for bundle extensions rather than individual extensions. Should we
take on the maintenance burden of adding each bundle extension to hwprobe
for those? In particular, I'm not sure about B, because it's already
available independently of a base behavior (profile) through hwcap.
Thanks,
drew