[PATCH 4/6] riscv: hwprobe: Report Supm only when available

From: Radim Krčmář

Date: Tue Oct 06 2026 - 03:58:02 EST


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 always returns -EINVAL unless Supm support is configured,
the pointer masking ISA extension is globally present, and the user-mode
is running in 64-bit 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 a global sysctl toggle isn't done.

Do not report Supm when some harts lack the extension, because it's not
available on any hart in that case.

(Reporting Supm when only PMLEN=0 is supported isn't great, but doesn't
violate the text of the extension and we ought to have Supm7 and Supm16
extensions if we care about precision.)

Fixes: 3c2e0aff7b4f ("riscv: hwprobe: Export the Supm ISA extension")
Signed-off-by: Radim Krčmář <radim.krcmar@xxxxxxxxxxxxxxxx>
---
The compat hiding and global sysctl toggle better fit in Andy's series.

arch/riscv/kernel/sys_hwprobe.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/arch/riscv/kernel/sys_hwprobe.c b/arch/riscv/kernel/sys_hwprobe.c
index 477d8fd780a6..9a864e050acf 100644
--- a/arch/riscv/kernel/sys_hwprobe.c
+++ b/arch/riscv/kernel/sys_hwprobe.c
@@ -101,6 +101,10 @@ static void hwprobe_isa_ext0(struct riscv_hwprobe *pair,
if (is_user_lpad_enabled())
pair->value |= RISCV_HWPROBE_EXT_ZICFILP;

+ if (IS_ENABLED(CONFIG_RISCV_ISA_SUPM) &&
+ riscv_isa_extension_available(NULL, SUPM))
+ pair->value |= RISCV_HWPROBE_EXT_SUPM;
+
/*
* Loop through and record extensions that 1) anyone has, and 2) anyone
* doesn't have.
@@ -183,9 +187,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