]> git.itanic.dy.fi Git - linux-stable/commitdiff
KVM: nSVM: Hide more stuff under CONFIG_KVM_HYPERV/CONFIG_HYPERV
authorVitaly Kuznetsov <vkuznets@redhat.com>
Tue, 5 Dec 2023 10:36:30 +0000 (11:36 +0100)
committerSean Christopherson <seanjc@google.com>
Thu, 7 Dec 2023 17:35:26 +0000 (09:35 -0800)
'struct hv_vmcb_enlightenments' in VMCB only make sense when either
CONFIG_KVM_HYPERV or CONFIG_HYPERV is enabled.

No functional change intended.

Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
Tested-by: Jeremi Piotrowski <jpiotrowski@linux.microsoft.com>
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Link: https://lore.kernel.org/r/20231205103630.1391318-17-vkuznets@redhat.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/svm/nested.c
arch/x86/kvm/svm/svm.h

index 74c04102ef01cb10933ce34f36a3eda679d6c50a..20212aac050b800534b2157d515e52b2721e217d 100644 (file)
@@ -187,7 +187,6 @@ void recalc_intercepts(struct vcpu_svm *svm)
  */
 static bool nested_svm_vmrun_msrpm(struct vcpu_svm *svm)
 {
-       struct hv_vmcb_enlightenments *hve = &svm->nested.ctl.hv_enlightenments;
        int i;
 
        /*
@@ -198,11 +197,16 @@ static bool nested_svm_vmrun_msrpm(struct vcpu_svm *svm)
         * - Nested hypervisor (L1) is using Hyper-V emulation interface and
         * tells KVM (L0) there were no changes in MSR bitmap for L2.
         */
-       if (!svm->nested.force_msr_bitmap_recalc &&
-           kvm_hv_hypercall_enabled(&svm->vcpu) &&
-           hve->hv_enlightenments_control.msr_bitmap &&
-           (svm->nested.ctl.clean & BIT(HV_VMCB_NESTED_ENLIGHTENMENTS)))
-               goto set_msrpm_base_pa;
+#ifdef CONFIG_KVM_HYPERV
+       if (!svm->nested.force_msr_bitmap_recalc) {
+               struct hv_vmcb_enlightenments *hve = &svm->nested.ctl.hv_enlightenments;
+
+               if (kvm_hv_hypercall_enabled(&svm->vcpu) &&
+                   hve->hv_enlightenments_control.msr_bitmap &&
+                   (svm->nested.ctl.clean & BIT(HV_VMCB_NESTED_ENLIGHTENMENTS)))
+                       goto set_msrpm_base_pa;
+       }
+#endif
 
        if (!(vmcb12_is_intercept(&svm->nested.ctl, INTERCEPT_MSR_PROT)))
                return true;
@@ -230,7 +234,9 @@ static bool nested_svm_vmrun_msrpm(struct vcpu_svm *svm)
 
        svm->nested.force_msr_bitmap_recalc = false;
 
+#ifdef CONFIG_KVM_HYPERV
 set_msrpm_base_pa:
+#endif
        svm->vmcb->control.msrpm_base_pa = __sme_set(__pa(svm->nested.msrpm));
 
        return true;
@@ -378,12 +384,14 @@ void __nested_copy_vmcb_control_to_cache(struct kvm_vcpu *vcpu,
        to->msrpm_base_pa &= ~0x0fffULL;
        to->iopm_base_pa  &= ~0x0fffULL;
 
+#ifdef CONFIG_KVM_HYPERV
        /* Hyper-V extensions (Enlightened VMCB) */
        if (kvm_hv_hypercall_enabled(vcpu)) {
                to->clean = from->clean;
                memcpy(&to->hv_enlightenments, &from->hv_enlightenments,
                       sizeof(to->hv_enlightenments));
        }
+#endif
 }
 
 void nested_copy_vmcb_control_to_cache(struct vcpu_svm *svm,
index be67ab7fdd104e33f1ecc960e94d23e9385acf73..59adff7bbf5548c033eb5f4850dca9c03657f703 100644 (file)
@@ -148,7 +148,9 @@ struct vmcb_ctrl_area_cached {
        u64 virt_ext;
        u32 clean;
        union {
+#if IS_ENABLED(CONFIG_HYPERV) || IS_ENABLED(CONFIG_KVM_HYPERV)
                struct hv_vmcb_enlightenments hv_enlightenments;
+#endif
                u8 reserved_sw[32];
        };
 };