forked from rpms/libvirt
72 lines
2.3 KiB
Diff
72 lines
2.3 KiB
Diff
From 48e546c1097a61c806412efe53e216fbc8beafca Mon Sep 17 00:00:00 2001
|
|
Message-Id: <48e546c1097a61c806412efe53e216fbc8beafca@dist-git>
|
|
From: Jiri Denemark <jdenemar@redhat.com>
|
|
Date: Tue, 26 May 2020 10:59:31 +0200
|
|
Subject: [PATCH] cpu_x86: Introduce virCPUx86SignatureFromCPUID
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
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@redhat.com>
|
|
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
(cherry picked from commit 3b474c1f8f3c1f124fab303625733ea79047660c)
|
|
|
|
https://bugzilla.redhat.com/show_bug.cgi?id=1840010
|
|
|
|
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
Message-Id: <1fe352bfb7cf40b5b8e24eea3bf4e476269adb92.1590483392.git.jdenemar@redhat.com>
|
|
Reviewed-by: Ján Tomko <jtomko@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 ed2090b0c6..dad3bceff0 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.2
|
|
|