It can be used for separating family, model, and stepping numbers from a
single 32b integer as reported by CPUID.
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/cpu/cpu_x86.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index a71b5ccacc..29c6e2b6be 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -717,6 +717,18 @@ x86MakeSignature(unsigned int family,
}
+static void
+virCPUx86SignatureFromCPUID(uint32_t sig,
+ unsigned int *family,
+ unsigned int *model,
+ unsigned int *stepping)
+{
+ *family = ((sig >> 20) & 0xff) + ((sig >> 8) & 0xf);
+ *model = ((sig >> 12) & 0xf0) + ((sig >> 4) & 0xf);
+ *stepping = sig & 0xf;
+}
+
+
static void
x86DataToSignatureFull(const virCPUx86Data *data,
unsigned int *family,
@@ -725,17 +737,14 @@ x86DataToSignatureFull(const virCPUx86Data *data,
{
virCPUx86DataItem leaf1 = CPUID(.eax_in = 0x1);
virCPUx86DataItemPtr item;
- virCPUx86CPUIDPtr cpuid;
*family = *model = *stepping = 0;
if (!(item = virCPUx86DataGet(data, &leaf1)))
return;
- cpuid = &item->data.cpuid;
- *family = ((cpuid->eax >> 20) & 0xff) + ((cpuid->eax >> 8)
& 0xf);
- *model = ((cpuid->eax >> 12) & 0xf0) + ((cpuid->eax >> 4) &
0xf);
- *stepping = cpuid->eax & 0xf;
+ virCPUx86SignatureFromCPUID(item->data.cpuid.eax,
+ family, model, stepping);
}
--
2.26.0