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

KVM: x86: Handle UMIP emulation CPUID adjustment in VMX code

Move the CPUID adjustment for UMIP emulation into VMX code to eliminate
an instance of the undesirable "unsigned f_* = *_supported ? F(*) : 0"
pattern in the common CPUID handling code.

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 5ffec6f9
...@@ -331,7 +331,6 @@ static int __do_cpuid_func_emulated(struct kvm_cpuid_array *array, u32 func) ...@@ -331,7 +331,6 @@ static int __do_cpuid_func_emulated(struct kvm_cpuid_array *array, u32 func)
static inline void do_cpuid_7_mask(struct kvm_cpuid_entry2 *entry) static inline void do_cpuid_7_mask(struct kvm_cpuid_entry2 *entry)
{ {
unsigned f_umip = kvm_x86_ops->umip_emulated() ? F(UMIP) : 0;
unsigned f_intel_pt = kvm_x86_ops->pt_supported() ? F(INTEL_PT) : 0; unsigned f_intel_pt = kvm_x86_ops->pt_supported() ? F(INTEL_PT) : 0;
unsigned f_la57; unsigned f_la57;
unsigned f_pku = kvm_x86_ops->pku_supported() ? F(PKU) : 0; unsigned f_pku = kvm_x86_ops->pku_supported() ? F(PKU) : 0;
...@@ -374,7 +373,6 @@ static inline void do_cpuid_7_mask(struct kvm_cpuid_entry2 *entry) ...@@ -374,7 +373,6 @@ static inline void do_cpuid_7_mask(struct kvm_cpuid_entry2 *entry)
cpuid_entry_mask(entry, CPUID_7_ECX); cpuid_entry_mask(entry, CPUID_7_ECX);
/* Set LA57 based on hardware capability. */ /* Set LA57 based on hardware capability. */
entry->ecx |= f_la57; entry->ecx |= f_la57;
entry->ecx |= f_umip;
entry->ecx |= f_pku; entry->ecx |= f_pku;
/* PKU is not yet implemented for shadow paging. */ /* PKU is not yet implemented for shadow paging. */
if (!tdp_enabled || !boot_cpu_has(X86_FEATURE_OSPKE)) if (!tdp_enabled || !boot_cpu_has(X86_FEATURE_OSPKE))
......
...@@ -7135,6 +7135,8 @@ static void vmx_set_supported_cpuid(struct kvm_cpuid_entry2 *entry) ...@@ -7135,6 +7135,8 @@ static void vmx_set_supported_cpuid(struct kvm_cpuid_entry2 *entry)
cpuid_entry_set(entry, X86_FEATURE_MPX); cpuid_entry_set(entry, X86_FEATURE_MPX);
if (boot_cpu_has(X86_FEATURE_INVPCID) && cpu_has_vmx_invpcid()) if (boot_cpu_has(X86_FEATURE_INVPCID) && cpu_has_vmx_invpcid())
cpuid_entry_set(entry, X86_FEATURE_INVPCID); cpuid_entry_set(entry, X86_FEATURE_INVPCID);
if (vmx_umip_emulated())
cpuid_entry_set(entry, X86_FEATURE_UMIP);
break; break;
default: default:
break; break;
......
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