Commit 90d2f60f authored by Sean Christopherson's avatar Sean Christopherson Committed by Paolo Bonzini

KVM: x86: Use KVM cpu caps to track UMIP emulation

Set UMIP in kvm_cpu_caps when it is emulated by VMX, even though the
bit will effectively be dropped by do_host_cpuid().  This allows
checking for UMIP emulation via kvm_cpu_caps instead of a dedicated
kvm_x86_ops callback.

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 c10398b6
...@@ -1177,7 +1177,6 @@ struct kvm_x86_ops { ...@@ -1177,7 +1177,6 @@ struct kvm_x86_ops {
void (*handle_exit_irqoff)(struct kvm_vcpu *vcpu, void (*handle_exit_irqoff)(struct kvm_vcpu *vcpu,
enum exit_fastpath_completion *exit_fastpath); enum exit_fastpath_completion *exit_fastpath);
bool (*umip_emulated)(void);
bool (*pt_supported)(void); bool (*pt_supported)(void);
int (*check_nested_events)(struct kvm_vcpu *vcpu); int (*check_nested_events)(struct kvm_vcpu *vcpu);
......
...@@ -6088,11 +6088,6 @@ static bool svm_rdtscp_supported(void) ...@@ -6088,11 +6088,6 @@ static bool svm_rdtscp_supported(void)
return boot_cpu_has(X86_FEATURE_RDTSCP); return boot_cpu_has(X86_FEATURE_RDTSCP);
} }
static bool svm_umip_emulated(void)
{
return false;
}
static bool svm_pt_supported(void) static bool svm_pt_supported(void)
{ {
return false; return false;
...@@ -7460,7 +7455,6 @@ static struct kvm_x86_ops svm_x86_ops __ro_after_init = { ...@@ -7460,7 +7455,6 @@ static struct kvm_x86_ops svm_x86_ops __ro_after_init = {
.cpuid_update = svm_cpuid_update, .cpuid_update = svm_cpuid_update,
.rdtscp_supported = svm_rdtscp_supported, .rdtscp_supported = svm_rdtscp_supported,
.umip_emulated = svm_umip_emulated,
.pt_supported = svm_pt_supported, .pt_supported = svm_pt_supported,
.set_supported_cpuid = svm_set_supported_cpuid, .set_supported_cpuid = svm_set_supported_cpuid,
......
...@@ -7132,6 +7132,10 @@ static void vmx_set_supported_cpuid(struct kvm_cpuid_entry2 *entry) ...@@ -7132,6 +7132,10 @@ static void vmx_set_supported_cpuid(struct kvm_cpuid_entry2 *entry)
{ {
switch (entry->function) { switch (entry->function) {
case 0x7: case 0x7:
/*
* UMIP needs to be manually set even though vmx_set_cpu_caps()
* also sets UMIP since do_host_cpuid() will drop it.
*/
if (vmx_umip_emulated()) if (vmx_umip_emulated())
cpuid_entry_set(entry, X86_FEATURE_UMIP); cpuid_entry_set(entry, X86_FEATURE_UMIP);
break; break;
...@@ -7160,6 +7164,9 @@ static __init void vmx_set_cpu_caps(void) ...@@ -7160,6 +7164,9 @@ static __init void vmx_set_cpu_caps(void)
if (enable_ept && boot_cpu_has(X86_FEATURE_OSPKE)) if (enable_ept && boot_cpu_has(X86_FEATURE_OSPKE))
kvm_cpu_cap_check_and_set(X86_FEATURE_PKU); kvm_cpu_cap_check_and_set(X86_FEATURE_PKU);
if (vmx_umip_emulated())
kvm_cpu_cap_set(X86_FEATURE_UMIP);
/* CPUID 0xD.1 */ /* CPUID 0xD.1 */
if (!vmx_xsaves_supported()) if (!vmx_xsaves_supported())
kvm_cpu_cap_clear(X86_FEATURE_XSAVES); kvm_cpu_cap_clear(X86_FEATURE_XSAVES);
...@@ -7963,7 +7970,6 @@ static struct kvm_x86_ops vmx_x86_ops __ro_after_init = { ...@@ -7963,7 +7970,6 @@ static struct kvm_x86_ops vmx_x86_ops __ro_after_init = {
.check_intercept = vmx_check_intercept, .check_intercept = vmx_check_intercept,
.handle_exit_irqoff = vmx_handle_exit_irqoff, .handle_exit_irqoff = vmx_handle_exit_irqoff,
.umip_emulated = vmx_umip_emulated,
.pt_supported = vmx_pt_supported, .pt_supported = vmx_pt_supported,
.request_immediate_exit = vmx_request_immediate_exit, .request_immediate_exit = vmx_request_immediate_exit,
......
...@@ -928,7 +928,7 @@ static u64 kvm_host_cr4_reserved_bits(struct cpuinfo_x86 *c) ...@@ -928,7 +928,7 @@ static u64 kvm_host_cr4_reserved_bits(struct cpuinfo_x86 *c)
if (kvm_cpu_cap_has(X86_FEATURE_LA57)) if (kvm_cpu_cap_has(X86_FEATURE_LA57))
reserved_bits &= ~X86_CR4_LA57; reserved_bits &= ~X86_CR4_LA57;
if (kvm_x86_ops->umip_emulated()) if (kvm_cpu_cap_has(X86_FEATURE_UMIP))
reserved_bits &= ~X86_CR4_UMIP; reserved_bits &= ~X86_CR4_UMIP;
return reserved_bits; return reserved_bits;
......
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