Skip to content

Commit 017a99a

Browse files
vittyvksean-jc
authored andcommitted
KVM: nSVM: Hide more stuff under CONFIG_KVM_HYPERV/CONFIG_HYPERV
'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>
1 parent 5a30f97 commit 017a99a

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

arch/x86/kvm/svm/nested.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ void recalc_intercepts(struct vcpu_svm *svm)
187187
*/
188188
static bool nested_svm_vmrun_msrpm(struct vcpu_svm *svm)
189189
{
190-
struct hv_vmcb_enlightenments *hve = &svm->nested.ctl.hv_enlightenments;
191190
int i;
192191

193192
/*
@@ -198,11 +197,16 @@ static bool nested_svm_vmrun_msrpm(struct vcpu_svm *svm)
198197
* - Nested hypervisor (L1) is using Hyper-V emulation interface and
199198
* tells KVM (L0) there were no changes in MSR bitmap for L2.
200199
*/
201-
if (!svm->nested.force_msr_bitmap_recalc &&
202-
kvm_hv_hypercall_enabled(&svm->vcpu) &&
203-
hve->hv_enlightenments_control.msr_bitmap &&
204-
(svm->nested.ctl.clean & BIT(HV_VMCB_NESTED_ENLIGHTENMENTS)))
205-
goto set_msrpm_base_pa;
200+
#ifdef CONFIG_KVM_HYPERV
201+
if (!svm->nested.force_msr_bitmap_recalc) {
202+
struct hv_vmcb_enlightenments *hve = &svm->nested.ctl.hv_enlightenments;
203+
204+
if (kvm_hv_hypercall_enabled(&svm->vcpu) &&
205+
hve->hv_enlightenments_control.msr_bitmap &&
206+
(svm->nested.ctl.clean & BIT(HV_VMCB_NESTED_ENLIGHTENMENTS)))
207+
goto set_msrpm_base_pa;
208+
}
209+
#endif
206210

207211
if (!(vmcb12_is_intercept(&svm->nested.ctl, INTERCEPT_MSR_PROT)))
208212
return true;
@@ -230,7 +234,9 @@ static bool nested_svm_vmrun_msrpm(struct vcpu_svm *svm)
230234

231235
svm->nested.force_msr_bitmap_recalc = false;
232236

237+
#ifdef CONFIG_KVM_HYPERV
233238
set_msrpm_base_pa:
239+
#endif
234240
svm->vmcb->control.msrpm_base_pa = __sme_set(__pa(svm->nested.msrpm));
235241

236242
return true;
@@ -378,12 +384,14 @@ void __nested_copy_vmcb_control_to_cache(struct kvm_vcpu *vcpu,
378384
to->msrpm_base_pa &= ~0x0fffULL;
379385
to->iopm_base_pa &= ~0x0fffULL;
380386

387+
#ifdef CONFIG_KVM_HYPERV
381388
/* Hyper-V extensions (Enlightened VMCB) */
382389
if (kvm_hv_hypercall_enabled(vcpu)) {
383390
to->clean = from->clean;
384391
memcpy(&to->hv_enlightenments, &from->hv_enlightenments,
385392
sizeof(to->hv_enlightenments));
386393
}
394+
#endif
387395
}
388396

389397
void nested_copy_vmcb_control_to_cache(struct vcpu_svm *svm,

arch/x86/kvm/svm/svm.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,9 @@ struct vmcb_ctrl_area_cached {
148148
u64 virt_ext;
149149
u32 clean;
150150
union {
151+
#if IS_ENABLED(CONFIG_HYPERV) || IS_ENABLED(CONFIG_KVM_HYPERV)
151152
struct hv_vmcb_enlightenments hv_enlightenments;
153+
#endif
152154
u8 reserved_sw[32];
153155
};
154156
};

0 commit comments

Comments
 (0)