render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
a41c76
From 48e546c1097a61c806412efe53e216fbc8beafca Mon Sep 17 00:00:00 2001
a41c76
Message-Id: <48e546c1097a61c806412efe53e216fbc8beafca@dist-git>
a41c76
From: Jiri Denemark <jdenemar@redhat.com>
a41c76
Date: Tue, 26 May 2020 10:59:31 +0200
a41c76
Subject: [PATCH] cpu_x86: Introduce virCPUx86SignatureFromCPUID
a41c76
MIME-Version: 1.0
a41c76
Content-Type: text/plain; charset=UTF-8
a41c76
Content-Transfer-Encoding: 8bit
a41c76
a41c76
It can be used for separating family, model, and stepping numbers from a
a41c76
single 32b integer as reported by CPUID.
a41c76
a41c76
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
(cherry picked from commit 3b474c1f8f3c1f124fab303625733ea79047660c)
a41c76
a41c76
https://bugzilla.redhat.com/show_bug.cgi?id=1840010
a41c76
a41c76
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
a41c76
Message-Id: <1fe352bfb7cf40b5b8e24eea3bf4e476269adb92.1590483392.git.jdenemar@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
---
a41c76
 src/cpu/cpu_x86.c | 19 ++++++++++++++-----
a41c76
 1 file changed, 14 insertions(+), 5 deletions(-)
a41c76
a41c76
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
a41c76
index ed2090b0c6..dad3bceff0 100644
a41c76
--- a/src/cpu/cpu_x86.c
a41c76
+++ b/src/cpu/cpu_x86.c
a41c76
@@ -717,6 +717,18 @@ x86MakeSignature(unsigned int family,
a41c76
 }
a41c76
 
a41c76
 
a41c76
+static void
a41c76
+virCPUx86SignatureFromCPUID(uint32_t sig,
a41c76
+                            unsigned int *family,
a41c76
+                            unsigned int *model,
a41c76
+                            unsigned int *stepping)
a41c76
+{
a41c76
+    *family = ((sig >> 20) & 0xff) + ((sig >> 8) & 0xf);
a41c76
+    *model = ((sig >> 12) & 0xf0) + ((sig >> 4) & 0xf);
a41c76
+    *stepping = sig & 0xf;
a41c76
+}
a41c76
+
a41c76
+
a41c76
 static void
a41c76
 x86DataToSignatureFull(const virCPUx86Data *data,
a41c76
                        unsigned int *family,
a41c76
@@ -725,17 +737,14 @@ x86DataToSignatureFull(const virCPUx86Data *data,
a41c76
 {
a41c76
     virCPUx86DataItem leaf1 = CPUID(.eax_in = 0x1);
a41c76
     virCPUx86DataItemPtr item;
a41c76
-    virCPUx86CPUIDPtr cpuid;
a41c76
 
a41c76
     *family = *model = *stepping = 0;
a41c76
 
a41c76
     if (!(item = virCPUx86DataGet(data, &leaf1)))
a41c76
         return;
a41c76
 
a41c76
-    cpuid = &item->data.cpuid;
a41c76
-    *family = ((cpuid->eax >> 20) & 0xff) + ((cpuid->eax >> 8) & 0xf);
a41c76
-    *model = ((cpuid->eax >> 12) & 0xf0) + ((cpuid->eax >> 4) & 0xf);
a41c76
-    *stepping = cpuid->eax & 0xf;
a41c76
+    virCPUx86SignatureFromCPUID(item->data.cpuid.eax,
a41c76
+                                family, model, stepping);
a41c76
 }
a41c76
 
a41c76
 
a41c76
-- 
a41c76
2.26.2
a41c76