KVM: selftests: Use this_cpu_has() to detect SVM support in L1
Replace an evil open coded instance of querying CPUID from L1 with this_cpu_has(X86_FEATURE_SVM). No functional change intended. Signed-off-by: Sean Christopherson <seanjc@google.com> Link: https://lore.kernel.org/r/20220614200707.3315957-35-seanjc@google.com
This commit is contained in:
parent
2b424a76d0
commit
05c2b6e5fa
@ -13,9 +13,6 @@
|
||||
#include "svm.h"
|
||||
#include "processor.h"
|
||||
|
||||
#define CPUID_SVM_BIT 2
|
||||
#define CPUID_SVM BIT_ULL(CPUID_SVM_BIT)
|
||||
|
||||
#define SVM_EXIT_EXCP_BASE 0x040
|
||||
#define SVM_EXIT_HLT 0x078
|
||||
#define SVM_EXIT_MSR 0x07c
|
||||
@ -52,16 +49,6 @@ struct svm_test_data *vcpu_alloc_svm(struct kvm_vm *vm, vm_vaddr_t *p_svm_gva);
|
||||
void generic_svm_setup(struct svm_test_data *svm, void *guest_rip, void *guest_rsp);
|
||||
void run_guest(struct vmcb *vmcb, uint64_t vmcb_gpa);
|
||||
|
||||
static inline bool cpu_has_svm(void)
|
||||
{
|
||||
u32 eax = 0x80000001, ecx;
|
||||
|
||||
asm("cpuid" :
|
||||
"=a" (eax), "=c" (ecx) : "0" (eax) : "ebx", "edx");
|
||||
|
||||
return ecx & CPUID_SVM;
|
||||
}
|
||||
|
||||
int open_sev_dev_path_or_exit(void);
|
||||
|
||||
#endif /* SELFTEST_KVM_SVM_UTILS_H */
|
||||
|
@ -83,7 +83,7 @@ static void guest_code(void *arg)
|
||||
sync_with_host(4);
|
||||
|
||||
if (arg) {
|
||||
if (cpu_has_svm()) {
|
||||
if (this_cpu_has(X86_FEATURE_SVM)) {
|
||||
generic_svm_setup(svm, l2_guest_code,
|
||||
&l2_guest_stack[L2_GUEST_STACK_SIZE]);
|
||||
} else {
|
||||
@ -99,7 +99,7 @@ static void guest_code(void *arg)
|
||||
|
||||
sync_with_host(7);
|
||||
|
||||
if (cpu_has_svm()) {
|
||||
if (this_cpu_has(X86_FEATURE_SVM)) {
|
||||
run_guest(svm->vmcb, svm->vmcb_gpa);
|
||||
run_guest(svm->vmcb, svm->vmcb_gpa);
|
||||
} else {
|
||||
|
@ -142,7 +142,7 @@ static void __attribute__((__flatten__)) guest_code(void *arg)
|
||||
GUEST_SYNC(2);
|
||||
|
||||
if (arg) {
|
||||
if (cpu_has_svm())
|
||||
if (this_cpu_has(X86_FEATURE_SVM))
|
||||
svm_l1_guest_code(arg);
|
||||
else
|
||||
vmx_l1_guest_code(arg);
|
||||
|
Loading…
Reference in New Issue
Block a user