From: Andrew Jones <andrew.jones@oss.qualcomm.com>
To: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org,
kvm-riscv@lists.infradead.org
Cc: "Paul Walmsley" <pjw@kernel.org>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Anup Patel" <anup@brainfault.org>,
"Clément Léger" <cleger@rivosinc.com>,
"Conor Dooley" <conor.dooley@microchip.com>,
"Guodong Xu" <guodong@riscstar.com>,
"Charlie Jenkins" <charlie@rivosinc.com>,
"Charlie Jenkins" <thecharlesjenkins@gmail.com>,
"Samuel Holland" <samuel.holland@sifive.com>
Subject: [RFC PATCH v1 08/11] riscv: hwprobe: Introduce rva23u64 base behavior
Date: Thu, 5 Feb 2026 18:23:46 -0600 [thread overview]
Message-ID: <20260206002349.96740-9-andrew.jones@oss.qualcomm.com> (raw)
In-Reply-To: <20260206002349.96740-1-andrew.jones@oss.qualcomm.com>
Provide a bit to conveniently determine when RVA23U64 is supported.
While it's already possible to determine RVA23U64 support with five
hwprobe calls and four prctl calls it would be error-prone to require
anything (and we presume eventually almost everything) that needs to
check for RVA23U64 support to all implement those calls and specific
checks. And, while RVA23U64 is the IMA base with mandated extensions,
most software will consider it a new base. For these reasons, add
the RVA23U64 bit as a base behavior bit.
Signed-off-by: Andrew Jones <andrew.jones@oss.qualcomm.com>
---
Documentation/arch/riscv/hwprobe.rst | 8 +++
arch/riscv/include/uapi/asm/hwprobe.h | 3 +-
arch/riscv/kernel/sys_hwprobe.c | 72 +++++++++++++++++++
.../selftests/riscv/hwprobe/which-cpus.c | 2 +-
4 files changed, 83 insertions(+), 2 deletions(-)
diff --git a/Documentation/arch/riscv/hwprobe.rst b/Documentation/arch/riscv/hwprobe.rst
index 97226b7c5936..6d915e7ba58a 100644
--- a/Documentation/arch/riscv/hwprobe.rst
+++ b/Documentation/arch/riscv/hwprobe.rst
@@ -67,6 +67,14 @@ The following keys are defined:
programs (it may still be executed in userspace via a
kernel-controlled mechanism such as the vDSO).
+ * :c:macro:`RISCV_HWPROBE_BASE_BEHAVIOR_RVA23U64`: Support for all mandatory
+ extensions of RVA23U64, as defined in the RISC-V Profiles specification
+ starting from commit b1d80660 ("Updated to ratified state.")
+
+ The RVA23U64 base is based upon the IMA base and therefore IMA extension
+ keys (e.g. :c:macro:`RISCV_HWPROBE_KEY_IMA_EXT_0`:) may be used to probe
+ optional extensions.
+
* :c:macro:`RISCV_HWPROBE_KEY_IMA_EXT_0`: A bitmask containing the extensions
that are compatible with the :c:macro:`RISCV_HWPROBE_BASE_BEHAVIOR_IMA`:
base system behavior.
diff --git a/arch/riscv/include/uapi/asm/hwprobe.h b/arch/riscv/include/uapi/asm/hwprobe.h
index fed9ea6fd2b5..72d2a4d0b733 100644
--- a/arch/riscv/include/uapi/asm/hwprobe.h
+++ b/arch/riscv/include/uapi/asm/hwprobe.h
@@ -21,7 +21,8 @@ struct riscv_hwprobe {
#define RISCV_HWPROBE_KEY_MARCHID 1
#define RISCV_HWPROBE_KEY_MIMPID 2
#define RISCV_HWPROBE_KEY_BASE_BEHAVIOR 3
-#define RISCV_HWPROBE_BASE_BEHAVIOR_IMA (1 << 0)
+#define RISCV_HWPROBE_BASE_BEHAVIOR_IMA (1 << 0)
+#define RISCV_HWPROBE_BASE_BEHAVIOR_RVA23U64 (1 << 1)
#define RISCV_HWPROBE_KEY_IMA_EXT_0 4
#define RISCV_HWPROBE_IMA_FD (1 << 0)
#define RISCV_HWPROBE_IMA_C (1 << 1)
diff --git a/arch/riscv/kernel/sys_hwprobe.c b/arch/riscv/kernel/sys_hwprobe.c
index 31d222301bf0..4b9981b15ebe 100644
--- a/arch/riscv/kernel/sys_hwprobe.c
+++ b/arch/riscv/kernel/sys_hwprobe.c
@@ -23,6 +23,7 @@
#include <asm/vendor_extensions/thead_hwprobe.h>
#include <vdso/vsyscall.h>
+extern bool riscv_have_user_pmlen_7;
#define EXT_KEY(isa_arg, ext, pv, missing) \
do { \
@@ -222,6 +223,75 @@ static bool hwprobe_ext0_has(const struct cpumask *cpus, u64 ext)
return (pair.value & ext);
}
+#define HWPROBE_EXT0_RVA23U64 ( \
+ /* IMA is always supported */ \
+ RISCV_HWPROBE_IMA_FD | \
+ RISCV_HWPROBE_IMA_C | \
+ /* B is Zba, Zbb and Zbs */ \
+ RISCV_HWPROBE_EXT_ZBA | \
+ RISCV_HWPROBE_EXT_ZBB | \
+ RISCV_HWPROBE_EXT_ZBS | \
+ /* ZICSR is always supported */ \
+ RISCV_HWPROBE_EXT_ZICNTR | \
+ RISCV_HWPROBE_EXT_ZIHPM | \
+ /* ZICCIF is in EXT1 */ \
+ /* ZICCRSE is in EXT1 */ \
+ /* ZICCAMOA is in EXT1 */ \
+ RISCV_HWPROBE_EXT_ZICCLSM | \
+ /* ZA64RS is in EXT1 */ \
+ RISCV_HWPROBE_EXT_ZIHINTPAUSE | \
+ /* ZIC64B (check block sizes are 64b) */ \
+ RISCV_HWPROBE_EXT_ZICBOM | \
+ RISCV_HWPROBE_EXT_ZICBOP | \
+ RISCV_HWPROBE_EXT_ZICBOZ | \
+ RISCV_HWPROBE_EXT_ZFHMIN | \
+ RISCV_HWPROBE_EXT_ZKT | \
+ RISCV_HWPROBE_IMA_V | \
+ RISCV_HWPROBE_EXT_ZVFHMIN | \
+ RISCV_HWPROBE_EXT_ZVBB | \
+ RISCV_HWPROBE_EXT_ZVKT | \
+ RISCV_HWPROBE_EXT_ZIHINTNTL | \
+ RISCV_HWPROBE_EXT_ZICOND | \
+ RISCV_HWPROBE_EXT_ZIMOP | \
+ RISCV_HWPROBE_EXT_ZCMOP | \
+ RISCV_HWPROBE_EXT_ZCB | \
+ RISCV_HWPROBE_EXT_ZFA | \
+ RISCV_HWPROBE_EXT_ZAWRS | \
+ RISCV_HWPROBE_EXT_SUPM /* (check PMLEN=7 support) */ \
+)
+
+#define HWPROBE_EXT1_RVA23U64 ( \
+ RISCV_HWPROBE_EXT_ZICCIF | \
+ RISCV_HWPROBE_EXT_ZICCRSE | \
+ RISCV_HWPROBE_EXT_ZICCAMOA | \
+ RISCV_HWPROBE_EXT_ZA64RS \
+)
+
+static bool hwprobe_has_rva23u64(const struct cpumask *cpus)
+{
+ struct riscv_hwprobe pair;
+
+ if (!IS_ENABLED(CONFIG_64BIT))
+ return false;
+
+ /* Additional mandates for Zic64b and Supm */
+ if (riscv_cbom_block_size != 64 ||
+ riscv_cbop_block_size != 64 ||
+ riscv_cboz_block_size != 64 ||
+ !riscv_have_user_pmlen_7)
+ return false;
+
+ hwprobe_isa_ext0(&pair, cpus);
+ if ((pair.value & HWPROBE_EXT0_RVA23U64) != HWPROBE_EXT0_RVA23U64)
+ return false;
+
+ hwprobe_isa_ext1(&pair, cpus);
+ if ((pair.value & HWPROBE_EXT1_RVA23U64) != HWPROBE_EXT1_RVA23U64)
+ return false;
+
+ return true;
+}
+
#if defined(CONFIG_RISCV_PROBE_UNALIGNED_ACCESS)
static u64 hwprobe_misaligned(const struct cpumask *cpus)
{
@@ -312,6 +382,8 @@ static void hwprobe_one_pair(struct riscv_hwprobe *pair,
*/
case RISCV_HWPROBE_KEY_BASE_BEHAVIOR:
pair->value = RISCV_HWPROBE_BASE_BEHAVIOR_IMA;
+ if (hwprobe_has_rva23u64(cpus))
+ pair->value |= RISCV_HWPROBE_BASE_BEHAVIOR_RVA23U64;
break;
case RISCV_HWPROBE_KEY_IMA_EXT_0:
diff --git a/tools/testing/selftests/riscv/hwprobe/which-cpus.c b/tools/testing/selftests/riscv/hwprobe/which-cpus.c
index 587feb198c04..f8c797b1d0fd 100644
--- a/tools/testing/selftests/riscv/hwprobe/which-cpus.c
+++ b/tools/testing/selftests/riscv/hwprobe/which-cpus.c
@@ -105,7 +105,7 @@ int main(int argc, char **argv)
pairs[0] = (struct riscv_hwprobe){ .key = RISCV_HWPROBE_KEY_BASE_BEHAVIOR, };
rc = riscv_hwprobe(pairs, 1, 0, NULL, 0);
assert(rc == 0 && pairs[0].key == RISCV_HWPROBE_KEY_BASE_BEHAVIOR &&
- pairs[0].value == RISCV_HWPROBE_BASE_BEHAVIOR_IMA);
+ (pairs[0].value & RISCV_HWPROBE_BASE_BEHAVIOR_IMA));
pairs[0] = (struct riscv_hwprobe){ .key = RISCV_HWPROBE_KEY_IMA_EXT_0, };
rc = riscv_hwprobe(pairs, 1, 0, NULL, 0);
--
2.43.0
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2026-02-06 0:24 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-06 0:23 [RFC PATCH v1 00/11] riscv: hwprobe: Introduce rva23u64 base behavior Andrew Jones
2026-02-06 0:23 ` [RFC PATCH v1 01/11] riscv: hwprobe: add support for RISCV_HWPROBE_KEY_IMA_EXT_1 Andrew Jones
2026-02-06 0:23 ` [RFC PATCH v1 02/11] RISC-V: Add Zicclsm to cpufeature and hwprobe Andrew Jones
2026-02-06 0:23 ` [RFC PATCH v1 03/11] riscv: Standardize extension capitilization Andrew Jones
2026-02-06 0:23 ` [RFC PATCH v1 04/11] riscv: Add B to hwcap Andrew Jones
2026-02-21 10:49 ` Guodong Xu
2026-02-24 23:04 ` Andrew Jones
2026-03-06 2:17 ` Guodong Xu
2026-03-06 18:27 ` Andrew Jones
2026-03-06 18:50 ` Conor Dooley
2026-03-06 19:04 ` Andrew Jones
2026-02-06 0:23 ` [RFC PATCH v1 05/11] riscv: hwprobe.rst: Replace tabs with spaces Andrew Jones
2026-02-06 0:23 ` [RFC PATCH v1 06/11] riscv: Add Ziccamoa, Ziccif, Ziccrse, and Za64rs to hwprobe Andrew Jones
2026-02-21 10:50 ` Guodong Xu
2026-02-24 23:22 ` Andrew Jones
2026-02-06 0:23 ` [RFC PATCH v1 07/11] riscv: Export have_user_pmlen* booleans Andrew Jones
2026-02-21 10:50 ` Guodong Xu
2026-02-24 23:32 ` Andrew Jones
2026-02-06 0:23 ` Andrew Jones [this message]
2026-02-08 16:15 ` [RFC PATCH v1 08/11] riscv: hwprobe: Introduce rva23u64 base behavior Andrew Jones
2026-02-21 10:51 ` Guodong Xu
2026-02-25 0:03 ` Andrew Jones
2026-03-06 12:29 ` Guodong Xu
2026-03-06 18:31 ` Andrew Jones
2026-03-06 12:08 ` Guodong Xu
2026-03-06 18:33 ` Andrew Jones
2026-02-06 0:23 ` [RFC PATCH v1 09/11] riscv: selftests: hwprobe: Check rva23u64 consistency Andrew Jones
2026-02-06 0:23 ` [RFC PATCH v1 10/11] riscv: /proc/cpuinfo: Add rva23 bases to output Andrew Jones
2026-02-21 10:52 ` Guodong Xu
2026-02-25 0:08 ` Andrew Jones
2026-03-06 12:47 ` Guodong Xu
2026-03-06 18:34 ` Andrew Jones
2026-02-06 0:23 ` [RFC PATCH v1 11/11] riscv: /proc/cpuinfo: Also output rva20 and rva22 isa bases Andrew Jones
2026-03-05 0:58 ` [RFC PATCH v1 00/11] riscv: hwprobe: Introduce rva23u64 base behavior Charlie Jenkins
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=20260206002349.96740-9-andrew.jones@oss.qualcomm.com \
--to=andrew.jones@oss.qualcomm.com \
--cc=anup@brainfault.org \
--cc=charlie@rivosinc.com \
--cc=cleger@rivosinc.com \
--cc=conor.dooley@microchip.com \
--cc=guodong@riscstar.com \
--cc=kvm-riscv@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=pjw@kernel.org \
--cc=samuel.holland@sifive.com \
--cc=thecharlesjenkins@gmail.com \
/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