summaryrefslogtreecommitdiff
path: root/arch/x86/kvm/xen.h
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2022-06-07 17:07:11 +0300
committerPaolo Bonzini <pbonzini@redhat.com>2022-06-08 11:21:06 +0300
commit54aa83c90198e68eee8b0850c749bc70efb548da (patch)
treed7d4efd13d42a72a0e05252689037bc08e126037 /arch/x86/kvm/xen.h
parent11d39e8cc43e1c6737af19ca9372e590061b5ad2 (diff)
downloadlinux-54aa83c90198e68eee8b0850c749bc70efb548da.tar.xz
KVM: x86: do not set st->preempted when going back to user space
Similar to the Xen path, only change the vCPU's reported state if the vCPU was actually preempted. The reason for KVM's behavior is that for example optimistic spinning might not be a good idea if the guest is doing repeated exits to userspace; however, it is confusing and unlikely to make a difference, because well-tuned guests will hardly ever exit KVM_RUN in the first place. Suggested-by: Sean Christopherson <seanjc@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/x86/kvm/xen.h')
-rw-r--r--arch/x86/kvm/xen.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/arch/x86/kvm/xen.h b/arch/x86/kvm/xen.h
index ee5c4ae0755c..532a535a9e99 100644
--- a/arch/x86/kvm/xen.h
+++ b/arch/x86/kvm/xen.h
@@ -159,8 +159,10 @@ static inline void kvm_xen_runstate_set_preempted(struct kvm_vcpu *vcpu)
* behalf of the vCPU. Only if the VMM does actually block
* does it need to enter RUNSTATE_blocked.
*/
- if (vcpu->preempted)
- kvm_xen_update_runstate_guest(vcpu, RUNSTATE_runnable);
+ if (WARN_ON_ONCE(!vcpu->preempted))
+ return;
+
+ kvm_xen_update_runstate_guest(vcpu, RUNSTATE_runnable);
}
/* 32-bit compatibility definitions, also used natively in 32-bit build */