|
|
c480ed |
From 5196a4b5fad475a8489faa9b5542536a941bd9da Mon Sep 17 00:00:00 2001
|
|
|
c480ed |
Message-Id: <5196a4b5fad475a8489faa9b5542536a941bd9da@dist-git>
|
|
|
c480ed |
From: Jiri Denemark <jdenemar@redhat.com>
|
|
|
c480ed |
Date: Fri, 21 Jun 2019 09:25:01 +0200
|
|
|
c480ed |
Subject: [PATCH] cpu_x86: Allow multiple signatures for a CPU model
|
|
|
c480ed |
MIME-Version: 1.0
|
|
|
c480ed |
Content-Type: text/plain; charset=UTF-8
|
|
|
c480ed |
Content-Transfer-Encoding: 8bit
|
|
|
c480ed |
|
|
|
c480ed |
CPU signatures in the cpu_map serve as a hint for CPUID to CPU model
|
|
|
c480ed |
matching algorithm. If the CPU signatures matches any CPU model in the
|
|
|
c480ed |
cpu_map, this model will be the preferred one.
|
|
|
c480ed |
|
|
|
c480ed |
This works out well and solved several mismatches, but in real world
|
|
|
c480ed |
CPUs which should match a single CPU model may be produced with several
|
|
|
c480ed |
different signatures. For example, low voltage Broadwell CPUs for
|
|
|
c480ed |
laptops and Broadwell CPUs for servers differ in CPU model numbers while
|
|
|
c480ed |
we should detect them all as Broadwell CPU model.
|
|
|
c480ed |
|
|
|
c480ed |
This patch adds support for storing several signatures for a single CPU
|
|
|
c480ed |
model to make this hint useful for more CPUs. Later commits will provide
|
|
|
c480ed |
additional signatures for existing CPU models, which will correct some
|
|
|
c480ed |
results in our CPU test suite.
|
|
|
c480ed |
|
|
|
c480ed |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
c480ed |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
c480ed |
(cherry picked from commit dfeb3e598438a891a05487c34e6723d1d3ed9256)
|
|
|
c480ed |
|
|
|
c480ed |
https://bugzilla.redhat.com/show_bug.cgi?id=1686895
|
|
|
c480ed |
|
|
|
c480ed |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
c480ed |
Message-Id: <393649e6301769c297f2d09bcb88d6200882eb9d.1561068591.git.jdenemar@redhat.com>
|
|
|
c480ed |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
c480ed |
---
|
|
|
c480ed |
src/cpu/cpu_x86.c | 31 +++++++++++++++++++++----------
|
|
|
c480ed |
1 file changed, 21 insertions(+), 10 deletions(-)
|
|
|
c480ed |
|
|
|
c480ed |
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
|
|
|
c480ed |
index f8b8d8a96b..7bd8119c23 100644
|
|
|
c480ed |
--- a/src/cpu/cpu_x86.c
|
|
|
c480ed |
+++ b/src/cpu/cpu_x86.c
|
|
|
c480ed |
@@ -1204,22 +1204,32 @@ x86ModelParseAncestor(virCPUx86ModelPtr model,
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
static int
|
|
|
c480ed |
-x86ModelParseSignature(virCPUx86ModelPtr model,
|
|
|
c480ed |
- xmlXPathContextPtr ctxt)
|
|
|
c480ed |
+x86ModelParseSignatures(virCPUx86ModelPtr model,
|
|
|
c480ed |
+ xmlXPathContextPtr ctxt)
|
|
|
c480ed |
{
|
|
|
c480ed |
+ VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
|
|
|
c480ed |
+ xmlNodePtr root = ctxt->node;
|
|
|
c480ed |
+ size_t i;
|
|
|
c480ed |
+ int n;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ if ((n = virXPathNodeSet("./signature", ctxt, &nodes)) <= 0)
|
|
|
c480ed |
+ return n;
|
|
|
c480ed |
+
|
|
|
c480ed |
/* Remove inherited signatures. */
|
|
|
c480ed |
VIR_FREE(model->signatures);
|
|
|
c480ed |
|
|
|
c480ed |
- if (virXPathBoolean("boolean(./signature)", ctxt)) {
|
|
|
c480ed |
+ model->nsignatures = n;
|
|
|
c480ed |
+ if (VIR_ALLOC_N(model->signatures, n) < 0)
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ for (i = 0; i < n; i++) {
|
|
|
c480ed |
unsigned int sigFamily = 0;
|
|
|
c480ed |
unsigned int sigModel = 0;
|
|
|
c480ed |
int rc;
|
|
|
c480ed |
|
|
|
c480ed |
- model->nsignatures = 1;
|
|
|
c480ed |
- if (VIR_ALLOC_N(model->signatures, 1) < 0)
|
|
|
c480ed |
- return -1;
|
|
|
c480ed |
+ ctxt->node = nodes[i];
|
|
|
c480ed |
|
|
|
c480ed |
- rc = virXPathUInt("string(./signature/@family)", ctxt, &sigFamily);
|
|
|
c480ed |
+ rc = virXPathUInt("string(@family)", ctxt, &sigFamily);
|
|
|
c480ed |
if (rc < 0 || sigFamily == 0) {
|
|
|
c480ed |
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
c480ed |
_("Invalid CPU signature family in model %s"),
|
|
|
c480ed |
@@ -1227,7 +1237,7 @@ x86ModelParseSignature(virCPUx86ModelPtr model,
|
|
|
c480ed |
return -1;
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
- rc = virXPathUInt("string(./signature/@model)", ctxt, &sigModel);
|
|
|
c480ed |
+ rc = virXPathUInt("string(@model)", ctxt, &sigModel);
|
|
|
c480ed |
if (rc < 0 || sigModel == 0) {
|
|
|
c480ed |
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
c480ed |
_("Invalid CPU signature model in model %s"),
|
|
|
c480ed |
@@ -1235,9 +1245,10 @@ x86ModelParseSignature(virCPUx86ModelPtr model,
|
|
|
c480ed |
return -1;
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
- model->signatures[0] = x86MakeSignature(sigFamily, sigModel, 0);
|
|
|
c480ed |
+ model->signatures[i] = x86MakeSignature(sigFamily, sigModel, 0);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
+ ctxt->node = root;
|
|
|
c480ed |
return 0;
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
@@ -1334,7 +1345,7 @@ x86ModelParse(xmlXPathContextPtr ctxt,
|
|
|
c480ed |
if (x86ModelParseAncestor(model, ctxt, map) < 0)
|
|
|
c480ed |
goto cleanup;
|
|
|
c480ed |
|
|
|
c480ed |
- if (x86ModelParseSignature(model, ctxt) < 0)
|
|
|
c480ed |
+ if (x86ModelParseSignatures(model, ctxt) < 0)
|
|
|
c480ed |
goto cleanup;
|
|
|
c480ed |
|
|
|
c480ed |
if (x86ModelParseVendor(model, ctxt, map) < 0)
|
|
|
c480ed |
--
|
|
|
c480ed |
2.22.0
|
|
|
c480ed |
|