mirror of
https://github.com/torvalds/linux.git
synced 2024-12-12 06:02:38 +00:00
KVM: selftests: Use get_cpuid_entry() in kvm_get_supported_cpuid_index()
Use get_cpuid_entry() in kvm_get_supported_cpuid_index() to replace functionally identical code. Signed-off-by: Sean Christopherson <seanjc@google.com> Link: https://lore.kernel.org/r/20220614200707.3315957-22-seanjc@google.com
This commit is contained in:
parent
8b02674103
commit
662162fed2
@ -618,6 +618,8 @@ static inline struct kvm_cpuid2 *allocate_kvm_cpuid2(int nr_entries)
|
||||
return cpuid;
|
||||
}
|
||||
|
||||
struct kvm_cpuid_entry2 *get_cpuid_entry(struct kvm_cpuid2 *cpuid,
|
||||
uint32_t function, uint32_t index);
|
||||
void vcpu_init_cpuid(struct kvm_vcpu *vcpu, struct kvm_cpuid2 *cpuid);
|
||||
|
||||
static inline int __vcpu_set_cpuid(struct kvm_vcpu *vcpu)
|
||||
@ -643,8 +645,11 @@ static inline void vcpu_set_cpuid(struct kvm_vcpu *vcpu)
|
||||
vcpu_ioctl(vcpu, KVM_GET_CPUID2, vcpu->cpuid);
|
||||
}
|
||||
|
||||
struct kvm_cpuid_entry2 *
|
||||
kvm_get_supported_cpuid_index(uint32_t function, uint32_t index);
|
||||
static inline struct kvm_cpuid_entry2 *kvm_get_supported_cpuid_index(uint32_t function,
|
||||
uint32_t index)
|
||||
{
|
||||
return get_cpuid_entry(kvm_get_supported_cpuid(), function, index);
|
||||
}
|
||||
|
||||
static inline struct kvm_cpuid_entry2 *
|
||||
kvm_get_supported_cpuid_entry(uint32_t function)
|
||||
@ -763,11 +768,6 @@ uint64_t vm_get_page_table_entry(struct kvm_vm *vm, struct kvm_vcpu *vcpu,
|
||||
void vm_set_page_table_entry(struct kvm_vm *vm, struct kvm_vcpu *vcpu,
|
||||
uint64_t vaddr, uint64_t pte);
|
||||
|
||||
/*
|
||||
* get_cpuid() - find matching CPUID entry and return pointer to it.
|
||||
*/
|
||||
struct kvm_cpuid_entry2 *get_cpuid_entry(struct kvm_cpuid2 *cpuid,
|
||||
uint32_t function, uint32_t index);
|
||||
/*
|
||||
* set_cpuid() - overwrites a matching cpuid entry with the provided value.
|
||||
* matches based on ent->function && ent->index. returns true
|
||||
|
@ -766,38 +766,6 @@ void vcpu_init_cpuid(struct kvm_vcpu *vcpu, struct kvm_cpuid2 *cpuid)
|
||||
vcpu_set_cpuid(vcpu);
|
||||
}
|
||||
|
||||
/*
|
||||
* Locate a cpuid entry.
|
||||
*
|
||||
* Input Args:
|
||||
* function: The function of the cpuid entry to find.
|
||||
* index: The index of the cpuid entry.
|
||||
*
|
||||
* Output Args: None
|
||||
*
|
||||
* Return: A pointer to the cpuid entry. Never returns NULL.
|
||||
*/
|
||||
struct kvm_cpuid_entry2 *
|
||||
kvm_get_supported_cpuid_index(uint32_t function, uint32_t index)
|
||||
{
|
||||
struct kvm_cpuid2 *cpuid;
|
||||
struct kvm_cpuid_entry2 *entry = NULL;
|
||||
int i;
|
||||
|
||||
cpuid = kvm_get_supported_cpuid();
|
||||
for (i = 0; i < cpuid->nent; i++) {
|
||||
if (cpuid->entries[i].function == function &&
|
||||
cpuid->entries[i].index == index) {
|
||||
entry = &cpuid->entries[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
TEST_ASSERT(entry, "Guest CPUID entry not found: (EAX=%x, ECX=%x).",
|
||||
function, index);
|
||||
return entry;
|
||||
}
|
||||
|
||||
uint64_t vcpu_get_msr(struct kvm_vcpu *vcpu, uint64_t msr_index)
|
||||
{
|
||||
struct {
|
||||
|
Loading…
Reference in New Issue
Block a user