KVM: selftests: Set input function/index in raw CPUID helper(s)

Set the function/index for CPUID in the helper instead of relying on the
caller to do so.  In addition to reducing the risk of consuming an
uninitialized ECX, having the function/index embedded in the call makes
it easier to understand what is being checked.

Signed-off-by: Sean Christopherson <seanjc@google.com>
Link: https://lore.kernel.org/r/20220614200707.3315957-32-seanjc@google.com
This commit is contained in:
Sean Christopherson
2022-06-14 20:06:56 +00:00
parent 813e38cd6d
commit 8fe09d6a91
4 changed files with 26 additions and 33 deletions

View File

@@ -31,10 +31,9 @@ static void test_guest_cpuids(struct kvm_cpuid2 *guest_cpuid)
u32 eax, ebx, ecx, edx;
for (i = 0; i < guest_cpuid->nent; i++) {
eax = guest_cpuid->entries[i].function;
ecx = guest_cpuid->entries[i].index;
cpuid(&eax, &ebx, &ecx, &edx);
__cpuid(guest_cpuid->entries[i].function,
guest_cpuid->entries[i].index,
&eax, &ebx, &ecx, &edx);
GUEST_ASSERT(eax == guest_cpuid->entries[i].eax &&
ebx == guest_cpuid->entries[i].ebx &&
@@ -46,9 +45,9 @@ static void test_guest_cpuids(struct kvm_cpuid2 *guest_cpuid)
static void test_cpuid_40000000(struct kvm_cpuid2 *guest_cpuid)
{
u32 eax = 0x40000000, ebx, ecx = 0, edx;
u32 eax, ebx, ecx, edx;
cpuid(&eax, &ebx, &ecx, &edx);
cpuid(0x40000000, &eax, &ebx, &ecx, &edx);
GUEST_ASSERT(eax == 0x40000001);
}