public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* KVM: x86: vcpu state writeback should be aware of REQ_NMI
@ 2011-03-24 12:47 Marcelo Tosatti
  2011-03-24 13:26 ` Avi Kivity
  2011-03-24 13:27 ` Gleb Natapov
  0 siblings, 2 replies; 10+ messages in thread
From: Marcelo Tosatti @ 2011-03-24 12:47 UTC (permalink / raw)
  To: kvm; +Cc: Avi Kivity, Gleb Natapov


Since "Fix race between nmi injection and enabling nmi window", pending NMI 
can be represented in KVM_REQ_NMI vcpu->requests bit. 

When setting vcpu state via SET_VCPU_EVENTS, for example during reset,
the REQ_NMI bit should be cleared otherwise pending NMI is transferred 
to nmi_pending upon vcpu entry.

Also should consider requests bit on runnable conditional.

BZ: http://bugzilla.redhat.com/show_bug.cgi?id=684719

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

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index f1e4025..d7f4c4f 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -2677,8 +2677,11 @@ static int kvm_vcpu_ioctl_x86_set_vcpu_events(struct kvm_vcpu *vcpu,
 						  events->interrupt.shadow);
 
 	vcpu->arch.nmi_injected = events->nmi.injected;
-	if (events->flags & KVM_VCPUEVENT_VALID_NMI_PENDING)
+	if (events->flags & KVM_VCPUEVENT_VALID_NMI_PENDING) {
 		vcpu->arch.nmi_pending = events->nmi.pending;
+		if (!vcpu->arch.nmi_pending)
+			clear_bit(KVM_REQ_NMI, &vcpu->requests);
+	}
 	kvm_x86_ops->set_nmi_mask(vcpu, events->nmi.masked);
 
 	if (events->flags & KVM_VCPUEVENT_VALID_SIPI_VECTOR)
@@ -6149,7 +6152,8 @@ int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu)
 		!vcpu->arch.apf.halted)
 		|| !list_empty_careful(&vcpu->async_pf.done)
 		|| vcpu->arch.mp_state == KVM_MP_STATE_SIPI_RECEIVED
-		|| vcpu->arch.nmi_pending ||
+		|| vcpu->arch.nmi_pending
+		|| test_bit(KVM_REQ_NMI, &vcpu->requests) ||
 		(kvm_arch_interrupt_allowed(vcpu) &&
 		 kvm_cpu_has_interrupt(vcpu));
 }



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

end of thread, other threads:[~2011-03-29 13:36 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-24 12:47 KVM: x86: vcpu state writeback should be aware of REQ_NMI Marcelo Tosatti
2011-03-24 13:26 ` Avi Kivity
2011-03-24 13:27 ` Gleb Natapov
2011-03-24 13:33   ` Avi Kivity
2011-03-24 13:38     ` Gleb Natapov
2011-03-24 14:59   ` Marcelo Tosatti
2011-03-24 15:19     ` Gleb Natapov
2011-03-24 15:35       ` Avi Kivity
2011-03-29 13:12         ` Marcelo Tosatti
2011-03-29 13:36           ` Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox