Skip to contentSkip to conversation

x86, kvm: fix compilation for !CONFIG_PARAVIRT_SPINLOCKS or !CONFIG_SMP

PATCH New Paolo Bonzini 1 participant 1 message Mar 31, 2022

Subsystems (3)
lore
Share & tools
lore

Paolo Bonzini

author maintainer
#0 lore raw

PATCH 1/1 x86, kvm: fix compilation for !CONFIG_PARAVIRT_SPINLOCKS or !CONFIG_SMP

The assembly version of __kvm_vcpu_is_preempted only works if CONFIG_SMP is defined, due to the use of __per_cpu_offset. It also uses the KVM_STEAL_TIME_preempted offset constant which is currently not defined if !CONFIG_PARAVIRT_SPINLOCKS. Fix both issues.

This is the delta between Li RongQing's v3 and v4
submissions.

---
 arch/x86/kernel/asm-offsets_64.c | 4 ++--
 arch/x86/kernel/kvm.c            | 4 +++-
 2 files changed, 5 insertions(+), 3 deletions(-)
arch/x86/kernel/asm-offsets_64.c +2 -2
index b14533af7676..9b698215d261 100644
@@ -5,7 +5,7 @@
 
 #include <asm/ia32.h>
 
-#if defined(CONFIG_KVM_GUEST) && defined(CONFIG_PARAVIRT_SPINLOCKS)
+#if defined(CONFIG_KVM_GUEST)
 #include <asm/kvm_para.h>
 #endif
 
@@ -20,7 +20,7 @@ int main(void)
 	BLANK();
 #endif
 
-#if defined(CONFIG_KVM_GUEST) && defined(CONFIG_PARAVIRT_SPINLOCKS)
+#if defined(CONFIG_KVM_GUEST)
 	OFFSET(KVM_STEAL_TIME_preempted, kvm_steal_time, preempted);
 	BLANK();
 #endif
arch/x86/kernel/kvm.c +3 -1
index 21933095a10e..e12beeed9d13 100644
@@ -752,7 +752,9 @@ static void kvm_crash_shutdown(struct pt_regs *regs)
 }
 #endif
 
-#ifdef CONFIG_X86_32
+#if defined(CONFIG_X86_32) || !defined(CONFIG_SMP)
+bool __kvm_vcpu_is_preempted(long cpu);
+
 __visible bool __kvm_vcpu_is_preempted(long cpu)
 {
 	struct kvm_steal_time *src = &per_cpu(steal_time, cpu);
Signature · 1 line
2.31.1