Re: [PATCH 4/7] KVM: nVMX: Process each host MSR entry at most once when unwinding failed VM-Entry

From: Jim Mattson

Date: Tue Nov 03 2026 - 14:40:55 EST


On Mon, Nov 2, 2026 at 4:10 PM Sean Christopherson <seanjc@xxxxxxxxxx> wrote:
>
> On Mon, Nov 02, 2026, Jim Mattson wrote:
> > KVM needs to do better.
>
> Meh, KVM is doing pretty darn good, all things considered. Yeah, this code sucks.
> But I'm not convinced the alternatives suck less. We've gotten the set of missed
> consistency checks down to effectively zero, module the TPR mess that I do test
> by running warn_on_missed_cc=true.

I don't understand the TPR mess. The SDM says, "With the exception of
fields corresponding to virtualized APIC registers (defined in Section
32.1.1), software may modify the virtual-APIC page referenced by the
current VMCS of a logical processor in VMX non-root operation. (This
is an exception to the general requirement given in Section 27.11.4.)"
I would argue that this prohibits changes to VTPR between KVM's
software VM-entry checks and hardware VM-entry to VMCS02. If the
hardware VM-entry fails because VTPR has changed, section 27.11.4
gives KVM the freedom to implement whatever "unpredictable behavior"
we like. Yes, that probably does include loading MSR values from the
VM-exit MSR-load list, but why complicate things?

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?