render / rpms / libvirt

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