All of lore.kernel.org
 help / color / mirror / Atom feed
* KVM: x86: better fix for race between nmi injection and enabling nmi window
@ 2011-03-30 16:30 Marcelo Tosatti
  2011-03-30 16:33 ` Gleb Natapov
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Marcelo Tosatti @ 2011-03-30 16:30 UTC (permalink / raw)
  To: kvm; +Cc: Avi Kivity, Gleb Natapov


Based on Gleb's idea, fix race between nmi injection and enabling 
nmi window in a simpler way.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index a6a129f..9a7cc1be 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -5152,6 +5152,7 @@ static void kvm_put_guest_xcr0(struct kvm_vcpu *vcpu)
 static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
 {
 	int r;
+	int nmi_pending;
 	bool req_int_win = !irqchip_in_kernel(vcpu->kvm) &&
 		vcpu->run->request_interrupt_window;
 
@@ -5195,11 +5196,13 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
 	if (unlikely(r))
 		goto out;
 
+	nmi_pending = ACCESS_ONCE(vcpu->arch.nmi_pending);
+
 	if (kvm_check_request(KVM_REQ_EVENT, vcpu) || req_int_win) {
 		inject_pending_event(vcpu);
 
 		/* enable NMI/IRQ window open exits if needed */
-		if (vcpu->arch.nmi_pending)
+		if (nmi_pending)
 			kvm_x86_ops->enable_nmi_window(vcpu);
 		else if (kvm_cpu_has_interrupt(vcpu) || req_int_win)
 			kvm_x86_ops->enable_irq_window(vcpu);


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2011-04-01 14:27 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-30 16:30 KVM: x86: better fix for race between nmi injection and enabling nmi window Marcelo Tosatti
2011-03-30 16:33 ` Gleb Natapov
2011-03-30 16:43   ` Marcelo Tosatti
2011-03-30 17:16 ` Avi Kivity
2011-03-30 18:47   ` Gleb Natapov
2011-03-31  9:23     ` Avi Kivity
2011-03-31  9:24       ` Gleb Natapov
2011-03-31  9:25         ` Avi Kivity
2011-03-31  9:40           ` Marcelo Tosatti
2011-03-31  9:47           ` Gleb Natapov
2011-03-31  9:30     ` Marcelo Tosatti
2011-04-01 14:26 ` KVM: x86: better fix for race between nmi injection and enabling nmi window (v2) Marcelo Tosatti

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.