From 0ba1dc1961628454675352f561e2b46506a7aad6 Mon Sep 17 00:00:00 2001 From: Han Gao Date: Mon, 10 Jun 2024 18:55:40 +0800 Subject: [PATCH] xtheadvector: fix it used as v-ext when hwprobe is used Signed-off-by: Han Gao --- arch/riscv/include/asm/vector.h | 6 ++++++ arch/riscv/kernel/sys_riscv.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/riscv/include/asm/vector.h b/arch/riscv/include/asm/vector.h index e8bafcf80a2d1..4cb38556236d5 100644 --- a/arch/riscv/include/asm/vector.h +++ b/arch/riscv/include/asm/vector.h @@ -115,6 +115,11 @@ static __always_inline bool has_vector(void) riscv_has_extension_unlikely(RISCV_ISA_EXT_XTHEADVECTOR); } +static __always_inline bool has_xtheadvector(void) +{ + return riscv_has_extension_unlikely(RISCV_ISA_EXT_XTHEADVECTOR); +} + static inline void __riscv_v_vstate_clean(struct pt_regs *regs) { xlen_t sr_vs, sr_vs_clean; @@ -416,6 +421,7 @@ struct pt_regs; static inline int riscv_v_setup_vsize(void) { return -EOPNOTSUPP; } static __always_inline bool has_vector(void) { return false; } static __always_inline bool has_matrix(void) { return false; } +static __always_inline bool has_xtheadvector(void) { return false; } static inline bool riscv_v_first_use_handler(struct pt_regs *regs) { return false; } static inline bool riscv_v_vstate_query(struct pt_regs *regs) { return false; } static inline bool riscv_v_vstate_ctrl_user_allowed(void) { return false; } diff --git a/arch/riscv/kernel/sys_riscv.c b/arch/riscv/kernel/sys_riscv.c index 473159b5f303a..aa8526ece6032 100644 --- a/arch/riscv/kernel/sys_riscv.c +++ b/arch/riscv/kernel/sys_riscv.c @@ -135,7 +135,7 @@ static void hwprobe_isa_ext0(struct riscv_hwprobe *pair, if (riscv_isa_extension_available(NULL, c)) pair->value |= RISCV_HWPROBE_IMA_C; - if (has_vector()) + if (has_vector() && !has_xtheadvector()) pair->value |= RISCV_HWPROBE_IMA_V; /*