Re: [PATCH] KVM: x86: nSVM: Redirect IA32_PAT accesses to either hPAT or gPAT

From: Sean Christopherson

Date: Tue Apr 07 2026 - 19:52:48 EST


On Tue, Apr 07, 2026, Jim Mattson wrote:
> On Tue, Apr 7, 2026 at 12:24 PM Sean Christopherson <seanjc@xxxxxxxxxx> wrote:
> >
> > On Tue, Apr 07, 2026, Jim Mattson wrote:
> > > When KVM_X86_QUIRK_NESTED_SVM_SHARED_PAT is disabled and the vCPU is in
> > > guest mode with nested NPT enabled, guest accesses to IA32_PAT are
> > > redirected to the gPAT register, which is stored in VMCB02's g_pat field.
> > >
> > > Non-guest accesses (e.g. from userspace) to IA32_PAT are always redirected
> > > to hPAT, which is stored in vcpu->arch.pat.
> > >
> > > Directing host-initiated accesses to hPAT ensures that KVM_GET/SET_MSRS and
> > > KVM_GET/SET_NESTED_STATE are independent of each other and can be ordered
> > > arbitrarily during save and restore. gPAT is saved and restored separately
> > > via KVM_GET/SET_NESTED_STATE.
> > >
> > > Use WARN_ON_ONCE to flag any host-initiated accesses originating from KVM
> > > itself rather than userspace.
> > >
> > > Use pr_warn_once to flag any use of the common MSR-handling code (now
> > > shared by VMX and TDX) for IA32_PAT by a vCPU that is SVM-capable.
> >
> > Changelog is stale, but otherwise this LGTM. I'll fixup the changelog when
> > applying (in a few weeks).
>
> Oh, crud. This was supposed to be 5/8, but I made some changes after
> checkpatch.pl complained and then tried to just regenerate this one,
> but I totally flubbed it.

Huh. The patch shows up when I grab the thread via b4 mbox and open it with mutt,
but b4 am skips it. I'm guessing there's version-based filtering somewhere in b4.

No need for a v9 on my account, I can splice in 5/8 when applying.