RISC-V: KVM: Fix builds without CONFIG_RISCV_ISA_V
Subsystems (4)
PATCH 1/1 RISC-V: KVM: Fix builds without CONFIG_RISCV_ISA_V
From: Xiaochun Yu <[email protected]>
Commit b5060a4aa33d ("RISC-V: KVM: fix vcpu vector context handling for kernel-mode vector") made the KVM vCPU load and put paths call get_cpu_vector_context() and put_cpu_vector_context() unconditionally. It also added an unconditional call to __kvm_riscv_vector_restore() on the guest entry path.
The no-op definitions of the first two helpers live in <asm/vector.h>, but <asm/kvm_vcpu_vector.h> includes that header only when CONFIG_RISCV_ISA_V is enabled. The KVM header also does not provide a no-op __kvm_riscv_vector_restore() in its disabled branch. As a result, a KVM build without CONFIG_RISCV_ISA_V fails with missing helper declarations.
Include <asm/vector.h> unconditionally to reuse its existing no-op helpers, and provide the missing KVM restore stub when Vector support is disabled. This does not change the Vector-enabled path.
---
This single patch fixes a build regression when KVM is enabled without the RISC-V Vector extension.
Tested on base a804c5742bff (Torvalds master):
- CONFIG_RISCV_ISA_V=n, CONFIG_KVM=m: full Image modules build passed.
- CONFIG_RISCV_ISA_V=y, CONFIG_KVM=m: vcpu.o and vcpu_vector.o rebuilt.
--- arch/riscv/include/asm/kvm_vcpu_vector.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
arch/riscv/include/asm/kvm_vcpu_vector.h +5 -1
@@ -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,10 @@ static inline void kvm_riscv_v_exit(void)struct kvm_cpu_context ; +static 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: a804c5742bff224d4cb4d25dd383554d598be32b
change-id: 20261021-ospp-c1-b4-submit-e22dc09faf5a
Best regards,
Signature · 1 line
slack up <[email protected]>
Quoted 22 lines · slack up
From: Xiaochun Yu <[email protected]>
Commit
b5060a4aa33d("RISC-V: KVM: fix vcpu vector context handling for kernel-mode vector") made the KVM vCPU load and put paths callget_cpu_vector_context()andput_cpu_vector_context()unconditionally. It also added an unconditional call to__kvm_riscv_vector_restore()on the guest entry path.The no-op definitions of the first two helpers live in <
asm/vector.h>, but <asm/kvm_vcpu_vector.h> includes that header only whenCONFIG_RISCV_ISA_Vis enabled. The KVM header also does not provide a no-op__kvm_riscv_vector_restore()in its disabled branch. As a result, a KVM build withoutCONFIG_RISCV_ISA_Vfails with missing helper declarations.Include <
asm/vector.h> unconditionally to reuse its existing no-op helpers, and provide the missing KVM restore stub when Vector support is disabled. This does not change the Vector-enabled path.Fixes b5060a4aa33d ("RISC-V: KVM: fix vcpu vector context handling for kernel-mode vector")Signed-off-by Xiaochun Yu <[email protected]>
Quoted 8 lines
---
This single patch fixes a build regression when KVM is enabled without the RISC-V Vector extension.Tested on base
a804c5742bff(Torvalds master):-
CONFIG_RISCV_ISA_V=n,CONFIG_KVM=m: full Image modules build passed.
-CONFIG_RISCV_ISA_V=y,CONFIG_KVM=m: vcpu.o and vcpu_vector.o rebuilt.
Tested on commit a804c5742bff with gcc 16.2.1 and clang 23.1.3:
CONFIG_RISCV_ISA_V=n, CONFIG_KVM=m: full Image + modules build passes (before the patch: 3 implicit-declaration errors with gcc, 5 with clang)
Quoted 36 lines
--- arch/riscv/include/asm/kvm_vcpu_vector.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)arch/riscv/include/asm/kvm_vcpu_vector.h +5
-2@@ -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,10 @@ static inline void kvm_riscv_v_exit(void)struct kvm_cpu_context ; +static 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:
a804c5742bff224d4cb4d25dd383554d598be32b
change-id: 20261021-ospp-c1-b4-submit-e22dc09faf5aBest regards,
Anup Patel
maintainerQuoted 16 lines · slack up
From: Xiaochun Yu <[email protected]>
Commit
b5060a4aa33d("RISC-V: KVM: fix vcpu vector context handling for kernel-mode vector") made the KVM vCPU load and put paths callget_cpu_vector_context()andput_cpu_vector_context()unconditionally. It also added an unconditional call to__kvm_riscv_vector_restore()on the guest entry path.The no-op definitions of the first two helpers live in <
asm/vector.h>, but <asm/kvm_vcpu_vector.h> includes that header only whenCONFIG_RISCV_ISA_Vis enabled. The KVM header also does not provide a no-op__kvm_riscv_vector_restore()in its disabled branch. As a result, a KVM build withoutCONFIG_RISCV_ISA_Vfails with missing helper declarations.
Quoted 7 lines
Include <
asm/vector.h> unconditionally to reuse its existing no-op helpers, and provide the missing KVM restore stub when Vector support is disabled. This does not change the Vector-enabled path.Fixes b5060a4aa33d ("RISC-V: KVM: fix vcpu vector context handling for kernel-mode vector")Signed-off-by Xiaochun Yu <[email protected]>
A similar fix from Zhanpeng Zhang is already merged.
https://lore.kernel.org/r/[email protected]
Regards,
Anup
Quoted 47 lines
---
This single patch fixes a build regression when KVM is enabled without the RISC-V Vector extension.Tested on base
a804c5742bff(Torvalds master):-
CONFIG_RISCV_ISA_V=n,CONFIG_KVM=m: full Image modules build passed.
-CONFIG_RISCV_ISA_V=y,CONFIG_KVM=m: vcpu.o and vcpu_vector.o rebuilt.--- arch/riscv/include/asm/kvm_vcpu_vector.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)arch/riscv/include/asm/kvm_vcpu_vector.h +5
-2@@ -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,10 @@ static inline void kvm_riscv_v_exit(void)struct kvm_cpu_context ; +static 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:
a804c5742bff224d4cb4d25dd383554d598be32b
change-id: 20261021-ospp-c1-b4-submit-e22dc09faf5aBest regards,
--
slack up <[email protected]>