diff options
author | Vitaly Kuznetsov <[email protected]> | 2020-05-29 15:04:06 +0200 |
---|---|---|
committer | Paolo Bonzini <[email protected]> | 2020-06-01 04:26:04 -0400 |
commit | ed881297338625f3799cce8774d198ef05a858e6 (patch) | |
tree | 1b19eb4d6f86cda45e523b6302bdfa3113d54a15 | |
parent | 929d1cfaa6926ccee28d8d4220e0b4e2defd9cd1 (diff) |
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 <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
-rw-r--r-- | tools/testing/selftests/kvm/include/x86_64/svm_util.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tools/testing/selftests/kvm/include/x86_64/svm_util.h b/tools/testing/selftests/kvm/include/x86_64/svm_util.h index cd037917fece..674151d24fcf 100644 --- a/tools/testing/selftests/kvm/include/x86_64/svm_util.h +++ b/tools/testing/selftests/kvm/include/x86_64/svm_util.h @@ -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 */ |