diff options
author | Vishal Annapurve <vannapurve@google.com> | 2023-01-11 03:44:43 +0300 |
---|---|---|
committer | Sean Christopherson <seanjc@google.com> | 2023-01-24 21:06:31 +0300 |
commit | e99b0d4cc2b679c5892d0994610b44e7b584d98b (patch) | |
tree | 049e11a829467bbb8c069ba23e94f2e675fdbc47 /tools/testing/selftests/kvm/include/x86_64 | |
parent | ca17899693518acde9ba1adcf46b95d76286106d (diff) | |
download | linux-e99b0d4cc2b679c5892d0994610b44e7b584d98b.tar.xz |
KVM: selftests: x86: Use "this_cpu" prefix for cpu vendor queries
Replace is_intel/amd_cpu helpers with this_cpu_* helpers to better
convey the intent of querying vendor of the current cpu.
Suggested-by: Sean Christopherson <seanjc@google.com>
Reviewed-by: David Matlack <dmatlack@google.com>
Signed-off-by: Vishal Annapurve <vannapurve@google.com>
Link: https://lore.kernel.org/r/20230111004445.416840-2-vannapurve@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
Diffstat (limited to 'tools/testing/selftests/kvm/include/x86_64')
-rw-r--r-- | tools/testing/selftests/kvm/include/x86_64/processor.h | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/tools/testing/selftests/kvm/include/x86_64/processor.h b/tools/testing/selftests/kvm/include/x86_64/processor.h index bbe47e6707eb..b5ea72f79540 100644 --- a/tools/testing/selftests/kvm/include/x86_64/processor.h +++ b/tools/testing/selftests/kvm/include/x86_64/processor.h @@ -555,6 +555,28 @@ static inline uint32_t this_cpu_model(void) return x86_model(this_cpu_fms()); } +static inline bool this_cpu_vendor_string_is(const char *vendor) +{ + const uint32_t *chunk = (const uint32_t *)vendor; + uint32_t eax, ebx, ecx, edx; + + cpuid(0, &eax, &ebx, &ecx, &edx); + return (ebx == chunk[0] && edx == chunk[1] && ecx == chunk[2]); +} + +static inline bool this_cpu_is_intel(void) +{ + return this_cpu_vendor_string_is("GenuineIntel"); +} + +/* + * Exclude early K5 samples with a vendor string of "AMDisbetter!" + */ +static inline bool this_cpu_is_amd(void) +{ + return this_cpu_vendor_string_is("AuthenticAMD"); +} + static inline uint32_t __this_cpu_has(uint32_t function, uint32_t index, uint8_t reg, uint8_t lo, uint8_t hi) { @@ -691,9 +713,6 @@ static inline void cpu_relax(void) "hlt\n" \ ) -bool is_intel_cpu(void); -bool is_amd_cpu(void); - struct kvm_x86_state *vcpu_save_state(struct kvm_vcpu *vcpu); void vcpu_load_state(struct kvm_vcpu *vcpu, struct kvm_x86_state *state); void kvm_x86_state_cleanup(struct kvm_x86_state *state); |