public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Gleb Natapov <gleb@redhat.com>
To: Avi Kivity <avi@redhat.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>, kvm <kvm@vger.kernel.org>
Subject: Re: KVM: x86: better fix for race between nmi injection and enabling nmi window
Date: Thu, 31 Mar 2011 11:47:57 +0200	[thread overview]
Message-ID: <20110331094757.GK7766@redhat.com> (raw)
In-Reply-To: <4D94489A.9060705@redhat.com>

On Thu, Mar 31, 2011 at 11:25:46AM +0200, Avi Kivity wrote:
> On 03/31/2011 11:24 AM, Gleb Natapov wrote:
> >On Thu, Mar 31, 2011 at 11:23:28AM +0200, Avi Kivity wrote:
> >>  On 03/30/2011 08:47 PM, Gleb Natapov wrote:
> >>  >On Wed, Mar 30, 2011 at 07:16:34PM +0200, Avi Kivity wrote:
> >>  >>   On 03/30/2011 06:30 PM, Marcelo Tosatti wrote:
> >>  >>   >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);
> >>  >>   >
> >>  >>
> >>  >>   What about the check in inject_pending_events()?
> >>  >>
> >>  >Didn't we decide that this check is not a problem? Worst that can happen
> >>  >is NMI injection will be delayed till next exit.
> >>
> >>  Could be very far in the future.
> >>
> >Next host interrupt. But with tickles host and guest yeah.
> >
> 
> esp. important with NMI, which may be used in a situation where your
> tick (and everything else) are dead.
> 
If host is alive eventually cpu should receive reschedule IPI.

--
			Gleb.

  parent reply	other threads:[~2011-03-31  9:47 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110331094757.GK7766@redhat.com \
    --to=gleb@redhat.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox