From: "Christopherson, Sean J" <sean.j.christopherson@intel.com>
To: Paolo Bonzini <pbonzini@redhat.com>, Nadav Amit <nadav.amit@gmail.com>
Cc: Vitaly Kuznetsov <vkuznets@redhat.com>,
Po-Hsu Lin <po-hsu.lin@canonical.com>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>
Subject: RE: [kvm-unit-tests PATCHv2] unittests.cfg: Increase timeout for apic test
Date: Tue, 20 Oct 2020 15:05:51 +0000 [thread overview]
Message-ID: <686175c1a45d4b438c9585d835bdd0dc@intel.com> (raw)
In-Reply-To: <d1277875-6b7a-f7fe-8a58-78ba5ae0ba1d@redhat.com>
On Tue, Oct 20, 2020 at 10:48:24AM +0200, Paolo Bonzini wrote:
> On 19/10/20 18:52, Nadav Amit wrote:
> > IIRC, this test failed on VMware, and according to our previous discussions,
> > does not follow the SDM as NMIs might be collapsed [1].
> >
> > [1] https://marc.info/?l=kvm&m=145876994031502&w=2
>
> So should KVM be changed to always collapse NMIs, like this?
No, Nadav's failure is not on bare metal. The test passes on bare metal.
Quoting myself:
Architecturally I don't think there are any guarantees regarding
simultaneous NMIs, but practically speaking the probability of NMIs
being collapsed (on hardware) when NMIs aren't blocked is nil. So while
it may be architecturally legal for a VMM to drop an NMI in this case,
it's reasonable for software to expect two NMIs to be received.
[*] https://lkml.kernel.org/r/A7453828-BD8E-43F8-B140-6D660535B7F2@gmail.com
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 105261402921..4032336ecba3 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -668,7 +668,7 @@ EXPORT_SYMBOL_GPL(kvm_inject_emulated_page_fault);
>
> void kvm_inject_nmi(struct kvm_vcpu *vcpu)
> {
> - atomic_inc(&vcpu->arch.nmi_queued);
> + atomic_set(&vcpu->arch.nmi_queued, 1);
> kvm_make_request(KVM_REQ_NMI, vcpu);
> }
> EXPORT_SYMBOL_GPL(kvm_inject_nmi);
> @@ -8304,18 +8304,7 @@ static void inject_pending_event(struct kvm_vcpu
> *vcpu, bool *req_immediate_exit
>
> static void process_nmi(struct kvm_vcpu *vcpu)
> {
> - unsigned limit = 2;
> -
> - /*
> - * x86 is limited to one NMI running, and one NMI pending after it.
> - * If an NMI is already in progress, limit further NMIs to just one.
> - * Otherwise, allow two (and we'll inject the first one immediately).
> - */
> - if (kvm_x86_ops.get_nmi_mask(vcpu) || vcpu->arch.nmi_injected)
> - limit = 1;
> -
> - vcpu->arch.nmi_pending += atomic_xchg(&vcpu->arch.nmi_queued, 0);
> - vcpu->arch.nmi_pending = min(vcpu->arch.nmi_pending, limit);
> + vcpu->arch.nmi_pending |= atomic_xchg(&vcpu->arch.nmi_queued, 0);
> kvm_make_request(KVM_REQ_EVENT, vcpu);
> }
next prev parent reply other threads:[~2020-10-20 15:09 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-13 9:12 [kvm-unit-tests PATCHv2] unittests.cfg: Increase timeout for apic test Po-Hsu Lin
2020-10-15 15:59 ` Vitaly Kuznetsov
2020-10-15 16:35 ` Sean Christopherson
2020-10-16 17:02 ` Paolo Bonzini
2020-10-16 17:40 ` Andrew Jones
2020-10-20 5:53 ` Thomas Huth
2020-10-20 8:49 ` Andrew Jones
2020-10-19 11:32 ` Vitaly Kuznetsov
2020-10-19 16:37 ` Christopherson, Sean J
2020-10-19 16:52 ` Nadav Amit
2020-10-20 8:48 ` Paolo Bonzini
2020-10-20 15:05 ` Christopherson, Sean J [this message]
2020-10-30 8:15 ` Po-Hsu Lin
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=686175c1a45d4b438c9585d835bdd0dc@intel.com \
--to=sean.j.christopherson@intel.com \
--cc=kvm@vger.kernel.org \
--cc=nadav.amit@gmail.com \
--cc=pbonzini@redhat.com \
--cc=po-hsu.lin@canonical.com \
--cc=vkuznets@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