[PATCH 5/6] riscv: hwprobe: Report XTheadVector only when available

Radim Krčmář radim.krcmar at oss.qualcomm.com
Tue Oct 6 00:53:02 PDT 2026


User-mode use of XTheadVector requires non-Off sstatus.VS, which we set
only when has_xtheadvector() (CONFIG_RISCV_ISA_XTHEADVECTOR and
XTheadVector on all harts).  XTheadVector also bundles operations with
floating state, which additionally requires non-Off sstatus.FS and hence
has_fpu().  hwprobe reports XTheadVector from the per-hart vendor ISA
bitmaps alone, so it can advertise an extension that is always disabled
in user-mode.

Report correct environment to user-mode.

Fixes: a5ea53da65c5 ("riscv: hwprobe: Add thead vendor extension probing")
Signed-off-by: Radim Krčmář <radim.krcmar at oss.qualcomm.com>
---
 The check could be done before the loop if we care about optimizing the
 code.
 XTheadVector can also be per-process disabled by prctl, which belongs
 to Andy's series.

 arch/riscv/kernel/vendor_extensions/thead_hwprobe.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/riscv/kernel/vendor_extensions/thead_hwprobe.c b/arch/riscv/kernel/vendor_extensions/thead_hwprobe.c
index 2eba34011786..f07aa1c8acac 100644
--- a/arch/riscv/kernel/vendor_extensions/thead_hwprobe.c
+++ b/arch/riscv/kernel/vendor_extensions/thead_hwprobe.c
@@ -1,5 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 
+#include <asm/switch_to.h>
+#include <asm/vector.h>
 #include <asm/vendor_extensions/thead.h>
 #include <asm/vendor_extensions/thead_hwprobe.h>
 #include <asm/vendor_extensions/vendor_hwprobe.h>
@@ -14,6 +16,7 @@ void hwprobe_isa_vendor_ext_thead_0(struct riscv_hwprobe *pair, const struct cpu
 {
 	VENDOR_EXTENSION_SUPPORTED(pair, cpus,
 				   riscv_isa_vendor_ext_list_thead.per_hart_isa_bitmap, {
-		VENDOR_EXT_KEY(XTHEADVECTOR);
+		if (has_xtheadvector() && has_fpu())
+			VENDOR_EXT_KEY(XTHEADVECTOR);
 	});
 }
-- 
2.55.0




More information about the linux-riscv mailing list