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: vcpu state writeback should be aware of REQ_NMI
Date: Thu, 24 Mar 2011 15:38:12 +0200 [thread overview]
Message-ID: <20110324133812.GB13195@redhat.com> (raw)
In-Reply-To: <4D8B482F.9070408@redhat.com>
On Thu, Mar 24, 2011 at 03:33:35PM +0200, Avi Kivity wrote:
> On 03/24/2011 03:27 PM, Gleb Natapov wrote:
> >On Thu, Mar 24, 2011 at 09:47:00AM -0300, Marcelo Tosatti wrote:
> >>
> >> 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
> >>
> >Looks like we need to clear request bit on cpu reset too. KVM_REQ_NMI
> >start to become more complicated that it was initially. May be replaced
> >it with something like this:
> >
> >
> >diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> >index 1b8b16a..6a66d19 100644
> >--- a/arch/x86/kvm/x86.c
> >+++ b/arch/x86/kvm/x86.c
> >@@ -5151,6 +5151,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;
> >
> >@@ -5188,19 +5189,19 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
> > r = 1;
> > goto out;
> > }
> >- if (kvm_check_request(KVM_REQ_NMI, vcpu))
> >- vcpu->arch.nmi_pending = true;
> > }
> >
> > r = kvm_mmu_reload(vcpu);
> > if (unlikely(r))
> > goto out;
> >
> >+ nmi_pending = vcpu->arch.nmi_pending;
> >+
>
> ACCESS_ONCE() to prevent compiler cleverness
>
> > if (kvm_check_request(KVM_REQ_EVENT, vcpu) || req_int_win) {
> > inject_pending_event(vcpu);
>
> This can use a newer vcpu->arch.nmi_pending.
>
We can do inject_pending_event(vcpu, nmi_pending); but is this a problem
that newer version of vcpu->arch.nmi_pending will be used? If NMI can be
injected it will - no problem. It it can't it will be delayed till the
next guest entry - no problem NMI is async anyway.
> >
> > /* 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);
>
> --
> error compiling committee.c: too many arguments to function
--
Gleb.
next prev parent reply other threads:[~2011-03-24 13:38 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
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=20110324133812.GB13195@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 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.