Commit 91661989 authored by Sean Christopherson's avatar Sean Christopherson Committed by Paolo Bonzini

KVM: x86: Move VMX's host_efer to common x86 code

Move host_efer to common x86 code and use it for CPUID's is_efer_nx() to
avoid constantly re-reading the MSR.

No functional change intended.
Reviewed-by: default avatarVitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: default avatarSean Christopherson <sean.j.christopherson@intel.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 600087b6
...@@ -1271,6 +1271,8 @@ struct kvm_arch_async_pf { ...@@ -1271,6 +1271,8 @@ struct kvm_arch_async_pf {
bool direct_map; bool direct_map;
}; };
extern u64 __read_mostly host_efer;
extern struct kvm_x86_ops *kvm_x86_ops; extern struct kvm_x86_ops *kvm_x86_ops;
extern struct kmem_cache *x86_fpu_cache; extern struct kmem_cache *x86_fpu_cache;
......
...@@ -134,10 +134,7 @@ int kvm_update_cpuid(struct kvm_vcpu *vcpu) ...@@ -134,10 +134,7 @@ int kvm_update_cpuid(struct kvm_vcpu *vcpu)
static int is_efer_nx(void) static int is_efer_nx(void)
{ {
unsigned long long efer = 0; return host_efer & EFER_NX;
rdmsrl_safe(MSR_EFER, &efer);
return efer & EFER_NX;
} }
static void cpuid_fix_nx_cap(struct kvm_vcpu *vcpu) static void cpuid_fix_nx_cap(struct kvm_vcpu *vcpu)
......
...@@ -433,7 +433,6 @@ static const struct kvm_vmx_segment_field { ...@@ -433,7 +433,6 @@ static const struct kvm_vmx_segment_field {
VMX_SEGMENT_FIELD(LDTR), VMX_SEGMENT_FIELD(LDTR),
}; };
u64 host_efer;
static unsigned long host_idt_base; static unsigned long host_idt_base;
/* /*
...@@ -7646,8 +7645,6 @@ static __init int hardware_setup(void) ...@@ -7646,8 +7645,6 @@ static __init int hardware_setup(void)
struct desc_ptr dt; struct desc_ptr dt;
int r, i, ept_lpage_level; int r, i, ept_lpage_level;
rdmsrl_safe(MSR_EFER, &host_efer);
store_idt(&dt); store_idt(&dt);
host_idt_base = dt.address; host_idt_base = dt.address;
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include "vmcs.h" #include "vmcs.h"
extern const u32 vmx_msr_index[]; extern const u32 vmx_msr_index[];
extern u64 host_efer;
extern u32 get_umwait_control_msr(void); extern u32 get_umwait_control_msr(void);
......
...@@ -186,6 +186,9 @@ static struct kvm_shared_msrs __percpu *shared_msrs; ...@@ -186,6 +186,9 @@ static struct kvm_shared_msrs __percpu *shared_msrs;
| XFEATURE_MASK_BNDCSR | XFEATURE_MASK_AVX512 \ | XFEATURE_MASK_BNDCSR | XFEATURE_MASK_AVX512 \
| XFEATURE_MASK_PKRU) | XFEATURE_MASK_PKRU)
u64 __read_mostly host_efer;
EXPORT_SYMBOL_GPL(host_efer);
static u64 __read_mostly host_xss; static u64 __read_mostly host_xss;
struct kvm_stats_debugfs_item debugfs_entries[] = { struct kvm_stats_debugfs_item debugfs_entries[] = {
...@@ -9612,6 +9615,8 @@ int kvm_arch_hardware_setup(void) ...@@ -9612,6 +9615,8 @@ int kvm_arch_hardware_setup(void)
{ {
int r; int r;
rdmsrl_safe(MSR_EFER, &host_efer);
r = kvm_x86_ops->hardware_setup(); r = kvm_x86_ops->hardware_setup();
if (r != 0) if (r != 0)
return r; return r;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment