Message ID | 20231205103630.1391318-12-vkuznets@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | KVM: x86: Make Hyper-V emulation optional | expand |
On Tue, 2023-12-05 at 11:36 +0100, Vitaly Kuznetsov wrote: > 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> > --- > arch/x86/kvm/vmx/hyperv.h | 11 +++++++++++ > arch/x86/kvm/vmx/vmx.h | 10 ---------- > 2 files changed, 11 insertions(+), 10 deletions(-) > > diff --git a/arch/x86/kvm/vmx/hyperv.h b/arch/x86/kvm/vmx/hyperv.h > index d4ed99008518..6e1ee951e360 100644 > --- a/arch/x86/kvm/vmx/hyperv.h > +++ b/arch/x86/kvm/vmx/hyperv.h > @@ -4,6 +4,7 @@ > > #include <linux/kvm_host.h> > #include "vmcs12.h" > +#include "vmx.h" > > #define EVMPTR_INVALID (-1ULL) > #define EVMPTR_MAP_PENDING (-2ULL) > @@ -20,6 +21,16 @@ enum nested_evmptrld_status { > EVMPTRLD_ERROR, > }; > > +static inline bool guest_cpuid_has_evmcs(struct kvm_vcpu *vcpu) > +{ > + /* > + * eVMCS is exposed to the guest if Hyper-V is enabled in CPUID and > + * eVMCS has been explicitly enabled by userspace. > + */ > + return vcpu->arch.hyperv_enabled && > + to_vmx(vcpu)->nested.enlightened_vmcs_enabled; > +} > + > u64 nested_get_evmptr(struct kvm_vcpu *vcpu); > uint16_t nested_get_evmcs_version(struct kvm_vcpu *vcpu); > int nested_enable_evmcs(struct kvm_vcpu *vcpu, > diff --git a/arch/x86/kvm/vmx/vmx.h b/arch/x86/kvm/vmx/vmx.h > index c2130d2c8e24..959c6d94287f 100644 > --- a/arch/x86/kvm/vmx/vmx.h > +++ b/arch/x86/kvm/vmx/vmx.h > @@ -745,14 +745,4 @@ static inline bool vmx_can_use_ipiv(struct kvm_vcpu *vcpu) > return lapic_in_kernel(vcpu) && enable_ipiv; > } > > -static inline bool guest_cpuid_has_evmcs(struct kvm_vcpu *vcpu) > -{ > - /* > - * eVMCS is exposed to the guest if Hyper-V is enabled in CPUID and > - * eVMCS has been explicitly enabled by userspace. > - */ > - return vcpu->arch.hyperv_enabled && > - to_vmx(vcpu)->nested.enlightened_vmcs_enabled; > -} > - > #endif /* __KVM_X86_VMX_H */ Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> Best regards, Maxim Levitsky
diff --git a/arch/x86/kvm/vmx/hyperv.h b/arch/x86/kvm/vmx/hyperv.h index d4ed99008518..6e1ee951e360 100644 --- a/arch/x86/kvm/vmx/hyperv.h +++ b/arch/x86/kvm/vmx/hyperv.h @@ -4,6 +4,7 @@ #include <linux/kvm_host.h> #include "vmcs12.h" +#include "vmx.h" #define EVMPTR_INVALID (-1ULL) #define EVMPTR_MAP_PENDING (-2ULL) @@ -20,6 +21,16 @@ enum nested_evmptrld_status { EVMPTRLD_ERROR, }; +static inline bool guest_cpuid_has_evmcs(struct kvm_vcpu *vcpu) +{ + /* + * eVMCS is exposed to the guest if Hyper-V is enabled in CPUID and + * eVMCS has been explicitly enabled by userspace. + */ + return vcpu->arch.hyperv_enabled && + to_vmx(vcpu)->nested.enlightened_vmcs_enabled; +} + u64 nested_get_evmptr(struct kvm_vcpu *vcpu); uint16_t nested_get_evmcs_version(struct kvm_vcpu *vcpu); int nested_enable_evmcs(struct kvm_vcpu *vcpu, diff --git a/arch/x86/kvm/vmx/vmx.h b/arch/x86/kvm/vmx/vmx.h index c2130d2c8e24..959c6d94287f 100644 --- a/arch/x86/kvm/vmx/vmx.h +++ b/arch/x86/kvm/vmx/vmx.h @@ -745,14 +745,4 @@ static inline bool vmx_can_use_ipiv(struct kvm_vcpu *vcpu) return lapic_in_kernel(vcpu) && enable_ipiv; } -static inline bool guest_cpuid_has_evmcs(struct kvm_vcpu *vcpu) -{ - /* - * eVMCS is exposed to the guest if Hyper-V is enabled in CPUID and - * eVMCS has been explicitly enabled by userspace. - */ - return vcpu->arch.hyperv_enabled && - to_vmx(vcpu)->nested.enlightened_vmcs_enabled; -} - #endif /* __KVM_X86_VMX_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> --- arch/x86/kvm/vmx/hyperv.h | 11 +++++++++++ arch/x86/kvm/vmx/vmx.h | 10 ---------- 2 files changed, 11 insertions(+), 10 deletions(-)