2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-21 03:33:59 +08:00

selftests: kvm: introduce cpu_has_svm() check

Many tests will want to check if the CPU is Intel or AMD in
guest code, add cpu_has_svm() and put it as static
inline to svm_util.h.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Message-Id: <20200529130407.57176-1-vkuznets@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Vitaly Kuznetsov 2020-05-29 15:04:06 +02:00 committed by Paolo Bonzini
parent 929d1cfaa6
commit ed88129733

View File

@ -35,4 +35,14 @@ void generic_svm_setup(struct svm_test_data *svm, void *guest_rip, void *guest_r
void run_guest(struct vmcb *vmcb, uint64_t vmcb_gpa);
void nested_svm_check_supported(void);
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;
}
#endif /* SELFTEST_KVM_SVM_UTILS_H */