mirror of
https://github.com/torvalds/linux.git
synced 2026-06-04 12:35:52 +02:00
KVM: selftests: Refactor kvm_cpuid_has() to prep for X86_PROPERTY_* support
Refactor kvm_cpuid_has() to prepare for extending X86_PROPERTY_* support to KVM as well as "this CPU". No functional change intended. Signed-off-by: Sean Christopherson <seanjc@google.com> Link: https://lore.kernel.org/r/20221006005125.680782-6-seanjc@google.com
This commit is contained in:
parent
d80ddad2a8
commit
a29e6e383b
|
|
@ -652,8 +652,9 @@ const struct kvm_cpuid2 *kvm_get_supported_cpuid(void)
|
|||
return cpuid;
|
||||
}
|
||||
|
||||
bool kvm_cpuid_has(const struct kvm_cpuid2 *cpuid,
|
||||
struct kvm_x86_cpu_feature feature)
|
||||
static uint32_t __kvm_cpu_has(const struct kvm_cpuid2 *cpuid,
|
||||
uint32_t function, uint32_t index,
|
||||
uint8_t reg, uint8_t lo, uint8_t hi)
|
||||
{
|
||||
const struct kvm_cpuid_entry2 *entry;
|
||||
int i;
|
||||
|
|
@ -666,12 +667,18 @@ bool kvm_cpuid_has(const struct kvm_cpuid2 *cpuid,
|
|||
* order, but kvm_x86_cpu_feature matches that mess, so yay
|
||||
* pointer shenanigans!
|
||||
*/
|
||||
if (entry->function == feature.function &&
|
||||
entry->index == feature.index)
|
||||
return (&entry->eax)[feature.reg] & BIT(feature.bit);
|
||||
if (entry->function == function && entry->index == index)
|
||||
return ((&entry->eax)[reg] & GENMASK(hi, lo)) >> lo;
|
||||
}
|
||||
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool kvm_cpuid_has(const struct kvm_cpuid2 *cpuid,
|
||||
struct kvm_x86_cpu_feature feature)
|
||||
{
|
||||
return __kvm_cpu_has(cpuid, feature.function, feature.index,
|
||||
feature.reg, feature.bit, feature.bit);
|
||||
}
|
||||
|
||||
uint64_t kvm_get_feature_msr(uint64_t msr_index)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user