]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
KVM: x86: nSVM: Save/restore gPAT with KVM_{GET,SET}_NESTED_STATE
authorJim Mattson <jmattson@google.com>
Tue, 7 Apr 2026 19:03:31 +0000 (12:03 -0700)
committerSean Christopherson <seanjc@google.com>
Thu, 14 May 2026 12:45:13 +0000 (05:45 -0700)
commit4f256d5770febb9d61f9b57a4c79c491bf4987f1
treed04ca442da0b45b5afd797172ad6da0d48ca6da2
parent32ebdbce3b2332f049cab5d0dc534471f2b0d7f6
KVM: x86: nSVM: Save/restore gPAT with KVM_{GET,SET}_NESTED_STATE

Add a 'gpat' field to kvm_svm_nested_state_hdr to carry L2's guest PAT
value across save and restore.

When KVM_X86_QUIRK_NESTED_SVM_SHARED_PAT is disabled and the vCPU is in
guest mode with nested NPT enabled, save vmcb02's g_pat into the header on
KVM_GET_NESTED_STATE, and restore it on KVM_SET_NESTED_STATE.

Host-initiated accesses to IA32_PAT (via KVM_GET/SET_MSRS) always target
L1's hPAT, so they cannot be used to save or restore gPAT. The separate
header field ensures that KVM_GET/SET_MSRS and KVM_GET/SET_NESTED_STATE are
independent and can be ordered arbitrarily during save and restore.

Note that struct kvm_svm_nested_state_hdr is included in a union padded to
120 bytes, so there is room to add the gpat field without changing any
offsets.

Fixes: cc440cdad5b7 ("KVM: nSVM: implement KVM_GET_NESTED_STATE and KVM_SET_NESTED_STATE")
Signed-off-by: Jim Mattson <jmattson@google.com>
Link: https://patch.msgid.link/20260407190343.325299-9-jmattson@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
Documentation/virt/kvm/api.rst
arch/x86/include/uapi/asm/kvm.h
arch/x86/kvm/svm/nested.c