[PATCH] riscv: KVM: Fix compilation when CONFIG_RISCV_ISA_V=n
Charlie Jenkins
thecharlesjenkins at gmail.com
Tue Oct 6 16:39:03 PDT 2026
Fix the KVM code to use stubbed out versions of vector functions when
vector is not enabled instead of failing to compile. An alternative
approach would be to ifdef out the vector code but since a handful of
the vector code already just uses stubbed functions to tell the compiler
to drop the implementation, follow the same pattern.
Fixes: b5060a4aa33d ("RISC-V: KVM: fix vcpu vector context handling for kernel-mode vector")
Signed-off-by: Charlie Jenkins <thecharlesjenkins at gmail.com>
---
I was reviewing [1] and noticed that when I disabled FPU and tried to
compile that vector got disabled and the kernel failed to compile.
[1] https://lore.kernel.org/all/20261006075303.205216-1-radim.krcmar@oss.qualcomm.com/
---
arch/riscv/include/asm/kvm_vcpu_vector.h | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/arch/riscv/include/asm/kvm_vcpu_vector.h b/arch/riscv/include/asm/kvm_vcpu_vector.h
index 6371d5ea5392..1c9efc6048bb 100644
--- a/arch/riscv/include/asm/kvm_vcpu_vector.h
+++ b/arch/riscv/include/asm/kvm_vcpu_vector.h
@@ -11,9 +11,9 @@
#define __KVM_VCPU_RISCV_VECTOR_H
#include <linux/types.h>
+#include <asm/vector.h>
#ifdef CONFIG_RISCV_ISA_V
-#include <asm/vector.h>
#include <asm/kvm_host.h>
static __always_inline void __kvm_riscv_vector_save(struct kvm_cpu_context *context)
@@ -55,6 +55,14 @@ static inline void kvm_riscv_v_exit(void)
struct kvm_cpu_context;
+static __always_inline void __kvm_riscv_vector_save(struct kvm_cpu_context *context)
+{
+}
+
+static __always_inline void __kvm_riscv_vector_restore(struct kvm_cpu_context *context)
+{
+}
+
static inline void kvm_riscv_vcpu_vector_reset(struct kvm_vcpu *vcpu)
{
}
---
base-commit: a90ee4305c4a5df72c11b31dacfdc76e00fcf78a
change-id: 20261006-vector_off_fix-938d61b1f906
Best regards,
--
- Charlie
More information about the linux-riscv
mailing list