|
|
a41c76 |
From 51290a9442c1b9347c43b2fec34b7aa979d26c77 Mon Sep 17 00:00:00 2001
|
|
|
a41c76 |
Message-Id: <51290a9442c1b9347c43b2fec34b7aa979d26c77@dist-git>
|
|
|
a41c76 |
From: Jiri Denemark <jdenemar@redhat.com>
|
|
|
a41c76 |
Date: Tue, 26 May 2020 10:59:34 +0200
|
|
|
a41c76 |
Subject: [PATCH] cpu_x86: Add support for stepping part of CPU signature
|
|
|
a41c76 |
MIME-Version: 1.0
|
|
|
a41c76 |
Content-Type: text/plain; charset=UTF-8
|
|
|
a41c76 |
Content-Transfer-Encoding: 8bit
|
|
|
a41c76 |
|
|
|
a41c76 |
CPU models defined in the cpu_map can use signature/@stepping attribute
|
|
|
a41c76 |
to match a limited set of stepping numbers. The value is a bitmap for
|
|
|
a41c76 |
bits 0..15 each corresponding to a single stepping value. For example,
|
|
|
a41c76 |
stepping='4-6,9' will match 4, 5, 6, and 9. Omitting the attribute is
|
|
|
a41c76 |
equivalent to stepping='0-15'.
|
|
|
a41c76 |
|
|
|
a41c76 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
a41c76 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
a41c76 |
(cherry picked from commit c7a27949954d78dc95459758e329fb9c580361bb)
|
|
|
a41c76 |
|
|
|
a41c76 |
https://bugzilla.redhat.com/show_bug.cgi?id=1840010
|
|
|
a41c76 |
|
|
|
a41c76 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
a41c76 |
Message-Id: <20bd9df72a22a004bb665409ddba20ff89a5b66d.1590483392.git.jdenemar@redhat.com>
|
|
|
a41c76 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
a41c76 |
---
|
|
|
a41c76 |
src/cpu/cpu_x86.c | 60 +++++++++++++++++++++++++++++++++++++++--------
|
|
|
a41c76 |
1 file changed, 50 insertions(+), 10 deletions(-)
|
|
|
a41c76 |
|
|
|
a41c76 |
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
|
|
|
a41c76 |
index 45a073c1d0..0d81f3d2ae 100644
|
|
|
a41c76 |
--- a/src/cpu/cpu_x86.c
|
|
|
a41c76 |
+++ b/src/cpu/cpu_x86.c
|
|
|
a41c76 |
@@ -125,6 +125,7 @@ typedef struct _virCPUx86Signature virCPUx86Signature;
|
|
|
a41c76 |
struct _virCPUx86Signature {
|
|
|
a41c76 |
unsigned int family;
|
|
|
a41c76 |
unsigned int model;
|
|
|
a41c76 |
+ virBitmapPtr stepping;
|
|
|
a41c76 |
};
|
|
|
a41c76 |
|
|
|
a41c76 |
typedef struct _virCPUx86Signatures virCPUx86Signatures;
|
|
|
a41c76 |
@@ -732,7 +733,17 @@ x86MakeSignature(unsigned int family,
|
|
|
a41c76 |
static uint32_t
|
|
|
a41c76 |
virCPUx86SignatureToCPUID(virCPUx86Signature *sig)
|
|
|
a41c76 |
{
|
|
|
a41c76 |
- return x86MakeSignature(sig->family, sig->model, 0);
|
|
|
a41c76 |
+ unsigned int stepping = 0;
|
|
|
a41c76 |
+
|
|
|
a41c76 |
+ if (sig->stepping) {
|
|
|
a41c76 |
+ ssize_t firstBit;
|
|
|
a41c76 |
+
|
|
|
a41c76 |
+ firstBit = virBitmapNextSetBit(sig->stepping, -1);
|
|
|
a41c76 |
+ if (firstBit >= 0)
|
|
|
a41c76 |
+ stepping = firstBit;
|
|
|
a41c76 |
+ }
|
|
|
a41c76 |
+
|
|
|
a41c76 |
+ return x86MakeSignature(sig->family, sig->model, stepping);
|
|
|
a41c76 |
}
|
|
|
a41c76 |
|
|
|
a41c76 |
|
|
|
a41c76 |
@@ -767,8 +778,8 @@ x86DataToSignatureFull(const virCPUx86Data *data,
|
|
|
a41c76 |
}
|
|
|
a41c76 |
|
|
|
a41c76 |
|
|
|
a41c76 |
-/* Mask out irrelevant bits (R and Step) from processor signature. */
|
|
|
a41c76 |
-#define SIGNATURE_MASK 0x0fff3ff0
|
|
|
a41c76 |
+/* Mask out reserved bits from processor signature. */
|
|
|
a41c76 |
+#define SIGNATURE_MASK 0x0fff3fff
|
|
|
a41c76 |
|
|
|
a41c76 |
static uint32_t
|
|
|
a41c76 |
x86DataToSignature(const virCPUx86Data *data)
|
|
|
a41c76 |
@@ -1134,9 +1145,14 @@ virCPUx86SignaturesNew(size_t count)
|
|
|
a41c76 |
static void
|
|
|
a41c76 |
virCPUx86SignaturesFree(virCPUx86SignaturesPtr sigs)
|
|
|
a41c76 |
{
|
|
|
a41c76 |
+ size_t i;
|
|
|
a41c76 |
+
|
|
|
a41c76 |
if (!sigs)
|
|
|
a41c76 |
return;
|
|
|
a41c76 |
|
|
|
a41c76 |
+ for (i = 0; i < sigs->count; i++)
|
|
|
a41c76 |
+ virBitmapFree(sigs->items[i].stepping);
|
|
|
a41c76 |
+
|
|
|
a41c76 |
g_free(sigs->items);
|
|
|
a41c76 |
g_free(sigs);
|
|
|
a41c76 |
}
|
|
|
a41c76 |
@@ -1153,8 +1169,12 @@ virCPUx86SignaturesCopy(virCPUx86SignaturesPtr src)
|
|
|
a41c76 |
|
|
|
a41c76 |
dst = virCPUx86SignaturesNew(src->count);
|
|
|
a41c76 |
|
|
|
a41c76 |
- for (i = 0; i < src->count; i++)
|
|
|
a41c76 |
- dst->items[i] = src->items[i];
|
|
|
a41c76 |
+ for (i = 0; i < src->count; i++) {
|
|
|
a41c76 |
+ dst->items[i].family = src->items[i].family;
|
|
|
a41c76 |
+ dst->items[i].model = src->items[i].model;
|
|
|
a41c76 |
+ if (src->items[i].stepping)
|
|
|
a41c76 |
+ dst->items[i].stepping = virBitmapNewCopy(src->items[i].stepping);
|
|
|
a41c76 |
+ }
|
|
|
a41c76 |
|
|
|
a41c76 |
return dst;
|
|
|
a41c76 |
}
|
|
|
a41c76 |
@@ -1176,7 +1196,9 @@ virCPUx86SignaturesMatch(virCPUx86SignaturesPtr sigs,
|
|
|
a41c76 |
|
|
|
a41c76 |
for (i = 0; i < sigs->count; i++) {
|
|
|
a41c76 |
if (sigs->items[i].family == family &&
|
|
|
a41c76 |
- sigs->items[i].model == model)
|
|
|
a41c76 |
+ sigs->items[i].model == model &&
|
|
|
a41c76 |
+ (!sigs->items[i].stepping ||
|
|
|
a41c76 |
+ virBitmapIsBitSet(sigs->items[i].stepping, stepping)))
|
|
|
a41c76 |
return true;
|
|
|
a41c76 |
}
|
|
|
a41c76 |
|
|
|
a41c76 |
@@ -1194,9 +1216,15 @@ virCPUx86SignaturesFormat(virCPUx86SignaturesPtr sigs)
|
|
|
a41c76 |
return virBufferContentAndReset(&buf;;
|
|
|
a41c76 |
|
|
|
a41c76 |
for (i = 0; i < sigs->count; i++) {
|
|
|
a41c76 |
- virBufferAsprintf(&buf, "(%u,%u,0), ",
|
|
|
a41c76 |
+ g_autofree char *stepping = NULL;
|
|
|
a41c76 |
+
|
|
|
a41c76 |
+ if (sigs->items[i].stepping)
|
|
|
a41c76 |
+ stepping = virBitmapFormat(sigs->items[i].stepping);
|
|
|
a41c76 |
+
|
|
|
a41c76 |
+ virBufferAsprintf(&buf, "(%u,%u,%s), ",
|
|
|
a41c76 |
sigs->items[i].family,
|
|
|
a41c76 |
- sigs->items[i].model);
|
|
|
a41c76 |
+ sigs->items[i].model,
|
|
|
a41c76 |
+ stepping ? stepping : "0-15");
|
|
|
a41c76 |
}
|
|
|
a41c76 |
|
|
|
a41c76 |
virBufferTrim(&buf, ", ", -1);
|
|
|
a41c76 |
@@ -1473,6 +1501,7 @@ x86ModelParseSignatures(virCPUx86ModelPtr model,
|
|
|
a41c76 |
|
|
|
a41c76 |
for (i = 0; i < n; i++) {
|
|
|
a41c76 |
virCPUx86Signature *sig = &model->signatures->items[i];
|
|
|
a41c76 |
+ g_autofree char *stepping = NULL;
|
|
|
a41c76 |
int rc;
|
|
|
a41c76 |
|
|
|
a41c76 |
ctxt->node = nodes[i];
|
|
|
a41c76 |
@@ -1492,6 +1521,11 @@ x86ModelParseSignatures(virCPUx86ModelPtr model,
|
|
|
a41c76 |
model->name);
|
|
|
a41c76 |
return -1;
|
|
|
a41c76 |
}
|
|
|
a41c76 |
+
|
|
|
a41c76 |
+ stepping = virXPathString("string(@stepping)", ctxt);
|
|
|
a41c76 |
+ /* stepping corresponds to 4 bits in 32b signature, see above */
|
|
|
a41c76 |
+ if (stepping && virBitmapParse(stepping, &sig->stepping, 16) < 0)
|
|
|
a41c76 |
+ return -1;
|
|
|
a41c76 |
}
|
|
|
a41c76 |
|
|
|
a41c76 |
ctxt->node = root;
|
|
|
a41c76 |
@@ -2090,6 +2124,9 @@ x86Decode(virCPUDefPtr cpu,
|
|
|
a41c76 |
virDomainCapsCPUModelPtr hvModel = NULL;
|
|
|
a41c76 |
g_autofree char *sigs = NULL;
|
|
|
a41c76 |
uint32_t signature;
|
|
|
a41c76 |
+ unsigned int sigFamily;
|
|
|
a41c76 |
+ unsigned int sigModel;
|
|
|
a41c76 |
+ unsigned int sigStepping;
|
|
|
a41c76 |
ssize_t i;
|
|
|
a41c76 |
int rc;
|
|
|
a41c76 |
|
|
|
a41c76 |
@@ -2103,6 +2140,7 @@ x86Decode(virCPUDefPtr cpu,
|
|
|
a41c76 |
|
|
|
a41c76 |
vendor = x86DataToVendor(&data, map);
|
|
|
a41c76 |
signature = x86DataToSignature(&data);
|
|
|
a41c76 |
+ virCPUx86SignatureFromCPUID(signature, &sigFamily, &sigModel, &sigStepping);
|
|
|
a41c76 |
|
|
|
a41c76 |
x86DataFilterTSX(&data, vendor, map);
|
|
|
a41c76 |
|
|
|
a41c76 |
@@ -2184,8 +2222,10 @@ x86Decode(virCPUDefPtr cpu,
|
|
|
a41c76 |
|
|
|
a41c76 |
sigs = virCPUx86SignaturesFormat(model->signatures);
|
|
|
a41c76 |
|
|
|
a41c76 |
- VIR_DEBUG("Using CPU model %s (signatures %s) for CPU with signature %06lx",
|
|
|
a41c76 |
- model->name, NULLSTR(sigs), (unsigned long)signature);
|
|
|
a41c76 |
+ VIR_DEBUG("Using CPU model %s with signatures [%s] for "
|
|
|
a41c76 |
+ "CPU with signature (%u,%u,%u)",
|
|
|
a41c76 |
+ model->name, NULLSTR(sigs),
|
|
|
a41c76 |
+ sigFamily, sigModel, sigStepping);
|
|
|
a41c76 |
|
|
|
a41c76 |
cpu->model = g_steal_pointer(&cpuModel->model);
|
|
|
a41c76 |
cpu->features = g_steal_pointer(&cpuModel->features);
|
|
|
a41c76 |
--
|
|
|
a41c76 |
2.26.2
|
|
|
a41c76 |
|