kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sean Christopherson <sean.j.christopherson@intel.com>
To: Jim Mattson <jmattson@google.com>
Cc: kvm list <kvm@vger.kernel.org>, Oliver Upton <oupton@google.com>,
	Peter Shier <pshier@google.com>
Subject: Re: [PATCH 1/2] kvm: nVMX: Pending debug exceptions trump expired VMX-preemption timer
Date: Wed, 22 Apr 2020 15:06:37 -0700	[thread overview]
Message-ID: <20200422220637.GC5823@linux.intel.com> (raw)
In-Reply-To: <CALMp9eSHyYvRfNe+X+Hd4i2c2phssakxr_5zV9tMQjtk1Usm9A@mail.gmail.com>

On Wed, Apr 22, 2020 at 02:27:33PM -0700, Jim Mattson wrote:
> On Wed, Apr 22, 2020 at 2:06 PM Sean Christopherson
> <sean.j.christopherson@intel.com> wrote:
> The KVM code that deals with all of these events is really hard to
> follow. I wish we could take a step back and just implement Table 6-2
> from the SDM volume 3 (augmented with the scattered information about
> VMX events and their priorities relative to their nearest neighbors.
> Lumping priorities 7 - 10 together (faults that we either intercepted
> or synthesized in emulation), I think these are the various things we
> need to check, in this order...
> 
> 0. Is there a fault to be delivered? (In L2, is it intercepted by L1?)
> 1. Is there a RESET or machine check event?
> 2. Is there a trap on task switch?
> 3. Is there an SMI or an INIT?
> 3.5 In L2, is there an MTF VM-exit?
> 4. Is there a #DB trap on the previous instruction? (In L2, is it
> intercepted by L1?)
> 4.3 In L2, has the VMX-preemption timer expired?
> 4.6 In L2, do we need to synthesize an NMI-window VM-exit?
> 5. Is there an NMI? (In L2, is it intercepted by L1?)
> 5.3 In L2 do we need to synthesize an interrupt-window VM-exit?
> 5.6 In L2, do we need to virtualize virtual-interrupt delivery?
> 6. Is there a maskable interrupt? (In L2, is it intercepted by L1?)
> 7. Now, we can enter VMX non-root mode.

100% agreed.  I even tried to go down that path, multiple times, while
sorting this stuff out.  The big problem that isn't easily resolved is
kvm_vcpu_running(), which currently calls .check_nested_events()
even if KVM_REQ_EVENT isn't set.  Its existence makes it annoyingly
difficult to provide a unified single-pass flow for exiting and
non-exiting events, e.g. we'd either have to duplicate a big pile of
logic (eww) or significantly rework the event handling (scary).

Having the INIT and SIPI handling buried in kvm_apic_accept_events() is
also a pain, but that's less scary to change.

In the long term, I absolutely think it'd be worth revamping the event
handling so that it's not scattered all over tarnation, but that's
something that should probably have a full kernel cycle or two of
testing and performance analysis.

If someone does pick up that torch, I think it'd also be worth experimenting
with removing KVM_REQ_EVENT, i.e. processing events on _every_ run.  IMO
that would simplify the code, or at least how one reasons about the code, a
great deal.

      reply	other threads:[~2020-04-22 22:06 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-14  0:09 [PATCH 1/2] kvm: nVMX: Pending debug exceptions trump expired VMX-preemption timer Jim Mattson
2020-04-14  0:09 ` [PATCH 2/2] kvm: nVMX: Single-step traps " Jim Mattson
2020-04-14  3:17   ` Sean Christopherson
2020-04-14 16:47     ` Jim Mattson
2020-04-15  0:12       ` Sean Christopherson
2020-04-15  0:20         ` Sean Christopherson
2020-04-15  0:22           ` Sean Christopherson
2020-04-15 23:33         ` Jim Mattson
2020-04-18  4:21           ` Sean Christopherson
2020-04-20 17:18             ` Jim Mattson
2020-04-21  4:41               ` Sean Christopherson
2020-04-21 18:28                 ` Jim Mattson
2020-04-22  0:16                   ` Sean Christopherson
2020-04-22  8:30   ` Paolo Bonzini
2020-04-22 15:48     ` Sean Christopherson
2020-04-22 16:28     ` Jim Mattson
2020-04-22 16:42       ` Sean Christopherson
2020-04-22 21:06 ` [PATCH 1/2] kvm: nVMX: Pending debug exceptions " Sean Christopherson
2020-04-22 21:23   ` Sean Christopherson
2020-04-22 21:27   ` Jim Mattson
2020-04-22 22:06     ` Sean Christopherson [this message]

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=20200422220637.GC5823@linux.intel.com \
    --to=sean.j.christopherson@intel.com \
    --cc=jmattson@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=oupton@google.com \
    --cc=pshier@google.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).