Skip to contentSkip to conversation

riscv: KVM: Fix compilation when CONFIG_RISCV_ISA_V=n

PATCH In review Charlie Jenkins 1 participant 2 messages Oct 6

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 riscv: KVM: Fix compilation when CONFIG_RISCV_ISA_V=n

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

---
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/[email protected]/

---
 arch/riscv/include/asm/kvm_vcpu_vector.h | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
arch/riscv/include/asm/kvm_vcpu_vector.h +9 -1
index 6371d5ea5392..1c9efc6048bb 100644
@@ -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,

Signature · 1 line
- Charlie
#1 lore raw
Quoted 8 lines · Charlie Jenkins

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

Should have looked at the lists first, this wa already sent
https://lore.kernel.org/all/[email protected]/.

Quoted 48 lines

---
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/[email protected]/

---
 arch/riscv/include/asm/kvm_vcpu_vector.h | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
arch/riscv/include/asm/kvm_vcpu_vector.h +9 -2
index 6371d5ea5392..1c9efc6048bb 100644
@@ -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,

Signature · 1 line
- Charlie