mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 10:09:10 +02:00
KVM: x86: nSVM: Set vmcb02.g_pat correctly for nested NPT
When KVM_X86_QUIRK_NESTED_SVM_SHARED_PAT is disabled and nested NPT is
enabled in vmcb12, copy the (cached and validated) vmcb12 g_pat field to
vmcb02's g_pat, giving L2 its own independent guest PAT register.
When the quirk is enabled (default), or when NPT is enabled but nested NPT
is disabled, copy L1's IA32_PAT MSR to the vmcb02 g_pat field, since L2
shares the IA32_PAT MSR with L1.
When NPT is disabled, the g_pat field is ignored by hardware.
Fixes: 15038e1472 ("KVM: SVM: obey guest PAT")
Signed-off-by: Jim Mattson <jmattson@google.com>
Link: https://patch.msgid.link/20260407190343.325299-5-jmattson@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
This commit is contained in:
parent
4b83e4ba83
commit
02233c73f8
|
|
@ -731,9 +731,6 @@ static void nested_vmcb02_prepare_save(struct vcpu_svm *svm)
|
|||
struct vmcb *vmcb02 = svm->nested.vmcb02.ptr;
|
||||
struct kvm_vcpu *vcpu = &svm->vcpu;
|
||||
|
||||
nested_vmcb02_compute_g_pat(svm);
|
||||
vmcb_mark_dirty(vmcb02, VMCB_NPT);
|
||||
|
||||
/* Load the nested guest state */
|
||||
if (svm->nested.vmcb12_gpa != svm->nested.last_vmcb12_gpa) {
|
||||
new_vmcb12 = true;
|
||||
|
|
@ -764,6 +761,13 @@ static void nested_vmcb02_prepare_save(struct vcpu_svm *svm)
|
|||
vmcb_mark_dirty(vmcb02, VMCB_CET);
|
||||
}
|
||||
|
||||
if (l2_has_separate_pat(vcpu)) {
|
||||
if (unlikely(new_vmcb12 || vmcb12_is_dirty(control, VMCB_NPT)))
|
||||
vmcb_set_gpat(vmcb02, svm->nested.save.g_pat);
|
||||
} else if (npt_enabled) {
|
||||
vmcb_set_gpat(vmcb02, vcpu->arch.pat);
|
||||
}
|
||||
|
||||
kvm_set_rflags(vcpu, save->rflags | X86_EFLAGS_FIXED);
|
||||
|
||||
svm_set_efer(vcpu, svm->nested.save.efer);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user