Skip to content

Commit

Permalink
x86, kvm: fix compilation for !CONFIG_PARAVIRT_SPINLOCKS or !CONFIG_SMP
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Paolo Bonzini <[email protected]>
  • Loading branch information
bonzini committed Mar 31, 2022
1 parent bcffdaa commit 81d50ef
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions arch/x86/kernel/asm-offsets_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion arch/x86/kernel/kvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 81d50ef

Please sign in to comment.