Re: [PATCH v4 2/8] KVM: x86: nSVM: Cache and validate vmcb12 g_pat
From: Yosry Ahmed
Date: Fri Feb 20 2026 - 18:25:42 EST
February 21, 2026 at 12:26 AM, "Jim Mattson" <jmattson@xxxxxxxxxx> wrote:
>
> On Thu, Feb 12, 2026 at 4:22 PM Yosry Ahmed <> wrote:
>
> >
> > @@ -2006,13 +2012,16 @@ static int svm_set_nested_state(struct kvm_vcpu *vcpu,
> >
> > /*
> > * Validate host state saved from before VMRUN (see
> > - * nested_svm_check_permissions).
> > + * nested_svm_check_permissions). Note that the g_pat field is not
> > + * validated, because (a) it may have been clobbered by SMM before
> > + * KVM_GET_NESTED_STATE, and (b) it is not loaded at emulated
> > + * #VMEXIT.
> >
> > (b) here means that svm_copy_vmrun_state() does not copy it to vmcb01,
> > and the value is restored by KVM_SET_MSRS, right?
> >
> Actually, (b) refers to the open-coded block of assignments in
> nested_svm_vmexit() under the comment:
>
> /*
> * Restore processor state that had been saved in vmcb01
> */
>
Yeah IIUC it's the same thing, we migrate them and copy them here to vmcb01 so that we can restore them in nested_svm_vmexit().