From: Radim Krcmar <rkrcmar@qti.qualcomm.com>
To: Guodong Xu <guodong.xu@oss.qualcomm.com>
Cc: Jonathan Corbet <corbet@lwn.net>,
Shuah Khan <skhan@linuxfoundation.org>,
Paul Walmsley <pjw@kernel.org>,
Palmer Dabbelt <palmer@dabbelt.com>,
Albert Ou <aou@eecs.berkeley.edu>,
Alexandre Ghiti <alex@ghiti.fr>,
Randy Dunlap <rdunlap@infradead.org>,
"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>,
"linux-riscv@lists.infradead.org"
<linux-riscv@lists.infradead.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Paul Walmsley <paul.walmsley@sifive.com>,
Conor Dooley <conor@kernel.org>,
"linux-kselftest@vger.kernel.org"
<linux-kselftest@vger.kernel.org>,
Andy Chiu <tchiu@tenstorrent.com>,
Florian Weimer <fweimer@redhat.com>,
Peter Bergner <bergner@oss.tenstorrent.com>,
Zihong Yao <zihong.plct@isrc.iscas.ac.cn>,
Mark Harris <mark.hsj@gmail.com>,
Aurelien Jarno <aurelien@aurel32.net>,
Andrew Jones <andrew.jones@linux.dev>,
linux-riscv <linux-riscv-bounces@lists.infradead.org>
Subject: Re: [PATCH v9 3/4] riscv: hwprobe: Introduce rva23u64 base behavior
Date: Tue, 17 Nov 2026 13:09:47 +0000 [thread overview]
Message-ID: <DMXIDXA2V2S5.M1C8TT9U62FQ@qti.qualcomm.com> (raw)
In-Reply-To: <20261109-rva23u64-hwprobe-v2-v9-3-ae846c5c7178@oss.qualcomm.com>
2026-11-09T07:47:36-05:00, Guodong Xu <guodong.xu@oss.qualcomm.com>:
> Provide a hwprobe base-behavior bit, RISCV_HWPROBE_BASE_BEHAVIOR_RVA23U64,
> so userspace can check RVA23U64 support in one call. Without it, a
> consumer has to test more than thirty extension bits across three
> hwprobe keys, and still cannot confirm that PMLEN=7 is selectable
> without prctl() calls that change the calling thread's state.
> Userspace treats RVA23U64 as a new base, so expose it as one.
>
> The bit is reported for a set of CPUs when each of them has the
> RVA23U64 mandatory extensions. F, D, C, V, Zicbom and Zicboz must in
> addition be present on every hart, as the kernel handles these across
> all harts.
>
> Co-developed-by: Andrew Jones <andrew.jones@oss.qualcomm.com>
> Signed-off-by: Andrew Jones <andrew.jones@oss.qualcomm.com>
> Signed-off-by: Guodong Xu <guodong.xu@oss.qualcomm.com>
> ---
> v9:
> - Report RVA23U64 only when F/D, C, V, Zicbom and Zicboz are present on
> every hart, in line with IMA_FD, IMA_C, IMA_V and the host-wide
> Zicbom/Zicboz enables (Radim).
> - Update the RVA23U64 entry in hwprobe.rst.
> - Reword the commit message.
> - Revert RISCV_HWPROBE_BASE_BEHAVIOR_IMA to hardcoded; do not compute
> it from I, M and A.
> ---
> diff --git a/arch/riscv/kernel/sys_hwprobe.c b/arch/riscv/kernel/sys_hwprobe.c
> +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...
> + 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.
Thanks.
next prev parent reply other threads:[~2026-11-17 13:10 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-09 12:47 [PATCH v9 0/4] riscv: hwprobe: Expose RVA23U64 base behavior Guodong Xu
2026-11-09 12:47 ` [PATCH v9 1/4] riscv: cpufeature: Introduce ISA bases bitmap and rva23u64 detection Guodong Xu
2026-11-09 15:56 ` Icenowy Zheng
2026-11-09 12:47 ` [PATCH v9 2/4] riscv: cpu: Output isa bases lines in cpuinfo Guodong Xu
2026-11-09 12:47 ` [PATCH v9 3/4] riscv: hwprobe: Introduce rva23u64 base behavior Guodong Xu
2026-11-17 13:09 ` Radim Krcmar [this message]
2026-11-09 12:47 ` [PATCH v9 4/4] riscv: hwprobe: Document that keys describe the user-mode environment Guodong Xu
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=DMXIDXA2V2S5.M1C8TT9U62FQ@qti.qualcomm.com \
--to=rkrcmar@qti.qualcomm.com \
--cc=alex@ghiti.fr \
--cc=andrew.jones@linux.dev \
--cc=aou@eecs.berkeley.edu \
--cc=aurelien@aurel32.net \
--cc=bergner@oss.tenstorrent.com \
--cc=conor@kernel.org \
--cc=corbet@lwn.net \
--cc=fweimer@redhat.com \
--cc=guodong.xu@oss.qualcomm.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-riscv-bounces@lists.infradead.org \
--cc=linux-riscv@lists.infradead.org \
--cc=mark.hsj@gmail.com \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=pjw@kernel.org \
--cc=rdunlap@infradead.org \
--cc=skhan@linuxfoundation.org \
--cc=tchiu@tenstorrent.com \
--cc=zihong.plct@isrc.iscas.ac.cn \
/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