Add a g_pat field to the vmcb_ctrl_area_cached struct for caching the VMCB12 g_pat at emulated VMRUN. This is a preliminary step to allow for proper validation and handling of the VMCB12 g_pat when nested paging is enabled in VMCB12. Fixes: 3d6368ef580a ("KVM: SVM: Add VMRUN handler") Signed-off-by: Jim Mattson --- arch/x86/kvm/svm/nested.c | 6 ++++++ arch/x86/kvm/svm/svm.h | 1 + 2 files changed, 7 insertions(+) diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index 51a89d6aa29f..6e48572e2bd7 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -984,6 +984,12 @@ int nested_svm_vmrun(struct kvm_vcpu *vcpu) nested_copy_vmcb_control_to_cache(svm, &vmcb12->control); nested_copy_vmcb_save_to_cache(svm, &vmcb12->save); + /* + * To facilitate independent validation of the cached state + * save area and the cached control area, we cache the vmcb12 + * g_pat with the cached controls. + */ + svm->nested.ctl.g_pat = vmcb12->save.g_pat; if (!nested_vmcb_check_save(vcpu) || !nested_vmcb_check_controls(vcpu)) { diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h index e4b04f435b3d..c91e20aa3ec2 100644 --- a/arch/x86/kvm/svm/svm.h +++ b/arch/x86/kvm/svm/svm.h @@ -176,6 +176,7 @@ struct vmcb_ctrl_area_cached { u64 virt_ext; u32 clean; u64 bus_lock_rip; + u64 g_pat; union { #if IS_ENABLED(CONFIG_HYPERV) || IS_ENABLED(CONFIG_KVM_HYPERV) struct hv_vmcb_enlightenments hv_enlightenments; -- 2.51.2.1041.gc1ab5b90ca-goog