Re: [PATCH v3 7/8] KVM: x86: nSVM: Handle restore of legacy nested state

From: Sean Christopherson

Date: Fri Feb 06 2026 - 14:18:16 EST


On Thu, Feb 05, 2026, Jim Mattson wrote:
> When nested NPT is enabled and KVM_SET_NESTED_STATE is used to restore an
> old checkpoint (without a valid gPAT), the current IA32_PAT value must be
> used as L2's gPAT.
>
> The current IA32_PAT value may be restored by KVM_SET_MSRS after
> KVM_SET_NESTED_STATE. Furthermore, there may be a KVM_GET_NESTED_STATE
> before the first KVM_RUN.
>
> Introduce a new boolean, svm->nested.legacy_gpat_semantics. When set, hPAT
> updates are also applied to gPAT, preserving the old behavior where L2
> shared L1's PAT. svm_vcpu_pre_run() clears this boolean at the first
> KVM_RUN.

State this last point as a command and explain why. E.g. I think this is why?

Clear legacy_gpat_semantics on KVM_RUN so that the legacy semantics are
scoped to a single restore (inasmuch as possible). E.g. to support
restoring a snapshot from an old KVM, and then later restoring a snapshot
from a new KVM.