Skip to contentSkip to conversation

dt-bindings: riscv: Add RISC-V Worlds and SiFive WorldGuard DT bindings

RFC PATCH Superseded Yu-Chien Peter Lin 4 participants 19 messages Jun 19 – Jul 29

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover dt-bindings: riscv: Add RISC-V Worlds and SiFive WorldGuard DT bindings

Add device tree bindings for RISC-V Worlds, a standard extension that tags every transaction with a World ID for fine-grained isolation. SiFive's WorldGuard Checker is a hardware firewall in the system interconnect that inspects transaction WIDs and enforces per-World access policies on memory and MMIO devices.

The three patches add: Worlds ISA extension properties (riscv,nworlds and sifive,trustedwid on /cpus), per-hart World ID constraints (riscv,pmwid, riscv,pmwidlist, riscv,pmlwidlist on cpu@X nodes), and the wgchecker2 binding with access-controller specifiers.

The access-controllers specifier carries range, permission and config fields to support three use cases:
1. single range device protection
2. discontiguous range device protection
3. sub-range memory partitioning.

Yu-Chien Peter Lin (3):
dt-bindings: riscv: Add Worlds ISA extensions
dt-bindings: riscv: Add Worlds per-hart properties
dt-bindings: sifive: Add WorldGuard Checker

 .../devicetree/bindings/riscv/cpus.yaml       |  21 ++
 .../devicetree/bindings/riscv/extensions.yaml |  29 +++
 .../devicetree/bindings/riscv/worlds.yaml     |  86 +++++++
 .../bindings/sifive/sifive,wgchecker2.yaml    | 237 ++++++++++++++++++
 4 files changed, 373 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/riscv/worlds.yaml
 create mode 100644 Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml
Signature · 1 line
2.43.7
#1 lore raw

RFC PATCH 1/3 dt-bindings: riscv: Add Worlds ISA extensions

Add DT bindings for RISC-V Worlds ISA extensions to tag transactions with World IDs that hardware uses to enforce world-based isolation across execution contexts.

---
 .../devicetree/bindings/riscv/extensions.yaml | 29 +++++++++++++++++++
 1 file changed, 29 insertions(+)
Documentation/devicetree/bindings/riscv/extensions.yaml +29 -0
index 2b0a8a93bb21..1bc8b1aa67c0 100644
@@ -193,12 +193,35 @@ properties:
             ratified at commit d70011dde6c2 ("Update to ratified state")
             of riscv-j-extension.
 
+        - const: smlwid
+          description: |
+            The standard Smlwid extension for M-mode control of lower
+            privilege World ID via the mlwid CSR as ratified at commit
+            TBD ("TBD") of riscv-worlds.
+
+        - const: smlwidlist
+          description: |
+            The standard Smlwidlist extension for M-mode control of lower
+            privilege World IDs via the mlwidlist CSR as ratified at commit
+            TBD ("TBD") of riscv-worlds.
+
         - const: smstateen
           description: |
             The standard Smstateen extension for controlling access to CSRs
             added by other RISC-V extensions in H/S/VS/U/VU modes and as
             ratified at commit a28bfae (Ratified (#7)) of riscv-state-enable.
 
+        - const: smwdeleg
+          description: |
+            The standard Smwdeleg extension for M-mode delegation of lower
+            privilege World ID control to S-mode via the mwiddeleg CSR, as
+            ratified at commit TBD ("TBD") of riscv-worlds.
+
+        - const: smwid
+          description: |
+            The standard Smwid extension for M-mode World ID control via the
+            mwid CSR as ratified at commit TBD ("TBD") of riscv-worlds.
+
         - const: ssaia
           description: |
             The standard Ssaia supervisor-level extension for the advanced
@@ -262,6 +285,12 @@ properties:
             ratified in RISC-V Profiles Version 1.0, with commit b1d806605f87
             ("Updated to ratified state.")
 
+        - const: sswid
+          description: |
+            The standard Sswid extension for S-mode control of lower
+            privilege World IDs via the slwid CSR as ratified at commit
+            TBD ("TBD") of riscv-worlds.
+
         - const: supm
           description: |
             The standard Supm extension for pointer masking support in user
Signature · 1 line
2.43.7
#2 lore raw

Re: [RFC PATCH 1/3] dt-bindings: riscv: Add Worlds ISA extensions

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Medium] The descriptions for the newly added RISC-V Worlds ISA extensions use placeholder 'TBD' text…

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] The descriptions for the newly added RISC-V Worlds ISA extensions use placeholder 'TBD' text instead of a valid specification commit hash.
- [Low] The newly added multi-letter ISA extensions smlwid and smlwidlist are not sorted alphanumerically.
--

commit 16fbfa5650f850f6481cd820aa9d7deb379f7452
Author: Yu-Chien Peter Lin <[email protected]>

dt-bindings: riscv: Add Worlds ISA extensions

This commit adds device tree bindings for the RISC-V Worlds ISA extensions. These extensions are used to tag transactions with World IDs that hardware uses to enforce isolation across execution contexts.

Documentation/devicetree/bindings/riscv/extensions.yaml properties: · line 196

Quoted 9 lines
Documentation/devicetree/bindings/riscv/extensions.yaml +1 -0
index 2b0a8a93bb214..1bc8b1aa67c06 100644
@@ -193,12 +193,35 @@ properties:
             ratified at commit d70011dde6c2 ("Update to ratified state")
             of riscv-j-extension.
 
+        - const: smlwid

[Severity: Low]
This isn't a bug, but are these extensions placed in the correct alphabetical order? Multi-letter extensions are typically required to be sorted alphanumerically, and "smlwid" appears to be inserted out of order relative to other "sm" extensions.

Documentation/devicetree/bindings/riscv/extensions.yaml properties: · line 200

Quoted 4 lines
Documentation/devicetree/bindings/riscv/extensions.yaml +4 -0
+          description: |
+            The standard Smlwid extension for M-mode control of lower
+            privilege World ID via the mlwid CSR as ratified at commit
+            TBD ("TBD") of riscv-worlds.

[Severity: Medium]
Is the "TBD" placeholder intended to be kept in the final binding? Device tree bindings usually require a specific commit hash to reference a frozen or ratified specification.

Documentation/devicetree/bindings/riscv/extensions.yaml properties: · line 206

Quoted 6 lines
Documentation/devicetree/bindings/riscv/extensions.yaml +6 -0
+
+        - const: smlwidlist
+          description: |
+            The standard Smlwidlist extension for M-mode control of lower
+            privilege World IDs via the mlwidlist CSR as ratified at commit
+            TBD ("TBD") of riscv-worlds.

[Severity: Medium]
Does this also need to be updated with the actual ratification commit hash instead of the placeholder?

Documentation/devicetree/bindings/riscv/extensions.yaml properties: · line 218

Quoted 12 lines
Documentation/devicetree/bindings/riscv/extensions.yaml +6 -0
+
         - const: smstateen
           description: |
             The standard Smstateen extension for controlling access to CSRs
             added by other RISC-V extensions in H/S/VS/U/VU modes and as
             ratified at commit a28bfae (Ratified (#7)) of riscv-state-enable.
 
+        - const: smwdeleg
+          description: |
+            The standard Smwdeleg extension for M-mode delegation of lower
+            privilege World ID control to S-mode via the mwiddeleg CSR, as
+            ratified at commit TBD ("TBD") of riscv-worlds.

[Severity: Medium]
Is the exact specification commit hash available to replace the placeholder text here?

Documentation/devicetree/bindings/riscv/extensions.yaml properties: · line 223

Quoted 5 lines
Documentation/devicetree/bindings/riscv/extensions.yaml +5 -0
+
+        - const: smwid
+          description: |
+            The standard Smwid extension for M-mode World ID control via the
+            mwid CSR as ratified at commit TBD ("TBD") of riscv-worlds.

[Severity: Medium]
Can we include the specific commit hash of riscv-worlds here instead of using the temporary text?

[ ... ]

Documentation/devicetree/bindings/riscv/extensions.yaml properties: · line 292

Quoted 9 lines
Documentation/devicetree/bindings/riscv/extensions.yaml +5 -0
@@ -262,6 +285,12 @@ properties:
             ratified in RISC-V Profiles Version 1.0, with commit b1d806605f87
             ("Updated to ratified state.")
 
+        - const: sswid
+          description: |
+            The standard Sswid extension for S-mode control of lower
+            privilege World IDs via the slwid CSR as ratified at commit
+            TBD ("TBD") of riscv-worlds.

[Severity: Medium]
Is the placeholder expected to be replaced with the actual ratification commit before this is merged?

Quoted 4 lines
Documentation/devicetree/bindings/riscv/extensions.yaml +1 -0
+
         - const: supm
           description: |
             The standard Supm extension for pointer masking support in user
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#3 lore raw

RFC PATCH 2/3 dt-bindings: riscv: Add Worlds per-hart properties

In reply to Yu-Chien Peter Lin

Add per-hart DT properties for RISC-V Worlds architecture:
riscv,pmwid, riscv,pmwidlist, and riscv,pmlwidlist. These platform-defined values are primarily used by M-mode firmware to configure World ID CSRs and restrict WID usage across privilege levels.

---
 .../devicetree/bindings/riscv/cpus.yaml       | 21 +++++
 .../devicetree/bindings/riscv/worlds.yaml     | 77 +++++++++++++++++++
 2 files changed, 98 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/riscv/worlds.yaml
Documentation/devicetree/bindings/riscv/cpus.yaml +21 -0
index 5feeb2203050..4b5778b6d3e7 100644
@@ -26,6 +26,7 @@ description: |
 allOf:
   - $ref: /schemas/cpu.yaml#
   - $ref: extensions.yaml
+  - $ref: worlds.yaml
   - if:
       not:
         properties:
@@ -120,11 +121,31 @@ properties:
       thead systems where the vector register length is not identical on all harts, or
       the vlenb CSR is not available.
 
+  riscv,pmwid:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      Platform-defined M-mode World ID (WID) assigned to this hart.
+    minimum: 0
+    maximum: 63
+
+  riscv,pmwidlist:
+    $ref: /schemas/types.yaml#/definitions/uint64
+    description:
+      Platform-defined bitmap of M-mode World IDs (WIDs) that this hart may use.
+
+  riscv,pmlwidlist:
+    $ref: /schemas/types.yaml#/definitions/uint64
+    description:
+      Platform-defined bitmap of World IDs (WIDs) that S-mode and U-mode may use
+      on this hart.
+
   # RISC-V has multiple properties for cache op block sizes as the sizes
   # differ between individual CBO extensions
   cache-op-block-size: false
   # RISC-V requires 'timebase-frequency' in /cpus, so disallow it here
   timebase-frequency: false
+  # RISC-V requires 'riscv,nworlds' in /cpus, so disallow it here
+  riscv,nworlds: false
 
   interrupt-controller:
     type: object
Documentation/devicetree/bindings/riscv/worlds.yaml new file +77 -0

77 lines not on this page · raw message

Signature · 1 line
2.43.7
#4 lore raw

Re: [RFC PATCH 2/3] dt-bindings: riscv: Add Worlds per-hart properties

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] Incorrect and unnecessary schema reference: `cpus.yaml` (which validates child `/cpus/cpu@*`…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Incorrect and unnecessary schema reference: cpus.yaml (which validates child /cpus/cpu@* nodes) improperly includes a $ref to worlds.yaml (which validates the parent /cpus container node). This erroneously bleeds parent constraints into the child schema. --

commit 2b4a193c4b5716c3f96b6ae87becc46dcf104835
Author: Yu-Chien Peter Lin <[email protected]>

dt-bindings: riscv: Add Worlds per-hart properties

This commit adds per-hart device tree properties for the RISC-V Worlds architecture, such as riscv,pmwid and riscv,pmwidlist. These platform-defined values are used by M-mode firmware to configure World ID CSRs and restrict usage across privilege levels.

Documentation/devicetree/bindings/riscv/cpus.yaml description: | · line 29

Quoted 9 lines
Documentation/devicetree/bindings/riscv/cpus.yaml +1 -0
index 5feeb2203050a..4b5778b6d3e70 100644
@@ -26,6 +26,7 @@ description: |
 allOf:
   - $ref: /schemas/cpu.yaml#
   - $ref: extensions.yaml
+  - $ref: worlds.yaml

[Severity: Medium]
Does this reference unintentionally bleed the parent container properties into the child hart nodes?

The schema worlds.yaml is designed to validate the system-wide /cpus node via its select: pattern: "^cpus$", while cpus.yaml validates the individual /cpus/cpu@* nodes. By referencing worlds.yaml here, properties meant for the parent container leak into the child schema. Any future properties added to worlds.yaml would implicitly bypass unevaluatedProperties strict evaluation on the cpu@* nodes.

Quoted 2 lines
Documentation/devicetree/bindings/riscv/cpus.yaml +0 -0
   - if:
       not:

[ ... ]

Quoted 3 lines
Documentation/devicetree/bindings/riscv/cpus.yaml +0 -0
@@ -120,11 +121,31 @@ properties:
       thead systems where the vector register length is not identical on all harts, or
       the vlenb CSR is not available.

[ ... ]

Documentation/devicetree/bindings/riscv/cpus.yaml properties: · line 148

Quoted 4 lines

# RISC-V requires 'timebase-frequency' in /cpus, so disallow it here
timebase-frequency: false

Documentation/devicetree/bindings/riscv/cpus.yaml +2 -0
+  # RISC-V requires 'riscv,nworlds' in /cpus, so disallow it here
+  riscv,nworlds: false

[Severity: Medium]
Is this explicit disallowance a workaround for pulling in the parent schema via the reference above?

If the reference to worlds.yaml is removed from the allOf block, this manual workaround shouldn't be necessary. Removing the reference would also prevent future parent properties from silently sneaking into the child node schemas.

Quoted 3 lines

interrupt-controller:
type: object

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
#5 lore raw

Re: [RFC PATCH 2/3] dt-bindings: riscv: Add Worlds per-hart properties

In reply to Yu-Chien Peter Lin
Quoted 30 lines · Yu-Chien Peter Lin

Add per-hart DT properties for RISC-V Worlds architecture:
riscv,pmwid, riscv,pmwidlist, and riscv,pmlwidlist. These platform-defined values are primarily used by M-mode firmware to configure World ID CSRs and restrict WID usage across privilege levels.

---
 .../devicetree/bindings/riscv/cpus.yaml       | 21 +++++
 .../devicetree/bindings/riscv/worlds.yaml     | 77 +++++++++++++++++++
 2 files changed, 98 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/riscv/worlds.yaml
Documentation/devicetree/bindings/riscv/cpus.yaml +2 -0
index 5feeb2203050..4b5778b6d3e7 100644
@@ -26,6 +26,7 @@ description: |
 allOf:
   - $ref: /schemas/cpu.yaml#
   - $ref: extensions.yaml
+  - $ref: worlds.yaml
   - if:
       not:
         properties:
@@ -120,11 +121,31 @@ properties:
       thead systems where the vector register length is not identical on all harts, or
       the vlenb CSR is not available.
 
+  riscv,pmwid:

Documentation/devicetree/bindings/riscv/cpus.yaml properties: · line 134

Quoted 10 lines
Documentation/devicetree/bindings/riscv/cpus.yaml +10 -0
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      Platform-defined M-mode World ID (WID) assigned to this hart.
+    minimum: 0
+    maximum: 63
+
+  riscv,pmwidlist:
+    $ref: /schemas/types.yaml#/definitions/uint64
+    description:
+      Platform-defined bitmap of M-mode World IDs (WIDs) that this hart may use.

I don't understand what the difference is between this property and the one before it are.
Is this one meant to be used by m-mode software to then select one which will appear in riscv,pmwid?

Quoted 5 lines
Documentation/devicetree/bindings/riscv/cpus.yaml +5 -0
+
+  riscv,pmlwidlist:
+    $ref: /schemas/types.yaml#/definitions/uint64
+    description:
+      Platform-defined bitmap of World IDs (WIDs) that S-mode and U-mode may use

Documentation/devicetree/bindings/riscv/cpus.yaml properties:

Quoted 10 lines
Documentation/devicetree/bindings/riscv/cpus.yaml +4 -0
+      on this hart.
+
   # RISC-V has multiple properties for cache op block sizes as the sizes
   # differ between individual CBO extensions
   cache-op-block-size: false
   # RISC-V requires 'timebase-frequency' in /cpus, so disallow it here
   timebase-frequency: false
 
+  # RISC-V requires 'riscv,nworlds' in /cpus, so disallow it here
+  riscv,nworlds: false

Isn't this pointless? Nothing ever defines riscv,nworlds as a cpu level property so there's no need to disallow it?

Quoted 89 lines
Documentation/devicetree/bindings/riscv/cpus.yaml +0 -0
   interrupt-controller:
     type: object
Documentation/devicetree/bindings/riscv/worlds.yaml new file +77 -0
new file mode 100644
index 000000000000..cc8b3747591e
@@ -0,0 +1,77 @@
+# SPDX-License-Identifier: (GPL-2.0 OR MIT)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/riscv/worlds.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: RISC-V Worlds Extension
+
+maintainers:
+  - Yu-Chien Peter Lin <[email protected]>
+
+description: |
+  The RISC-V Worlds ISA extension, as described in the RISC-V Privileged
+  Specification, adds World ID tagging for context isolation.
+
+  This binding describes the system-wide Worlds configuration for the /cpus node
+  and is used alongside per-hart Worlds-related properties such as riscv,pmwid in
+  the RISC-V CPU binding and Worlds-related ISA extensions enumerated via
+  riscv,isa-extensions.
+
+select:
+  properties:
+    $nodename:
+      pattern: "^cpus$"
+
+properties:
+  riscv,nworlds:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description: |
+      Number of World IDs (WIDs) supported by the platform. This is a system-wide
+      property that describes the total number of isolation contexts available.
+      Hardware components such as the WorldGuard Checker use this to determine
+      the valid range of WID values.
+    minimum: 2
+    maximum: 64
+
+additionalProperties: true
+
+examples:
+  - |
+    // Example: System with 4 World IDs
+    cpus {
+        #address-cells = <1>;
+        #size-cells = <0>;
+        timebase-frequency = <1000000>;
+        riscv,nworlds = <4>;
+
+        cpu@0 {
+            device_type = "cpu";
+            reg = <0>;
+            compatible = "sifive,bullet0", "riscv";
+            riscv,isa-base = "rv64i";
+            riscv,isa-extensions = "i", "m", "a", "f", "d", "c";
+            riscv,pmwid = <0>;
+
+            interrupt-controller {
+                #interrupt-cells = <1>;
+                compatible = "riscv,cpu-intc";
+                interrupt-controller;
+            };
+        };
+
+        cpu@1 {
+            device_type = "cpu";
+            reg = <1>;
+            compatible = "sifive,bullet0", "riscv";
+            riscv,isa-base = "rv64i";
+            riscv,isa-extensions = "i", "m", "a", "f", "d", "c";
+            riscv,pmwid = <1>;
+
+            interrupt-controller {
+                #interrupt-cells = <1>;
+                compatible = "riscv,cpu-intc";
+                interrupt-controller;
+            };
+        };
+    };
Signature · 1 line
2.43.7
#6 lore raw

Re: [RFC PATCH 2/3] dt-bindings: riscv: Add Worlds per-hart properties

Hi Conor,

Quoted 30 lines · Conor Dooley
Quoted 29 lines · Yu-Chien Peter Lin

Add per-hart DT properties for RISC-V Worlds architecture:
riscv,pmwid, riscv,pmwidlist, and riscv,pmlwidlist. These platform-defined values are primarily used by M-mode firmware to configure World ID CSRs and restrict WID usage across privilege levels.

---
 .../devicetree/bindings/riscv/cpus.yaml       | 21 +++++
 .../devicetree/bindings/riscv/worlds.yaml     | 77 +++++++++++++++++++
 2 files changed, 98 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/riscv/worlds.yaml
Documentation/devicetree/bindings/riscv/cpus.yaml +1 -0
index 5feeb2203050..4b5778b6d3e7 100644
@@ -26,6 +26,7 @@ description: |
 allOf:
   - $ref: /schemas/cpu.yaml#
   - $ref: extensions.yaml
+  - $ref: worlds.yaml
   - if:
       not:
         properties:
@@ -120,11 +121,31 @@ properties:
       thead systems where the vector register length is not identical on all harts, or
       the vlenb CSR is not available.
 
Quoted 16 lines

Documentation/devicetree/bindings/riscv/cpus.yaml properties: · line 134

Quoted 11 lines
Documentation/devicetree/bindings/riscv/cpus.yaml +11 -0
+  riscv,pmwid:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      Platform-defined M-mode World ID (WID) assigned to this hart.
+    minimum: 0
+    maximum: 63
+
+  riscv,pmwidlist:
+    $ref: /schemas/types.yaml#/definitions/uint64
+    description:
+      Platform-defined bitmap of M-mode World IDs (WIDs) that this hart may use.

I don't understand what the difference is between this property and the one before it are.
Is this one meant to be used by m-mode software to then select one which will appear in riscv,pmwid?

pmwid (single value) is the reset default, while pmwidlist (bitmap) defines the allowed set. The root-of-trust M-mode software may select an allowed value from the pmwidlist and write it to the mwid CSR.

Quoted 14 lines
Quoted 13 lines
Documentation/devicetree/bindings/riscv/cpus.yaml +7 -0
+
+  riscv,pmlwidlist:
+    $ref: /schemas/types.yaml#/definitions/uint64
+    description:
+      Platform-defined bitmap of World IDs (WIDs) that S-mode and U-mode may use
+      on this hart.
+
   # RISC-V has multiple properties for cache op block sizes as the sizes
   # differ between individual CBO extensions
   cache-op-block-size: false
   # RISC-V requires 'timebase-frequency' in /cpus, so disallow it here
   timebase-frequency: false
Quoted 5 lines

Documentation/devicetree/bindings/riscv/cpus.yaml properties: · line 148

Quoted 2 lines
Documentation/devicetree/bindings/riscv/cpus.yaml +2 -0
+  # RISC-V requires 'riscv,nworlds' in /cpus, so disallow it here
+  riscv,nworlds: false

Isn't this pointless? Nothing ever defines riscv,nworlds as a cpu level property so there's no need to disallow it?

Okay, thanks for the catch, will drop this.

Best regards,
Peter Lin

Quoted 90 lines
Quoted 90 lines
Documentation/devicetree/bindings/riscv/cpus.yaml +0 -0
   interrupt-controller:
     type: object
Documentation/devicetree/bindings/riscv/worlds.yaml new file +77 -0
new file mode 100644
index 000000000000..cc8b3747591e
@@ -0,0 +1,77 @@
+# SPDX-License-Identifier: (GPL-2.0 OR MIT)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/riscv/worlds.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: RISC-V Worlds Extension
+
+maintainers:
+  - Yu-Chien Peter Lin <[email protected]>
+
+description: |
+  The RISC-V Worlds ISA extension, as described in the RISC-V Privileged
+  Specification, adds World ID tagging for context isolation.
+
+  This binding describes the system-wide Worlds configuration for the /cpus node
+  and is used alongside per-hart Worlds-related properties such as riscv,pmwid in
+  the RISC-V CPU binding and Worlds-related ISA extensions enumerated via
+  riscv,isa-extensions.
+
+select:
+  properties:
+    $nodename:
+      pattern: "^cpus$"
+
+properties:
+  riscv,nworlds:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description: |
+      Number of World IDs (WIDs) supported by the platform. This is a system-wide
+      property that describes the total number of isolation contexts available.
+      Hardware components such as the WorldGuard Checker use this to determine
+      the valid range of WID values.
+    minimum: 2
+    maximum: 64
+
+additionalProperties: true
+
+examples:
+  - |
+    // Example: System with 4 World IDs
+    cpus {
+        #address-cells = <1>;
+        #size-cells = <0>;
+        timebase-frequency = <1000000>;
+        riscv,nworlds = <4>;
+
+        cpu@0 {
+            device_type = "cpu";
+            reg = <0>;
+            compatible = "sifive,bullet0", "riscv";
+            riscv,isa-base = "rv64i";
+            riscv,isa-extensions = "i", "m", "a", "f", "d", "c";
+            riscv,pmwid = <0>;
+
+            interrupt-controller {
+                #interrupt-cells = <1>;
+                compatible = "riscv,cpu-intc";
+                interrupt-controller;
+            };
+        };
+
+        cpu@1 {
+            device_type = "cpu";
+            reg = <1>;
+            compatible = "sifive,bullet0", "riscv";
+            riscv,isa-base = "rv64i";
+            riscv,isa-extensions = "i", "m", "a", "f", "d", "c";
+            riscv,pmwid = <1>;
+
+            interrupt-controller {
+                #interrupt-cells = <1>;
+                compatible = "riscv,cpu-intc";
+                interrupt-controller;
+            };
+        };
+    };
Signature · 1 line
2.43.7
#7 lore raw

Re: [RFC PATCH 2/3] dt-bindings: riscv: Add Worlds per-hart properties

Quoted 50 lines · Yu-Chien Peter Lin

Hi Conor,

Quoted 30 lines · Conor Dooley
Quoted 29 lines · Yu-Chien Peter Lin

Add per-hart DT properties for RISC-V Worlds architecture:
riscv,pmwid, riscv,pmwidlist, and riscv,pmlwidlist. These platform-defined values are primarily used by M-mode firmware to configure World ID CSRs and restrict WID usage across privilege levels.

---
 .../devicetree/bindings/riscv/cpus.yaml       | 21 +++++
 .../devicetree/bindings/riscv/worlds.yaml     | 77 +++++++++++++++++++
 2 files changed, 98 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/riscv/worlds.yaml
Documentation/devicetree/bindings/riscv/cpus.yaml +1 -0
index 5feeb2203050..4b5778b6d3e7 100644
@@ -26,6 +26,7 @@ description: |
 allOf:
   - $ref: /schemas/cpu.yaml#
   - $ref: extensions.yaml
+  - $ref: worlds.yaml
   - if:
       not:
         properties:
@@ -120,11 +121,31 @@ properties:
       thead systems where the vector register length is not identical on all harts, or
       the vlenb CSR is not available.
 
Quoted 16 lines

Documentation/devicetree/bindings/riscv/cpus.yaml properties: · line 134

Quoted 11 lines
Documentation/devicetree/bindings/riscv/cpus.yaml +11 -0
+  riscv,pmwid:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      Platform-defined M-mode World ID (WID) assigned to this hart.
+    minimum: 0
+    maximum: 63
+
+  riscv,pmwidlist:
+    $ref: /schemas/types.yaml#/definitions/uint64
+    description:
+      Platform-defined bitmap of M-mode World IDs (WIDs) that this hart may use.

I don't understand what the difference is between this property and the one before it are.
Is this one meant to be used by m-mode software to then select one which will appear in riscv,pmwid?

Quoted 3 lines

pmwid (single value) is the reset default, while pmwidlist (bitmap) defines the allowed set. The root-of-trust M-mode software may select an allowed value from the pmwidlist and write it to the mwid CSR.

I don't understand the point of the property then. If it is the reset default, just read it out of the register?
Unless I am missing something, it's useless to s-mode because it may not be what m-mode chose and useless to m-mode that has access to the csr.

Cheers,
Conor.

#8 lore raw

Re: [RFC PATCH 2/3] dt-bindings: riscv: Add Worlds per-hart properties

Hi Conor,

Quoted 55 lines · Conor Dooley
Quoted 50 lines · Yu-Chien Peter Lin

Hi Conor,

Quoted 30 lines · Conor Dooley
Quoted 29 lines · Yu-Chien Peter Lin

Add per-hart DT properties for RISC-V Worlds architecture:
riscv,pmwid, riscv,pmwidlist, and riscv,pmlwidlist. These platform-defined values are primarily used by M-mode firmware to configure World ID CSRs and restrict WID usage across privilege levels.

---
 .../devicetree/bindings/riscv/cpus.yaml       | 21 +++++
 .../devicetree/bindings/riscv/worlds.yaml     | 77 +++++++++++++++++++
 2 files changed, 98 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/riscv/worlds.yaml
Documentation/devicetree/bindings/riscv/cpus.yaml +1 -0
index 5feeb2203050..4b5778b6d3e7 100644
@@ -26,6 +26,7 @@ description: |
 allOf:
   - $ref: /schemas/cpu.yaml#
   - $ref: extensions.yaml
+  - $ref: worlds.yaml
   - if:
       not:
         properties:
@@ -120,11 +121,31 @@ properties:
       thead systems where the vector register length is not identical on all harts, or
       the vlenb CSR is not available.
 
Quoted 16 lines

Documentation/devicetree/bindings/riscv/cpus.yaml properties: · line 134

Quoted 11 lines
Documentation/devicetree/bindings/riscv/cpus.yaml +11 -0
+  riscv,pmwid:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      Platform-defined M-mode World ID (WID) assigned to this hart.
+    minimum: 0
+    maximum: 63
+
+  riscv,pmwidlist:
+    $ref: /schemas/types.yaml#/definitions/uint64
+    description:
+      Platform-defined bitmap of M-mode World IDs (WIDs) that this hart may use.

I don't understand what the difference is between this property and the one before it are.
Is this one meant to be used by m-mode software to then select one which will appear in riscv,pmwid?

Quoted 3 lines

pmwid (single value) is the reset default, while pmwidlist (bitmap) defines the allowed set. The root-of-trust M-mode software may select an allowed value from the pmwidlist and write it to the mwid CSR.

Quoted 5 lines

I don't understand the point of the property then. If it is the reset default, just read it out of the register?
Unless I am missing something, it's useless to s-mode because it may not be what m-mode chose and useless to m-mode that has access to the csr.

Smwid is optional. In the no-Smwid case:
- M-mode's WID is fixed to pmwid (hardware-defined via fuse/pinstrap/SoC registers, exposed to software via riscv,pmwid DT property)
- S/U-mode's WID depends on opensbi-domain configuration [1]:
- If next-wid is specified: S/U use that WID (via mlwid CSR)
- If next-wid is absent : S/U fall back to pmwid (M/S/U in same
world)

So riscv,pmwid serves two purpose:
1. Source of truth for M-mode's WID when mwid CSR doesn't exist
2. Fallback value for OpenSBI to write to mlwid when domain config is absent.

[1] https://lists.infradead.org/pipermail/opensbi/2026-June/010090.html

Best regards,
Peter Lin

Quoted 3 lines

Cheers,
Conor.

#9 lore raw

Re: [RFC PATCH 2/3] dt-bindings: riscv: Add Worlds per-hart properties

Quoted 72 lines · Yu-Chien Peter Lin

Hi Conor,

Quoted 55 lines · Conor Dooley
Quoted 50 lines · Yu-Chien Peter Lin

Hi Conor,

Quoted 30 lines · Conor Dooley
Quoted 29 lines · Yu-Chien Peter Lin

Add per-hart DT properties for RISC-V Worlds architecture:
riscv,pmwid, riscv,pmwidlist, and riscv,pmlwidlist. These platform-defined values are primarily used by M-mode firmware to configure World ID CSRs and restrict WID usage across privilege levels.

---
 .../devicetree/bindings/riscv/cpus.yaml       | 21 +++++
 .../devicetree/bindings/riscv/worlds.yaml     | 77 +++++++++++++++++++
 2 files changed, 98 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/riscv/worlds.yaml
Documentation/devicetree/bindings/riscv/cpus.yaml +1 -0
index 5feeb2203050..4b5778b6d3e7 100644
@@ -26,6 +26,7 @@ description: |
 allOf:
   - $ref: /schemas/cpu.yaml#
   - $ref: extensions.yaml
+  - $ref: worlds.yaml
   - if:
       not:
         properties:
@@ -120,11 +121,31 @@ properties:
       thead systems where the vector register length is not identical on all harts, or
       the vlenb CSR is not available.
 
Quoted 16 lines

Documentation/devicetree/bindings/riscv/cpus.yaml properties: · line 134

Quoted 11 lines
Documentation/devicetree/bindings/riscv/cpus.yaml +11 -0
+  riscv,pmwid:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      Platform-defined M-mode World ID (WID) assigned to this hart.
+    minimum: 0
+    maximum: 63
+
+  riscv,pmwidlist:
+    $ref: /schemas/types.yaml#/definitions/uint64
+    description:
+      Platform-defined bitmap of M-mode World IDs (WIDs) that this hart may use.

I don't understand what the difference is between this property and the one before it are.
Is this one meant to be used by m-mode software to then select one which will appear in riscv,pmwid?

Quoted 3 lines

pmwid (single value) is the reset default, while pmwidlist (bitmap) defines the allowed set. The root-of-trust M-mode software may select an allowed value from the pmwidlist and write it to the mwid CSR.

Quoted 5 lines

I don't understand the point of the property then. If it is the reset default, just read it out of the register?
Unless I am missing something, it's useless to s-mode because it may not be what m-mode chose and useless to m-mode that has access to the csr.

Smwid is optional. In the no-Smwid case:
- M-mode's WID is fixed to pmwid (hardware-defined via fuse/pinstrap/SoC registers, exposed to software via riscv,pmwid DT property)
- S/U-mode's WID depends on opensbi-domain configuration [1]:
- If next-wid is specified: S/U use that WID (via mlwid CSR)
- If next-wid is absent : S/U fall back to pmwid (M/S/U in same
world)

Quoted 4 lines

So riscv,pmwid serves two purpose:
1. Source of truth for M-mode's WID when mwid CSR doesn't exist
2. Fallback value for OpenSBI to write to mlwid when domain config is absent.

So it is not the default at reset at all then. The reset default is something else entirely and this is used to overwrite that.

Quoted 2 lines

- M-mode's WID is fixed to pmwid (hardware-defined via fuse/pinstrap/SoC registers, exposed to software via riscv,pmwid DT property)

In this case, it seems like pmwidlist would just contain a single entry, and there is no need for pwmid.

Quite frankly, it seems like you need to decouple these properties from being 1:1 mappings to your extension's CSRs and both name and explain how they are to be used by software.

For example, how is software to treat the value in riscv,pwmid when Smwid is enabled? Must it be the same value? Is riscv,pwmidlist useless in that scenario as a result and should not be populated? Should riscv,pwmid not be used if Smwid is enabled?

There's a lot of extensions defined in this series, and there's no clarity on how these properties behave depending on what's enabled in the binding. There must be.

Quoted 9 lines

- S/U-mode's WID depends on opensbi-domain configuration [1]:
- If next-wid is specified: S/U use that WID (via mlwid CSR)
- If next-wid is absent : S/U fall back to pmwid (M/S/U in same
world)

So riscv,pmwid serves two purpose:
1. Source of truth for M-mode's WID when mwid CSR doesn't exist
2. Fallback value for OpenSBI to write to mlwid when domain config is absent.

Again same point applies here, why can a single-entry riscv,pmwidlist not suffice here?
Additionally, if it cannot, you may need to introduce mutual exclusion and the relevant extensions because it doesn't seem like in your current design that the two properties are intended to co-exist.

Cheers,
Conor.

#10 lore raw

Re: [RFC PATCH 2/3] dt-bindings: riscv: Add Worlds per-hart properties

Hi Conor,

Quoted 78 lines · Conor Dooley
Quoted 72 lines · Yu-Chien Peter Lin

Hi Conor,

Quoted 55 lines · Conor Dooley
Quoted 50 lines · Yu-Chien Peter Lin

Hi Conor,

Quoted 30 lines · Conor Dooley
Quoted 29 lines · Yu-Chien Peter Lin

Add per-hart DT properties for RISC-V Worlds architecture:
riscv,pmwid, riscv,pmwidlist, and riscv,pmlwidlist. These platform-defined values are primarily used by M-mode firmware to configure World ID CSRs and restrict WID usage across privilege levels.

---
 .../devicetree/bindings/riscv/cpus.yaml       | 21 +++++
 .../devicetree/bindings/riscv/worlds.yaml     | 77 +++++++++++++++++++
 2 files changed, 98 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/riscv/worlds.yaml
Documentation/devicetree/bindings/riscv/cpus.yaml +1 -0
index 5feeb2203050..4b5778b6d3e7 100644
@@ -26,6 +26,7 @@ description: |
 allOf:
   - $ref: /schemas/cpu.yaml#
   - $ref: extensions.yaml
+  - $ref: worlds.yaml
   - if:
       not:
         properties:
@@ -120,11 +121,31 @@ properties:
       thead systems where the vector register length is not identical on all harts, or
       the vlenb CSR is not available.
 
Quoted 16 lines

Documentation/devicetree/bindings/riscv/cpus.yaml properties: · line 134

Quoted 11 lines
Documentation/devicetree/bindings/riscv/cpus.yaml +11 -0
+  riscv,pmwid:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      Platform-defined M-mode World ID (WID) assigned to this hart.
+    minimum: 0
+    maximum: 63
+
+  riscv,pmwidlist:
+    $ref: /schemas/types.yaml#/definitions/uint64
+    description:
+      Platform-defined bitmap of M-mode World IDs (WIDs) that this hart may use.

I don't understand what the difference is between this property and the one before it are.
Is this one meant to be used by m-mode software to then select one which will appear in riscv,pmwid?

Quoted 3 lines

pmwid (single value) is the reset default, while pmwidlist (bitmap) defines the allowed set. The root-of-trust M-mode software may select an allowed value from the pmwidlist and write it to the mwid CSR.

Quoted 5 lines

I don't understand the point of the property then. If it is the reset default, just read it out of the register?
Unless I am missing something, it's useless to s-mode because it may not be what m-mode chose and useless to m-mode that has access to the csr.

Smwid is optional. In the no-Smwid case:
- M-mode's WID is fixed to pmwid (hardware-defined via fuse/pinstrap/SoC registers, exposed to software via riscv,pmwid DT property)
- S/U-mode's WID depends on opensbi-domain configuration [1]:
- If next-wid is specified: S/U use that WID (via mlwid CSR)
- If next-wid is absent : S/U fall back to pmwid (M/S/U in same
world)

Quoted 4 lines

So riscv,pmwid serves two purpose:
1. Source of truth for M-mode's WID when mwid CSR doesn't exist
2. Fallback value for OpenSBI to write to mlwid when domain config is absent.

Quoted 8 lines

So it is not the default at reset at all then. The reset default is something else entirely and this is used to overwrite that.

Quoted 2 lines

- M-mode's WID is fixed to pmwid (hardware-defined via fuse/pinstrap/SoC registers, exposed to software via riscv,pmwid DT property)

In this case, it seems like pmwidlist would just contain a single entry, and there is no need for pwmid.

The pmwid and pmwidlist properties cannot merge because pmwidlist represents an optional hardware mask. On physically unrestricted platforms, pmwidlist doesn't exist, making pmwid essential to define the hardware reset default.

Quoted 4 lines

Quite frankly, it seems like you need to decouple these properties from being 1:1 mappings to your extension's CSRs and both name and explain how they are to be used by software.

These properties are actually not 1:1 CSR mappings. pmwid, pmwidlist, and pmlwidlist are the exact terms used in the RISC-V specification to describe these platform-defined hardware values, so I prefer to follow it.

Quoted 9 lines

For example, how is software to treat the value in riscv,pwmid when Smwid is enabled? Must it be the same value? Is riscv,pwmidlist useless in that scenario as a result and should not be populated? Should riscv,pwmid not be used if Smwid is enabled?

There's a lot of extensions defined in this series, and there's no clarity on how these properties behave depending on what's enabled in the binding. There must be.

Yes, agreed. I have summarized the possible ISA extension combinations and their corresponding Device Tree property requirements in the table below:

# | Smwid | Smlwid | Smlwidlist | Smwiddeleg | Sswid | CSRs Present | pmwid | pmwidlist | pmlwidlist | Notes
------------------------------------------------------------------------------------------------------------------------------------------------------

0 | off   | off    | off        | off        | off   | (none)                                   | REQ   | NO        | NO         | Base: single fixed WID per hart, platform-defined only
1 | on    | off    | off        | off        | off   | mwid                                     | OPT   | OPT       | NO         | M-mode control only: lockable M-mode WID; all privilege modes share one WID
2 | off   | on     | off        | off        | off   | mlwid                                    | REQ   | NO        | OPT        | Lower-mode control: M-mode assigns WID to lower privileges; M-mode WID is platfo rm-fixed
3 | on    | on     | off        | off        | off   | mwid, mlwid                              | OPT   | OPT       | OPT        | RoT M-mode control: RoT M-mode configures regular M-mode WID (lockable)
4 | on    | on     | on         | off        | off   | mwid, mlwid, mlwidlist                   | OPT   | OPT       | OPT        | WID list restriction: M-mode can software-restrict the mlwid set
5 | off   | on     | off        | on         | on    | mlwid, mwiddeleg, slwid                  | REQ   | NO        | OPT        | S-delegated control (M-mode fixed): M-mode WID platform-fixed; S-mode controls U -mode WID
6 | on    | on     | off        | on         | on    | mwid, mlwid, mwiddeleg, slwid            | OPT   | OPT       | OPT        | S-delegated control (M-mode programmable): M-mode WID lockable; S-mode controls U-mode WID
7 | on    | on     | on         | on         | on    | mwid, mlwid, mlwidlist, mwiddeleg, slwid | OPT   | OPT       | OPT        | Complete feature set: all CSRs present; M-mode lockable WID, mlwidlist restricti on, S-mode delegation
  REQ = REQUIRED   - Property must be present in DT
  OPT = OPTIONAL   - Property may be present; provides optional platform defined values
  NO  = FORBIDDEN  - Property must not be present
Quoted 6 lines
Quoted 6 lines

- S/U-mode's WID depends on opensbi-domain configuration [1]:
- If next-wid is specified: S/U use that WID (via mlwid CSR)
- If next-wid is absent : S/U fall back to pmwid (M/S/U in same
world)

Quoted 7 lines
Quoted 4 lines

So riscv,pmwid serves two purpose:
1. Source of truth for M-mode's WID when mwid CSR doesn't exist
2. Fallback value for OpenSBI to write to mlwid when domain config is absent.

Again same point applies here, why can a single-entry riscv,pmwidlist not suffice here?

As explained above, a single-entry pmwidlist cannot replace pmwid because it would fail to represent the exact hardware reset default for platforms without physical WID restrictions. I hope this addresses your concern.

Quoted 3 lines

Additionally, if it cannot, you may need to introduce mutual exclusion and the relevant extensions because it doesn't seem like in your current design that the two properties are intended to co-exist.

Agreed. In the next version, I will introduce mutual exclusion in the YAML schema based on the table above.

Thanks,
Peter Lin

Quoted 3 lines

Cheers,
Conor.

#11 lore raw

Re: [RFC PATCH 2/3] dt-bindings: riscv: Add Worlds per-hart properties

Quoted 95 lines · Yu-Chien Peter Lin

Hi Conor,

Quoted 78 lines · Conor Dooley
Quoted 72 lines · Yu-Chien Peter Lin

Hi Conor,

Quoted 55 lines · Conor Dooley
Quoted 50 lines · Yu-Chien Peter Lin

Hi Conor,

Quoted 30 lines · Conor Dooley
Quoted 29 lines · Yu-Chien Peter Lin

Add per-hart DT properties for RISC-V Worlds architecture:
riscv,pmwid, riscv,pmwidlist, and riscv,pmlwidlist. These platform-defined values are primarily used by M-mode firmware to configure World ID CSRs and restrict WID usage across privilege levels.

---
 .../devicetree/bindings/riscv/cpus.yaml       | 21 +++++
 .../devicetree/bindings/riscv/worlds.yaml     | 77 +++++++++++++++++++
 2 files changed, 98 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/riscv/worlds.yaml
Documentation/devicetree/bindings/riscv/cpus.yaml +1 -0
index 5feeb2203050..4b5778b6d3e7 100644
@@ -26,6 +26,7 @@ description: |
 allOf:
   - $ref: /schemas/cpu.yaml#
   - $ref: extensions.yaml
+  - $ref: worlds.yaml
   - if:
       not:
         properties:
@@ -120,11 +121,31 @@ properties:
       thead systems where the vector register length is not identical on all harts, or
       the vlenb CSR is not available.
 
Quoted 16 lines

Documentation/devicetree/bindings/riscv/cpus.yaml properties: · line 134

Quoted 11 lines
Documentation/devicetree/bindings/riscv/cpus.yaml +11 -0
+  riscv,pmwid:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      Platform-defined M-mode World ID (WID) assigned to this hart.
+    minimum: 0
+    maximum: 63
+
+  riscv,pmwidlist:
+    $ref: /schemas/types.yaml#/definitions/uint64
+    description:
+      Platform-defined bitmap of M-mode World IDs (WIDs) that this hart may use.

I don't understand what the difference is between this property and the one before it are.
Is this one meant to be used by m-mode software to then select one which will appear in riscv,pmwid?

Quoted 3 lines

pmwid (single value) is the reset default, while pmwidlist (bitmap) defines the allowed set. The root-of-trust M-mode software may select an allowed value from the pmwidlist and write it to the mwid CSR.

Quoted 5 lines

I don't understand the point of the property then. If it is the reset default, just read it out of the register?
Unless I am missing something, it's useless to s-mode because it may not be what m-mode chose and useless to m-mode that has access to the csr.

Smwid is optional. In the no-Smwid case:
- M-mode's WID is fixed to pmwid (hardware-defined via fuse/pinstrap/SoC registers, exposed to software via riscv,pmwid DT property)
- S/U-mode's WID depends on opensbi-domain configuration [1]:
- If next-wid is specified: S/U use that WID (via mlwid CSR)
- If next-wid is absent : S/U fall back to pmwid (M/S/U in same
world)

Quoted 4 lines

So riscv,pmwid serves two purpose:
1. Source of truth for M-mode's WID when mwid CSR doesn't exist
2. Fallback value for OpenSBI to write to mlwid when domain config is absent.

Quoted 8 lines

So it is not the default at reset at all then. The reset default is something else entirely and this is used to overwrite that.

Quoted 2 lines

- M-mode's WID is fixed to pmwid (hardware-defined via fuse/pinstrap/SoC registers, exposed to software via riscv,pmwid DT property)

In this case, it seems like pmwidlist would just contain a single entry, and there is no need for pwmid.

The pmwid and pmwidlist properties cannot merge because pmwidlist represents an optional hardware mask. On physically unrestricted platforms, pmwidlist doesn't exist, making pmwid essential to define the hardware reset default.

Quoted 1 line
Quoted 7 lines
Quoted 3 lines

Quite frankly, it seems like you need to decouple these properties from being 1:1 mappings to your extension's CSRs and both name and explain how they are to be used by software.

These properties are actually not 1:1 CSR mappings. pmwid, pmwidlist, and pmlwidlist are the exact terms used in the RISC-V specification to describe these platform-defined hardware values, so I prefer to follow it.

CSRs or terms in your extension, it matters little.
Your properties should reflect how software will actually interact with the devicetree and wordguard. There's no point having a bunch of properties that relate to aspects of the extension if software is not going to actually use them.

I fundamentally do not understand why software ever needs both both the singular and list properties. What does software actually do with the list property when both it and the singular property are provided?

I expect to see something simpler and/or much better explained in the next revision.

Quoted 6 lines
Quoted 2 lines

Again same point applies here, why can a single-entry riscv,pmwidlist not suffice here?

As explained above, a single-entry pmwidlist cannot replace pmwid because it would fail to represent the exact hardware reset default for platforms without physical WID restrictions.

If there is one entry, use that, and if there are multiple entries, pick one?

Thanks,
Conor.

#12 lore raw

Re: [RFC PATCH 2/3] dt-bindings: riscv: Add Worlds per-hart properties

Quoted 120 lines · Conor Dooley
Quoted 95 lines · Yu-Chien Peter Lin

Hi Conor,

Quoted 78 lines · Conor Dooley
Quoted 72 lines · Yu-Chien Peter Lin

Hi Conor,

Quoted 55 lines · Conor Dooley
Quoted 50 lines · Yu-Chien Peter Lin

Hi Conor,

Quoted 30 lines · Conor Dooley
Quoted 29 lines · Yu-Chien Peter Lin

Add per-hart DT properties for RISC-V Worlds architecture:
riscv,pmwid, riscv,pmwidlist, and riscv,pmlwidlist. These platform-defined values are primarily used by M-mode firmware to configure World ID CSRs and restrict WID usage across privilege levels.

---
 .../devicetree/bindings/riscv/cpus.yaml       | 21 +++++
 .../devicetree/bindings/riscv/worlds.yaml     | 77 +++++++++++++++++++
 2 files changed, 98 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/riscv/worlds.yaml
Documentation/devicetree/bindings/riscv/cpus.yaml +1 -0
index 5feeb2203050..4b5778b6d3e7 100644
@@ -26,6 +26,7 @@ description: |
 allOf:
   - $ref: /schemas/cpu.yaml#
   - $ref: extensions.yaml
+  - $ref: worlds.yaml
   - if:
       not:
         properties:
@@ -120,11 +121,31 @@ properties:
       thead systems where the vector register length is not identical on all harts, or
       the vlenb CSR is not available.
 
Quoted 16 lines

Documentation/devicetree/bindings/riscv/cpus.yaml properties: · line 134

Quoted 11 lines
Documentation/devicetree/bindings/riscv/cpus.yaml +11 -0
+  riscv,pmwid:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      Platform-defined M-mode World ID (WID) assigned to this hart.
+    minimum: 0
+    maximum: 63
+
+  riscv,pmwidlist:
+    $ref: /schemas/types.yaml#/definitions/uint64
+    description:
+      Platform-defined bitmap of M-mode World IDs (WIDs) that this hart may use.

I don't understand what the difference is between this property and the one before it are.
Is this one meant to be used by m-mode software to then select one which will appear in riscv,pmwid?

Quoted 3 lines

pmwid (single value) is the reset default, while pmwidlist (bitmap) defines the allowed set. The root-of-trust M-mode software may select an allowed value from the pmwidlist and write it to the mwid CSR.

Quoted 5 lines

I don't understand the point of the property then. If it is the reset default, just read it out of the register?
Unless I am missing something, it's useless to s-mode because it may not be what m-mode chose and useless to m-mode that has access to the csr.

Smwid is optional. In the no-Smwid case:
- M-mode's WID is fixed to pmwid (hardware-defined via fuse/pinstrap/SoC registers, exposed to software via riscv,pmwid DT property)
- S/U-mode's WID depends on opensbi-domain configuration [1]:
- If next-wid is specified: S/U use that WID (via mlwid CSR)
- If next-wid is absent : S/U fall back to pmwid (M/S/U in same
world)

Quoted 4 lines

So riscv,pmwid serves two purpose:
1. Source of truth for M-mode's WID when mwid CSR doesn't exist
2. Fallback value for OpenSBI to write to mlwid when domain config is absent.

Quoted 8 lines

So it is not the default at reset at all then. The reset default is something else entirely and this is used to overwrite that.

Quoted 2 lines

- M-mode's WID is fixed to pmwid (hardware-defined via fuse/pinstrap/SoC registers, exposed to software via riscv,pmwid DT property)

In this case, it seems like pmwidlist would just contain a single entry, and there is no need for pwmid.

The pmwid and pmwidlist properties cannot merge because pmwidlist represents an optional hardware mask. On physically unrestricted platforms, pmwidlist doesn't exist, making pmwid essential to define the hardware reset default.

Quoted 1 line
Quoted 7 lines
Quoted 3 lines

Quite frankly, it seems like you need to decouple these properties from being 1:1 mappings to your extension's CSRs and both name and explain how they are to be used by software.

These properties are actually not 1:1 CSR mappings. pmwid, pmwidlist, and pmlwidlist are the exact terms used in the RISC-V specification to describe these platform-defined hardware values, so I prefer to follow it.

CSRs or terms in your extension, it matters little.
Your properties should reflect how software will actually interact with the devicetree and wordguard. There's no point having a bunch of properties that relate to aspects of the extension if software is not going to actually use them.

I fundamentally do not understand why software ever needs both both the singular and list properties. What does software actually do with the list property when both it and the singular property are provided?

I expect to see something simpler and/or much better explained in the next revision.

Quoted 3 lines
Quoted 2 lines

Again same point applies here, why can a single-entry riscv,pmwidlist not suffice here?

Quoted 6 lines
Quoted 3 lines

As explained above, a single-entry pmwidlist cannot replace pmwid because it would fail to represent the exact hardware reset default for platforms without physical WID restrictions.

If there is one entry, use that, and if there are multiple entries, pick one?

Thank you, Conor. I am reworking OpenSBI part and hopefully PATCHv2 will address some of issues here. I will also rewrite description to focus on software usage rather than hardware spec terminology.

Regards,
Peter Lin

Quoted 3 lines

Thanks,
Conor.

#13 lore raw

RFC PATCH 3/3 dt-bindings: sifive: Add WorldGuard Checker

In reply to Yu-Chien Peter Lin

Add DT binding for SiFive wgChecker2, a hardware firewall enforcing WID-based access control in RISC-V Worlds. Provides checker slots to program per-WID permissions for downstream resources, with optional sub-range partitioning.

---
 .../devicetree/bindings/riscv/worlds.yaml     |   9 +
 .../bindings/sifive/sifive,wgchecker2.yaml    | 237 ++++++++++++++++++
 2 files changed, 246 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml
Documentation/devicetree/bindings/riscv/worlds.yaml +9 -0
index cc8b3747591e..c39a06c2dd8d 100644
@@ -34,6 +34,14 @@ properties:
     minimum: 2
     maximum: 64
 
+  sifive,trustedwid:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    maximum: 31
+    description: |
+      The World ID (WID) designated as the trusted WID for this platform.
+      Transactions tagged with this WID are authorized to access and configure
+      WorldGuard blocks, including wgCheckers and wgMarkers.
+
 additionalProperties: true
 
 examples:
@@ -44,6 +52,7 @@ examples:
         #size-cells = <0>;
         timebase-frequency = <1000000>;
         riscv,nworlds = <4>;
+        sifive,trustedwid = <3>;
 
         cpu@0 {
             device_type = "cpu";
Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml new file +237 -0

237 lines not on this page · raw message

Signature · 1 line
2.43.7
#14 lore raw

Re: [RFC PATCH 3/3] dt-bindings: sifive: Add WorldGuard Checker

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider: - [High] The `#access-controller-cells` specifier inappropriately encodes 64-bit absolute physical…

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [High] The #access-controller-cells specifier inappropriately encodes 64-bit absolute physical addresses and sizes, bypassing Devicetree's native address translation.
- [Low] The schema examples reference an undefined label &aplic_m, causing a dt_binding_check compilation failure.
- [Low] The sifive,trustedwid property is not explicitly disallowed in riscv/cpus.yaml, allowing it to bypass schema validation if erroneously placed in a cpu@* node.
- [Low] The examples in sifive,wgchecker2.yaml omit the required interrupt-controller child node in their cpu@0 definitions, leading to a schema validation error. --

commit 26cbbd0f7310c04b5d6fe920375466bc89dd2479
Author: Yu-Chien Peter Lin <[email protected]>

dt-bindings: sifive: Add WorldGuard Checker

This commit adds a Device Tree binding for the SiFive wgChecker2, a hardware firewall enforcing World ID (WID) based access control. It enables spatial partitioning of memory and memory-mapped devices by providing checker slots to program per-WID permissions.

Documentation/devicetree/bindings/riscv/worlds.yaml properties: · line 38

Quoted 10 lines
Documentation/devicetree/bindings/riscv/worlds.yaml +2 -0
index cc8b3747591eb..c39a06c2dd8d3 100644
@@ -34,6 +34,14 @@ properties:
     minimum: 2
     maximum: 64
 
+  sifive,trustedwid:
+    $ref: /schemas/types.yaml#/definitions/uint32

[Severity: Low]
Because riscv/cpus.yaml includes worlds.yaml via $ref, does this allow the property to be erroneously placed on individual cpu@* nodes without failing validation?

To enforce correct usage, should sifive,trustedwid: false be explicitly added to riscv/cpus.yaml, similar to riscv,nworlds: false?

[ ... ]

Quoted 5 lines
Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml new file +0 -0
new file mode 100644
index 0000000000000..043c748385ed4

[ ... ]

Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml line 61

Quoted 5 lines
Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml new file +5 -0
+  '#access-controller-cells':
+    const: 7
+    description: |
+      Specifier for one access-control rule, encoded as seven u32 cells:
+        <addr-hi addr-lo size-hi size-lo perm-hi perm-lo config>

[Severity: High]
Does encoding absolute physical addresses and sizes directly into the access-controllers array bypass Devicetree's native address translation?

If the protected device is behind a bus with a translation mapping, or if a bootloader dynamically patches reg sizes, the hardcoded addresses in the firewall configuration might be incorrect since they are opaque to DT address translation APIs.

[ ... ]

Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml line 113

Quoted 13 lines
Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml new file +13 -0
+    cpus {
+        #address-cells = <1>;
+        #size-cells = <0>;
+        timebase-frequency = <1000000>;
+        riscv,nworlds = <4>;
+        sifive,trustedwid = <3>;
+
+        cpu@0 {
+            device_type = "cpu";
+            reg = <0>;
+            compatible = "riscv";
+            riscv,isa = "rv64imac";
+        };

[Severity: Low]
Will this omission cause a dt_binding_check failure?

When validated against riscv/cpus.yaml, the schema strictly mandates an interrupt-controller child node for cpu@0 nodes with compatible = "riscv".

[ ... ]

Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml line 136

Quoted 6 lines
Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml new file +6 -0
+        wgchecker0: wgchecker@1c2000 {
+            compatible = "sifive,wgchecker2";
+            reg = <0x0 0x001c2000 0x0 0x1000>;
+            #access-controller-cells = <7>;
+            interrupts = <80 IRQ_TYPE_LEVEL_HIGH>;
+            interrupt-parent = <&aplic_m>;

[Severity: Low]
Is the aplic_m label defined anywhere in these examples?

It appears missing, which might cause make dt_binding_check to fail with a "Reference to non-existent node or label" error.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
#15 lore raw

Re: [RFC PATCH 3/3] dt-bindings: sifive: Add WorldGuard Checker

In reply to Yu-Chien Peter Lin
Quoted 20 lines · Yu-Chien Peter Lin

Add DT binding for SiFive wgChecker2, a hardware firewall enforcing WID-based access control in RISC-V Worlds. Provides checker slots to program per-WID permissions for downstream resources, with optional sub-range partitioning.

---
 .../devicetree/bindings/riscv/worlds.yaml     |   9 +
 .../bindings/sifive/sifive,wgchecker2.yaml    | 237 ++++++++++++++++++
 2 files changed, 246 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml
Documentation/devicetree/bindings/riscv/worlds.yaml +0 -0
index cc8b3747591e..c39a06c2dd8d 100644

Documentation/devicetree/bindings/riscv/worlds.yaml properties: · line 37

Quoted 4 lines
Documentation/devicetree/bindings/riscv/worlds.yaml +1 -0
@@ -34,6 +34,14 @@ properties:
     minimum: 2
     maximum: 64
 
+  sifive,trustedwid:

What's sifive specific about this? Wouldn't other vendors also have trusted worlds?

Quoted 57 lines
Documentation/devicetree/bindings/riscv/worlds.yaml +8 -0
+    $ref: /schemas/types.yaml#/definitions/uint32
+    maximum: 31
+    description: |
+      The World ID (WID) designated as the trusted WID for this platform.
+      Transactions tagged with this WID are authorized to access and configure
+      WorldGuard blocks, including wgCheckers and wgMarkers.
+
 additionalProperties: true
 
 examples:
@@ -44,6 +52,7 @@ examples:
         #size-cells = <0>;
         timebase-frequency = <1000000>;
         riscv,nworlds = <4>;
+        sifive,trustedwid = <3>;
 
         cpu@0 {
             device_type = "cpu";
Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml new file +33 -0
new file mode 100644
index 000000000000..043c748385ed
@@ -0,0 +1,237 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright (C) 2026 SiFive, Inc.
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sifive/sifive,wgchecker2.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: SiFive WorldGuard Checker
+
+maintainers:
+  - Yu-Chien Peter Lin <[email protected]>
+
+description: |
+  The RISC-V Worlds ISA extension defines World IDs (WIDs) as architectural
+  identifiers that tag each system transaction with its originating context.
+  System integrators assign WIDs to execution contexts such as privilege modes,
+  trusted execution environments, or other isolation boundaries.
+
+  The SiFive WorldGuard Checker is a hardware firewall positioned in the
+  system interconnect fabric. It inspects every transaction, evaluating the
+  WID against access control policies encoded in checker slots for each
+  protected resource. Transactions from unauthorized WIDs are blocked and
+  reported as bus errors, interrupts, or both.
+
+  This enables spatial partitioning of memory regions and memory-mapped devices
+  across execution contexts. Different address ranges can enforce distinct
+  policies, allowing isolated workloads to coexist with hardware-enforced
+  protection.
+
+  The wgChecker acts as an access-controller provider as defined in the
+  access-controllers framework. Protected devices are consumers that declare
+  their access policy via the access-controllers property. The hardware
+  supports up to 32 World IDs.

Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml line 43

Quoted 10 lines
Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml new file +10 -0
+
+  The World ID authorized to configure WorldGuard blocks is specified by the
+  sifive,trustedwid property in the /cpus node.
+
+allOf:
+  - $ref: /schemas/access-controllers/access-controllers.yaml#
+
+properties:
+  compatible:
+    const: sifive,wgchecker2

Missing device specific compatibles.

Quoted 12 lines
Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml new file +12 -0
+
+  reg:
+    maxItems: 1
+    description:
+      Base address and size of the wgChecker memory-mapped I/O registers.
+
+  interrupts:
+    maxItems: 1
+    description:
+      Interrupt line asserted when a WID access violation is detected and
+      interrupt reporting is enabled in the slot configuration (IR or IW
+      bits set).

Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml line 65

Quoted 10 lines
Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml new file +10 -0
+
+  '#access-controller-cells':
+    const: 7
+    description: |
+      Specifier for one access-control rule, encoded as seven u32 cells:
+        <addr-hi addr-lo size-hi size-lo perm-hi perm-lo config>
+
+      where:
+        - addr-hi, addr-lo: 64-bit base address of the protected region.
+        - size-hi, size-lo: 64-bit size of the protected region in bytes.

These two cells effectively just duplicate the reg property.

Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml line 74

Quoted 9 lines
Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml new file +9 -0
+        - perm-hi: Permission bitmap for WIDs 16..31. Two bits per WID:
+                     bit 2*(WID-16)   = Read  permission
+                     bit 2*(WID-16)+1 = Write permission
+                   Set bits grant access. Use 0x0 for systems with
+                   riscv,nworlds <= 16.
+        - perm-lo: Permission bitmap for WIDs 0..15. Two bits per WID:
+                     bit 2*WID   = Read  permission
+                     bit 2*WID+1 = Write permission
+                   Set bits grant access.

And these two look like a layering violation to me. Why does the consumer contain its own configuration information? If firmware provides this to s-mode, it is either useless (because firmware has already done the configuration) or it makes the access control pointless because s-mode is expected to program its own access.
With that in mind, the first 4 cells can probably just be transmuted to a single cell with platform-specific unique identifiers. Surely the ecall involved with actually requesting access needs something like that anyway?

The only value I can see in this is if some worlds that a bit of software is running on can access a peripheral (or part thereof) and others can't? Though platforms like that might benefit more from being reworked to have homogeneous access! I've got no idea how a Linux driver etc would handle the only some CPUs being permitted to access a register region.

Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml line 81

Quoted 7 lines
Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml new file +7 -0
+        - config:  Slot configuration bits:
+                     Bit 0 (ER): Report read  violations as bus errors
+                     Bit 1 (EW): Report write violations as bus errors
+                     Bit 2 (IR): Report read  violations via interrupt
+                     Bit 3 (IW): Report write violations via interrupt
+                     Bit 4 (L):  Lock bit - prevents further modification
+                   Bits 5..31 are reserved and must be zero.

For the next revision of this, I really would like to see the access controller driver.

Quoted 40 lines
Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml new file +40 -0
+
+      Multiple entries may be listed to apply different policies to
+      different address ranges, including sub-ranges within a single
+      physical resource.
+
+required:
+  - compatible
+  - reg
+  - '#access-controller-cells'
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    // Example 1: Single device protection
+    // WID 0 and WID 3 have RW access to UART; errors and IRQs reported.
+
+    cpus {
+        #address-cells = <1>;
+        #size-cells = <0>;
+        timebase-frequency = <1000000>;
+        riscv,nworlds = <4>;
+        sifive,trustedwid = <3>;
+
+        cpu@0 {
+            device_type = "cpu";
+            reg = <0>;
+            compatible = "riscv";
+            riscv,isa = "rv64imac";
+        };
+    };
+
+    soc {
+        #address-cells = <2>;
+        #size-cells = <2>;
+
+        uart: uart@1c1000 {
+            compatible = "ns16550a";

Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml line 131

Quoted 10 lines
Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml new file +10 -0
+            reg = <0x0 0x001c1000 0x0 0x1000>;
+            reg-names = "control";
+            interrupts = <10 IRQ_TYPE_LEVEL_HIGH>;
+            // WID 0,3 RW; report errors+IRQs
+            access-controllers = <&wgchecker0
+                                  0x0 0x001c1000 0x0 0x00001000
+                                  0x0 0x000000c3 0x0f>;
+        };
+
+        wgchecker0: wgchecker@1c2000 {

I think this should be access-controller@

Quoted 7 lines
Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml new file +7 -0
+            compatible = "sifive,wgchecker2";
+            reg = <0x0 0x001c2000 0x0 0x1000>;
+            #access-controller-cells = <7>;
+            interrupts = <80 IRQ_TYPE_LEVEL_HIGH>;
+            interrupt-parent = <&aplic_m>;
+        };
+    };
#16 lore raw

Re: [RFC PATCH 3/3] dt-bindings: sifive: Add WorldGuard Checker

Hi Conor,

Quoted 24 lines · Conor Dooley
Quoted 23 lines · Yu-Chien Peter Lin

Add DT binding for SiFive wgChecker2, a hardware firewall enforcing WID-based access control in RISC-V Worlds. Provides checker slots to program per-WID permissions for downstream resources, with optional sub-range partitioning.

---
 .../devicetree/bindings/riscv/worlds.yaml     |   9 +
 .../bindings/sifive/sifive,wgchecker2.yaml    | 237 ++++++++++++++++++
 2 files changed, 246 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml
Documentation/devicetree/bindings/riscv/worlds.yaml +0 -0
index cc8b3747591e..c39a06c2dd8d 100644
@@ -34,6 +34,14 @@ properties:
     minimum: 2
     maximum: 64
 
Quoted 4 lines

Documentation/devicetree/bindings/riscv/worlds.yaml properties: · line 37

Quoted 1 line
Documentation/devicetree/bindings/riscv/worlds.yaml +1 -0
+  sifive,trustedwid:

What's sifive specific about this? Wouldn't other vendors also have trusted worlds?

The property is intended to identify the trusted WID, i.e. the trusted agent authorized for programming WorldGuard components such as wgChecker according to the policy specified in the device tree (see sifive,partition-rule below).

wgChecker is a proprietary Worlds-aware firewall and is not part of the RISC-V ISA specification, so the Worlds extension itself does not define a corresponding concept of a trusted world for this.

Quoted 62 lines
Quoted 62 lines
Documentation/devicetree/bindings/riscv/worlds.yaml +8 -0
+    $ref: /schemas/types.yaml#/definitions/uint32
+    maximum: 31
+    description: |
+      The World ID (WID) designated as the trusted WID for this platform.
+      Transactions tagged with this WID are authorized to access and configure
+      WorldGuard blocks, including wgCheckers and wgMarkers.
+
 additionalProperties: true
 
 examples:
@@ -44,6 +52,7 @@ examples:
         #size-cells = <0>;
         timebase-frequency = <1000000>;
         riscv,nworlds = <4>;
+        sifive,trustedwid = <3>;
 
         cpu@0 {
             device_type = "cpu";
Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml new file +37 -0
new file mode 100644
index 000000000000..043c748385ed
@@ -0,0 +1,237 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright (C) 2026 SiFive, Inc.
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sifive/sifive,wgchecker2.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: SiFive WorldGuard Checker
+
+maintainers:
+  - Yu-Chien Peter Lin <[email protected]>
+
+description: |
+  The RISC-V Worlds ISA extension defines World IDs (WIDs) as architectural
+  identifiers that tag each system transaction with its originating context.
+  System integrators assign WIDs to execution contexts such as privilege modes,
+  trusted execution environments, or other isolation boundaries.
+
+  The SiFive WorldGuard Checker is a hardware firewall positioned in the
+  system interconnect fabric. It inspects every transaction, evaluating the
+  WID against access control policies encoded in checker slots for each
+  protected resource. Transactions from unauthorized WIDs are blocked and
+  reported as bus errors, interrupts, or both.
+
+  This enables spatial partitioning of memory regions and memory-mapped devices
+  across execution contexts. Different address ranges can enforce distinct
+  policies, allowing isolated workloads to coexist with hardware-enforced
+  protection.
+
+  The wgChecker acts as an access-controller provider as defined in the
+  access-controllers framework. Protected devices are consumers that declare
+  their access policy via the access-controllers property. The hardware
+  supports up to 32 World IDs.
+
+  The World ID authorized to configure WorldGuard blocks is specified by the
+  sifive,trustedwid property in the /cpus node.
+
Quoted 8 lines

Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml line 43

Quoted 6 lines
Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml new file +6 -0
+allOf:
+  - $ref: /schemas/access-controllers/access-controllers.yaml#
+
+properties:
+  compatible:
+    const: sifive,wgchecker2

Missing device specific compatibles.

We will test on qemu, can I add "qemu,wgchecker2" here?

Quoted 17 lines
Quoted 17 lines
Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml new file +16 -0
+
+  reg:
+    maxItems: 1
+    description:
+      Base address and size of the wgChecker memory-mapped I/O registers.
+
+  interrupts:
+    maxItems: 1
+    description:
+      Interrupt line asserted when a WID access violation is detected and
+      interrupt reporting is enabled in the slot configuration (IR or IW
+      bits set).
+
+  '#access-controller-cells':
+    const: 7
+    description: |
Quoted 8 lines

Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml line 65

Quoted 6 lines
Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml new file +6 -0
+      Specifier for one access-control rule, encoded as seven u32 cells:
+        <addr-hi addr-lo size-hi size-lo perm-hi perm-lo config>
+
+      where:
+        - addr-hi, addr-lo: 64-bit base address of the protected region.
+        - size-hi, size-lo: 64-bit size of the protected region in bytes.

These two cells effectively just duplicate the reg property.

Agreed, will drop this region encoding.

Quoted 11 lines

Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml line 74

Quoted 10 lines
Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml new file +9 -0
+        - perm-hi: Permission bitmap for WIDs 16..31. Two bits per WID:
+                     bit 2*(WID-16)   = Read  permission
+                     bit 2*(WID-16)+1 = Write permission
+                   Set bits grant access. Use 0x0 for systems with
+                   riscv,nworlds <= 16.
+        - perm-lo: Permission bitmap for WIDs 0..15. Two bits per WID:
+                     bit 2*WID   = Read  permission
+                     bit 2*WID+1 = Write permission
+                   Set bits grant access.
Quoted 5 lines

And these two look like a layering violation to me. Why does the consumer contain its own configuration information? If firmware provides this to s-mode, it is either useless (because firmware has already done the configuration) or it makes the access control pointless because s-mode is expected to program its own access.

Yes — DT only describes the access rules. The wgChecker slots are programmed by M-mode firmware (OpenSBI), which holds the trusted WID.

riscv,pmwid = <3>;
sifive,trustedwid = <3>
M-mode : WID3 (sets mlwid to 0)
S/U-mode: WID0

It's fine for Linux to see the access rule, because WID0 is not the trusted WID and therefore cannot program the wgChecker configuration registers. For denied accesses, reads return zero data and writes are ignored.

Quoted 2 lines

With that in mind, the first 4 cells can probably just be transmuted to a single cell with platform-specific unique identifiers.

Good point, for memory partition use case, I plan to update the encoding to:

  ddr: memory@80000000 {
      device_type = "memory";
      reg = <0x0 0x80000000 0x0 0x80000000>;
      access-controllers = <&wgchecker2 0>, // partition ID: 0
                           <&wgchecker2 1>, // partition ID: 1
                           <&wgchecker2 2>; // partition ID: 2
  };
  
  wgchecker2: wgchecker@40000000 {
      compatible = "sifive,wgchecker2";
      reg = <0x0 0x40000000 0x0 0x1000>;
      #access-controller-cells = <1>;
      #address-cells = <2>;
      #size-cells = <2>;
      interrupts = <82 IRQ_TYPE_LEVEL_HIGH>;
      interrupt-parent = <&aplic_m>;
      partition@0 {
              reg = <0x0 0x80000000 0x0 0x40000000>;
              sifive,partition-id = <0>;
              /* (perm_hi, perm_lo, config) */
              sifive,partition-rule = <0x0 0x000000cf 0x0f>;
      };
  
      partition@1 {
              reg = <0x0 0xc0000000 0x0 0x01000000>;
              sifive,partition-id = <1>;
              /* (perm_hi, perm_lo, config) */
              sifive,partition-rule = <0x0 0x000000cc 0x0f>;
      };
  
      partition@2 {
              reg = <0x0 0xc1000000 0x0 0x3f000000>;
              sifive,partition-id = <2>;
              /* (perm_hi, perm_lo, config) */
              sifive,partition-rule = <0x0 0x000000cf 0x0f>;
      };

};

I hope this work for you.

Quoted 2 lines

Surely the ecall involved with actually requesting access needs something like that anyway?

In this initial support, there is no such interface for S-mode to request reconfiguration -- wgCheckers are programmed once at boot-time.

Quoted 7 lines

The only value I can see in this is if some worlds that a bit of software is running on can access a peripheral (or part thereof) and others can't? Though platforms like that might benefit more from being reworked to have homogeneous access! I've got no idea how a Linux driver etc would handle the only some CPUs being permitted to access a register region.

One use case is APLIC, which naturally has separate root-domain and child-domain regions and should be controlled by M-mode and S-mode respectively. A wgChecker can protect these regions with different access permissions, for example M-mode-only access for the root domain and M/S-mode access for the child domain.

The same mechanism can also support multiple supervisor domains e.g. for a TEE. As shown in third example, a DRAM sub-region may be carved out exclusively for the TEE.

Quoted 11 lines

Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml line 81

Quoted 8 lines
Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml new file +7 -0
+        - config:  Slot configuration bits:
+                     Bit 0 (ER): Report read  violations as bus errors
+                     Bit 1 (EW): Report write violations as bus errors
+                     Bit 2 (IR): Report read  violations via interrupt
+                     Bit 3 (IW): Report write violations via interrupt
+                     Bit 4 (L):  Lock bit - prevents further modification
+                   Bits 5..31 are reserved and must be zero.

For the next revision of this, I really would like to see the access controller driver.

Sure, the fdt driver will be added to OpenSBI. (Not in the kernel which runs untrusted WID).

Quoted 45 lines
Quoted 45 lines
Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml new file +44 -0
+
+      Multiple entries may be listed to apply different policies to
+      different address ranges, including sub-ranges within a single
+      physical resource.
+
+required:
+  - compatible
+  - reg
+  - '#access-controller-cells'
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    // Example 1: Single device protection
+    // WID 0 and WID 3 have RW access to UART; errors and IRQs reported.
+
+    cpus {
+        #address-cells = <1>;
+        #size-cells = <0>;
+        timebase-frequency = <1000000>;
+        riscv,nworlds = <4>;
+        sifive,trustedwid = <3>;
+
+        cpu@0 {
+            device_type = "cpu";
+            reg = <0>;
+            compatible = "riscv";
+            riscv,isa = "rv64imac";
+        };
+    };
+
+    soc {
+        #address-cells = <2>;
+        #size-cells = <2>;
+
+        uart: uart@1c1000 {
+            compatible = "ns16550a";
+            reg = <0x0 0x001c1000 0x0 0x1000>;
+            reg-names = "control";
+            interrupts = <10 IRQ_TYPE_LEVEL_HIGH>;
+            // WID 0,3 RW; report errors+IRQs
Quoted 8 lines

Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml line 131

Quoted 6 lines
Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml new file +6 -0
+            access-controllers = <&wgchecker0
+                                  0x0 0x001c1000 0x0 0x00001000
+                                  0x0 0x000000c3 0x0f>;
+        };
+
+        wgchecker0: wgchecker@1c2000 {

I think this should be access-controller@

Will update.

Thanks,
Peter Lin

#17 lore raw

Re: [RFC PATCH 3/3] dt-bindings: sifive: Add WorldGuard Checker

Quoted 32 lines · Yu-Chien Peter Lin

Hi Conor,

Quoted 24 lines · Conor Dooley
Quoted 23 lines · Yu-Chien Peter Lin

Add DT binding for SiFive wgChecker2, a hardware firewall enforcing WID-based access control in RISC-V Worlds. Provides checker slots to program per-WID permissions for downstream resources, with optional sub-range partitioning.

---
 .../devicetree/bindings/riscv/worlds.yaml     |   9 +
 .../bindings/sifive/sifive,wgchecker2.yaml    | 237 ++++++++++++++++++
 2 files changed, 246 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml
Documentation/devicetree/bindings/riscv/worlds.yaml +0 -0
index cc8b3747591e..c39a06c2dd8d 100644
@@ -34,6 +34,14 @@ properties:
     minimum: 2
     maximum: 64
 
Quoted 4 lines

Documentation/devicetree/bindings/riscv/worlds.yaml properties: · line 37

Quoted 1 line
Documentation/devicetree/bindings/riscv/worlds.yaml +1 -0
+  sifive,trustedwid:

What's sifive specific about this? Wouldn't other vendors also have trusted worlds?

Quoted 8 lines

The property is intended to identify the trusted WID, i.e. the trusted agent authorized for programming WorldGuard components such as wgChecker according to the policy specified in the device tree (see sifive,partition-rule below).

wgChecker is a proprietary Worlds-aware firewall and is not part of the RISC-V ISA specification, so the Worlds extension itself does not define a corresponding concept of a trusted world for this.

I'm just worried that I am going to see 15 different versions of this property when 14 other vendors also decide to create support for having a trusted world.

Quoted 72 lines
Quoted 63 lines
Quoted 63 lines
Documentation/devicetree/bindings/riscv/worlds.yaml +8 -0
+    $ref: /schemas/types.yaml#/definitions/uint32
+    maximum: 31
+    description: |
+      The World ID (WID) designated as the trusted WID for this platform.
+      Transactions tagged with this WID are authorized to access and configure
+      WorldGuard blocks, including wgCheckers and wgMarkers.
+
 additionalProperties: true
 
 examples:
@@ -44,6 +52,7 @@ examples:
         #size-cells = <0>;
         timebase-frequency = <1000000>;
         riscv,nworlds = <4>;
+        sifive,trustedwid = <3>;
 
         cpu@0 {
             device_type = "cpu";
Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml new file +37 -0
new file mode 100644
index 000000000000..043c748385ed
@@ -0,0 +1,237 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright (C) 2026 SiFive, Inc.
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sifive/sifive,wgchecker2.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: SiFive WorldGuard Checker
+
+maintainers:
+  - Yu-Chien Peter Lin <[email protected]>
+
+description: |
+  The RISC-V Worlds ISA extension defines World IDs (WIDs) as architectural
+  identifiers that tag each system transaction with its originating context.
+  System integrators assign WIDs to execution contexts such as privilege modes,
+  trusted execution environments, or other isolation boundaries.
+
+  The SiFive WorldGuard Checker is a hardware firewall positioned in the
+  system interconnect fabric. It inspects every transaction, evaluating the
+  WID against access control policies encoded in checker slots for each
+  protected resource. Transactions from unauthorized WIDs are blocked and
+  reported as bus errors, interrupts, or both.
+
+  This enables spatial partitioning of memory regions and memory-mapped devices
+  across execution contexts. Different address ranges can enforce distinct
+  policies, allowing isolated workloads to coexist with hardware-enforced
+  protection.
+
+  The wgChecker acts as an access-controller provider as defined in the
+  access-controllers framework. Protected devices are consumers that declare
+  their access policy via the access-controllers property. The hardware
+  supports up to 32 World IDs.
+
+  The World ID authorized to configure WorldGuard blocks is specified by the
+  sifive,trustedwid property in the /cpus node.
+
Quoted 8 lines

Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml line 43

Quoted 6 lines
Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml new file +6 -0
+allOf:
+  - $ref: /schemas/access-controllers/access-controllers.yaml#
+
+properties:
+  compatible:
+    const: sifive,wgchecker2

Missing device specific compatibles.

Quoted 1 line

We will test on qemu, can I add "qemu,wgchecker2" here?

Sure, with a fallback to the sifive,wgchecker2 compatible.

Quoted 46 lines
Quoted 15 lines
Quoted 15 lines
Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml new file +15 -0
+  reg:
+    maxItems: 1
+    description:
+      Base address and size of the wgChecker memory-mapped I/O registers.
+
+  interrupts:
+    maxItems: 1
+    description:
+      Interrupt line asserted when a WID access violation is detected and
+      interrupt reporting is enabled in the slot configuration (IR or IW
+      bits set).
+
+  '#access-controller-cells':
+    const: 7
+    description: |
Quoted 8 lines

Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml line 65

Quoted 6 lines
Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml new file +6 -0
+      Specifier for one access-control rule, encoded as seven u32 cells:
+        <addr-hi addr-lo size-hi size-lo perm-hi perm-lo config>
+
+      where:
+        - addr-hi, addr-lo: 64-bit base address of the protected region.
+        - size-hi, size-lo: 64-bit size of the protected region in bytes.

These two cells effectively just duplicate the reg property.

Agreed, will drop this region encoding.

Quoted 11 lines

Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml line 74

Quoted 10 lines
Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml new file +9 -0
+        - perm-hi: Permission bitmap for WIDs 16..31. Two bits per WID:
+                     bit 2*(WID-16)   = Read  permission
+                     bit 2*(WID-16)+1 = Write permission
+                   Set bits grant access. Use 0x0 for systems with
+                   riscv,nworlds <= 16.
+        - perm-lo: Permission bitmap for WIDs 0..15. Two bits per WID:
+                     bit 2*WID   = Read  permission
+                     bit 2*WID+1 = Write permission
+                   Set bits grant access.
Quoted 5 lines

And these two look like a layering violation to me. Why does the consumer contain its own configuration information? If firmware provides this to s-mode, it is either useless (because firmware has already done the configuration) or it makes the access control pointless because s-mode is expected to program its own access.

Yes — DT only describes the access rules. The wgChecker slots are programmed by M-mode firmware (OpenSBI), which holds the trusted WID.

Quoted 8 lines

riscv,pmwid = <3>;
sifive,trustedwid = <3>
M-mode : WID3 (sets mlwid to 0)
S/U-mode: WID0

It's fine for Linux to see the access rule, because WID0 is not the trusted WID and therefore cannot program the wgChecker configuration registers. For denied accesses, reads return zero data and writes are ignored.

I think you misunderstood, I don't mind linux seeing it, I think having the configuration information in the consumer node is the problem. Your example below goes away from that, which I approve of.

Quoted 24 lines
Quoted 3 lines

With that in mind, the first 4 cells can probably just be transmuted to a single cell with platform-specific unique identifiers.

Good point, for memory partition use case, I plan to update the encoding to:

  ddr: memory@80000000 {
      device_type = "memory";
      reg = <0x0 0x80000000 0x0 0x80000000>;
      access-controllers = <&wgchecker2 0>, // partition ID: 0
                           <&wgchecker2 1>, // partition ID: 1
                           <&wgchecker2 2>; // partition ID: 2
  };
  
  wgchecker2: wgchecker@40000000 {
      compatible = "sifive,wgchecker2";
      reg = <0x0 0x40000000 0x0 0x1000>;
      #access-controller-cells = <1>;
      #address-cells = <2>;
      #size-cells = <2>;
      interrupts = <82 IRQ_TYPE_LEVEL_HIGH>;
      interrupt-parent = <&aplic_m>;
Quoted 3 lines
      partition@0 {
              reg = <0x0 0x80000000 0x0 0x40000000>;
              sifive,partition-id = <0>;

You're gonna cause issues with this because the node address matches your "partition id" property when it needs to match reg. Matching "partition id" rather than what you have as "reg" actually makes more sense though, so I would retain that.
I'd be include to move sifive,partition-id to reg and then rework your reg property to some new name, because it doesn't describe a register region belonging to this device.
Possibly I would split what's currently called reg into separate size and address properties and split partition-rule too.

Does the final "config" bit of partition-rule provide any value to consumers? The answer is no, right? Cos the interrupts are going to be reported to m-mode rather than s-mode.

Quoted 19 lines
              /* (perm_hi, perm_lo, config) */
              sifive,partition-rule = <0x0 0x000000cf 0x0f>;
      };
  
      partition@1 {
              reg = <0x0 0xc0000000 0x0 0x01000000>;
              sifive,partition-id = <1>;
              /* (perm_hi, perm_lo, config) */
              sifive,partition-rule = <0x0 0x000000cc 0x0f>;
      };
  
      partition@2 {
              reg = <0x0 0xc1000000 0x0 0x3f000000>;
              sifive,partition-id = <2>;
              /* (perm_hi, perm_lo, config) */
              sifive,partition-rule = <0x0 0x000000cf 0x0f>;
      };

};

Quoted 8 lines

I hope this work for you.

Quoted 2 lines

Surely the ecall involved with actually requesting access needs something like that anyway?

In this initial support, there is no such interface for S-mode to request reconfiguration -- wgCheckers are programmed once at boot-time.

Right, but we need to consider what the final support will look like when writing the binding!

Quoted 26 lines
Quoted 6 lines

The only value I can see in this is if some worlds that a bit of software is running on can access a peripheral (or part thereof) and others can't? Though platforms like that might benefit more from being reworked to have homogeneous access! I've got no idea how a Linux driver etc would handle the only some CPUs being permitted to access a register region.

One use case is APLIC, which naturally has separate root-domain and child-domain regions and should be controlled by M-mode and S-mode respectively. A wgChecker can protect these regions with different access permissions, for example M-mode-only access for the root domain and M/S-mode access for the child domain.

The same mechanism can also support multiple supervisor domains e.g. for a TEE. As shown in third example, a DRAM sub-region may be carved out exclusively for the TEE.

Quoted 9 lines
Quoted 8 lines
Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml new file +7 -0
+        - config:  Slot configuration bits:
+                     Bit 0 (ER): Report read  violations as bus errors
+                     Bit 1 (EW): Report write violations as bus errors
+                     Bit 2 (IR): Report read  violations via interrupt
+                     Bit 3 (IW): Report write violations via interrupt
+                     Bit 4 (L):  Lock bit - prevents further modification
+                   Bits 5..31 are reserved and must be zero.
Quoted 5 lines
Quoted 2 lines

For the next revision of this, I really would like to see the access controller driver.

Sure, the fdt driver will be added to OpenSBI. (Not in the kernel which runs untrusted WID).

Whether or not you are trusted, does it not make sense to be able to request that the firmware give you access to a peripheral? Ultimately opensbi will be making the configuration edits, but I don't think the kernel being untrusted precludes it having an access controller driver, as that driver will just use an ecall rather than manipulate directly.

That said, I will not expect you to provide that driver now, but unless reconfiguration at runtime is not supported by hardware this needs to be considered.

Cheers,
Conor.

Quoted 59 lines
Quoted 46 lines
Quoted 46 lines
Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml new file +44 -0
+
+      Multiple entries may be listed to apply different policies to
+      different address ranges, including sub-ranges within a single
+      physical resource.
+
+required:
+  - compatible
+  - reg
+  - '#access-controller-cells'
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    // Example 1: Single device protection
+    // WID 0 and WID 3 have RW access to UART; errors and IRQs reported.
+
+    cpus {
+        #address-cells = <1>;
+        #size-cells = <0>;
+        timebase-frequency = <1000000>;
+        riscv,nworlds = <4>;
+        sifive,trustedwid = <3>;
+
+        cpu@0 {
+            device_type = "cpu";
+            reg = <0>;
+            compatible = "riscv";
+            riscv,isa = "rv64imac";
+        };
+    };
+
+    soc {
+        #address-cells = <2>;
+        #size-cells = <2>;
+
+        uart: uart@1c1000 {
+            compatible = "ns16550a";
+            reg = <0x0 0x001c1000 0x0 0x1000>;
+            reg-names = "control";
+            interrupts = <10 IRQ_TYPE_LEVEL_HIGH>;
+            // WID 0,3 RW; report errors+IRQs
Quoted 8 lines

Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml line 131

Quoted 6 lines
Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml new file +6 -0
+            access-controllers = <&wgchecker0
+                                  0x0 0x001c1000 0x0 0x00001000
+                                  0x0 0x000000c3 0x0f>;
+        };
+
+        wgchecker0: wgchecker@1c2000 {

I think this should be access-controller@

Will update.

Thanks,
Peter Lin

#18 lore raw

Re: [RFC PATCH 3/3] dt-bindings: sifive: Add WorldGuard Checker

Quoted 38 lines · Conor Dooley
Quoted 37 lines · Yu-Chien Peter Lin

Hi Conor,

Quoted 24 lines · Conor Dooley
Quoted 23 lines · Yu-Chien Peter Lin

Add DT binding for SiFive wgChecker2, a hardware firewall enforcing WID-based access control in RISC-V Worlds. Provides checker slots to program per-WID permissions for downstream resources, with optional sub-range partitioning.

---
 .../devicetree/bindings/riscv/worlds.yaml     |   9 +
 .../bindings/sifive/sifive,wgchecker2.yaml    | 237 ++++++++++++++++++
 2 files changed, 246 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml
Documentation/devicetree/bindings/riscv/worlds.yaml +0 -0
index cc8b3747591e..c39a06c2dd8d 100644
@@ -34,6 +34,14 @@ properties:
     minimum: 2
     maximum: 64
 
Quoted 4 lines

Documentation/devicetree/bindings/riscv/worlds.yaml properties: · line 37

Quoted 1 line
Documentation/devicetree/bindings/riscv/worlds.yaml +1 -0
+  sifive,trustedwid:

What's sifive specific about this? Wouldn't other vendors also have trusted worlds?

The property is intended to identify the trusted WID, i.e. the trusted agent authorized for programming WorldGuard components such as wgChecker according to the policy specified in the device tree (see sifive,partition-rule below).

Quoted 7 lines
Quoted 3 lines

wgChecker is a proprietary Worlds-aware firewall and is not part of the RISC-V ISA specification, so the Worlds extension itself does not define a corresponding concept of a trusted world for this.

I'm just worried that I am going to see 15 different versions of this property when 14 other vendors also decide to create support for having a trusted world.

That is a fair concern. However, future RISC-V platforms will likely adopt the IOPMP specification, which may secure its registers via other memory protection mechanism (e.g. PMP) and hardware locks instead of a trusted WID. I expect this property will remain specific to SiFive.

Quoted 164 lines
Quoted 73 lines
Quoted 64 lines
Quoted 64 lines
Documentation/devicetree/bindings/riscv/worlds.yaml +8 -0
+    $ref: /schemas/types.yaml#/definitions/uint32
+    maximum: 31
+    description: |
+      The World ID (WID) designated as the trusted WID for this platform.
+      Transactions tagged with this WID are authorized to access and configure
+      WorldGuard blocks, including wgCheckers and wgMarkers.
+
 additionalProperties: true
 
 examples:
@@ -44,6 +52,7 @@ examples:
         #size-cells = <0>;
         timebase-frequency = <1000000>;
         riscv,nworlds = <4>;
+        sifive,trustedwid = <3>;
 
         cpu@0 {
             device_type = "cpu";
Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml new file +37 -0
new file mode 100644
index 000000000000..043c748385ed
@@ -0,0 +1,237 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright (C) 2026 SiFive, Inc.
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sifive/sifive,wgchecker2.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: SiFive WorldGuard Checker
+
+maintainers:
+  - Yu-Chien Peter Lin <[email protected]>
+
+description: |
+  The RISC-V Worlds ISA extension defines World IDs (WIDs) as architectural
+  identifiers that tag each system transaction with its originating context.
+  System integrators assign WIDs to execution contexts such as privilege modes,
+  trusted execution environments, or other isolation boundaries.
+
+  The SiFive WorldGuard Checker is a hardware firewall positioned in the
+  system interconnect fabric. It inspects every transaction, evaluating the
+  WID against access control policies encoded in checker slots for each
+  protected resource. Transactions from unauthorized WIDs are blocked and
+  reported as bus errors, interrupts, or both.
+
+  This enables spatial partitioning of memory regions and memory-mapped devices
+  across execution contexts. Different address ranges can enforce distinct
+  policies, allowing isolated workloads to coexist with hardware-enforced
+  protection.
+
+  The wgChecker acts as an access-controller provider as defined in the
+  access-controllers framework. Protected devices are consumers that declare
+  their access policy via the access-controllers property. The hardware
+  supports up to 32 World IDs.
+
+  The World ID authorized to configure WorldGuard blocks is specified by the
+  sifive,trustedwid property in the /cpus node.
+
Quoted 8 lines

Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml line 43

Quoted 6 lines
Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml new file +6 -0
+allOf:
+  - $ref: /schemas/access-controllers/access-controllers.yaml#
+
+properties:
+  compatible:
+    const: sifive,wgchecker2

Missing device specific compatibles.

Quoted 1 line

We will test on qemu, can I add "qemu,wgchecker2" here?

Sure, with a fallback to the sifive,wgchecker2 compatible.

Quoted 46 lines
Quoted 15 lines
Quoted 15 lines
Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml new file +15 -0
+  reg:
+    maxItems: 1
+    description:
+      Base address and size of the wgChecker memory-mapped I/O registers.
+
+  interrupts:
+    maxItems: 1
+    description:
+      Interrupt line asserted when a WID access violation is detected and
+      interrupt reporting is enabled in the slot configuration (IR or IW
+      bits set).
+
+  '#access-controller-cells':
+    const: 7
+    description: |
Quoted 8 lines

Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml line 65

Quoted 6 lines
Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml new file +6 -0
+      Specifier for one access-control rule, encoded as seven u32 cells:
+        <addr-hi addr-lo size-hi size-lo perm-hi perm-lo config>
+
+      where:
+        - addr-hi, addr-lo: 64-bit base address of the protected region.
+        - size-hi, size-lo: 64-bit size of the protected region in bytes.

These two cells effectively just duplicate the reg property.

Agreed, will drop this region encoding.

Quoted 11 lines

Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml line 74

Quoted 10 lines
Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml new file +9 -0
+        - perm-hi: Permission bitmap for WIDs 16..31. Two bits per WID:
+                     bit 2*(WID-16)   = Read  permission
+                     bit 2*(WID-16)+1 = Write permission
+                   Set bits grant access. Use 0x0 for systems with
+                   riscv,nworlds <= 16.
+        - perm-lo: Permission bitmap for WIDs 0..15. Two bits per WID:
+                     bit 2*WID   = Read  permission
+                     bit 2*WID+1 = Write permission
+                   Set bits grant access.
Quoted 5 lines

And these two look like a layering violation to me. Why does the consumer contain its own configuration information? If firmware provides this to s-mode, it is either useless (because firmware has already done the configuration) or it makes the access control pointless because s-mode is expected to program its own access.

Yes — DT only describes the access rules. The wgChecker slots are programmed by M-mode firmware (OpenSBI), which holds the trusted WID.

Quoted 8 lines

riscv,pmwid = <3>;
sifive,trustedwid = <3>
M-mode : WID3 (sets mlwid to 0)
S/U-mode: WID0

It's fine for Linux to see the access rule, because WID0 is not the trusted WID and therefore cannot program the wgChecker configuration registers. For denied accesses, reads return zero data and writes are ignored.

I think you misunderstood, I don't mind linux seeing it, I think having the configuration information in the consumer node is the problem. Your example below goes away from that, which I approve of.

Quoted 24 lines
Quoted 3 lines

With that in mind, the first 4 cells can probably just be transmuted to a single cell with platform-specific unique identifiers.

Good point, for memory partition use case, I plan to update the encoding to:

  ddr: memory@80000000 {
      device_type = "memory";
      reg = <0x0 0x80000000 0x0 0x80000000>;
      access-controllers = <&wgchecker2 0>, // partition ID: 0
                           <&wgchecker2 1>, // partition ID: 1
                           <&wgchecker2 2>; // partition ID: 2
  };
  
  wgchecker2: wgchecker@40000000 {
      compatible = "sifive,wgchecker2";
      reg = <0x0 0x40000000 0x0 0x1000>;
      #access-controller-cells = <1>;
      #address-cells = <2>;
      #size-cells = <2>;
      interrupts = <82 IRQ_TYPE_LEVEL_HIGH>;
      interrupt-parent = <&aplic_m>;
Quoted 3 lines
      partition@0 {
              reg = <0x0 0x80000000 0x0 0x40000000>;
              sifive,partition-id = <0>;
Quoted 9 lines

You're gonna cause issues with this because the node address matches your "partition id" property when it needs to match reg. Matching "partition id" rather than what you have as "reg" actually makes more sense though, so I would retain that.
I'd be include to move sifive,partition-id to reg and then rework your reg property to some new name, because it doesn't describe a register region belonging to this device.
Possibly I would split what's currently called reg into separate size and address properties and split partition-rule too.

Thanks, Conor, for the suggestions. I’ll address these issues in PATCHv2. Please feel free to point out anything else.

Quoted 4 lines

Does the final "config" bit of partition-rule provide any value to consumers? The answer is no, right? Cos the interrupts are going to be reported to m-mode rather than s-mode.

Correct. The config flags are only useful to those who are authorized to program the wgChecker slots.

Quoted 25 lines
Quoted 25 lines
              /* (perm_hi, perm_lo, config) */
              sifive,partition-rule = <0x0 0x000000cf 0x0f>;
      };
  
      partition@1 {
              reg = <0x0 0xc0000000 0x0 0x01000000>;
              sifive,partition-id = <1>;
              /* (perm_hi, perm_lo, config) */
              sifive,partition-rule = <0x0 0x000000cc 0x0f>;
      };
  
      partition@2 {
              reg = <0x0 0xc1000000 0x0 0x3f000000>;
              sifive,partition-id = <2>;
              /* (perm_hi, perm_lo, config) */
              sifive,partition-rule = <0x0 0x000000cf 0x0f>;
      };

};

I hope this work for you.

Quoted 2 lines

Surely the ecall involved with actually requesting access needs something like that anyway?

Quoted 6 lines
Quoted 3 lines

In this initial support, there is no such interface for S-mode to request reconfiguration -- wgCheckers are programmed once at boot-time.

Right, but we need to consider what the final support will look like when writing the binding!

Understood.

Quoted 39 lines
Quoted 27 lines
Quoted 7 lines

The only value I can see in this is if some worlds that a bit of software is running on can access a peripheral (or part thereof) and others can't? Though platforms like that might benefit more from being reworked to have homogeneous access! I've got no idea how a Linux driver etc would handle the only some CPUs being permitted to access a register region.

One use case is APLIC, which naturally has separate root-domain and child-domain regions and should be controlled by M-mode and S-mode respectively. A wgChecker can protect these regions with different access permissions, for example M-mode-only access for the root domain and M/S-mode access for the child domain.

The same mechanism can also support multiple supervisor domains e.g. for a TEE. As shown in third example, a DRAM sub-region may be carved out exclusively for the TEE.

Quoted 9 lines
Quoted 8 lines
Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml new file +7 -0
+        - config:  Slot configuration bits:
+                     Bit 0 (ER): Report read  violations as bus errors
+                     Bit 1 (EW): Report write violations as bus errors
+                     Bit 2 (IR): Report read  violations via interrupt
+                     Bit 3 (IW): Report write violations via interrupt
+                     Bit 4 (L):  Lock bit - prevents further modification
+                   Bits 5..31 are reserved and must be zero.
Quoted 5 lines
Quoted 2 lines

For the next revision of this, I really would like to see the access controller driver.

Sure, the fdt driver will be added to OpenSBI. (Not in the kernel which runs untrusted WID).

Whether or not you are trusted, does it not make sense to be able to request that the firmware give you access to a peripheral? Ultimately opensbi will be making the configuration edits, but I don't think the kernel being untrusted precludes it having an access controller driver, as that driver will just use an ecall rather than manipulate directly.

Quoted 3 lines

That said, I will not expect you to provide that driver now, but unless reconfiguration at runtime is not supported by hardware this needs to be considered.

That is a very fair point, and TBH, we don't have an answer for now. Currently, our primary use cases for WorldGuard are focused on enforcing M/S-mode access boundary and static partitioning TEEs, S-mode kernels runs transparently within the areas designated by trusted agent.

Regards,
Peter Lin

Quoted 63 lines

Cheers,
Conor.

Quoted 59 lines
Quoted 46 lines
Quoted 46 lines
Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml new file +44 -0
+
+      Multiple entries may be listed to apply different policies to
+      different address ranges, including sub-ranges within a single
+      physical resource.
+
+required:
+  - compatible
+  - reg
+  - '#access-controller-cells'
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    // Example 1: Single device protection
+    // WID 0 and WID 3 have RW access to UART; errors and IRQs reported.
+
+    cpus {
+        #address-cells = <1>;
+        #size-cells = <0>;
+        timebase-frequency = <1000000>;
+        riscv,nworlds = <4>;
+        sifive,trustedwid = <3>;
+
+        cpu@0 {
+            device_type = "cpu";
+            reg = <0>;
+            compatible = "riscv";
+            riscv,isa = "rv64imac";
+        };
+    };
+
+    soc {
+        #address-cells = <2>;
+        #size-cells = <2>;
+
+        uart: uart@1c1000 {
+            compatible = "ns16550a";
+            reg = <0x0 0x001c1000 0x0 0x1000>;
+            reg-names = "control";
+            interrupts = <10 IRQ_TYPE_LEVEL_HIGH>;
+            // WID 0,3 RW; report errors+IRQs
Quoted 8 lines

Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml line 131

Quoted 6 lines
Documentation/devicetree/bindings/sifive/sifive,wgchecker2.yaml new file +6 -0
+            access-controllers = <&wgchecker0
+                                  0x0 0x001c1000 0x0 0x00001000
+                                  0x0 0x000000c3 0x0f>;
+        };
+
+        wgchecker0: wgchecker@1c2000 {

I think this should be access-controller@

Will update.

Thanks,
Peter Lin