Commit 682a8108 authored by Borislav Petkov's avatar Borislav Petkov Committed by Paolo Bonzini

x86/kvm/svm: Simplify cpu_has_svm()

Use already cached CPUID information instead of querying CPUID again.

No functionality change.
Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
Cc: Joerg Roedel <joro@8bytes.org>
Cc: kvm@vger.kernel.org
Cc: x86@kernel.org
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 4e10b764
...@@ -193,7 +193,6 @@ struct __attribute__ ((__packed__)) vmcb { ...@@ -193,7 +193,6 @@ struct __attribute__ ((__packed__)) vmcb {
struct vmcb_save_area save; struct vmcb_save_area save;
}; };
#define SVM_CPUID_FEATURE_SHIFT 2
#define SVM_CPUID_FUNC 0x8000000a #define SVM_CPUID_FUNC 0x8000000a
#define SVM_VM_CR_SVM_DISABLE 4 #define SVM_VM_CR_SVM_DISABLE 4
......
...@@ -83,23 +83,19 @@ static inline void cpu_emergency_vmxoff(void) ...@@ -83,23 +83,19 @@ static inline void cpu_emergency_vmxoff(void)
*/ */
static inline int cpu_has_svm(const char **msg) static inline int cpu_has_svm(const char **msg)
{ {
uint32_t eax, ebx, ecx, edx;
if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD) { if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD) {
if (msg) if (msg)
*msg = "not amd"; *msg = "not amd";
return 0; return 0;
} }
cpuid(0x80000000, &eax, &ebx, &ecx, &edx); if (boot_cpu_data.extended_cpuid_level < SVM_CPUID_FUNC) {
if (eax < SVM_CPUID_FUNC) {
if (msg) if (msg)
*msg = "can't execute cpuid_8000000a"; *msg = "can't execute cpuid_8000000a";
return 0; return 0;
} }
cpuid(0x80000001, &eax, &ebx, &ecx, &edx); if (!boot_cpu_has(X86_FEATURE_SVM)) {
if (!(ecx & (1 << SVM_CPUID_FEATURE_SHIFT))) {
if (msg) if (msg)
*msg = "svm not available"; *msg = "svm not available";
return 0; return 0;
......
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