Re: [PATCH v3 3/8] KVM: x86: nSVM: Set vmcb02.g_pat correctly for nested NPT

From: Sean Christopherson

Date: Fri Feb 06 2026 - 14:20:44 EST


On Fri, Feb 06, 2026, Yosry Ahmed wrote:
> February 6, 2026 at 10:23 AM, "Sean Christopherson" <seanjc@xxxxxxxxxx> wrote:
> > > if (svm->nested.vmcb12_gpa != svm->nested.last_vmcb12_gpa) {
> > > new_vmcb12 = true;
> > > @@ -656,6 +653,19 @@ static void nested_vmcb02_prepare_save(struct vcpu_svm *svm, struct vmcb *vmcb12
> > > svm->nested.force_msr_bitmap_recalc = true;
> > > }
> > >
> > > + if (npt_enabled) {
> > > + if (nested_npt_enabled(svm)) {
> > > + if (unlikely(new_vmcb12 ||
> > > + vmcb_is_dirty(vmcb12, VMCB_NPT))) {
> > > + vmcb02->save.g_pat = svm->nested.gpat;
> > > + vmcb_mark_dirty(vmcb02, VMCB_NPT);
> > > + }
> > > + } else {
> > > + vmcb02->save.g_pat = vcpu->arch.pat;
> > > + vmcb_mark_dirty(vmcb02, VMCB_NPT);
> > > + }
> > > + }
> > >
> > To reduce indentation, how about this? There's a consistency check for
> > nested_npt_enabled() vs. npt_enabled, so it's guaranteed to do the right thing.
>
> You mean the one that goes away after this patch: https://lore.kernel.org/kvm/20260115011312.3675857-16-yosry.ahmed@xxxxxxxxx/?

Heh, still fine. All that matters is that nested_npt_enabled() can't be %true
if npt_enabled is %false.