[PATCH] riscv: cpufeature: Fix Zk bundled extension missing Zknh

Guodong Xu posted 1 patch 1 month, 2 weeks ago
arch/riscv/kernel/cpufeature.c | 23 +++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)
[PATCH] riscv: cpufeature: Fix Zk bundled extension missing Zknh
Posted by Guodong Xu 1 month, 2 weeks ago
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>
---
 arch/riscv/kernel/cpufeature.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c
index b057362f8fb5f92d9a608b223666831d769a805c..f5855af0453d5ce206f8c8201ad108dfe4d300fb 100644
--- a/arch/riscv/kernel/cpufeature.c
+++ b/arch/riscv/kernel/cpufeature.c
@@ -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[] = {

---
base-commit: 9448598b22c50c8a5bb77a9103e2d49f134c9578
change-id: 20251223-zk-missing-zknh-262ffed774d2

Best regards,
-- 
Guodong Xu <guodong@riscstar.com>
Re: [PATCH] riscv: cpufeature: Fix Zk bundled extension missing Zknh
Posted by Paul Walmsley 1 month ago
On Tue, 23 Dec 2025, Guodong Xu wrote:

> 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>

Thanks, queued for v6.19-rc.


- Paul
Re: [PATCH] riscv: cpufeature: Fix Zk bundled extension missing Zknh
Posted by Clément Léger 1 month, 1 week ago
On Tue, Dec 23, 2025 at 3:44 AM Guodong Xu <guodong@riscstar.com> wrote:
>
> 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>
> ---
>  arch/riscv/kernel/cpufeature.c | 23 +++++++++++------------
>  1 file changed, 11 insertions(+), 12 deletions(-)
>
> diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c
> index b057362f8fb5f92d9a608b223666831d769a805c..f5855af0453d5ce206f8c8201ad108dfe4d300fb 100644
> --- a/arch/riscv/kernel/cpufeature.c
> +++ b/arch/riscv/kernel/cpufeature.c
> @@ -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[] = {
>
> ---
> base-commit: 9448598b22c50c8a5bb77a9103e2d49f134c9578
> change-id: 20251223-zk-missing-zknh-262ffed774d2
>
> Best regards,
> --
> Guodong Xu <guodong@riscstar.com>
>

Hi Guodong,

Nice catch, looks good to me:

Reviewed-by: Clément Léger <cleger@rivosinc.com>

Thanks,