From: Sean Christopherson <seanjc@google.com>
To: Jim Mattson <jmattson@google.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
stable@vger.kernel.org, David Woodhouse <dwmw2@infradead.org>,
Stefan Teodorescu <fane@google.com>
Subject: Re: [PATCH 4/7] KVM: nVMX: Process each host MSR entry at most once when unwinding failed VM-Entry
Date: Tue, 3 Nov 2026 16:12:01 -0800 [thread overview]
Message-ID: <aup4UcK__je0wtp6@google.com> (raw)
In-Reply-To: <CALMp9eR9=JTv80HuG5zAcSj91tJos2ecFA_Sc5Qbs4s5XetKHQ@mail.gmail.com>
On Tue, Nov 03, 2026, Jim Mattson wrote:
> On Tue, Nov 3, 2026 at 12:59 PM Sean Christopherson <seanjc@google.com> wrote:
> > > Something like returning to userspace with
> > > KVM_INTERNAL_ERROR_EMULATION following a prohibited write to an active
> > > VTPR seems far easier--and cleaner. What am I missing?
> >
> > My biggest concern is that KVM could kill L1 if an L2 coerces L1 into trying
> > VMLAUNCH/VMRESUME with invalid state. KVM simply can't *know* that an unexpected
> > VM-Fail was due to the vTPR wrinkle. Even if KVM re-checked state, it's possible
> > for the vTPR to be "restored" to a good value.
>
> The only way that I can see for L2 to coerce L1 into trying VM-entry
> with invalid control fields or invalid host-state fields is by
> exploiting an L1 nested virtualization bug (i.e. L2 is running an L3).
Hmm, I agree L2 would be a tall order, but L1 userspace running against KVM can
definitely get bad state into the vCPU by abusing KVM ioctls. So not a VM-to-host
DoS, but still an unprivileged DoS (given that /dev/kvm isn't usually locked down
by default). Of course that would still require L0 KVM to have a missing check,
or require L1 KVM to be buggy and let userspace modify vTPR.
> In any case, if L0 has already performed the checks in software, then
> failure of the checks in hardware implies either (a) misbehavior on
> the part of L1 or (b) an emulation error in L0.
>
> > I.e. if KVM exits to userspace with KVM_INTERNAL_ERROR_EMULATION, then there's a
> > non-zero chance of a false positive. KVM could exit to userspace if and only if
> > it caught the guest red-handed, but then we'd still need this horrific code for
> > the other cases, so that seems rather pointless.
>
> Let's go back to the Xen example, since by your argument any L1 can be
> victimized. If an L2 VM somehow coerced L1 Xen into trying VM-entry
> with invalid control fields or invalid host-state fields, and somehow
> L0's software checks passed, but the hardware checks on VMCS02 failed,
> you would continue to run the L1 VCPU with L2's SPEC_CTRL MSR. Surely,
> the possibility of a malicious L2 exfiltrating data from L1 with the
> assistance of L0 has to be worse than the abnormal termination of L1?
Probably.
> (Note that I'm just playing devil's advocate here. I don't actually
> buy your argument.)
>
> > warn_on_missed_cc helps, but in practice it can't detect cases for which we don't
> > have test coverage. So *if* there was a bug that could be exploited by L2 to DoS
> > L1, odds are good warn_on_missed_cc didn't catch that hypothetical bug either.
> >
> > Maybe with AI we can be 100% confident that KVM performs all of the VM-Fail
> > consistency checks? Again, I'm not opposed to alternative approaches, but at the
> > same time I don't feel a sense of urgency.
>
> KVM *must* perform all of the control field and host-state field consistency
> checks. Otherwise, we risk priority inversion with "illegal guest state."
Eh, not sure if that matters in practice though.
> If KVM is missing any of these checks, then it has an "internal error."
I agree, but KVM has historically had a *lot* of those types of internal errors.
Even now I genuinely don't know if we have 100% coverage and accuracy. I suppose
we could add a cap or quirk the existing behavior, but I'd prefer not to do that,
because odds are good the restore code would eventually bitrot.
I guess I'd be up for having AI audit the checks, and then ripping out
nested_vmx_restore_host_state() in 7.5 in favor of kvm_prepare_emulation_failure_exit().
That change is pretty darn easy, and would likely revert cleanly too if it came
to that. Sashiko would probably even understand the implications without extra
guidance, i.e. would hopefully flag missed checks as new features are added, so
maybe my maintenance concerns are unfounded.
next prev parent reply other threads:[~2026-11-04 0:12 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-02 23:14 [PATCH 0/7] KVM: a bunch of fixes Paolo Bonzini
2026-11-02 23:14 ` [PATCH 1/7] KVM: nSVM: Check validity of vmcs01 save area copied from SMRAM on RSM Paolo Bonzini
2026-11-02 23:14 ` [PATCH 2/7] KVM: x86/mmu: Conditionally resched when retrying gPTE walk on A/D update failure Paolo Bonzini
2026-11-02 23:14 ` [PATCH 3/7] KVM: x86: Conditionally resched when restarting REP string emulation Paolo Bonzini
2026-11-02 23:14 ` [PATCH 4/7] KVM: nVMX: Process each host MSR entry at most once when unwinding failed VM-Entry Paolo Bonzini
2026-11-02 23:39 ` Jim Mattson
2026-11-03 0:10 ` Sean Christopherson
2026-11-03 0:34 ` Jim Mattson
2026-11-03 19:40 ` Jim Mattson
2026-11-03 20:59 ` Sean Christopherson
2026-11-03 22:52 ` Jim Mattson
2026-11-04 0:12 ` Sean Christopherson [this message]
2026-11-02 23:14 ` [PATCH 5/7] KVM: x86/mmu: Cap number of parent PTEs per SP at 1000 (the arbitrary rmap limit) Paolo Bonzini
2026-11-02 23:14 ` [PATCH 6/7] KVM: x86: Unconditionally reset MMU context when emulating INIT Paolo Bonzini
2026-11-02 23:14 ` [PATCH 7/7] KVM: x86: Flush guest TLB when emulating a RESET to strictly honor the spec 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=aup4UcK__je0wtp6@google.com \
--to=seanjc@google.com \
--cc=dwmw2@infradead.org \
--cc=fane@google.com \
--cc=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=stable@vger.kernel.org \
/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
all inboxes | Powered by JetHome®