From 3f8e67f69f2cd86e06763129375bf92808ba42bd Mon Sep 17 00:00:00 2001 From: Alexander Romanov Date: Thu, 13 Nov 2025 10:37:08 +0000 Subject: [PATCH] feat: support zvkb vector cryptography bitmanip subset extension This commit gates Zvkb behind Zvkb extension. Previously they were attached to Zvbb which is Zvkb's superset --- disasm/isa_parser.cc | 9 +++++++++ riscv/insns/vandn_vv.h | 2 +- riscv/insns/vandn_vx.h | 2 +- riscv/insns/vbrev8_v.h | 2 +- riscv/insns/vrev8_v.h | 2 +- riscv/insns/vrol_vv.h | 2 +- riscv/insns/vrol_vx.h | 2 +- riscv/insns/vror_vi.h | 2 +- riscv/insns/vror_vv.h | 2 +- riscv/insns/vror_vx.h | 2 +- riscv/isa_parser.h | 1 + riscv/zvk_ext_macros.h | 8 ++++++++ 12 files changed, 27 insertions(+), 9 deletions(-) diff --git a/disasm/isa_parser.cc b/disasm/isa_parser.cc index bc7f1d14..2869b35a 100644 --- a/disasm/isa_parser.cc +++ b/disasm/isa_parser.cc @@ -290,7 +290,10 @@ isa_parser_t::isa_parser_t(const char* str, const char *priv) extension_table[EXT_ZILSD] = true; } else if (ext_str == "zclsd") { extension_table[EXT_ZCLSD] = true; + } else if (ext_str == "zvkb") { + extension_table[EXT_ZVKB] = true; } else if (ext_str == "zvbb") { + extension_table[EXT_ZVKB] = true; extension_table[EXT_ZVBB] = true; } else if (ext_str == "zvbc") { extension_table[EXT_ZVBC] = true; @@ -301,15 +304,18 @@ isa_parser_t::isa_parser_t(const char* str, const char *priv) } else if (ext_str == "zvkg") { extension_table[EXT_ZVKG] = true; } else if (ext_str == "zvkn") { + extension_table[EXT_ZVKB] = true; extension_table[EXT_ZVBB] = true; extension_table[EXT_ZVKNED] = true; extension_table[EXT_ZVKNHB] = true; } else if (ext_str == "zvknc") { + extension_table[EXT_ZVKB] = true; extension_table[EXT_ZVBB] = true; extension_table[EXT_ZVBC] = true; extension_table[EXT_ZVKNED] = true; extension_table[EXT_ZVKNHB] = true; } else if (ext_str == "zvkng") { + extension_table[EXT_ZVKB] = true; extension_table[EXT_ZVBB] = true; extension_table[EXT_ZVKG] = true; extension_table[EXT_ZVKNED] = true; @@ -321,15 +327,18 @@ isa_parser_t::isa_parser_t(const char* str, const char *priv) } else if (ext_str == "zvknhb") { extension_table[EXT_ZVKNHB] = true; } else if (ext_str == "zvks") { + extension_table[EXT_ZVKB] = true; extension_table[EXT_ZVBB] = true; extension_table[EXT_ZVKSED] = true; extension_table[EXT_ZVKSH] = true; } else if (ext_str == "zvksc") { + extension_table[EXT_ZVKB] = true; extension_table[EXT_ZVBB] = true; extension_table[EXT_ZVBC] = true; extension_table[EXT_ZVKSED] = true; extension_table[EXT_ZVKSH] = true; } else if (ext_str == "zvksg") { + extension_table[EXT_ZVKB] = true; extension_table[EXT_ZVBB] = true; extension_table[EXT_ZVKG] = true; extension_table[EXT_ZVKSED] = true; diff --git a/riscv/insns/vandn_vv.h b/riscv/insns/vandn_vv.h index d85e47d7..411c97d5 100644 --- a/riscv/insns/vandn_vv.h +++ b/riscv/insns/vandn_vv.h @@ -2,7 +2,7 @@ #include "zvk_ext_macros.h" -require_zvbb; +require_zvkb; VI_VV_LOOP ({ diff --git a/riscv/insns/vandn_vx.h b/riscv/insns/vandn_vx.h index 1c66a409..417b8d2e 100644 --- a/riscv/insns/vandn_vx.h +++ b/riscv/insns/vandn_vx.h @@ -2,7 +2,7 @@ #include "zvk_ext_macros.h" -require_zvbb; +require_zvkb; VI_VX_LOOP ({ diff --git a/riscv/insns/vbrev8_v.h b/riscv/insns/vbrev8_v.h index a6d3cda7..19fa7235 100644 --- a/riscv/insns/vbrev8_v.h +++ b/riscv/insns/vbrev8_v.h @@ -2,7 +2,7 @@ #include "zvk_ext_macros.h" -require_zvbb; +require_zvkb; VI_V_ULOOP ({ diff --git a/riscv/insns/vrev8_v.h b/riscv/insns/vrev8_v.h index f26c5a05..e39c5c07 100644 --- a/riscv/insns/vrev8_v.h +++ b/riscv/insns/vrev8_v.h @@ -2,7 +2,7 @@ #include "zvk_ext_macros.h" -require_zvbb; +require_zvkb; VI_V_ULOOP ({ diff --git a/riscv/insns/vrol_vv.h b/riscv/insns/vrol_vv.h index fb2e4833..a2ac8324 100644 --- a/riscv/insns/vrol_vv.h +++ b/riscv/insns/vrol_vv.h @@ -2,7 +2,7 @@ #include "zvk_ext_macros.h" -require_zvbb; +require_zvkb; // 'mask' selects the low log2(vsew) bits of the shift amount, // to limit the maximum shift to "vsew - 1" bits. diff --git a/riscv/insns/vrol_vx.h b/riscv/insns/vrol_vx.h index b0c89a27..8e4b41b6 100644 --- a/riscv/insns/vrol_vx.h +++ b/riscv/insns/vrol_vx.h @@ -2,7 +2,7 @@ #include "zvk_ext_macros.h" -require_zvbb; +require_zvkb; // 'mask' selects the low log2(vsew) bits of the shift amount, // to limit the maximum shift to "vsew - 1" bits. diff --git a/riscv/insns/vror_vi.h b/riscv/insns/vror_vi.h index 1269c3d4..6ae9fcdb 100644 --- a/riscv/insns/vror_vi.h +++ b/riscv/insns/vror_vi.h @@ -2,7 +2,7 @@ #include "zvk_ext_macros.h" -require_zvbb; +require_zvkb; // 'mask' selects the low log2(vsew) bits of the shift amount, // to limit the maximum shift to "vsew - 1" bits. diff --git a/riscv/insns/vror_vv.h b/riscv/insns/vror_vv.h index c649c6d9..276d7ec2 100644 --- a/riscv/insns/vror_vv.h +++ b/riscv/insns/vror_vv.h @@ -2,7 +2,7 @@ #include "zvk_ext_macros.h" -require_zvbb; +require_zvkb; // 'mask' selects the low log2(vsew) bits of the shift amount, // to limit the maximum shift to "vsew - 1" bits. diff --git a/riscv/insns/vror_vx.h b/riscv/insns/vror_vx.h index 50c8e5c9..98e12483 100644 --- a/riscv/insns/vror_vx.h +++ b/riscv/insns/vror_vx.h @@ -2,7 +2,7 @@ #include "zvk_ext_macros.h" -require_zvbb; +require_zvkb; // 'mask' selects the low log2(vsew) bits of the shift amount, // to limit the maximum shift to "vsew - 1" bits. diff --git a/riscv/isa_parser.h b/riscv/isa_parser.h index bd9a032d..29bb1441 100644 --- a/riscv/isa_parser.h +++ b/riscv/isa_parser.h @@ -64,6 +64,7 @@ typedef enum { EXT_ZIHPM, EXT_ZILSD, EXT_ZVBB, + EXT_ZVKB, EXT_ZVBC, EXT_ZVFBFMIN, EXT_ZVFBFWMA, diff --git a/riscv/zvk_ext_macros.h b/riscv/zvk_ext_macros.h index 702ad917..e96e0a88 100644 --- a/riscv/zvk_ext_macros.h +++ b/riscv/zvk_ext_macros.h @@ -13,6 +13,14 @@ // Predicate Macros // +// Ensures that the ZVKB extension (vector crypto bitmanip subset) is present, +// and the vector unit is enabled and in a valid state. +#define require_zvkb \ + do { \ + require_vector(true); \ + require_extension(EXT_ZVKB); \ + } while (0) + // Ensures that the ZVBB extension (vector crypto bitmanip) is present, // and the vector unit is enabled and in a valid state. #define require_zvbb \