]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
riscv: cpufeature: Fix Zk bundled extension missing Zknh
authorGuodong Xu <guodong@riscstar.com>
Tue, 23 Dec 2025 02:44:27 +0000 (10:44 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 17 Jan 2026 15:35:25 +0000 (16:35 +0100)
[ Upstream commit 8632180daf735074a746ce2b3808a8f2c079310e ]

The Zk extension is a bundle consisting of Zkn, Zkr, and Zkt. The Zkn
extension itself is a bundle consisting of Zbkb, Zbkc, Zbkx, Zknd, Zkne,
and Zknh.

The current implementation of riscv_zk_bundled_exts manually listed
the dependencies but missed RISCV_ISA_EXT_ZKNH.

Fix this by introducing a RISCV_ISA_EXT_ZKN macro that lists the Zkn
components and using it in both riscv_zk_bundled_exts and
riscv_zkn_bundled_exts.

This adds the missing Zknh extension to Zk and reduces code duplication.

Fixes: 0d8295ed975b ("riscv: add ISA extension parsing for scalar crypto")
Link: https://patch.msgid.link/20231114141256.126749-4-cleger@rivosinc.com/
Signed-off-by: Guodong Xu <guodong@riscstar.com>
Reviewed-by: Clément Léger <cleger@rivosinc.com>
Link: https://patch.msgid.link/20251223-zk-missing-zknh-v1-1-b627c990ee1a@riscstar.com
Signed-off-by: Paul Walmsley <pjw@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/riscv/kernel/cpufeature.c

index 72ca768f4e9191dbe08271736fe9ea7d8e24b70b..2367e9755524adacbd08c16b5ab344a8ae3af503 100644 (file)
@@ -279,23 +279,22 @@ static const unsigned int riscv_a_exts[] = {
        RISCV_ISA_EXT_ZALRSC,
 };
 
+#define RISCV_ISA_EXT_ZKN      \
+       RISCV_ISA_EXT_ZBKB,     \
+       RISCV_ISA_EXT_ZBKC,     \
+       RISCV_ISA_EXT_ZBKX,     \
+       RISCV_ISA_EXT_ZKND,     \
+       RISCV_ISA_EXT_ZKNE,     \
+       RISCV_ISA_EXT_ZKNH
+
 static const unsigned int riscv_zk_bundled_exts[] = {
-       RISCV_ISA_EXT_ZBKB,
-       RISCV_ISA_EXT_ZBKC,
-       RISCV_ISA_EXT_ZBKX,
-       RISCV_ISA_EXT_ZKND,
-       RISCV_ISA_EXT_ZKNE,
+       RISCV_ISA_EXT_ZKN,
        RISCV_ISA_EXT_ZKR,
-       RISCV_ISA_EXT_ZKT,
+       RISCV_ISA_EXT_ZKT
 };
 
 static const unsigned int riscv_zkn_bundled_exts[] = {
-       RISCV_ISA_EXT_ZBKB,
-       RISCV_ISA_EXT_ZBKC,
-       RISCV_ISA_EXT_ZBKX,
-       RISCV_ISA_EXT_ZKND,
-       RISCV_ISA_EXT_ZKNE,
-       RISCV_ISA_EXT_ZKNH,
+       RISCV_ISA_EXT_ZKN
 };
 
 static const unsigned int riscv_zks_bundled_exts[] = {