[PATCH v4 06/11] dt-bindings: riscv: Add B ISA extension description

Guodong Xu posted 11 patches 4 weeks, 1 day ago
There is a newer version of this series
[PATCH v4 06/11] dt-bindings: riscv: Add B ISA extension description
Posted by Guodong Xu 4 weeks, 1 day ago
Add description of the single-letter B extension for Bit Manipulation.
B is mandatory for RVA23U64.

The B extension is ratified in the 20240411 version of the unprivileged
ISA specification. According to the ratified spec, the B standard
extension comprises instructions provided by the Zba, Zbb, and Zbs
extensions.

Add two-way dependency check to enforce that B implies Zba/Zbb/Zbs; and
when Zba/Zbb/Zbs (all of them) are specified, then B must be added too.

The reason why B/Zba/Zbb/Zbs must coexist at the same time is that
unlike other single-letter extensions, B was ratified (Apr/2024) much
later than its component extensions Zba/Zbb/Zbs (Jun/2021).

When "b" is specified, zba/zbb/zbs must be present to ensure
backward compatibility with existing software and kernels that only
look for the explicit component strings.

When all three components zba/zbb/zbs are specified, "b" should also be
present. Making "b" mandatory when all three components are present.

Existing devicetrees with zba/zbb/zbs but without "b" will generate
warnings that can be fixed in follow-up patches.

Signed-off-by: Guodong Xu <guodong@riscstar.com>
---
v4: No change.
v3: Update the commit message to explain the retionale why B and
     Zba/Zbb/Zbs should all exist in DT.
v2: New patch.
---
 .../devicetree/bindings/riscv/extensions.yaml      | 31 ++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/Documentation/devicetree/bindings/riscv/extensions.yaml b/Documentation/devicetree/bindings/riscv/extensions.yaml
index b615083f2544..f671299ac819 100644
--- a/Documentation/devicetree/bindings/riscv/extensions.yaml
+++ b/Documentation/devicetree/bindings/riscv/extensions.yaml
@@ -109,6 +109,13 @@ properties:
             The standard C extension for compressed instructions, as ratified in
             the 20191213 version of the unprivileged ISA specification.
 
+        - const: b
+          description:
+            The standard B extension for bit manipulation instructions, as
+            ratified in the 20240411 version of the unprivileged ISA
+            specification. The B standard extension comprises instructions
+            provided by the Zba, Zbb, and Zbs extensions.
+
         - const: v
           description:
             The standard V extension for vector operations, as ratified
@@ -752,6 +759,30 @@ properties:
         then:
           contains:
             const: f
+      # B comprises Zba, Zbb, and Zbs
+      - if:
+          contains:
+            const: b
+        then:
+          allOf:
+            - contains:
+                const: zba
+            - contains:
+                const: zbb
+            - contains:
+                const: zbs
+      # Zba, Zbb, Zbs together require B
+      - if:
+          allOf:
+            - contains:
+                const: zba
+            - contains:
+                const: zbb
+            - contains:
+                const: zbs
+        then:
+          contains:
+            const: b
       # Zcb depends on Zca
       - if:
           contains:

-- 
2.43.0
Re: [PATCH v4 06/11] dt-bindings: riscv: Add B ISA extension description
Posted by Conor Dooley 3 weeks, 5 days ago
On Sat, Jan 10, 2026 at 01:18:18PM +0800, Guodong Xu wrote:
> Add description of the single-letter B extension for Bit Manipulation.
> B is mandatory for RVA23U64.
> 
> The B extension is ratified in the 20240411 version of the unprivileged
> ISA specification. According to the ratified spec, the B standard
> extension comprises instructions provided by the Zba, Zbb, and Zbs
> extensions.
> 
> Add two-way dependency check to enforce that B implies Zba/Zbb/Zbs; and
> when Zba/Zbb/Zbs (all of them) are specified, then B must be added too.
> 
> The reason why B/Zba/Zbb/Zbs must coexist at the same time is that
> unlike other single-letter extensions, B was ratified (Apr/2024) much
> later than its component extensions Zba/Zbb/Zbs (Jun/2021).
> 
> When "b" is specified, zba/zbb/zbs must be present to ensure
> backward compatibility with existing software and kernels that only
> look for the explicit component strings.
> 
> When all three components zba/zbb/zbs are specified, "b" should also be
> present. Making "b" mandatory when all three components are present.

> Existing devicetrees with zba/zbb/zbs but without "b" will generate
> warnings that can be fixed in follow-up patches.

Are you going to send these fixup patches for other devicetrees? The
majority appear to be other spacemit devices.
Re: [PATCH v4 06/11] dt-bindings: riscv: Add B ISA extension description
Posted by Guodong Xu 3 weeks, 5 days ago
Hi, Conor

On Tue, Jan 13, 2026 at 5:41 AM Conor Dooley <conor@kernel.org> wrote:
>
> On Sat, Jan 10, 2026 at 01:18:18PM +0800, Guodong Xu wrote:
> > Add description of the single-letter B extension for Bit Manipulation.
> > B is mandatory for RVA23U64.
> >
> > The B extension is ratified in the 20240411 version of the unprivileged
> > ISA specification. According to the ratified spec, the B standard
> > extension comprises instructions provided by the Zba, Zbb, and Zbs
> > extensions.
> >
> > Add two-way dependency check to enforce that B implies Zba/Zbb/Zbs; and
> > when Zba/Zbb/Zbs (all of them) are specified, then B must be added too.
> >
> > The reason why B/Zba/Zbb/Zbs must coexist at the same time is that
> > unlike other single-letter extensions, B was ratified (Apr/2024) much
> > later than its component extensions Zba/Zbb/Zbs (Jun/2021).
> >
> > When "b" is specified, zba/zbb/zbs must be present to ensure
> > backward compatibility with existing software and kernels that only
> > look for the explicit component strings.
> >
> > When all three components zba/zbb/zbs are specified, "b" should also be
> > present. Making "b" mandatory when all three components are present.
>
> > Existing devicetrees with zba/zbb/zbs but without "b" will generate
> > warnings that can be fixed in follow-up patches.
>
> Are you going to send these fixup patches for other devicetrees? The
> majority appear to be other spacemit devices.

Yes, I will. My check shows that these three dtsi files need to be updated to
include the newly ratified "b" extension:

arch/riscv/boot/dts/anlogic/dr1v90.dtsi
arch/riscv/boot/dts/sophgo/sg2044-cpus.dtsi
arch/riscv/boot/dts/spacemit/k1.dtsi

I will start a follow up patch to update these dtsi files. Basically, adding
"b" into both the "riscv,isa-extensions" and "riscv,isa" (when available)
fields.

Thank you for your review.

Best regards,
Guodong Xu