Guest vCPUs never enable Vector state (sstatus.VS), so any vector instruction traps as illegal. If the toolchain's default -march includes the V extension, the compiler may auto-vectorize routines like memset() into vector instructions, crashing guests.
Build with -march=rv64gc, probed the same way as x86's -march=x86-64-v2, to ensure vector instructions are never emitted. Signed-off-by: Yong-Xuan Wang <[email protected]> --- tools/testing/selftests/kvm/Makefile.kvm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/testing/selftests/kvm/Makefile.kvm b/tools/testing/selftests/kvm/Makefile.kvm index 6fc34e9bf8e1..46c54948f4b1 100644 --- a/tools/testing/selftests/kvm/Makefile.kvm +++ b/tools/testing/selftests/kvm/Makefile.kvm @@ -297,6 +297,11 @@ CFLAGS += -I$(GEN_HDRS) $(GEN_HDRS): $(wildcard $(arm64_tools_dir)/*) $(MAKE) -C $(arm64_tools_dir) OUTPUT=$(arm64_hdr_outdir) endif +ifeq ($(ARCH),riscv) +ifeq ($(shell echo "void foo(void) { }" | $(CC) -march=rv64gc -x c - -c -o /dev/null 2>/dev/null; echo "$$?"),0) + CFLAGS += -march=rv64gc +endif +endif no-pie-option := $(call try-run, echo 'int main(void) { return 0; }' | \ $(CC) -Werror $(CFLAGS) -no-pie -x c - -o "$$TMP", -no-pie) --- base-commit: b5060a4aa33d7d78a8c1837ab08ef0c81ea96650 change-id: 20260831-kvm_kselftest_disable_v-23bbfab68098

