]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
KVM: nSVM: enable GMET for guests
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 8 Apr 2026 15:42:17 +0000 (11:42 -0400)
committerPaolo Bonzini <pbonzini@redhat.com>
Sun, 10 May 2026 12:55:08 +0000 (14:55 +0200)
All that needs to be done is moving the GMET bit from vmcb12 to vmcb02.
The only new thing is that __nested_copy_vmcb_control_to_cache now
ensures that ignored-if-unavailable bits are zero in svm->nested.ctl.

Tested-by: David Riley <d.riley@proxmox.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/svm/nested.c
arch/x86/kvm/svm/svm.c

index 74a1df1cb84f3ab65814e013433c496a405c79e5..3d1fd1776e195d96c2dfb98490d916f6f9b3343f 100644 (file)
@@ -489,11 +489,14 @@ void __nested_copy_vmcb_control_to_cache(struct kvm_vcpu *vcpu,
        nested_svm_sanitize_intercept(vcpu, to, SKINIT);
        nested_svm_sanitize_intercept(vcpu, to, RDPRU);
 
-       /* Always clear SVM_MISC_ENABLE_NP if the guest cannot use NPTs */
+       /* Always clear misc_ctl bits that the guest cannot use */
        to->misc_ctl = from->misc_ctl;
        if (!guest_cpu_cap_has(vcpu, X86_FEATURE_NPT))
                to->misc_ctl &= ~SVM_MISC_ENABLE_NP;
 
+       if (!gmet_enabled || !guest_cpu_cap_has(vcpu, X86_FEATURE_GMET))
+               to->misc_ctl &= ~SVM_MISC_ENABLE_GMET;
+
        to->iopm_base_pa        = from->iopm_base_pa & PAGE_MASK;
        to->msrpm_base_pa       = from->msrpm_base_pa & PAGE_MASK;
        to->tsc_offset          = from->tsc_offset;
@@ -898,6 +901,7 @@ static void nested_vmcb02_prepare_control(struct vcpu_svm *svm)
        /* Use vmcb01 MMU and format if guest does not use nNPT */
        if (nested_npt_enabled(svm)) {
                vmcb02->control.misc_ctl &= ~SVM_MISC_ENABLE_GMET;
+               vmcb02->control.misc_ctl |= (svm->nested.ctl.misc_ctl & SVM_MISC_ENABLE_GMET);
 
                nested_svm_init_mmu_context(vcpu);
        }
index fd79874c5f4bca165122a8cab2f297fea685f20d..a82471a6d3ea2dcb6e4ee0435b9f898c3e2ba10e 100644 (file)
@@ -5504,6 +5504,9 @@ static __init void svm_set_cpu_caps(void)
                if (boot_cpu_has(X86_FEATURE_PFTHRESHOLD))
                        kvm_cpu_cap_set(X86_FEATURE_PFTHRESHOLD);
 
+               if (gmet_enabled)
+                       kvm_cpu_cap_set(X86_FEATURE_GMET);
+
                if (vgif)
                        kvm_cpu_cap_set(X86_FEATURE_VGIF);