public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] riscv: cpufeature: Add Supm extension id and validation
@ 2026-01-25  1:36 Guodong Xu
  2026-01-25  1:36 ` [PATCH v2 1/3] dt-bindings: riscv: Add Supm extension description Guodong Xu
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Guodong Xu @ 2026-01-25  1:36 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Samuel Holland,
	Heinrich Schuchardt, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	Alexandre Ghiti, Evan Green, Andrew Jones, Conor Dooley
  Cc: Paul Walmsley, Conor Dooley, devicetree, linux-riscv,
	linux-kernel, Guodong Xu

Supm as an extension indicates pointer-masking support for user mode
(U-mode). It relies on Ssnpm or Smnpm for the underlying hardware
implementation.

Major change in v2 is added dependency check for Supm in bindings.

As a ratified feature, define a dedicated RISCV_ISA_EXT_ id for Supm.
However, since Supm is targeting U-mode, it should not be added into
devicetrees that describe hardware running privileged system softwares.

Supm is implied by Ssnpm (S-mode) or Smnpm (M-mode). Add parsing logic
and validation to ensure this dependency.

When CONFIG_RISCV_ISA_SUPM is disabled, Supm validation will fail
regardless of whether Ssnpm or Smnpm exist. This patchset doesn't change
this behavior.

Prior discussions about how Supm should be handled can be found in Links
[1] and [2].

Link: https://lore.kernel.org/lkml/20260101-legume-engraved-0fae8282cfbe@spud/#r [1]
Link: https://lore.kernel.org/all/4ebbe14b-2579-4ba6-808d-d50c24641d04@sifive.com/#r [2]

Changes in v2:
- Patch 1: Added Supm dependency check.
- Patch 2: Updated the SUPM id number due to rebase conflict.
           Added Reviewed-by from Conor.
- Patch 3: Updated the Fixes tag.
           Added Acked-by from Conor.
- Link to v1: https://lore.kernel.org/r/20260116-supm-ext-id-v1-0-5fcf778ba4a6@riscstar.com

Signed-off-by: Guodong Xu <guodong@riscstar.com>
---
To: Rob Herring <robh@kernel.org>
To: Krzysztof Kozlowski <krzk+dt@kernel.org>
To: Conor Dooley <conor+dt@kernel.org>
To: Paul Walmsley <pjw@kernel.org>
To: Palmer Dabbelt <palmer@dabbelt.com>
To: Albert Ou <aou@eecs.berkeley.edu>
To: Alexandre Ghiti <alex@ghiti.fr>
To: Andrew Jones <ajones@ventanamicro.com>
To: Conor Dooley <conor.dooley@microchip.com>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Conor Dooley <conor@kernel.org>
Cc: devicetree@vger.kernel.org
Cc: linux-riscv@lists.infradead.org
Cc: linux-kernel@vger.kernel.org

---
Guodong Xu (3):
      dt-bindings: riscv: Add Supm extension description
      riscv: cpufeature: Add ISA extension parsing for Supm
      riscv: cpufeature: Clarify ISA spec version for canonical order

 .../devicetree/bindings/riscv/extensions.yaml      | 27 +++++++++++++++
 arch/riscv/include/asm/hwcap.h                     |  3 +-
 arch/riscv/kernel/cpufeature.c                     | 38 ++++++++++++++++++++--
 3 files changed, 63 insertions(+), 5 deletions(-)
---
base-commit: 4af4e95edc37ae54f64cbd75b46f16ce15f3a6b8
change-id: 20260116-supm-ext-id-826e8da4c4b5

Best regards,
-- 
Guodong Xu <guodong@riscstar.com>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 1/3] dt-bindings: riscv: Add Supm extension description
  2026-01-25  1:36 [PATCH v2 0/3] riscv: cpufeature: Add Supm extension id and validation Guodong Xu
@ 2026-01-25  1:36 ` Guodong Xu
  2026-01-28 20:10   ` Conor Dooley
  2026-01-25  1:36 ` [PATCH v2 2/3] riscv: cpufeature: Add ISA extension parsing for Supm Guodong Xu
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 8+ messages in thread
From: Guodong Xu @ 2026-01-25  1:36 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Samuel Holland,
	Heinrich Schuchardt, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	Alexandre Ghiti, Evan Green, Andrew Jones, Conor Dooley
  Cc: Paul Walmsley, Conor Dooley, devicetree, linux-riscv,
	linux-kernel, Guodong Xu

Add description for the Supm extension. Supm indicates support for pointer
masking in user mode. Supm is mandatory for RVA23S64.

Add dependency check that Supm requires either Smnpm or Ssnpm.

The Supm extension is ratified in commit d70011dde6c2 ("Update to ratified
state") of riscv-j-extension.

Signed-off-by: Guodong Xu <guodong@riscstar.com>
---
v2: Add dependency check for Sump.
    Put the check blok after single-letters and before Z*.
---
 .../devicetree/bindings/riscv/extensions.yaml      | 27 ++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/Documentation/devicetree/bindings/riscv/extensions.yaml b/Documentation/devicetree/bindings/riscv/extensions.yaml
index c6ec9290fe07..2b0a8a93bb21 100644
--- a/Documentation/devicetree/bindings/riscv/extensions.yaml
+++ b/Documentation/devicetree/bindings/riscv/extensions.yaml
@@ -262,6 +262,23 @@ properties:
             ratified in RISC-V Profiles Version 1.0, with commit b1d806605f87
             ("Updated to ratified state.")
 
+        - const: supm
+          description: |
+            The standard Supm extension for pointer masking support in user
+            mode (U-mode) as ratified at commit d70011dde6c2 ("Update to
+            ratified state") of riscv-j-extension.
+
+            Supm represents a combination of underlying hardware capability
+            (Smnpm or Ssnpm), U-mode consumer privilege level, and M/S-mode
+            software configuration that enables pointer masking for U-mode.
+
+            DO NOT include this property in device trees targeting privileged
+            system software (S-mode or M-mode).
+
+            This property is only appropriate in device trees provided to
+            U-mode software where the next-higher-privilege-mode supports
+            Smnpm or Ssnpm and enables it for U-mode.
+
         - const: svade
           description: |
             The standard Svade supervisor-level extension for SW-managed PTE A/D
@@ -907,6 +924,16 @@ properties:
         then:
           contains:
             const: b
+      # Supm depends on Smnpm or Ssnpm
+      - if:
+          contains:
+            const: supm
+        then:
+          oneOf:
+            - contains:
+                const: smnpm
+            - contains:
+                const: ssnpm
       # Za64rs and Ziccrse depend on Zalrsc or A
       - if:
           contains:

-- 
2.43.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 2/3] riscv: cpufeature: Add ISA extension parsing for Supm
  2026-01-25  1:36 [PATCH v2 0/3] riscv: cpufeature: Add Supm extension id and validation Guodong Xu
  2026-01-25  1:36 ` [PATCH v2 1/3] dt-bindings: riscv: Add Supm extension description Guodong Xu
@ 2026-01-25  1:36 ` Guodong Xu
  2026-03-08 18:20   ` Samuel Holland
  2026-01-25  1:36 ` [PATCH v2 3/3] riscv: cpufeature: Clarify ISA spec version for canonical order Guodong Xu
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 8+ messages in thread
From: Guodong Xu @ 2026-01-25  1:36 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Samuel Holland,
	Heinrich Schuchardt, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	Alexandre Ghiti, Evan Green, Andrew Jones, Conor Dooley
  Cc: Paul Walmsley, Conor Dooley, devicetree, linux-riscv,
	linux-kernel, Guodong Xu

Supm has been ratified in the RISC-V Pointer Masking specification
(Version 1.0, 10/2024) and is mandated in RVA23 Profiles (Version 1.0,
2024-10-17) for RVA23U64. Supm indicates userspace pointer masking
support.

Remove the previous macro aliasing of Supm to Ssnpm/Smnpm in hwcap.h,
treating Supm as a distinct RISC-V ISA extension ID.

Add ISA parsing logic for Supm, and implement a validator to ensure
that Supm is only reported as available if Kconfig allows it and the
underlying Ssnpm (for supervisor mode) or Smnpm (for machine mode)
extension is present. Supm relies on Ssnpm or Smnpm to provide the
underlying hardware implementation.

With this change, "supm" will be reported (when available) in
/proc/cpuinfo as part of the "isa" and "hart isa" string.

Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Link: https://lore.kernel.org/lkml/20260101-legume-engraved-0fae8282cfbe@spud/#r [1]
Link: https://lore.kernel.org/all/4ebbe14b-2579-4ba6-808d-d50c24641d04@sifive.com/#r [2]
Signed-off-by: Guodong Xu <guodong@riscstar.com>
---
v2: Add Reviewed-by from Conor.
    Update RISCV_ISA_EXT_SUPM id to solve rebase conflict.
---
 arch/riscv/include/asm/hwcap.h |  3 +--
 arch/riscv/kernel/cpufeature.c | 35 +++++++++++++++++++++++++++++++++--
 2 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/arch/riscv/include/asm/hwcap.h b/arch/riscv/include/asm/hwcap.h
index 7ef8e5f55c8d..aa2af21f3bd3 100644
--- a/arch/riscv/include/asm/hwcap.h
+++ b/arch/riscv/include/asm/hwcap.h
@@ -112,6 +112,7 @@
 #define RISCV_ISA_EXT_ZCLSD		103
 #define RISCV_ISA_EXT_ZICFILP		104
 #define RISCV_ISA_EXT_ZICFISS		105
+#define RISCV_ISA_EXT_SUPM		106
 
 #define RISCV_ISA_EXT_XLINUXENVCFG	127
 
@@ -120,10 +121,8 @@
 
 #ifdef CONFIG_RISCV_M_MODE
 #define RISCV_ISA_EXT_SxAIA		RISCV_ISA_EXT_SMAIA
-#define RISCV_ISA_EXT_SUPM		RISCV_ISA_EXT_SMNPM
 #else
 #define RISCV_ISA_EXT_SxAIA		RISCV_ISA_EXT_SSAIA
-#define RISCV_ISA_EXT_SUPM		RISCV_ISA_EXT_SSNPM
 #endif
 
 #endif /* _ASM_RISCV_HWCAP_H */
diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c
index 1734f9a4c2fd..e1f7ad882289 100644
--- a/arch/riscv/kernel/cpufeature.c
+++ b/arch/riscv/kernel/cpufeature.c
@@ -317,6 +317,27 @@ static int riscv_cfiss_validate(const struct riscv_isa_ext_data *data,
 	return 0;
 }
 
+static int riscv_ext_supm_validate(const struct riscv_isa_ext_data *data,
+				   const unsigned long *isa_bitmap)
+{
+	if (!IS_ENABLED(CONFIG_RISCV_ISA_SUPM))
+		return -EINVAL;
+
+	/*
+	 * Supm requires Ssnpm for S-mode or Smnpm for M-mode to provide
+	 * pointer masking for the U-mode execution environment.
+	 */
+	if (IS_ENABLED(CONFIG_RISCV_M_MODE)) {
+		if (__riscv_isa_extension_available(isa_bitmap, RISCV_ISA_EXT_SMNPM))
+			return 0;
+	} else {
+		if (__riscv_isa_extension_available(isa_bitmap, RISCV_ISA_EXT_SSNPM))
+			return 0;
+	}
+
+	return -EPROBE_DEFER;
+}
+
 static const unsigned int riscv_a_exts[] = {
 	RISCV_ISA_EXT_ZAAMO,
 	RISCV_ISA_EXT_ZALRSC,
@@ -450,6 +471,15 @@ static const unsigned int riscv_c_exts[] = {
 	RISCV_ISA_EXT_ZCD,
 };
 
+/*
+ * Smnpm and Ssnpm provide pointer masking for the next lower privilege mode
+ * (U-mode), thus enabling Supm. Both extensions imply the same subset.
+ */
+static const unsigned int riscv_supm_exts[] = {
+	RISCV_ISA_EXT_XLINUXENVCFG,
+	RISCV_ISA_EXT_SUPM
+};
+
 /*
  * The canonical order of ISA extension names in the ISA string is defined in
  * chapter 27 of the unprivileged specification.
@@ -577,12 +607,13 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = {
 	__RISCV_ISA_EXT_DATA_VALIDATE(zvkt, RISCV_ISA_EXT_ZVKT, riscv_ext_vector_crypto_validate),
 	__RISCV_ISA_EXT_DATA(smaia, RISCV_ISA_EXT_SMAIA),
 	__RISCV_ISA_EXT_DATA(smmpm, RISCV_ISA_EXT_SMMPM),
-	__RISCV_ISA_EXT_SUPERSET(smnpm, RISCV_ISA_EXT_SMNPM, riscv_xlinuxenvcfg_exts),
+	__RISCV_ISA_EXT_SUPERSET(smnpm, RISCV_ISA_EXT_SMNPM, riscv_supm_exts),
 	__RISCV_ISA_EXT_DATA(smstateen, RISCV_ISA_EXT_SMSTATEEN),
 	__RISCV_ISA_EXT_DATA(ssaia, RISCV_ISA_EXT_SSAIA),
 	__RISCV_ISA_EXT_DATA(sscofpmf, RISCV_ISA_EXT_SSCOFPMF),
-	__RISCV_ISA_EXT_SUPERSET(ssnpm, RISCV_ISA_EXT_SSNPM, riscv_xlinuxenvcfg_exts),
+	__RISCV_ISA_EXT_SUPERSET(ssnpm, RISCV_ISA_EXT_SSNPM, riscv_supm_exts),
 	__RISCV_ISA_EXT_DATA(sstc, RISCV_ISA_EXT_SSTC),
+	__RISCV_ISA_EXT_DATA_VALIDATE(supm, RISCV_ISA_EXT_SUPM, riscv_ext_supm_validate),
 	__RISCV_ISA_EXT_DATA(svade, RISCV_ISA_EXT_SVADE),
 	__RISCV_ISA_EXT_DATA_VALIDATE(svadu, RISCV_ISA_EXT_SVADU, riscv_ext_svadu_validate),
 	__RISCV_ISA_EXT_DATA(svinval, RISCV_ISA_EXT_SVINVAL),

-- 
2.43.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 3/3] riscv: cpufeature: Clarify ISA spec version for canonical order
  2026-01-25  1:36 [PATCH v2 0/3] riscv: cpufeature: Add Supm extension id and validation Guodong Xu
  2026-01-25  1:36 ` [PATCH v2 1/3] dt-bindings: riscv: Add Supm extension description Guodong Xu
  2026-01-25  1:36 ` [PATCH v2 2/3] riscv: cpufeature: Add ISA extension parsing for Supm Guodong Xu
@ 2026-01-25  1:36 ` Guodong Xu
  2026-03-06 18:05 ` (subset) [PATCH v2 0/3] riscv: cpufeature: Add Supm extension id and validation Conor Dooley
  2026-04-30  3:25 ` patchwork-bot+linux-riscv
  4 siblings, 0 replies; 8+ messages in thread
From: Guodong Xu @ 2026-01-25  1:36 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Samuel Holland,
	Heinrich Schuchardt, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	Alexandre Ghiti, Evan Green, Andrew Jones, Conor Dooley
  Cc: Paul Walmsley, Conor Dooley, devicetree, linux-riscv,
	linux-kernel, Guodong Xu

Specify that chapter 27 refers to version 20191213 of the RISC-V ISA
Unprivileged Architecture. The chapter numbering differs across
specification versions - for example, in version 20250508, the ISA
Extension Naming Conventions is chapter 36, not chapter 27.

Historical versions of the RISC-V specification can be found via Link [1].

Acked-by: Conor Dooley <conor.dooley@microchip.com>
Link: https://riscv.org/specifications/ratified/ [1]
Fixes: 99e2266f2460 ("RISC-V: clarify ISA string ordering rules in cpu.c")
Signed-off-by: Guodong Xu <guodong@riscstar.com>
---
v2: Add Acked-by from Conor.
    Update the Fixes tag to point to the original commit who added the
     description.
---
 arch/riscv/kernel/cpufeature.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c
index e1f7ad882289..63ad6393b2c6 100644
--- a/arch/riscv/kernel/cpufeature.c
+++ b/arch/riscv/kernel/cpufeature.c
@@ -482,7 +482,8 @@ static const unsigned int riscv_supm_exts[] = {
 
 /*
  * The canonical order of ISA extension names in the ISA string is defined in
- * chapter 27 of the unprivileged specification.
+ * Chapter 27 of the RISC-V Instruction Set Manual Volume I Unprivileged ISA
+ * (Document Version 20191213).
  *
  * Ordinarily, for in-kernel data structures, this order is unimportant but
  * isa_ext_arr defines the order of the ISA string in /proc/cpuinfo.

-- 
2.43.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 1/3] dt-bindings: riscv: Add Supm extension description
  2026-01-25  1:36 ` [PATCH v2 1/3] dt-bindings: riscv: Add Supm extension description Guodong Xu
@ 2026-01-28 20:10   ` Conor Dooley
  0 siblings, 0 replies; 8+ messages in thread
From: Conor Dooley @ 2026-01-28 20:10 UTC (permalink / raw)
  To: Guodong Xu
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Samuel Holland,
	Heinrich Schuchardt, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	Alexandre Ghiti, Evan Green, Andrew Jones, Conor Dooley,
	Paul Walmsley, devicetree, linux-riscv, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2896 bytes --]

On Sun, Jan 25, 2026 at 09:36:06AM +0800, Guodong Xu wrote:
> Add description for the Supm extension. Supm indicates support for pointer
> masking in user mode. Supm is mandatory for RVA23S64.
> 
> Add dependency check that Supm requires either Smnpm or Ssnpm.
> 
> The Supm extension is ratified in commit d70011dde6c2 ("Update to ratified
> state") of riscv-j-extension.
> 
> Signed-off-by: Guodong Xu <guodong@riscstar.com>

FWIW, this is missing my 6.20/7.0 (whichever it ends up being) PR cos
I'd like some other folks to look at the series. If Paul/Palmer are
happy with it though,
Acked-by: Conor Dooley <conor.dooley@microchip.com>

Cheers,
Conor.

> ---
> v2: Add dependency check for Sump.
>     Put the check blok after single-letters and before Z*.
> ---
>  .../devicetree/bindings/riscv/extensions.yaml      | 27 ++++++++++++++++++++++
>  1 file changed, 27 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/riscv/extensions.yaml b/Documentation/devicetree/bindings/riscv/extensions.yaml
> index c6ec9290fe07..2b0a8a93bb21 100644
> --- a/Documentation/devicetree/bindings/riscv/extensions.yaml
> +++ b/Documentation/devicetree/bindings/riscv/extensions.yaml
> @@ -262,6 +262,23 @@ properties:
>              ratified in RISC-V Profiles Version 1.0, with commit b1d806605f87
>              ("Updated to ratified state.")
>  
> +        - const: supm
> +          description: |
> +            The standard Supm extension for pointer masking support in user
> +            mode (U-mode) as ratified at commit d70011dde6c2 ("Update to
> +            ratified state") of riscv-j-extension.
> +
> +            Supm represents a combination of underlying hardware capability
> +            (Smnpm or Ssnpm), U-mode consumer privilege level, and M/S-mode
> +            software configuration that enables pointer masking for U-mode.
> +
> +            DO NOT include this property in device trees targeting privileged
> +            system software (S-mode or M-mode).
> +
> +            This property is only appropriate in device trees provided to
> +            U-mode software where the next-higher-privilege-mode supports
> +            Smnpm or Ssnpm and enables it for U-mode.
> +
>          - const: svade
>            description: |
>              The standard Svade supervisor-level extension for SW-managed PTE A/D
> @@ -907,6 +924,16 @@ properties:
>          then:
>            contains:
>              const: b
> +      # Supm depends on Smnpm or Ssnpm
> +      - if:
> +          contains:
> +            const: supm
> +        then:
> +          oneOf:
> +            - contains:
> +                const: smnpm
> +            - contains:
> +                const: ssnpm
>        # Za64rs and Ziccrse depend on Zalrsc or A
>        - if:
>            contains:
> 
> -- 
> 2.43.0
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: (subset) [PATCH v2 0/3] riscv: cpufeature: Add Supm extension id and validation
  2026-01-25  1:36 [PATCH v2 0/3] riscv: cpufeature: Add Supm extension id and validation Guodong Xu
                   ` (2 preceding siblings ...)
  2026-01-25  1:36 ` [PATCH v2 3/3] riscv: cpufeature: Clarify ISA spec version for canonical order Guodong Xu
@ 2026-03-06 18:05 ` Conor Dooley
  2026-04-30  3:25 ` patchwork-bot+linux-riscv
  4 siblings, 0 replies; 8+ messages in thread
From: Conor Dooley @ 2026-03-06 18:05 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Samuel Holland,
	Heinrich Schuchardt, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	Alexandre Ghiti, Evan Green, Andrew Jones, Guodong Xu
  Cc: conor, Conor Dooley, Paul Walmsley, devicetree, linux-riscv,
	linux-kernel

From: Conor Dooley <conor.dooley@microchip.com>

On Sun, 25 Jan 2026 09:36:05 +0800, Guodong Xu wrote:
> Supm as an extension indicates pointer-masking support for user mode
> (U-mode). It relies on Ssnpm or Smnpm for the underlying hardware
> implementation.
> 
> Major change in v2 is added dependency check for Supm in bindings.
> 
> As a ratified feature, define a dedicated RISCV_ISA_EXT_ id for Supm.
> However, since Supm is targeting U-mode, it should not be added into
> devicetrees that describe hardware running privileged system softwares.
> 
> [...]

Applied to riscv-dt-for-next, thanks!

[1/3] dt-bindings: riscv: Add Supm extension description
      https://git.kernel.org/conor/c/5932c871e067

Thanks,
Conor.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 2/3] riscv: cpufeature: Add ISA extension parsing for Supm
  2026-01-25  1:36 ` [PATCH v2 2/3] riscv: cpufeature: Add ISA extension parsing for Supm Guodong Xu
@ 2026-03-08 18:20   ` Samuel Holland
  0 siblings, 0 replies; 8+ messages in thread
From: Samuel Holland @ 2026-03-08 18:20 UTC (permalink / raw)
  To: Guodong Xu
  Cc: Paul Walmsley, Conor Dooley, devicetree, linux-riscv,
	linux-kernel, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Heinrich Schuchardt, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	Alexandre Ghiti, Evan Green, Andrew Jones, Conor Dooley

Hi Guodong,

On 2026-01-24 7:36 PM, Guodong Xu wrote:
> Supm has been ratified in the RISC-V Pointer Masking specification
> (Version 1.0, 10/2024) and is mandated in RVA23 Profiles (Version 1.0,
> 2024-10-17) for RVA23U64. Supm indicates userspace pointer masking
> support.
> 
> Remove the previous macro aliasing of Supm to Ssnpm/Smnpm in hwcap.h,
> treating Supm as a distinct RISC-V ISA extension ID.
> 
> Add ISA parsing logic for Supm, and implement a validator to ensure
> that Supm is only reported as available if Kconfig allows it and the
> underlying Ssnpm (for supervisor mode) or Smnpm (for machine mode)
> extension is present. Supm relies on Ssnpm or Smnpm to provide the
> underlying hardware implementation.
> 
> With this change, "supm" will be reported (when available) in
> /proc/cpuinfo as part of the "isa" and "hart isa" string.
> 
> Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
> Link: https://lore.kernel.org/lkml/20260101-legume-engraved-0fae8282cfbe@spud/#r [1]
> Link: https://lore.kernel.org/all/4ebbe14b-2579-4ba6-808d-d50c24641d04@sifive.com/#r [2]
> Signed-off-by: Guodong Xu <guodong@riscstar.com>
> ---
> v2: Add Reviewed-by from Conor.
>     Update RISCV_ISA_EXT_SUPM id to solve rebase conflict.
> ---
>  arch/riscv/include/asm/hwcap.h |  3 +--
>  arch/riscv/kernel/cpufeature.c | 35 +++++++++++++++++++++++++++++++++--
>  2 files changed, 34 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/riscv/include/asm/hwcap.h b/arch/riscv/include/asm/hwcap.h
> index 7ef8e5f55c8d..aa2af21f3bd3 100644
> --- a/arch/riscv/include/asm/hwcap.h
> +++ b/arch/riscv/include/asm/hwcap.h
> @@ -112,6 +112,7 @@
>  #define RISCV_ISA_EXT_ZCLSD		103
>  #define RISCV_ISA_EXT_ZICFILP		104
>  #define RISCV_ISA_EXT_ZICFISS		105
> +#define RISCV_ISA_EXT_SUPM		106
>  
>  #define RISCV_ISA_EXT_XLINUXENVCFG	127
>  
> @@ -120,10 +121,8 @@
>  
>  #ifdef CONFIG_RISCV_M_MODE
>  #define RISCV_ISA_EXT_SxAIA		RISCV_ISA_EXT_SMAIA
> -#define RISCV_ISA_EXT_SUPM		RISCV_ISA_EXT_SMNPM
>  #else
>  #define RISCV_ISA_EXT_SxAIA		RISCV_ISA_EXT_SSAIA
> -#define RISCV_ISA_EXT_SUPM		RISCV_ISA_EXT_SSNPM
>  #endif
>  
>  #endif /* _ASM_RISCV_HWCAP_H */
> diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c
> index 1734f9a4c2fd..e1f7ad882289 100644
> --- a/arch/riscv/kernel/cpufeature.c
> +++ b/arch/riscv/kernel/cpufeature.c
> @@ -317,6 +317,27 @@ static int riscv_cfiss_validate(const struct riscv_isa_ext_data *data,
>  	return 0;
>  }
>  
> +static int riscv_ext_supm_validate(const struct riscv_isa_ext_data *data,
> +				   const unsigned long *isa_bitmap)
> +{
> +	if (!IS_ENABLED(CONFIG_RISCV_ISA_SUPM))
> +		return -EINVAL;
> +
> +	/*
> +	 * Supm requires Ssnpm for S-mode or Smnpm for M-mode to provide
> +	 * pointer masking for the U-mode execution environment.
> +	 */
> +	if (IS_ENABLED(CONFIG_RISCV_M_MODE)) {
> +		if (__riscv_isa_extension_available(isa_bitmap, RISCV_ISA_EXT_SMNPM))
> +			return 0;
> +	} else {
> +		if (__riscv_isa_extension_available(isa_bitmap, RISCV_ISA_EXT_SSNPM))
> +			return 0;
> +	}
> +
> +	return -EPROBE_DEFER;
> +}
> +
>  static const unsigned int riscv_a_exts[] = {
>  	RISCV_ISA_EXT_ZAAMO,
>  	RISCV_ISA_EXT_ZALRSC,
> @@ -450,6 +471,15 @@ static const unsigned int riscv_c_exts[] = {
>  	RISCV_ISA_EXT_ZCD,
>  };
>  
> +/*
> + * Smnpm and Ssnpm provide pointer masking for the next lower privilege mode
> + * (U-mode), thus enabling Supm. Both extensions imply the same subset.

If Linux is running in S-mode, then Smnpm does _not_ imply Supm. So this list
cannot be shared between Ssnpm and Smnpm. (When running Linux in M-mode, I think
we assume S-mode isn't supported, so the opposite case isn't possible. If you do
run M-mode Linux on M/S/U hardware, I think there are other things that explode
spectacularly, since we will touch for example the wrong envcfg register.)

> + */
> +static const unsigned int riscv_supm_exts[] = {
> +	RISCV_ISA_EXT_XLINUXENVCFG,
> +	RISCV_ISA_EXT_SUPM
> +};
> +
>  /*
>   * The canonical order of ISA extension names in the ISA string is defined in
>   * chapter 27 of the unprivileged specification.
> @@ -577,12 +607,13 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = {
>  	__RISCV_ISA_EXT_DATA_VALIDATE(zvkt, RISCV_ISA_EXT_ZVKT, riscv_ext_vector_crypto_validate),
>  	__RISCV_ISA_EXT_DATA(smaia, RISCV_ISA_EXT_SMAIA),
>  	__RISCV_ISA_EXT_DATA(smmpm, RISCV_ISA_EXT_SMMPM),
> -	__RISCV_ISA_EXT_SUPERSET(smnpm, RISCV_ISA_EXT_SMNPM, riscv_xlinuxenvcfg_exts),
> +	__RISCV_ISA_EXT_SUPERSET(smnpm, RISCV_ISA_EXT_SMNPM, riscv_supm_exts),
>  	__RISCV_ISA_EXT_DATA(smstateen, RISCV_ISA_EXT_SMSTATEEN),
>  	__RISCV_ISA_EXT_DATA(ssaia, RISCV_ISA_EXT_SSAIA),
>  	__RISCV_ISA_EXT_DATA(sscofpmf, RISCV_ISA_EXT_SSCOFPMF),
> -	__RISCV_ISA_EXT_SUPERSET(ssnpm, RISCV_ISA_EXT_SSNPM, riscv_xlinuxenvcfg_exts),
> +	__RISCV_ISA_EXT_SUPERSET(ssnpm, RISCV_ISA_EXT_SSNPM, riscv_supm_exts),
>  	__RISCV_ISA_EXT_DATA(sstc, RISCV_ISA_EXT_SSTC),
> +	__RISCV_ISA_EXT_DATA_VALIDATE(supm, RISCV_ISA_EXT_SUPM, riscv_ext_supm_validate),

I don't think this quite matches what we want either. We don't want to accept
Supm from the devicetree at all, so it shouldn't be in this array (just like
Xlinuxenvcfg is not in this array). You'll need new code in riscv_resolve_isa()
(or its callers) to set the RISCV_ISA_EXT_SUPM bit under the right conditions.

Regards,
Samuel

>  	__RISCV_ISA_EXT_DATA(svade, RISCV_ISA_EXT_SVADE),
>  	__RISCV_ISA_EXT_DATA_VALIDATE(svadu, RISCV_ISA_EXT_SVADU, riscv_ext_svadu_validate),
>  	__RISCV_ISA_EXT_DATA(svinval, RISCV_ISA_EXT_SVINVAL),
> 


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 0/3] riscv: cpufeature: Add Supm extension id and validation
  2026-01-25  1:36 [PATCH v2 0/3] riscv: cpufeature: Add Supm extension id and validation Guodong Xu
                   ` (3 preceding siblings ...)
  2026-03-06 18:05 ` (subset) [PATCH v2 0/3] riscv: cpufeature: Add Supm extension id and validation Conor Dooley
@ 2026-04-30  3:25 ` patchwork-bot+linux-riscv
  4 siblings, 0 replies; 8+ messages in thread
From: patchwork-bot+linux-riscv @ 2026-04-30  3:25 UTC (permalink / raw)
  To: Guodong Xu
  Cc: linux-riscv, robh, krzk+dt, conor+dt, samuel.holland,
	heinrich.schuchardt, pjw, palmer, aou, alex, evan, ajones,
	conor.dooley, paul.walmsley, conor, devicetree, linux-kernel

Hello:

This series was applied to riscv/linux.git (fixes)
by Conor Dooley <conor.dooley@microchip.com>:

On Sun, 25 Jan 2026 09:36:05 +0800 you wrote:
> Supm as an extension indicates pointer-masking support for user mode
> (U-mode). It relies on Ssnpm or Smnpm for the underlying hardware
> implementation.
> 
> Major change in v2 is added dependency check for Supm in bindings.
> 
> As a ratified feature, define a dedicated RISCV_ISA_EXT_ id for Supm.
> However, since Supm is targeting U-mode, it should not be added into
> devicetrees that describe hardware running privileged system softwares.
> 
> [...]

Here is the summary with links:
  - [v2,1/3] dt-bindings: riscv: Add Supm extension description
    https://git.kernel.org/riscv/c/feb5dba31a36
  - [v2,2/3] riscv: cpufeature: Add ISA extension parsing for Supm
    (no matching commit)
  - [v2,3/3] riscv: cpufeature: Clarify ISA spec version for canonical order
    (no matching commit)

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-04-30  3:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-25  1:36 [PATCH v2 0/3] riscv: cpufeature: Add Supm extension id and validation Guodong Xu
2026-01-25  1:36 ` [PATCH v2 1/3] dt-bindings: riscv: Add Supm extension description Guodong Xu
2026-01-28 20:10   ` Conor Dooley
2026-01-25  1:36 ` [PATCH v2 2/3] riscv: cpufeature: Add ISA extension parsing for Supm Guodong Xu
2026-03-08 18:20   ` Samuel Holland
2026-01-25  1:36 ` [PATCH v2 3/3] riscv: cpufeature: Clarify ISA spec version for canonical order Guodong Xu
2026-03-06 18:05 ` (subset) [PATCH v2 0/3] riscv: cpufeature: Add Supm extension id and validation Conor Dooley
2026-04-30  3:25 ` patchwork-bot+linux-riscv

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox