lkml.org 
[lkml]   [2021]   [Apr]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 4/4] selftests: kvm: add get_emulated_cpuid test
From
Date

>> +static void check_cpuid(struct kvm_cpuid2 *cpuid, struct kvm_cpuid_entry2 *entrie)
>> +{
>> + int i;
>> +
>> + for (i = 0; i < cpuid->nent; i++) {
>> + if (cpuid->entries[i].function == entrie->function &&
>> + cpuid->entries[i].index == entrie->index) {
>> + if (is_cpuid_mangled(entrie))
>> + return;
>> +
>> + TEST_ASSERT(cpuid->entries[i].eax == entrie->eax &&
>> + cpuid->entries[i].ebx == entrie->ebx &&
>> + cpuid->entries[i].ecx == entrie->ecx &&
>> + cpuid->entries[i].edx == entrie->edx,
>> + "CPUID 0x%x.%x differ: 0x%x:0x%x:0x%x:0x%x vs 0x%x:0x%x:0x%x:0x%x",
>> + entrie->function, entrie->index,
>> + cpuid->entries[i].eax, cpuid->entries[i].ebx,
>> + cpuid->entries[i].ecx, cpuid->entries[i].edx,
>> + entrie->eax, entrie->ebx, entrie->ecx, entrie->edx);
>> + return;
>> + }
>> + }
>> +
>> + TEST_ASSERT(false, "CPUID 0x%x.%x not found", entrie->function, entrie->index);
>> +}
>> +
>> +static void compare_cpuids(struct kvm_cpuid2 *cpuid1,
>> + struct kvm_cpuid2 *cpuid2)
>> +{
>> + int i;
>> +
>> + for (i = 0; i < cpuid1->nent; i++)
>> + check_cpuid(cpuid2, &cpuid1->entries[i]);
>> +
>> + for (i = 0; i < cpuid2->nent; i++)
>> + check_cpuid(cpuid1, &cpuid2->entries[i]);
>> +}
>
> CPUID comparison here seems to be borrowed from get_cpuid_test.c, I
> think we can either put it to a library or (my preference) just merge
> these two selftests together. 'get_cpuid_test' name is generic enough to
> be used for KVM_GET_EMULATED_CPUID too.

Yes it is identical. I agree with you, I will merge the test in
get_cpuid_test.c

Emanuele

\
 
 \ /
  Last update: 2021-04-01 11:56    [W:0.039 / U:0.212 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site