[PATCH v10 0/4] riscv: hwprobe: Expose RVA23U64 base behavior
From: Guodong Xu
Date: Thu Nov 26 2026 - 16:33:00 EST
This series builds on Andrew Jones's earlier RFC [1]. It lets userspace
check for RVA23U64 conformance in one call, instead of walking hwprobe +
prctl across every mandatory extension.
The series adds a small framework that resolves profile-class bases
(currently RVA23U64) from the kernel's ISA extension bitmap at init time,
and surfaces the result, together with the IMA base, through
/proc/cpuinfo. hwprobe reports the same bases, derived from its own
extension keys, so that they follow what the kernel enables for user
mode. Later patches can add other bases, such as RVA20U64 or RVA23S64,
without changes to the surrounding code.
One change since v9.
>From Radim's review of v9 3/4 [3]:
- hwprobe no longer reads the isa_bases bitmap. RVA23U64 is reported
when PMLEN=7 is selectable and all RVA23U64 mandatory extensions are
reported in IMA_EXT_0 and IMA_EXT_1 (I, M and A are the IMA base, and
Zicsr is implied by F). The bit therefore follows any fix to the
extension keys, including the host-wide rules in Radim's series [4],
with no second copy of those conditions in hwprobe.
Part of me is a little concerned about the hardcoded masks,
RVA23U64_EXT0 and RVA23U64_EXT1: they are an exhaustive list of the
RVA23U64 mandatory extensions, and another exhaustive list, as
__set_bit() calls on RISCV_ISA_EXT_* bits, already exists in
riscv_set_isa_bases() in cpufeature.c (patch 1). Merging the two into
one source is not straightforward. But as said, RVA23 is ratified and
no further change to the list is expected, so I tend to keep them as
they are in v10.
Unless someone has a different opinion; please speak up.
With that, series outline (v10):
1: cpufeature: per-hart and host-wide isa_bases bitmaps; RVA23U64
detection for /proc/cpuinfo lives here.
2: /proc/cpuinfo: print "isa bases:" and "hart isa bases:", e.g.
"rv64ima rva23u64".
3: hwprobe: expose RVA23U64 as RISCV_HWPROBE_BASE_BEHAVIOR_RVA23U64,
derived from the IMA_EXT_0/IMA_EXT_1 bits and PMLEN.
4: hwprobe.rst: note on what "supported" means for a hwprobe bit.
Note: patch 4 states the rule for all hwprobe keys, but some keys only
follow it with Radim's series [4], such as the Zicbom/Zicboz keys.
Follow-ups I plan to post separately:
- A series exposing these extensions to KVM guests (extending the KVM
ISA extension ONE_REG interface), on top of this one.
- A series adding further bases: RVA20U64 first, then RVA22U64 and
RVA23S64. RVA20U64 also needs Za128rs support in the kernel, which
will be part of that series.
Tested on QEMU (virt machine, 4 harts):
1) With '-cpu rva23s64,sv39=on', /proc/cpuinfo reports
"isa bases : rv64ima rva23u64"
on both the aggregated and per-hart lines, and hwprobe
RISCV_HWPROBE_KEY_BASE_BEHAVIOR returns
BASE_BEHAVIOR_IMA | BASE_BEHAVIOR_RVA23U64
through both the vDSO and the raw syscall. The riscv/hwprobe
kselftests pass.
2) With '-cpu rva22s64', /proc/cpuinfo reports "isa bases : rv64ima"
and hwprobe returns BASE_BEHAVIOR_IMA only.
3) With device trees in which one hart lacks an extension: when that
extension is D, C or V, RVA23U64 is not reported for any CPU.
A branch is available for all patches in the series: [2].
v10 is based on v7.4-rc1.
Thanks,
Guodong Xu
Link: https://lore.kernel.org/linux-riscv/20260206002349.96740-1-andrew.jones@xxxxxxxxxxxxxxxx/ [1]
Link: https://github.com/docularxu/linux/commits/b4/rva23u64-hwprobe-v10/ [2]
Link: https://lore.kernel.org/linux-riscv/DMXIDXA2V2S5.M1C8TT9U62FQ@xxxxxxxxxxxxxxxx/ [3]
Link: https://lore.kernel.org/linux-riscv/20261006075303.205216-1-radim.krcmar@xxxxxxxxxxxxxxxx/ [4]
Link: https://lore.kernel.org/all/c24e720e279fed0296f1f78630b6a471.guodong.xu@xxxxxxxxxxxxxxxx/ [5]
Changes in v10:
- Patch 3: report RVA23U64 as a function of the IMA_EXT_0 and IMA_EXT_1
bits plus PMLEN=7; drop the isa_bases lookup and the host-wide gate
from hwprobe (Radim). hwprobe_ext0_has() takes a mask; add
hwprobe_ext1_has().
- Patch 1: reword the commit message and comments; isa_bases now feeds
/proc/cpuinfo only.
- Patches 2 and 4: no change.
- Link to v9: https://patch.msgid.link/20261109-rva23u64-hwprobe-v2-v9-0-ae846c5c7178@xxxxxxxxxxxxxxxx
Changes in v9:
- Dropped patches 1-8 of v8, which have been applied by Paul. Rebased
the remaining three onto v7.4-rc1; patch 2 (10 in v8) has no other
change.
- Patch 1 (9 in v8): set the IMA base unconditionally; do not derive it
from I, M and A.
- Patch 3 (11 in v8):
- Report RVA23U64 only when F, D, C, V, Zicbom and Zicboz are present
on every hart (Radim).
- Revert RISCV_HWPROBE_BASE_BEHAVIOR_IMA to hardcoded; do not compute
it from I, M and A.
- Reword the commit message.
- Update the hwprobe.rst.
- New patch 4: add a note to hwprobe.rst that clarifies what
"supported" means for a hwprobe bit (Radim).
- Link to v8: https://patch.msgid.link/20260920-rva23u64-hwprobe-v2-v8-0-5f14bc5c23d3@xxxxxxxxxxxxxxxx
Changes in v8:
- Patch 10: Andrew Jones is the author; most of the code is still his
from the RFC. Added my Co-developed-by (Conor).
- Patches 09 and 11: added Co-developed-by for Andrew Jones ahead of
his Signed-off-by; the RVA23U64 bit, the hwprobe.rst text and the
mandate list came from his RFC (Conor).
- Rebased onto riscv/for-next at e11160948333. Patch 11 drops its own
pair->value = 0 in the BASE_BEHAVIOR case, since commit d0fc6fab2046
("riscv: hwprobe: initialize pair->value in hwprobe_one_pair()") now
zeroes it for every key. No other code change since v7.
- Link to v7: https://patch.msgid.link/20260915-rva23u64-hwprobe-v2-v7-0-aa35ebd9ae96@xxxxxxxxxxxxxxxx
Changes in v7:
- Patch 09: register riscv_init_isa_bases() at arch_initcall so the vDSO
hwprobe snapshot (arch_initcall_sync) sees the ISA bases; v6 returned 0
for RISCV_HWPROBE_KEY_BASE_BEHAVIOR through the vDSO, IMA bit included,
while the syscall path was correct [5].
- Patch 09: keep riscv_isa_bases static and add riscv_isa_base_available(),
mirroring the extension accessor; patches 10 and 11 use it.
- Collected Acked-by from Conor Dooley on patches 02 and 03.
- Rebased onto riscv/for-next at 77ae27fd98f3 (post 7.3 merge window);
no code adaptation needed.
- Link to v6: https://patch.msgid.link/20260812-rva23u64-hwprobe-v2-v6-0-c985af3256b8@xxxxxxxxxxxxxxxx
Changes in v6:
- Rebased onto riscv/for-next; dropped patches 1-6 of v5, which have been
applied by Paul.
- dt-bindings block-size: only match nodes that have
riscv,isa-extensions (fix suggested by Conor, breakage reported by
Rob's bot).
- Zic64b dt-binding: guard the zic64b rule the same way (same defect
class, found while fixing the above).
- Follow the _BITULL() style of commit 8da45c93dfa9 ("RISC-V: hwprobe:
Use BIT macro to avoid warnings") for the new hwprobe bits (EXT_B,
EXT_ZIC64B, BASE_BEHAVIOR_RVA23U64).
- Zic64b: RISCV_ISA_EXT_ZIC64B renumbered 110 to 116 after upstream
additions took 106-111.
- Link to v5: https://patch.msgid.link/20260701-rva23u64-hwprobe-v2-v5-0-2c61f94a695a@xxxxxxxxx
Changes in v5:
- Rebased onto v7.2-rc1.
- New patch: make riscv,cbom/cbop/cboz-block-size required whenever the
matching Zicbom/Zicbop/Zicboz extension is present (Conor).
- Ziccamoa/Za64rs: drop the Zaamo/Zalrsc validate callbacks (Conor).
- Zic64b dt-binding: fix a double space in the commit message (Conor).
- Collected Reviewed-by and Acked-by tags in v4.
- Link to v4: https://patch.msgid.link/20260611-rva23u64-hwprobe-v2-v4-0-3f01a2449488@xxxxxxxxx
Changes in v4:
- New patch: sort the multi-letter Z extensions alphanumerically in the
dt-binding (Conor), and place zic64b at its sorted position.
- Zic64b cpufeature: validate only the CBO block sizes that are present;
overlaps Qingwei Hu's earlier patch, so it is now authored by Qingwei.
- Document EXT_ZICFISS / EXT_ZICFILP: cite the riscv-cfi v1.0 tag commit.
- Picked up Inochi Amaoto's Acked-by (SG2044 dts) and Andrew Jones's
Reviewed-by (documentation patch).
- Link to v3: https://patch.msgid.link/20260603-rva23u64-hwprobe-v2-v3-0-5529a7b28384@xxxxxxxxx
Changes in v3:
- Add Zic64b as a first-class ISA extension: dt-binding, cpufeature
parsing with a validate check, hwprobe export, and device-tree
declarations for K3/K1/SG2044.
- Patch 1 is now a clean up of hwprobe.rst indentation.
- Document RISCV_HWPROBE_EXT_ZICFILP alongside ZICFISS.
- Move the Zicclsm hwprobe.rst entry to the IMA_EXT_1 section to match
its bit allocation.
- Collect Anup Patel's Acked-by/Reviewed-by on Patch 3, the capitalization.
- In cpufeature.c, set the local ext_mask with __set_bit().
- Update Guodong Xu's email to docular.xu@xxxxxxxxx.
- Link to v2: https://patch.msgid.link/20260511-rva23u64-hwprobe-v2-v2-0-21c5a544f1dc@xxxxxxxxxxxx
Changes in v2 (since Andrew's RFC v1):
- Rebased onto v7.1-rc2.
- Reworked rva23u64 detection into per-hart and host isa_bases bitmaps,
shared by /proc/cpuinfo and hwprobe.
- Scoped to IMA and RVA23U64 (RVA23S64, RVA20/RVA22 cpuinfo output deferred).
- Link to v1: https://lore.kernel.org/linux-riscv/20260206002349.96740-1-andrew.jones@xxxxxxxxxxxxxxxx
Signed-off-by: Guodong Xu <guodong.xu@xxxxxxxxxxxxxxxx>
---
Andrew Jones (1):
riscv: cpu: Output isa bases lines in cpuinfo
Guodong Xu (3):
riscv: cpufeature: Introduce ISA bases bitmap and rva23u64 detection
riscv: hwprobe: Introduce rva23u64 base behavior
riscv: hwprobe: Document that keys describe the user-mode environment
Documentation/arch/riscv/hwprobe.rst | 29 ++++++
arch/riscv/include/asm/cpufeature.h | 13 +++
arch/riscv/include/uapi/asm/hwprobe.h | 3 +-
arch/riscv/kernel/cpu.c | 26 +++++
arch/riscv/kernel/cpufeature.c | 106 +++++++++++++++++++++
arch/riscv/kernel/sys_hwprobe.c | 54 ++++++++++-
tools/testing/selftests/riscv/hwprobe/which-cpus.c | 2 +-
7 files changed, 226 insertions(+), 7 deletions(-)
---
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
change-id: 20260508-rva23u64-hwprobe-v2-1d20739cbb8e
Best regards,
--
Guodong Xu <guodong.xu@xxxxxxxxxxxxxxxx>