Skip to content

Commit f973146

Browse files
vittyvksean-jc
authored andcommitted
KVM: nVMX: Move guest_cpuid_has_evmcs() to hyperv.h
In preparation for making Hyper-V emulation optional, move Hyper-V specific guest_cpuid_has_evmcs() to hyperv.h. No functional change intended. Suggested-by: Sean Christopherson <seanjc@google.com> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com> Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> Tested-by: Jeremi Piotrowski <jpiotrowski@linux.microsoft.com> Link: https://lore.kernel.org/r/20231205103630.1391318-12-vkuznets@redhat.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 225b7c1 commit f973146

2 files changed

Lines changed: 11 additions & 10 deletions

File tree

arch/x86/kvm/vmx/hyperv.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include <linux/kvm_host.h>
66
#include "vmcs12.h"
7+
#include "vmx.h"
78

89
#define EVMPTR_INVALID (-1ULL)
910
#define EVMPTR_MAP_PENDING (-2ULL)
@@ -20,6 +21,16 @@ enum nested_evmptrld_status {
2021
EVMPTRLD_ERROR,
2122
};
2223

24+
static inline bool guest_cpuid_has_evmcs(struct kvm_vcpu *vcpu)
25+
{
26+
/*
27+
* eVMCS is exposed to the guest if Hyper-V is enabled in CPUID and
28+
* eVMCS has been explicitly enabled by userspace.
29+
*/
30+
return vcpu->arch.hyperv_enabled &&
31+
to_vmx(vcpu)->nested.enlightened_vmcs_enabled;
32+
}
33+
2334
u64 nested_get_evmptr(struct kvm_vcpu *vcpu);
2435
uint16_t nested_get_evmcs_version(struct kvm_vcpu *vcpu);
2536
int nested_enable_evmcs(struct kvm_vcpu *vcpu,

arch/x86/kvm/vmx/vmx.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -745,14 +745,4 @@ static inline bool vmx_can_use_ipiv(struct kvm_vcpu *vcpu)
745745
return lapic_in_kernel(vcpu) && enable_ipiv;
746746
}
747747

748-
static inline bool guest_cpuid_has_evmcs(struct kvm_vcpu *vcpu)
749-
{
750-
/*
751-
* eVMCS is exposed to the guest if Hyper-V is enabled in CPUID and
752-
* eVMCS has been explicitly enabled by userspace.
753-
*/
754-
return vcpu->arch.hyperv_enabled &&
755-
to_vmx(vcpu)->nested.enlightened_vmcs_enabled;
756-
}
757-
758748
#endif /* __KVM_X86_VMX_H */

0 commit comments

Comments
 (0)