From: Daniel P. Berrangé Date: Thu, 29 Jun 2023 16:51:03 +0000 (+0100) Subject: virt-what-cvm: support alternative cpuid leaf ordering X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=56498baf2eddf072b9dcab7570febc6ce8f58504;p=virt-what.git virt-what-cvm: support alternative cpuid leaf ordering The HyperV CPUID leaf for reporting the vendor string has an alternative ordering of ecx/edx. Signed-off-by: Daniel P. Berrangé (cherry picked from commit 15d3e4a92fd9c1490fb6f86b7ab3a2dff8364837) --- diff --git a/virt-what-cvm.c b/virt-what-cvm.c index f184768..1e7c50b 100644 --- a/virt-what-cvm.c +++ b/virt-what-cvm.c @@ -209,11 +209,14 @@ cpuid (uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx) static uint32_t -cpuid_leaf (uint32_t eax, char *sig) +cpuid_leaf (uint32_t eax, char *sig, bool swapped) { uint32_t *sig32 = (uint32_t *) sig; - cpuid (&eax, &sig32[0], &sig32[2], &sig32[1]); + if (swapped) + cpuid (&eax, &sig32[0], &sig32[2], &sig32[1]); + else + cpuid (&eax, &sig32[0], &sig32[1], &sig32[2]); sig[12] = 0; /* \0-terminate the string to make string comparison possible */ debug("CPUID sig %s\n", sig); return eax; @@ -335,7 +338,7 @@ cpu_sig_intel (void) return; memset (sig, 0, sizeof sig); - cpuid_leaf (CPUID_INTEL_TDX_ENUMERATION, sig); + cpuid_leaf (CPUID_INTEL_TDX_ENUMERATION, sig, true); if (memcmp (sig, CPUID_SIG_INTEL_TDX, sizeof(sig)) == 0) puts ("intel-tdx"); @@ -368,7 +371,7 @@ cpu_sig (void) return; memset (sig, 0, sizeof sig); - cpuid_leaf (0, sig); + cpuid_leaf (0, sig, true); if (memcmp (sig, CPUID_SIG_AMD, sizeof(sig)) == 0) cpu_sig_amd ();