riscv: hwprobe: export vector crypto ISA extensions
authorClément Léger <cleger@rivosinc.com>
Tue, 14 Nov 2023 14:12:43 +0000 (09:12 -0500)
committerPalmer Dabbelt <palmer@rivosinc.com>
Tue, 12 Dec 2023 23:45:04 +0000 (15:45 -0800)
Export Zv* vector crypto ISA extensions that were added in "RISC-V
Cryptography Extensions Volume II" specification[1] through hwprobe.
This adds support for the following instructions:

- Zvbb: Vector Basic Bit-manipulation
- Zvbc: Vector Carryless Multiplication
- Zvkb: Vector Cryptography Bit-manipulation
- Zvkg: Vector GCM/GMAC.
- Zvkned: NIST Suite: Vector AES Block Cipher
- Zvknh[ab]: NIST Suite: Vector SHA-2 Secure Hash
- Zvksed: ShangMi Suite: SM4 Block Cipher
- Zvksh: ShangMi Suite: SM3 Secure Hash
- Zvknc: NIST Algorithm Suite with carryless multiply
- Zvkng: NIST Algorithm Suite with GCM.
- Zvksc: ShangMi Algorithm Suite with carryless multiplication
- Zvksg: ShangMi Algorithm Suite with GCM.
- Zvkt: Vector Data-Independent Execution Latency.

Zvkn and Zvks are ommited since they are a superset of other extensions.

Link: https://drive.google.com/file/d/1gb9OLH-DhbCgWp7VwpPOVrrY6f3oSJLL/view
Signed-off-by: Clément Léger <cleger@rivosinc.com>
Reviewed-by: Evan Green <evan@rivosinc.com>
Link: https://lore.kernel.org/r/20231114141256.126749-8-cleger@rivosinc.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Documentation/arch/riscv/hwprobe.rst
arch/riscv/include/uapi/asm/hwprobe.h
arch/riscv/kernel/sys_riscv.c

index 3a18a31e32c3659de06da806d9f2ec05e62b9534..a08fcd899b6dbe95b1f4c1875187dc4750f40d17 100644 (file)
@@ -110,6 +110,36 @@ The following keys are defined:
   * :c:macro:`RISCV_HWPROBE_EXT_ZKT` The Zkt extension is supported, as defined
        in version 1.0 of the Scalar Crypto ISA extensions.
 
+  * :c:macro:`RISCV_HWPROBE_EXT_ZVBB`: The Zvbb extension is supported as
+       defined in version 1.0 of the RISC-V Cryptography Extensions Volume II.
+
+  * :c:macro:`RISCV_HWPROBE_EXT_ZVBC`: The Zvbc extension is supported as
+       defined in version 1.0 of the RISC-V Cryptography Extensions Volume II.
+
+  * :c:macro:`RISCV_HWPROBE_EXT_ZVKB`: The Zvkb extension is supported as
+       defined in version 1.0 of the RISC-V Cryptography Extensions Volume II.
+
+  * :c:macro:`RISCV_HWPROBE_EXT_ZVKG`: The Zvkg extension is supported as
+       defined in version 1.0 of the RISC-V Cryptography Extensions Volume II.
+
+  * :c:macro:`RISCV_HWPROBE_EXT_ZVKNED`: The Zvkned extension is supported as
+       defined in version 1.0 of the RISC-V Cryptography Extensions Volume II.
+
+  * :c:macro:`RISCV_HWPROBE_EXT_ZVKNHA`: The Zvknha extension is supported as
+       defined in version 1.0 of the RISC-V Cryptography Extensions Volume II.
+
+  * :c:macro:`RISCV_HWPROBE_EXT_ZVKNHB`: The Zvknhb extension is supported as
+       defined in version 1.0 of the RISC-V Cryptography Extensions Volume II.
+
+  * :c:macro:`RISCV_HWPROBE_EXT_ZVKSED`: The Zvksed extension is supported as
+       defined in version 1.0 of the RISC-V Cryptography Extensions Volume II.
+
+  * :c:macro:`RISCV_HWPROBE_EXT_ZVKSH`: The Zvksh extension is supported as
+       defined in version 1.0 of the RISC-V Cryptography Extensions Volume II.
+
+  * :c:macro:`RISCV_HWPROBE_EXT_ZVKT`: The Zvkt extension is supported as
+       defined in version 1.0 of the RISC-V Cryptography Extensions Volume II.
+
 * :c:macro:`RISCV_HWPROBE_KEY_CPUPERF_0`: A bitmask that contains performance
   information about the selected set of processors.
 
index 624abd5cde2935d46809a8e0de85e72e27456826..89628a76ca04735298db6122d9b8c2e10734d32b 100644 (file)
@@ -40,6 +40,16 @@ struct riscv_hwprobe {
 #define                RISCV_HWPROBE_EXT_ZKSED         (1 << 14)
 #define                RISCV_HWPROBE_EXT_ZKSH          (1 << 15)
 #define                RISCV_HWPROBE_EXT_ZKT           (1 << 16)
+#define                RISCV_HWPROBE_EXT_ZVBB          (1 << 17)
+#define                RISCV_HWPROBE_EXT_ZVBC          (1 << 18)
+#define                RISCV_HWPROBE_EXT_ZVKB          (1 << 19)
+#define                RISCV_HWPROBE_EXT_ZVKG          (1 << 20)
+#define                RISCV_HWPROBE_EXT_ZVKNED        (1 << 21)
+#define                RISCV_HWPROBE_EXT_ZVKNHA        (1 << 22)
+#define                RISCV_HWPROBE_EXT_ZVKNHB        (1 << 23)
+#define                RISCV_HWPROBE_EXT_ZVKSED        (1 << 24)
+#define                RISCV_HWPROBE_EXT_ZVKSH         (1 << 25)
+#define                RISCV_HWPROBE_EXT_ZVKT          (1 << 26)
 #define RISCV_HWPROBE_KEY_CPUPERF_0    5
 #define                RISCV_HWPROBE_MISALIGNED_UNKNOWN        (0 << 0)
 #define                RISCV_HWPROBE_MISALIGNED_EMULATED       (1 << 0)
index 43aa66e71418ef5a9978cfa2835dc7a92089ab9f..9bbcd7334d96dc93c1eae721d4878c08b5d34723 100644 (file)
@@ -173,6 +173,19 @@ static void hwprobe_isa_ext0(struct riscv_hwprobe *pair,
                EXT_KEY(ZKSED);
                EXT_KEY(ZKSH);
                EXT_KEY(ZKT);
+
+               if (has_vector()) {
+                       EXT_KEY(ZVBB);
+                       EXT_KEY(ZVBC);
+                       EXT_KEY(ZVKB);
+                       EXT_KEY(ZVKG);
+                       EXT_KEY(ZVKNED);
+                       EXT_KEY(ZVKNHA);
+                       EXT_KEY(ZVKNHB);
+                       EXT_KEY(ZVKSED);
+                       EXT_KEY(ZVKSH);
+                       EXT_KEY(ZVKT);
+               }
 #undef EXT_KEY
        }