kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Maxim Levitsky <mlevitsk@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Lai Jiangshan <jiangshanlai+lkml@gmail.com>,
	Sean Christopherson <sean.j.christopherson@intel.com>,
	Vitaly Kuznetsov <vkuznets@redhat.com>,
	Wanpeng Li <wanpengli@tencent.com>,
	Jim Mattson <jmattson@google.com>, Joerg Roedel <joro@8bytes.org>,
	kvm@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>,
	Josh Poimboeuf <jpoimboe@redhat.com>,
	Uros Bizjak <ubizjak@gmail.com>, Andi Kleen <ak@linux.intel.com>,
	Andy Lutomirski <luto@kernel.org>
Subject: Re: [PATCH v2 2/2] KVM: VMX: Invoke NMI handler via indirect call instead of INTn
Date: Mon, 26 Apr 2021 09:59:07 -0400	[thread overview]
Message-ID: <20210426095907.698ec524@gandalf.local.home> (raw)
In-Reply-To: <ace4c4d81ef0ee461ead6d046c3b3d7308dd32ae.camel@redhat.com>

On Mon, 26 Apr 2021 14:44:49 +0300
Maxim Levitsky <mlevitsk@redhat.com> wrote:

> On Mon, 2021-04-26 at 12:40 +0200, Paolo Bonzini wrote:
> > On 26/04/21 11:33, Lai Jiangshan wrote:  
> > > When handle_interrupt_nmi_irqoff() is called, we may lose the
> > > CPU-hidden-NMI-masked state due to IRET of #DB, #BP or other traps
> > > between VMEXIT and handle_interrupt_nmi_irqoff().
> > > 
> > > But the NMI handler in the Linux kernel*expects*  the CPU-hidden-NMI-masked
> > > state is still set in the CPU for no nested NMI intruding into the beginning
> > > of the handler.

This is incorrect. The Linux kernel has for some time handled the case of
nested NMIs. It had to, to implement the ftrace break point updates, as it
would trigger an int3 in an NMI which would "unmask" the NMIs. It has also
been a long time bug where a page fault could do the same (the reason you
could never do a dump all tasks from NMI without triple faulting!).

But that's been fixed a long time ago, and I even wrote an LWN article
about it ;-)

 https://lwn.net/Articles/484932/

The NMI handler can handle the case of nested NMIs, and implements a
software "latch" to remember that another NMI is to be executed, if there
is a nested one. And it does so after the first one has finished.

-- Steve

  reply	other threads:[~2021-04-26 13:59 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-15 19:15 [PATCH v2 0/2] KVM: VMX: Clean up IRQ/NMI handling Sean Christopherson
2020-09-15 19:15 ` [PATCH v2 1/2] KVM: VMX: Move IRQ invocation to assembly subroutine Sean Christopherson
2020-09-15 19:27   ` Josh Poimboeuf
2020-09-15 19:38   ` Uros Bizjak
2020-09-15 19:15 ` [PATCH v2 2/2] KVM: VMX: Invoke NMI handler via indirect call instead of INTn Sean Christopherson
2021-04-26  9:33   ` Lai Jiangshan
2021-04-26 10:40     ` Paolo Bonzini
2021-04-26 11:44       ` Maxim Levitsky
2021-04-26 13:59         ` Steven Rostedt [this message]
2021-04-26 14:51       ` Andi Kleen
2021-04-26 15:09         ` Andy Lutomirski
2021-04-27  0:54       ` Lai Jiangshan
2021-04-27  1:00         ` Steven Rostedt
2021-04-27  7:05         ` Paolo Bonzini
2021-04-30  2:56           ` Lai Jiangshan
2020-09-22 13:38 ` [PATCH v2 0/2] KVM: VMX: Clean up IRQ/NMI handling Paolo Bonzini

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=20210426095907.698ec524@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=ak@linux.intel.com \
    --cc=jiangshanlai+lkml@gmail.com \
    --cc=jmattson@google.com \
    --cc=joro@8bytes.org \
    --cc=jpoimboe@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mlevitsk@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=sean.j.christopherson@intel.com \
    --cc=ubizjak@gmail.com \
    --cc=vkuznets@redhat.com \
    --cc=wanpengli@tencent.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;
as well as URLs for NNTP newsgroup(s).