[PATCH v2 4/6] riscv: hwprobe: Report Supm only when available
Radim Krčmář
radim.krcmar at oss.qualcomm.com
Tue Nov 10 09:50:46 PST 2026
The RISC-V ISA defines Supm as
"An extension that indicates that there is pointer-masking support
available in user mode, with some facility provided in the application
execution environment to control pointer masking."
Our facility, PR_{SET,GET}_TAGGED_ADDR_CTRL, always returns -EINVAL
unless CONFIG_RISCV_ISA_SUPM is enabled, Supm is present on all harts,
and the user-mode is running in 64-bit mode.
While we technically could advertise Supm even when it only supports
PMLEN=0, it seems a bit more useful to report Supm only in cases where
the userspace can configure non-zero pointer masking.
A minor downside of this approach is that we'll need to update the Supm
detection line when more pointer-masking modes get added.
hwprobe currently reports Supm from the per-hart ISA bitmaps alone, so
it can advertise Supm when the facility always returns -EINVAL.
Report slightly more precise environment to user-mode.
Hiding Supm in compat tasks would add complexity that doesn't seem
justified as 32-bit code has no reason to look at Supm anyway.
Reporting based on the global sysctl toggle isn't done either.
Fixes: 3c2e0aff7b4f ("riscv: hwprobe: Export the Supm ISA extension")
Signed-off-by: Radim Krčmář <radim.krcmar at oss.qualcomm.com>
---
v2:
* Used pmlen helpers from v7.4-rc1 [Guodong]
* Updated commit message to reflect the reasoning
---
arch/riscv/kernel/sys_hwprobe.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/riscv/kernel/sys_hwprobe.c b/arch/riscv/kernel/sys_hwprobe.c
index a9aa1e193840..21738e2539a8 100644
--- a/arch/riscv/kernel/sys_hwprobe.c
+++ b/arch/riscv/kernel/sys_hwprobe.c
@@ -101,6 +101,9 @@ static void hwprobe_isa_ext0(struct riscv_hwprobe *pair,
if (is_user_lpad_enabled())
pair->value |= RISCV_HWPROBE_EXT_ZICFILP;
+ if (riscv_have_user_pmlen(7) || riscv_have_user_pmlen(16))
+ pair->value |= RISCV_HWPROBE_EXT_SUPM;
+
/*
* Loop through and record extensions that 1) anyone has, and 2) anyone
* doesn't have.
@@ -183,9 +186,6 @@ static void hwprobe_isa_ext0(struct riscv_hwprobe *pair,
EXT_KEY(isainfo->isa, ZFH, pair->value, missing);
EXT_KEY(isainfo->isa, ZFHMIN, pair->value, missing);
}
-
- if (IS_ENABLED(CONFIG_RISCV_ISA_SUPM))
- EXT_KEY(isainfo->isa, SUPM, pair->value, missing);
}
/* Now turn off reporting features if any CPU is missing it. */
--
2.55.0
More information about the linux-riscv
mailing list