render / rpms / libvirt

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