Re: [PATCH v9 3/4] riscv: hwprobe: Introduce rva23u64 base behavior

From: Guodong Xu

Date: Thu Nov 26 2026 - 07:12:04 EST


Hi Radim,

On Tue, 17 Nov 2026 13:09:47 +0000, Radim Krcmar wrote:
> 2026-11-09T07:47:36-05:00, Guodong Xu <guodong.xu@xxxxxxxxxxxxxxxx>:

[...]

> > +static bool hwprobe_has_isa_base(const struct cpumask *cpus, unsigned int base)
> > +{
> > + int cpu;
> > +
> > + /*
> > + * F, D, C, V, Zicbom and Zicboz are RVA23U64 mandatory extensions
> > + * that the kernel enables for user mode only when every hart has
> > + * them, partly because their enable bits (sstatus.FS/VS,
> > + * senvcfg.CBCFE/CBZE) are managed across all harts rather than
> > + * per hart.
> > + */
> > + if (base == RISCV_ISA_BASE_RVA23U64 &&
> > + !(has_fpu() &&
> > + riscv_isa_extension_available(NULL, C) &&
> > + has_vector() && riscv_isa_extension_available(NULL, V) &&
> > + riscv_isa_extension_available(NULL, ZICBOM) &&
> > + riscv_isa_extension_available(NULL, ZICBOZ)))
> > + return false;
> > +
>
> Looking at the condition, I feel a bit uneasy about code duplication...

Thanks for the review. I had the same feeling, and I agree. I had
considered moving these host-wide checks into a static helper shared
with hwprobe_isa_ext0(), but ...

> > + for_each_cpu(cpu, cpus) {
> > + if (!riscv_isa_base_available(hart_isa[cpu].isa_bases, base))
> > + return false;
> > + }
>
> Could we avoid the isa_bases here and just report the base as a function
> of other hwprobe bits (and the awkward PMLEN)?
>
> I think something like the following would directly make use of any
> fixes we apply to the detection of hwprobe features:
>
> static bool hwprobe_has_rva23u64(const struct cpumask *cpus) {
> /* IMA extensions are required by the kernel. */
> return riscv_have_user_pmlen(7) &&
> hwprobe_ext0_has(cpus, RVA23U64_EXT0) &&
> hwprobe_ext1_has(cpus, RVA23U64_EXT1); }
>
> Where the two RVA23U64_EXT are hardcoded bitmasks of RVA32U64 extensions
> and hwprobe_ext_has is tweaked slightly to accept a bitmask and return
> true iff all extensions match.

Your suggestion is better. I will take it in v10.

One small concern is the two hardcoded masks, RVA23U64_EXT0 and
RVA23U64_EXT1: a similar exhaustive list already exists in
riscv_set_isa_bases() in cpufeature.c (patch 1). Merging the two into
one source is not straightforward.

Then again, RVA23 is ratified and the list will not change, so that is
probably acceptable, unless somebody wants to avoid even that level of
duplication, which may not be worth the effort.

Guodong