From: Guodong Xu <guodong.xu@oss.qualcomm.com>
To: Radim Krcmar <rkrcmar@qti.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>
Subject: Re: [PATCH v9 3/4] riscv: hwprobe: Introduce rva23u64 base behavior
Date: Thu, 26 Nov 2026 07:11:51 -0500 [thread overview]
Message-ID: <da5af153e664e882654e7f6068ea7105.guodong.xu@oss.qualcomm.com> (raw)
In-Reply-To: <DMXIDXA2V2S5.M1C8TT9U62FQ@qti.qualcomm.com>
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@oss.qualcomm.com>:
[...]
> > +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
next prev parent reply other threads:[~2026-11-26 12:11 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-09 12:47 [PATCH v9 0/4] riscv: hwprobe: Expose RVA23U64 " 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-26 5:16 ` Guodong Xu
2026-11-26 8:15 ` 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
2026-11-26 12:11 ` Guodong Xu [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=da5af153e664e882654e7f6068ea7105.guodong.xu@oss.qualcomm.com \
--to=guodong.xu@oss.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=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.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=rkrcmar@qti.qualcomm.com \
--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
all inboxes | Powered by JetHome®