Re: [PATCH v4 2/8] KVM: x86: nSVM: Cache and validate vmcb12 g_pat

From: Jim Mattson

Date: Fri Feb 20 2026 - 17:29:59 EST


On Thu, Feb 12, 2026 at 4:22 PM Yosry Ahmed <yosry.ahmed@xxxxxxxxx> 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
*/

> If my understanding is correct:
>
> Reviewed-by: Yosry Ahmed <yosry.ahmed@xxxxxxxxx>