import libvirt-4.5.0-37.module+el8.2.0+5221+0a85e35d

This commit is contained in:
CentOS Sources 2020-01-21 13:46:57 -05:00 committed by Stepan Oksanichenko
parent abe0c88101
commit d954e5c2e6
341 changed files with 86942 additions and 2 deletions

View File

@ -0,0 +1,56 @@
From e75abae126f9fcaf1e8478f0780ecae736f7d3e1 Mon Sep 17 00:00:00 2001
Message-Id: <e75abae126f9fcaf1e8478f0780ecae736f7d3e1@dist-git>
From: "Allen, John" <John.Allen@amd.com>
Date: Tue, 2 Jul 2019 17:05:34 +0200
Subject: [PATCH] Handle copying bitmaps to larger data buffers
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
If a bitmap of a shorter length than the data buffer is passed to
virBitmapToDataBuf, it will read off the end of the bitmap and copy junk
into the returned buffer. Add a check to only copy the length of the
bitmap to the buffer.
The problem can be observed after setting a vcpu affinity using the vcpupin
command on a system with a large number of cores:
# virsh vcpupin example_domain 0 0
# virsh vcpupin example_domain 0
VCPU CPU Affinity
---------------------------
0 0,192,197-198,202
Signed-off-by: John Allen <john.allen@amd.com>
(cherry picked from commit 51f9f80d350e633adf479c6a9b3c55f82ca9cbd4)
https: //bugzilla.redhat.com/show_bug.cgi?id=1703160
Signed-off-by: Erik Skultety <eskultet@redhat.com>
Message-Id: <1a487c4f1ba9725eb7325debeeff2861d7047890.1562079635.git.eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/util/virbitmap.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c
index 49e542a4e6..7df0a2d4f3 100644
--- a/src/util/virbitmap.c
+++ b/src/util/virbitmap.c
@@ -831,11 +831,15 @@ virBitmapToDataBuf(virBitmapPtr bitmap,
unsigned char *bytes,
size_t len)
{
+ size_t nbytes = bitmap->map_len * (VIR_BITMAP_BITS_PER_UNIT / CHAR_BIT);
unsigned long *l;
size_t i, j;
memset(bytes, 0, len);
+ /* If bitmap and buffer differ in size, only fill to the smaller length */
+ len = MIN(len, nbytes);
+
/* htole64 is not provided by gnulib, so we do the conversion by hand */
l = bitmap->map;
for (i = j = 0; i < len; i++, j++) {
--
2.22.0

View File

@ -0,0 +1,93 @@
From 8069bb50b2548acd3f2176499ede205e6099c067 Mon Sep 17 00:00:00 2001
Message-Id: <8069bb50b2548acd3f2176499ede205e6099c067@dist-git>
From: Michal Privoznik <mprivozn@redhat.com>
Date: Thu, 27 Jun 2019 15:18:17 +0200
Subject: [PATCH] Revert "Separate out StateAutoStart from StateInitialize"
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This reverts commit e4a969092bda5b3b952963fdf6658895165040b7.
Now that drivers may call virConnectOpen() on secondary drivers, it
doesn't make much sense to have autostart separated from driver
initialization callback. In fact, it creates a problem because one
driver during its initialization might try to fetch an object from
another driver but since the object is yet to be autostarted the fetch
fails. This has been observed in reality: qemu driver performs
qemuProcessReconnect() during qemu's stateInitialize phase which may
call virDomainDiskTranslateSourcePool() which connects to the storage
driver to look up the volume. But the storage driver did not autostart
its pools yet therefore volume lookup fails and the domain is killed.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 07a9c8bae8b80ef1650e6d05869cbf55c6aea837)
https://bugzilla.redhat.com/show_bug.cgi?id=1685151
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Message-Id: <4ed5f8f4edd0053cc14f4bb579a945b606b36f5a.1561641375.git.mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
---
src/driver-state.h | 4 ----
src/libvirt.c | 14 +-------------
2 files changed, 1 insertion(+), 17 deletions(-)
diff --git a/src/driver-state.h b/src/driver-state.h
index 1cb3e4faf3..e1e060bcc5 100644
--- a/src/driver-state.h
+++ b/src/driver-state.h
@@ -30,9 +30,6 @@ typedef int
virStateInhibitCallback callback,
void *opaque);
-typedef void
-(*virDrvStateAutoStart)(void);
-
typedef int
(*virDrvStateCleanup)(void);
@@ -48,7 +45,6 @@ typedef virStateDriver *virStateDriverPtr;
struct _virStateDriver {
const char *name;
virDrvStateInitialize stateInitialize;
- virDrvStateAutoStart stateAutoStart;
virDrvStateCleanup stateCleanup;
virDrvStateReload stateReload;
virDrvStateStop stateStop;
diff --git a/src/libvirt.c b/src/libvirt.c
index 52f4dd2808..c9e5f47fd4 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -637,11 +637,7 @@ virRegisterStateDriver(virStateDriverPtr driver)
* @callback: callback to invoke to inhibit shutdown of the daemon
* @opaque: data to pass to @callback
*
- * Initialize all virtualization drivers. Accomplished in two phases,
- * the first being state and structure initialization followed by any
- * auto start supported by the driver. This is done to ensure dependencies
- * that some drivers may have on another driver having been initialized
- * will exist, such as the storage driver's need to use the secret driver.
+ * Initialize all virtualization drivers.
*
* Returns 0 if all succeed, -1 upon any failure.
*/
@@ -669,14 +665,6 @@ virStateInitialize(bool privileged,
}
}
}
-
- for (i = 0; i < virStateDriverTabCount; i++) {
- if (virStateDriverTab[i]->stateAutoStart) {
- VIR_DEBUG("Running global auto start for %s state driver",
- virStateDriverTab[i]->name);
- virStateDriverTab[i]->stateAutoStart();
- }
- }
return 0;
}
--
2.22.0

View File

@ -0,0 +1,108 @@
From 2395bf301cf76ffa863a3c2e125d52345cfbf6b5 Mon Sep 17 00:00:00 2001
Message-Id: <2395bf301cf76ffa863a3c2e125d52345cfbf6b5@dist-git>
From: Pavel Hrdina <phrdina@redhat.com>
Date: Mon, 1 Jul 2019 17:08:23 +0200
Subject: [PATCH] Revert "util: vircgroup: pass parent cgroup into
virCgroupDetectControllersCB"
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This reverts commit 7bca1c9bdc85247446129f856e27c80a32819e17.
As it turns out it's not a good idea on systemd hosts. The root
cgroup can have all controllers enabled but they don't have to be
enabled for sub-cgroups.
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit d117431143d5b6dcfc8fae4a6b3fae23881d0937)
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1689297
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Message-Id: <754b0ac5a0f1bd21e79eaeb71f6d2ab811446168.1561993100.git.phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/util/vircgroup.c | 2 +-
src/util/vircgroupbackend.h | 3 +--
src/util/vircgroupv1.c | 3 +--
src/util/vircgroupv2.c | 17 ++++++-----------
4 files changed, 9 insertions(+), 16 deletions(-)
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index ff2a0b75b5..a7fb595bce 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -412,7 +412,7 @@ virCgroupDetect(virCgroupPtr group,
for (i = 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) {
if (group->backends[i]) {
- int rc = group->backends[i]->detectControllers(group, controllers, parent);
+ int rc = group->backends[i]->detectControllers(group, controllers);
if (rc < 0)
return -1;
controllersAvailable |= rc;
diff --git a/src/util/vircgroupbackend.h b/src/util/vircgroupbackend.h
index 05af118ec1..a825dc4be7 100644
--- a/src/util/vircgroupbackend.h
+++ b/src/util/vircgroupbackend.h
@@ -96,8 +96,7 @@ typedef char *
typedef int
(*virCgroupDetectControllersCB)(virCgroupPtr group,
- int controllers,
- virCgroupPtr parent);
+ int controllers);
typedef bool
(*virCgroupHasControllerCB)(virCgroupPtr cgroup,
diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c
index 5b218c7f78..58bd20d636 100644
--- a/src/util/vircgroupv1.c
+++ b/src/util/vircgroupv1.c
@@ -419,8 +419,7 @@ virCgroupV1StealPlacement(virCgroupPtr group)
static int
virCgroupV1DetectControllers(virCgroupPtr group,
- int controllers,
- virCgroupPtr parent ATTRIBUTE_UNUSED)
+ int controllers)
{
size_t i;
size_t j;
diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
index bdeab397a3..b0ed889cc8 100644
--- a/src/util/vircgroupv2.c
+++ b/src/util/vircgroupv2.c
@@ -285,21 +285,16 @@ virCgroupV2ParseControllersFile(virCgroupPtr group)
static int
virCgroupV2DetectControllers(virCgroupPtr group,
- int controllers,
- virCgroupPtr parent)
+ int controllers)
{
size_t i;
- if (parent) {
- group->unified.controllers = parent->unified.controllers;
- } else {
- if (virCgroupV2ParseControllersFile(group) < 0)
- return -1;
+ if (virCgroupV2ParseControllersFile(group) < 0)
+ return -1;
- /* In cgroup v2 there is no cpuacct controller, the cpu.stat file always
- * exists with usage stats. */
- group->unified.controllers |= 1 << VIR_CGROUP_CONTROLLER_CPUACCT;
- }
+ /* In cgroup v2 there is no cpuacct controller, the cpu.stat file always
+ * exists with usage stats. */
+ group->unified.controllers |= 1 << VIR_CGROUP_CONTROLLER_CPUACCT;
if (controllers >= 0)
group->unified.controllers &= controllers;
--
2.22.0

View File

@ -0,0 +1,295 @@
From 799c9dd37390878a54be303b3e3e27445049bf2b Mon Sep 17 00:00:00 2001
Message-Id: <799c9dd37390878a54be303b3e3e27445049bf2b@dist-git>
From: Michal Privoznik <mprivozn@redhat.com>
Date: Thu, 27 Jun 2019 15:18:16 +0200
Subject: [PATCH] Revert "virStateDriver - Separate AutoStart from Initialize"
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This reverts commit cefb97fb815c81fc882da752f45effd23bcb9b4b.
The stateAutoStart callback will be removed in the next commit.
Therefore move autostarting of domains, networks and storage
pools back into stateInitialize callbacks.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit fc380c2e018ae15347d4c281a7e74896c48cac4a)
https://bugzilla.redhat.com/show_bug.cgi?id=1685151
The difference to the upstream commit is uml driver change. In
upstream, the uml driver was dropped, but it's still kept around
in downstream.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Message-Id: <a8e69f65b397c81c2a68597cca6c8ac04df24153.1561641375.git.mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
---
src/libxl/libxl_driver.c | 14 +++-----------
src/lxc/lxc_driver.c | 16 ++--------------
src/network/bridge_driver.c | 22 ++++------------------
src/qemu/qemu_driver.c | 17 ++---------------
src/storage/storage_driver.c | 19 ++-----------------
src/uml/uml_driver.c | 17 ++---------------
6 files changed, 15 insertions(+), 90 deletions(-)
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 5a5e792957..99bb010af4 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -773,6 +773,9 @@ libxlStateInitialize(bool privileged,
NULL, NULL) < 0)
goto error;
+ virDomainObjListForEach(libxl_driver->domains, libxlAutostartDomain,
+ libxl_driver);
+
virDomainObjListForEach(libxl_driver->domains, libxlDomainManagedSaveLoad,
libxl_driver);
@@ -784,16 +787,6 @@ libxlStateInitialize(bool privileged,
return -1;
}
-static void
-libxlStateAutoStart(void)
-{
- if (!libxl_driver)
- return;
-
- virDomainObjListForEach(libxl_driver->domains, libxlAutostartDomain,
- libxl_driver);
-}
-
static int
libxlStateReload(void)
{
@@ -6479,7 +6472,6 @@ static virConnectDriver libxlConnectDriver = {
static virStateDriver libxlStateDriver = {
.name = "LIBXL",
.stateInitialize = libxlStateInitialize,
- .stateAutoStart = libxlStateAutoStart,
.stateCleanup = libxlStateCleanup,
.stateReload = libxlStateReload,
};
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index f9794e0655..527fa72083 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -1646,6 +1646,8 @@ static int lxcStateInitialize(bool privileged,
NULL, NULL) < 0)
goto cleanup;
+ virLXCProcessAutostartAll(lxc_driver);
+
virObjectUnref(caps);
return 0;
@@ -1655,19 +1657,6 @@ static int lxcStateInitialize(bool privileged,
return -1;
}
-/**
- * lxcStateAutoStart:
- *
- * Function to autostart the LXC daemons
- */
-static void lxcStateAutoStart(void)
-{
- if (!lxc_driver)
- return;
-
- virLXCProcessAutostartAll(lxc_driver);
-}
-
static void lxcNotifyLoadDomain(virDomainObjPtr vm, int newVM, void *opaque)
{
virLXCDriverPtr driver = opaque;
@@ -5550,7 +5539,6 @@ static virConnectDriver lxcConnectDriver = {
static virStateDriver lxcStateDriver = {
.name = LXC_DRIVER_NAME,
.stateInitialize = lxcStateInitialize,
- .stateAutoStart = lxcStateAutoStart,
.stateCleanup = lxcStateCleanup,
.stateReload = lxcStateReload,
};
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index d153a8cdb6..a60d7db685 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -755,6 +755,10 @@ networkStateInitialize(bool privileged,
networkReloadFirewallRules(network_driver);
networkRefreshDaemons(network_driver);
+ virNetworkObjListForEach(network_driver->networks,
+ networkAutostartConfig,
+ network_driver);
+
network_driver->networkEventState = virObjectEventStateNew();
#ifdef WITH_FIREWALLD
@@ -794,23 +798,6 @@ networkStateInitialize(bool privileged,
}
-/**
- * networkStateAutoStart:
- *
- * Function to AutoStart the bridge configs
- */
-static void
-networkStateAutoStart(void)
-{
- if (!network_driver)
- return;
-
- virNetworkObjListForEach(network_driver->networks,
- networkAutostartConfig,
- network_driver);
-}
-
-
/**
* networkStateReload:
*
@@ -5616,7 +5603,6 @@ static virConnectDriver networkConnectDriver = {
static virStateDriver networkStateDriver = {
.name = "bridge",
.stateInitialize = networkStateInitialize,
- .stateAutoStart = networkStateAutoStart,
.stateCleanup = networkStateCleanup,
.stateReload = networkStateReload,
};
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 2da87992fd..056d324a62 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -911,6 +911,8 @@ qemuStateInitialize(bool privileged,
qemuProcessReconnectAll(qemu_driver);
+ qemuAutostartDomains(qemu_driver);
+
return 0;
error:
@@ -921,20 +923,6 @@ qemuStateInitialize(bool privileged,
return -1;
}
-/**
- * qemuStateAutoStart:
- *
- * Function to auto start the QEMU daemons
- */
-static void
-qemuStateAutoStart(void)
-{
- if (!qemu_driver)
- return;
-
- qemuAutostartDomains(qemu_driver);
-}
-
static void qemuNotifyLoadDomain(virDomainObjPtr vm, int newVM, void *opaque)
{
virQEMUDriverPtr driver = opaque;
@@ -21846,7 +21834,6 @@ static virConnectDriver qemuConnectDriver = {
static virStateDriver qemuStateDriver = {
.name = QEMU_DRIVER_NAME,
.stateInitialize = qemuStateInitialize,
- .stateAutoStart = qemuStateAutoStart,
.stateCleanup = qemuStateCleanup,
.stateReload = qemuStateReload,
.stateStop = qemuStateStop,
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index 254818e308..f61fb074e6 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -291,6 +291,8 @@ storageStateInitialize(bool privileged,
storagePoolUpdateAllState();
+ storageDriverAutostart();
+
driver->storageEventState = virObjectEventStateNew();
storageDriverUnlock();
@@ -307,22 +309,6 @@ storageStateInitialize(bool privileged,
goto cleanup;
}
-/**
- * storageStateAutoStart:
- *
- * Function to auto start the storage driver
- */
-static void
-storageStateAutoStart(void)
-{
- if (!driver)
- return;
-
- storageDriverLock();
- storageDriverAutostart();
- storageDriverUnlock();
-}
-
/**
* storageStateReload:
*
@@ -2843,7 +2829,6 @@ static virConnectDriver storageConnectDriver = {
static virStateDriver stateDriver = {
.name = "storage",
.stateInitialize = storageStateInitialize,
- .stateAutoStart = storageStateAutoStart,
.stateCleanup = storageStateCleanup,
.stateReload = storageStateReload,
};
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index c77988f01e..296adf55d1 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -575,6 +575,8 @@ umlStateInitialize(bool privileged,
umlDriverUnlock(uml_driver);
+ umlAutostartConfigs(uml_driver);
+
VIR_FREE(userdir);
return 0;
@@ -590,20 +592,6 @@ umlStateInitialize(bool privileged,
return -1;
}
-/**
- * umlStateAutoStart:
- *
- * Function to autostart the Uml daemons
- */
-static void
-umlStateAutoStart(void)
-{
- if (!uml_driver)
- return;
-
- umlAutostartConfigs(uml_driver);
-}
-
static void umlNotifyLoadDomain(virDomainObjPtr vm, int newVM, void *opaque)
{
struct uml_driver *driver = opaque;
@@ -2826,7 +2814,6 @@ static virConnectDriver umlConnectDriver = {
static virStateDriver umlStateDriver = {
.name = "UML",
.stateInitialize = umlStateInitialize,
- .stateAutoStart = umlStateAutoStart,
.stateCleanup = umlStateCleanup,
.stateReload = umlStateReload,
};
--
2.22.0

View File

@ -0,0 +1,83 @@
From ddea95c1c2e32c6454c89aa83d78b26a83564cd4 Mon Sep 17 00:00:00 2001
Message-Id: <ddea95c1c2e32c6454c89aa83d78b26a83564cd4@dist-git>
From: Pavel Hrdina <phrdina@redhat.com>
Date: Mon, 1 Jul 2019 17:07:11 +0200
Subject: [PATCH] Revert "vircgroup: cleanup controllers not managed by systemd
on error"
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This reverts commit 1602aa28f820ada66f707cef3e536e8572fbda1e.
There is no need to call virCgroupRemove() nor virCgroupFree() if
virCgroupEnableMissingControllers() fails because it will not modify
'group' at all.
The cleanup of directories is done in virCgroupMakeGroup().
Reviewed-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
(cherry picked from commit 199eee6aae7af3d813fbe98660c7e0fa1a8ae7b7)
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1689297
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Message-Id: <53288dd310e0305ac3179693e64684eb8b3a31ab.1561993100.git.phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/util/vircgroup.c | 25 ++++++++++---------------
1 file changed, 10 insertions(+), 15 deletions(-)
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index a376b9b89a..7ec1399bc6 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -1059,7 +1059,6 @@ virCgroupNewMachineSystemd(const char *name,
int rv;
virCgroupPtr init;
VIR_AUTOFREE(char *) path = NULL;
- virErrorPtr saved = NULL;
VIR_DEBUG("Trying to setup machine '%s' via systemd", name);
if ((rv = virSystemdCreateMachine(name,
@@ -1092,24 +1091,20 @@ virCgroupNewMachineSystemd(const char *name,
if (virCgroupEnableMissingControllers(path, pidleader,
controllers, group) < 0) {
- goto error;
+ return -1;
}
- if (virCgroupAddProcess(*group, pidleader) < 0)
- goto error;
+ if (virCgroupAddProcess(*group, pidleader) < 0) {
+ virErrorPtr saved = virSaveLastError();
+ virCgroupRemove(*group);
+ virCgroupFree(group);
+ if (saved) {
+ virSetError(saved);
+ virFreeError(saved);
+ }
+ }
return 0;
-
- error:
- saved = virSaveLastError();
- virCgroupRemove(*group);
- virCgroupFree(group);
- if (saved) {
- virSetError(saved);
- virFreeError(saved);
- }
-
- return -1;
}
--
2.22.0

View File

@ -0,0 +1,61 @@
From 3eaa16967f0546c5d1596bb6c36767cbe01040b9 Mon Sep 17 00:00:00 2001
Message-Id: <3eaa16967f0546c5d1596bb6c36767cbe01040b9@dist-git>
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= <berrange@redhat.com>
Date: Wed, 15 May 2019 21:40:56 +0100
Subject: [PATCH] admin: reject clients unless their UID matches the current
UID
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The admin protocol RPC messages are only intended for use by the user
running the daemon. As such they should not be allowed for any client
UID that does not match the server UID.
Fixes CVE-2019-10132
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
(cherry picked from commit 96f41cd765c9e525fe28ee5abbfbf4a79b3720c7)
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <20190515204058.28077-2-berrange@redhat.com>
---
src/admin/admin_server_dispatch.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/src/admin/admin_server_dispatch.c b/src/admin/admin_server_dispatch.c
index b78ff902c0..9f25813ae3 100644
--- a/src/admin/admin_server_dispatch.c
+++ b/src/admin/admin_server_dispatch.c
@@ -66,6 +66,28 @@ remoteAdmClientNew(virNetServerClientPtr client ATTRIBUTE_UNUSED,
void *opaque)
{
struct daemonAdmClientPrivate *priv;
+ uid_t clientuid;
+ gid_t clientgid;
+ pid_t clientpid;
+ unsigned long long timestamp;
+
+ if (virNetServerClientGetUNIXIdentity(client,
+ &clientuid,
+ &clientgid,
+ &clientpid,
+ &timestamp) < 0)
+ return NULL;
+
+ VIR_DEBUG("New client pid %lld uid %lld",
+ (long long)clientpid,
+ (long long)clientuid);
+
+ if (geteuid() != clientuid) {
+ virReportRestrictedError(_("Disallowing client %lld with uid %lld"),
+ (long long)clientpid,
+ (long long)clientuid);
+ return NULL;
+ }
if (VIR_ALLOC(priv) < 0)
return NULL;
--
2.22.0

View File

@ -0,0 +1,46 @@
From bab30af2d83e27d9141545cb9dcff51924e52b4d Mon Sep 17 00:00:00 2001
Message-Id: <bab30af2d83e27d9141545cb9dcff51924e52b4d@dist-git>
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
Date: Tue, 18 Jun 2019 13:30:02 +0200
Subject: [PATCH] api: disallow virConnect*HypervisorCPU on read-only
connections
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
These APIs can be used to execute arbitrary emulators.
Forbid them on read-only connections.
Fixes: CVE-2019-10168
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Message-Id: <470651092e7d6a4ba5875cf8885fd3714d5ea189.1560857354.git.jtomko@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
---
src/libvirt-host.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/libvirt-host.c b/src/libvirt-host.c
index e20d6ee250..2978825d22 100644
--- a/src/libvirt-host.c
+++ b/src/libvirt-host.c
@@ -1041,6 +1041,7 @@ virConnectCompareHypervisorCPU(virConnectPtr conn,
virCheckConnectReturn(conn, VIR_CPU_COMPARE_ERROR);
virCheckNonNullArgGoto(xmlCPU, error);
+ virCheckReadOnlyGoto(conn->flags, error);
if (conn->driver->connectCompareHypervisorCPU) {
int ret;
@@ -1234,6 +1235,7 @@ virConnectBaselineHypervisorCPU(virConnectPtr conn,
virCheckConnectReturn(conn, NULL);
virCheckNonNullArgGoto(xmlCPUs, error);
+ virCheckReadOnlyGoto(conn->flags, error);
if (conn->driver->connectBaselineHypervisorCPU) {
char *cpu;
--
2.22.0

View File

@ -0,0 +1,38 @@
From 2b0e20b240848c84932aa549e8ec2b6e0a5646fa Mon Sep 17 00:00:00 2001
Message-Id: <2b0e20b240848c84932aa549e8ec2b6e0a5646fa@dist-git>
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
Date: Tue, 18 Jun 2019 13:30:01 +0200
Subject: [PATCH] api: disallow virConnectGetDomainCapabilities on read-only
connections
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This API can be used to execute arbitrary emulators.
Forbid it on read-only connections.
Fixes: CVE-2019-10167
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Message-Id: <eeefd7cf2afba696bed78582e086bfbd3ed23e00.1560857354.git.jtomko@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
---
src/libvirt-domain.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index 3855dfe0dd..a1c913bd86 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -11279,6 +11279,7 @@ virConnectGetDomainCapabilities(virConnectPtr conn,
virResetLastError();
virCheckConnectReturn(conn, NULL);
+ virCheckReadOnlyGoto(conn->flags, error);
if (conn->driver->connectGetDomainCapabilities) {
char *ret;
--
2.22.0

View File

@ -0,0 +1,40 @@
From 0673d5b707d68562732b78c89fe339e8558f8496 Mon Sep 17 00:00:00 2001
Message-Id: <0673d5b707d68562732b78c89fe339e8558f8496@dist-git>
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
Date: Tue, 18 Jun 2019 13:30:00 +0200
Subject: [PATCH] api: disallow virDomainManagedSaveDefineXML on read-only
connections
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The virDomainManagedSaveDefineXML can be used to alter the domain's
config used for managedsave or even execute arbitrary emulator binaries.
Forbid it on read-only connections.
Fixes: CVE-2019-10166
Reported-by: Matthias Gerstner <mgerstner@suse.de>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Message-Id: <352bf5e963a6482d426f97b0ef36ca019e69280b.1560857354.git.jtomko@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
---
src/libvirt-domain.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index 0ba85b9360..3855dfe0dd 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -9487,6 +9487,7 @@ virDomainManagedSaveDefineXML(virDomainPtr domain, const char *dxml,
virCheckDomainReturn(domain, -1);
conn = domain->conn;
+ virCheckReadOnlyGoto(conn->flags, error);
if (conn->driver->domainManagedSaveDefineXML) {
int ret;
--
2.22.0

View File

@ -0,0 +1,98 @@
From 8533d820c378ae31176922703b7368f586a59bc0 Mon Sep 17 00:00:00 2001
Message-Id: <8533d820c378ae31176922703b7368f586a59bc0@dist-git>
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
Date: Tue, 18 Jun 2019 13:29:59 +0200
Subject: [PATCH] api: disallow virDomainSaveImageGetXMLDesc on read-only
connections
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The virDomainSaveImageGetXMLDesc API is taking a path parameter,
which can point to any path on the system. This file will then be
read and parsed by libvirtd running with root privileges.
Forbid it on read-only connections.
Fixes: CVE-2019-10161
Reported-by: Matthias Gerstner <mgerstner@suse.de>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Conflicts:
src/libvirt-domain.c
src/remote/remote_protocol.x
Upstream commit 12a51f372 which introduced the VIR_DOMAIN_SAVE_IMAGE_XML_SECURE
alias for VIR_DOMAIN_XML_SECURE is not backported.
Just skip the commit since we now disallow the whole API on read-only
connections, regardless of the flag.
Message-Id: <4c14d609cd7b548459b9ef2f59728fa5c5e38268.1560857354.git.jtomko@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
---
src/libvirt-domain.c | 11 ++---------
src/qemu/qemu_driver.c | 2 +-
src/remote/remote_protocol.x | 3 +--
3 files changed, 4 insertions(+), 12 deletions(-)
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index ad0ded9ee3..0ba85b9360 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -1073,9 +1073,7 @@ virDomainRestoreFlags(virConnectPtr conn, const char *from, const char *dxml,
* previously by virDomainSave() or virDomainSaveFlags().
*
* No security-sensitive data will be included unless @flags contains
- * VIR_DOMAIN_XML_SECURE; this flag is rejected on read-only
- * connections. For this API, @flags should not contain either
- * VIR_DOMAIN_XML_INACTIVE or VIR_DOMAIN_XML_UPDATE_CPU.
+ * VIR_DOMAIN_XML_SECURE.
*
* Returns a 0 terminated UTF-8 encoded XML instance, or NULL in case of
* error. The caller must free() the returned value.
@@ -1091,12 +1089,7 @@ virDomainSaveImageGetXMLDesc(virConnectPtr conn, const char *file,
virCheckConnectReturn(conn, NULL);
virCheckNonNullArgGoto(file, error);
-
- if ((conn->flags & VIR_CONNECT_RO) && (flags & VIR_DOMAIN_XML_SECURE)) {
- virReportError(VIR_ERR_OPERATION_DENIED, "%s",
- _("virDomainSaveImageGetXMLDesc with secure flag"));
- goto error;
- }
+ virCheckReadOnlyGoto(conn->flags, error);
if (conn->driver->domainSaveImageGetXMLDesc) {
char *ret;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 88c08f88ee..2da87992fd 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6786,7 +6786,7 @@ qemuDomainSaveImageGetXMLDesc(virConnectPtr conn, const char *path,
if (fd < 0)
goto cleanup;
- if (virDomainSaveImageGetXMLDescEnsureACL(conn, def, flags) < 0)
+ if (virDomainSaveImageGetXMLDescEnsureACL(conn, def) < 0)
goto cleanup;
ret = qemuDomainDefFormatXML(driver, def, flags);
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 28c8febabd..52b92334fa 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -5226,8 +5226,7 @@ enum remote_procedure {
/**
* @generate: both
* @priority: high
- * @acl: domain:read
- * @acl: domain:read_secure:VIR_DOMAIN_XML_SECURE
+ * @acl: domain:write
*/
REMOTE_PROC_DOMAIN_SAVE_IMAGE_GET_XML_DESC = 235,
--
2.22.0

View File

@ -0,0 +1,65 @@
From a26ad1b57617abc4de8a0d13716b898d311ee01e Mon Sep 17 00:00:00 2001
Message-Id: <a26ad1b57617abc4de8a0d13716b898d311ee01e@dist-git>
From: Michal Privoznik <mprivozn@redhat.com>
Date: Thu, 27 Jun 2019 15:18:15 +0200
Subject: [PATCH] bhyve: Move autostarting of domains into bhyveStateInitialize
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The stateAutoStart callback will go away shortly. Therefore, move
the autostart call into state initialize callback.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 31c3c35c940010a793fea8351751bb04fab1a6d4)
https://bugzilla.redhat.com/show_bug.cgi?id=1685151
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Message-Id: <1a93e2bef531c11190c652fcfb73b568ee73e487.1561641375.git.mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
---
src/bhyve/bhyve_driver.c | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)
diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index 9284b51783..ec016ecc0c 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -1270,6 +1270,8 @@ bhyveStateInitialize(bool privileged,
virBhyveProcessReconnectAll(bhyve_driver);
+ bhyveAutostartDomains(bhyve_driver);
+
return 0;
cleanup:
@@ -1297,15 +1299,6 @@ bhyveDriverGetGrubCaps(virConnectPtr conn)
return 0;
}
-static void
-bhyveStateAutoStart(void)
-{
- if (!bhyve_driver)
- return;
-
- bhyveAutostartDomains(bhyve_driver);
-}
-
static int
bhyveConnectGetMaxVcpus(virConnectPtr conn,
const char *type)
@@ -1713,7 +1706,6 @@ static virConnectDriver bhyveConnectDriver = {
static virStateDriver bhyveStateDriver = {
.name = "bhyve",
.stateInitialize = bhyveStateInitialize,
- .stateAutoStart = bhyveStateAutoStart,
.stateCleanup = bhyveStateCleanup,
};
--
2.22.0

View File

@ -0,0 +1,67 @@
From dd083516c7057ee50e59290643634156daf0773b Mon Sep 17 00:00:00 2001
Message-Id: <dd083516c7057ee50e59290643634156daf0773b@dist-git>
From: Yi Min Zhao <zyimin@linux.ibm.com>
Date: Mon, 8 Apr 2019 10:57:18 +0200
Subject: [PATCH] conf: Add definitions for 'uid' and 'fid' PCI address
attributes
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Add zPCI definitions in preparation of extending the PCI address
with parameters uid (user-defined identifier) and fid (PCI function
identifier).
Signed-off-by: Yi Min Zhao <zyimin@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
(cherry-picked from commit 30522c78c11d9ff6c6c177dfca4a0da8057095fe)
https://bugzilla.redhat.com/show_bug.cgi?id=1508149
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Message-Id: <20190408085732.28684-2-abologna@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
cfg.mk | 1 +
src/util/virpci.h | 7 +++++++
2 files changed, 8 insertions(+)
diff --git a/cfg.mk b/cfg.mk
index e3e94bf6f0..7fd2b1dcb6 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -472,6 +472,7 @@ sc_prohibit_canonicalize_file_name:
# Insist on correct types for [pug]id.
sc_correct_id_types:
@prohibit='\<(int|long) *[pug]id\>' \
+ exclude='exempt from syntax-check' \
halt='use pid_t for pid, uid_t for uid, gid_t for gid' \
$(_sc_search_regexp)
diff --git a/src/util/virpci.h b/src/util/virpci.h
index 794b7e59db..01df652b86 100644
--- a/src/util/virpci.h
+++ b/src/util/virpci.h
@@ -36,6 +36,13 @@ typedef virPCIDeviceAddress *virPCIDeviceAddressPtr;
typedef struct _virPCIDeviceList virPCIDeviceList;
typedef virPCIDeviceList *virPCIDeviceListPtr;
+typedef struct _virZPCIDeviceAddress virZPCIDeviceAddress;
+typedef virZPCIDeviceAddress *virZPCIDeviceAddressPtr;
+struct _virZPCIDeviceAddress {
+ unsigned int uid; /* exempt from syntax-check */
+ unsigned int fid;
+};
+
struct _virPCIDeviceAddress {
unsigned int domain;
unsigned int bus;
--
2.22.0

View File

@ -0,0 +1,527 @@
From 87e3a5f2f797c79516a560ddc224074c834ef528 Mon Sep 17 00:00:00 2001
Message-Id: <87e3a5f2f797c79516a560ddc224074c834ef528@dist-git>
From: Yi Min Zhao <zyimin@linux.ibm.com>
Date: Mon, 8 Apr 2019 10:57:27 +0200
Subject: [PATCH] conf: Allocate/release 'uid' and 'fid' in PCI address
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This patch adds new functions for reservation, assignment and release
to handle the uid/fid. If the uid/fid is defined in the domain XML,
they will be reserved directly in the collecting phase. If any of them
is not defined, we will find out an available value for them from the
zPCI address hashtable, and reserve them. For the hotplug case there
might not be a zPCI definition. So allocate and reserve uid/fid the
case. Assign if needed and reserve uid/fid for the defined case.
Signed-off-by: Yi Min Zhao <zyimin@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
(cherry picked from commit f183b87fc1dbcc6446ac3c1cef9cdd345b9725fb)
https://bugzilla.redhat.com/show_bug.cgi?id=1508149
Conflicts:
* src/libvirt_private.syms
+ several symbols are not present in the list
- missing 9ad119f4db5, ab3f781a10c, edeef779585, b899726faa5
* src/qemu/qemu_domain_address.c
+ the old name for virDeviceInfoPCIAddressIsPresent() is used
- missing 76151a53a100
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Message-Id: <20190408085732.28684-11-abologna@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/conf/device_conf.c | 16 +++
src/conf/device_conf.h | 3 +
src/conf/domain_addr.c | 244 +++++++++++++++++++++++++++++++++
src/conf/domain_addr.h | 12 ++
src/libvirt_private.syms | 5 +
src/qemu/qemu_domain_address.c | 59 +++++++-
6 files changed, 338 insertions(+), 1 deletion(-)
diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c
index cadac32603..76370d30a2 100644
--- a/src/conf/device_conf.c
+++ b/src/conf/device_conf.c
@@ -28,6 +28,7 @@
#include "viruuid.h"
#include "virbuffer.h"
#include "device_conf.h"
+#include "domain_addr.h"
#include "virstring.h"
#define VIR_FROM_THIS VIR_FROM_DEVICE
@@ -230,6 +231,21 @@ int virPCIDeviceAddressIsValid(virPCIDeviceAddressPtr addr,
}
+bool
+virDeviceInfoPCIAddressExtensionIsWanted(const virDomainDeviceInfo *info)
+{
+ return (info->addr.pci.extFlags & VIR_PCI_ADDRESS_EXTENSION_ZPCI) &&
+ virZPCIDeviceAddressIsEmpty(&info->addr.pci.zpci);
+}
+
+bool
+virDeviceInfoPCIAddressExtensionIsPresent(const virDomainDeviceInfo *info)
+{
+ return (info->addr.pci.extFlags & VIR_PCI_ADDRESS_EXTENSION_ZPCI) &&
+ !virZPCIDeviceAddressIsEmpty(&info->addr.pci.zpci);
+}
+
+
int
virPCIDeviceAddressParseXML(xmlNodePtr node,
virPCIDeviceAddressPtr addr)
diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h
index c79066ec02..6bef2f093a 100644
--- a/src/conf/device_conf.h
+++ b/src/conf/device_conf.h
@@ -214,6 +214,9 @@ virDeviceInfoPCIAddressPresent(const virDomainDeviceInfo *info)
!virPCIDeviceAddressIsEmpty(&info->addr.pci);
}
+bool virDeviceInfoPCIAddressExtensionIsWanted(const virDomainDeviceInfo *info);
+bool virDeviceInfoPCIAddressExtensionIsPresent(const virDomainDeviceInfo *info);
+
int virPCIDeviceAddressParseXML(xmlNodePtr node,
virPCIDeviceAddressPtr addr);
diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
index 9e0a0fdf95..a58910c394 100644
--- a/src/conf/domain_addr.c
+++ b/src/conf/domain_addr.c
@@ -33,6 +33,238 @@
VIR_LOG_INIT("conf.domain_addr");
+static int
+virDomainZPCIAddressReserveId(virHashTablePtr set,
+ unsigned int id,
+ const char *name)
+{
+ if (virHashLookup(set, &id)) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("zPCI %s %o is already reserved"),
+ name, id);
+ return -1;
+ }
+
+ if (virHashAddEntry(set, &id, (void*)1) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to reserve %s %o"),
+ name, id);
+ return -1;
+ }
+
+ return 0;
+}
+
+
+static int
+virDomainZPCIAddressReserveUid(virHashTablePtr set,
+ virZPCIDeviceAddressPtr addr)
+{
+ return virDomainZPCIAddressReserveId(set, addr->uid, "uid");
+}
+
+
+static int
+virDomainZPCIAddressReserveFid(virHashTablePtr set,
+ virZPCIDeviceAddressPtr addr)
+{
+ return virDomainZPCIAddressReserveId(set, addr->fid, "fid");
+}
+
+
+static int
+virDomainZPCIAddressAssignId(virHashTablePtr set,
+ unsigned int *id,
+ unsigned int min,
+ unsigned int max,
+ const char *name)
+{
+ while (virHashLookup(set, &min)) {
+ if (min == max) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("There is no more free %s."),
+ name);
+ return -1;
+ }
+ ++min;
+ }
+ *id = min;
+
+ return 0;
+}
+
+
+static int
+virDomainZPCIAddressAssignUid(virHashTablePtr set,
+ virZPCIDeviceAddressPtr addr)
+{
+ return virDomainZPCIAddressAssignId(set, &addr->uid, 1,
+ VIR_DOMAIN_DEVICE_ZPCI_MAX_UID, "uid");
+}
+
+
+static int
+virDomainZPCIAddressAssignFid(virHashTablePtr set,
+ virZPCIDeviceAddressPtr addr)
+{
+ return virDomainZPCIAddressAssignId(set, &addr->fid, 0,
+ VIR_DOMAIN_DEVICE_ZPCI_MAX_FID, "fid");
+}
+
+
+static void
+virDomainZPCIAddressReleaseId(virHashTablePtr set,
+ unsigned int *id,
+ const char *name)
+{
+ if (virHashRemoveEntry(set, id) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Release %s %o failed"),
+ name, *id);
+ }
+
+ *id = 0;
+}
+
+
+static void
+virDomainZPCIAddressReleaseUid(virHashTablePtr set,
+ virZPCIDeviceAddressPtr addr)
+{
+ virDomainZPCIAddressReleaseId(set, &addr->uid, "uid");
+}
+
+
+static void
+virDomainZPCIAddressReleaseFid(virHashTablePtr set,
+ virZPCIDeviceAddressPtr addr)
+{
+ virDomainZPCIAddressReleaseId(set, &addr->fid, "fid");
+}
+
+
+static void
+virDomainZPCIAddressReleaseIds(virDomainZPCIAddressIdsPtr zpciIds,
+ virZPCIDeviceAddressPtr addr)
+{
+ if (!zpciIds || virZPCIDeviceAddressIsEmpty(addr))
+ return;
+
+ virDomainZPCIAddressReleaseUid(zpciIds->uids, addr);
+
+ virDomainZPCIAddressReleaseFid(zpciIds->fids, addr);
+}
+
+
+static int
+virDomainZPCIAddressReserveNextUid(virHashTablePtr uids,
+ virZPCIDeviceAddressPtr zpci)
+{
+ if (virDomainZPCIAddressAssignUid(uids, zpci) < 0)
+ return -1;
+
+ if (virDomainZPCIAddressReserveUid(uids, zpci) < 0)
+ return -1;
+
+ return 0;
+}
+
+
+static int
+virDomainZPCIAddressReserveNextFid(virHashTablePtr fids,
+ virZPCIDeviceAddressPtr zpci)
+{
+ if (virDomainZPCIAddressAssignFid(fids, zpci) < 0)
+ return -1;
+
+ if (virDomainZPCIAddressReserveFid(fids, zpci) < 0)
+ return -1;
+
+ return 0;
+}
+
+
+static int
+virDomainZPCIAddressReserveAddr(virDomainZPCIAddressIdsPtr zpciIds,
+ virZPCIDeviceAddressPtr addr)
+{
+ if (virDomainZPCIAddressReserveUid(zpciIds->uids, addr) < 0)
+ return -1;
+
+ if (virDomainZPCIAddressReserveFid(zpciIds->fids, addr) < 0) {
+ virDomainZPCIAddressReleaseUid(zpciIds->uids, addr);
+ return -1;
+ }
+
+ return 0;
+}
+
+
+static int
+virDomainZPCIAddressReserveNextAddr(virDomainZPCIAddressIdsPtr zpciIds,
+ virZPCIDeviceAddressPtr addr)
+{
+ if (virDomainZPCIAddressReserveNextUid(zpciIds->uids, addr) < 0)
+ return -1;
+
+ if (virDomainZPCIAddressReserveNextFid(zpciIds->fids, addr) < 0) {
+ virDomainZPCIAddressReleaseUid(zpciIds->uids, addr);
+ return -1;
+ }
+
+ return 0;
+}
+
+
+int
+virDomainPCIAddressExtensionReserveAddr(virDomainPCIAddressSetPtr addrs,
+ virPCIDeviceAddressPtr addr)
+{
+ if (addr->extFlags & VIR_PCI_ADDRESS_EXTENSION_ZPCI) {
+ /* Reserve uid/fid to ZPCI device which has defined uid/fid
+ * in the domain.
+ */
+ return virDomainZPCIAddressReserveAddr(addrs->zpciIds, &addr->zpci);
+ }
+
+ return 0;
+}
+
+
+int
+virDomainPCIAddressExtensionReserveNextAddr(virDomainPCIAddressSetPtr addrs,
+ virPCIDeviceAddressPtr addr)
+{
+ if (addr->extFlags & VIR_PCI_ADDRESS_EXTENSION_ZPCI) {
+ virZPCIDeviceAddress zpci = { 0 };
+
+ if (virDomainZPCIAddressReserveNextAddr(addrs->zpciIds, &zpci) < 0)
+ return -1;
+
+ if (!addrs->dryRun)
+ addr->zpci = zpci;
+ }
+
+ return 0;
+}
+
+static int
+virDomainPCIAddressExtensionEnsureAddr(virDomainPCIAddressSetPtr addrs,
+ virPCIDeviceAddressPtr addr)
+{
+ if (addr->extFlags & VIR_PCI_ADDRESS_EXTENSION_ZPCI) {
+ virZPCIDeviceAddressPtr zpci = &addr->zpci;
+
+ if (virZPCIDeviceAddressIsEmpty(zpci))
+ return virDomainZPCIAddressReserveNextAddr(addrs->zpciIds, zpci);
+ else
+ return virDomainZPCIAddressReserveAddr(addrs->zpciIds, zpci);
+ }
+
+ return 0;
+}
+
+
virDomainPCIConnectFlags
virDomainPCIControllerModelToConnectType(virDomainControllerModelPCI model)
{
@@ -729,12 +961,24 @@ virDomainPCIAddressEnsureAddr(virDomainPCIAddressSetPtr addrs,
ret = virDomainPCIAddressReserveNextAddr(addrs, dev, flags, -1);
}
+ dev->addr.pci.extFlags = dev->pciAddrExtFlags;
+ ret = virDomainPCIAddressExtensionEnsureAddr(addrs, &dev->addr.pci);
+
cleanup:
VIR_FREE(addrStr);
return ret;
}
+void
+virDomainPCIAddressExtensionReleaseAddr(virDomainPCIAddressSetPtr addrs,
+ virPCIDeviceAddressPtr addr)
+{
+ if (addr->extFlags & VIR_PCI_ADDRESS_EXTENSION_ZPCI)
+ virDomainZPCIAddressReleaseIds(addrs->zpciIds, &addr->zpci);
+}
+
+
void
virDomainPCIAddressReleaseAddr(virDomainPCIAddressSetPtr addrs,
virPCIDeviceAddressPtr addr)
diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h
index b01e6b9d20..e5ce4868d5 100644
--- a/src/conf/domain_addr.h
+++ b/src/conf/domain_addr.h
@@ -166,6 +166,14 @@ bool virDomainPCIAddressSlotInUse(virDomainPCIAddressSetPtr addrs,
virPCIDeviceAddressPtr addr)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
+int virDomainPCIAddressExtensionReserveAddr(virDomainPCIAddressSetPtr addrs,
+ virPCIDeviceAddressPtr addr)
+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
+
+int virDomainPCIAddressExtensionReserveNextAddr(virDomainPCIAddressSetPtr addrs,
+ virPCIDeviceAddressPtr addr)
+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
+
int virDomainPCIAddressReserveAddr(virDomainPCIAddressSetPtr addrs,
virPCIDeviceAddressPtr addr,
virDomainPCIConnectFlags flags,
@@ -187,6 +195,10 @@ void virDomainPCIAddressReleaseAddr(virDomainPCIAddressSetPtr addrs,
virPCIDeviceAddressPtr addr)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
+void virDomainPCIAddressExtensionReleaseAddr(virDomainPCIAddressSetPtr addrs,
+ virPCIDeviceAddressPtr addr)
+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
+
void virDomainPCIAddressSetAllMulti(virDomainDefPtr def)
ATTRIBUTE_NONNULL(1);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index b2a2a1f265..ee7625b0f3 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -93,6 +93,8 @@ virCPUModeTypeToString;
# conf/device_conf.h
+virDeviceInfoPCIAddressExtensionIsPresent;
+virDeviceInfoPCIAddressExtensionIsWanted;
virDomainDeviceInfoAddressIsEqual;
virDomainDeviceInfoCopy;
virInterfaceLinkFormat;
@@ -114,6 +116,9 @@ virDomainPCIAddressAsString;
virDomainPCIAddressBusIsFullyReserved;
virDomainPCIAddressBusSetModel;
virDomainPCIAddressEnsureAddr;
+virDomainPCIAddressExtensionReleaseAddr;
+virDomainPCIAddressExtensionReserveAddr;
+virDomainPCIAddressExtensionReserveNextAddr;
virDomainPCIAddressReleaseAddr;
virDomainPCIAddressReserveAddr;
virDomainPCIAddressReserveNextAddr;
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index ba870d56b1..8338241cba 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -1405,6 +1405,24 @@ qemuDomainPCIAddressReserveNextAddr(virDomainPCIAddressSetPtr addrs,
}
+static int
+qemuDomainAssignPCIAddressExtension(virDomainDefPtr def ATTRIBUTE_UNUSED,
+ virDomainDeviceDefPtr device ATTRIBUTE_UNUSED,
+ virDomainDeviceInfoPtr info,
+ void *opaque)
+{
+ virDomainPCIAddressSetPtr addrs = opaque;
+ virPCIDeviceAddressPtr addr = &info->addr.pci;
+
+ if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI)
+ addr->extFlags = info->pciAddrExtFlags;
+
+ if (virDeviceInfoPCIAddressExtensionIsWanted(info))
+ return virDomainPCIAddressExtensionReserveNextAddr(addrs, addr);
+
+ return 0;
+}
+
static int
qemuDomainCollectPCIAddress(virDomainDefPtr def ATTRIBUTE_UNUSED,
virDomainDeviceDefPtr device,
@@ -1498,6 +1516,31 @@ qemuDomainCollectPCIAddress(virDomainDefPtr def ATTRIBUTE_UNUSED,
return ret;
}
+static int
+qemuDomainCollectPCIAddressExtension(virDomainDefPtr def ATTRIBUTE_UNUSED,
+ virDomainDeviceDefPtr device,
+ virDomainDeviceInfoPtr info,
+ void *opaque)
+{
+ virDomainPCIAddressSetPtr addrs = opaque;
+ virPCIDeviceAddressPtr addr = &info->addr.pci;
+
+ if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI)
+ addr->extFlags = info->pciAddrExtFlags;
+
+ if (!virDeviceInfoPCIAddressExtensionIsPresent(info) ||
+ ((device->type == VIR_DOMAIN_DEVICE_HOSTDEV) &&
+ (device->data.hostdev->parent.type != VIR_DOMAIN_DEVICE_NONE))) {
+ /* If a hostdev has a parent, its info will be a part of the
+ * parent, and will have its address collected during the scan
+ * of the parent's device type.
+ */
+ return 0;
+ }
+
+ return virDomainPCIAddressExtensionReserveAddr(addrs, addr);
+}
+
static virDomainPCIAddressSetPtr
qemuDomainPCIAddressSetCreate(virDomainDefPtr def,
virQEMUCapsPtr qemuCaps,
@@ -1589,6 +1632,12 @@ qemuDomainPCIAddressSetCreate(virDomainDefPtr def,
if (virDomainDeviceInfoIterate(def, qemuDomainCollectPCIAddress, addrs) < 0)
goto error;
+ if (virDomainDeviceInfoIterate(def,
+ qemuDomainCollectPCIAddressExtension,
+ addrs) < 0) {
+ goto error;
+ }
+
return addrs;
error:
@@ -2590,6 +2639,9 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
if (qemuDomainAssignDevicePCISlots(def, qemuCaps, addrs) < 0)
goto cleanup;
+ if (virDomainDeviceInfoIterate(def, qemuDomainAssignPCIAddressExtension, addrs) < 0)
+ goto cleanup;
+
/* Only for *new* domains with pcie-root (and no other
* manually specified PCI controllers in the definition): If,
* after assigning addresses/reserving slots for all devices,
@@ -2684,6 +2736,9 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
if (qemuDomainAssignDevicePCISlots(def, qemuCaps, addrs) < 0)
goto cleanup;
+ if (virDomainDeviceInfoIterate(def, qemuDomainAssignPCIAddressExtension, addrs) < 0)
+ goto cleanup;
+
/* set multi attribute for devices at function 0 of
* any slot that has multiple functions in use
*/
@@ -3143,8 +3198,10 @@ qemuDomainReleaseDeviceAddress(virDomainObjPtr vm,
if (!devstr)
devstr = info->alias;
- if (virDeviceInfoPCIAddressPresent(info))
+ if (virDeviceInfoPCIAddressPresent(info)) {
virDomainPCIAddressReleaseAddr(priv->pciaddrs, &info->addr.pci);
+ virDomainPCIAddressExtensionReleaseAddr(priv->pciaddrs, &info->addr.pci);
+ }
if (virDomainUSBAddressRelease(priv->usbaddrs, info) < 0)
VIR_WARN("Unable to release USB address on %s", NULLSTR(devstr));
--
2.22.0

View File

@ -0,0 +1,241 @@
From 7888472ef1d57d992995a16dc7c9ba0fe18562a8 Mon Sep 17 00:00:00 2001
Message-Id: <7888472ef1d57d992995a16dc7c9ba0fe18562a8@dist-git>
From: Yi Min Zhao <zyimin@linux.ibm.com>
Date: Mon, 8 Apr 2019 10:57:22 +0200
Subject: [PATCH] conf: Introduce address caching for PCI extensions
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This patch provides a caching mechanism for the device address
extensions uid and fid on S390. For efficient sparse address allocation,
we introduce two hash tables for uid/fid which hold the address set
information per domain. Also in order to improve performance of
searching available value, we introduce our own callbacks for the two
hashtables. In this way, uid/fid is saved in hash key and hash value
could be any non-NULL pointer due to no operation on hash value. That is
also the reason why we don't introduce hash value free callback.
Signed-off-by: Yi Min Zhao <zyimin@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
(cherry picked from commit 28831e1f1ec001882e907f03f7618f7c00ebc98d)
https://bugzilla.redhat.com/show_bug.cgi?id=1508149
Conflicts:
* src/conf/domain_addr.h
+ context
- missing b72183223f3b
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Message-Id: <20190408085732.28684-6-abologna@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/bhyve/bhyve_device.c | 3 +-
src/conf/domain_addr.c | 93 +++++++++++++++++++++++++++++++++-
src/conf/domain_addr.h | 10 +++-
src/qemu/qemu_domain_address.c | 6 ++-
4 files changed, 108 insertions(+), 4 deletions(-)
diff --git a/src/bhyve/bhyve_device.c b/src/bhyve/bhyve_device.c
index 03aa6c93bd..8f0862b0b6 100644
--- a/src/bhyve/bhyve_device.c
+++ b/src/bhyve/bhyve_device.c
@@ -71,7 +71,8 @@ bhyveDomainPCIAddressSetCreate(virDomainDefPtr def, unsigned int nbuses)
{
virDomainPCIAddressSetPtr addrs;
- if ((addrs = virDomainPCIAddressSetAlloc(nbuses)) == NULL)
+ if ((addrs = virDomainPCIAddressSetAlloc(nbuses,
+ VIR_PCI_ADDRESS_EXTENSION_NONE)) == NULL)
return NULL;
if (virDomainPCIAddressBusSetModel(&addrs->buses[0],
diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
index 39f22b82eb..3e33549c3d 100644
--- a/src/conf/domain_addr.c
+++ b/src/conf/domain_addr.c
@@ -27,6 +27,7 @@
#include "virlog.h"
#include "virstring.h"
#include "domain_addr.h"
+#include "virhashcode.h"
#define VIR_FROM_THIS VIR_FROM_DOMAIN
@@ -741,8 +742,93 @@ virDomainPCIAddressReleaseAddr(virDomainPCIAddressSetPtr addrs,
addrs->buses[addr->bus].slot[addr->slot].functions &= ~(1 << addr->function);
}
+
+static uint32_t
+virZPCIAddrKeyCode(const void *name,
+ uint32_t seed)
+{
+ unsigned int value = *((unsigned int *)name);
+ return virHashCodeGen(&value, sizeof(value), seed);
+}
+
+
+static bool
+virZPCIAddrKeyEqual(const void *namea,
+ const void *nameb)
+{
+ return *((unsigned int *)namea) == *((unsigned int *)nameb);
+}
+
+
+static void *
+virZPCIAddrKeyCopy(const void *name)
+{
+ unsigned int *copy;
+
+ if (VIR_ALLOC(copy) < 0)
+ return NULL;
+
+ *copy = *((unsigned int *)name);
+ return (void *)copy;
+}
+
+
+static void
+virZPCIAddrKeyFree(void *name)
+{
+ VIR_FREE(name);
+}
+
+
+static void
+virDomainPCIAddressSetExtensionFree(virDomainPCIAddressSetPtr addrs)
+{
+ if (!addrs || !addrs->zpciIds)
+ return;
+
+ virHashFree(addrs->zpciIds->uids);
+ virHashFree(addrs->zpciIds->fids);
+ VIR_FREE(addrs->zpciIds);
+}
+
+
+static int
+virDomainPCIAddressSetExtensionAlloc(virDomainPCIAddressSetPtr addrs,
+ virPCIDeviceAddressExtensionFlags extFlags)
+{
+ if (extFlags & VIR_PCI_ADDRESS_EXTENSION_ZPCI) {
+ if (addrs->zpciIds)
+ return 0;
+
+ if (VIR_ALLOC(addrs->zpciIds) < 0)
+ return -1;
+
+ if (!(addrs->zpciIds->uids = virHashCreateFull(10, NULL,
+ virZPCIAddrKeyCode,
+ virZPCIAddrKeyEqual,
+ virZPCIAddrKeyCopy,
+ virZPCIAddrKeyFree)))
+ goto error;
+
+ if (!(addrs->zpciIds->fids = virHashCreateFull(10, NULL,
+ virZPCIAddrKeyCode,
+ virZPCIAddrKeyEqual,
+ virZPCIAddrKeyCopy,
+ virZPCIAddrKeyFree)))
+ goto error;
+ }
+
+ return 0;
+
+ error:
+ virDomainPCIAddressSetExtensionFree(addrs);
+ return -1;
+}
+
+
virDomainPCIAddressSetPtr
-virDomainPCIAddressSetAlloc(unsigned int nbuses)
+virDomainPCIAddressSetAlloc(unsigned int nbuses,
+ virPCIDeviceAddressExtensionFlags extFlags)
{
virDomainPCIAddressSetPtr addrs;
@@ -753,6 +839,10 @@ virDomainPCIAddressSetAlloc(unsigned int nbuses)
goto error;
addrs->nbuses = nbuses;
+
+ if (virDomainPCIAddressSetExtensionAlloc(addrs, extFlags) < 0)
+ goto error;
+
return addrs;
error:
@@ -767,6 +857,7 @@ virDomainPCIAddressSetFree(virDomainPCIAddressSetPtr addrs)
if (!addrs)
return;
+ virDomainPCIAddressSetExtensionFree(addrs);
VIR_FREE(addrs->buses);
VIR_FREE(addrs);
}
diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h
index fd06008e26..b01e6b9d20 100644
--- a/src/conf/domain_addr.h
+++ b/src/conf/domain_addr.h
@@ -116,6 +116,12 @@ typedef struct {
} virDomainPCIAddressBus;
typedef virDomainPCIAddressBus *virDomainPCIAddressBusPtr;
+typedef struct {
+ virHashTablePtr uids;
+ virHashTablePtr fids;
+} virDomainZPCIAddressIds;
+typedef virDomainZPCIAddressIds *virDomainZPCIAddressIdsPtr;
+
struct _virDomainPCIAddressSet {
virDomainPCIAddressBus *buses;
size_t nbuses;
@@ -125,6 +131,7 @@ struct _virDomainPCIAddressSet {
bool areMultipleRootsSupported;
/* If true, the guest can use the pcie-to-pci-bridge controller */
bool isPCIeToPCIBridgeSupported;
+ virDomainZPCIAddressIdsPtr zpciIds;
};
typedef struct _virDomainPCIAddressSet virDomainPCIAddressSet;
typedef virDomainPCIAddressSet *virDomainPCIAddressSetPtr;
@@ -132,7 +139,8 @@ typedef virDomainPCIAddressSet *virDomainPCIAddressSetPtr;
char *virDomainPCIAddressAsString(virPCIDeviceAddressPtr addr)
ATTRIBUTE_NONNULL(1);
-virDomainPCIAddressSetPtr virDomainPCIAddressSetAlloc(unsigned int nbuses);
+virDomainPCIAddressSetPtr virDomainPCIAddressSetAlloc(unsigned int nbuses,
+ virPCIDeviceAddressExtensionFlags extFlags);
void virDomainPCIAddressSetFree(virDomainPCIAddressSetPtr addrs);
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index 3d01d14b46..ba870d56b1 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -1508,8 +1508,12 @@ qemuDomainPCIAddressSetCreate(virDomainDefPtr def,
size_t i;
bool hasPCIeRoot = false;
virDomainControllerModelPCI defaultModel;
+ virPCIDeviceAddressExtensionFlags extFlags = VIR_PCI_ADDRESS_EXTENSION_NONE;
- if ((addrs = virDomainPCIAddressSetAlloc(nbuses)) == NULL)
+ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_ZPCI))
+ extFlags |= VIR_PCI_ADDRESS_EXTENSION_ZPCI;
+
+ if ((addrs = virDomainPCIAddressSetAlloc(nbuses, extFlags)) == NULL)
return NULL;
addrs->dryRun = dryRun;
--
2.22.0

View File

@ -0,0 +1,283 @@
From 050eb598af9291f385998cb1127d5bdf83305501 Mon Sep 17 00:00:00 2001
Message-Id: <050eb598af9291f385998cb1127d5bdf83305501@dist-git>
From: Yi Min Zhao <zyimin@linux.ibm.com>
Date: Mon, 8 Apr 2019 10:57:21 +0200
Subject: [PATCH] conf: Introduce extension flag and zPCI member for PCI
address
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This patch introduces PCI address extension flag for virDomainDeviceInfo
and virPCIDeviceAddress. The extension flag in virDomainDeviceInfo is
used internally during calculating PCI extension flag. The one in
virPCIDeviceAddress is the duplicate to indicate extension address is
being used. Currently only zPCI extension address is introduced to deal
with 'uid' and 'fid' on the S390 platform.
Signed-off-by: Yi Min Zhao <zyimin@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
(cherry picked from commit 478e5f90fd4c0c0a8c1b3a8e19b9cae93ed78a4e)
https://bugzilla.redhat.com/show_bug.cgi?id=1508149
Conflicts:
* src/qemu/qemu_domain_address.c
+ context
- missing db98a426a640
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Message-Id: <20190408085732.28684-5-abologna@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/conf/device_conf.h | 4 +
src/conf/domain_addr.h | 5 ++
src/qemu/qemu_domain_address.c | 140 ++++++++++++++++++++++++++++++++-
src/util/virpci.h | 2 +
4 files changed, 149 insertions(+), 2 deletions(-)
diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h
index a31ce9c376..c79066ec02 100644
--- a/src/conf/device_conf.h
+++ b/src/conf/device_conf.h
@@ -164,6 +164,10 @@ struct _virDomainDeviceInfo {
* assignment, never saved and never reported.
*/
int pciConnectFlags; /* enum virDomainPCIConnectFlags */
+ /* pciAddrExtFlags is only used internally to calculate PCI
+ * address extension flags during address assignment.
+ */
+ int pciAddrExtFlags; /* enum virDomainPCIAddressExtensionFlags */
char *loadparm;
/* PCI devices will only be automatically placed on a PCI bus
diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h
index 3236b7d6de..fd06008e26 100644
--- a/src/conf/domain_addr.h
+++ b/src/conf/domain_addr.h
@@ -29,6 +29,11 @@
# define VIR_PCI_ADDRESS_SLOT_LAST 31
# define VIR_PCI_ADDRESS_FUNCTION_LAST 7
+typedef enum {
+ VIR_PCI_ADDRESS_EXTENSION_NONE = 0, /* no extension */
+ VIR_PCI_ADDRESS_EXTENSION_ZPCI = 1 << 0, /* zPCI support */
+} virPCIDeviceAddressExtensionFlags;
+
typedef enum {
VIR_PCI_CONNECT_HOTPLUGGABLE = 1 << 0, /* is hotplug needed/supported */
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index 79d2b9f9c4..3d01d14b46 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -511,6 +511,64 @@ qemuDomainAssignARMVirtioMMIOAddresses(virDomainDefPtr def,
}
+static bool
+qemuDomainDeviceSupportZPCI(virDomainDeviceDefPtr device)
+{
+ switch ((virDomainDeviceType)device->type) {
+ case VIR_DOMAIN_DEVICE_CHR:
+ return false;
+
+ case VIR_DOMAIN_DEVICE_CONTROLLER:
+ case VIR_DOMAIN_DEVICE_DISK:
+ case VIR_DOMAIN_DEVICE_LEASE:
+ case VIR_DOMAIN_DEVICE_FS:
+ case VIR_DOMAIN_DEVICE_NET:
+ case VIR_DOMAIN_DEVICE_INPUT:
+ case VIR_DOMAIN_DEVICE_SOUND:
+ case VIR_DOMAIN_DEVICE_VIDEO:
+ case VIR_DOMAIN_DEVICE_HOSTDEV:
+ case VIR_DOMAIN_DEVICE_WATCHDOG:
+ case VIR_DOMAIN_DEVICE_GRAPHICS:
+ case VIR_DOMAIN_DEVICE_HUB:
+ case VIR_DOMAIN_DEVICE_REDIRDEV:
+ case VIR_DOMAIN_DEVICE_SMARTCARD:
+ case VIR_DOMAIN_DEVICE_MEMBALLOON:
+ case VIR_DOMAIN_DEVICE_NVRAM:
+ case VIR_DOMAIN_DEVICE_RNG:
+ case VIR_DOMAIN_DEVICE_SHMEM:
+ case VIR_DOMAIN_DEVICE_TPM:
+ case VIR_DOMAIN_DEVICE_PANIC:
+ case VIR_DOMAIN_DEVICE_MEMORY:
+ case VIR_DOMAIN_DEVICE_IOMMU:
+ case VIR_DOMAIN_DEVICE_VSOCK:
+ break;
+
+ case VIR_DOMAIN_DEVICE_NONE:
+ case VIR_DOMAIN_DEVICE_LAST:
+ default:
+ virReportEnumRangeError(virDomainDeviceType, device->type);
+ return false;
+ }
+
+ return true;
+}
+
+
+static virPCIDeviceAddressExtensionFlags
+qemuDomainDeviceCalculatePCIAddressExtensionFlags(virQEMUCapsPtr qemuCaps,
+ virDomainDeviceDefPtr dev)
+{
+ virPCIDeviceAddressExtensionFlags extFlags = 0;
+
+ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_ZPCI) &&
+ qemuDomainDeviceSupportZPCI(dev)) {
+ extFlags |= VIR_PCI_ADDRESS_EXTENSION_ZPCI;
+ }
+
+ return extFlags;
+}
+
+
/**
* qemuDomainDeviceCalculatePCIConnectFlags:
*
@@ -993,6 +1051,56 @@ qemuDomainFillAllPCIConnectFlags(virDomainDefPtr def,
}
+/**
+ * qemuDomainFillDevicePCIExtensionFlagsIter:
+ *
+ * @def: the entire DomainDef
+ * @dev: The device to be checked
+ * @info: virDomainDeviceInfo within the device
+ * @opaque: qemu capabilities
+ *
+ * Sets the pciAddressExtFlags for a single device's info. Has properly
+ * formatted arguments to be called by virDomainDeviceInfoIterate().
+ *
+ * Always returns 0 - there is no failure.
+ */
+static int
+qemuDomainFillDevicePCIExtensionFlagsIter(virDomainDefPtr def ATTRIBUTE_UNUSED,
+ virDomainDeviceDefPtr dev,
+ virDomainDeviceInfoPtr info,
+ void *opaque)
+{
+ virQEMUCapsPtr qemuCaps = opaque;
+
+ info->pciAddrExtFlags =
+ qemuDomainDeviceCalculatePCIAddressExtensionFlags(qemuCaps, dev);
+
+ return 0;
+}
+
+
+/**
+ * qemuDomainFillAllPCIExtensionFlags:
+ *
+ * @def: the entire DomainDef
+ * @qemuCaps: as you'd expect
+ *
+ * Set the info->pciAddressExtFlags for all devices in the domain.
+ *
+ * Returns 0 on success or -1 on failure (the only possibility of
+ * failure would be some internal problem with
+ * virDomainDeviceInfoIterate())
+ */
+static int
+qemuDomainFillAllPCIExtensionFlags(virDomainDefPtr def,
+ virQEMUCapsPtr qemuCaps)
+{
+ return virDomainDeviceInfoIterate(def,
+ qemuDomainFillDevicePCIExtensionFlagsIter,
+ qemuCaps);
+}
+
+
/**
* qemuDomainFindUnusedIsolationGroupIter:
* @def: domain definition
@@ -1267,6 +1375,27 @@ qemuDomainFillDevicePCIConnectFlags(virDomainDefPtr def,
}
+/**
+ * qemuDomainFillDevicePCIExtensionFlags:
+ *
+ * @dev: The device to be checked
+ * @info: virDomainDeviceInfo within the device
+ * @qemuCaps: as you'd expect
+ *
+ * Set the info->pciAddressExtFlags for a single device.
+ *
+ * No return value.
+ */
+static void
+qemuDomainFillDevicePCIExtensionFlags(virDomainDeviceDefPtr dev,
+ virDomainDeviceInfoPtr info,
+ virQEMUCapsPtr qemuCaps)
+{
+ info->pciAddrExtFlags =
+ qemuDomainDeviceCalculatePCIAddressExtensionFlags(qemuCaps, dev);
+}
+
+
static int
qemuDomainPCIAddressReserveNextAddr(virDomainPCIAddressSetPtr addrs,
virDomainDeviceInfoPtr dev)
@@ -2400,6 +2529,9 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
if (qemuDomainFillAllPCIConnectFlags(def, qemuCaps, driver) < 0)
goto cleanup;
+ if (qemuDomainFillAllPCIExtensionFlags(def, qemuCaps) < 0)
+ goto cleanup;
+
if (qemuDomainSetupIsolationGroups(def) < 0)
goto cleanup;
@@ -2435,7 +2567,8 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
*/
virDomainDeviceInfo info = {
.pciConnectFlags = (VIR_PCI_CONNECT_HOTPLUGGABLE |
- VIR_PCI_CONNECT_TYPE_PCI_DEVICE)
+ VIR_PCI_CONNECT_TYPE_PCI_DEVICE),
+ .pciAddrExtFlags = VIR_PCI_ADDRESS_EXTENSION_NONE
};
bool buses_reserved = true;
@@ -2472,7 +2605,8 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
qemuDomainHasPCIeRoot(def)) {
virDomainDeviceInfo info = {
.pciConnectFlags = (VIR_PCI_CONNECT_HOTPLUGGABLE |
- VIR_PCI_CONNECT_TYPE_PCIE_DEVICE)
+ VIR_PCI_CONNECT_TYPE_PCIE_DEVICE),
+ .pciAddrExtFlags = VIR_PCI_ADDRESS_EXTENSION_NONE
};
/* if there isn't an empty pcie-root-port, this will
@@ -2989,6 +3123,8 @@ qemuDomainEnsurePCIAddress(virDomainObjPtr obj,
qemuDomainFillDevicePCIConnectFlags(obj->def, dev, priv->qemuCaps, driver);
+ qemuDomainFillDevicePCIExtensionFlags(dev, info, priv->qemuCaps);
+
return virDomainPCIAddressEnsureAddr(priv->pciaddrs, info,
info->pciConnectFlags);
}
diff --git a/src/util/virpci.h b/src/util/virpci.h
index 01df652b86..b366d7d9c3 100644
--- a/src/util/virpci.h
+++ b/src/util/virpci.h
@@ -49,6 +49,8 @@ struct _virPCIDeviceAddress {
unsigned int slot;
unsigned int function;
int multi; /* virTristateSwitch */
+ int extFlags; /* enum virPCIDeviceAddressExtensionFlags */
+ virZPCIDeviceAddress zpci;
};
typedef enum {
--
2.22.0

View File

@ -0,0 +1,574 @@
From fddd43e717869d56e481c3fde2d5ee6b5513a1f5 Mon Sep 17 00:00:00 2001
Message-Id: <fddd43e717869d56e481c3fde2d5ee6b5513a1f5@dist-git>
From: Yi Min Zhao <zyimin@linux.ibm.com>
Date: Mon, 8 Apr 2019 10:57:25 +0200
Subject: [PATCH] conf: Introduce parser, formatter for uid and fid
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This patch introduces new XML parser/formatter functions. Uid is
16-bit and non-zero. Fid is 32-bit. They are the two attributes of zpci
which is introduced as PCI address element. Zpci element is parsed and
formatted along with PCI address. And add the related test cases.
Signed-off-by: Yi Min Zhao <zyimin@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
(cherry picked from commit b4833b2c2f7be8a68eb6495ed57ed61918e3ecd8)
https://bugzilla.redhat.com/show_bug.cgi?id=1508149
Conflicts:
* src/conf/device_conf.c
+ context
- missing edeef779585
* tests/qemuxml2argvtest.c
+ context
- missing a0ff9fbe5cad, 0bdb704383f7
Changed:
* tests/qemuxml2argvdata/disk-virtio-s390-zpci.args
tests/qemuxml2argvdata/hostdev-vfio-zpci.args
+ no -boot in output
- missing caccbba64aa9
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Message-Id: <20190408085732.28684-9-abologna@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
docs/schemas/basictypes.rng | 27 ++++++++++
docs/schemas/domaincommon.rng | 1 +
src/conf/device_conf.c | 53 +++++++++++++++++++
src/conf/domain_addr.c | 3 ++
src/conf/domain_conf.c | 12 ++++-
src/libvirt_private.syms | 2 +
src/util/virpci.c | 26 +++++++++
src/util/virpci.h | 6 +++
.../disk-virtio-s390-zpci.args | 26 +++++++++
.../disk-virtio-s390-zpci.xml | 19 +++++++
tests/qemuxml2argvdata/hostdev-vfio-zpci.args | 24 +++++++++
tests/qemuxml2argvdata/hostdev-vfio-zpci.xml | 21 ++++++++
tests/qemuxml2argvtest.c | 7 +++
.../disk-virtio-s390-zpci.xml | 31 +++++++++++
.../qemuxml2xmloutdata/hostdev-vfio-zpci.xml | 32 +++++++++++
tests/qemuxml2xmltest.c | 6 +++
16 files changed, 295 insertions(+), 1 deletion(-)
create mode 100644 tests/qemuxml2argvdata/disk-virtio-s390-zpci.args
create mode 100644 tests/qemuxml2argvdata/disk-virtio-s390-zpci.xml
create mode 100644 tests/qemuxml2argvdata/hostdev-vfio-zpci.args
create mode 100644 tests/qemuxml2argvdata/hostdev-vfio-zpci.xml
create mode 100644 tests/qemuxml2xmloutdata/disk-virtio-s390-zpci.xml
create mode 100644 tests/qemuxml2xmloutdata/hostdev-vfio-zpci.xml
diff --git a/docs/schemas/basictypes.rng b/docs/schemas/basictypes.rng
index b45a7fcdc8..97e14d7ca8 100644
--- a/docs/schemas/basictypes.rng
+++ b/docs/schemas/basictypes.rng
@@ -65,6 +65,17 @@
</data>
</choice>
</define>
+ <define name="uint32">
+ <choice>
+ <data type="string">
+ <param name="pattern">(0x)?[0-9a-fA-F]{1,8}</param>
+ </data>
+ <data type="unsignedInt">
+ <param name="minInclusive">0</param>
+ <param name="maxInclusive">4294967295</param>
+ </data>
+ </choice>
+ </define>
<define name="UUID">
<choice>
@@ -111,6 +122,22 @@
</attribute>
</optional>
</define>
+ <define name="zpciaddress">
+ <optional>
+ <element name="zpci">
+ <optional>
+ <attribute name="uid">
+ <ref name="uint16"/>
+ </attribute>
+ </optional>
+ <optional>
+ <attribute name="fid">
+ <ref name="uint32"/>
+ </attribute>
+ </optional>
+ </element>
+ </optional>
+ </define>
<!-- a 6 byte MAC address in ASCII-hex format, eg "12:34:56:78:9A:BC" -->
<!-- The lowest bit of the 1st byte is the "multicast" bit. a -->
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 70a7767d9c..2b6d4dced6 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -5186,6 +5186,7 @@
<value>pci</value>
</attribute>
<ref name="pciaddress"/>
+ <ref name="zpciaddress"/>
</group>
<group>
<attribute name="type">
diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c
index d69f94fadf..cadac32603 100644
--- a/src/conf/device_conf.c
+++ b/src/conf/device_conf.c
@@ -32,6 +32,45 @@
#define VIR_FROM_THIS VIR_FROM_DEVICE
+static int
+virZPCIDeviceAddressParseXML(xmlNodePtr node,
+ virPCIDeviceAddressPtr addr)
+{
+ virZPCIDeviceAddress def = { 0 };
+ char *uid;
+ char *fid;
+ int ret = -1;
+
+ uid = virXMLPropString(node, "uid");
+ fid = virXMLPropString(node, "fid");
+
+ if (uid &&
+ virStrToLong_uip(uid, NULL, 0, &def.uid) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Cannot parse <address> 'uid' attribute"));
+ goto cleanup;
+ }
+
+ if (fid &&
+ virStrToLong_uip(fid, NULL, 0, &def.fid) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Cannot parse <address> 'fid' attribute"));
+ goto cleanup;
+ }
+
+ if (!virZPCIDeviceAddressIsEmpty(&def) &&
+ !virZPCIDeviceAddressIsValid(&def))
+ goto cleanup;
+
+ addr->zpci = def;
+ ret = 0;
+
+ cleanup:
+ VIR_FREE(uid);
+ VIR_FREE(fid);
+ return ret;
+}
+
int
virDomainDeviceInfoCopy(virDomainDeviceInfoPtr dst,
virDomainDeviceInfoPtr src)
@@ -196,6 +235,8 @@ virPCIDeviceAddressParseXML(xmlNodePtr node,
virPCIDeviceAddressPtr addr)
{
char *domain, *slot, *bus, *function, *multi;
+ xmlNodePtr cur;
+ xmlNodePtr zpci = NULL;
int ret = -1;
memset(addr, 0, sizeof(*addr));
@@ -245,6 +286,18 @@ virPCIDeviceAddressParseXML(xmlNodePtr node,
if (!virPCIDeviceAddressIsEmpty(addr) && !virPCIDeviceAddressIsValid(addr, true))
goto cleanup;
+ cur = node->children;
+ while (cur) {
+ if (cur->type == XML_ELEMENT_NODE &&
+ virXMLNodeNameEqual(cur, "zpci")) {
+ zpci = cur;
+ }
+ cur = cur->next;
+ }
+
+ if (zpci && virZPCIDeviceAddressParseXML(zpci, addr) < 0)
+ goto cleanup;
+
ret = 0;
cleanup:
diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
index 3e33549c3d..9e0a0fdf95 100644
--- a/src/conf/domain_addr.c
+++ b/src/conf/domain_addr.c
@@ -1054,6 +1054,9 @@ virDomainPCIAddressReserveNextAddr(virDomainPCIAddressSetPtr addrs,
dev->isolationGroup, false) < 0)
return -1;
+ addr.extFlags = dev->addr.pci.extFlags;
+ addr.zpci = dev->addr.pci.zpci;
+
if (!addrs->dryRun) {
dev->type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
dev->addr.pci = addr;
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index bcb0558bc3..29ebf0a930 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -6448,6 +6448,7 @@ virDomainDeviceInfoFormat(virBufferPtr buf,
unsigned int flags)
{
virBuffer attrBuf = VIR_BUFFER_INITIALIZER;
+ virBuffer childBuf = VIR_BUFFER_INITIALIZER;
if ((flags & VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT) && info->bootIndex) {
virBufferAsprintf(buf, "<boot order='%u'", info->bootIndex);
@@ -6510,6 +6511,14 @@ virDomainDeviceInfoFormat(virBufferPtr buf,
virBufferAsprintf(&attrBuf, " multifunction='%s'",
virTristateSwitchTypeToString(info->addr.pci.multi));
}
+
+ if (!virZPCIDeviceAddressIsEmpty(&info->addr.pci.zpci)) {
+ virBufferSetChildIndent(&childBuf, buf);
+ virBufferAsprintf(&childBuf,
+ "<zpci uid='0x%.4x' fid='0x%.8x'/>\n",
+ info->addr.pci.zpci.uid,
+ info->addr.pci.zpci.fid);
+ }
break;
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE:
@@ -6577,9 +6586,10 @@ virDomainDeviceInfoFormat(virBufferPtr buf,
break;
}
- virXMLFormatElement(buf, "address", &attrBuf, NULL);
+ virXMLFormatElement(buf, "address", &attrBuf, &childBuf);
virBufferFreeAndReset(&attrBuf);
+ virBufferFreeAndReset(&childBuf);
}
static int
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index df27ac4b3a..b2a2a1f265 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2569,6 +2569,8 @@ virPCIHeaderTypeToString;
virPCIIsVirtualFunction;
virPCIStubDriverTypeFromString;
virPCIStubDriverTypeToString;
+virZPCIDeviceAddressIsEmpty;
+virZPCIDeviceAddressIsValid;
# util/virperf.h
diff --git a/src/util/virpci.c b/src/util/virpci.c
index 8d02366664..3a1e49a7a7 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -2597,6 +2597,32 @@ virPCIDeviceAddressParse(char *address,
#ifdef __linux__
+bool
+virZPCIDeviceAddressIsValid(virZPCIDeviceAddressPtr zpci)
+{
+ /* We don't need to check fid because fid covers
+ * all range of uint32 type.
+ */
+ if (zpci->uid > VIR_DOMAIN_DEVICE_ZPCI_MAX_UID ||
+ zpci->uid == 0) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("Invalid PCI address uid='0x%.4x', "
+ "must be > 0x0000 and <= 0x%.4x"),
+ zpci->uid,
+ VIR_DOMAIN_DEVICE_ZPCI_MAX_UID);
+ return false;
+ }
+
+ return true;
+}
+
+bool
+virZPCIDeviceAddressIsEmpty(const virZPCIDeviceAddress *addr)
+{
+ return !(addr->uid || addr->fid);
+}
+
+
/*
* returns true if equal
*/
diff --git a/src/util/virpci.h b/src/util/virpci.h
index b366d7d9c3..1ed9e2381e 100644
--- a/src/util/virpci.h
+++ b/src/util/virpci.h
@@ -36,6 +36,9 @@ typedef virPCIDeviceAddress *virPCIDeviceAddressPtr;
typedef struct _virPCIDeviceList virPCIDeviceList;
typedef virPCIDeviceList *virPCIDeviceListPtr;
+# define VIR_DOMAIN_DEVICE_ZPCI_MAX_UID UINT16_MAX
+# define VIR_DOMAIN_DEVICE_ZPCI_MAX_FID UINT32_MAX
+
typedef struct _virZPCIDeviceAddress virZPCIDeviceAddress;
typedef virZPCIDeviceAddress *virZPCIDeviceAddressPtr;
struct _virZPCIDeviceAddress {
@@ -235,6 +238,9 @@ int virPCIGetAddrString(unsigned int domain,
int virPCIDeviceAddressParse(char *address, virPCIDeviceAddressPtr bdf);
+bool virZPCIDeviceAddressIsValid(virZPCIDeviceAddressPtr zpci);
+bool virZPCIDeviceAddressIsEmpty(const virZPCIDeviceAddress *addr);
+
int virPCIGetVirtualFunctionInfo(const char *vf_sysfs_device_path,
int pfNetDevIdx,
char **pfname,
diff --git a/tests/qemuxml2argvdata/disk-virtio-s390-zpci.args b/tests/qemuxml2argvdata/disk-virtio-s390-zpci.args
new file mode 100644
index 0000000000..20e63a15b5
--- /dev/null
+++ b/tests/qemuxml2argvdata/disk-virtio-s390-zpci.args
@@ -0,0 +1,26 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-s390x \
+-name QEMUGuest1 \
+-S \
+-machine s390-ccw-virtio,accel=tcg,usb=off,dump-guest-core=off \
+-m 214 \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
+server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-boot c \
+-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \
+-device virtio-blk-pci,bus=pci.0,addr=0x8,drive=drive-virtio-disk0,\
+id=virtio-disk0 \
+-device virtio-balloon-ccw,id=balloon0,devno=fe.0.0000
diff --git a/tests/qemuxml2argvdata/disk-virtio-s390-zpci.xml b/tests/qemuxml2argvdata/disk-virtio-s390-zpci.xml
new file mode 100644
index 0000000000..8bf4a23670
--- /dev/null
+++ b/tests/qemuxml2argvdata/disk-virtio-s390-zpci.xml
@@ -0,0 +1,19 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory>219136</memory>
+ <vcpu>1</vcpu>
+ <os>
+ <type arch='s390x' machine='s390-ccw-virtio'>hvm</type>
+ </os>
+ <devices>
+ <emulator>/usr/bin/qemu-system-s390x</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='virtio'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'>
+ <zpci uid='0x0019' fid='0x0000001f'/>
+ </address>
+ </disk>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/hostdev-vfio-zpci.args b/tests/qemuxml2argvdata/hostdev-vfio-zpci.args
new file mode 100644
index 0000000000..622c504da0
--- /dev/null
+++ b/tests/qemuxml2argvdata/hostdev-vfio-zpci.args
@@ -0,0 +1,24 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-s390x \
+-name QEMUGuest1 \
+-S \
+-machine s390-ccw-virtio,accel=tcg,usb=off,dump-guest-core=off \
+-m 214 \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
+server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-boot c \
+-device vfio-pci,host=00:00.0,id=hostdev0,bus=pci.0,addr=0x8 \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x1
diff --git a/tests/qemuxml2argvdata/hostdev-vfio-zpci.xml b/tests/qemuxml2argvdata/hostdev-vfio-zpci.xml
new file mode 100644
index 0000000000..002b99c52d
--- /dev/null
+++ b/tests/qemuxml2argvdata/hostdev-vfio-zpci.xml
@@ -0,0 +1,21 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory>219100</memory>
+ <os>
+ <type arch='s390x' machine='s390-ccw-virtio'>hvm</type>
+ </os>
+ <devices>
+ <emulator>/usr/bin/qemu-system-s390x</emulator>
+ <controller type='pci' index='0' model='pci-root'/>
+ <hostdev mode='subsystem' type='pci' managed='no'>
+ <driver name='vfio'/>
+ <source>
+ <address domain='0x0000' bus='0x00' slot='0x00' function='0x0'/>
+ </source>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'>
+ <zpci uid='0x0019' fid='0x0000001f'/>
+ </address>
+ </hostdev>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 7f25cccf9d..2eb2505971 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1038,6 +1038,10 @@ mymain(void)
QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
DO_TEST("disk-virtio-scsi-ccw", QEMU_CAPS_VIRTIO_SCSI,
QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
+ DO_TEST("disk-virtio-s390-zpci",
+ QEMU_CAPS_DEVICE_ZPCI,
+ QEMU_CAPS_CCW,
+ QEMU_CAPS_VIRTIO_S390);
DO_TEST("disk-order",
QEMU_CAPS_DRIVE_BOOT, QEMU_CAPS_VIRTIO_BLK_SCSI);
DO_TEST("disk-virtio-drive-queues",
@@ -1628,6 +1632,9 @@ mymain(void)
DO_TEST_PARSE_ERROR("hostdev-mdev-display-missing-graphics",
QEMU_CAPS_DEVICE_VFIO_PCI,
QEMU_CAPS_VFIO_PCI_DISPLAY);
+ DO_TEST("hostdev-vfio-zpci",
+ QEMU_CAPS_DEVICE_VFIO_PCI,
+ QEMU_CAPS_DEVICE_ZPCI);
DO_TEST("pci-rom", NONE);
DO_TEST("pci-rom-disabled", NONE);
DO_TEST("pci-rom-disabled-invalid", NONE);
diff --git a/tests/qemuxml2xmloutdata/disk-virtio-s390-zpci.xml b/tests/qemuxml2xmloutdata/disk-virtio-s390-zpci.xml
new file mode 100644
index 0000000000..37684c82b1
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/disk-virtio-s390-zpci.xml
@@ -0,0 +1,31 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='s390x' machine='s390-ccw-virtio'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-s390x</emulator>
+ <disk type='block' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='virtio'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'>
+ <zpci uid='0x0019' fid='0x0000001f'/>
+ </address>
+ </disk>
+ <controller type='pci' index='0' model='pci-root'/>
+ <memballoon model='virtio'>
+ <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0000'/>
+ </memballoon>
+ <panic model='s390'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2xmloutdata/hostdev-vfio-zpci.xml b/tests/qemuxml2xmloutdata/hostdev-vfio-zpci.xml
new file mode 100644
index 0000000000..fc8c38ab66
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/hostdev-vfio-zpci.xml
@@ -0,0 +1,32 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='s390x' machine='s390-ccw-virtio'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-s390x</emulator>
+ <controller type='pci' index='0' model='pci-root'/>
+ <hostdev mode='subsystem' type='pci' managed='no'>
+ <driver name='vfio'/>
+ <source>
+ <address domain='0x0000' bus='0x00' slot='0x00' function='0x0'/>
+ </source>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'>
+ <zpci uid='0x0019' fid='0x0000001f'/>
+ </address>
+ </hostdev>
+ <memballoon model='virtio'>
+ <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0000'/>
+ </memballoon>
+ <panic model='s390'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 2a2bf01ffa..a787f4f4a3 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -400,6 +400,9 @@ mymain(void)
QEMU_CAPS_VIRTIO_SCSI);
DO_TEST("disk-virtio-scsi-ioeventfd",
QEMU_CAPS_VIRTIO_SCSI);
+ DO_TEST("disk-virtio-s390-zpci",
+ QEMU_CAPS_DEVICE_ZPCI,
+ QEMU_CAPS_CCW);
DO_TEST("disk-scsi-megasas",
QEMU_CAPS_SCSI_MEGASAS);
DO_TEST("disk-scsi-mptsas1068",
@@ -482,6 +485,9 @@ mymain(void)
DO_TEST("hostdev-usb-address", NONE);
DO_TEST("hostdev-pci-address", NONE);
DO_TEST("hostdev-vfio", NONE);
+ DO_TEST("hostdev-vfio-zpci",
+ QEMU_CAPS_DEVICE_ZPCI,
+ QEMU_CAPS_CCW);
DO_TEST("hostdev-mdev-precreated", NONE);
DO_TEST("hostdev-mdev-display", QEMU_CAPS_VFIO_PCI_DISPLAY);
DO_TEST("pci-rom", NONE);
--
2.22.0

View File

@ -0,0 +1,103 @@
From 0bed2e17ea6469ccabb374c0520a97706b281911 Mon Sep 17 00:00:00 2001
Message-Id: <0bed2e17ea6469ccabb374c0520a97706b281911@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:26:06 +0200
Subject: [PATCH] conf: Introduce virCPUDefCheckFeatures
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This API can be used to check whether a CPU definition contains features
matching a given filter.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 4e6f58b8d55d44fa9f80736b2745b44710f6e25a)
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <ea489f203e2d52250acb1b9656de6aba8355f3a6.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/conf/cpu_conf.c | 33 +++++++++++++++++++++++++++++++++
src/conf/cpu_conf.h | 6 ++++++
src/libvirt_private.syms | 1 +
3 files changed, 40 insertions(+)
diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
index 51e2a83eae..4cccea9981 100644
--- a/src/conf/cpu_conf.c
+++ b/src/conf/cpu_conf.c
@@ -872,6 +872,39 @@ virCPUDefFilterFeatures(virCPUDefPtr cpu,
}
+/**
+ * virCPUDefCheckFeatures:
+ *
+ * Check CPU features for which @filter reports true and store them in a NULL
+ * terminated list returned via @features.
+ *
+ * Returns the number of features matching @filter or -1 on error.
+ */
+int
+virCPUDefCheckFeatures(virCPUDefPtr cpu,
+ virCPUDefFeatureFilter filter,
+ void *opaque,
+ char ***features)
+{
+ VIR_AUTOSTRINGLIST list = NULL;
+ size_t n = 0;
+ size_t i;
+
+ *features = NULL;
+
+ for (i = 0; i < cpu->nfeatures; i++) {
+ if (filter(cpu->features[i].name, opaque)) {
+ if (virStringListAdd(&list, cpu->features[i].name) < 0)
+ return -1;
+ n++;
+ }
+ }
+
+ VIR_STEAL_PTR(*features, list);
+ return n;
+}
+
+
bool
virCPUDefIsEqual(virCPUDefPtr src,
virCPUDefPtr dst,
diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h
index ad25932b9b..cba0ec7c81 100644
--- a/src/conf/cpu_conf.h
+++ b/src/conf/cpu_conf.h
@@ -225,6 +225,12 @@ virCPUDefFilterFeatures(virCPUDefPtr cpu,
virCPUDefFeatureFilter filter,
void *opaque);
+int
+virCPUDefCheckFeatures(virCPUDefPtr cpu,
+ virCPUDefFeatureFilter filter,
+ void *opaque,
+ char ***features);
+
virCPUDefPtr *
virCPUDefListParse(const char **xmlCPUs,
unsigned int ncpus,
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 06374deaae..0290f960a0 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -72,6 +72,7 @@ virCapabilitiesSetNetPrefix;
virCPUCacheModeTypeFromString;
virCPUCacheModeTypeToString;
virCPUDefAddFeature;
+virCPUDefCheckFeatures;
virCPUDefCopy;
virCPUDefCopyModel;
virCPUDefCopyModelFilter;
--
2.22.0

View File

@ -0,0 +1,154 @@
From 2566a32fae64fa5cc8a3d3c30778d0ea7d8c4faa Mon Sep 17 00:00:00 2001
Message-Id: <2566a32fae64fa5cc8a3d3c30778d0ea7d8c4faa@dist-git>
From: Yi Min Zhao <zyimin@linux.ibm.com>
Date: Mon, 8 Apr 2019 10:57:24 +0200
Subject: [PATCH] conf: use virXMLFormatElement() in
virDomainDeviceInfoFormat()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
In order to add zPCI child element for PCI address, we update
virDomainDeviceInfoFormat() to format device info by helper function
virXMLFormatElement(). Then we could simply format zPCI address into
child buffer later.
Signed-off-by: Yi Min Zhao <zyimin@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
(cherry picked from commit 0d6b87335c00451b0923ecc91d617f71e4135bf8)
https://bugzilla.redhat.com/show_bug.cgi?id=1508149
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Message-Id: <20190408085732.28684-8-abologna@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/conf/domain_conf.c | 40 ++++++++++++++++++++++------------------
1 file changed, 22 insertions(+), 18 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index e62f78471c..bcb0558bc3 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -6447,6 +6447,8 @@ virDomainDeviceInfoFormat(virBufferPtr buf,
virDomainDeviceInfoPtr info,
unsigned int flags)
{
+ virBuffer attrBuf = VIR_BUFFER_INITIALIZER;
+
if ((flags & VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT) && info->bootIndex) {
virBufferAsprintf(buf, "<boot order='%u'", info->bootIndex);
@@ -6491,13 +6493,13 @@ virDomainDeviceInfoFormat(virBufferPtr buf,
info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390)
return;
- virBufferAsprintf(buf, "<address type='%s'",
+ virBufferAsprintf(&attrBuf, " type='%s'",
virDomainDeviceAddressTypeToString(info->type));
switch ((virDomainDeviceAddressType) info->type) {
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI:
if (!virPCIDeviceAddressIsEmpty(&info->addr.pci)) {
- virBufferAsprintf(buf, " domain='0x%.4x' bus='0x%.2x' "
+ virBufferAsprintf(&attrBuf, " domain='0x%.4x' bus='0x%.2x' "
"slot='0x%.2x' function='0x%.1x'",
info->addr.pci.domain,
info->addr.pci.bus,
@@ -6505,13 +6507,13 @@ virDomainDeviceInfoFormat(virBufferPtr buf,
info->addr.pci.function);
}
if (info->addr.pci.multi) {
- virBufferAsprintf(buf, " multifunction='%s'",
- virTristateSwitchTypeToString(info->addr.pci.multi));
+ virBufferAsprintf(&attrBuf, " multifunction='%s'",
+ virTristateSwitchTypeToString(info->addr.pci.multi));
}
break;
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE:
- virBufferAsprintf(buf, " controller='%d' bus='%d' target='%d' unit='%d'",
+ virBufferAsprintf(&attrBuf, " controller='%d' bus='%d' target='%d' unit='%d'",
info->addr.drive.controller,
info->addr.drive.bus,
info->addr.drive.target,
@@ -6519,34 +6521,34 @@ virDomainDeviceInfoFormat(virBufferPtr buf,
break;
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL:
- virBufferAsprintf(buf, " controller='%d' bus='%d' port='%d'",
+ virBufferAsprintf(&attrBuf, " controller='%d' bus='%d' port='%d'",
info->addr.vioserial.controller,
info->addr.vioserial.bus,
info->addr.vioserial.port);
break;
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCID:
- virBufferAsprintf(buf, " controller='%d' slot='%d'",
+ virBufferAsprintf(&attrBuf, " controller='%d' slot='%d'",
info->addr.ccid.controller,
info->addr.ccid.slot);
break;
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB:
- virBufferAsprintf(buf, " bus='%d'", info->addr.usb.bus);
+ virBufferAsprintf(&attrBuf, " bus='%d'", info->addr.usb.bus);
if (virDomainUSBAddressPortIsValid(info->addr.usb.port)) {
- virBufferAddLit(buf, " port='");
- virDomainUSBAddressPortFormatBuf(buf, info->addr.usb.port);
- virBufferAddLit(buf, "'");
+ virBufferAddLit(&attrBuf, " port='");
+ virDomainUSBAddressPortFormatBuf(&attrBuf, info->addr.usb.port);
+ virBufferAddLit(&attrBuf, "'");
}
break;
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO:
if (info->addr.spaprvio.has_reg)
- virBufferAsprintf(buf, " reg='0x%llx'", info->addr.spaprvio.reg);
+ virBufferAsprintf(&attrBuf, " reg='0x%llx'", info->addr.spaprvio.reg);
break;
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW:
- virBufferAsprintf(buf, " cssid='0x%x' ssid='0x%x' devno='0x%04x'",
+ virBufferAsprintf(&attrBuf, " cssid='0x%x' ssid='0x%x' devno='0x%04x'",
info->addr.ccw.cssid,
info->addr.ccw.ssid,
info->addr.ccw.devno);
@@ -6557,15 +6559,15 @@ virDomainDeviceInfoFormat(virBufferPtr buf,
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA:
if (info->addr.isa.iobase > 0)
- virBufferAsprintf(buf, " iobase='0x%x'", info->addr.isa.iobase);
+ virBufferAsprintf(&attrBuf, " iobase='0x%x'", info->addr.isa.iobase);
if (info->addr.isa.irq > 0)
- virBufferAsprintf(buf, " irq='0x%x'", info->addr.isa.irq);
+ virBufferAsprintf(&attrBuf, " irq='0x%x'", info->addr.isa.irq);
break;
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM:
- virBufferAsprintf(buf, " slot='%u'", info->addr.dimm.slot);
+ virBufferAsprintf(&attrBuf, " slot='%u'", info->addr.dimm.slot);
if (info->addr.dimm.base)
- virBufferAsprintf(buf, " base='0x%llx'", info->addr.dimm.base);
+ virBufferAsprintf(&attrBuf, " base='0x%llx'", info->addr.dimm.base);
break;
@@ -6575,7 +6577,9 @@ virDomainDeviceInfoFormat(virBufferPtr buf,
break;
}
- virBufferAddLit(buf, "/>\n");
+ virXMLFormatElement(buf, "address", &attrBuf, NULL);
+
+ virBufferFreeAndReset(&attrBuf);
}
static int
--
2.22.0

View File

@ -0,0 +1,59 @@
From b339a54e493d97a5616be8883d1a0b4ebcd149d3 Mon Sep 17 00:00:00 2001
Message-Id: <b339a54e493d97a5616be8883d1a0b4ebcd149d3@dist-git>
From: Michal Privoznik <mprivozn@redhat.com>
Date: Fri, 21 Jun 2019 09:25:18 +0200
Subject: [PATCH] cpu: Don't access invalid memory in virCPUx86Translate
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Problem is that if there are no signatures for a CPU, then we
still allocate cpu->signatures (even though with size 0). Later,
we access cpu->signatures[0] if cpu->signatures is not NULL.
Invalid read of size 4
at 0x5F439D7: virCPUx86Translate (cpu_x86.c:2930)
by 0x5F3C239: virCPUTranslate (cpu.c:927)
by 0x57CE7A1: qemuProcessUpdateGuestCPU (qemu_process.c:5870)
...
Address 0xf752d40 is 0 bytes after a block of size 0 alloc'd
at 0x4C30EC6: calloc (vg_replace_malloc.c:711)
by 0x5DBDE4E: virAllocN (viralloc.c:190)
by 0x5F3E4FA: x86ModelCopySignatures (cpu_x86.c:990)
by 0x5F3E60F: x86ModelCopy (cpu_x86.c:1008)
by 0x5F3E7CB: x86ModelFromCPU (cpu_x86.c:1068)
by 0x5F4397E: virCPUx86Translate (cpu_x86.c:2922)
by 0x5F3C239: virCPUTranslate (cpu.c:927)
by 0x57CE7A1: qemuProcessUpdateGuestCPU (qemu_process.c:5870)
...
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
(cherry picked from commit 62cb9c335c43a722e81ac0a1ed6e1111ba1d428b)
https://bugzilla.redhat.com/show_bug.cgi?id=1686895
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <b36b22d237a7044a473e9b72de9763b2c603198c.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_x86.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 24569a90f3..66aa5a612c 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -985,6 +985,9 @@ x86ModelCopySignatures(virCPUx86ModelPtr dst,
{
size_t i;
+ if (src->nsignatures == 0)
+ return 0;
+
if (VIR_ALLOC_N(dst->signatures, src->nsignatures) < 0)
return -1;
--
2.22.0

View File

@ -0,0 +1,176 @@
From 992af2f6564b899142a2be5f342e0cdbdd13eadc Mon Sep 17 00:00:00 2001
Message-Id: <992af2f6564b899142a2be5f342e0cdbdd13eadc@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:25:59 +0200
Subject: [PATCH] cpu: Introduce virCPUDataAddFeature
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This is a generic replacement for the former virCPUx86DataAddFeature,
which worked on the generic virCPUDataPtr anyway.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit df73078c612a70e48aa76e889a7026e2daa47b16)
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
Conflicts:
src/cpu/cpu_x86.h
- downstream did not switch to #pragma once
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <4e946f702092fe5eb4c8235dbb98402b30876a5f.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu.c | 33 +++++++++++++++++++++++++++++++++
src/cpu/cpu.h | 9 +++++++++
src/cpu/cpu_x86.c | 3 ++-
src/cpu/cpu_x86.h | 3 ---
src/libvirt_private.syms | 2 +-
src/qemu/qemu_capabilities.c | 2 +-
6 files changed, 46 insertions(+), 6 deletions(-)
diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c
index cc93c49418..a2d143c94a 100644
--- a/src/cpu/cpu.c
+++ b/src/cpu/cpu.c
@@ -1078,3 +1078,36 @@ virCPUValidateFeatures(virArch arch,
else
return 0;
}
+
+
+/**
+ * virCPUDataAddFeature:
+ *
+ * @cpuData: CPU data
+ * @name: feature to be added to @cpuData
+ *
+ * Adds a feature called @name to @cpuData.
+ *
+ * Returns 0 on success, -1 on error.
+ */
+int
+virCPUDataAddFeature(virCPUDataPtr cpuData,
+ const char *name)
+{
+ struct cpuArchDriver *driver;
+
+ VIR_DEBUG("arch=%s, cpuData=%p, name=%s",
+ virArchToString(cpuData->arch), cpuData, name);
+
+ if (!(driver = cpuGetSubDriver(cpuData->arch)))
+ return -1;
+
+ if (!driver->dataAddFeature) {
+ virReportError(VIR_ERR_NO_SUPPORT,
+ _("cannot add guest CPU feature for %s architecture"),
+ virArchToString(cpuData->arch));
+ return -1;
+ }
+
+ return driver->dataAddFeature(cpuData, name);
+}
diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h
index 81119b6aeb..e5fae31e30 100644
--- a/src/cpu/cpu.h
+++ b/src/cpu/cpu.h
@@ -121,6 +121,10 @@ typedef virCPUDefPtr
typedef int
(*virCPUArchValidateFeatures)(virCPUDefPtr cpu);
+typedef int
+(*virCPUArchDataAddFeature)(virCPUDataPtr cpuData,
+ const char *name);
+
struct cpuArchDriver {
const char *name;
const virArch *arch;
@@ -143,6 +147,7 @@ struct cpuArchDriver {
virCPUArchExpandFeatures expandFeatures;
virCPUArchCopyMigratable copyMigratable;
virCPUArchValidateFeatures validateFeatures;
+ virCPUArchDataAddFeature dataAddFeature;
};
@@ -260,6 +265,10 @@ virCPUValidateFeatures(virArch arch,
virCPUDefPtr cpu)
ATTRIBUTE_NONNULL(2);
+int
+virCPUDataAddFeature(virCPUDataPtr cpuData,
+ const char *name);
+
/* virCPUDataFormat and virCPUDataParse are implemented for unit tests only and
* have no real-life usage
*/
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 3c1bd623db..ead962ae06 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -3316,7 +3316,7 @@ virCPUx86DataSetVendor(virCPUDataPtr cpuData,
}
-int
+static int
virCPUx86DataAddFeature(virCPUDataPtr cpuData,
const char *name)
{
@@ -3361,4 +3361,5 @@ struct cpuArchDriver cpuDriverX86 = {
.expandFeatures = virCPUx86ExpandFeatures,
.copyMigratable = virCPUx86CopyMigratable,
.validateFeatures = virCPUx86ValidateFeatures,
+ .dataAddFeature = virCPUx86DataAddFeature,
};
diff --git a/src/cpu/cpu_x86.h b/src/cpu/cpu_x86.h
index 8b51cef9c1..519024b7c0 100644
--- a/src/cpu/cpu_x86.h
+++ b/src/cpu/cpu_x86.h
@@ -45,7 +45,4 @@ uint32_t virCPUx86DataGetSignature(virCPUDataPtr cpuData,
int virCPUx86DataSetVendor(virCPUDataPtr cpuData,
const char *vendor);
-int virCPUx86DataAddFeature(virCPUDataPtr cpuData,
- const char *name);
-
#endif /* __VIR_CPU_X86_H__ */
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 57508de0c1..a20e0593f0 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1187,6 +1187,7 @@ virCPUCompare;
virCPUCompareXML;
virCPUConvertLegacy;
virCPUCopyMigratable;
+virCPUDataAddFeature;
virCPUDataCheckFeature;
virCPUDataFormat;
virCPUDataFree;
@@ -1205,7 +1206,6 @@ virCPUValidateFeatures;
# cpu/cpu_x86.h
virCPUx86DataAdd;
-virCPUx86DataAddFeature;
virCPUx86DataGetSignature;
virCPUx86DataSetSignature;
virCPUx86DataSetVendor;
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 78be2d35f4..4be0ec305f 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -2916,7 +2916,7 @@ virQEMUCapsGetCPUModelX86Data(virQEMUCapsPtr qemuCaps,
(migratable && prop->migratable == VIR_TRISTATE_BOOL_NO))
continue;
- if (virCPUx86DataAddFeature(data, name) < 0)
+ if (virCPUDataAddFeature(data, name) < 0)
goto cleanup;
break;
--
2.22.0

View File

@ -0,0 +1,159 @@
From 6438640b53fef3e889c21a2ed016638b91c5ac80 Mon Sep 17 00:00:00 2001
Message-Id: <6438640b53fef3e889c21a2ed016638b91c5ac80@dist-git>
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= <berrange@redhat.com>
Date: Fri, 21 Jun 2019 09:24:44 +0200
Subject: [PATCH] cpu: allow include files for CPU definition
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Allow for syntax
<include filename="subdir/fooo.xml"/>
to reference other files in the CPU database directory
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
(cherry picked from commit eda5f575f2a7530fc7f6471f88496778a9bc9fcb)
https://bugzilla.redhat.com/show_bug.cgi?id=1686895
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <800e5ebbc30502fd780a3ef84fe524f1dc0ffd67.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_map.c | 92 +++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 89 insertions(+), 3 deletions(-)
diff --git a/src/cpu/cpu_map.c b/src/cpu/cpu_map.c
index d263eb8cdd..333c7ef24f 100644
--- a/src/cpu/cpu_map.c
+++ b/src/cpu/cpu_map.c
@@ -1,7 +1,7 @@
/*
* cpu_map.c: internal functions for handling CPU mapping configuration
*
- * Copyright (C) 2009-2010 Red Hat, Inc.
+ * Copyright (C) 2009-2018 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -70,6 +70,89 @@ static int load(xmlXPathContextPtr ctxt,
return ret;
}
+static int
+cpuMapLoadInclude(const char *filename,
+ cpuMapLoadCallback cb,
+ void *data)
+{
+ xmlDocPtr xml = NULL;
+ xmlXPathContextPtr ctxt = NULL;
+ int ret = -1;
+ int element;
+ char *mapfile;
+
+ if (!(mapfile = virFileFindResource(filename,
+ abs_topsrcdir "/src/cpu",
+ PKGDATADIR)))
+ return -1;
+
+ VIR_DEBUG("Loading CPU map include from %s", mapfile);
+
+ if (!(xml = virXMLParseFileCtxt(mapfile, &ctxt)))
+ goto cleanup;
+
+ ctxt->node = xmlDocGetRootElement(xml);
+
+ for (element = 0; element < CPU_MAP_ELEMENT_LAST; element++) {
+ if (load(ctxt, element, cb, data) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("cannot parse CPU map '%s'"), mapfile);
+ goto cleanup;
+ }
+ }
+
+ ret = 0;
+
+ cleanup:
+ xmlXPathFreeContext(ctxt);
+ xmlFreeDoc(xml);
+ VIR_FREE(mapfile);
+
+ return ret;
+}
+
+
+static int
+loadIncludes(xmlXPathContextPtr ctxt,
+ cpuMapLoadCallback callback,
+ void *data)
+{
+ int ret = -1;
+ xmlNodePtr ctxt_node;
+ xmlNodePtr *nodes = NULL;
+ int n;
+ size_t i;
+
+ ctxt_node = ctxt->node;
+
+ n = virXPathNodeSet("include", ctxt, &nodes);
+ if (n < 0)
+ goto cleanup;
+
+ for (i = 0; i < n; i++) {
+ char *filename = virXMLPropString(nodes[i], "filename");
+ if (!filename) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Missing 'filename' in CPU map include"));
+ goto cleanup;
+ }
+ VIR_DEBUG("Finding CPU map include '%s'", filename);
+ if (cpuMapLoadInclude(filename, callback, data) < 0) {
+ VIR_FREE(filename);
+ goto cleanup;
+ }
+ VIR_FREE(filename);
+ }
+
+ ret = 0;
+
+ cleanup:
+ ctxt->node = ctxt_node;
+ VIR_FREE(nodes);
+
+ return ret;
+}
+
int cpuMapLoad(const char *arch,
cpuMapLoadCallback cb,
@@ -88,7 +171,7 @@ int cpuMapLoad(const char *arch,
PKGDATADIR)))
return -1;
- VIR_DEBUG("Loading CPU map from %s", mapfile);
+ VIR_DEBUG("Loading '%s' CPU map from %s", NULLSTR(arch), mapfile);
if (arch == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -122,11 +205,14 @@ int cpuMapLoad(const char *arch,
for (element = 0; element < CPU_MAP_ELEMENT_LAST; element++) {
if (load(ctxt, element, cb, data) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
- _("cannot parse CPU map for %s architecture"), arch);
+ _("cannot parse CPU map '%s'"), mapfile);
goto cleanup;
}
}
+ if (loadIncludes(ctxt, cb, data) < 0)
+ goto cleanup;
+
ret = 0;
cleanup:
--
2.22.0

View File

@ -0,0 +1,51 @@
From 612913a764992dc1a9ae63762749ecee447427d7 Mon Sep 17 00:00:00 2001
Message-Id: <612913a764992dc1a9ae63762749ecee447427d7@dist-git>
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= <berrange@redhat.com>
Date: Fri, 21 Jun 2019 09:24:45 +0200
Subject: [PATCH] cpu: fix cleanup when signature parsing fails
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Two pieces of code accidentally jumped to the wrong label when they
failed causing incorrect cleanup, returning a partially initialized
CPU model struct.
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
(cherry picked from commit 118fcdd480ad38a3e8477f466f6a876dce7e9fa6)
https://bugzilla.redhat.com/show_bug.cgi?id=1686895
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <5e9aedc6fd4f4570322a7d13626863bec0449283.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_x86.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 89baf94d7d..124aa5fd5e 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -1250,7 +1250,7 @@ x86ModelParse(xmlXPathContextPtr ctxt,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Invalid CPU signature family in model %s"),
model->name);
- goto cleanup;
+ goto error;
}
rc = virXPathUInt("string(./signature/@model)", ctxt, &sigModel);
@@ -1258,7 +1258,7 @@ x86ModelParse(xmlXPathContextPtr ctxt,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Invalid CPU signature model in model %s"),
model->name);
- goto cleanup;
+ goto error;
}
model->signature = x86MakeSignature(sigFamily, sigModel, 0);
--
2.22.0

View File

@ -0,0 +1,782 @@
From 728231dcbbf2a4ab8a4bfe03fdf43d78bdeccbb0 Mon Sep 17 00:00:00 2001
Message-Id: <728231dcbbf2a4ab8a4bfe03fdf43d78bdeccbb0@dist-git>
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= <berrange@redhat.com>
Date: Fri, 21 Jun 2019 09:24:46 +0200
Subject: [PATCH] cpu: push more parsing logic into common code
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The x86 and ppc impls both duplicate some logic when parsing CPU
features. Change the callback signature so that this duplication can be
pushed up a level to common code.
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
(cherry picked from commit 0815f519784a7c565c543498777dc25f129620f9)
https://bugzilla.redhat.com/show_bug.cgi?id=1686895
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <c770b678131dc5e207cbe84d276a2774e0c807c7.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_map.c | 98 +++++++++++++---------
src/cpu/cpu_map.h | 22 ++---
src/cpu/cpu_ppc64.c | 112 ++++++-------------------
src/cpu/cpu_x86.c | 196 +++++++++++++-------------------------------
4 files changed, 143 insertions(+), 285 deletions(-)
diff --git a/src/cpu/cpu_map.c b/src/cpu/cpu_map.c
index 333c7ef24f..ac7e58037a 100644
--- a/src/cpu/cpu_map.c
+++ b/src/cpu/cpu_map.c
@@ -35,31 +35,47 @@
VIR_LOG_INIT("cpu.cpu_map");
-VIR_ENUM_IMPL(cpuMapElement, CPU_MAP_ELEMENT_LAST,
- "vendor",
- "feature",
- "model")
-
-
-static int load(xmlXPathContextPtr ctxt,
- cpuMapElement element,
- cpuMapLoadCallback callback,
- void *data)
+static int
+loadData(const char *mapfile,
+ xmlXPathContextPtr ctxt,
+ const char *element,
+ cpuMapLoadCallback callback,
+ void *data)
{
int ret = -1;
xmlNodePtr ctxt_node;
xmlNodePtr *nodes = NULL;
int n;
+ size_t i;
+ int rv;
ctxt_node = ctxt->node;
- n = virXPathNodeSet(cpuMapElementTypeToString(element), ctxt, &nodes);
- if (n < 0)
+ if ((n = virXPathNodeSet(element, ctxt, &nodes)) < 0)
goto cleanup;
- if (n > 0 &&
- callback(element, ctxt, nodes, n, data) < 0)
+ if (n > 0 && !callback) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected element '%s' in CPU map '%s'"), element, mapfile);
goto cleanup;
+ }
+
+ for (i = 0; i < n; i++) {
+ xmlNodePtr old = ctxt->node;
+ char *name = virXMLPropString(nodes[i], "name");
+ if (!name) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("cannot find %s name in CPU map '%s'"), element, mapfile);
+ goto cleanup;
+ }
+ VIR_DEBUG("Load %s name %s", element, name);
+ ctxt->node = nodes[i];
+ rv = callback(ctxt, name, data);
+ ctxt->node = old;
+ VIR_FREE(name);
+ if (rv < 0)
+ goto cleanup;
+ }
ret = 0;
@@ -72,13 +88,14 @@ static int load(xmlXPathContextPtr ctxt,
static int
cpuMapLoadInclude(const char *filename,
- cpuMapLoadCallback cb,
+ cpuMapLoadCallback vendorCB,
+ cpuMapLoadCallback featureCB,
+ cpuMapLoadCallback modelCB,
void *data)
{
xmlDocPtr xml = NULL;
xmlXPathContextPtr ctxt = NULL;
int ret = -1;
- int element;
char *mapfile;
if (!(mapfile = virFileFindResource(filename,
@@ -93,13 +110,14 @@ cpuMapLoadInclude(const char *filename,
ctxt->node = xmlDocGetRootElement(xml);
- for (element = 0; element < CPU_MAP_ELEMENT_LAST; element++) {
- if (load(ctxt, element, cb, data) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("cannot parse CPU map '%s'"), mapfile);
- goto cleanup;
- }
- }
+ if (loadData(mapfile, ctxt, "vendor", vendorCB, data) < 0)
+ goto cleanup;
+
+ if (loadData(mapfile, ctxt, "feature", featureCB, data) < 0)
+ goto cleanup;
+
+ if (loadData(mapfile, ctxt, "model", modelCB, data) < 0)
+ goto cleanup;
ret = 0;
@@ -114,7 +132,9 @@ cpuMapLoadInclude(const char *filename,
static int
loadIncludes(xmlXPathContextPtr ctxt,
- cpuMapLoadCallback callback,
+ cpuMapLoadCallback vendorCB,
+ cpuMapLoadCallback featureCB,
+ cpuMapLoadCallback modelCB,
void *data)
{
int ret = -1;
@@ -137,7 +157,7 @@ loadIncludes(xmlXPathContextPtr ctxt,
goto cleanup;
}
VIR_DEBUG("Finding CPU map include '%s'", filename);
- if (cpuMapLoadInclude(filename, callback, data) < 0) {
+ if (cpuMapLoadInclude(filename, vendorCB, featureCB, modelCB, data) < 0) {
VIR_FREE(filename);
goto cleanup;
}
@@ -155,7 +175,9 @@ loadIncludes(xmlXPathContextPtr ctxt,
int cpuMapLoad(const char *arch,
- cpuMapLoadCallback cb,
+ cpuMapLoadCallback vendorCB,
+ cpuMapLoadCallback featureCB,
+ cpuMapLoadCallback modelCB,
void *data)
{
xmlDocPtr xml = NULL;
@@ -163,7 +185,6 @@ int cpuMapLoad(const char *arch,
virBuffer buf = VIR_BUFFER_INITIALIZER;
char *xpath = NULL;
int ret = -1;
- int element;
char *mapfile;
if (!(mapfile = virFileFindResource("cpu_map.xml",
@@ -179,12 +200,6 @@ int cpuMapLoad(const char *arch,
goto cleanup;
}
- if (cb == NULL) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("no callback provided"));
- goto cleanup;
- }
-
if (!(xml = virXMLParseFileCtxt(mapfile, &ctxt)))
goto cleanup;
@@ -202,15 +217,16 @@ int cpuMapLoad(const char *arch,
goto cleanup;
}
- for (element = 0; element < CPU_MAP_ELEMENT_LAST; element++) {
- if (load(ctxt, element, cb, data) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("cannot parse CPU map '%s'"), mapfile);
- goto cleanup;
- }
- }
+ if (loadData(mapfile, ctxt, "vendor", vendorCB, data) < 0)
+ goto cleanup;
- if (loadIncludes(ctxt, cb, data) < 0)
+ if (loadData(mapfile, ctxt, "feature", featureCB, data) < 0)
+ goto cleanup;
+
+ if (loadData(mapfile, ctxt, "model", modelCB, data) < 0)
+ goto cleanup;
+
+ if (loadIncludes(ctxt, vendorCB, featureCB, modelCB, data) < 0)
goto cleanup;
ret = 0;
diff --git a/src/cpu/cpu_map.h b/src/cpu/cpu_map.h
index 0c7507e98f..4596987150 100644
--- a/src/cpu/cpu_map.h
+++ b/src/cpu/cpu_map.h
@@ -26,28 +26,16 @@
# include "virxml.h"
-
-typedef enum {
- CPU_MAP_ELEMENT_VENDOR,
- CPU_MAP_ELEMENT_FEATURE,
- CPU_MAP_ELEMENT_MODEL,
-
- CPU_MAP_ELEMENT_LAST
-} cpuMapElement;
-
-VIR_ENUM_DECL(cpuMapElement)
-
-
typedef int
-(*cpuMapLoadCallback) (cpuMapElement element,
- xmlXPathContextPtr ctxt,
- xmlNodePtr *nodes,
- int n,
+(*cpuMapLoadCallback) (xmlXPathContextPtr ctxt,
+ const char *name,
void *data);
int
cpuMapLoad(const char *arch,
- cpuMapLoadCallback cb,
+ cpuMapLoadCallback vendorCB,
+ cpuMapLoadCallback featureCB,
+ cpuMapLoadCallback modelCB,
void *data);
#endif /* __VIR_CPU_MAP_H__ */
diff --git a/src/cpu/cpu_ppc64.c b/src/cpu/cpu_ppc64.c
index d562677fa3..75da5b77d8 100644
--- a/src/cpu/cpu_ppc64.c
+++ b/src/cpu/cpu_ppc64.c
@@ -281,21 +281,19 @@ ppc64MapFree(struct ppc64_map *map)
VIR_FREE(map);
}
-static struct ppc64_vendor *
-ppc64VendorParse(xmlXPathContextPtr ctxt,
- struct ppc64_map *map)
+static int
+ppc64VendorParse(xmlXPathContextPtr ctxt ATTRIBUTE_UNUSED,
+ const char *name,
+ void *data)
{
+ struct ppc64_map *map = data;
struct ppc64_vendor *vendor;
if (VIR_ALLOC(vendor) < 0)
- return NULL;
+ return -1;
- vendor->name = virXPathString("string(@name)", ctxt);
- if (!vendor->name) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("Missing CPU vendor name"));
+ if (VIR_STRDUP(vendor->name, name) < 0)
goto error;
- }
if (ppc64VendorFind(map, vendor->name)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -303,57 +301,36 @@ ppc64VendorParse(xmlXPathContextPtr ctxt,
goto error;
}
- return vendor;
+ if (VIR_APPEND_ELEMENT(map->vendors, map->nvendors, vendor) < 0)
+ goto error;
+
+ return 0;
error:
ppc64VendorFree(vendor);
- return NULL;
+ return -1;
}
static int
-ppc64VendorsLoad(struct ppc64_map *map,
- xmlXPathContextPtr ctxt,
- xmlNodePtr *nodes,
- int n)
-{
- struct ppc64_vendor *vendor;
- size_t i;
-
- if (VIR_ALLOC_N(map->vendors, n) < 0)
- return -1;
-
- for (i = 0; i < n; i++) {
- ctxt->node = nodes[i];
- if (!(vendor = ppc64VendorParse(ctxt, map)))
- return -1;
- map->vendors[map->nvendors++] = vendor;
- }
-
- return 0;
-}
-
-
-static struct ppc64_model *
ppc64ModelParse(xmlXPathContextPtr ctxt,
- struct ppc64_map *map)
+ const char *name,
+ void *data)
{
+ struct ppc64_map *map = data;
struct ppc64_model *model;
xmlNodePtr *nodes = NULL;
char *vendor = NULL;
unsigned long pvr;
size_t i;
int n;
+ int ret = -1;
if (VIR_ALLOC(model) < 0)
goto error;
- model->name = virXPathString("string(@name)", ctxt);
- if (!model->name) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("Missing CPU model name"));
+ if (VIR_STRDUP(model->name, name) < 0)
goto error;
- }
if (ppc64ModelFind(map, model->name)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -410,63 +387,22 @@ ppc64ModelParse(xmlXPathContextPtr ctxt,
model->data.pvr[i].mask = pvr;
}
+ if (VIR_APPEND_ELEMENT(map->models, map->nmodels, model) < 0)
+ goto error;
+
+ ret = 0;
+
cleanup:
VIR_FREE(vendor);
VIR_FREE(nodes);
- return model;
+ return ret;
error:
ppc64ModelFree(model);
- model = NULL;
goto cleanup;
}
-static int
-ppc64ModelsLoad(struct ppc64_map *map,
- xmlXPathContextPtr ctxt,
- xmlNodePtr *nodes,
- int n)
-{
- struct ppc64_model *model;
- size_t i;
-
- if (VIR_ALLOC_N(map->models, n) < 0)
- return -1;
-
- for (i = 0; i < n; i++) {
- ctxt->node = nodes[i];
- if (!(model = ppc64ModelParse(ctxt, map)))
- return -1;
- map->models[map->nmodels++] = model;
- }
-
- return 0;
-}
-
-
-static int
-ppc64MapLoadCallback(cpuMapElement element,
- xmlXPathContextPtr ctxt,
- xmlNodePtr *nodes,
- int n,
- void *data)
-{
- struct ppc64_map *map = data;
-
- switch (element) {
- case CPU_MAP_ELEMENT_VENDOR:
- return ppc64VendorsLoad(map, ctxt, nodes, n);
- case CPU_MAP_ELEMENT_MODEL:
- return ppc64ModelsLoad(map, ctxt, nodes, n);
- case CPU_MAP_ELEMENT_FEATURE:
- case CPU_MAP_ELEMENT_LAST:
- break;
- }
-
- return 0;
-}
-
static struct ppc64_map *
ppc64LoadMap(void)
{
@@ -475,7 +411,7 @@ ppc64LoadMap(void)
if (VIR_ALLOC(map) < 0)
goto error;
- if (cpuMapLoad("ppc64", ppc64MapLoadCallback, map) < 0)
+ if (cpuMapLoad("ppc64", ppc64VendorParse, NULL, ppc64ModelParse, map) < 0)
goto error;
return map;
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 124aa5fd5e..11dbd1e757 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -720,22 +720,21 @@ x86VendorFind(virCPUx86MapPtr map,
}
-static virCPUx86VendorPtr
+static int
x86VendorParse(xmlXPathContextPtr ctxt,
- virCPUx86MapPtr map)
+ const char *name,
+ void *data)
{
+ virCPUx86MapPtr map = data;
virCPUx86VendorPtr vendor = NULL;
char *string = NULL;
+ int ret = -1;
if (VIR_ALLOC(vendor) < 0)
goto error;
- vendor->name = virXPathString("string(@name)", ctxt);
- if (!vendor->name) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Missing CPU vendor name"));
+ if (VIR_STRDUP(vendor->name, name) < 0)
goto error;
- }
if (x86VendorFind(map, vendor->name)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -754,40 +753,21 @@ x86VendorParse(xmlXPathContextPtr ctxt,
if (virCPUx86VendorToCPUID(string, &vendor->cpuid) < 0)
goto error;
+ if (VIR_APPEND_ELEMENT(map->vendors, map->nvendors, vendor) < 0)
+ goto error;
+
+ ret = 0;
+
cleanup:
VIR_FREE(string);
- return vendor;
+ return ret;
error:
x86VendorFree(vendor);
- vendor = NULL;
goto cleanup;
}
-static int
-x86VendorsLoad(virCPUx86MapPtr map,
- xmlXPathContextPtr ctxt,
- xmlNodePtr *nodes,
- int n)
-{
- virCPUx86VendorPtr vendor;
- size_t i;
-
- if (VIR_ALLOC_N(map->vendors, n) < 0)
- return -1;
-
- for (i = 0; i < n; i++) {
- ctxt->node = nodes[i];
- if (!(vendor = x86VendorParse(ctxt, map)))
- return -1;
- map->vendors[map->nvendors++] = vendor;
- }
-
- return 0;
-}
-
-
static virCPUx86FeaturePtr
x86FeatureNew(void)
{
@@ -909,27 +889,27 @@ x86ParseCPUID(xmlXPathContextPtr ctxt,
}
-static virCPUx86FeaturePtr
+static int
x86FeatureParse(xmlXPathContextPtr ctxt,
- virCPUx86MapPtr map)
+ const char *name,
+ void *data)
{
+ virCPUx86MapPtr map = data;
xmlNodePtr *nodes = NULL;
virCPUx86FeaturePtr feature;
virCPUx86CPUID cpuid;
size_t i;
int n;
char *str = NULL;
+ int ret = -1;
if (!(feature = x86FeatureNew()))
goto error;
feature->migratable = true;
- feature->name = virXPathString("string(@name)", ctxt);
- if (!feature->name) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("Missing CPU feature name"));
+
+ if (VIR_STRDUP(feature->name, name) < 0)
goto error;
- }
if (x86FeatureFind(map, feature->name)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -957,46 +937,28 @@ x86FeatureParse(xmlXPathContextPtr ctxt,
goto error;
}
+ if (!feature->migratable &&
+ VIR_APPEND_ELEMENT_COPY(map->migrate_blockers,
+ map->nblockers,
+ feature) < 0)
+ goto error;
+
+ if (VIR_APPEND_ELEMENT(map->features, map->nfeatures, feature) < 0)
+ goto error;
+
+ ret = 0;
+
cleanup:
VIR_FREE(nodes);
VIR_FREE(str);
- return feature;
+ return ret;
error:
x86FeatureFree(feature);
- feature = NULL;
goto cleanup;
}
-static int
-x86FeaturesLoad(virCPUx86MapPtr map,
- xmlXPathContextPtr ctxt,
- xmlNodePtr *nodes,
- int n)
-{
- virCPUx86FeaturePtr feature;
- size_t i;
-
- if (VIR_ALLOC_N(map->features, n) < 0)
- return -1;
-
- for (i = 0; i < n; i++) {
- ctxt->node = nodes[i];
- if (!(feature = x86FeatureParse(ctxt, map)))
- return -1;
- map->features[map->nfeatures++] = feature;
- if (!feature->migratable &&
- VIR_APPEND_ELEMENT(map->migrate_blockers,
- map->nblockers,
- feature) < 0)
- return -1;
- }
-
- return 0;
-}
-
-
static virCPUx86ModelPtr
x86ModelNew(void)
{
@@ -1192,47 +1154,46 @@ x86ModelCompare(virCPUx86ModelPtr model1,
}
-static virCPUx86ModelPtr
+static int
x86ModelParse(xmlXPathContextPtr ctxt,
- virCPUx86MapPtr map)
+ const char *name,
+ void *data)
{
+ virCPUx86MapPtr map = data;
xmlNodePtr *nodes = NULL;
virCPUx86ModelPtr model;
char *vendor = NULL;
size_t i;
int n;
+ int ret = -1;
if (!(model = x86ModelNew()))
goto error;
- model->name = virXPathString("string(@name)", ctxt);
- if (!model->name) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("Missing CPU model name"));
+ if (VIR_STRDUP(model->name, name) < 0)
goto error;
- }
if (virXPathNode("./model", ctxt)) {
virCPUx86ModelPtr ancestor;
- char *name;
+ char *anname;
- name = virXPathString("string(./model/@name)", ctxt);
- if (!name) {
+ anname = virXPathString("string(./model/@name)", ctxt);
+ if (!anname) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Missing ancestor's name in CPU model %s"),
model->name);
goto error;
}
- if (!(ancestor = x86ModelFind(map, name))) {
+ if (!(ancestor = x86ModelFind(map, anname))) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Ancestor model %s not found for CPU model %s"),
- name, model->name);
- VIR_FREE(name);
+ anname, model->name);
+ VIR_FREE(anname);
goto error;
}
- VIR_FREE(name);
+ VIR_FREE(anname);
model->vendor = ancestor->vendor;
model->signature = ancestor->signature;
@@ -1287,62 +1248,43 @@ x86ModelParse(xmlXPathContextPtr ctxt,
for (i = 0; i < n; i++) {
virCPUx86FeaturePtr feature;
- char *name;
+ char *ftname;
- if (!(name = virXMLPropString(nodes[i], "name"))) {
+ if (!(ftname = virXMLPropString(nodes[i], "name"))) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Missing feature name for CPU model %s"), model->name);
goto error;
}
- if (!(feature = x86FeatureFind(map, name))) {
+ if (!(feature = x86FeatureFind(map, ftname))) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Feature %s required by CPU model %s not found"),
- name, model->name);
- VIR_FREE(name);
+ ftname, model->name);
+ VIR_FREE(ftname);
goto error;
}
- VIR_FREE(name);
+ VIR_FREE(ftname);
if (x86DataAdd(&model->data, &feature->data))
goto error;
}
+ if (VIR_APPEND_ELEMENT(map->models, map->nmodels, model) < 0)
+ goto error;
+
+ ret = 0;
+
cleanup:
VIR_FREE(vendor);
VIR_FREE(nodes);
- return model;
+ return ret;
error:
x86ModelFree(model);
- model = NULL;
goto cleanup;
}
-static int
-x86ModelsLoad(virCPUx86MapPtr map,
- xmlXPathContextPtr ctxt,
- xmlNodePtr *nodes,
- int n)
-{
- virCPUx86ModelPtr model;
- size_t i;
-
- if (VIR_ALLOC_N(map->models, n) < 0)
- return -1;
-
- for (i = 0; i < n; i++) {
- ctxt->node = nodes[i];
- if (!(model = x86ModelParse(ctxt, map)))
- return -1;
- map->models[map->nmodels++] = model;
- }
-
- return 0;
-}
-
-
static void
x86MapFree(virCPUx86MapPtr map)
{
@@ -1372,30 +1314,6 @@ x86MapFree(virCPUx86MapPtr map)
}
-static int
-x86MapLoadCallback(cpuMapElement element,
- xmlXPathContextPtr ctxt,
- xmlNodePtr *nodes,
- int n,
- void *data)
-{
- virCPUx86MapPtr map = data;
-
- switch (element) {
- case CPU_MAP_ELEMENT_VENDOR:
- return x86VendorsLoad(map, ctxt, nodes, n);
- case CPU_MAP_ELEMENT_FEATURE:
- return x86FeaturesLoad(map, ctxt, nodes, n);
- case CPU_MAP_ELEMENT_MODEL:
- return x86ModelsLoad(map, ctxt, nodes, n);
- case CPU_MAP_ELEMENT_LAST:
- break;
- }
-
- return 0;
-}
-
-
static virCPUx86MapPtr
virCPUx86LoadMap(void)
{
@@ -1404,7 +1322,7 @@ virCPUx86LoadMap(void)
if (VIR_ALLOC(map) < 0)
return NULL;
- if (cpuMapLoad("x86", x86MapLoadCallback, map) < 0)
+ if (cpuMapLoad("x86", x86VendorParse, x86FeatureParse, x86ModelParse, map) < 0)
goto error;
return map;
--
2.22.0

View File

@ -0,0 +1,397 @@
From 85d367abe6063225117cc27c85e01e36a7b70409 Mon Sep 17 00:00:00 2001
Message-Id: <85d367abe6063225117cc27c85e01e36a7b70409@dist-git>
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= <berrange@redhat.com>
Date: Fri, 21 Jun 2019 09:24:47 +0200
Subject: [PATCH] cpu: simplify failure cleanup paths
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Get rid of the separate 'error:' label, so all code paths jump straight
to the 'cleanup:' label.
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
(cherry picked from commit 18cab54c3a0bc72390f29300684396690a7ecf51)
https://bugzilla.redhat.com/show_bug.cgi?id=1686895
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <40ff4abfea153cf8210286a84967c3ca7850b775.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_ppc64.c | 38 ++++++++++++------------
src/cpu/cpu_x86.c | 71 ++++++++++++++++++++-------------------------
2 files changed, 49 insertions(+), 60 deletions(-)
diff --git a/src/cpu/cpu_ppc64.c b/src/cpu/cpu_ppc64.c
index 75da5b77d8..fcba7e9b37 100644
--- a/src/cpu/cpu_ppc64.c
+++ b/src/cpu/cpu_ppc64.c
@@ -288,27 +288,28 @@ ppc64VendorParse(xmlXPathContextPtr ctxt ATTRIBUTE_UNUSED,
{
struct ppc64_map *map = data;
struct ppc64_vendor *vendor;
+ int ret = -1;
if (VIR_ALLOC(vendor) < 0)
return -1;
if (VIR_STRDUP(vendor->name, name) < 0)
- goto error;
+ goto cleanup;
if (ppc64VendorFind(map, vendor->name)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("CPU vendor %s already defined"), vendor->name);
- goto error;
+ goto cleanup;
}
if (VIR_APPEND_ELEMENT(map->vendors, map->nvendors, vendor) < 0)
- goto error;
+ goto cleanup;
- return 0;
+ ret = 0;
- error:
+ cleanup:
ppc64VendorFree(vendor);
- return -1;
+ return ret;
}
@@ -327,15 +328,15 @@ ppc64ModelParse(xmlXPathContextPtr ctxt,
int ret = -1;
if (VIR_ALLOC(model) < 0)
- goto error;
+ goto cleanup;
if (VIR_STRDUP(model->name, name) < 0)
- goto error;
+ goto cleanup;
if (ppc64ModelFind(map, model->name)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("CPU model %s already defined"), model->name);
- goto error;
+ goto cleanup;
}
if (virXPathBoolean("boolean(./vendor)", ctxt)) {
@@ -344,14 +345,14 @@ ppc64ModelParse(xmlXPathContextPtr ctxt,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Invalid vendor element in CPU model %s"),
model->name);
- goto error;
+ goto cleanup;
}
if (!(model->vendor = ppc64VendorFind(map, vendor))) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unknown vendor %s referenced by CPU model %s"),
vendor, model->name);
- goto error;
+ goto cleanup;
}
}
@@ -359,11 +360,11 @@ ppc64ModelParse(xmlXPathContextPtr ctxt,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Missing PVR information for CPU model %s"),
model->name);
- goto error;
+ goto cleanup;
}
if (VIR_ALLOC_N(model->data.pvr, n) < 0)
- goto error;
+ goto cleanup;
model->data.len = n;
@@ -374,7 +375,7 @@ ppc64ModelParse(xmlXPathContextPtr ctxt,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Missing or invalid PVR value in CPU model %s"),
model->name);
- goto error;
+ goto cleanup;
}
model->data.pvr[i].value = pvr;
@@ -382,24 +383,21 @@ ppc64ModelParse(xmlXPathContextPtr ctxt,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Missing or invalid PVR mask in CPU model %s"),
model->name);
- goto error;
+ goto cleanup;
}
model->data.pvr[i].mask = pvr;
}
if (VIR_APPEND_ELEMENT(map->models, map->nmodels, model) < 0)
- goto error;
+ goto cleanup;
ret = 0;
cleanup:
+ ppc64ModelFree(model);
VIR_FREE(vendor);
VIR_FREE(nodes);
return ret;
-
- error:
- ppc64ModelFree(model);
- goto cleanup;
}
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 11dbd1e757..ce48ca6867 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -731,15 +731,15 @@ x86VendorParse(xmlXPathContextPtr ctxt,
int ret = -1;
if (VIR_ALLOC(vendor) < 0)
- goto error;
+ goto cleanup;
if (VIR_STRDUP(vendor->name, name) < 0)
- goto error;
+ goto cleanup;
if (x86VendorFind(map, vendor->name)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("CPU vendor %s already defined"), vendor->name);
- goto error;
+ goto cleanup;
}
string = virXPathString("string(@string)", ctxt);
@@ -747,24 +747,21 @@ x86VendorParse(xmlXPathContextPtr ctxt,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Missing vendor string for CPU vendor %s"),
vendor->name);
- goto error;
+ goto cleanup;
}
if (virCPUx86VendorToCPUID(string, &vendor->cpuid) < 0)
- goto error;
+ goto cleanup;
if (VIR_APPEND_ELEMENT(map->vendors, map->nvendors, vendor) < 0)
- goto error;
+ goto cleanup;
ret = 0;
cleanup:
+ x86VendorFree(vendor);
VIR_FREE(string);
return ret;
-
- error:
- x86VendorFree(vendor);
- goto cleanup;
}
@@ -904,17 +901,17 @@ x86FeatureParse(xmlXPathContextPtr ctxt,
int ret = -1;
if (!(feature = x86FeatureNew()))
- goto error;
+ goto cleanup;
feature->migratable = true;
if (VIR_STRDUP(feature->name, name) < 0)
- goto error;
+ goto cleanup;
if (x86FeatureFind(map, feature->name)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("CPU feature %s already defined"), feature->name);
- goto error;
+ goto cleanup;
}
str = virXPathString("string(@migratable)", ctxt);
@@ -923,7 +920,7 @@ x86FeatureParse(xmlXPathContextPtr ctxt,
n = virXPathNodeSet("./cpuid", ctxt, &nodes);
if (n < 0)
- goto error;
+ goto cleanup;
for (i = 0; i < n; i++) {
ctxt->node = nodes[i];
@@ -931,31 +928,28 @@ x86FeatureParse(xmlXPathContextPtr ctxt,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Invalid cpuid[%zu] in %s feature"),
i, feature->name);
- goto error;
+ goto cleanup;
}
if (virCPUx86DataAddCPUIDInt(&feature->data, &cpuid))
- goto error;
+ goto cleanup;
}
if (!feature->migratable &&
VIR_APPEND_ELEMENT_COPY(map->migrate_blockers,
map->nblockers,
feature) < 0)
- goto error;
+ goto cleanup;
if (VIR_APPEND_ELEMENT(map->features, map->nfeatures, feature) < 0)
- goto error;
+ goto cleanup;
ret = 0;
cleanup:
+ x86FeatureFree(feature);
VIR_FREE(nodes);
VIR_FREE(str);
return ret;
-
- error:
- x86FeatureFree(feature);
- goto cleanup;
}
@@ -1168,10 +1162,10 @@ x86ModelParse(xmlXPathContextPtr ctxt,
int ret = -1;
if (!(model = x86ModelNew()))
- goto error;
+ goto cleanup;
if (VIR_STRDUP(model->name, name) < 0)
- goto error;
+ goto cleanup;
if (virXPathNode("./model", ctxt)) {
virCPUx86ModelPtr ancestor;
@@ -1182,7 +1176,7 @@ x86ModelParse(xmlXPathContextPtr ctxt,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Missing ancestor's name in CPU model %s"),
model->name);
- goto error;
+ goto cleanup;
}
if (!(ancestor = x86ModelFind(map, anname))) {
@@ -1190,7 +1184,7 @@ x86ModelParse(xmlXPathContextPtr ctxt,
_("Ancestor model %s not found for CPU model %s"),
anname, model->name);
VIR_FREE(anname);
- goto error;
+ goto cleanup;
}
VIR_FREE(anname);
@@ -1198,7 +1192,7 @@ x86ModelParse(xmlXPathContextPtr ctxt,
model->vendor = ancestor->vendor;
model->signature = ancestor->signature;
if (x86DataCopy(&model->data, &ancestor->data) < 0)
- goto error;
+ goto cleanup;
}
if (virXPathBoolean("boolean(./signature)", ctxt)) {
@@ -1211,7 +1205,7 @@ x86ModelParse(xmlXPathContextPtr ctxt,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Invalid CPU signature family in model %s"),
model->name);
- goto error;
+ goto cleanup;
}
rc = virXPathUInt("string(./signature/@model)", ctxt, &sigModel);
@@ -1219,7 +1213,7 @@ x86ModelParse(xmlXPathContextPtr ctxt,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Invalid CPU signature model in model %s"),
model->name);
- goto error;
+ goto cleanup;
}
model->signature = x86MakeSignature(sigFamily, sigModel, 0);
@@ -1231,20 +1225,20 @@ x86ModelParse(xmlXPathContextPtr ctxt,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Invalid vendor element in CPU model %s"),
model->name);
- goto error;
+ goto cleanup;
}
if (!(model->vendor = x86VendorFind(map, vendor))) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unknown vendor %s referenced by CPU model %s"),
vendor, model->name);
- goto error;
+ goto cleanup;
}
}
n = virXPathNodeSet("./feature", ctxt, &nodes);
if (n < 0)
- goto error;
+ goto cleanup;
for (i = 0; i < n; i++) {
virCPUx86FeaturePtr feature;
@@ -1253,7 +1247,7 @@ x86ModelParse(xmlXPathContextPtr ctxt,
if (!(ftname = virXMLPropString(nodes[i], "name"))) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Missing feature name for CPU model %s"), model->name);
- goto error;
+ goto cleanup;
}
if (!(feature = x86FeatureFind(map, ftname))) {
@@ -1261,27 +1255,24 @@ x86ModelParse(xmlXPathContextPtr ctxt,
_("Feature %s required by CPU model %s not found"),
ftname, model->name);
VIR_FREE(ftname);
- goto error;
+ goto cleanup;
}
VIR_FREE(ftname);
if (x86DataAdd(&model->data, &feature->data))
- goto error;
+ goto cleanup;
}
if (VIR_APPEND_ELEMENT(map->models, map->nmodels, model) < 0)
- goto error;
+ goto cleanup;
ret = 0;
cleanup:
+ x86ModelFree(model);
VIR_FREE(vendor);
VIR_FREE(nodes);
return ret;
-
- error:
- x86ModelFree(model);
- goto cleanup;
}
--
2.22.0

View File

@ -0,0 +1,91 @@
From 296ff8fbba31a8052bdf24e409b0bb9e3c041c8f Mon Sep 17 00:00:00 2001
Message-Id: <296ff8fbba31a8052bdf24e409b0bb9e3c041c8f@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:25:46 +0200
Subject: [PATCH] cpu_conf: Introduce virCPUDefFilterFeatures
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This new internal API can be used for in place filtering of CPU features
in virCPUDef.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit c145b660b8225f73db16660461077ef931730939)
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <b3bd18c6e9cdf5256a7369bd06e5f773e160d9f3.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/conf/cpu_conf.c | 22 ++++++++++++++++++++++
src/conf/cpu_conf.h | 5 +++++
src/libvirt_private.syms | 1 +
3 files changed, 28 insertions(+)
diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
index 43a3ab5dcd..51e2a83eae 100644
--- a/src/conf/cpu_conf.c
+++ b/src/conf/cpu_conf.c
@@ -850,6 +850,28 @@ virCPUDefFindFeature(virCPUDefPtr def,
}
+int
+virCPUDefFilterFeatures(virCPUDefPtr cpu,
+ virCPUDefFeatureFilter filter,
+ void *opaque)
+{
+ size_t i = 0;
+
+ while (i < cpu->nfeatures) {
+ if (filter(cpu->features[i].name, opaque)) {
+ i++;
+ continue;
+ }
+
+ VIR_FREE(cpu->features[i].name);
+ if (VIR_DELETE_ELEMENT_INPLACE(cpu->features, i, cpu->nfeatures) < 0)
+ return -1;
+ }
+
+ return 0;
+}
+
+
bool
virCPUDefIsEqual(virCPUDefPtr src,
virCPUDefPtr dst,
diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h
index 9f2e7ee264..ad25932b9b 100644
--- a/src/conf/cpu_conf.h
+++ b/src/conf/cpu_conf.h
@@ -220,6 +220,11 @@ virCPUFeatureDefPtr
virCPUDefFindFeature(virCPUDefPtr def,
const char *name);
+int
+virCPUDefFilterFeatures(virCPUDefPtr cpu,
+ virCPUDefFeatureFilter filter,
+ void *opaque);
+
virCPUDefPtr *
virCPUDefListParse(const char **xmlCPUs,
unsigned int ncpus,
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 9ebc5384fb..57508de0c1 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -76,6 +76,7 @@ virCPUDefCopy;
virCPUDefCopyModel;
virCPUDefCopyModelFilter;
virCPUDefCopyWithoutModel;
+virCPUDefFilterFeatures;
virCPUDefFindFeature;
virCPUDefFormat;
virCPUDefFormatBuf;
--
2.22.0

View File

@ -0,0 +1,165 @@
From acb2d441abd4b584c40748cbaf4f6f7a376753aa Mon Sep 17 00:00:00 2001
Message-Id: <acb2d441abd4b584c40748cbaf4f6f7a376753aa@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 15 Nov 2019 17:52:32 +0100
Subject: [PATCH] cpu_conf: Pass policy to CPU feature filtering callbacks
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
(cherry picked from commit 668797dc5cb474585609559dbe610e09517e23e6)
https://bugzilla.redhat.com/show_bug.cgi?id=1749672
https://bugzilla.redhat.com/show_bug.cgi?id=1756156
https://bugzilla.redhat.com/show_bug.cgi?id=1721608
Conflicts:
src/cpu/cpu_x86.c
src/qemu/qemu_capabilities.c
- no glib stuff downstream
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <e35cd40bd84f7304288051c24fa0d4581c3d43cb.1573836581.git.jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
---
src/conf/cpu_conf.c | 6 +++---
src/conf/cpu_conf.h | 1 +
src/cpu/cpu_x86.c | 13 ++++++++++++-
src/cpu/cpu_x86.h | 2 ++
src/qemu/qemu_capabilities.c | 1 +
src/qemu/qemu_capabilities.h | 1 +
6 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
index 4cccea9981..d4e3c81145 100644
--- a/src/conf/cpu_conf.c
+++ b/src/conf/cpu_conf.c
@@ -135,7 +135,7 @@ virCPUDefCopyModelFilter(virCPUDefPtr dst,
dst->nfeatures = 0;
for (i = 0; i < src->nfeatures; i++) {
- if (filter && !filter(src->features[i].name, opaque))
+ if (filter && !filter(src->features[i].name, src->features[i].policy, opaque))
continue;
n = dst->nfeatures++;
@@ -858,7 +858,7 @@ virCPUDefFilterFeatures(virCPUDefPtr cpu,
size_t i = 0;
while (i < cpu->nfeatures) {
- if (filter(cpu->features[i].name, opaque)) {
+ if (filter(cpu->features[i].name, cpu->features[i].policy, opaque)) {
i++;
continue;
}
@@ -893,7 +893,7 @@ virCPUDefCheckFeatures(virCPUDefPtr cpu,
*features = NULL;
for (i = 0; i < cpu->nfeatures; i++) {
- if (filter(cpu->features[i].name, opaque)) {
+ if (filter(cpu->features[i].name, cpu->features[i].policy, opaque)) {
if (virStringListAdd(&list, cpu->features[i].name) < 0)
return -1;
n++;
diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h
index cba0ec7c81..687e1b09d2 100644
--- a/src/conf/cpu_conf.h
+++ b/src/conf/cpu_conf.h
@@ -162,6 +162,7 @@ virCPUDefCopyModel(virCPUDefPtr dst,
* Returns true if feature @name should copied, false otherwise.
*/
typedef bool (*virCPUDefFeatureFilter)(const char *name,
+ virCPUFeaturePolicy policy,
void *opaque);
int
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 9104bdbf1e..cf5ef442e7 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -3260,6 +3260,15 @@ virCPUx86ExpandFeatures(virCPUDefPtr cpu)
}
+static bool
+x86FeatureFilterMigratable(const char *name,
+ virCPUFeaturePolicy policy ATTRIBUTE_UNUSED,
+ void *cpu_map)
+{
+ return x86FeatureIsMigratable(name, cpu_map);
+}
+
+
static virCPUDefPtr
virCPUx86CopyMigratable(virCPUDefPtr cpu)
{
@@ -3273,7 +3282,7 @@ virCPUx86CopyMigratable(virCPUDefPtr cpu)
return NULL;
if (virCPUDefCopyModelFilter(copy, cpu, false,
- x86FeatureIsMigratable, map) < 0)
+ x86FeatureFilterMigratable, map) < 0)
goto error;
return copy;
@@ -3408,6 +3417,7 @@ virCPUx86FeatureIsMSR(const char *name)
*/
bool
virCPUx86FeatureFilterSelectMSR(const char *name,
+ virCPUFeaturePolicy policy ATTRIBUTE_UNUSED,
void *opaque ATTRIBUTE_UNUSED)
{
return virCPUx86FeatureIsMSR(name);
@@ -3424,6 +3434,7 @@ virCPUx86FeatureFilterSelectMSR(const char *name,
*/
bool
virCPUx86FeatureFilterDropMSR(const char *name,
+ virCPUFeaturePolicy policy ATTRIBUTE_UNUSED,
void *opaque ATTRIBUTE_UNUSED)
{
return !virCPUx86FeatureIsMSR(name);
diff --git a/src/cpu/cpu_x86.h b/src/cpu/cpu_x86.h
index 5126679985..866fe17e88 100644
--- a/src/cpu/cpu_x86.h
+++ b/src/cpu/cpu_x86.h
@@ -46,9 +46,11 @@ int virCPUx86DataSetVendor(virCPUDataPtr cpuData,
const char *vendor);
bool virCPUx86FeatureFilterSelectMSR(const char *name,
+ virCPUFeaturePolicy policy,
void *opaque);
bool virCPUx86FeatureFilterDropMSR(const char *name,
+ virCPUFeaturePolicy policy,
void *opaque);
#endif /* __VIR_CPU_X86_H__ */
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index fbfe74d45b..c25d8c3e1a 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -2753,6 +2753,7 @@ virQEMUCapsProbeQMPSEVCapabilities(virQEMUCapsPtr qemuCaps,
bool
virQEMUCapsCPUFilterFeatures(const char *name,
+ virCPUFeaturePolicy policy ATTRIBUTE_UNUSED,
void *opaque)
{
virArch *arch = opaque;
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 1767b2ab6c..a4055d5458 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -629,6 +629,7 @@ bool virQEMUCapsGuestIsNative(virArch host,
virArch guest);
bool virQEMUCapsCPUFilterFeatures(const char *name,
+ virCPUFeaturePolicy policy,
void *opaque);
const char *
--
2.24.0

View File

@ -0,0 +1,211 @@
From 6d31e77ae83bb2b29d3bff5bd08742ee4c611e25 Mon Sep 17 00:00:00 2001
Message-Id: <6d31e77ae83bb2b29d3bff5bd08742ee4c611e25@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:25:21 +0200
Subject: [PATCH] cpu_map: Add Cascadelake-Server CPU model
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Introduced in QEMU 3.1.0 by commit
c7a88b52f62b30c04158eeb07f73e3f72221b6a8
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 2878278c74cc450a7e28a3830ed0ceff3126f12f)
https://bugzilla.redhat.com/show_bug.cgi?id=1693433
Conflicts:
src/cpu_map/index.xml
src/cpu_map/x86_Cascadelake-Server.xml
- cpu_map split not backported
tests/domaincapsschemadata/qemu_3.1.0.x86_64.xml
tests/domaincapsschemadata/qemu_4.0.0.x86_64.xml
- test data missing
tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-guest.xml
tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-host.xml
- md-clear feature did not exist at the time of the original
patch, but downstream already has it
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <d99c9ab500eb9a482450ba87dec52f5f3cf03429.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_map.xml | 81 +++++++++++++++++++
.../x86_64-cpuid-Xeon-Platinum-8268-guest.xml | 5 +-
.../x86_64-cpuid-Xeon-Platinum-8268-host.xml | 5 +-
.../x86_64-cpuid-Xeon-Platinum-8268-json.xml | 5 +-
4 files changed, 84 insertions(+), 12 deletions(-)
diff --git a/src/cpu/cpu_map.xml b/src/cpu/cpu_map.xml
index b2eb07b832..9b289556e8 100644
--- a/src/cpu/cpu_map.xml
+++ b/src/cpu/cpu_map.xml
@@ -2193,6 +2193,87 @@
<feature name='xsaveopt'/>
</model>
+ <model name='Cascadelake-Server'>
+ <signature family='6' model='85'/> <!-- 050654 -->
+ <vendor name='Intel'/>
+ <feature name='3dnowprefetch'/>
+ <feature name='abm'/>
+ <feature name='adx'/>
+ <feature name='aes'/>
+ <feature name='apic'/>
+ <feature name='arat'/>
+ <feature name='avx'/>
+ <feature name='avx2'/>
+ <feature name='avx512bw'/>
+ <feature name='avx512cd'/>
+ <feature name='avx512dq'/>
+ <feature name='avx512f'/>
+ <feature name='avx512vl'/>
+ <feature name='avx512vnni'/>
+ <feature name='bmi1'/>
+ <feature name='bmi2'/>
+ <feature name='clflush'/>
+ <feature name='clflushopt'/>
+ <feature name='clwb'/>
+ <feature name='cmov'/>
+ <feature name='cx16'/>
+ <feature name='cx8'/>
+ <feature name='de'/>
+ <feature name='erms'/>
+ <feature name='f16c'/>
+ <feature name='fma'/>
+ <feature name='fpu'/>
+ <feature name='fsgsbase'/>
+ <feature name='fxsr'/>
+ <feature name='hle'/>
+ <feature name='invpcid'/>
+ <feature name='lahf_lm'/>
+ <feature name='lm'/>
+ <feature name='mca'/>
+ <feature name='mce'/>
+ <feature name='mmx'/>
+ <feature name='movbe'/>
+ <feature name='mpx'/>
+ <feature name='msr'/>
+ <feature name='mtrr'/>
+ <feature name='nx'/>
+ <!-- 'ospke' is a dynamic feature and cannot be enabled manually
+ see QEMU's commit 9ccb9784b57 for more details -->
+ <feature name='pae'/>
+ <feature name='pat'/>
+ <feature name='pcid'/>
+ <feature name='pclmuldq'/>
+ <feature name='pdpe1gb'/>
+ <feature name='pge'/>
+ <feature name='pni'/>
+ <feature name='popcnt'/>
+ <feature name='pse'/>
+ <feature name='pse36'/>
+ <feature name='rdrand'/>
+ <feature name='rdseed'/>
+ <feature name='rdtscp'/>
+ <feature name='rtm'/>
+ <feature name='sep'/>
+ <feature name='smap'/>
+ <feature name='smep'/>
+ <feature name='spec-ctrl'/>
+ <feature name='ssbd'/>
+ <feature name='sse'/>
+ <feature name='sse2'/>
+ <feature name='sse4.1'/>
+ <feature name='sse4.2'/>
+ <feature name='ssse3'/>
+ <feature name='syscall'/>
+ <feature name='tsc'/>
+ <feature name='tsc-deadline'/>
+ <feature name='vme'/>
+ <feature name='x2apic'/>
+ <feature name='xgetbv1'/>
+ <feature name='xsave'/>
+ <feature name='xsavec'/>
+ <feature name='xsaveopt'/>
+ </model>
+
<!-- AMD CPUs -->
<model name='athlon'>
<vendor name='AMD'/>
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-guest.xml b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-guest.xml
index 2836481454..c7e8a1fccf 100644
--- a/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-guest.xml
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-guest.xml
@@ -1,5 +1,5 @@
<cpu mode='custom' match='exact'>
- <model fallback='forbid'>Skylake-Server-IBRS</model>
+ <model fallback='forbid'>Cascadelake-Server</model>
<vendor>Intel</vendor>
<feature policy='require' name='ds'/>
<feature policy='require' name='acpi'/>
@@ -20,15 +20,12 @@
<feature policy='require' name='osxsave'/>
<feature policy='require' name='tsc_adjust'/>
<feature policy='require' name='cmt'/>
- <feature policy='require' name='clflushopt'/>
<feature policy='require' name='intel-pt'/>
<feature policy='require' name='pku'/>
<feature policy='require' name='ospke'/>
- <feature policy='require' name='avx512vnni'/>
<feature policy='require' name='md-clear'/>
<feature policy='require' name='stibp'/>
<feature policy='require' name='arch-capabilities'/>
- <feature policy='require' name='ssbd'/>
<feature policy='require' name='xsaves'/>
<feature policy='require' name='mbm_total'/>
<feature policy='require' name='mbm_local'/>
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-host.xml b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-host.xml
index 032d8ffeca..d7482751b4 100644
--- a/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-host.xml
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-host.xml
@@ -1,6 +1,6 @@
<cpu>
<arch>x86_64</arch>
- <model>Skylake-Server-IBRS</model>
+ <model>Cascadelake-Server</model>
<vendor>Intel</vendor>
<feature name='ds'/>
<feature name='acpi'/>
@@ -21,15 +21,12 @@
<feature name='osxsave'/>
<feature name='tsc_adjust'/>
<feature name='cmt'/>
- <feature name='clflushopt'/>
<feature name='intel-pt'/>
<feature name='pku'/>
<feature name='ospke'/>
- <feature name='avx512vnni'/>
<feature name='md-clear'/>
<feature name='stibp'/>
<feature name='arch-capabilities'/>
- <feature name='ssbd'/>
<feature name='xsaves'/>
<feature name='mbm_total'/>
<feature name='mbm_local'/>
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-json.xml b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-json.xml
index 12431de213..b7d12dced7 100644
--- a/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-json.xml
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-json.xml
@@ -1,13 +1,10 @@
<cpu mode='custom' match='exact'>
- <model fallback='forbid'>Skylake-Server-IBRS</model>
+ <model fallback='forbid'>Cascadelake-Server</model>
<vendor>Intel</vendor>
<feature policy='require' name='ss'/>
<feature policy='require' name='hypervisor'/>
<feature policy='require' name='tsc_adjust'/>
- <feature policy='require' name='clflushopt'/>
<feature policy='require' name='umip'/>
<feature policy='require' name='pku'/>
- <feature policy='require' name='avx512vnni'/>
- <feature policy='require' name='ssbd'/>
<feature policy='require' name='xsaves'/>
</cpu>
--
2.22.0

View File

@ -0,0 +1,47 @@
From 06a798d6c6283b7041ec8fd631c1289b6fc1b29c Mon Sep 17 00:00:00 2001
Message-Id: <06a798d6c6283b7041ec8fd631c1289b6fc1b29c@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 13 Dec 2019 14:28:07 +0100
Subject: [PATCH] cpu_map: Add TAA_NO bit for IA32_ARCH_CAPABILITIES MSR
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
CVE-2019-11135
CPUs with TAA_NO bit of IA32_ARCH_CAPABILITIES MSR set to 1 are not
vulnerable to TSX Asynchronous Abort and passing this bit to a guest
may avoid unnecessary mitigations.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 07aaced4e6ea6db8b27f44636f51cafa6f1847a8)
Conflicts:
src/cpu_map/x86_features.xml
- cpu_map is still monolithic downstream
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <0ff574a85f1cc7b53140d41a6a62254bea08a06f.1576243094.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_map.xml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/cpu/cpu_map.xml b/src/cpu/cpu_map.xml
index 7b9f8bb452..c2b3fca47a 100644
--- a/src/cpu/cpu_map.xml
+++ b/src/cpu/cpu_map.xml
@@ -501,6 +501,9 @@
<feature name='mds-no'>
<msr index='0x10a' edx='0x00000000' eax='0x00000020'/>
</feature>
+ <feature name='taa-no'>
+ <msr index='0x10a' edx='0x00000000' eax='0x00000100'/>
+ </feature>
<!-- models -->
<model name='486'>
--
2.24.1

View File

@ -0,0 +1,46 @@
From acc51748038a8074fe3a7c769b101455afd64eb7 Mon Sep 17 00:00:00 2001
Message-Id: <acc51748038a8074fe3a7c769b101455afd64eb7@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 13 Dec 2019 14:28:08 +0100
Subject: [PATCH] cpu_map: Add TSX_CTRL bit for IA32_ARCH_CAPABILITIES MSR
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
CVE-2019-11135
When TSX_CTRL bit of IA32_ARCH_CAPABILITIES MSR is set to 1, the CPU
supports IA32_TSX_CTRL MSR which can be used to disable and/or mask TSX.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit f411b7ef68221e82dec0129aaf2f2a26a8987504)
Conflicts:
src/cpu_map/x86_features.xml
- cpu_map is still monolithic downstream
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <cb4f05c8c84ed910bcd4bceae58f6fd090684031.1576243094.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_map.xml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/cpu/cpu_map.xml b/src/cpu/cpu_map.xml
index c2b3fca47a..9609ce71a7 100644
--- a/src/cpu/cpu_map.xml
+++ b/src/cpu/cpu_map.xml
@@ -501,6 +501,9 @@
<feature name='mds-no'>
<msr index='0x10a' edx='0x00000000' eax='0x00000020'/>
</feature>
+ <feature name='tsx-ctrl'>
+ <msr index='0x10a' edx='0x00000000' eax='0x00000080'/>
+ </feature>
<feature name='taa-no'>
<msr index='0x10a' edx='0x00000000' eax='0x00000100'/>
</feature>
--
2.24.1

View File

@ -0,0 +1,318 @@
From 83a1114820c95f9cd98789b14044a229dcc090a7 Mon Sep 17 00:00:00 2001
Message-Id: <83a1114820c95f9cd98789b14044a229dcc090a7@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:25:07 +0200
Subject: [PATCH] cpu_map: Add hex representation of signatures
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The family/model numbers are nice for humans or for comparing with
/proc/cpuinfo, but sometimes there's a need to see the CPUID
representation of the signature. Let's add it into a comment for each
signature in out cpu_map XMLs as the conversion is not exactly
straightforward.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 61be05a00fd383f11070761fac5ae28272b784dd)
https://bugzilla.redhat.com/show_bug.cgi?id=1686895
Conflicts:
src/cpu/cpu_map.xml
- the cpu_map split was not backported
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <e8e2e0bdf183bec170df5252cf927ff5fbe0ef47.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_map.xml | 62 ++++++++++++++++++++++-----------------------
1 file changed, 31 insertions(+), 31 deletions(-)
diff --git a/src/cpu/cpu_map.xml b/src/cpu/cpu_map.xml
index a9f284fbbe..a5a5290a09 100644
--- a/src/cpu/cpu_map.xml
+++ b/src/cpu/cpu_map.xml
@@ -828,7 +828,7 @@
<!-- Intel CPU models -->
<model name='Conroe'>
- <signature family='6' model='15'/>
+ <signature family='6' model='15'/> <!-- 0006f0 -->
<vendor name='Intel'/>
<feature name='apic'/>
<feature name='clflush'/>
@@ -860,7 +860,7 @@
</model>
<model name='Penryn'>
- <signature family='6' model='23'/>
+ <signature family='6' model='23'/> <!-- 010670 -->
<vendor name='Intel'/>
<feature name='apic'/>
<feature name='clflush'/>
@@ -894,7 +894,7 @@
</model>
<model name='Nehalem'>
- <signature family='6' model='26'/>
+ <signature family='6' model='26'/> <!-- 0106a0 -->
<vendor name='Intel'/>
<feature name='apic'/>
<feature name='clflush'/>
@@ -930,7 +930,7 @@
</model>
<model name='Nehalem-IBRS'>
- <signature family='6' model='26'/>
+ <signature family='6' model='26'/> <!-- 0106a0 -->
<vendor name='Intel'/>
<feature name='apic'/>
<feature name='clflush'/>
@@ -967,7 +967,7 @@
</model>
<model name='Westmere'>
- <signature family='6' model='44'/>
+ <signature family='6' model='44'/> <!-- 0206c0 -->
<vendor name='Intel'/>
<feature name='aes'/>
<feature name='apic'/>
@@ -1004,7 +1004,7 @@
</model>
<model name='Westmere-IBRS'>
- <signature family='6' model='44'/>
+ <signature family='6' model='44'/> <!-- 0206c0 -->
<vendor name='Intel'/>
<feature name='aes'/>
<feature name='apic'/>
@@ -1042,7 +1042,7 @@
</model>
<model name='SandyBridge'>
- <signature family='6' model='42'/>
+ <signature family='6' model='42'/> <!-- 0206a0 -->
<vendor name='Intel'/>
<feature name='aes'/>
<feature name='apic'/>
@@ -1085,7 +1085,7 @@
</model>
<model name='SandyBridge-IBRS'>
- <signature family='6' model='42'/>
+ <signature family='6' model='42'/> <!-- 0206a0 -->
<vendor name='Intel'/>
<feature name='aes'/>
<feature name='apic'/>
@@ -1129,7 +1129,7 @@
</model>
<model name='IvyBridge'>
- <signature family='6' model='58'/>
+ <signature family='6' model='58'/> <!-- 0306a0 -->
<vendor name='Intel'/>
<feature name='aes'/>
<feature name='apic'/>
@@ -1178,7 +1178,7 @@
</model>
<model name='IvyBridge-IBRS'>
- <signature family='6' model='58'/>
+ <signature family='6' model='58'/> <!-- 0306a0 -->
<vendor name='Intel'/>
<feature name='aes'/>
<feature name='apic'/>
@@ -1228,7 +1228,7 @@
</model>
<model name='Haswell-noTSX'>
- <signature family='6' model='60'/>
+ <signature family='6' model='60'/> <!-- 0306c0 -->
<vendor name='Intel'/>
<feature name='aes'/>
<feature name='apic'/>
@@ -1281,7 +1281,7 @@
</model>
<model name='Haswell-noTSX-IBRS'>
- <signature family='6' model='60'/>
+ <signature family='6' model='60'/> <!-- 0306c0 -->
<vendor name='Intel'/>
<feature name='aes'/>
<feature name='apic'/>
@@ -1335,7 +1335,7 @@
</model>
<model name='Haswell'>
- <signature family='6' model='60'/>
+ <signature family='6' model='60'/> <!-- 0306c0 -->
<vendor name='Intel'/>
<feature name='aes'/>
<feature name='apic'/>
@@ -1390,7 +1390,7 @@
</model>
<model name='Haswell-IBRS'>
- <signature family='6' model='60'/>
+ <signature family='6' model='60'/> <!-- 0306c0 -->
<vendor name='Intel'/>
<feature name='aes'/>
<feature name='apic'/>
@@ -1446,7 +1446,7 @@
</model>
<model name='Broadwell-noTSX'>
- <signature family='6' model='61'/>
+ <signature family='6' model='61'/> <!-- 0306d0 -->
<vendor name='Intel'/>
<feature name='3dnowprefetch'/>
<feature name='adx'/>
@@ -1503,7 +1503,7 @@
</model>
<model name='Broadwell-noTSX-IBRS'>
- <signature family='6' model='61'/>
+ <signature family='6' model='61'/> <!-- 0306d0 -->
<vendor name='Intel'/>
<feature name='3dnowprefetch'/>
<feature name='adx'/>
@@ -1561,7 +1561,7 @@
</model>
<model name='Broadwell'>
- <signature family='6' model='61'/>
+ <signature family='6' model='61'/> <!-- 0306d0 -->
<vendor name='Intel'/>
<feature name='3dnowprefetch'/>
<feature name='adx'/>
@@ -1620,7 +1620,7 @@
</model>
<model name='Broadwell-IBRS'>
- <signature family='6' model='61'/>
+ <signature family='6' model='61'/> <!-- 0306d0 -->
<vendor name='Intel'/>
<feature name='3dnowprefetch'/>
<feature name='adx'/>
@@ -1680,7 +1680,7 @@
</model>
<model name='Skylake-Client'>
- <signature family='6' model='94'/>
+ <signature family='6' model='94'/> <!-- 0506e0 -->
<vendor name='Intel'/>
<feature name='3dnowprefetch'/>
<feature name='abm'/>
@@ -1748,7 +1748,7 @@
</model>
<model name='Skylake-Client-IBRS'>
- <signature family='6' model='94'/>
+ <signature family='6' model='94'/> <!-- 0506e0 -->
<vendor name='Intel'/>
<feature name='3dnowprefetch'/>
<feature name='abm'/>
@@ -1817,7 +1817,7 @@
</model>
<model name='Skylake-Server'>
- <signature family='6' model='85'/>
+ <signature family='6' model='85'/> <!-- 050654 -->
<vendor name='Intel'/>
<feature name='3dnowprefetch'/>
<feature name='abm'/>
@@ -1892,7 +1892,7 @@
</model>
<model name='Skylake-Server-IBRS'>
- <signature family='6' model='85'/>
+ <signature family='6' model='85'/> <!-- 050654 -->
<vendor name='Intel'/>
<feature name='3dnowprefetch'/>
<feature name='abm'/>
@@ -1968,7 +1968,7 @@
</model>
<model name='Icelake-Client'>
- <signature family='6' model='126'/>
+ <signature family='6' model='126'/> <!-- 0706e0 -->
<vendor name='Intel'/>
<feature name='3dnowprefetch'/>
<feature name='abm'/>
@@ -2052,7 +2052,7 @@
</model>
<model name='Icelake-Server'>
- <signature family='6' model='134'/>
+ <signature family='6' model='134'/> <!-- 080660 -->
<vendor name='Intel'/>
<feature name='3dnowprefetch'/>
<feature name='abm'/>
@@ -2209,7 +2209,7 @@
</model>
<model name='Opteron_G1'>
- <signature family='15' model='6'/>
+ <signature family='15' model='6'/> <!-- 100e60 -->
<vendor name='AMD'/>
<feature name='apic'/>
<feature name='clflush'/>
@@ -2239,7 +2239,7 @@
</model>
<model name='Opteron_G2'>
- <signature family='15' model='6'/>
+ <signature family='15' model='6'/> <!-- 100e60 -->
<vendor name='AMD'/>
<feature name='apic'/>
<feature name='clflush'/>
@@ -2273,7 +2273,7 @@
</model>
<model name='Opteron_G3'>
- <signature family='15' model='6'/>
+ <signature family='15' model='6'/> <!-- 100e60 -->
<vendor name='AMD'/>
<feature name='abm'/>
<feature name='apic'/>
@@ -2312,7 +2312,7 @@
</model>
<model name='Opteron_G4'>
- <signature family='21' model='1'/>
+ <signature family='21' model='1'/> <!-- 600f10 -->
<vendor name='AMD'/>
<feature name='3dnowprefetch'/>
<feature name='abm'/>
@@ -2361,7 +2361,7 @@
</model>
<model name='Opteron_G5'>
- <signature family='21' model='2'/>
+ <signature family='21' model='2'/> <!-- 600f20 -->
<vendor name='AMD'/>
<feature name='3dnowprefetch'/>
<feature name='abm'/>
@@ -2413,7 +2413,7 @@
</model>
<model name='EPYC'>
- <signature family='23' model='1'/>
+ <signature family='23' model='1'/> <!-- 800f10 -->
<vendor name='AMD'/>
<feature name='3dnowprefetch'/>
<feature name='abm'/>
@@ -2484,7 +2484,7 @@
</model>
<model name='EPYC-IBPB'>
- <signature family='23' model='1'/>
+ <signature family='23' model='1'/> <!-- 800f10 -->
<vendor name='AMD'/>
<feature name='3dnowprefetch'/>
<feature name='abm'/>
--
2.22.0

View File

@ -0,0 +1,254 @@
From 77ad41e460c2e91f2c2e187c80581069654b741d Mon Sep 17 00:00:00 2001
Message-Id: <77ad41e460c2e91f2c2e187c80581069654b741d@dist-git>
From: Jiri Denemark <Jiri.Denemark@gmail.com>
Date: Fri, 21 Jun 2019 09:25:16 +0200
Subject: [PATCH] cpu_map: Add more signatures for Broadwell CPU models
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This fixes several CPUs which were incorrectly detected as
Skylake-Client.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 4ff74a806ad42820eef3877c8ec146770914d8df)
https://bugzilla.redhat.com/show_bug.cgi?id=1686895
Conflicts:
src/cpu_map/x86_Broadwell-IBRS.xml
src/cpu_map/x86_Broadwell-noTSX-IBRS.xml
src/cpu_map/x86_Broadwell-noTSX.xml
src/cpu_map/x86_Broadwell.xml
- cpu_map split not backported
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <543534b544d2d09470c218aeb6c7d945facaf2c8.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_map.xml | 12 ++++++++++++
.../x86_64-cpuid-Xeon-E5-2623-v4-guest.xml | 11 +++++++----
.../x86_64-cpuid-Xeon-E5-2623-v4-json.xml | 11 +++++++----
.../x86_64-cpuid-Xeon-E5-2630-v4-guest.xml | 11 +++++++----
.../x86_64-cpuid-Xeon-E5-2630-v4-json.xml | 11 +++++++----
.../x86_64-cpuid-Xeon-E5-2650-v4-guest.xml | 11 +++++++----
.../x86_64-cpuid-Xeon-E5-2650-v4-json.xml | 11 +++++++----
7 files changed, 54 insertions(+), 24 deletions(-)
diff --git a/src/cpu/cpu_map.xml b/src/cpu/cpu_map.xml
index ed6006643b..04369d1eda 100644
--- a/src/cpu/cpu_map.xml
+++ b/src/cpu/cpu_map.xml
@@ -1473,6 +1473,9 @@
<model name='Broadwell-noTSX'>
<signature family='6' model='61'/> <!-- 0306d0 -->
+ <signature family='6' model='71'/> <!-- 040670 -->
+ <signature family='6' model='79'/> <!-- 0406f0 -->
+ <signature family='6' model='86'/> <!-- 050660 -->
<vendor name='Intel'/>
<feature name='3dnowprefetch'/>
<feature name='adx'/>
@@ -1530,6 +1533,9 @@
<model name='Broadwell-noTSX-IBRS'>
<signature family='6' model='61'/> <!-- 0306d0 -->
+ <signature family='6' model='71'/> <!-- 040670 -->
+ <signature family='6' model='79'/> <!-- 0406f0 -->
+ <signature family='6' model='86'/> <!-- 050660 -->
<vendor name='Intel'/>
<feature name='3dnowprefetch'/>
<feature name='adx'/>
@@ -1588,6 +1594,9 @@
<model name='Broadwell'>
<signature family='6' model='61'/> <!-- 0306d0 -->
+ <signature family='6' model='71'/> <!-- 040670 -->
+ <signature family='6' model='79'/> <!-- 0406f0 -->
+ <signature family='6' model='86'/> <!-- 050660 -->
<vendor name='Intel'/>
<feature name='3dnowprefetch'/>
<feature name='adx'/>
@@ -1647,6 +1656,9 @@
<model name='Broadwell-IBRS'>
<signature family='6' model='61'/> <!-- 0306d0 -->
+ <signature family='6' model='71'/> <!-- 040670 -->
+ <signature family='6' model='79'/> <!-- 0406f0 -->
+ <signature family='6' model='86'/> <!-- 050660 -->
<vendor name='Intel'/>
<feature name='3dnowprefetch'/>
<feature name='adx'/>
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2623-v4-guest.xml b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2623-v4-guest.xml
index 7718d7ca59..a5c6d9b471 100644
--- a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2623-v4-guest.xml
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2623-v4-guest.xml
@@ -1,6 +1,7 @@
<cpu mode='custom' match='exact'>
- <model fallback='forbid'>Skylake-Client-IBRS</model>
+ <model fallback='forbid'>Broadwell-IBRS</model>
<vendor>Intel</vendor>
+ <feature policy='require' name='vme'/>
<feature policy='require' name='ds'/>
<feature policy='require' name='acpi'/>
<feature policy='require' name='ss'/>
@@ -18,15 +19,17 @@
<feature policy='require' name='pdcm'/>
<feature policy='require' name='dca'/>
<feature policy='require' name='osxsave'/>
+ <feature policy='require' name='f16c'/>
+ <feature policy='require' name='rdrand'/>
+ <feature policy='require' name='arat'/>
<feature policy='require' name='tsc_adjust'/>
<feature policy='require' name='cmt'/>
<feature policy='require' name='intel-pt'/>
<feature policy='require' name='stibp'/>
+ <feature policy='require' name='xsaveopt'/>
<feature policy='require' name='mbm_total'/>
<feature policy='require' name='mbm_local'/>
<feature policy='require' name='pdpe1gb'/>
+ <feature policy='require' name='abm'/>
<feature policy='require' name='invtsc'/>
- <feature policy='disable' name='mpx'/>
- <feature policy='disable' name='xsavec'/>
- <feature policy='disable' name='xgetbv1'/>
</cpu>
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2623-v4-json.xml b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2623-v4-json.xml
index 167a9028ab..de082dbd93 100644
--- a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2623-v4-json.xml
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2623-v4-json.xml
@@ -1,11 +1,14 @@
<cpu mode='custom' match='exact'>
- <model fallback='forbid'>Skylake-Client-IBRS</model>
+ <model fallback='forbid'>Broadwell-IBRS</model>
<vendor>Intel</vendor>
+ <feature policy='require' name='vme'/>
<feature policy='require' name='ss'/>
+ <feature policy='require' name='f16c'/>
+ <feature policy='require' name='rdrand'/>
<feature policy='require' name='hypervisor'/>
+ <feature policy='require' name='arat'/>
<feature policy='require' name='tsc_adjust'/>
+ <feature policy='require' name='xsaveopt'/>
<feature policy='require' name='pdpe1gb'/>
- <feature policy='disable' name='mpx'/>
- <feature policy='disable' name='xsavec'/>
- <feature policy='disable' name='xgetbv1'/>
+ <feature policy='require' name='abm'/>
</cpu>
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-v4-guest.xml b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-v4-guest.xml
index cd7e25b52a..e2999db8e9 100644
--- a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-v4-guest.xml
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-v4-guest.xml
@@ -1,6 +1,7 @@
<cpu mode='custom' match='exact'>
- <model fallback='forbid'>Skylake-Client</model>
+ <model fallback='forbid'>Broadwell</model>
<vendor>Intel</vendor>
+ <feature policy='require' name='vme'/>
<feature policy='require' name='ds'/>
<feature policy='require' name='acpi'/>
<feature policy='require' name='ss'/>
@@ -18,14 +19,16 @@
<feature policy='require' name='pdcm'/>
<feature policy='require' name='dca'/>
<feature policy='require' name='osxsave'/>
+ <feature policy='require' name='f16c'/>
+ <feature policy='require' name='rdrand'/>
+ <feature policy='require' name='arat'/>
<feature policy='require' name='tsc_adjust'/>
<feature policy='require' name='cmt'/>
<feature policy='require' name='intel-pt'/>
+ <feature policy='require' name='xsaveopt'/>
<feature policy='require' name='mbm_total'/>
<feature policy='require' name='mbm_local'/>
<feature policy='require' name='pdpe1gb'/>
+ <feature policy='require' name='abm'/>
<feature policy='require' name='invtsc'/>
- <feature policy='disable' name='mpx'/>
- <feature policy='disable' name='xsavec'/>
- <feature policy='disable' name='xgetbv1'/>
</cpu>
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-v4-json.xml b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-v4-json.xml
index 5dfce947b2..5b8891093a 100644
--- a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-v4-json.xml
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-v4-json.xml
@@ -1,11 +1,14 @@
<cpu mode='custom' match='exact'>
- <model fallback='forbid'>Skylake-Client</model>
+ <model fallback='forbid'>Broadwell</model>
<vendor>Intel</vendor>
+ <feature policy='require' name='vme'/>
<feature policy='require' name='ss'/>
+ <feature policy='require' name='f16c'/>
+ <feature policy='require' name='rdrand'/>
<feature policy='require' name='hypervisor'/>
+ <feature policy='require' name='arat'/>
<feature policy='require' name='tsc_adjust'/>
+ <feature policy='require' name='xsaveopt'/>
<feature policy='require' name='pdpe1gb'/>
- <feature policy='disable' name='mpx'/>
- <feature policy='disable' name='xsavec'/>
- <feature policy='disable' name='xgetbv1'/>
+ <feature policy='require' name='abm'/>
</cpu>
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2650-v4-guest.xml b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2650-v4-guest.xml
index cd7e25b52a..e2999db8e9 100644
--- a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2650-v4-guest.xml
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2650-v4-guest.xml
@@ -1,6 +1,7 @@
<cpu mode='custom' match='exact'>
- <model fallback='forbid'>Skylake-Client</model>
+ <model fallback='forbid'>Broadwell</model>
<vendor>Intel</vendor>
+ <feature policy='require' name='vme'/>
<feature policy='require' name='ds'/>
<feature policy='require' name='acpi'/>
<feature policy='require' name='ss'/>
@@ -18,14 +19,16 @@
<feature policy='require' name='pdcm'/>
<feature policy='require' name='dca'/>
<feature policy='require' name='osxsave'/>
+ <feature policy='require' name='f16c'/>
+ <feature policy='require' name='rdrand'/>
+ <feature policy='require' name='arat'/>
<feature policy='require' name='tsc_adjust'/>
<feature policy='require' name='cmt'/>
<feature policy='require' name='intel-pt'/>
+ <feature policy='require' name='xsaveopt'/>
<feature policy='require' name='mbm_total'/>
<feature policy='require' name='mbm_local'/>
<feature policy='require' name='pdpe1gb'/>
+ <feature policy='require' name='abm'/>
<feature policy='require' name='invtsc'/>
- <feature policy='disable' name='mpx'/>
- <feature policy='disable' name='xsavec'/>
- <feature policy='disable' name='xgetbv1'/>
</cpu>
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2650-v4-json.xml b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2650-v4-json.xml
index 5dfce947b2..5b8891093a 100644
--- a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2650-v4-json.xml
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2650-v4-json.xml
@@ -1,11 +1,14 @@
<cpu mode='custom' match='exact'>
- <model fallback='forbid'>Skylake-Client</model>
+ <model fallback='forbid'>Broadwell</model>
<vendor>Intel</vendor>
+ <feature policy='require' name='vme'/>
<feature policy='require' name='ss'/>
+ <feature policy='require' name='f16c'/>
+ <feature policy='require' name='rdrand'/>
<feature policy='require' name='hypervisor'/>
+ <feature policy='require' name='arat'/>
<feature policy='require' name='tsc_adjust'/>
+ <feature policy='require' name='xsaveopt'/>
<feature policy='require' name='pdpe1gb'/>
- <feature policy='disable' name='mpx'/>
- <feature policy='disable' name='xsavec'/>
- <feature policy='disable' name='xgetbv1'/>
+ <feature policy='require' name='abm'/>
</cpu>
--
2.22.0

View File

@ -0,0 +1,41 @@
From 93520cb5f3b412c8cb4b5cf7098ff4a8c6c819ab Mon Sep 17 00:00:00 2001
Message-Id: <93520cb5f3b412c8cb4b5cf7098ff4a8c6c819ab@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:25:09 +0200
Subject: [PATCH] cpu_map: Add more signatures for Conroe CPU model
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit c1f6a3269c595e7d3d0c9cf31ef7e6cf88291056)
https://bugzilla.redhat.com/show_bug.cgi?id=1686895
Conflicts:
src/cpu_map/x86_Conroe.xml
- cpu_map split not backported
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <bdc4e7ff05e41cf66f69b61c0c622740f710d411.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_map.xml | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/cpu/cpu_map.xml b/src/cpu/cpu_map.xml
index a5a5290a09..1699aec2cf 100644
--- a/src/cpu/cpu_map.xml
+++ b/src/cpu/cpu_map.xml
@@ -829,6 +829,7 @@
<!-- Intel CPU models -->
<model name='Conroe'>
<signature family='6' model='15'/> <!-- 0006f0 -->
+ <signature family='6' model='22'/> <!-- 010660 -->
<vendor name='Intel'/>
<feature name='apic'/>
<feature name='clflush'/>
--
2.22.0

View File

@ -0,0 +1,76 @@
From 41472ea4967eed29a41f619aca9c3d78504d0031 Mon Sep 17 00:00:00 2001
Message-Id: <41472ea4967eed29a41f619aca9c3d78504d0031@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:25:15 +0200
Subject: [PATCH] cpu_map: Add more signatures for Haswell CPU models
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit e58ca588cc0deee36c8ae44f2ad75bf9b1680fc5)
https://bugzilla.redhat.com/show_bug.cgi?id=1686895
Conflicts:
src/cpu_map/x86_Haswell-IBRS.xml
src/cpu_map/x86_Haswell-noTSX-IBRS.xml
src/cpu_map/x86_Haswell-noTSX.xml
src/cpu_map/x86_Haswell.xml
- cpu_map split not backported
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <f2154885afb3bb49b36ae3468b11251c7ebf896f.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_map.xml | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/src/cpu/cpu_map.xml b/src/cpu/cpu_map.xml
index 9bd8bbbfbb..ed6006643b 100644
--- a/src/cpu/cpu_map.xml
+++ b/src/cpu/cpu_map.xml
@@ -1243,6 +1243,9 @@
<model name='Haswell-noTSX'>
<signature family='6' model='60'/> <!-- 0306c0 -->
+ <signature family='6' model='63'/> <!-- 0306f0 -->
+ <signature family='6' model='69'/> <!-- 040650 -->
+ <signature family='6' model='70'/> <!-- 040660 -->
<vendor name='Intel'/>
<feature name='aes'/>
<feature name='apic'/>
@@ -1296,6 +1299,9 @@
<model name='Haswell-noTSX-IBRS'>
<signature family='6' model='60'/> <!-- 0306c0 -->
+ <signature family='6' model='63'/> <!-- 0306f0 -->
+ <signature family='6' model='69'/> <!-- 040650 -->
+ <signature family='6' model='70'/> <!-- 040660 -->
<vendor name='Intel'/>
<feature name='aes'/>
<feature name='apic'/>
@@ -1350,6 +1356,9 @@
<model name='Haswell'>
<signature family='6' model='60'/> <!-- 0306c0 -->
+ <signature family='6' model='63'/> <!-- 0306f0 -->
+ <signature family='6' model='69'/> <!-- 040650 -->
+ <signature family='6' model='70'/> <!-- 040660 -->
<vendor name='Intel'/>
<feature name='aes'/>
<feature name='apic'/>
@@ -1405,6 +1414,9 @@
<model name='Haswell-IBRS'>
<signature family='6' model='60'/> <!-- 0306c0 -->
+ <signature family='6' model='63'/> <!-- 0306f0 -->
+ <signature family='6' model='69'/> <!-- 040650 -->
+ <signature family='6' model='70'/> <!-- 040660 -->
<vendor name='Intel'/>
<feature name='aes'/>
<feature name='apic'/>
--
2.22.0

View File

@ -0,0 +1,50 @@
From 182faff133a2a21d6ce9fb2d2f2a59c10bded7a4 Mon Sep 17 00:00:00 2001
Message-Id: <182faff133a2a21d6ce9fb2d2f2a59c10bded7a4@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:25:14 +0200
Subject: [PATCH] cpu_map: Add more signatures for IvyBridge CPU models
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 194105fef1a3a8645486df3323e460cc4a9b2d4c)
https://bugzilla.redhat.com/show_bug.cgi?id=1686895
Conflicts:
src/cpu_map/x86_IvyBridge-IBRS.xml
src/cpu_map/x86_IvyBridge.xml
- cpu_map split not backported
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <07778daea0841ab2e211311adc90fd04967b2fb3.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_map.xml | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/cpu/cpu_map.xml b/src/cpu/cpu_map.xml
index 9eaba9572c..9bd8bbbfbb 100644
--- a/src/cpu/cpu_map.xml
+++ b/src/cpu/cpu_map.xml
@@ -1142,6 +1142,7 @@
<model name='IvyBridge'>
<signature family='6' model='58'/> <!-- 0306a0 -->
+ <signature family='6' model='62'/> <!-- 0306e0 -->
<vendor name='Intel'/>
<feature name='aes'/>
<feature name='apic'/>
@@ -1191,6 +1192,7 @@
<model name='IvyBridge-IBRS'>
<signature family='6' model='58'/> <!-- 0306a0 -->
+ <signature family='6' model='62'/> <!-- 0306e0 -->
<vendor name='Intel'/>
<feature name='aes'/>
<feature name='apic'/>
--
2.22.0

View File

@ -0,0 +1,54 @@
From 72bcfcf07c76288e943602995308d3e505aa1cff Mon Sep 17 00:00:00 2001
Message-Id: <72bcfcf07c76288e943602995308d3e505aa1cff@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:25:11 +0200
Subject: [PATCH] cpu_map: Add more signatures for Nehalem CPU models
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit f349f3c53f6427d9955ab7c57900c094f06dfd87)
https://bugzilla.redhat.com/show_bug.cgi?id=1686895
Conflicts:
src/cpu_map/x86_Nehalem-IBRS.xml
src/cpu_map/x86_Nehalem.xml
- cpu_map split not backported
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <6351ae62d5ea091e831968cd1fc50176d1552a86.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_map.xml | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/cpu/cpu_map.xml b/src/cpu/cpu_map.xml
index f42b2e629c..4f9c247f3e 100644
--- a/src/cpu/cpu_map.xml
+++ b/src/cpu/cpu_map.xml
@@ -897,6 +897,9 @@
<model name='Nehalem'>
<signature family='6' model='26'/> <!-- 0106a0 -->
+ <signature family='6' model='30'/> <!-- 0106e0 -->
+ <signature family='6' model='31'/> <!-- 0106f0 -->
+ <signature family='6' model='46'/> <!-- 0206e0 -->
<vendor name='Intel'/>
<feature name='apic'/>
<feature name='clflush'/>
@@ -933,6 +936,9 @@
<model name='Nehalem-IBRS'>
<signature family='6' model='26'/> <!-- 0106a0 -->
+ <signature family='6' model='30'/> <!-- 0106e0 -->
+ <signature family='6' model='31'/> <!-- 0106f0 -->
+ <signature family='6' model='46'/> <!-- 0206e0 -->
<vendor name='Intel'/>
<feature name='apic'/>
<feature name='clflush'/>
--
2.22.0

View File

@ -0,0 +1,41 @@
From 4042ef3cf2a0221d4c59a5adc9051ee9ae41aa7d Mon Sep 17 00:00:00 2001
Message-Id: <4042ef3cf2a0221d4c59a5adc9051ee9ae41aa7d@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:25:10 +0200
Subject: [PATCH] cpu_map: Add more signatures for Penryn CPU model
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 0a09e59457f843b53c2702d1936bca6513868320)
https://bugzilla.redhat.com/show_bug.cgi?id=1686895
Conflicts:
src/cpu_map/x86_Penryn.xml
- cpu_map split not backported
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <1604252f9ef65cfb55161a0f8329ee6868926814.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_map.xml | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/cpu/cpu_map.xml b/src/cpu/cpu_map.xml
index 1699aec2cf..f42b2e629c 100644
--- a/src/cpu/cpu_map.xml
+++ b/src/cpu/cpu_map.xml
@@ -862,6 +862,7 @@
<model name='Penryn'>
<signature family='6' model='23'/> <!-- 010670 -->
+ <signature family='6' model='29'/> <!-- 0106d0 -->
<vendor name='Intel'/>
<feature name='apic'/>
<feature name='clflush'/>
--
2.22.0

View File

@ -0,0 +1,50 @@
From 250d216f3f9f033ec39b2116b30c93b37967484c Mon Sep 17 00:00:00 2001
Message-Id: <250d216f3f9f033ec39b2116b30c93b37967484c@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:25:13 +0200
Subject: [PATCH] cpu_map: Add more signatures for SandyBridge CPU models
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 4a3c3682f3da4ae1e1036c67db7ddba3dcc66d68)
https://bugzilla.redhat.com/show_bug.cgi?id=1686895
Conflicts:
src/cpu_map/x86_SandyBridge-IBRS.xml
src/cpu_map/x86_SandyBridge.xml
- cpu_map split not backported
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <521680181b58a762b0d6b3668e0d162fbc5d3cf9.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_map.xml | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/cpu/cpu_map.xml b/src/cpu/cpu_map.xml
index fed0f51934..9eaba9572c 100644
--- a/src/cpu/cpu_map.xml
+++ b/src/cpu/cpu_map.xml
@@ -1053,6 +1053,7 @@
<model name='SandyBridge'>
<signature family='6' model='42'/> <!-- 0206a0 -->
+ <signature family='6' model='45'/> <!-- 0206d0 -->
<vendor name='Intel'/>
<feature name='aes'/>
<feature name='apic'/>
@@ -1096,6 +1097,7 @@
<model name='SandyBridge-IBRS'>
<signature family='6' model='42'/> <!-- 0206a0 -->
+ <signature family='6' model='45'/> <!-- 0206d0 -->
<vendor name='Intel'/>
<feature name='aes'/>
<feature name='apic'/>
--
2.22.0

View File

@ -0,0 +1,58 @@
From f1a00c505aac83fe04f5385db5a9ed4768b0222b Mon Sep 17 00:00:00 2001
Message-Id: <f1a00c505aac83fe04f5385db5a9ed4768b0222b@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:25:17 +0200
Subject: [PATCH] cpu_map: Add more signatures for Skylake-Client CPU models
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 367d96a5d6b04bf25d025ed59a7079d71f843c56)
https://bugzilla.redhat.com/show_bug.cgi?id=1686895
Conflicts:
src/cpu_map/x86_Skylake-Client-IBRS.xml
src/cpu_map/x86_Skylake-Client.xml
- cpu_map split not backported
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <d7ff83903e6d8ae1881afee54d3a248b9bb28678.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_map.xml | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/src/cpu/cpu_map.xml b/src/cpu/cpu_map.xml
index 04369d1eda..b2eb07b832 100644
--- a/src/cpu/cpu_map.xml
+++ b/src/cpu/cpu_map.xml
@@ -1719,6 +1719,11 @@
<model name='Skylake-Client'>
<signature family='6' model='94'/> <!-- 0506e0 -->
+ <signature family='6' model='78'/> <!-- 0406e0 -->
+ <!-- These are Kaby Lake and Coffee Lake successors to Skylake,
+ but we don't have specific models for them. -->
+ <signature family='6' model='142'/> <!-- 0806e0 -->
+ <signature family='6' model='158'/> <!-- 0906e0 -->
<vendor name='Intel'/>
<feature name='3dnowprefetch'/>
<feature name='abm'/>
@@ -1787,6 +1792,11 @@
<model name='Skylake-Client-IBRS'>
<signature family='6' model='94'/> <!-- 0506e0 -->
+ <signature family='6' model='78'/> <!-- 0406e0 -->
+ <!-- These are Kaby Lake and Coffee Lake successors to Skylake,
+ but we don't have specific models for them. -->
+ <signature family='6' model='142'/> <!-- 0806e0 -->
+ <signature family='6' model='158'/> <!-- 0906e0 -->
<vendor name='Intel'/>
<feature name='3dnowprefetch'/>
<feature name='abm'/>
--
2.22.0

View File

@ -0,0 +1,184 @@
From d31a3ba6c9396f8ede2966d49030e9b4011be636 Mon Sep 17 00:00:00 2001
Message-Id: <d31a3ba6c9396f8ede2966d49030e9b4011be636@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:25:12 +0200
Subject: [PATCH] cpu_map: Add more signatures for Westmere CPU model
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This fixes several CPUs which were incorrectly detected as a different
CPU model.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit e89f87721406f6ad6e811ff613a22dc804d69355)
https://bugzilla.redhat.com/show_bug.cgi?id=1686895
Conflicts:
src/cpu_map/x86_Westmere.xml
- cpu_map split not backported
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <facb5fd10ffe274e581e16db8362d0b8ee71424b.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_map.xml | 2 ++
tests/cputestdata/x86_64-cpuid-Core-i5-650-json.xml | 9 +++++----
tests/cputestdata/x86_64-cpuid-Pentium-P6100-guest.xml | 10 ++++++----
tests/cputestdata/x86_64-cpuid-Xeon-E7-4820-guest.xml | 8 ++++----
tests/cputestdata/x86_64-cpuid-Xeon-E7-4820-json.xml | 8 +++++---
tests/cputestdata/x86_64-cpuid-Xeon-E7-4830-json.xml | 9 +++++----
6 files changed, 27 insertions(+), 19 deletions(-)
diff --git a/src/cpu/cpu_map.xml b/src/cpu/cpu_map.xml
index 4f9c247f3e..fed0f51934 100644
--- a/src/cpu/cpu_map.xml
+++ b/src/cpu/cpu_map.xml
@@ -976,6 +976,8 @@
<model name='Westmere'>
<signature family='6' model='44'/> <!-- 0206c0 -->
+ <signature family='6' model='47'/> <!-- 0206f0 -->
+ <signature family='6' model='37'/> <!-- 020650 -->
<vendor name='Intel'/>
<feature name='aes'/>
<feature name='apic'/>
diff --git a/tests/cputestdata/x86_64-cpuid-Core-i5-650-json.xml b/tests/cputestdata/x86_64-cpuid-Core-i5-650-json.xml
index f5980f53e5..cb21e48a9f 100644
--- a/tests/cputestdata/x86_64-cpuid-Core-i5-650-json.xml
+++ b/tests/cputestdata/x86_64-cpuid-Core-i5-650-json.xml
@@ -1,12 +1,13 @@
<cpu mode='custom' match='exact'>
- <model fallback='forbid'>SandyBridge</model>
+ <model fallback='forbid'>Westmere</model>
<vendor>Intel</vendor>
<feature policy='require' name='vme'/>
<feature policy='require' name='ss'/>
+ <feature policy='require' name='pclmuldq'/>
+ <feature policy='require' name='x2apic'/>
+ <feature policy='require' name='tsc-deadline'/>
<feature policy='require' name='hypervisor'/>
<feature policy='require' name='arat'/>
<feature policy='require' name='tsc_adjust'/>
- <feature policy='disable' name='xsave'/>
- <feature policy='disable' name='avx'/>
- <feature policy='disable' name='xsaveopt'/>
+ <feature policy='require' name='rdtscp'/>
</cpu>
diff --git a/tests/cputestdata/x86_64-cpuid-Pentium-P6100-guest.xml b/tests/cputestdata/x86_64-cpuid-Pentium-P6100-guest.xml
index db5e0ae6af..20e2fa363a 100644
--- a/tests/cputestdata/x86_64-cpuid-Pentium-P6100-guest.xml
+++ b/tests/cputestdata/x86_64-cpuid-Pentium-P6100-guest.xml
@@ -1,6 +1,7 @@
<cpu mode='custom' match='exact'>
- <model fallback='forbid'>core2duo</model>
+ <model fallback='forbid'>Westmere</model>
<vendor>Intel</vendor>
+ <feature policy='require' name='vme'/>
<feature policy='require' name='ds'/>
<feature policy='require' name='acpi'/>
<feature policy='require' name='ss'/>
@@ -8,16 +9,17 @@
<feature policy='require' name='tm'/>
<feature policy='require' name='pbe'/>
<feature policy='require' name='dtes64'/>
+ <feature policy='require' name='monitor'/>
<feature policy='require' name='ds_cpl'/>
<feature policy='require' name='est'/>
<feature policy='require' name='tm2'/>
- <feature policy='require' name='cx16'/>
<feature policy='require' name='xtpr'/>
<feature policy='require' name='pdcm'/>
<feature policy='require' name='pcid'/>
- <feature policy='require' name='popcnt'/>
<feature policy='require' name='arat'/>
<feature policy='require' name='rdtscp'/>
- <feature policy='require' name='lahf_lm'/>
<feature policy='require' name='invtsc'/>
+ <feature policy='disable' name='sse4.1'/>
+ <feature policy='disable' name='sse4.2'/>
+ <feature policy='disable' name='aes'/>
</cpu>
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-E7-4820-guest.xml b/tests/cputestdata/x86_64-cpuid-Xeon-E7-4820-guest.xml
index dbf8580a0e..659779687a 100644
--- a/tests/cputestdata/x86_64-cpuid-Xeon-E7-4820-guest.xml
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-E7-4820-guest.xml
@@ -1,5 +1,5 @@
<cpu mode='custom' match='exact'>
- <model fallback='forbid'>SandyBridge</model>
+ <model fallback='forbid'>Westmere</model>
<vendor>Intel</vendor>
<feature policy='require' name='vme'/>
<feature policy='require' name='ds'/>
@@ -8,6 +8,7 @@
<feature policy='require' name='ht'/>
<feature policy='require' name='tm'/>
<feature policy='require' name='pbe'/>
+ <feature policy='require' name='pclmuldq'/>
<feature policy='require' name='dtes64'/>
<feature policy='require' name='monitor'/>
<feature policy='require' name='ds_cpl'/>
@@ -19,10 +20,9 @@
<feature policy='require' name='pdcm'/>
<feature policy='require' name='pcid'/>
<feature policy='require' name='dca'/>
+ <feature policy='require' name='x2apic'/>
<feature policy='require' name='arat'/>
<feature policy='require' name='pdpe1gb'/>
+ <feature policy='require' name='rdtscp'/>
<feature policy='require' name='invtsc'/>
- <feature policy='disable' name='tsc-deadline'/>
- <feature policy='disable' name='xsave'/>
- <feature policy='disable' name='avx'/>
</cpu>
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-E7-4820-json.xml b/tests/cputestdata/x86_64-cpuid-Xeon-E7-4820-json.xml
index d94a330f37..e8b74c5c30 100644
--- a/tests/cputestdata/x86_64-cpuid-Xeon-E7-4820-json.xml
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-E7-4820-json.xml
@@ -1,12 +1,14 @@
<cpu mode='custom' match='exact'>
- <model fallback='forbid'>SandyBridge</model>
+ <model fallback='forbid'>Westmere</model>
<vendor>Intel</vendor>
<feature policy='require' name='vme'/>
<feature policy='require' name='ss'/>
+ <feature policy='require' name='pclmuldq'/>
<feature policy='require' name='pcid'/>
+ <feature policy='require' name='x2apic'/>
+ <feature policy='require' name='tsc-deadline'/>
<feature policy='require' name='hypervisor'/>
<feature policy='require' name='tsc_adjust'/>
<feature policy='require' name='pdpe1gb'/>
- <feature policy='disable' name='xsave'/>
- <feature policy='disable' name='avx'/>
+ <feature policy='require' name='rdtscp'/>
</cpu>
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-E7-4830-json.xml b/tests/cputestdata/x86_64-cpuid-Xeon-E7-4830-json.xml
index aae32bd7e2..da949ad25e 100644
--- a/tests/cputestdata/x86_64-cpuid-Xeon-E7-4830-json.xml
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-E7-4830-json.xml
@@ -1,14 +1,15 @@
<cpu mode='custom' match='exact'>
- <model fallback='forbid'>SandyBridge</model>
+ <model fallback='forbid'>Westmere</model>
<vendor>Intel</vendor>
<feature policy='require' name='vme'/>
<feature policy='require' name='ss'/>
+ <feature policy='require' name='pclmuldq'/>
<feature policy='require' name='pcid'/>
+ <feature policy='require' name='x2apic'/>
+ <feature policy='require' name='tsc-deadline'/>
<feature policy='require' name='hypervisor'/>
<feature policy='require' name='arat'/>
<feature policy='require' name='tsc_adjust'/>
<feature policy='require' name='pdpe1gb'/>
- <feature policy='disable' name='xsave'/>
- <feature policy='disable' name='avx'/>
- <feature policy='disable' name='xsaveopt'/>
+ <feature policy='require' name='rdtscp'/>
</cpu>
--
2.22.0

View File

@ -0,0 +1,110 @@
From bd665085c2cd890f2249042f135b7a1735932d1b Mon Sep 17 00:00:00 2001
Message-Id: <bd665085c2cd890f2249042f135b7a1735932d1b@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:24:48 +0200
Subject: [PATCH] cpu_map: Add support for arch-capabilities feature
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The feature was added to QEMU in 3.1.0 and it is currently blocking
migration, which is expected to change in the future. Luckily 3.1.0 is
new enough to give us migratability hints on each feature via
query-cpu-model-expension, which means we don't need to use the
"migratable" attribute on the CPU map XML.
The kernel calls this feature arch_capabilities and RHEL/CentOS 7.* use
arch-facilities. Apparently some CPU test files were gathered with the
RHEL version of QEMU. Let's update the test files to avoid possible
confusion about the correct naming.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 511df17aec36385320dbcc088ba85968537d1d42)
https://bugzilla.redhat.com/show_bug.cgi?id=1693433
Conflicts:
src/cpu_map/x86_features.xml
- cpu_map split was not backported
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <fc8d72f3a2191ef85b537943aa1cc844f50b038d.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_map.xml | 3 +++
tests/cputestdata/x86_64-cpuid-EPYC-7601-32-Core-ibpb.json | 2 +-
tests/cputestdata/x86_64-cpuid-Xeon-E5-2609-v3.json | 2 +-
tests/cputestdata/x86_64-cpuid-Xeon-E5-2623-v4.json | 2 +-
tests/cputestdata/x86_64-cpuid-Xeon-Gold-5115.json | 2 +-
5 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/src/cpu/cpu_map.xml b/src/cpu/cpu_map.xml
index ceee0ae489..a9f284fbbe 100644
--- a/src/cpu/cpu_map.xml
+++ b/src/cpu/cpu_map.xml
@@ -337,6 +337,9 @@
<feature name='stibp'>
<cpuid eax_in='0x07' ecx_in='0x00' edx='0x08000000'/>
</feature>
+ <feature name='arch-capabilities'> <!-- arch_capabilities, arch-facilities -->
+ <cpuid eax_in='0x07' ecx_in='0x00' edx='0x20000000'/>
+ </feature>
<feature name='ssbd'>
<cpuid eax_in='0x07' ecx_in='0x00' edx='0x80000000'/>
</feature>
diff --git a/tests/cputestdata/x86_64-cpuid-EPYC-7601-32-Core-ibpb.json b/tests/cputestdata/x86_64-cpuid-EPYC-7601-32-Core-ibpb.json
index 94a60fcc8f..1f53bb8bf3 100644
--- a/tests/cputestdata/x86_64-cpuid-EPYC-7601-32-Core-ibpb.json
+++ b/tests/cputestdata/x86_64-cpuid-EPYC-7601-32-Core-ibpb.json
@@ -232,7 +232,7 @@
"avx512vbmi": false,
"kvm-asyncpf": true,
"spec-ctrl": false,
- "arch-facilities": false,
+ "arch-capabilities": false,
"model": 1,
"node-id": -1
}
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2609-v3.json b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2609-v3.json
index 10c5434263..6bdaf6e83a 100644
--- a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2609-v3.json
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2609-v3.json
@@ -232,7 +232,7 @@
"avx512vbmi": false,
"kvm-asyncpf": true,
"spec-ctrl": true,
- "arch-facilities": false,
+ "arch-capabilities": false,
"model": 63,
"node-id": -1
}
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2623-v4.json b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2623-v4.json
index 0506dec0a7..2c6be20768 100644
--- a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2623-v4.json
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2623-v4.json
@@ -232,7 +232,7 @@
"avx512vbmi": false,
"kvm-asyncpf": true,
"spec-ctrl": true,
- "arch-facilities": false,
+ "arch-capabilities": false,
"model": 79,
"node-id": -1
}
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-Gold-5115.json b/tests/cputestdata/x86_64-cpuid-Xeon-Gold-5115.json
index 79f3580219..79b47a56fb 100644
--- a/tests/cputestdata/x86_64-cpuid-Xeon-Gold-5115.json
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-Gold-5115.json
@@ -232,7 +232,7 @@
"avx512vbmi": false,
"kvm-asyncpf": true,
"spec-ctrl": true,
- "arch-facilities": false,
+ "arch-capabilities": false,
"model": 85,
"node-id": -1
}
--
2.22.0

View File

@ -0,0 +1,190 @@
From 059091703401ef3029a1ffdbec8de97d5d5a1fd1 Mon Sep 17 00:00:00 2001
Message-Id: <059091703401ef3029a1ffdbec8de97d5d5a1fd1@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 15 Nov 2019 17:52:36 +0100
Subject: [PATCH] cpu_map: Drop pconfig from Icelake-Server CPU model
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The pconfig feature was enabled in QEMU by accident in 3.1.0. All other
newer versions do not support it and it was removed from the
Icelake-Server CPU model in QEMU.
We don't normally change our CPU models even when QEMU does so to avoid
breaking migrations between different versions of libvirt. But we can
safely do so in this specific case. QEMU never supported enabling
pconfig so any domain which was able to start has pconfig disabled.
With a small compatibility hack which explicitly disables pconfig when
CPU model equals Icelake-Server in migratable domain definition, only
one migration scenario stays broken (and there's nothing we can do about
it): from any host to a host with libvirt < 5.10.0 and QEMU > 3.1.0.
https://bugzilla.redhat.com/show_bug.cgi?id=1749672
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
(cherry picked from commit 9cd03f7957e114892ae54e7ccb3758b6fb440644)
https://bugzilla.redhat.com/show_bug.cgi?id=1756156
https://bugzilla.redhat.com/show_bug.cgi?id=1721608
Conflicts:
src/cpu_map/x86_Icelake-Server.xml
- still monolithic cpu_map.xml downstream
src/qemu/qemu_domain.h
- context
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <6c06dac67da208e6ba8c07798c31405644acfb16.1573836581.git.jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
---
src/cpu/cpu_map.xml | 1 -
src/qemu/qemu_domain.c | 23 +++++++++++++++++++
src/qemu/qemu_domain.h | 3 +++
src/qemu/qemu_migration_cookie.c | 3 +++
.../x86_64-cpuid-Ice-Lake-Server-guest.xml | 1 -
.../x86_64-cpuid-Ice-Lake-Server-host.xml | 11 +--------
.../x86_64-cpuid-Ice-Lake-Server-json.xml | 1 -
7 files changed, 30 insertions(+), 13 deletions(-)
diff --git a/src/cpu/cpu_map.xml b/src/cpu/cpu_map.xml
index acd9dad7dc..7b9f8bb452 100644
--- a/src/cpu/cpu_map.xml
+++ b/src/cpu/cpu_map.xml
@@ -2176,7 +2176,6 @@
<feature name='pat'/>
<feature name='pcid'/>
<feature name='pclmuldq'/>
- <feature name='pconfig'/>
<feature name='pdpe1gb'/>
<feature name='pge'/>
<feature name='pku'/>
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index c9899b9e6d..f45d7d427e 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -7348,6 +7348,26 @@ qemuDomainDefCopy(virQEMUDriverPtr driver,
}
+int
+qemuDomainMakeCPUMigratable(virCPUDefPtr cpu)
+{
+ if (cpu->mode == VIR_CPU_MODE_CUSTOM &&
+ STREQ_NULLABLE(cpu->model, "Icelake-Server")) {
+ /* Originally Icelake-Server CPU model contained pconfig CPU feature.
+ * It was never actually enabled and thus it was removed. To enable
+ * migration to QEMU 3.1.0 (with both new and old libvirt), we
+ * explicitly disable pconfig in migration XML (otherwise old libvirt
+ * would think it was implicitly enabled on the source). New libvirt
+ * will drop it from the XML before starting the domain on new QEMU.
+ */
+ if (virCPUDefUpdateFeature(cpu, "pconfig", VIR_CPU_FEATURE_DISABLE) < 0)
+ return -1;
+ }
+
+ return 0;
+}
+
+
static int
qemuDomainDefFormatBufInternal(virQEMUDriverPtr driver,
virDomainDefPtr def,
@@ -7522,6 +7542,9 @@ qemuDomainDefFormatBufInternal(virQEMUDriverPtr driver,
if (!(def->cpu = virCPUDefCopy(origCPU)))
goto cleanup;
}
+
+ if (qemuDomainMakeCPUMigratable(def->cpu) < 0)
+ goto cleanup;
}
format:
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 8463a8b706..a29a678771 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -1072,4 +1072,7 @@ char * qemuDomainGetManagedPRSocketPath(qemuDomainObjPrivatePtr priv);
virDomainEventResumedDetailType
qemuDomainRunningReasonToResumeEvent(virDomainRunningReason reason);
+int
+qemuDomainMakeCPUMigratable(virCPUDefPtr cpu);
+
#endif /* __QEMU_DOMAIN_H__ */
diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_cookie.c
index 60df449d53..c270896944 100644
--- a/src/qemu/qemu_migration_cookie.c
+++ b/src/qemu/qemu_migration_cookie.c
@@ -543,6 +543,9 @@ qemuMigrationCookieAddCPU(qemuMigrationCookiePtr mig,
if (!(mig->cpu = virCPUDefCopy(vm->def->cpu)))
return -1;
+ if (qemuDomainMakeCPUMigratable(mig->cpu) < 0)
+ return -1;
+
mig->flags |= QEMU_MIGRATION_COOKIE_CPU;
return 0;
diff --git a/tests/cputestdata/x86_64-cpuid-Ice-Lake-Server-guest.xml b/tests/cputestdata/x86_64-cpuid-Ice-Lake-Server-guest.xml
index 6ca2099b33..4676f3aa7d 100644
--- a/tests/cputestdata/x86_64-cpuid-Ice-Lake-Server-guest.xml
+++ b/tests/cputestdata/x86_64-cpuid-Ice-Lake-Server-guest.xml
@@ -32,5 +32,4 @@
<feature policy='require' name='rdctl-no'/>
<feature policy='require' name='ibrs-all'/>
<feature policy='require' name='skip-l1dfl-vmentry'/>
- <feature policy='disable' name='pconfig'/>
</cpu>
diff --git a/tests/cputestdata/x86_64-cpuid-Ice-Lake-Server-host.xml b/tests/cputestdata/x86_64-cpuid-Ice-Lake-Server-host.xml
index 31af20bc85..35b9e39629 100644
--- a/tests/cputestdata/x86_64-cpuid-Ice-Lake-Server-host.xml
+++ b/tests/cputestdata/x86_64-cpuid-Ice-Lake-Server-host.xml
@@ -1,6 +1,6 @@
<cpu>
<arch>x86_64</arch>
- <model>Icelake-Client</model>
+ <model>Icelake-Server</model>
<vendor>Intel</vendor>
<feature name='ds'/>
<feature name='acpi'/>
@@ -21,23 +21,14 @@
<feature name='osxsave'/>
<feature name='tsc_adjust'/>
<feature name='cmt'/>
- <feature name='avx512f'/>
- <feature name='avx512dq'/>
<feature name='avx512ifma'/>
- <feature name='clflushopt'/>
- <feature name='clwb'/>
- <feature name='avx512cd'/>
<feature name='sha-ni'/>
- <feature name='avx512bw'/>
- <feature name='avx512vl'/>
<feature name='ospke'/>
- <feature name='la57'/>
<feature name='stibp'/>
<feature name='arch-capabilities'/>
<feature name='xsaves'/>
<feature name='mbm_total'/>
<feature name='mbm_local'/>
- <feature name='pdpe1gb'/>
<feature name='invtsc'/>
<feature name='rdctl-no'/>
<feature name='ibrs-all'/>
diff --git a/tests/cputestdata/x86_64-cpuid-Ice-Lake-Server-json.xml b/tests/cputestdata/x86_64-cpuid-Ice-Lake-Server-json.xml
index b043db58d7..ada11d2608 100644
--- a/tests/cputestdata/x86_64-cpuid-Ice-Lake-Server-json.xml
+++ b/tests/cputestdata/x86_64-cpuid-Ice-Lake-Server-json.xml
@@ -13,5 +13,4 @@
<feature policy='require' name='ibrs-all'/>
<feature policy='require' name='skip-l1dfl-vmentry'/>
<feature policy='disable' name='intel-pt'/>
- <feature policy='disable' name='pconfig'/>
</cpu>
--
2.24.0

View File

@ -0,0 +1,155 @@
From 0c781b84fe81ca2d4865e92d6c22dafcea62261c Mon Sep 17 00:00:00 2001
Message-Id: <0c781b84fe81ca2d4865e92d6c22dafcea62261c@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:26:10 +0200
Subject: [PATCH] cpu_map: Introduce IA32_ARCH_CAPABILITIES MSR features
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit c8ec678fd9d97189667c0121f48a220dd26856b7)
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
Conflicts:
src/cpu_map/x86_features.xml
- cpu_map XML is not split downstream
tests/domaincapsschemadata/qemu_3.1.0.x86_64.xml
tests/domaincapsschemadata/qemu_4.0.0.x86_64.xml
- missing
tests/domaincapsschemadata/qemu_4.1.0.x86_64.xml
- commit 4586b11bed9bc59ea749e28f522bf5e0b462c4c7 not
backported
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <acddba8b7464f063de46f04fc421319cc78ad86c.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_map.xml | 20 +++++++++++++++++++
.../x86_64-cpuid-Core-i7-7600U-enabled.xml | 1 +
.../x86_64-cpuid-Core-i7-7600U-json.xml | 1 +
...86_64-cpuid-Xeon-Platinum-8268-enabled.xml | 1 +
.../x86_64-cpuid-Xeon-Platinum-8268-guest.xml | 4 ++++
.../x86_64-cpuid-Xeon-Platinum-8268-host.xml | 4 ++++
.../x86_64-cpuid-Xeon-Platinum-8268-json.xml | 3 +++
.../qemu_4.1.0.x86_64.xml | 1 +
8 files changed, 35 insertions(+)
diff --git a/src/cpu/cpu_map.xml b/src/cpu/cpu_map.xml
index 9b289556e8..acd9dad7dc 100644
--- a/src/cpu/cpu_map.xml
+++ b/src/cpu/cpu_map.xml
@@ -482,6 +482,26 @@
<cpuid eax_in='0x80000008' ebx='0x02000000'/>
</feature>
+ <!-- IA32_ARCH_CAPABILITIES features -->
+ <feature name='rdctl-no'>
+ <msr index='0x10a' edx='0x00000000' eax='0x00000001'/>
+ </feature>
+ <feature name='ibrs-all'>
+ <msr index='0x10a' edx='0x00000000' eax='0x00000002'/>
+ </feature>
+ <feature name='rsba'>
+ <msr index='0x10a' edx='0x00000000' eax='0x00000004'/>
+ </feature>
+ <feature name='skip-l1dfl-vmentry'>
+ <msr index='0x10a' edx='0x00000000' eax='0x00000008'/>
+ </feature>
+ <feature name='ssb-no'>
+ <msr index='0x10a' edx='0x00000000' eax='0x00000010'/>
+ </feature>
+ <feature name='mds-no'>
+ <msr index='0x10a' edx='0x00000000' eax='0x00000020'/>
+ </feature>
+
<!-- models -->
<model name='486'>
<feature name='fpu'/>
diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-7600U-enabled.xml b/tests/cputestdata/x86_64-cpuid-Core-i7-7600U-enabled.xml
index b1cdaa802a..58bc84577c 100644
--- a/tests/cputestdata/x86_64-cpuid-Core-i7-7600U-enabled.xml
+++ b/tests/cputestdata/x86_64-cpuid-Core-i7-7600U-enabled.xml
@@ -5,4 +5,5 @@
<cpuid eax_in='0x00000007' ecx_in='0x00' eax='0x00000000' ebx='0x009c4fbb' ecx='0x00000004' edx='0x84000000'/>
<cpuid eax_in='0x0000000d' ecx_in='0x01' eax='0x0000000f' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
<cpuid eax_in='0x80000001' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000121' edx='0x2c100800'/>
+ <msr index='0x10a' edx='0x00000000' eax='0x00000008'/>
</cpudata>
diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-7600U-json.xml b/tests/cputestdata/x86_64-cpuid-Core-i7-7600U-json.xml
index 48089c6003..690081493b 100644
--- a/tests/cputestdata/x86_64-cpuid-Core-i7-7600U-json.xml
+++ b/tests/cputestdata/x86_64-cpuid-Core-i7-7600U-json.xml
@@ -10,4 +10,5 @@
<feature policy='require' name='ssbd'/>
<feature policy='require' name='xsaves'/>
<feature policy='require' name='pdpe1gb'/>
+ <feature policy='require' name='skip-l1dfl-vmentry'/>
</cpu>
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-enabled.xml b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-enabled.xml
index 434ac1956a..313009b156 100644
--- a/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-enabled.xml
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-enabled.xml
@@ -5,4 +5,5 @@
<cpuid eax_in='0x00000007' ecx_in='0x00' eax='0x00000000' ebx='0xd19f4fbb' ecx='0x0000080c' edx='0x84000000'/>
<cpuid eax_in='0x0000000d' ecx_in='0x01' eax='0x0000000f' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
<cpuid eax_in='0x80000001' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000121' edx='0x2c100800'/>
+ <msr index='0x10a' edx='0x00000000' eax='0x0000000b'/>
</cpudata>
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-guest.xml b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-guest.xml
index c7e8a1fccf..988fb1dbdc 100644
--- a/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-guest.xml
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-guest.xml
@@ -30,4 +30,8 @@
<feature policy='require' name='mbm_total'/>
<feature policy='require' name='mbm_local'/>
<feature policy='require' name='invtsc'/>
+ <feature policy='require' name='rdctl-no'/>
+ <feature policy='require' name='ibrs-all'/>
+ <feature policy='require' name='skip-l1dfl-vmentry'/>
+ <feature policy='require' name='mds-no'/>
</cpu>
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-host.xml b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-host.xml
index d7482751b4..fdeafc4870 100644
--- a/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-host.xml
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-host.xml
@@ -31,4 +31,8 @@
<feature name='mbm_total'/>
<feature name='mbm_local'/>
<feature name='invtsc'/>
+ <feature name='rdctl-no'/>
+ <feature name='ibrs-all'/>
+ <feature name='skip-l1dfl-vmentry'/>
+ <feature name='mds-no'/>
</cpu>
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-json.xml b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-json.xml
index b7d12dced7..78863c61d1 100644
--- a/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-json.xml
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-json.xml
@@ -7,4 +7,7 @@
<feature policy='require' name='umip'/>
<feature policy='require' name='pku'/>
<feature policy='require' name='xsaves'/>
+ <feature policy='require' name='rdctl-no'/>
+ <feature policy='require' name='ibrs-all'/>
+ <feature policy='require' name='skip-l1dfl-vmentry'/>
</cpu>
diff --git a/tests/domaincapsschemadata/qemu_4.1.0.x86_64.xml b/tests/domaincapsschemadata/qemu_4.1.0.x86_64.xml
index 47aed6a43a..63ae7957c4 100644
--- a/tests/domaincapsschemadata/qemu_4.1.0.x86_64.xml
+++ b/tests/domaincapsschemadata/qemu_4.1.0.x86_64.xml
@@ -34,6 +34,7 @@
<feature policy='require' name='arch-capabilities'/>
<feature policy='require' name='xsaves'/>
<feature policy='require' name='pdpe1gb'/>
+ <feature policy='require' name='skip-l1dfl-vmentry'/>
</mode>
<mode name='custom' supported='yes'>
<model usable='yes'>qemu64</model>
--
2.22.0

View File

@ -0,0 +1,328 @@
From 808b0c73134cd3c6a7fdd387fd9654dbd41356ac Mon Sep 17 00:00:00 2001
Message-Id: <808b0c73134cd3c6a7fdd387fd9654dbd41356ac@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:25:39 +0200
Subject: [PATCH] cpu_x86: Add support for storing MSR features in CPU map
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit fcf4846a6bb902a5cd2230fff2a1e7591dcb7456)
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
Conflicts:
tests/cputestdata/cpu-cpuid.py
- no need to update this script downstream
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <0c37dabaaa6c2559b48918ca55e170750fe34ea0.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_x86.c | 127 +++++++++++++++++++++++++++++++++++++----
src/cpu/cpu_x86_data.h | 10 ++++
2 files changed, 125 insertions(+), 12 deletions(-)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index e6da974b31..49562944c1 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -197,6 +197,8 @@ virCPUx86DataItemMatch(const virCPUx86DataItem *item1,
{
const virCPUx86CPUID *cpuid1;
const virCPUx86CPUID *cpuid2;
+ const virCPUx86MSR *msr1;
+ const virCPUx86MSR *msr2;
switch (item1->type) {
case VIR_CPU_X86_DATA_CPUID:
@@ -207,6 +209,12 @@ virCPUx86DataItemMatch(const virCPUx86DataItem *item1,
cpuid1->ecx == cpuid2->ecx &&
cpuid1->edx == cpuid2->edx);
+ case VIR_CPU_X86_DATA_MSR:
+ msr1 = &item1->data.msr;
+ msr2 = &item2->data.msr;
+ return (msr1->eax == msr2->eax &&
+ msr1->edx == msr2->edx);
+
case VIR_CPU_X86_DATA_NONE:
default:
return false;
@@ -220,6 +228,8 @@ virCPUx86DataItemMatchMasked(const virCPUx86DataItem *item,
{
const virCPUx86CPUID *cpuid;
const virCPUx86CPUID *cpuidMask;
+ const virCPUx86MSR *msr;
+ const virCPUx86MSR *msrMask;
switch (item->type) {
case VIR_CPU_X86_DATA_CPUID:
@@ -230,6 +240,12 @@ virCPUx86DataItemMatchMasked(const virCPUx86DataItem *item,
(cpuid->ecx & cpuidMask->ecx) == cpuidMask->ecx &&
(cpuid->edx & cpuidMask->edx) == cpuidMask->edx);
+ case VIR_CPU_X86_DATA_MSR:
+ msr = &item->data.msr;
+ msrMask = &mask->data.msr;
+ return ((msr->eax & msrMask->eax) == msrMask->eax &&
+ (msr->edx & msrMask->edx) == msrMask->edx);
+
case VIR_CPU_X86_DATA_NONE:
default:
return false;
@@ -243,6 +259,8 @@ virCPUx86DataItemSetBits(virCPUx86DataItemPtr item,
{
virCPUx86CPUIDPtr cpuid;
const virCPUx86CPUID *cpuidMask;
+ virCPUx86MSRPtr msr;
+ const virCPUx86MSR *msrMask;
if (!mask)
return;
@@ -257,6 +275,13 @@ virCPUx86DataItemSetBits(virCPUx86DataItemPtr item,
cpuid->edx |= cpuidMask->edx;
break;
+ case VIR_CPU_X86_DATA_MSR:
+ msr = &item->data.msr;
+ msrMask = &mask->data.msr;
+ msr->eax |= msrMask->eax;
+ msr->edx |= msrMask->edx;
+ break;
+
case VIR_CPU_X86_DATA_NONE:
default:
break;
@@ -270,6 +295,8 @@ virCPUx86DataItemClearBits(virCPUx86DataItemPtr item,
{
virCPUx86CPUIDPtr cpuid;
const virCPUx86CPUID *cpuidMask;
+ virCPUx86MSRPtr msr;
+ const virCPUx86MSR *msrMask;
if (!mask)
return;
@@ -284,6 +311,13 @@ virCPUx86DataItemClearBits(virCPUx86DataItemPtr item,
cpuid->edx &= ~cpuidMask->edx;
break;
+ case VIR_CPU_X86_DATA_MSR:
+ msr = &item->data.msr;
+ msrMask = &mask->data.msr;
+ msr->eax &= ~msrMask->eax;
+ msr->edx &= ~msrMask->edx;
+ break;
+
case VIR_CPU_X86_DATA_NONE:
default:
break;
@@ -297,6 +331,8 @@ virCPUx86DataItemAndBits(virCPUx86DataItemPtr item,
{
virCPUx86CPUIDPtr cpuid;
const virCPUx86CPUID *cpuidMask;
+ virCPUx86MSRPtr msr;
+ const virCPUx86MSR *msrMask;
if (!mask)
return;
@@ -311,6 +347,13 @@ virCPUx86DataItemAndBits(virCPUx86DataItemPtr item,
cpuid->edx &= cpuidMask->edx;
break;
+ case VIR_CPU_X86_DATA_MSR:
+ msr = &item->data.msr;
+ msrMask = &mask->data.msr;
+ msr->eax &= msrMask->eax;
+ msr->edx &= msrMask->edx;
+ break;
+
case VIR_CPU_X86_DATA_NONE:
default:
break;
@@ -373,6 +416,14 @@ virCPUx86DataSorter(const void *a, const void *b)
break;
+ case VIR_CPU_X86_DATA_MSR:
+ if (da->data.msr.index > db->data.msr.index)
+ return 1;
+ else if (da->data.msr.index < db->data.msr.index)
+ return -1;
+
+ break;
+
case VIR_CPU_X86_DATA_NONE:
default:
break;
@@ -978,6 +1029,31 @@ x86ParseCPUID(xmlXPathContextPtr ctxt,
}
+static int
+x86ParseMSR(xmlXPathContextPtr ctxt,
+ virCPUx86DataItemPtr item)
+{
+ virCPUx86MSRPtr msr;
+ unsigned long index;
+ unsigned long eax;
+ unsigned long edx;
+
+ memset(item, 0, sizeof(*item));
+
+ if (virXPathULongHex("string(@index)", ctxt, &index) < 0 ||
+ virXPathULongHex("string(@eax)", ctxt, &eax) < 0 ||
+ virXPathULongHex("string(@edx)", ctxt, &edx) < 0)
+ return -1;
+
+ item->type = VIR_CPU_X86_DATA_MSR;
+ msr = &item->data.msr;
+ msr->index = index;
+ msr->eax = eax;
+ msr->edx = edx;
+ return 0;
+}
+
+
static int
x86FeatureParse(xmlXPathContextPtr ctxt,
const char *name,
@@ -1010,25 +1086,35 @@ x86FeatureParse(xmlXPathContextPtr ctxt,
if (STREQ_NULLABLE(str, "no"))
feature->migratable = false;
- n = virXPathNodeSet("./cpuid", ctxt, &nodes);
+ n = virXPathNodeSet("./cpuid|./msr", ctxt, &nodes);
if (n < 0)
goto cleanup;
if (n == 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Missing cpuid for feature %s"),
+ _("Missing cpuid or msr element in feature %s"),
feature->name);
goto cleanup;
}
for (i = 0; i < n; i++) {
ctxt->node = nodes[i];
- if (x86ParseCPUID(ctxt, &item) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Invalid cpuid[%zu] in %s feature"),
- i, feature->name);
- goto cleanup;
+ if (virXMLNodeNameEqual(nodes[i], "cpuid")) {
+ if (x86ParseCPUID(ctxt, &item) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Invalid cpuid[%zu] in %s feature"),
+ i, feature->name);
+ goto cleanup;
+ }
+ } else {
+ if (x86ParseMSR(ctxt, &item) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Invalid msr[%zu] in %s feature"),
+ i, feature->name);
+ goto cleanup;
+ }
}
+
if (virCPUx86DataAddItem(&feature->data, &item))
goto cleanup;
}
@@ -1544,6 +1630,7 @@ virCPUx86DataFormat(const virCPUData *data)
virBufferAddLit(&buf, "<cpudata arch='x86'>\n");
while ((item = virCPUx86DataNext(&iter))) {
virCPUx86CPUIDPtr cpuid;
+ virCPUx86MSRPtr msr;
switch (item->type) {
case VIR_CPU_X86_DATA_CPUID:
@@ -1556,6 +1643,13 @@ virCPUx86DataFormat(const virCPUData *data)
cpuid->eax, cpuid->ebx, cpuid->ecx, cpuid->edx);
break;
+ case VIR_CPU_X86_DATA_MSR:
+ msr = &item->data.msr;
+ virBufferAsprintf(&buf,
+ " <msr index='0x%x' eax='0x%08x' edx='0x%08x'/>\n",
+ msr->index, msr->eax, msr->edx);
+ break;
+
case VIR_CPU_X86_DATA_NONE:
default:
break;
@@ -1579,7 +1673,7 @@ virCPUx86DataParse(xmlXPathContextPtr ctxt)
size_t i;
int n;
- n = virXPathNodeSet("/cpudata/cpuid", ctxt, &nodes);
+ n = virXPathNodeSet("/cpudata/cpuid|/cpudata/msr", ctxt, &nodes);
if (n <= 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("no x86 CPU data found"));
@@ -1591,11 +1685,20 @@ virCPUx86DataParse(xmlXPathContextPtr ctxt)
for (i = 0; i < n; i++) {
ctxt->node = nodes[i];
- if (x86ParseCPUID(ctxt, &item) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("failed to parse cpuid[%zu]"), i);
- goto error;
+ if (virXMLNodeNameEqual(nodes[i], "cpuid")) {
+ if (x86ParseCPUID(ctxt, &item) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("failed to parse cpuid[%zu]"), i);
+ goto error;
+ }
+ } else {
+ if (x86ParseMSR(ctxt, &item) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("failed to parse msr[%zu]"), i);
+ goto error;
+ }
}
+
if (virCPUx86DataAdd(cpuData, &item) < 0)
goto error;
}
diff --git a/src/cpu/cpu_x86_data.h b/src/cpu/cpu_x86_data.h
index da8e91fe71..454345b688 100644
--- a/src/cpu/cpu_x86_data.h
+++ b/src/cpu/cpu_x86_data.h
@@ -37,6 +37,14 @@ struct _virCPUx86CPUID {
uint32_t edx;
};
+typedef struct _virCPUx86MSR virCPUx86MSR;
+typedef virCPUx86MSR *virCPUx86MSRPtr;
+struct _virCPUx86MSR {
+ uint32_t index;
+ uint32_t eax;
+ uint32_t edx;
+};
+
# define CPUX86_BASIC 0x0
# define CPUX86_KVM 0x40000000
# define CPUX86_EXTENDED 0x80000000
@@ -74,6 +82,7 @@ struct _virCPUx86CPUID {
typedef enum {
VIR_CPU_X86_DATA_NONE = 0,
VIR_CPU_X86_DATA_CPUID,
+ VIR_CPU_X86_DATA_MSR,
} virCPUx86DataType;
typedef struct _virCPUx86DataItem virCPUx86DataItem;
@@ -82,6 +91,7 @@ struct _virCPUx86DataItem {
virCPUx86DataType type;
union {
virCPUx86CPUID cpuid;
+ virCPUx86MSR msr;
} data;
};
--
2.22.0

View File

@ -0,0 +1,81 @@
From 459e059de518794d909c77b6c24fd6962558d362 Mon Sep 17 00:00:00 2001
Message-Id: <459e059de518794d909c77b6c24fd6962558d362@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:25:06 +0200
Subject: [PATCH] cpu_x86: Add virCPUx86DataGetSignature for tests
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The function exports the functionality of x86DataToSignatureFull and
x86MakeSignature to the test suite.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 661307b4b2e8597d889efddfac0ff5d324c9fa42)
https://bugzilla.redhat.com/show_bug.cgi?id=1686895
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <7964c9cc9ea47fdce4c2b07fda8efa2cb9f9f384.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_x86.c | 12 ++++++++++++
src/cpu/cpu_x86.h | 5 +++++
src/libvirt_private.syms | 1 +
3 files changed, 18 insertions(+)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index ba14a6097d..24569a90f3 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -3066,6 +3066,18 @@ virCPUx86DataSetSignature(virCPUDataPtr cpuData,
}
+uint32_t
+virCPUx86DataGetSignature(virCPUDataPtr cpuData,
+ unsigned int *family,
+ unsigned int *model,
+ unsigned int *stepping)
+{
+ x86DataToSignatureFull(&cpuData->data.x86, family, model, stepping);
+
+ return x86MakeSignature(*family, *model, *stepping);
+}
+
+
int
virCPUx86DataSetVendor(virCPUDataPtr cpuData,
const char *vendor)
diff --git a/src/cpu/cpu_x86.h b/src/cpu/cpu_x86.h
index 5d14d83e1b..9d3c2b2cdd 100644
--- a/src/cpu/cpu_x86.h
+++ b/src/cpu/cpu_x86.h
@@ -37,6 +37,11 @@ int virCPUx86DataSetSignature(virCPUDataPtr cpuData,
unsigned int model,
unsigned int stepping);
+uint32_t virCPUx86DataGetSignature(virCPUDataPtr cpuData,
+ unsigned int *family,
+ unsigned int *model,
+ unsigned int *stepping);
+
int virCPUx86DataSetVendor(virCPUDataPtr cpuData,
const char *vendor);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 7c48908a54..a275fa9aa1 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1205,6 +1205,7 @@ virCPUValidateFeatures;
# cpu/cpu_x86.h
virCPUx86DataAddCPUID;
virCPUx86DataAddFeature;
+virCPUx86DataGetSignature;
virCPUx86DataSetSignature;
virCPUx86DataSetVendor;
--
2.22.0

View File

@ -0,0 +1,77 @@
From 0b98a3d385f3d46949c5b2bc15c27c7c62739496 Mon Sep 17 00:00:00 2001
Message-Id: <0b98a3d385f3d46949c5b2bc15c27c7c62739496@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:24:59 +0200
Subject: [PATCH] cpu_x86: Add x86ModelCopySignatures helper
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Introduce a helper for copying CPU signature between two CPU models.
It's not very useful until the way we store signatures is changed in the
next patch.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 2254c1cfb854dfc52f3b4bfdfca2bd995b0a163c)
https://bugzilla.redhat.com/show_bug.cgi?id=1686895
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <eb973566dab0f8d77ff536e4c56eb6bffd77928f.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_x86.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 51cb9b7143..e25bc691ae 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -977,6 +977,16 @@ x86ModelFree(virCPUx86ModelPtr model)
}
+static int
+x86ModelCopySignatures(virCPUx86ModelPtr dst,
+ virCPUx86ModelPtr src)
+{
+ dst->signature = src->signature;
+
+ return 0;
+}
+
+
static virCPUx86ModelPtr
x86ModelCopy(virCPUx86ModelPtr model)
{
@@ -984,13 +994,13 @@ x86ModelCopy(virCPUx86ModelPtr model)
if (VIR_ALLOC(copy) < 0 ||
VIR_STRDUP(copy->name, model->name) < 0 ||
+ x86ModelCopySignatures(copy, model) < 0 ||
x86DataCopy(&copy->data, &model->data) < 0) {
x86ModelFree(copy);
return NULL;
}
copy->vendor = model->vendor;
- copy->signature = model->signature;
return copy;
}
@@ -1176,8 +1186,8 @@ x86ModelParseAncestor(virCPUx86ModelPtr model,
}
model->vendor = ancestor->vendor;
- model->signature = ancestor->signature;
- if (x86DataCopy(&model->data, &ancestor->data) < 0)
+ if (x86ModelCopySignatures(model, ancestor) < 0 ||
+ x86DataCopy(&model->data, &ancestor->data) < 0)
return -1;
return 0;
--
2.22.0

View File

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

View File

@ -0,0 +1,43 @@
From b63d4e603a3617bd0d68d8897afb5e1c13a75165 Mon Sep 17 00:00:00 2001
Message-Id: <b63d4e603a3617bd0d68d8897afb5e1c13a75165@dist-git>
From: John Ferlan <jferlan@redhat.com>
Date: Tue, 2 Jul 2019 12:57:21 +0200
Subject: [PATCH] cpu_x86: Fix memory leak - virCPUx86GetHost
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Commit 56b254dcc called virCPUx86DataAdd, but returned -1 directly
without calling the virCPUx86DataFree.
Found by Coverity.
Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit 5acb4eede23bcd5bc75193ea21542e0fb04b6e45)
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <96135f1275b80b251c83ca947333b1969380ef7b.1562064911.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_x86.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 0a520f07ff..9104bdbf1e 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -2789,7 +2789,7 @@ virCPUx86GetHost(virCPUDefPtr cpu,
};
if (virCPUx86DataAdd(cpuData, &item) < 0)
- return -1;
+ goto cleanup;
}
}
--
2.22.0

View File

@ -0,0 +1,119 @@
From e0ea2a8c9fb17cbb0b48cb8a1548152e962b126b Mon Sep 17 00:00:00 2001
Message-Id: <e0ea2a8c9fb17cbb0b48cb8a1548152e962b126b@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:25:45 +0200
Subject: [PATCH] cpu_x86: Fix placement of *CheckFeature functions
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Commit 0a97486e09 moved them outside #ifdef, but after virCPUx86GetHost,
which will start calling them in the following patch.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
(cherry picked from commit 32f577ab10aefda6c4666abd07814c5c39f57788)
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
Conflicts:
src/cpu/cpu_x86.c
- only the last patch moving these functions is backported
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <7bb25ee8ca5b743934fa2ae8249f5715a47aba06.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_x86.c | 70 +++++++++++++++++++++++------------------------
1 file changed, 35 insertions(+), 35 deletions(-)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index fdc2974a0d..3c1bd623db 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -2377,6 +2377,41 @@ x86Encode(virArch arch,
}
+static int
+virCPUx86CheckFeature(const virCPUDef *cpu,
+ const char *name)
+{
+ int ret = -1;
+ virCPUx86MapPtr map;
+ virCPUx86ModelPtr model = NULL;
+
+ if (!(map = virCPUx86GetMap()))
+ return -1;
+
+ if (!(model = x86ModelFromCPU(cpu, map, -1)))
+ goto cleanup;
+
+ ret = x86FeatureInData(name, &model->data, map);
+
+ cleanup:
+ x86ModelFree(model);
+ return ret;
+}
+
+
+static int
+virCPUx86DataCheckFeature(const virCPUData *data,
+ const char *name)
+{
+ virCPUx86MapPtr map;
+
+ if (!(map = virCPUx86GetMap()))
+ return -1;
+
+ return x86FeatureInData(name, &data->data.x86, map);
+}
+
+
#if defined(__i386__) || defined(__x86_64__)
static inline void
cpuidCall(virCPUx86CPUID *cpuid)
@@ -2706,41 +2741,6 @@ cpuidSet(uint32_t base, virCPUDataPtr data)
}
-static int
-virCPUx86CheckFeature(const virCPUDef *cpu,
- const char *name)
-{
- int ret = -1;
- virCPUx86MapPtr map;
- virCPUx86ModelPtr model = NULL;
-
- if (!(map = virCPUx86GetMap()))
- return -1;
-
- if (!(model = x86ModelFromCPU(cpu, map, -1)))
- goto cleanup;
-
- ret = x86FeatureInData(name, &model->data, map);
-
- cleanup:
- x86ModelFree(model);
- return ret;
-}
-
-
-static int
-virCPUx86DataCheckFeature(const virCPUData *data,
- const char *name)
-{
- virCPUx86MapPtr map;
-
- if (!(map = virCPUx86GetMap()))
- return -1;
-
- return x86FeatureInData(name, &data->data.x86, map);
-}
-
-
static int
virCPUx86GetHost(virCPUDefPtr cpu,
virDomainCapsCPUModelsPtr models)
--
2.22.0

View File

@ -0,0 +1,60 @@
From 5354c931f98f2d95d131bf4d490d0e5e057157fe Mon Sep 17 00:00:00 2001
Message-Id: <5354c931f98f2d95d131bf4d490d0e5e057157fe@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:25:32 +0200
Subject: [PATCH] cpu_x86: Introduce virCPUx86DataCmp
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
virCPUx86DataSorter already compares two virCPUx86DataItem structs.
Let's add a tiny wrapper around it called virCPUx86DataCmp and use it
instead of open coded comparisons.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 559ccd7815056af23de24b7a01e8f644d97b6a92)
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <9623fdd20059ec6abc7f09c5e7f1e13927c56944.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_x86.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 0582be63e2..5a09033d2a 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -304,6 +304,13 @@ virCPUx86DataSorter(const void *a, const void *b)
return 0;
}
+static int
+virCPUx86DataItemCmp(const virCPUx86DataItem *item1,
+ const virCPUx86DataItem *item2)
+{
+ return virCPUx86DataSorter(item1, item2);
+}
+
/* skips all zero CPUID leaves */
static virCPUx86DataItemPtr
@@ -332,9 +339,9 @@ virCPUx86DataGet(const virCPUx86Data *data,
size_t i;
for (i = 0; i < data->len; i++) {
- if (data->items[i].cpuid.eax_in == item->cpuid.eax_in &&
- data->items[i].cpuid.ecx_in == item->cpuid.ecx_in)
- return data->items + i;
+ virCPUx86DataItemPtr di = data->items + i;
+ if (virCPUx86DataItemCmp(di, item) == 0)
+ return di;
}
return NULL;
--
2.22.0

View File

@ -0,0 +1,850 @@
From 891f6c594088c787c92279af08ba0ab037492bdd Mon Sep 17 00:00:00 2001
Message-Id: <891f6c594088c787c92279af08ba0ab037492bdd@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:25:22 +0200
Subject: [PATCH] cpu_x86: Introduce virCPUx86DataItem container struct
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The following patches introduce CPU features read from MSR in addition
to those queried via CPUID instruction. Let's introduce a container
struct which will be able to describe either feature type.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 3673269e3aa22566f87e06a2b10dbc3b20110f84)
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <161419b9968304180f18b33e6dc29ba70d9174d0.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_x86.c | 312 ++++++++++++++++++---------------
src/cpu/cpu_x86.h | 2 +-
src/cpu/cpu_x86_data.h | 9 +-
src/libxl/libxl_capabilities.c | 8 +-
src/qemu/qemu_monitor_json.c | 6 +-
5 files changed, 183 insertions(+), 154 deletions(-)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 98e8d608d6..2e953eaa12 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -49,7 +49,7 @@ typedef struct _virCPUx86Vendor virCPUx86Vendor;
typedef virCPUx86Vendor *virCPUx86VendorPtr;
struct _virCPUx86Vendor {
char *name;
- virCPUx86CPUID cpuid;
+ virCPUx86DataItem cpuid;
};
typedef struct _virCPUx86Feature virCPUx86Feature;
@@ -61,17 +61,19 @@ struct _virCPUx86Feature {
};
+#define CPUID(...) { .cpuid = {__VA_ARGS__} }
+
#define KVM_FEATURE_DEF(Name, Eax_in, Eax) \
- static virCPUx86CPUID Name ## _cpuid[] = { \
- { .eax_in = Eax_in, .eax = Eax }, \
+ static virCPUx86DataItem Name ## _data[] = { \
+ CPUID(.eax_in = Eax_in, .eax = Eax), \
}
#define KVM_FEATURE(Name) \
{ \
.name = (char *) Name, \
.data = { \
- .len = ARRAY_CARDINALITY(Name ## _cpuid), \
- .data = Name ## _cpuid \
+ .len = ARRAY_CARDINALITY(Name ## _data), \
+ .items = Name ## _data, \
} \
}
@@ -286,17 +288,17 @@ x86FeatureFindInternal(const char *name)
static int
virCPUx86CPUIDSorter(const void *a, const void *b)
{
- virCPUx86CPUID *da = (virCPUx86CPUID *) a;
- virCPUx86CPUID *db = (virCPUx86CPUID *) b;
+ virCPUx86DataItemPtr da = (virCPUx86DataItemPtr) a;
+ virCPUx86DataItemPtr db = (virCPUx86DataItemPtr) b;
- if (da->eax_in > db->eax_in)
+ if (da->cpuid.eax_in > db->cpuid.eax_in)
return 1;
- else if (da->eax_in < db->eax_in)
+ else if (da->cpuid.eax_in < db->cpuid.eax_in)
return -1;
- if (da->ecx_in > db->ecx_in)
+ if (da->cpuid.ecx_in > db->cpuid.ecx_in)
return 1;
- else if (da->ecx_in < db->ecx_in)
+ else if (da->cpuid.ecx_in < db->cpuid.ecx_in)
return -1;
return 0;
@@ -304,7 +306,7 @@ virCPUx86CPUIDSorter(const void *a, const void *b)
/* skips all zero CPUID leaves */
-static virCPUx86CPUID *
+static virCPUx86DataItemPtr
x86DataCpuidNext(virCPUx86DataIteratorPtr iterator)
{
const virCPUx86Data *data = iterator->data;
@@ -313,24 +315,26 @@ x86DataCpuidNext(virCPUx86DataIteratorPtr iterator)
return NULL;
while (++iterator->pos < data->len) {
- if (!x86cpuidMatch(data->data + iterator->pos, &cpuidNull))
- return data->data + iterator->pos;
+ virCPUx86DataItemPtr item = data->items + iterator->pos;
+
+ if (!x86cpuidMatch(&item->cpuid, &cpuidNull))
+ return item;
}
return NULL;
}
-static virCPUx86CPUID *
+static virCPUx86DataItemPtr
x86DataCpuid(const virCPUx86Data *data,
- const virCPUx86CPUID *cpuid)
+ const virCPUx86DataItem *cpuid)
{
size_t i;
for (i = 0; i < data->len; i++) {
- if (data->data[i].eax_in == cpuid->eax_in &&
- data->data[i].ecx_in == cpuid->ecx_in)
- return data->data + i;
+ if (data->items[i].cpuid.eax_in == cpuid->cpuid.eax_in &&
+ data->items[i].cpuid.ecx_in == cpuid->cpuid.ecx_in)
+ return data->items + i;
}
return NULL;
@@ -342,7 +346,7 @@ virCPUx86DataClear(virCPUx86Data *data)
if (!data)
return;
- VIR_FREE(data->data);
+ VIR_FREE(data->items);
}
@@ -362,12 +366,12 @@ x86DataCopy(virCPUx86Data *dst, const virCPUx86Data *src)
{
size_t i;
- if (VIR_ALLOC_N(dst->data, src->len) < 0)
+ if (VIR_ALLOC_N(dst->items, src->len) < 0)
return -1;
dst->len = src->len;
for (i = 0; i < src->len; i++)
- dst->data[i] = src->data[i];
+ dst->items[i] = src->items[i];
return 0;
}
@@ -375,19 +379,19 @@ x86DataCopy(virCPUx86Data *dst, const virCPUx86Data *src)
static int
virCPUx86DataAddCPUIDInt(virCPUx86Data *data,
- const virCPUx86CPUID *cpuid)
+ const virCPUx86DataItem *cpuid)
{
- virCPUx86CPUID *existing;
+ virCPUx86DataItemPtr existing;
if ((existing = x86DataCpuid(data, cpuid))) {
- x86cpuidSetBits(existing, cpuid);
+ x86cpuidSetBits(&existing->cpuid, &cpuid->cpuid);
} else {
- if (VIR_APPEND_ELEMENT_COPY(data->data, data->len,
- *((virCPUx86CPUID *)cpuid)) < 0)
+ if (VIR_APPEND_ELEMENT_COPY(data->items, data->len,
+ *((virCPUx86DataItemPtr)cpuid)) < 0)
return -1;
- qsort(data->data, data->len,
- sizeof(virCPUx86CPUID), virCPUx86CPUIDSorter);
+ qsort(data->items, data->len,
+ sizeof(virCPUx86DataItem), virCPUx86CPUIDSorter);
}
return 0;
@@ -399,14 +403,14 @@ x86DataAdd(virCPUx86Data *data1,
const virCPUx86Data *data2)
{
virCPUx86DataIterator iter = virCPUx86DataIteratorInit(data2);
- virCPUx86CPUID *cpuid1;
- virCPUx86CPUID *cpuid2;
+ virCPUx86DataItemPtr cpuid1;
+ virCPUx86DataItemPtr cpuid2;
while ((cpuid2 = x86DataCpuidNext(&iter))) {
cpuid1 = x86DataCpuid(data1, cpuid2);
if (cpuid1) {
- x86cpuidSetBits(cpuid1, cpuid2);
+ x86cpuidSetBits(&cpuid1->cpuid, &cpuid2->cpuid);
} else {
if (virCPUx86DataAddCPUIDInt(data1, cpuid2) < 0)
return -1;
@@ -422,12 +426,12 @@ x86DataSubtract(virCPUx86Data *data1,
const virCPUx86Data *data2)
{
virCPUx86DataIterator iter = virCPUx86DataIteratorInit(data1);
- virCPUx86CPUID *cpuid1;
- virCPUx86CPUID *cpuid2;
+ virCPUx86DataItemPtr cpuid1;
+ virCPUx86DataItemPtr cpuid2;
while ((cpuid1 = x86DataCpuidNext(&iter))) {
- cpuid2 = x86DataCpuid(data2, cpuid1);
- x86cpuidClearBits(cpuid1, cpuid2);
+ if ((cpuid2 = x86DataCpuid(data2, cpuid1)))
+ x86cpuidClearBits(&cpuid1->cpuid, &cpuid2->cpuid);
}
}
@@ -437,15 +441,15 @@ x86DataIntersect(virCPUx86Data *data1,
const virCPUx86Data *data2)
{
virCPUx86DataIterator iter = virCPUx86DataIteratorInit(data1);
- virCPUx86CPUID *cpuid1;
- virCPUx86CPUID *cpuid2;
+ virCPUx86DataItemPtr cpuid1;
+ virCPUx86DataItemPtr cpuid2;
while ((cpuid1 = x86DataCpuidNext(&iter))) {
cpuid2 = x86DataCpuid(data2, cpuid1);
if (cpuid2)
- x86cpuidAndBits(cpuid1, cpuid2);
+ x86cpuidAndBits(&cpuid1->cpuid, &cpuid2->cpuid);
else
- x86cpuidClearBits(cpuid1, cpuid1);
+ x86cpuidClearBits(&cpuid1->cpuid, &cpuid1->cpuid);
}
}
@@ -465,12 +469,12 @@ x86DataIsSubset(const virCPUx86Data *data,
{
virCPUx86DataIterator iter = virCPUx86DataIteratorInit((virCPUx86Data *)subset);
- const virCPUx86CPUID *cpuid;
- const virCPUx86CPUID *cpuidSubset;
+ const virCPUx86DataItem *cpuid;
+ const virCPUx86DataItem *cpuidSubset;
while ((cpuidSubset = x86DataCpuidNext(&iter))) {
if (!(cpuid = x86DataCpuid(data, cpuidSubset)) ||
- !x86cpuidMatchMasked(cpuid, cpuidSubset))
+ !x86cpuidMatchMasked(&cpuid->cpuid, &cpuidSubset->cpuid))
return false;
}
@@ -505,14 +509,14 @@ static virCPUx86VendorPtr
x86DataToVendor(const virCPUx86Data *data,
virCPUx86MapPtr map)
{
- virCPUx86CPUID *cpuid;
+ virCPUx86DataItemPtr cpuid;
size_t i;
for (i = 0; i < map->nvendors; i++) {
virCPUx86VendorPtr vendor = map->vendors[i];
if ((cpuid = x86DataCpuid(data, &vendor->cpuid)) &&
- x86cpuidMatchMasked(cpuid, &vendor->cpuid)) {
- x86cpuidClearBits(cpuid, &vendor->cpuid);
+ x86cpuidMatchMasked(&cpuid->cpuid, &vendor->cpuid.cpuid)) {
+ x86cpuidClearBits(&cpuid->cpuid, &vendor->cpuid.cpuid);
return vendor;
}
}
@@ -523,8 +527,10 @@ x86DataToVendor(const virCPUx86Data *data,
static int
virCPUx86VendorToCPUID(const char *vendor,
- virCPUx86CPUID *cpuid)
+ virCPUx86DataItemPtr data)
{
+ virCPUx86CPUIDPtr cpuid = &data->cpuid;
+
if (strlen(vendor) != VENDOR_STRING_LENGTH) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Invalid CPU vendor string '%s'"), vendor);
@@ -597,14 +603,16 @@ x86DataToSignatureFull(const virCPUx86Data *data,
unsigned int *model,
unsigned int *stepping)
{
- virCPUx86CPUID leaf1 = { .eax_in = 0x1 };
- virCPUx86CPUID *cpuid;
+ virCPUx86DataItem leaf1 = CPUID(.eax_in = 0x1);
+ virCPUx86DataItemPtr item;
+ virCPUx86CPUIDPtr cpuid;
*family = *model = *stepping = 0;
- if (!(cpuid = x86DataCpuid(data, &leaf1)))
+ if (!(item = x86DataCpuid(data, &leaf1)))
return;
+ cpuid = &item->cpuid;
*family = ((cpuid->eax >> 20) & 0xff) + ((cpuid->eax >> 8) & 0xf);
*model = ((cpuid->eax >> 12) & 0xf0) + ((cpuid->eax >> 4) & 0xf);
*stepping = cpuid->eax & 0xf;
@@ -617,13 +625,13 @@ x86DataToSignatureFull(const virCPUx86Data *data,
static uint32_t
x86DataToSignature(const virCPUx86Data *data)
{
- virCPUx86CPUID leaf1 = { .eax_in = 0x1 };
- virCPUx86CPUID *cpuid;
+ virCPUx86DataItem leaf1 = CPUID(.eax_in = 0x1);
+ virCPUx86DataItemPtr cpuid;
if (!(cpuid = x86DataCpuid(data, &leaf1)))
return 0;
- return cpuid->eax & SIGNATURE_MASK;
+ return cpuid->cpuid.eax & SIGNATURE_MASK;
}
@@ -631,7 +639,7 @@ static int
x86DataAddSignature(virCPUx86Data *data,
uint32_t signature)
{
- virCPUx86CPUID cpuid = { .eax_in = 0x1, .eax = signature };
+ virCPUx86DataItem cpuid = CPUID(.eax_in = 0x1, .eax = signature);
return virCPUx86DataAddCPUIDInt(data, &cpuid);
}
@@ -856,13 +864,14 @@ x86FeatureNames(virCPUx86MapPtr map,
static int
x86ParseCPUID(xmlXPathContextPtr ctxt,
- virCPUx86CPUID *cpuid)
+ virCPUx86DataItemPtr item)
{
+ virCPUx86CPUIDPtr cpuid;
unsigned long eax_in, ecx_in;
unsigned long eax, ebx, ecx, edx;
int ret_eax_in, ret_ecx_in, ret_eax, ret_ebx, ret_ecx, ret_edx;
- memset(cpuid, 0, sizeof(*cpuid));
+ memset(item, 0, sizeof(*item));
eax_in = ecx_in = 0;
eax = ebx = ecx = edx = 0;
@@ -877,6 +886,7 @@ x86ParseCPUID(xmlXPathContextPtr ctxt,
ret_eax == -2 || ret_ebx == -2 || ret_ecx == -2 || ret_edx == -2)
return -1;
+ cpuid = &item->cpuid;
cpuid->eax_in = eax_in;
cpuid->ecx_in = ecx_in;
cpuid->eax = eax;
@@ -895,7 +905,7 @@ x86FeatureParse(xmlXPathContextPtr ctxt,
virCPUx86MapPtr map = data;
xmlNodePtr *nodes = NULL;
virCPUx86FeaturePtr feature;
- virCPUx86CPUID cpuid;
+ virCPUx86DataItem cpuid;
size_t i;
int n;
char *str = NULL;
@@ -1138,16 +1148,16 @@ x86ModelCompare(virCPUx86ModelPtr model1,
virCPUx86CompareResult result = EQUAL;
virCPUx86DataIterator iter1 = virCPUx86DataIteratorInit(&model1->data);
virCPUx86DataIterator iter2 = virCPUx86DataIteratorInit(&model2->data);
- virCPUx86CPUID *cpuid1;
- virCPUx86CPUID *cpuid2;
+ virCPUx86DataItemPtr cpuid1;
+ virCPUx86DataItemPtr cpuid2;
while ((cpuid1 = x86DataCpuidNext(&iter1))) {
virCPUx86CompareResult match = SUPERSET;
if ((cpuid2 = x86DataCpuid(&model2->data, cpuid1))) {
- if (x86cpuidMatch(cpuid1, cpuid2))
+ if (x86cpuidMatch(&cpuid1->cpuid, &cpuid2->cpuid))
continue;
- else if (!x86cpuidMatchMasked(cpuid1, cpuid2))
+ else if (!x86cpuidMatchMasked(&cpuid1->cpuid, &cpuid2->cpuid))
match = SUBSET;
}
@@ -1161,9 +1171,9 @@ x86ModelCompare(virCPUx86ModelPtr model1,
virCPUx86CompareResult match = SUBSET;
if ((cpuid1 = x86DataCpuid(&model1->data, cpuid2))) {
- if (x86cpuidMatch(cpuid2, cpuid1))
+ if (x86cpuidMatch(&cpuid2->cpuid, &cpuid1->cpuid))
continue;
- else if (!x86cpuidMatchMasked(cpuid2, cpuid1))
+ else if (!x86cpuidMatchMasked(&cpuid2->cpuid, &cpuid1->cpuid))
match = SUPERSET;
}
@@ -1447,11 +1457,12 @@ static char *
virCPUx86DataFormat(const virCPUData *data)
{
virCPUx86DataIterator iter = virCPUx86DataIteratorInit(&data->data.x86);
- virCPUx86CPUID *cpuid;
+ virCPUx86DataItemPtr item;
virBuffer buf = VIR_BUFFER_INITIALIZER;
virBufferAddLit(&buf, "<cpudata arch='x86'>\n");
- while ((cpuid = x86DataCpuidNext(&iter))) {
+ while ((item = x86DataCpuidNext(&iter))) {
+ virCPUx86CPUIDPtr cpuid = &item->cpuid;
virBufferAsprintf(&buf,
" <cpuid eax_in='0x%08x' ecx_in='0x%08x'"
" eax='0x%08x' ebx='0x%08x'"
@@ -1473,7 +1484,7 @@ virCPUx86DataParse(xmlXPathContextPtr ctxt)
{
xmlNodePtr *nodes = NULL;
virCPUDataPtr cpuData = NULL;
- virCPUx86CPUID cpuid;
+ virCPUx86DataItem cpuid;
size_t i;
int n;
@@ -2059,7 +2070,7 @@ x86EncodePolicy(virCPUx86Data *data,
*data = model->data;
model->data.len = 0;
- model->data.data = NULL;
+ model->data.items = NULL;
x86ModelFree(model);
return 0;
@@ -2213,17 +2224,18 @@ cpuidCall(virCPUx86CPUID *cpuid)
*/
static int
cpuidSetLeaf4(virCPUDataPtr data,
- virCPUx86CPUID *subLeaf0)
+ virCPUx86DataItemPtr subLeaf0)
{
- virCPUx86CPUID cpuid = *subLeaf0;
+ virCPUx86DataItem item = *subLeaf0;
+ virCPUx86CPUIDPtr cpuid = &item.cpuid;
if (virCPUx86DataAddCPUID(data, subLeaf0) < 0)
return -1;
- while (cpuid.eax & 0x1f) {
- cpuid.ecx_in++;
- cpuidCall(&cpuid);
- if (virCPUx86DataAddCPUID(data, &cpuid) < 0)
+ while (cpuid->eax & 0x1f) {
+ cpuid->ecx_in++;
+ cpuidCall(cpuid);
+ if (virCPUx86DataAddCPUID(data, &item) < 0)
return -1;
}
return 0;
@@ -2236,18 +2248,19 @@ cpuidSetLeaf4(virCPUDataPtr data,
*/
static int
cpuidSetLeaf7(virCPUDataPtr data,
- virCPUx86CPUID *subLeaf0)
+ virCPUx86DataItemPtr subLeaf0)
{
- virCPUx86CPUID cpuid = { .eax_in = 0x7 };
+ virCPUx86DataItem item = CPUID(.eax_in = 0x7);
+ virCPUx86CPUIDPtr cpuid = &item.cpuid;
uint32_t sub;
if (virCPUx86DataAddCPUID(data, subLeaf0) < 0)
return -1;
- for (sub = 1; sub <= subLeaf0->eax; sub++) {
- cpuid.ecx_in = sub;
- cpuidCall(&cpuid);
- if (virCPUx86DataAddCPUID(data, &cpuid) < 0)
+ for (sub = 1; sub <= subLeaf0->cpuid.eax; sub++) {
+ cpuid->ecx_in = sub;
+ cpuidCall(cpuid);
+ if (virCPUx86DataAddCPUID(data, &item) < 0)
return -1;
}
return 0;
@@ -2263,15 +2276,16 @@ cpuidSetLeaf7(virCPUDataPtr data,
*/
static int
cpuidSetLeafB(virCPUDataPtr data,
- virCPUx86CPUID *subLeaf0)
+ virCPUx86DataItemPtr subLeaf0)
{
- virCPUx86CPUID cpuid = *subLeaf0;
+ virCPUx86DataItem item = *subLeaf0;
+ virCPUx86CPUIDPtr cpuid = &item.cpuid;
- while (cpuid.ecx & 0xff00) {
- if (virCPUx86DataAddCPUID(data, &cpuid) < 0)
+ while (cpuid->ecx & 0xff00) {
+ if (virCPUx86DataAddCPUID(data, &item) < 0)
return -1;
- cpuid.ecx_in++;
- cpuidCall(&cpuid);
+ cpuid->ecx_in++;
+ cpuidCall(cpuid);
}
return 0;
}
@@ -2287,9 +2301,10 @@ cpuidSetLeafB(virCPUDataPtr data,
*/
static int
cpuidSetLeafD(virCPUDataPtr data,
- virCPUx86CPUID *subLeaf0)
+ virCPUx86DataItemPtr subLeaf0)
{
- virCPUx86CPUID cpuid = { .eax_in = 0xd };
+ virCPUx86DataItem item = CPUID(.eax_in = 0xd);
+ virCPUx86CPUIDPtr cpuid = &item.cpuid;
virCPUx86CPUID sub0;
virCPUx86CPUID sub1;
uint32_t sub;
@@ -2297,13 +2312,13 @@ cpuidSetLeafD(virCPUDataPtr data,
if (virCPUx86DataAddCPUID(data, subLeaf0) < 0)
return -1;
- cpuid.ecx_in = 1;
- cpuidCall(&cpuid);
- if (virCPUx86DataAddCPUID(data, &cpuid) < 0)
+ cpuid->ecx_in = 1;
+ cpuidCall(cpuid);
+ if (virCPUx86DataAddCPUID(data, &item) < 0)
return -1;
- sub0 = *subLeaf0;
- sub1 = cpuid;
+ sub0 = subLeaf0->cpuid;
+ sub1 = *cpuid;
for (sub = 2; sub < 64; sub++) {
if (sub < 32 &&
!(sub0.eax & (1 << sub)) &&
@@ -2314,9 +2329,9 @@ cpuidSetLeafD(virCPUDataPtr data,
!(sub1.edx & (1 << (sub - 32))))
continue;
- cpuid.ecx_in = sub;
- cpuidCall(&cpuid);
- if (virCPUx86DataAddCPUID(data, &cpuid) < 0)
+ cpuid->ecx_in = sub;
+ cpuidCall(cpuid);
+ if (virCPUx86DataAddCPUID(data, &item) < 0)
return -1;
}
return 0;
@@ -2334,10 +2349,11 @@ cpuidSetLeafD(virCPUDataPtr data,
*/
static int
cpuidSetLeafResID(virCPUDataPtr data,
- virCPUx86CPUID *subLeaf0,
+ virCPUx86DataItemPtr subLeaf0,
uint32_t res)
{
- virCPUx86CPUID cpuid = { .eax_in = subLeaf0->eax_in };
+ virCPUx86DataItem item = CPUID(.eax_in = subLeaf0->cpuid.eax_in);
+ virCPUx86CPUIDPtr cpuid = &item.cpuid;
uint32_t sub;
if (virCPUx86DataAddCPUID(data, subLeaf0) < 0)
@@ -2346,9 +2362,9 @@ cpuidSetLeafResID(virCPUDataPtr data,
for (sub = 1; sub < 32; sub++) {
if (!(res & (1 << sub)))
continue;
- cpuid.ecx_in = sub;
- cpuidCall(&cpuid);
- if (virCPUx86DataAddCPUID(data, &cpuid) < 0)
+ cpuid->ecx_in = sub;
+ cpuidCall(cpuid);
+ if (virCPUx86DataAddCPUID(data, &item) < 0)
return -1;
}
return 0;
@@ -2362,31 +2378,32 @@ cpuidSetLeafResID(virCPUDataPtr data,
*/
static int
cpuidSetLeaf12(virCPUDataPtr data,
- virCPUx86CPUID *subLeaf0)
+ virCPUx86DataItemPtr subLeaf0)
{
- virCPUx86CPUID cpuid = { .eax_in = 0x7 };
- virCPUx86CPUID *cpuid7;
+ virCPUx86DataItem item = CPUID(.eax_in = 0x7);
+ virCPUx86CPUIDPtr cpuid = &item.cpuid;
+ virCPUx86DataItemPtr cpuid7;
- if (!(cpuid7 = x86DataCpuid(&data->data.x86, &cpuid)) ||
- !(cpuid7->ebx & (1 << 2)))
+ if (!(cpuid7 = x86DataCpuid(&data->data.x86, &item)) ||
+ !(cpuid7->cpuid.ebx & (1 << 2)))
return 0;
if (virCPUx86DataAddCPUID(data, subLeaf0) < 0)
return -1;
- cpuid.eax_in = 0x12;
- cpuid.ecx_in = 1;
- cpuidCall(&cpuid);
- if (virCPUx86DataAddCPUID(data, &cpuid) < 0)
+ cpuid->eax_in = 0x12;
+ cpuid->ecx_in = 1;
+ cpuidCall(cpuid);
+ if (virCPUx86DataAddCPUID(data, &item) < 0)
return -1;
- cpuid.ecx_in = 2;
- cpuidCall(&cpuid);
- while (cpuid.eax & 0xf) {
- if (virCPUx86DataAddCPUID(data, &cpuid) < 0)
+ cpuid->ecx_in = 2;
+ cpuidCall(cpuid);
+ while (cpuid->eax & 0xf) {
+ if (virCPUx86DataAddCPUID(data, &item) < 0)
return -1;
- cpuid.ecx_in++;
- cpuidCall(&cpuid);
+ cpuid->ecx_in++;
+ cpuidCall(cpuid);
}
return 0;
}
@@ -2398,18 +2415,19 @@ cpuidSetLeaf12(virCPUDataPtr data,
*/
static int
cpuidSetLeaf14(virCPUDataPtr data,
- virCPUx86CPUID *subLeaf0)
+ virCPUx86DataItemPtr subLeaf0)
{
- virCPUx86CPUID cpuid = { .eax_in = 0x14 };
+ virCPUx86DataItem item = CPUID(.eax_in = 0x14);
+ virCPUx86CPUIDPtr cpuid = &item.cpuid;
uint32_t sub;
if (virCPUx86DataAddCPUID(data, subLeaf0) < 0)
return -1;
- for (sub = 1; sub <= subLeaf0->eax; sub++) {
- cpuid.ecx_in = sub;
- cpuidCall(&cpuid);
- if (virCPUx86DataAddCPUID(data, &cpuid) < 0)
+ for (sub = 1; sub <= subLeaf0->cpuid.eax; sub++) {
+ cpuid->ecx_in = sub;
+ cpuidCall(cpuid);
+ if (virCPUx86DataAddCPUID(data, &item) < 0)
return -1;
}
return 0;
@@ -2423,21 +2441,22 @@ cpuidSetLeaf14(virCPUDataPtr data,
*/
static int
cpuidSetLeaf17(virCPUDataPtr data,
- virCPUx86CPUID *subLeaf0)
+ virCPUx86DataItemPtr subLeaf0)
{
- virCPUx86CPUID cpuid = { .eax_in = 0x17 };
+ virCPUx86DataItem item = CPUID(.eax_in = 0x17);
+ virCPUx86CPUIDPtr cpuid = &item.cpuid;
uint32_t sub;
- if (subLeaf0->eax < 3)
+ if (subLeaf0->cpuid.eax < 3)
return 0;
if (virCPUx86DataAddCPUID(data, subLeaf0) < 0)
return -1;
- for (sub = 1; sub <= subLeaf0->eax; sub++) {
- cpuid.ecx_in = sub;
- cpuidCall(&cpuid);
- if (virCPUx86DataAddCPUID(data, &cpuid) < 0)
+ for (sub = 1; sub <= subLeaf0->cpuid.eax; sub++) {
+ cpuid->ecx_in = sub;
+ cpuidCall(cpuid);
+ if (virCPUx86DataAddCPUID(data, &item) < 0)
return -1;
}
return 0;
@@ -2450,39 +2469,40 @@ cpuidSet(uint32_t base, virCPUDataPtr data)
int rc;
uint32_t max;
uint32_t leaf;
- virCPUx86CPUID cpuid = { .eax_in = base };
+ virCPUx86DataItem item = CPUID(.eax_in = base);
+ virCPUx86CPUIDPtr cpuid = &item.cpuid;
- cpuidCall(&cpuid);
- max = cpuid.eax;
+ cpuidCall(cpuid);
+ max = cpuid->eax;
for (leaf = base; leaf <= max; leaf++) {
- cpuid.eax_in = leaf;
- cpuid.ecx_in = 0;
- cpuidCall(&cpuid);
+ cpuid->eax_in = leaf;
+ cpuid->ecx_in = 0;
+ cpuidCall(cpuid);
/* Handle CPUID leaves that depend on previously queried bits or
* which provide additional sub leaves for ecx_in > 0
*/
if (leaf == 0x4)
- rc = cpuidSetLeaf4(data, &cpuid);
+ rc = cpuidSetLeaf4(data, &item);
else if (leaf == 0x7)
- rc = cpuidSetLeaf7(data, &cpuid);
+ rc = cpuidSetLeaf7(data, &item);
else if (leaf == 0xb)
- rc = cpuidSetLeafB(data, &cpuid);
+ rc = cpuidSetLeafB(data, &item);
else if (leaf == 0xd)
- rc = cpuidSetLeafD(data, &cpuid);
+ rc = cpuidSetLeafD(data, &item);
else if (leaf == 0xf)
- rc = cpuidSetLeafResID(data, &cpuid, cpuid.edx);
+ rc = cpuidSetLeafResID(data, &item, cpuid->edx);
else if (leaf == 0x10)
- rc = cpuidSetLeafResID(data, &cpuid, cpuid.ebx);
+ rc = cpuidSetLeafResID(data, &item, cpuid->ebx);
else if (leaf == 0x12)
- rc = cpuidSetLeaf12(data, &cpuid);
+ rc = cpuidSetLeaf12(data, &item);
else if (leaf == 0x14)
- rc = cpuidSetLeaf14(data, &cpuid);
+ rc = cpuidSetLeaf14(data, &item);
else if (leaf == 0x17)
- rc = cpuidSetLeaf17(data, &cpuid);
+ rc = cpuidSetLeaf17(data, &item);
else
- rc = virCPUx86DataAddCPUID(data, &cpuid);
+ rc = virCPUx86DataAddCPUID(data, &item);
if (rc < 0)
return -1;
@@ -3058,7 +3078,7 @@ virCPUx86ValidateFeatures(virCPUDefPtr cpu)
int
virCPUx86DataAddCPUID(virCPUDataPtr cpuData,
- const virCPUx86CPUID *cpuid)
+ const virCPUx86DataItem *cpuid)
{
return virCPUx86DataAddCPUIDInt(&cpuData->data.x86, cpuid);
}
@@ -3092,7 +3112,7 @@ int
virCPUx86DataSetVendor(virCPUDataPtr cpuData,
const char *vendor)
{
- virCPUx86CPUID cpuid = { 0 };
+ virCPUx86DataItem cpuid = CPUID(0);
if (virCPUx86VendorToCPUID(vendor, &cpuid) < 0)
return -1;
diff --git a/src/cpu/cpu_x86.h b/src/cpu/cpu_x86.h
index 9d3c2b2cdd..94655746c6 100644
--- a/src/cpu/cpu_x86.h
+++ b/src/cpu/cpu_x86.h
@@ -30,7 +30,7 @@
extern struct cpuArchDriver cpuDriverX86;
int virCPUx86DataAddCPUID(virCPUDataPtr cpuData,
- const virCPUx86CPUID *cpuid);
+ const virCPUx86DataItem *cpuid);
int virCPUx86DataSetSignature(virCPUDataPtr cpuData,
unsigned int family,
diff --git a/src/cpu/cpu_x86_data.h b/src/cpu/cpu_x86_data.h
index 090a21156f..e93b355cf0 100644
--- a/src/cpu/cpu_x86_data.h
+++ b/src/cpu/cpu_x86_data.h
@@ -27,6 +27,7 @@
# include <stdint.h>
typedef struct _virCPUx86CPUID virCPUx86CPUID;
+typedef virCPUx86CPUID *virCPUx86CPUIDPtr;
struct _virCPUx86CPUID {
uint32_t eax_in;
uint32_t ecx_in;
@@ -70,10 +71,16 @@ struct _virCPUx86CPUID {
# define VIR_CPU_X86_DATA_INIT { 0 }
+typedef struct _virCPUx86DataItem virCPUx86DataItem;
+typedef virCPUx86DataItem *virCPUx86DataItemPtr;
+struct _virCPUx86DataItem {
+ virCPUx86CPUID cpuid;
+};
+
typedef struct _virCPUx86Data virCPUx86Data;
struct _virCPUx86Data {
size_t len;
- virCPUx86CPUID *data;
+ virCPUx86DataItem *items;
};
#endif /* __VIR_CPU_X86_DATA_H__ */
diff --git a/src/libxl/libxl_capabilities.c b/src/libxl/libxl_capabilities.c
index 18596c7c72..231d72669f 100644
--- a/src/libxl/libxl_capabilities.c
+++ b/src/libxl/libxl_capabilities.c
@@ -67,13 +67,15 @@ struct guest_arch {
static int
libxlCapsAddCPUID(virCPUDataPtr data, virCPUx86CPUID *cpuid, ssize_t ncaps)
{
+ virCPUx86DataItem item = { 0 };
size_t i;
for (i = 0; i < ncaps; i++) {
- virCPUx86CPUID *c = &cpuid[i];
+ item.cpuid = cpuid[i];
- if (virCPUx86DataAddCPUID(data, c) < 0) {
- VIR_DEBUG("Failed to add CPUID(%x,%x)", c->eax_in, c->ecx_in);
+ if (virCPUx86DataAddCPUID(data, &item) < 0) {
+ VIR_DEBUG("Failed to add CPUID(%x,%x)",
+ cpuid[i].eax_in, cpuid[i].ecx_in);
return -1;
}
}
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index d6c11666c5..0b4dfd70c0 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -7043,7 +7043,7 @@ static virCPUDataPtr
qemuMonitorJSONParseCPUx86Features(virJSONValuePtr data)
{
virCPUDataPtr cpudata = NULL;
- virCPUx86CPUID cpuid;
+ virCPUx86DataItem item = { 0 };
size_t i;
if (!(cpudata = virCPUDataNew(VIR_ARCH_X86_64)))
@@ -7051,8 +7051,8 @@ qemuMonitorJSONParseCPUx86Features(virJSONValuePtr data)
for (i = 0; i < virJSONValueArraySize(data); i++) {
if (qemuMonitorJSONParseCPUx86FeatureWord(virJSONValueArrayGet(data, i),
- &cpuid) < 0 ||
- virCPUx86DataAddCPUID(cpudata, &cpuid) < 0)
+ &item.cpuid) < 0 ||
+ virCPUx86DataAddCPUID(cpudata, &item) < 0)
goto error;
}
--
2.22.0

View File

@ -0,0 +1,133 @@
From 016b5348df8fc1007c08b0d0deec68d923be2e75 Mon Sep 17 00:00:00 2001
Message-Id: <016b5348df8fc1007c08b0d0deec68d923be2e75@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:26:08 +0200
Subject: [PATCH] cpu_x86: Introduce virCPUx86FeatureFilter*MSR
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This functions may be used as a virCPUDefFeatureFilter callbacks for
virCPUDefCheckFeatures, virCPUDefFilerFeatures, and similar functions to
select (virCPUx86FeatureFilterSelectMSR) or drop
(virCPUx86FeatureFilterDropMSR) features reported via MSR.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit bcfed7f1c84cbff21d129a79cbd675b0cd51613c)
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
Conflicts:
src/cpu/cpu_x86.h
- downstream did not switch to #pragma once
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <1a0fd2733f3aaec22e4ad598086baac0f086bb47.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_x86.c | 57 ++++++++++++++++++++++++++++++++++++++++
src/cpu/cpu_x86.h | 6 +++++
src/libvirt_private.syms | 3 ++-
3 files changed, 65 insertions(+), 1 deletion(-)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 75527fd28f..ec0e408f98 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -3351,6 +3351,63 @@ virCPUx86DataAddFeature(virCPUDataPtr cpuData,
}
+static bool
+virCPUx86FeatureIsMSR(const char *name)
+{
+ virCPUx86FeaturePtr feature;
+ virCPUx86DataIterator iter;
+ virCPUx86DataItemPtr item;
+ virCPUx86MapPtr map;
+
+ if (!(map = virCPUx86GetMap()))
+ return false;
+
+ if (!(feature = x86FeatureFind(map, name)) &&
+ !(feature = x86FeatureFindInternal(name)))
+ return false;
+
+ virCPUx86DataIteratorInit(&iter, &feature->data);
+ while ((item = virCPUx86DataNext(&iter))) {
+ if (item->type == VIR_CPU_X86_DATA_MSR)
+ return true;
+ }
+
+ return false;
+}
+
+
+/**
+ * virCPUx86FeatureFilterSelectMSR:
+ *
+ * This is a callback for functions filtering features in virCPUDef. The result
+ * will contain only MSR features.
+ *
+ * Returns true if @name is an MSR feature, false otherwise.
+ */
+bool
+virCPUx86FeatureFilterSelectMSR(const char *name,
+ void *opaque ATTRIBUTE_UNUSED)
+{
+ return virCPUx86FeatureIsMSR(name);
+}
+
+
+/**
+ * virCPUx86FeatureFilterDropMSR:
+ *
+ * This is a callback for functions filtering features in virCPUDef. The result
+ * will not contain any MSR feature.
+ *
+ * Returns true if @name is not an MSR feature, false otherwise.
+ */
+bool
+virCPUx86FeatureFilterDropMSR(const char *name,
+ void *opaque ATTRIBUTE_UNUSED)
+{
+ return !virCPUx86FeatureIsMSR(name);
+}
+
+
struct cpuArchDriver cpuDriverX86 = {
.name = "x86",
.arch = archs,
diff --git a/src/cpu/cpu_x86.h b/src/cpu/cpu_x86.h
index 519024b7c0..5126679985 100644
--- a/src/cpu/cpu_x86.h
+++ b/src/cpu/cpu_x86.h
@@ -45,4 +45,10 @@ uint32_t virCPUx86DataGetSignature(virCPUDataPtr cpuData,
int virCPUx86DataSetVendor(virCPUDataPtr cpuData,
const char *vendor);
+bool virCPUx86FeatureFilterSelectMSR(const char *name,
+ void *opaque);
+
+bool virCPUx86FeatureFilterDropMSR(const char *name,
+ void *opaque);
+
#endif /* __VIR_CPU_X86_H__ */
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 0290f960a0..f158a17b49 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1210,7 +1210,8 @@ virCPUx86DataAdd;
virCPUx86DataGetSignature;
virCPUx86DataSetSignature;
virCPUx86DataSetVendor;
-
+virCPUx86FeatureFilterDropMSR;
+virCPUx86FeatureFilterSelectMSR;
# datatypes.h
virConnectClass;
--
2.22.0

View File

@ -0,0 +1,79 @@
From 3335b5e0db21375053c5005be9f820f7ba945010 Mon Sep 17 00:00:00 2001
Message-Id: <3335b5e0db21375053c5005be9f820f7ba945010@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:25:02 +0200
Subject: [PATCH] cpu_x86: Log decoded CPU model and signatures
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The log message may be useful when debugging why a specific CPU model
was selected for a given set of CPUID data.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 5ced12decea42f1d588f2cb28b10ca7a5772098e)
https://bugzilla.redhat.com/show_bug.cgi?id=1686895
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <cae19825427465e352de05433920c96dc44552ff.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_x86.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 7bd8119c23..ba14a6097d 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -1769,6 +1769,26 @@ x86ModelHasSignature(virCPUx86ModelPtr model,
}
+static char *
+x86FormatSignatures(virCPUx86ModelPtr model)
+{
+ virBuffer buf = VIR_BUFFER_INITIALIZER;
+ size_t i;
+
+ for (i = 0; i < model->nsignatures; i++) {
+ virBufferAsprintf(&buf, "%06lx,",
+ (unsigned long)model->signatures[i]);
+ }
+
+ virBufferTrim(&buf, ",", -1);
+
+ if (virBufferCheckError(&buf) < 0)
+ return NULL;
+
+ return virBufferContentAndReset(&buf);
+}
+
+
/*
* Checks whether a candidate model is a better fit for the CPU data than the
* current model.
@@ -1892,6 +1912,7 @@ x86Decode(virCPUDefPtr cpu,
virCPUx86Data features = VIR_CPU_X86_DATA_INIT;
virCPUx86VendorPtr vendor;
virDomainCapsCPUModelPtr hvModel = NULL;
+ VIR_AUTOFREE(char *) sigs = NULL;
uint32_t signature;
ssize_t i;
int rc;
@@ -1984,6 +2005,11 @@ x86Decode(virCPUDefPtr cpu,
if (vendor && VIR_STRDUP(cpu->vendor, vendor->name) < 0)
goto cleanup;
+ sigs = x86FormatSignatures(model);
+
+ VIR_DEBUG("Using CPU model %s (signatures %s) for CPU with signature %06lx",
+ model->name, NULLSTR(sigs), (unsigned long)signature);
+
VIR_STEAL_PTR(cpu->model, cpuModel->model);
VIR_STEAL_PTR(cpu->features, cpuModel->features);
cpu->nfeatures = cpuModel->nfeatures;
--
2.22.0

View File

@ -0,0 +1,49 @@
From 84ee95b9504d89236078952a44c1a8b7dba148ca Mon Sep 17 00:00:00 2001
Message-Id: <84ee95b9504d89236078952a44c1a8b7dba148ca@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:24:58 +0200
Subject: [PATCH] cpu_x86: Make sure CPU model names are unique in cpu_map
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Having multiple CPU model definitions with the same name could result in
unexpected behavior.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 8d7245441a473bc1f73005fd378d4a925870cce6)
https://bugzilla.redhat.com/show_bug.cgi?id=1686895
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <c5dcc42f39009e8a659acb56b89cc18da1c3b7b8.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_x86.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 91362198ab..51cb9b7143 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -1291,9 +1291,15 @@ x86ModelParse(xmlXPathContextPtr ctxt,
void *data)
{
virCPUx86MapPtr map = data;
- virCPUx86ModelPtr model;
+ virCPUx86ModelPtr model = NULL;
int ret = -1;
+ if (x86ModelFind(map, name)) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Multiple definitions of CPU model '%s'"), name);
+ goto cleanup;
+ }
+
if (!(model = x86ModelNew()))
goto cleanup;
--
2.22.0

View File

@ -0,0 +1,64 @@
From be1b7ab3f5a634de17359376d559d5c312f5623f Mon Sep 17 00:00:00 2001
Message-Id: <be1b7ab3f5a634de17359376d559d5c312f5623f@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:25:35 +0200
Subject: [PATCH] cpu_x86: Make x86cpuidAndBits more general
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The function now works on virCPUx86DataItem and it's renamed as
virCPUx86DataItemAndBits.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit da1efddfa6606520fb5f16622bc522b231484b54)
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <c265f1fcb4ab52f884dd9481a426978efa60b8c8.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_x86.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 5fbf0294bb..54da9a985c 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -242,16 +242,16 @@ virCPUx86DataItemClearBits(virCPUx86DataItemPtr item,
static void
-x86cpuidAndBits(virCPUx86CPUID *cpuid,
- const virCPUx86CPUID *mask)
+virCPUx86DataItemAndBits(virCPUx86DataItemPtr item,
+ const virCPUx86DataItem *mask)
{
if (!mask)
return;
- cpuid->eax &= mask->eax;
- cpuid->ebx &= mask->ebx;
- cpuid->ecx &= mask->ecx;
- cpuid->edx &= mask->edx;
+ item->cpuid.eax &= mask->cpuid.eax;
+ item->cpuid.ebx &= mask->cpuid.ebx;
+ item->cpuid.ecx &= mask->cpuid.ecx;
+ item->cpuid.edx &= mask->cpuid.edx;
}
@@ -447,7 +447,7 @@ x86DataIntersect(virCPUx86Data *data1,
while ((item1 = virCPUx86DataNext(&iter))) {
item2 = virCPUx86DataGet(data2, item1);
if (item2)
- x86cpuidAndBits(&item1->cpuid, &item2->cpuid);
+ virCPUx86DataItemAndBits(item1, item2);
else
virCPUx86DataItemClearBits(item1, item1);
}
--
2.22.0

View File

@ -0,0 +1,84 @@
From e9bc4fcd2c16a80cf564879d154f3083a6766ff9 Mon Sep 17 00:00:00 2001
Message-Id: <e9bc4fcd2c16a80cf564879d154f3083a6766ff9@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:25:34 +0200
Subject: [PATCH] cpu_x86: Make x86cpuidClearBits more general
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The parameters changed from virCPUx86CPUID to virCPUx86DataItem and the
function is now called virCPUx86DataItemClearBits.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 4e3cab2d002d5f4cfdf81359467de8ffe4e18682)
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <bdc0f6c7da3674ba988c2fd83525a60df9108864.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_x86.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index e2951ed1b0..5fbf0294bb 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -228,16 +228,16 @@ virCPUx86DataItemSetBits(virCPUx86DataItemPtr item,
static void
-x86cpuidClearBits(virCPUx86CPUID *cpuid,
- const virCPUx86CPUID *mask)
+virCPUx86DataItemClearBits(virCPUx86DataItemPtr item,
+ const virCPUx86DataItem *mask)
{
if (!mask)
return;
- cpuid->eax &= ~mask->eax;
- cpuid->ebx &= ~mask->ebx;
- cpuid->ecx &= ~mask->ecx;
- cpuid->edx &= ~mask->edx;
+ item->cpuid.eax &= ~mask->cpuid.eax;
+ item->cpuid.ebx &= ~mask->cpuid.ebx;
+ item->cpuid.ecx &= ~mask->cpuid.ecx;
+ item->cpuid.edx &= ~mask->cpuid.edx;
}
@@ -430,8 +430,8 @@ x86DataSubtract(virCPUx86Data *data1,
virCPUx86DataItemPtr item2;
while ((item1 = virCPUx86DataNext(&iter))) {
- if ((item2 = virCPUx86DataGet(data2, item1)))
- x86cpuidClearBits(&item1->cpuid, &item2->cpuid);
+ item2 = virCPUx86DataGet(data2, item1);
+ virCPUx86DataItemClearBits(item1, item2);
}
}
@@ -449,7 +449,7 @@ x86DataIntersect(virCPUx86Data *data1,
if (item2)
x86cpuidAndBits(&item1->cpuid, &item2->cpuid);
else
- x86cpuidClearBits(&item1->cpuid, &item1->cpuid);
+ virCPUx86DataItemClearBits(item1, item1);
}
}
@@ -516,7 +516,7 @@ x86DataToVendor(const virCPUx86Data *data,
virCPUx86VendorPtr vendor = map->vendors[i];
if ((item = virCPUx86DataGet(data, &vendor->data)) &&
x86cpuidMatchMasked(&item->cpuid, &vendor->data.cpuid)) {
- x86cpuidClearBits(&item->cpuid, &vendor->data.cpuid);
+ virCPUx86DataItemClearBits(item, &vendor->data);
return vendor;
}
}
--
2.22.0

View File

@ -0,0 +1,96 @@
From 759fe35a1acdccf68577de62752c087aea4b8268 Mon Sep 17 00:00:00 2001
Message-Id: <759fe35a1acdccf68577de62752c087aea4b8268@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:25:37 +0200
Subject: [PATCH] cpu_x86: Make x86cpuidMatch more general
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The function now works on virCPUx86DataItem and it's called
virCPUx86DataItemMatch.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 10b80165dba31f99306f39e348e3a6335feec5ef)
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <0b829eb945561e54c1fc4d333c59af53759edf19.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_x86.c | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 1bb35ec4e8..11c023ac31 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -41,8 +41,6 @@ VIR_LOG_INIT("cpu.cpu_x86");
#define VENDOR_STRING_LENGTH 12
-static const virCPUx86CPUID cpuidNull = { 0 };
-
static const virArch archs[] = { VIR_ARCH_I686, VIR_ARCH_X86_64 };
typedef struct _virCPUx86Vendor virCPUx86Vendor;
@@ -192,13 +190,13 @@ struct _virCPUx86DataIterator {
static bool
-x86cpuidMatch(const virCPUx86CPUID *cpuid1,
- const virCPUx86CPUID *cpuid2)
+virCPUx86DataItemMatch(const virCPUx86DataItem *item1,
+ const virCPUx86DataItem *item2)
{
- return (cpuid1->eax == cpuid2->eax &&
- cpuid1->ebx == cpuid2->ebx &&
- cpuid1->ecx == cpuid2->ecx &&
- cpuid1->edx == cpuid2->edx);
+ return (item1->cpuid.eax == item2->cpuid.eax &&
+ item1->cpuid.ebx == item2->cpuid.ebx &&
+ item1->cpuid.ecx == item2->cpuid.ecx &&
+ item1->cpuid.edx == item2->cpuid.edx);
}
@@ -317,6 +315,7 @@ static virCPUx86DataItemPtr
virCPUx86DataNext(virCPUx86DataIteratorPtr iterator)
{
const virCPUx86Data *data = iterator->data;
+ virCPUx86DataItem zero = { 0 };
if (!data)
return NULL;
@@ -324,7 +323,7 @@ virCPUx86DataNext(virCPUx86DataIteratorPtr iterator)
while (++iterator->pos < data->len) {
virCPUx86DataItemPtr item = data->items + iterator->pos;
- if (!x86cpuidMatch(&item->cpuid, &cpuidNull))
+ if (!virCPUx86DataItemMatch(item, &zero))
return item;
}
@@ -1155,7 +1154,7 @@ x86ModelCompare(virCPUx86ModelPtr model1,
virCPUx86CompareResult match = SUPERSET;
if ((item2 = virCPUx86DataGet(&model2->data, item1))) {
- if (x86cpuidMatch(&item1->cpuid, &item2->cpuid))
+ if (virCPUx86DataItemMatch(item1, item2))
continue;
else if (!virCPUx86DataItemMatchMasked(item1, item2))
match = SUBSET;
@@ -1171,7 +1170,7 @@ x86ModelCompare(virCPUx86ModelPtr model1,
virCPUx86CompareResult match = SUBSET;
if ((item1 = virCPUx86DataGet(&model1->data, item2))) {
- if (x86cpuidMatch(&item2->cpuid, &item1->cpuid))
+ if (virCPUx86DataItemMatch(item2, item1))
continue;
else if (!virCPUx86DataItemMatchMasked(item2, item1))
match = SUPERSET;
--
2.22.0

View File

@ -0,0 +1,88 @@
From 920ac610bc68ffd7de1ac14c401c7f8c37f3337e Mon Sep 17 00:00:00 2001
Message-Id: <920ac610bc68ffd7de1ac14c401c7f8c37f3337e@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:25:36 +0200
Subject: [PATCH] cpu_x86: Make x86cpuidMatchMasked more general
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The function is renamed as virCPUx86DataItemMatchMasked to reflect the
change in parameter types.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 2eea67a98eab58b46dbf4275819c06c90bc4c5b6)
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <7c0a54c618d67d64663eb92d5eeb1d8a2270be16.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_x86.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 54da9a985c..1bb35ec4e8 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -203,13 +203,13 @@ x86cpuidMatch(const virCPUx86CPUID *cpuid1,
static bool
-x86cpuidMatchMasked(const virCPUx86CPUID *cpuid,
- const virCPUx86CPUID *mask)
+virCPUx86DataItemMatchMasked(const virCPUx86DataItem *item,
+ const virCPUx86DataItem *mask)
{
- return ((cpuid->eax & mask->eax) == mask->eax &&
- (cpuid->ebx & mask->ebx) == mask->ebx &&
- (cpuid->ecx & mask->ecx) == mask->ecx &&
- (cpuid->edx & mask->edx) == mask->edx);
+ return ((item->cpuid.eax & mask->cpuid.eax) == mask->cpuid.eax &&
+ (item->cpuid.ebx & mask->cpuid.ebx) == mask->cpuid.ebx &&
+ (item->cpuid.ecx & mask->cpuid.ecx) == mask->cpuid.ecx &&
+ (item->cpuid.edx & mask->cpuid.edx) == mask->cpuid.edx);
}
@@ -474,7 +474,7 @@ x86DataIsSubset(const virCPUx86Data *data,
while ((itemSubset = virCPUx86DataNext(&iter))) {
if (!(item = virCPUx86DataGet(data, itemSubset)) ||
- !x86cpuidMatchMasked(&item->cpuid, &itemSubset->cpuid))
+ !virCPUx86DataItemMatchMasked(item, itemSubset))
return false;
}
@@ -515,7 +515,7 @@ x86DataToVendor(const virCPUx86Data *data,
for (i = 0; i < map->nvendors; i++) {
virCPUx86VendorPtr vendor = map->vendors[i];
if ((item = virCPUx86DataGet(data, &vendor->data)) &&
- x86cpuidMatchMasked(&item->cpuid, &vendor->data.cpuid)) {
+ virCPUx86DataItemMatchMasked(item, &vendor->data)) {
virCPUx86DataItemClearBits(item, &vendor->data);
return vendor;
}
@@ -1157,7 +1157,7 @@ x86ModelCompare(virCPUx86ModelPtr model1,
if ((item2 = virCPUx86DataGet(&model2->data, item1))) {
if (x86cpuidMatch(&item1->cpuid, &item2->cpuid))
continue;
- else if (!x86cpuidMatchMasked(&item1->cpuid, &item2->cpuid))
+ else if (!virCPUx86DataItemMatchMasked(item1, item2))
match = SUBSET;
}
@@ -1173,7 +1173,7 @@ x86ModelCompare(virCPUx86ModelPtr model1,
if ((item1 = virCPUx86DataGet(&model1->data, item2))) {
if (x86cpuidMatch(&item2->cpuid, &item1->cpuid))
continue;
- else if (!x86cpuidMatchMasked(&item2->cpuid, &item1->cpuid))
+ else if (!virCPUx86DataItemMatchMasked(item2, item1))
match = SUPERSET;
}
--
2.22.0

View File

@ -0,0 +1,64 @@
From d32fbe55ad3ee1bbbfe2adc9ab47034c7a5cb884 Mon Sep 17 00:00:00 2001
Message-Id: <d32fbe55ad3ee1bbbfe2adc9ab47034c7a5cb884@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:25:33 +0200
Subject: [PATCH] cpu_x86: Make x86cpuidSetBits more general
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The function is renamed as virCPUx86DataItemSetBits and it works on
virCPUx86DataItem now.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 9c6f00fc3351800dc8b63472e71b398c180161d8)
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <f2e1e24cb2be24ee66911f75384436c5c4513d3e.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_x86.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 5a09033d2a..e2951ed1b0 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -214,16 +214,16 @@ x86cpuidMatchMasked(const virCPUx86CPUID *cpuid,
static void
-x86cpuidSetBits(virCPUx86CPUID *cpuid,
- const virCPUx86CPUID *mask)
+virCPUx86DataItemSetBits(virCPUx86DataItemPtr item,
+ const virCPUx86DataItem *mask)
{
if (!mask)
return;
- cpuid->eax |= mask->eax;
- cpuid->ebx |= mask->ebx;
- cpuid->ecx |= mask->ecx;
- cpuid->edx |= mask->edx;
+ item->cpuid.eax |= mask->cpuid.eax;
+ item->cpuid.ebx |= mask->cpuid.ebx;
+ item->cpuid.ecx |= mask->cpuid.ecx;
+ item->cpuid.edx |= mask->cpuid.edx;
}
@@ -391,7 +391,7 @@ virCPUx86DataAddItem(virCPUx86Data *data,
virCPUx86DataItemPtr existing;
if ((existing = virCPUx86DataGet(data, item))) {
- x86cpuidSetBits(&existing->cpuid, &item->cpuid);
+ virCPUx86DataItemSetBits(existing, item);
} else {
if (VIR_APPEND_ELEMENT_COPY(data->items, data->len,
*((virCPUx86DataItemPtr)item)) < 0)
--
2.22.0

View File

@ -0,0 +1,115 @@
From dec2ce4345db0d13cff8c639c69afbf894ee593a Mon Sep 17 00:00:00 2001
Message-Id: <dec2ce4345db0d13cff8c639c69afbf894ee593a@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:25:40 +0200
Subject: [PATCH] cpu_x86: Move *CheckFeature functions
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
They are static and we will need to call them a little bit closer to the
beginning of the file.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit e17d10386bd9abcfb37c7d8b151bbd1071a87fc4)
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <41d2a36757ed83f70c9dc23e9b984e109e5a81ba.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_x86.c | 69 ++++++++++++++++++++++++-----------------------
1 file changed, 35 insertions(+), 34 deletions(-)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 49562944c1..fdc2974a0d 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -2706,6 +2706,41 @@ cpuidSet(uint32_t base, virCPUDataPtr data)
}
+static int
+virCPUx86CheckFeature(const virCPUDef *cpu,
+ const char *name)
+{
+ int ret = -1;
+ virCPUx86MapPtr map;
+ virCPUx86ModelPtr model = NULL;
+
+ if (!(map = virCPUx86GetMap()))
+ return -1;
+
+ if (!(model = x86ModelFromCPU(cpu, map, -1)))
+ goto cleanup;
+
+ ret = x86FeatureInData(name, &model->data, map);
+
+ cleanup:
+ x86ModelFree(model);
+ return ret;
+}
+
+
+static int
+virCPUx86DataCheckFeature(const virCPUData *data,
+ const char *name)
+{
+ virCPUx86MapPtr map;
+
+ if (!(map = virCPUx86GetMap()))
+ return -1;
+
+ return x86FeatureInData(name, &data->data.x86, map);
+}
+
+
static int
virCPUx86GetHost(virCPUDefPtr cpu,
virDomainCapsCPUModelsPtr models)
@@ -3062,40 +3097,6 @@ virCPUx86UpdateLive(virCPUDefPtr cpu,
}
-static int
-virCPUx86CheckFeature(const virCPUDef *cpu,
- const char *name)
-{
- int ret = -1;
- virCPUx86MapPtr map;
- virCPUx86ModelPtr model = NULL;
-
- if (!(map = virCPUx86GetMap()))
- return -1;
-
- if (!(model = x86ModelFromCPU(cpu, map, -1)))
- goto cleanup;
-
- ret = x86FeatureInData(name, &model->data, map);
-
- cleanup:
- x86ModelFree(model);
- return ret;
-}
-
-
-static int
-virCPUx86DataCheckFeature(const virCPUData *data,
- const char *name)
-{
- virCPUx86MapPtr map;
-
- if (!(map = virCPUx86GetMap()))
- return -1;
-
- return x86FeatureInData(name, &data->data.x86, map);
-}
-
static int
virCPUx86GetModels(char ***models)
{
--
2.22.0

View File

@ -0,0 +1,61 @@
From 0004d2f3b0c3b21336415a967d70b7e9c2d08f54 Mon Sep 17 00:00:00 2001
Message-Id: <0004d2f3b0c3b21336415a967d70b7e9c2d08f54@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:26:09 +0200
Subject: [PATCH] cpu_x86: Read CPU features from IA32_ARCH_CAPABILITIES MSR
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This is used by the host capabilities code to construct host CPU
definition.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 56b254dccc96b7339494812c9df07ccf6af3da95)
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <58ad207c48e0f2a6c44ff097b0881b649826ecd4.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_x86.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index ec0e408f98..0a520f07ff 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -2771,6 +2771,28 @@ virCPUx86GetHost(virCPUDefPtr cpu,
cpuidSet(CPUX86_EXTENDED, cpuData) < 0)
goto cleanup;
+ /* Read the IA32_ARCH_CAPABILITIES MSR (0x10a) if supported.
+ * This is best effort since there might be no way to read the MSR
+ * when we are not running as root. */
+ if (virCPUx86DataCheckFeature(cpuData, "arch-capabilities") == 1) {
+ uint64_t msr;
+ unsigned long index = 0x10a;
+
+ if (virHostCPUGetMSR(index, &msr) == 0) {
+ virCPUx86DataItem item = {
+ .type = VIR_CPU_X86_DATA_MSR,
+ .data.msr = {
+ .index = index,
+ .eax = msr & 0xffffffff,
+ .edx = msr >> 32,
+ },
+ };
+
+ if (virCPUx86DataAdd(cpuData, &item) < 0)
+ return -1;
+ }
+ }
+
ret = x86DecodeCPUData(cpu, cpuData, models);
cpu->microcodeVersion = virHostCPUGetMicrocodeVersion();
--
2.22.0

View File

@ -0,0 +1,50 @@
From ea8bf8889659145cbf53306e3d16357f40679e4e Mon Sep 17 00:00:00 2001
Message-Id: <ea8bf8889659145cbf53306e3d16357f40679e4e@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:25:27 +0200
Subject: [PATCH] cpu_x86: Rename virCPUx86CPUIDSorter
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
It is called virCPUx86DataSorter since the function will work on any CPU
data type.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 95accfa7fa15b21bf4824b55be666312d11c273a)
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <4661aa497f1b8d9b5ca1383a91affe24cd54caa9.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_x86.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 52709f109e..efb2a3bb07 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -286,7 +286,7 @@ x86FeatureFindInternal(const char *name)
static int
-virCPUx86CPUIDSorter(const void *a, const void *b)
+virCPUx86DataSorter(const void *a, const void *b)
{
virCPUx86DataItemPtr da = (virCPUx86DataItemPtr) a;
virCPUx86DataItemPtr db = (virCPUx86DataItemPtr) b;
@@ -391,7 +391,7 @@ virCPUx86DataAddCPUIDInt(virCPUx86Data *data,
return -1;
qsort(data->items, data->len,
- sizeof(virCPUx86DataItem), virCPUx86CPUIDSorter);
+ sizeof(virCPUx86DataItem), virCPUx86DataSorter);
}
return 0;
--
2.22.0

View File

@ -0,0 +1,274 @@
From d4df159ee1e489c9afc238f39e6bb52d4f71bce7 Mon Sep 17 00:00:00 2001
Message-Id: <d4df159ee1e489c9afc238f39e6bb52d4f71bce7@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:25:29 +0200
Subject: [PATCH] cpu_x86: Rename virCPUx86DataAddCPUID
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
It's called virCPUx86DataAdd now.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 8f1a8ce397d7514bee9f370a1531d668e01ec923)
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <1be869684ede8249c16fcab128fc6775edda08be.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_x86.c | 46 +++++++++++++++++-----------------
src/cpu/cpu_x86.h | 4 +--
src/libvirt_private.syms | 2 +-
src/libxl/libxl_capabilities.c | 2 +-
src/qemu/qemu_monitor_json.c | 2 +-
5 files changed, 28 insertions(+), 28 deletions(-)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 7e077577d3..6d48c9264c 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -1505,7 +1505,7 @@ virCPUx86DataParse(xmlXPathContextPtr ctxt)
_("failed to parse cpuid[%zu]"), i);
goto error;
}
- if (virCPUx86DataAddCPUID(cpuData, &item) < 0)
+ if (virCPUx86DataAdd(cpuData, &item) < 0)
goto error;
}
@@ -2153,7 +2153,7 @@ x86Encode(virArch arch,
if (!(data_vendor = virCPUDataNew(arch)))
goto error;
- if (v && virCPUx86DataAddCPUID(data_vendor, &v->data) < 0)
+ if (v && virCPUx86DataAdd(data_vendor, &v->data) < 0)
goto error;
}
@@ -2229,13 +2229,13 @@ cpuidSetLeaf4(virCPUDataPtr data,
virCPUx86DataItem item = *subLeaf0;
virCPUx86CPUIDPtr cpuid = &item.cpuid;
- if (virCPUx86DataAddCPUID(data, subLeaf0) < 0)
+ if (virCPUx86DataAdd(data, subLeaf0) < 0)
return -1;
while (cpuid->eax & 0x1f) {
cpuid->ecx_in++;
cpuidCall(cpuid);
- if (virCPUx86DataAddCPUID(data, &item) < 0)
+ if (virCPUx86DataAdd(data, &item) < 0)
return -1;
}
return 0;
@@ -2254,13 +2254,13 @@ cpuidSetLeaf7(virCPUDataPtr data,
virCPUx86CPUIDPtr cpuid = &item.cpuid;
uint32_t sub;
- if (virCPUx86DataAddCPUID(data, subLeaf0) < 0)
+ if (virCPUx86DataAdd(data, subLeaf0) < 0)
return -1;
for (sub = 1; sub <= subLeaf0->cpuid.eax; sub++) {
cpuid->ecx_in = sub;
cpuidCall(cpuid);
- if (virCPUx86DataAddCPUID(data, &item) < 0)
+ if (virCPUx86DataAdd(data, &item) < 0)
return -1;
}
return 0;
@@ -2282,7 +2282,7 @@ cpuidSetLeafB(virCPUDataPtr data,
virCPUx86CPUIDPtr cpuid = &item.cpuid;
while (cpuid->ecx & 0xff00) {
- if (virCPUx86DataAddCPUID(data, &item) < 0)
+ if (virCPUx86DataAdd(data, &item) < 0)
return -1;
cpuid->ecx_in++;
cpuidCall(cpuid);
@@ -2309,12 +2309,12 @@ cpuidSetLeafD(virCPUDataPtr data,
virCPUx86CPUID sub1;
uint32_t sub;
- if (virCPUx86DataAddCPUID(data, subLeaf0) < 0)
+ if (virCPUx86DataAdd(data, subLeaf0) < 0)
return -1;
cpuid->ecx_in = 1;
cpuidCall(cpuid);
- if (virCPUx86DataAddCPUID(data, &item) < 0)
+ if (virCPUx86DataAdd(data, &item) < 0)
return -1;
sub0 = subLeaf0->cpuid;
@@ -2331,7 +2331,7 @@ cpuidSetLeafD(virCPUDataPtr data,
cpuid->ecx_in = sub;
cpuidCall(cpuid);
- if (virCPUx86DataAddCPUID(data, &item) < 0)
+ if (virCPUx86DataAdd(data, &item) < 0)
return -1;
}
return 0;
@@ -2356,7 +2356,7 @@ cpuidSetLeafResID(virCPUDataPtr data,
virCPUx86CPUIDPtr cpuid = &item.cpuid;
uint32_t sub;
- if (virCPUx86DataAddCPUID(data, subLeaf0) < 0)
+ if (virCPUx86DataAdd(data, subLeaf0) < 0)
return -1;
for (sub = 1; sub < 32; sub++) {
@@ -2364,7 +2364,7 @@ cpuidSetLeafResID(virCPUDataPtr data,
continue;
cpuid->ecx_in = sub;
cpuidCall(cpuid);
- if (virCPUx86DataAddCPUID(data, &item) < 0)
+ if (virCPUx86DataAdd(data, &item) < 0)
return -1;
}
return 0;
@@ -2388,19 +2388,19 @@ cpuidSetLeaf12(virCPUDataPtr data,
!(leaf7->cpuid.ebx & (1 << 2)))
return 0;
- if (virCPUx86DataAddCPUID(data, subLeaf0) < 0)
+ if (virCPUx86DataAdd(data, subLeaf0) < 0)
return -1;
cpuid->eax_in = 0x12;
cpuid->ecx_in = 1;
cpuidCall(cpuid);
- if (virCPUx86DataAddCPUID(data, &item) < 0)
+ if (virCPUx86DataAdd(data, &item) < 0)
return -1;
cpuid->ecx_in = 2;
cpuidCall(cpuid);
while (cpuid->eax & 0xf) {
- if (virCPUx86DataAddCPUID(data, &item) < 0)
+ if (virCPUx86DataAdd(data, &item) < 0)
return -1;
cpuid->ecx_in++;
cpuidCall(cpuid);
@@ -2421,13 +2421,13 @@ cpuidSetLeaf14(virCPUDataPtr data,
virCPUx86CPUIDPtr cpuid = &item.cpuid;
uint32_t sub;
- if (virCPUx86DataAddCPUID(data, subLeaf0) < 0)
+ if (virCPUx86DataAdd(data, subLeaf0) < 0)
return -1;
for (sub = 1; sub <= subLeaf0->cpuid.eax; sub++) {
cpuid->ecx_in = sub;
cpuidCall(cpuid);
- if (virCPUx86DataAddCPUID(data, &item) < 0)
+ if (virCPUx86DataAdd(data, &item) < 0)
return -1;
}
return 0;
@@ -2450,13 +2450,13 @@ cpuidSetLeaf17(virCPUDataPtr data,
if (subLeaf0->cpuid.eax < 3)
return 0;
- if (virCPUx86DataAddCPUID(data, subLeaf0) < 0)
+ if (virCPUx86DataAdd(data, subLeaf0) < 0)
return -1;
for (sub = 1; sub <= subLeaf0->cpuid.eax; sub++) {
cpuid->ecx_in = sub;
cpuidCall(cpuid);
- if (virCPUx86DataAddCPUID(data, &item) < 0)
+ if (virCPUx86DataAdd(data, &item) < 0)
return -1;
}
return 0;
@@ -2502,7 +2502,7 @@ cpuidSet(uint32_t base, virCPUDataPtr data)
else if (leaf == 0x17)
rc = cpuidSetLeaf17(data, &item);
else
- rc = virCPUx86DataAddCPUID(data, &item);
+ rc = virCPUx86DataAdd(data, &item);
if (rc < 0)
return -1;
@@ -3077,8 +3077,8 @@ virCPUx86ValidateFeatures(virCPUDefPtr cpu)
int
-virCPUx86DataAddCPUID(virCPUDataPtr cpuData,
- const virCPUx86DataItem *item)
+virCPUx86DataAdd(virCPUDataPtr cpuData,
+ const virCPUx86DataItem *item)
{
return virCPUx86DataAddItem(&cpuData->data.x86, item);
}
@@ -3117,7 +3117,7 @@ virCPUx86DataSetVendor(virCPUDataPtr cpuData,
if (virCPUx86VendorToCPUID(vendor, &item) < 0)
return -1;
- return virCPUx86DataAddCPUID(cpuData, &item);
+ return virCPUx86DataAdd(cpuData, &item);
}
diff --git a/src/cpu/cpu_x86.h b/src/cpu/cpu_x86.h
index 94655746c6..8b51cef9c1 100644
--- a/src/cpu/cpu_x86.h
+++ b/src/cpu/cpu_x86.h
@@ -29,8 +29,8 @@
extern struct cpuArchDriver cpuDriverX86;
-int virCPUx86DataAddCPUID(virCPUDataPtr cpuData,
- const virCPUx86DataItem *cpuid);
+int virCPUx86DataAdd(virCPUDataPtr cpuData,
+ const virCPUx86DataItem *cpuid);
int virCPUx86DataSetSignature(virCPUDataPtr cpuData,
unsigned int family,
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index a275fa9aa1..347667b17c 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1203,7 +1203,7 @@ virCPUValidateFeatures;
# cpu/cpu_x86.h
-virCPUx86DataAddCPUID;
+virCPUx86DataAdd;
virCPUx86DataAddFeature;
virCPUx86DataGetSignature;
virCPUx86DataSetSignature;
diff --git a/src/libxl/libxl_capabilities.c b/src/libxl/libxl_capabilities.c
index 231d72669f..2b351fbdde 100644
--- a/src/libxl/libxl_capabilities.c
+++ b/src/libxl/libxl_capabilities.c
@@ -73,7 +73,7 @@ libxlCapsAddCPUID(virCPUDataPtr data, virCPUx86CPUID *cpuid, ssize_t ncaps)
for (i = 0; i < ncaps; i++) {
item.cpuid = cpuid[i];
- if (virCPUx86DataAddCPUID(data, &item) < 0) {
+ if (virCPUx86DataAdd(data, &item) < 0) {
VIR_DEBUG("Failed to add CPUID(%x,%x)",
cpuid[i].eax_in, cpuid[i].ecx_in);
return -1;
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 0b4dfd70c0..abfaa6e68a 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -7052,7 +7052,7 @@ qemuMonitorJSONParseCPUx86Features(virJSONValuePtr data)
for (i = 0; i < virJSONValueArraySize(data); i++) {
if (qemuMonitorJSONParseCPUx86FeatureWord(virJSONValueArrayGet(data, i),
&item.cpuid) < 0 ||
- virCPUx86DataAddCPUID(cpudata, &item) < 0)
+ virCPUx86DataAdd(cpudata, &item) < 0)
goto error;
}
--
2.22.0

View File

@ -0,0 +1,107 @@
From 39da1d7fe9d2bd12c10c40de62c36724556797be Mon Sep 17 00:00:00 2001
Message-Id: <39da1d7fe9d2bd12c10c40de62c36724556797be@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:25:28 +0200
Subject: [PATCH] cpu_x86: Rename virCPUx86DataAddCPUIDInt
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The new name is virCPUx86DataAddItem.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit ce42042577ada2616a7b062f890677f9797c7bf9)
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <631af83ec447522318e8169b0b9ef607b764befa.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_x86.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index efb2a3bb07..7e077577d3 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -378,8 +378,8 @@ x86DataCopy(virCPUx86Data *dst, const virCPUx86Data *src)
static int
-virCPUx86DataAddCPUIDInt(virCPUx86Data *data,
- const virCPUx86DataItem *item)
+virCPUx86DataAddItem(virCPUx86Data *data,
+ const virCPUx86DataItem *item)
{
virCPUx86DataItemPtr existing;
@@ -412,7 +412,7 @@ x86DataAdd(virCPUx86Data *data1,
if (item1) {
x86cpuidSetBits(&item1->cpuid, &item2->cpuid);
} else {
- if (virCPUx86DataAddCPUIDInt(data1, item2) < 0)
+ if (virCPUx86DataAddItem(data1, item2) < 0)
return -1;
}
}
@@ -641,7 +641,7 @@ x86DataAddSignature(virCPUx86Data *data,
{
virCPUx86DataItem leaf1 = CPUID(.eax_in = 0x1, .eax = signature);
- return virCPUx86DataAddCPUIDInt(data, &leaf1);
+ return virCPUx86DataAddItem(data, &leaf1);
}
@@ -948,7 +948,7 @@ x86FeatureParse(xmlXPathContextPtr ctxt,
i, feature->name);
goto cleanup;
}
- if (virCPUx86DataAddCPUIDInt(&feature->data, &item))
+ if (virCPUx86DataAddItem(&feature->data, &item))
goto cleanup;
}
@@ -1664,8 +1664,8 @@ x86Compute(virCPUDefPtr host,
goto error;
if (cpu->vendor && host_model->vendor &&
- virCPUx86DataAddCPUIDInt(&guest_model->data,
- &host_model->vendor->data) < 0)
+ virCPUx86DataAddItem(&guest_model->data,
+ &host_model->vendor->data) < 0)
goto error;
if (host_model->signatures &&
@@ -2650,7 +2650,7 @@ virCPUx86Baseline(virCPUDefPtr *cpus,
}
if (vendor &&
- virCPUx86DataAddCPUIDInt(&base_model->data, &vendor->data) < 0)
+ virCPUx86DataAddItem(&base_model->data, &vendor->data) < 0)
goto error;
if (x86Decode(cpu, &base_model->data, models, modelName, migratable) < 0)
@@ -2949,7 +2949,7 @@ virCPUx86Translate(virCPUDefPtr cpu,
goto cleanup;
if (model->vendor &&
- virCPUx86DataAddCPUIDInt(&model->data, &model->vendor->data) < 0)
+ virCPUx86DataAddItem(&model->data, &model->vendor->data) < 0)
goto cleanup;
if (model->signatures &&
@@ -3080,7 +3080,7 @@ int
virCPUx86DataAddCPUID(virCPUDataPtr cpuData,
const virCPUx86DataItem *item)
{
- return virCPUx86DataAddCPUIDInt(&cpuData->data.x86, item);
+ return virCPUx86DataAddItem(&cpuData->data.x86, item);
}
--
2.22.0

View File

@ -0,0 +1,328 @@
From 74ecc2a0c728cf59279c61e1e9837423c72182e9 Mon Sep 17 00:00:00 2001
Message-Id: <74ecc2a0c728cf59279c61e1e9837423c72182e9@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:25:24 +0200
Subject: [PATCH] cpu_x86: Rename virCPUx86DataItem variables
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 6c22b329d5bc592a390bd4d802c55a2a44af750e)
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <570635ac7fb5f7a6514072ee4b871eb4d08f65bc.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_x86.c | 128 +++++++++++++++++++++++-----------------------
1 file changed, 64 insertions(+), 64 deletions(-)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 6e1fb37d20..74f4083aac 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -327,13 +327,13 @@ x86DataCpuidNext(virCPUx86DataIteratorPtr iterator)
static virCPUx86DataItemPtr
x86DataCpuid(const virCPUx86Data *data,
- const virCPUx86DataItem *cpuid)
+ const virCPUx86DataItem *item)
{
size_t i;
for (i = 0; i < data->len; i++) {
- if (data->items[i].cpuid.eax_in == cpuid->cpuid.eax_in &&
- data->items[i].cpuid.ecx_in == cpuid->cpuid.ecx_in)
+ if (data->items[i].cpuid.eax_in == item->cpuid.eax_in &&
+ data->items[i].cpuid.ecx_in == item->cpuid.ecx_in)
return data->items + i;
}
@@ -379,15 +379,15 @@ x86DataCopy(virCPUx86Data *dst, const virCPUx86Data *src)
static int
virCPUx86DataAddCPUIDInt(virCPUx86Data *data,
- const virCPUx86DataItem *cpuid)
+ const virCPUx86DataItem *item)
{
virCPUx86DataItemPtr existing;
- if ((existing = x86DataCpuid(data, cpuid))) {
- x86cpuidSetBits(&existing->cpuid, &cpuid->cpuid);
+ if ((existing = x86DataCpuid(data, item))) {
+ x86cpuidSetBits(&existing->cpuid, &item->cpuid);
} else {
if (VIR_APPEND_ELEMENT_COPY(data->items, data->len,
- *((virCPUx86DataItemPtr)cpuid)) < 0)
+ *((virCPUx86DataItemPtr)item)) < 0)
return -1;
qsort(data->items, data->len,
@@ -403,16 +403,16 @@ x86DataAdd(virCPUx86Data *data1,
const virCPUx86Data *data2)
{
virCPUx86DataIterator iter = virCPUx86DataIteratorInit(data2);
- virCPUx86DataItemPtr cpuid1;
- virCPUx86DataItemPtr cpuid2;
+ virCPUx86DataItemPtr item1;
+ virCPUx86DataItemPtr item2;
- while ((cpuid2 = x86DataCpuidNext(&iter))) {
- cpuid1 = x86DataCpuid(data1, cpuid2);
+ while ((item2 = x86DataCpuidNext(&iter))) {
+ item1 = x86DataCpuid(data1, item2);
- if (cpuid1) {
- x86cpuidSetBits(&cpuid1->cpuid, &cpuid2->cpuid);
+ if (item1) {
+ x86cpuidSetBits(&item1->cpuid, &item2->cpuid);
} else {
- if (virCPUx86DataAddCPUIDInt(data1, cpuid2) < 0)
+ if (virCPUx86DataAddCPUIDInt(data1, item2) < 0)
return -1;
}
}
@@ -426,12 +426,12 @@ x86DataSubtract(virCPUx86Data *data1,
const virCPUx86Data *data2)
{
virCPUx86DataIterator iter = virCPUx86DataIteratorInit(data1);
- virCPUx86DataItemPtr cpuid1;
- virCPUx86DataItemPtr cpuid2;
+ virCPUx86DataItemPtr item1;
+ virCPUx86DataItemPtr item2;
- while ((cpuid1 = x86DataCpuidNext(&iter))) {
- if ((cpuid2 = x86DataCpuid(data2, cpuid1)))
- x86cpuidClearBits(&cpuid1->cpuid, &cpuid2->cpuid);
+ while ((item1 = x86DataCpuidNext(&iter))) {
+ if ((item2 = x86DataCpuid(data2, item1)))
+ x86cpuidClearBits(&item1->cpuid, &item2->cpuid);
}
}
@@ -441,15 +441,15 @@ x86DataIntersect(virCPUx86Data *data1,
const virCPUx86Data *data2)
{
virCPUx86DataIterator iter = virCPUx86DataIteratorInit(data1);
- virCPUx86DataItemPtr cpuid1;
- virCPUx86DataItemPtr cpuid2;
+ virCPUx86DataItemPtr item1;
+ virCPUx86DataItemPtr item2;
- while ((cpuid1 = x86DataCpuidNext(&iter))) {
- cpuid2 = x86DataCpuid(data2, cpuid1);
- if (cpuid2)
- x86cpuidAndBits(&cpuid1->cpuid, &cpuid2->cpuid);
+ while ((item1 = x86DataCpuidNext(&iter))) {
+ item2 = x86DataCpuid(data2, item1);
+ if (item2)
+ x86cpuidAndBits(&item1->cpuid, &item2->cpuid);
else
- x86cpuidClearBits(&cpuid1->cpuid, &cpuid1->cpuid);
+ x86cpuidClearBits(&item1->cpuid, &item1->cpuid);
}
}
@@ -469,12 +469,12 @@ x86DataIsSubset(const virCPUx86Data *data,
{
virCPUx86DataIterator iter = virCPUx86DataIteratorInit((virCPUx86Data *)subset);
- const virCPUx86DataItem *cpuid;
- const virCPUx86DataItem *cpuidSubset;
+ const virCPUx86DataItem *item;
+ const virCPUx86DataItem *itemSubset;
- while ((cpuidSubset = x86DataCpuidNext(&iter))) {
- if (!(cpuid = x86DataCpuid(data, cpuidSubset)) ||
- !x86cpuidMatchMasked(&cpuid->cpuid, &cpuidSubset->cpuid))
+ while ((itemSubset = x86DataCpuidNext(&iter))) {
+ if (!(item = x86DataCpuid(data, itemSubset)) ||
+ !x86cpuidMatchMasked(&item->cpuid, &itemSubset->cpuid))
return false;
}
@@ -509,14 +509,14 @@ static virCPUx86VendorPtr
x86DataToVendor(const virCPUx86Data *data,
virCPUx86MapPtr map)
{
- virCPUx86DataItemPtr cpuid;
+ virCPUx86DataItemPtr item;
size_t i;
for (i = 0; i < map->nvendors; i++) {
virCPUx86VendorPtr vendor = map->vendors[i];
- if ((cpuid = x86DataCpuid(data, &vendor->data)) &&
- x86cpuidMatchMasked(&cpuid->cpuid, &vendor->data.cpuid)) {
- x86cpuidClearBits(&cpuid->cpuid, &vendor->data.cpuid);
+ if ((item = x86DataCpuid(data, &vendor->data)) &&
+ x86cpuidMatchMasked(&item->cpuid, &vendor->data.cpuid)) {
+ x86cpuidClearBits(&item->cpuid, &vendor->data.cpuid);
return vendor;
}
}
@@ -626,12 +626,12 @@ static uint32_t
x86DataToSignature(const virCPUx86Data *data)
{
virCPUx86DataItem leaf1 = CPUID(.eax_in = 0x1);
- virCPUx86DataItemPtr cpuid;
+ virCPUx86DataItemPtr item;
- if (!(cpuid = x86DataCpuid(data, &leaf1)))
+ if (!(item = x86DataCpuid(data, &leaf1)))
return 0;
- return cpuid->cpuid.eax & SIGNATURE_MASK;
+ return item->cpuid.eax & SIGNATURE_MASK;
}
@@ -639,9 +639,9 @@ static int
x86DataAddSignature(virCPUx86Data *data,
uint32_t signature)
{
- virCPUx86DataItem cpuid = CPUID(.eax_in = 0x1, .eax = signature);
+ virCPUx86DataItem leaf1 = CPUID(.eax_in = 0x1, .eax = signature);
- return virCPUx86DataAddCPUIDInt(data, &cpuid);
+ return virCPUx86DataAddCPUIDInt(data, &leaf1);
}
@@ -905,7 +905,7 @@ x86FeatureParse(xmlXPathContextPtr ctxt,
virCPUx86MapPtr map = data;
xmlNodePtr *nodes = NULL;
virCPUx86FeaturePtr feature;
- virCPUx86DataItem cpuid;
+ virCPUx86DataItem item;
size_t i;
int n;
char *str = NULL;
@@ -942,13 +942,13 @@ x86FeatureParse(xmlXPathContextPtr ctxt,
for (i = 0; i < n; i++) {
ctxt->node = nodes[i];
- if (x86ParseCPUID(ctxt, &cpuid) < 0) {
+ if (x86ParseCPUID(ctxt, &item) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Invalid cpuid[%zu] in %s feature"),
i, feature->name);
goto cleanup;
}
- if (virCPUx86DataAddCPUIDInt(&feature->data, &cpuid))
+ if (virCPUx86DataAddCPUIDInt(&feature->data, &item))
goto cleanup;
}
@@ -1148,16 +1148,16 @@ x86ModelCompare(virCPUx86ModelPtr model1,
virCPUx86CompareResult result = EQUAL;
virCPUx86DataIterator iter1 = virCPUx86DataIteratorInit(&model1->data);
virCPUx86DataIterator iter2 = virCPUx86DataIteratorInit(&model2->data);
- virCPUx86DataItemPtr cpuid1;
- virCPUx86DataItemPtr cpuid2;
+ virCPUx86DataItemPtr item1;
+ virCPUx86DataItemPtr item2;
- while ((cpuid1 = x86DataCpuidNext(&iter1))) {
+ while ((item1 = x86DataCpuidNext(&iter1))) {
virCPUx86CompareResult match = SUPERSET;
- if ((cpuid2 = x86DataCpuid(&model2->data, cpuid1))) {
- if (x86cpuidMatch(&cpuid1->cpuid, &cpuid2->cpuid))
+ if ((item2 = x86DataCpuid(&model2->data, item1))) {
+ if (x86cpuidMatch(&item1->cpuid, &item2->cpuid))
continue;
- else if (!x86cpuidMatchMasked(&cpuid1->cpuid, &cpuid2->cpuid))
+ else if (!x86cpuidMatchMasked(&item1->cpuid, &item2->cpuid))
match = SUBSET;
}
@@ -1167,13 +1167,13 @@ x86ModelCompare(virCPUx86ModelPtr model1,
return UNRELATED;
}
- while ((cpuid2 = x86DataCpuidNext(&iter2))) {
+ while ((item2 = x86DataCpuidNext(&iter2))) {
virCPUx86CompareResult match = SUBSET;
- if ((cpuid1 = x86DataCpuid(&model1->data, cpuid2))) {
- if (x86cpuidMatch(&cpuid2->cpuid, &cpuid1->cpuid))
+ if ((item1 = x86DataCpuid(&model1->data, item2))) {
+ if (x86cpuidMatch(&item2->cpuid, &item1->cpuid))
continue;
- else if (!x86cpuidMatchMasked(&cpuid2->cpuid, &cpuid1->cpuid))
+ else if (!x86cpuidMatchMasked(&item2->cpuid, &item1->cpuid))
match = SUPERSET;
}
@@ -1484,7 +1484,7 @@ virCPUx86DataParse(xmlXPathContextPtr ctxt)
{
xmlNodePtr *nodes = NULL;
virCPUDataPtr cpuData = NULL;
- virCPUx86DataItem cpuid;
+ virCPUx86DataItem item;
size_t i;
int n;
@@ -1500,12 +1500,12 @@ virCPUx86DataParse(xmlXPathContextPtr ctxt)
for (i = 0; i < n; i++) {
ctxt->node = nodes[i];
- if (x86ParseCPUID(ctxt, &cpuid) < 0) {
+ if (x86ParseCPUID(ctxt, &item) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("failed to parse cpuid[%zu]"), i);
goto error;
}
- if (virCPUx86DataAddCPUID(cpuData, &cpuid) < 0)
+ if (virCPUx86DataAddCPUID(cpuData, &item) < 0)
goto error;
}
@@ -2382,10 +2382,10 @@ cpuidSetLeaf12(virCPUDataPtr data,
{
virCPUx86DataItem item = CPUID(.eax_in = 0x7);
virCPUx86CPUIDPtr cpuid = &item.cpuid;
- virCPUx86DataItemPtr cpuid7;
+ virCPUx86DataItemPtr leaf7;
- if (!(cpuid7 = x86DataCpuid(&data->data.x86, &item)) ||
- !(cpuid7->cpuid.ebx & (1 << 2)))
+ if (!(leaf7 = x86DataCpuid(&data->data.x86, &item)) ||
+ !(leaf7->cpuid.ebx & (1 << 2)))
return 0;
if (virCPUx86DataAddCPUID(data, subLeaf0) < 0)
@@ -3078,9 +3078,9 @@ virCPUx86ValidateFeatures(virCPUDefPtr cpu)
int
virCPUx86DataAddCPUID(virCPUDataPtr cpuData,
- const virCPUx86DataItem *cpuid)
+ const virCPUx86DataItem *item)
{
- return virCPUx86DataAddCPUIDInt(&cpuData->data.x86, cpuid);
+ return virCPUx86DataAddCPUIDInt(&cpuData->data.x86, item);
}
@@ -3112,12 +3112,12 @@ int
virCPUx86DataSetVendor(virCPUDataPtr cpuData,
const char *vendor)
{
- virCPUx86DataItem cpuid = CPUID(0);
+ virCPUx86DataItem item = CPUID(0);
- if (virCPUx86VendorToCPUID(vendor, &cpuid) < 0)
+ if (virCPUx86VendorToCPUID(vendor, &item) < 0)
return -1;
- return virCPUx86DataAddCPUID(cpuData, &cpuid);
+ return virCPUx86DataAddCPUID(cpuData, &item);
}
--
2.22.0

View File

@ -0,0 +1,99 @@
From 088d9da6e6c4f3edc0293f78ba7270941d2e7fd0 Mon Sep 17 00:00:00 2001
Message-Id: <088d9da6e6c4f3edc0293f78ba7270941d2e7fd0@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:25:23 +0200
Subject: [PATCH] cpu_x86: Rename virCPUx86Vendor.cpuid
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Although vendor string is always reported by CPUID, the container struct
is used for consistency and thus "cpuid" name is not a good fit anymore.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit c02d70d52efc4b7af09e68847ef72ad47a6bdcf1)
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <0b6fccb50f2ce2b5d926a75c90a8107a300c8d57.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_x86.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 2e953eaa12..6e1fb37d20 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -49,7 +49,7 @@ typedef struct _virCPUx86Vendor virCPUx86Vendor;
typedef virCPUx86Vendor *virCPUx86VendorPtr;
struct _virCPUx86Vendor {
char *name;
- virCPUx86DataItem cpuid;
+ virCPUx86DataItem data;
};
typedef struct _virCPUx86Feature virCPUx86Feature;
@@ -514,9 +514,9 @@ x86DataToVendor(const virCPUx86Data *data,
for (i = 0; i < map->nvendors; i++) {
virCPUx86VendorPtr vendor = map->vendors[i];
- if ((cpuid = x86DataCpuid(data, &vendor->cpuid)) &&
- x86cpuidMatchMasked(&cpuid->cpuid, &vendor->cpuid.cpuid)) {
- x86cpuidClearBits(&cpuid->cpuid, &vendor->cpuid.cpuid);
+ if ((cpuid = x86DataCpuid(data, &vendor->data)) &&
+ x86cpuidMatchMasked(&cpuid->cpuid, &vendor->data.cpuid)) {
+ x86cpuidClearBits(&cpuid->cpuid, &vendor->data.cpuid);
return vendor;
}
}
@@ -759,7 +759,7 @@ x86VendorParse(xmlXPathContextPtr ctxt,
goto cleanup;
}
- if (virCPUx86VendorToCPUID(string, &vendor->cpuid) < 0)
+ if (virCPUx86VendorToCPUID(string, &vendor->data) < 0)
goto cleanup;
if (VIR_APPEND_ELEMENT(map->vendors, map->nvendors, vendor) < 0)
@@ -1665,7 +1665,7 @@ x86Compute(virCPUDefPtr host,
if (cpu->vendor && host_model->vendor &&
virCPUx86DataAddCPUIDInt(&guest_model->data,
- &host_model->vendor->cpuid) < 0)
+ &host_model->vendor->data) < 0)
goto error;
if (host_model->signatures &&
@@ -2153,7 +2153,7 @@ x86Encode(virArch arch,
if (!(data_vendor = virCPUDataNew(arch)))
goto error;
- if (v && virCPUx86DataAddCPUID(data_vendor, &v->cpuid) < 0)
+ if (v && virCPUx86DataAddCPUID(data_vendor, &v->data) < 0)
goto error;
}
@@ -2650,7 +2650,7 @@ virCPUx86Baseline(virCPUDefPtr *cpus,
}
if (vendor &&
- virCPUx86DataAddCPUIDInt(&base_model->data, &vendor->cpuid) < 0)
+ virCPUx86DataAddCPUIDInt(&base_model->data, &vendor->data) < 0)
goto error;
if (x86Decode(cpu, &base_model->data, models, modelName, migratable) < 0)
@@ -2949,7 +2949,7 @@ virCPUx86Translate(virCPUDefPtr cpu,
goto cleanup;
if (model->vendor &&
- virCPUx86DataAddCPUIDInt(&model->data, &model->vendor->cpuid) < 0)
+ virCPUx86DataAddCPUIDInt(&model->data, &model->vendor->data) < 0)
goto cleanup;
if (model->signatures &&
--
2.22.0

View File

@ -0,0 +1,60 @@
From c3573dbf60524401d06da6f6c5ce70a780494509 Mon Sep 17 00:00:00 2001
Message-Id: <c3573dbf60524401d06da6f6c5ce70a780494509@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:25:30 +0200
Subject: [PATCH] cpu_x86: Rename virCPUx86VendorToCPUID
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Renamed as virCPUx86VendorToData.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 3eff71a2d5048b30ded73bc6e542cbbd3e5b6193)
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <01af4e7922b394abeb1ea11856c188cb80ffb9a8.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_x86.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 6d48c9264c..9c0f39e76d 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -526,8 +526,8 @@ x86DataToVendor(const virCPUx86Data *data,
static int
-virCPUx86VendorToCPUID(const char *vendor,
- virCPUx86DataItemPtr data)
+virCPUx86VendorToData(const char *vendor,
+ virCPUx86DataItemPtr data)
{
virCPUx86CPUIDPtr cpuid = &data->cpuid;
@@ -759,7 +759,7 @@ x86VendorParse(xmlXPathContextPtr ctxt,
goto cleanup;
}
- if (virCPUx86VendorToCPUID(string, &vendor->data) < 0)
+ if (virCPUx86VendorToData(string, &vendor->data) < 0)
goto cleanup;
if (VIR_APPEND_ELEMENT(map->vendors, map->nvendors, vendor) < 0)
@@ -3114,7 +3114,7 @@ virCPUx86DataSetVendor(virCPUDataPtr cpuData,
{
virCPUx86DataItem item = CPUID(0);
- if (virCPUx86VendorToCPUID(vendor, &item) < 0)
+ if (virCPUx86VendorToData(vendor, &item) < 0)
return -1;
return virCPUx86DataAdd(cpuData, &item);
--
2.22.0

View File

@ -0,0 +1,141 @@
From 99431463aaf37298bc90f82bc6b20b44f4853246 Mon Sep 17 00:00:00 2001
Message-Id: <99431463aaf37298bc90f82bc6b20b44f4853246@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:25:26 +0200
Subject: [PATCH] cpu_x86: Rename x86DataCpuid
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
It is now called virCPUx86DataGet.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 609f467f1377da3418dad23fdd9f7136e462ba5b)
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <427e52b2993356d0170e2f756526e9d523686a42.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_x86.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index d9475e5b4a..52709f109e 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -326,8 +326,8 @@ virCPUx86DataNext(virCPUx86DataIteratorPtr iterator)
static virCPUx86DataItemPtr
-x86DataCpuid(const virCPUx86Data *data,
- const virCPUx86DataItem *item)
+virCPUx86DataGet(const virCPUx86Data *data,
+ const virCPUx86DataItem *item)
{
size_t i;
@@ -383,7 +383,7 @@ virCPUx86DataAddCPUIDInt(virCPUx86Data *data,
{
virCPUx86DataItemPtr existing;
- if ((existing = x86DataCpuid(data, item))) {
+ if ((existing = virCPUx86DataGet(data, item))) {
x86cpuidSetBits(&existing->cpuid, &item->cpuid);
} else {
if (VIR_APPEND_ELEMENT_COPY(data->items, data->len,
@@ -407,7 +407,7 @@ x86DataAdd(virCPUx86Data *data1,
virCPUx86DataItemPtr item2;
while ((item2 = virCPUx86DataNext(&iter))) {
- item1 = x86DataCpuid(data1, item2);
+ item1 = virCPUx86DataGet(data1, item2);
if (item1) {
x86cpuidSetBits(&item1->cpuid, &item2->cpuid);
@@ -430,7 +430,7 @@ x86DataSubtract(virCPUx86Data *data1,
virCPUx86DataItemPtr item2;
while ((item1 = virCPUx86DataNext(&iter))) {
- if ((item2 = x86DataCpuid(data2, item1)))
+ if ((item2 = virCPUx86DataGet(data2, item1)))
x86cpuidClearBits(&item1->cpuid, &item2->cpuid);
}
}
@@ -445,7 +445,7 @@ x86DataIntersect(virCPUx86Data *data1,
virCPUx86DataItemPtr item2;
while ((item1 = virCPUx86DataNext(&iter))) {
- item2 = x86DataCpuid(data2, item1);
+ item2 = virCPUx86DataGet(data2, item1);
if (item2)
x86cpuidAndBits(&item1->cpuid, &item2->cpuid);
else
@@ -473,7 +473,7 @@ x86DataIsSubset(const virCPUx86Data *data,
const virCPUx86DataItem *itemSubset;
while ((itemSubset = virCPUx86DataNext(&iter))) {
- if (!(item = x86DataCpuid(data, itemSubset)) ||
+ if (!(item = virCPUx86DataGet(data, itemSubset)) ||
!x86cpuidMatchMasked(&item->cpuid, &itemSubset->cpuid))
return false;
}
@@ -514,7 +514,7 @@ x86DataToVendor(const virCPUx86Data *data,
for (i = 0; i < map->nvendors; i++) {
virCPUx86VendorPtr vendor = map->vendors[i];
- if ((item = x86DataCpuid(data, &vendor->data)) &&
+ if ((item = virCPUx86DataGet(data, &vendor->data)) &&
x86cpuidMatchMasked(&item->cpuid, &vendor->data.cpuid)) {
x86cpuidClearBits(&item->cpuid, &vendor->data.cpuid);
return vendor;
@@ -609,7 +609,7 @@ x86DataToSignatureFull(const virCPUx86Data *data,
*family = *model = *stepping = 0;
- if (!(item = x86DataCpuid(data, &leaf1)))
+ if (!(item = virCPUx86DataGet(data, &leaf1)))
return;
cpuid = &item->cpuid;
@@ -628,7 +628,7 @@ x86DataToSignature(const virCPUx86Data *data)
virCPUx86DataItem leaf1 = CPUID(.eax_in = 0x1);
virCPUx86DataItemPtr item;
- if (!(item = x86DataCpuid(data, &leaf1)))
+ if (!(item = virCPUx86DataGet(data, &leaf1)))
return 0;
return item->cpuid.eax & SIGNATURE_MASK;
@@ -1154,7 +1154,7 @@ x86ModelCompare(virCPUx86ModelPtr model1,
while ((item1 = virCPUx86DataNext(&iter1))) {
virCPUx86CompareResult match = SUPERSET;
- if ((item2 = x86DataCpuid(&model2->data, item1))) {
+ if ((item2 = virCPUx86DataGet(&model2->data, item1))) {
if (x86cpuidMatch(&item1->cpuid, &item2->cpuid))
continue;
else if (!x86cpuidMatchMasked(&item1->cpuid, &item2->cpuid))
@@ -1170,7 +1170,7 @@ x86ModelCompare(virCPUx86ModelPtr model1,
while ((item2 = virCPUx86DataNext(&iter2))) {
virCPUx86CompareResult match = SUBSET;
- if ((item1 = x86DataCpuid(&model1->data, item2))) {
+ if ((item1 = virCPUx86DataGet(&model1->data, item2))) {
if (x86cpuidMatch(&item2->cpuid, &item1->cpuid))
continue;
else if (!x86cpuidMatchMasked(&item2->cpuid, &item1->cpuid))
@@ -2384,7 +2384,7 @@ cpuidSetLeaf12(virCPUDataPtr data,
virCPUx86CPUIDPtr cpuid = &item.cpuid;
virCPUx86DataItemPtr leaf7;
- if (!(leaf7 = x86DataCpuid(&data->data.x86, &item)) ||
+ if (!(leaf7 = virCPUx86DataGet(&data->data.x86, &item)) ||
!(leaf7->cpuid.ebx & (1 << 2)))
return 0;
--
2.22.0

View File

@ -0,0 +1,113 @@
From ad4abf728510a5fed123d46a223f19f0b8178045 Mon Sep 17 00:00:00 2001
Message-Id: <ad4abf728510a5fed123d46a223f19f0b8178045@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:25:25 +0200
Subject: [PATCH] cpu_x86: Rename x86DataCpuidNext function
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The function is now called virCPUx86DataNext to reflect its purpose: it
is an iterator over CPU data (both CPUID and MSR in the near future).
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 5655b83139e47b6c52d48a7d10640bf3508865eb)
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <bcc496d392ff77d824f53460cacb0a7de0993785.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_x86.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 74f4083aac..d9475e5b4a 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -307,7 +307,7 @@ virCPUx86CPUIDSorter(const void *a, const void *b)
/* skips all zero CPUID leaves */
static virCPUx86DataItemPtr
-x86DataCpuidNext(virCPUx86DataIteratorPtr iterator)
+virCPUx86DataNext(virCPUx86DataIteratorPtr iterator)
{
const virCPUx86Data *data = iterator->data;
@@ -406,7 +406,7 @@ x86DataAdd(virCPUx86Data *data1,
virCPUx86DataItemPtr item1;
virCPUx86DataItemPtr item2;
- while ((item2 = x86DataCpuidNext(&iter))) {
+ while ((item2 = virCPUx86DataNext(&iter))) {
item1 = x86DataCpuid(data1, item2);
if (item1) {
@@ -429,7 +429,7 @@ x86DataSubtract(virCPUx86Data *data1,
virCPUx86DataItemPtr item1;
virCPUx86DataItemPtr item2;
- while ((item1 = x86DataCpuidNext(&iter))) {
+ while ((item1 = virCPUx86DataNext(&iter))) {
if ((item2 = x86DataCpuid(data2, item1)))
x86cpuidClearBits(&item1->cpuid, &item2->cpuid);
}
@@ -444,7 +444,7 @@ x86DataIntersect(virCPUx86Data *data1,
virCPUx86DataItemPtr item1;
virCPUx86DataItemPtr item2;
- while ((item1 = x86DataCpuidNext(&iter))) {
+ while ((item1 = virCPUx86DataNext(&iter))) {
item2 = x86DataCpuid(data2, item1);
if (item2)
x86cpuidAndBits(&item1->cpuid, &item2->cpuid);
@@ -459,7 +459,7 @@ x86DataIsEmpty(virCPUx86Data *data)
{
virCPUx86DataIterator iter = virCPUx86DataIteratorInit(data);
- return !x86DataCpuidNext(&iter);
+ return !virCPUx86DataNext(&iter);
}
@@ -472,7 +472,7 @@ x86DataIsSubset(const virCPUx86Data *data,
const virCPUx86DataItem *item;
const virCPUx86DataItem *itemSubset;
- while ((itemSubset = x86DataCpuidNext(&iter))) {
+ while ((itemSubset = virCPUx86DataNext(&iter))) {
if (!(item = x86DataCpuid(data, itemSubset)) ||
!x86cpuidMatchMasked(&item->cpuid, &itemSubset->cpuid))
return false;
@@ -1151,7 +1151,7 @@ x86ModelCompare(virCPUx86ModelPtr model1,
virCPUx86DataItemPtr item1;
virCPUx86DataItemPtr item2;
- while ((item1 = x86DataCpuidNext(&iter1))) {
+ while ((item1 = virCPUx86DataNext(&iter1))) {
virCPUx86CompareResult match = SUPERSET;
if ((item2 = x86DataCpuid(&model2->data, item1))) {
@@ -1167,7 +1167,7 @@ x86ModelCompare(virCPUx86ModelPtr model1,
return UNRELATED;
}
- while ((item2 = x86DataCpuidNext(&iter2))) {
+ while ((item2 = virCPUx86DataNext(&iter2))) {
virCPUx86CompareResult match = SUBSET;
if ((item1 = x86DataCpuid(&model1->data, item2))) {
@@ -1461,7 +1461,7 @@ virCPUx86DataFormat(const virCPUData *data)
virBuffer buf = VIR_BUFFER_INITIALIZER;
virBufferAddLit(&buf, "<cpudata arch='x86'>\n");
- while ((item = x86DataCpuidNext(&iter))) {
+ while ((item = virCPUx86DataNext(&iter))) {
virCPUx86CPUIDPtr cpuid = &item->cpuid;
virBufferAsprintf(&buf,
" <cpuid eax_in='0x%08x' ecx_in='0x%08x'"
--
2.22.0

View File

@ -0,0 +1,46 @@
From c3148a408bd3c7ccf858bd5e0ac1139588847fc9 Mon Sep 17 00:00:00 2001
Message-Id: <c3148a408bd3c7ccf858bd5e0ac1139588847fc9@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:25:19 +0200
Subject: [PATCH] cpu_x86: Require <cpuid> within <feature> in CPU map
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
A feature with no cpuid element is invalid and it should not be silently
treated as a feature with all CPUID bits set to zero.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit dbc04114f3d14b53c999bd89db51276358b1aba3)
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <ea3bbf9cb28709fe52f43ce312c0171e2a62c1e8.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_x86.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 66aa5a612c..98e8d608d6 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -923,6 +923,13 @@ x86FeatureParse(xmlXPathContextPtr ctxt,
if (n < 0)
goto cleanup;
+ if (n == 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Missing cpuid for feature %s"),
+ feature->name);
+ goto cleanup;
+ }
+
for (i = 0; i < n; i++) {
ctxt->node = nodes[i];
if (x86ParseCPUID(ctxt, &cpuid) < 0) {
--
2.22.0

View File

@ -0,0 +1,110 @@
From 4111804c77930ebcda4fa5fae751074f75da4f1c Mon Sep 17 00:00:00 2001
Message-Id: <4111804c77930ebcda4fa5fae751074f75da4f1c@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:24:54 +0200
Subject: [PATCH] cpu_x86: Separate ancestor model parsing from x86ModelParse
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The code is separated into a new x86ModelParseAncestor function.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 2e1e2b910c6a9d31f2fb6d388ed72dc8f561b845)
https://bugzilla.redhat.com/show_bug.cgi?id=1686895
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <0e941dce0077eb7d7a31dffa60f7d647d66b95e6.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_x86.c | 65 +++++++++++++++++++++++++++--------------------
1 file changed, 38 insertions(+), 27 deletions(-)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index ce48ca6867..64788d60b3 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -1148,6 +1148,42 @@ x86ModelCompare(virCPUx86ModelPtr model1,
}
+static int
+x86ModelParseAncestor(virCPUx86ModelPtr model,
+ xmlXPathContextPtr ctxt,
+ virCPUx86MapPtr map)
+{
+ VIR_AUTOFREE(char *) name = NULL;
+ virCPUx86ModelPtr ancestor;
+ int rc;
+
+ if ((rc = virXPathBoolean("boolean(./model)", ctxt)) <= 0)
+ return rc;
+
+ name = virXPathString("string(./model/@name)", ctxt);
+ if (!name) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Missing ancestor's name in CPU model %s"),
+ model->name);
+ return -1;
+ }
+
+ if (!(ancestor = x86ModelFind(map, name))) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Ancestor model %s not found for CPU model %s"),
+ name, model->name);
+ return -1;
+ }
+
+ model->vendor = ancestor->vendor;
+ model->signature = ancestor->signature;
+ if (x86DataCopy(&model->data, &ancestor->data) < 0)
+ return -1;
+
+ return 0;
+}
+
+
static int
x86ModelParse(xmlXPathContextPtr ctxt,
const char *name,
@@ -1167,33 +1203,8 @@ x86ModelParse(xmlXPathContextPtr ctxt,
if (VIR_STRDUP(model->name, name) < 0)
goto cleanup;
- if (virXPathNode("./model", ctxt)) {
- virCPUx86ModelPtr ancestor;
- char *anname;
-
- anname = virXPathString("string(./model/@name)", ctxt);
- if (!anname) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Missing ancestor's name in CPU model %s"),
- model->name);
- goto cleanup;
- }
-
- if (!(ancestor = x86ModelFind(map, anname))) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Ancestor model %s not found for CPU model %s"),
- anname, model->name);
- VIR_FREE(anname);
- goto cleanup;
- }
-
- VIR_FREE(anname);
-
- model->vendor = ancestor->vendor;
- model->signature = ancestor->signature;
- if (x86DataCopy(&model->data, &ancestor->data) < 0)
- goto cleanup;
- }
+ if (x86ModelParseAncestor(model, ctxt, map) < 0)
+ goto cleanup;
if (virXPathBoolean("boolean(./signature)", ctxt)) {
unsigned int sigFamily = 0;
--
2.22.0

View File

@ -0,0 +1,129 @@
From 8d2f5155be8834db501930716e2cd2e1be14785c Mon Sep 17 00:00:00 2001
Message-Id: <8d2f5155be8834db501930716e2cd2e1be14785c@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:24:57 +0200
Subject: [PATCH] cpu_x86: Separate feature list parsing from x86ModelParse
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The code is separated into a new x86ModelParseFeatures function.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 8d249df9c917040d180202343e5cf7f70c3e4fe1)
https://bugzilla.redhat.com/show_bug.cgi?id=1686895
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <5a741350b39394a93aee99a3b98142548936bc2d.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_x86.c | 68 +++++++++++++++++++++++++++--------------------
1 file changed, 39 insertions(+), 29 deletions(-)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 62894cae9b..91362198ab 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -1247,16 +1247,51 @@ x86ModelParseVendor(virCPUx86ModelPtr model,
}
+static int
+x86ModelParseFeatures(virCPUx86ModelPtr model,
+ xmlXPathContextPtr ctxt,
+ virCPUx86MapPtr map)
+{
+ VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
+ size_t i;
+ int n;
+
+ if ((n = virXPathNodeSet("./feature", ctxt, &nodes)) <= 0)
+ return n;
+
+ for (i = 0; i < n; i++) {
+ VIR_AUTOFREE(char *) ftname = NULL;
+ virCPUx86FeaturePtr feature;
+
+ if (!(ftname = virXMLPropString(nodes[i], "name"))) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Missing feature name for CPU model %s"),
+ model->name);
+ return -1;
+ }
+
+ if (!(feature = x86FeatureFind(map, ftname))) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Feature %s required by CPU model %s not found"),
+ ftname, model->name);
+ return -1;
+ }
+
+ if (x86DataAdd(&model->data, &feature->data))
+ return -1;
+ }
+
+ return 0;
+}
+
+
static int
x86ModelParse(xmlXPathContextPtr ctxt,
const char *name,
void *data)
{
virCPUx86MapPtr map = data;
- xmlNodePtr *nodes = NULL;
virCPUx86ModelPtr model;
- size_t i;
- int n;
int ret = -1;
if (!(model = x86ModelNew()))
@@ -1274,33 +1309,9 @@ x86ModelParse(xmlXPathContextPtr ctxt,
if (x86ModelParseVendor(model, ctxt, map) < 0)
goto cleanup;
- n = virXPathNodeSet("./feature", ctxt, &nodes);
- if (n < 0)
+ if (x86ModelParseFeatures(model, ctxt, map) < 0)
goto cleanup;
- for (i = 0; i < n; i++) {
- virCPUx86FeaturePtr feature;
- char *ftname;
-
- if (!(ftname = virXMLPropString(nodes[i], "name"))) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Missing feature name for CPU model %s"), model->name);
- goto cleanup;
- }
-
- if (!(feature = x86FeatureFind(map, ftname))) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Feature %s required by CPU model %s not found"),
- ftname, model->name);
- VIR_FREE(ftname);
- goto cleanup;
- }
- VIR_FREE(ftname);
-
- if (x86DataAdd(&model->data, &feature->data))
- goto cleanup;
- }
-
if (VIR_APPEND_ELEMENT(map->models, map->nmodels, model) < 0)
goto cleanup;
@@ -1308,7 +1319,6 @@ x86ModelParse(xmlXPathContextPtr ctxt,
cleanup:
x86ModelFree(model);
- VIR_FREE(nodes);
return ret;
}
--
2.22.0

View File

@ -0,0 +1,103 @@
From e7b8b38fe1fe7e7d8eb9fab6cb3ded16652f60f8 Mon Sep 17 00:00:00 2001
Message-Id: <e7b8b38fe1fe7e7d8eb9fab6cb3ded16652f60f8@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:24:55 +0200
Subject: [PATCH] cpu_x86: Separate signature parsing from x86ModelParse
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The code is separated into a new x86ModelParseSignature function.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit fe78d2fda9f2dd67eb9daa98e48fbffa468d271e)
https://bugzilla.redhat.com/show_bug.cgi?id=1686895
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <616b60991bfdaa735804b839e258f6f1fa409a7b.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_x86.c | 58 ++++++++++++++++++++++++++++-------------------
1 file changed, 35 insertions(+), 23 deletions(-)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 64788d60b3..119ece4758 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -1184,6 +1184,39 @@ x86ModelParseAncestor(virCPUx86ModelPtr model,
}
+static int
+x86ModelParseSignature(virCPUx86ModelPtr model,
+ xmlXPathContextPtr ctxt)
+{
+
+ if (virXPathBoolean("boolean(./signature)", ctxt)) {
+ unsigned int sigFamily = 0;
+ unsigned int sigModel = 0;
+ int rc;
+
+ rc = virXPathUInt("string(./signature/@family)", ctxt, &sigFamily);
+ if (rc < 0 || sigFamily == 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Invalid CPU signature family in model %s"),
+ model->name);
+ return -1;
+ }
+
+ rc = virXPathUInt("string(./signature/@model)", ctxt, &sigModel);
+ if (rc < 0 || sigModel == 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Invalid CPU signature model in model %s"),
+ model->name);
+ return -1;
+ }
+
+ model->signature = x86MakeSignature(sigFamily, sigModel, 0);
+ }
+
+ return 0;
+}
+
+
static int
x86ModelParse(xmlXPathContextPtr ctxt,
const char *name,
@@ -1206,29 +1239,8 @@ x86ModelParse(xmlXPathContextPtr ctxt,
if (x86ModelParseAncestor(model, ctxt, map) < 0)
goto cleanup;
- if (virXPathBoolean("boolean(./signature)", ctxt)) {
- unsigned int sigFamily = 0;
- unsigned int sigModel = 0;
- int rc;
-
- rc = virXPathUInt("string(./signature/@family)", ctxt, &sigFamily);
- if (rc < 0 || sigFamily == 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Invalid CPU signature family in model %s"),
- model->name);
- goto cleanup;
- }
-
- rc = virXPathUInt("string(./signature/@model)", ctxt, &sigModel);
- if (rc < 0 || sigModel == 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Invalid CPU signature model in model %s"),
- model->name);
- goto cleanup;
- }
-
- model->signature = x86MakeSignature(sigFamily, sigModel, 0);
- }
+ if (x86ModelParseSignature(model, ctxt) < 0)
+ goto cleanup;
if (virXPathBoolean("boolean(./vendor)", ctxt)) {
vendor = virXPathString("string(./vendor/@name)", ctxt);
--
2.22.0

View File

@ -0,0 +1,109 @@
From e1b42297bc41c8f356693f2756e806a8c7275f4f Mon Sep 17 00:00:00 2001
Message-Id: <e1b42297bc41c8f356693f2756e806a8c7275f4f@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:24:56 +0200
Subject: [PATCH] cpu_x86: Separate vendor parsing from x86ModelParse
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The code is separated into a new x86ModelParseVendor function.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 232266839c994dcf2958f1efdfe74cfb7973a749)
https://bugzilla.redhat.com/show_bug.cgi?id=1686895
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <aaa0e5fac04ccd7b267e6912ceb3308249d9217e.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_x86.c | 50 ++++++++++++++++++++++++++++++-----------------
1 file changed, 32 insertions(+), 18 deletions(-)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 119ece4758..62894cae9b 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -1217,6 +1217,36 @@ x86ModelParseSignature(virCPUx86ModelPtr model,
}
+static int
+x86ModelParseVendor(virCPUx86ModelPtr model,
+ xmlXPathContextPtr ctxt,
+ virCPUx86MapPtr map)
+{
+ VIR_AUTOFREE(char *) vendor = NULL;
+ int rc;
+
+ if ((rc = virXPathBoolean("boolean(./vendor)", ctxt)) <= 0)
+ return rc;
+
+ vendor = virXPathString("string(./vendor/@name)", ctxt);
+ if (!vendor) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Invalid vendor element in CPU model %s"),
+ model->name);
+ return -1;
+ }
+
+ if (!(model->vendor = x86VendorFind(map, vendor))) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unknown vendor %s referenced by CPU model %s"),
+ vendor, model->name);
+ return -1;
+ }
+
+ return 0;
+}
+
+
static int
x86ModelParse(xmlXPathContextPtr ctxt,
const char *name,
@@ -1225,7 +1255,6 @@ x86ModelParse(xmlXPathContextPtr ctxt,
virCPUx86MapPtr map = data;
xmlNodePtr *nodes = NULL;
virCPUx86ModelPtr model;
- char *vendor = NULL;
size_t i;
int n;
int ret = -1;
@@ -1242,22 +1271,8 @@ x86ModelParse(xmlXPathContextPtr ctxt,
if (x86ModelParseSignature(model, ctxt) < 0)
goto cleanup;
- if (virXPathBoolean("boolean(./vendor)", ctxt)) {
- vendor = virXPathString("string(./vendor/@name)", ctxt);
- if (!vendor) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Invalid vendor element in CPU model %s"),
- model->name);
- goto cleanup;
- }
-
- if (!(model->vendor = x86VendorFind(map, vendor))) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Unknown vendor %s referenced by CPU model %s"),
- vendor, model->name);
- goto cleanup;
- }
- }
+ if (x86ModelParseVendor(model, ctxt, map) < 0)
+ goto cleanup;
n = virXPathNodeSet("./feature", ctxt, &nodes);
if (n < 0)
@@ -1293,7 +1308,6 @@ x86ModelParse(xmlXPathContextPtr ctxt,
cleanup:
x86ModelFree(model);
- VIR_FREE(vendor);
VIR_FREE(nodes);
return ret;
}
--
2.22.0

View File

@ -0,0 +1,54 @@
From ed7c9cb6444ec9344ebb253eac417703c5371c2d Mon Sep 17 00:00:00 2001
Message-Id: <ed7c9cb6444ec9344ebb253eac417703c5371c2d@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:25:31 +0200
Subject: [PATCH] cpu_x86: Simplify x86DataAdd
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The while loop just copied half of virCPUx86DataAddItem.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 0fdc0ad84c7ea27480f6f4edb82389d414584ada)
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <8ffc18c0ee7c61e5e1ce1af023ee7e6c62726f5a.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_x86.c | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 9c0f39e76d..0582be63e2 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -403,18 +403,11 @@ x86DataAdd(virCPUx86Data *data1,
const virCPUx86Data *data2)
{
virCPUx86DataIterator iter = virCPUx86DataIteratorInit(data2);
- virCPUx86DataItemPtr item1;
- virCPUx86DataItemPtr item2;
+ virCPUx86DataItemPtr item;
- while ((item2 = virCPUx86DataNext(&iter))) {
- item1 = virCPUx86DataGet(data1, item2);
-
- if (item1) {
- x86cpuidSetBits(&item1->cpuid, &item2->cpuid);
- } else {
- if (virCPUx86DataAddItem(data1, item2) < 0)
- return -1;
- }
+ while ((item = virCPUx86DataNext(&iter))) {
+ if (virCPUx86DataAddItem(data1, item) < 0)
+ return -1;
}
return 0;
--
2.22.0

View File

@ -0,0 +1,161 @@
From c7a8133cbe9d0612db2889038079d260c3a8334f Mon Sep 17 00:00:00 2001
Message-Id: <c7a8133cbe9d0612db2889038079d260c3a8334f@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:25:00 +0200
Subject: [PATCH] cpu_x86: Store CPU signature in an array
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
In preparation for storing several CPU signatures in a single CPU model,
we need to turn virCPUx86Model's signature into an array of signatures.
The parser still hardcodes the number of signatures to 1, but the
following patch will drop this limit.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit b07b8b7750c6a505d4b00bd272e79ea0305cb610)
https://bugzilla.redhat.com/show_bug.cgi?id=1686895
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <1d24aad1c6b9aa8142a2e882511f52a41fbaff67.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_x86.c | 50 ++++++++++++++++++++++++++++++++++++++---------
1 file changed, 41 insertions(+), 9 deletions(-)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index e25bc691ae..f8b8d8a96b 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -145,7 +145,8 @@ typedef virCPUx86Model *virCPUx86ModelPtr;
struct _virCPUx86Model {
char *name;
virCPUx86VendorPtr vendor;
- uint32_t signature;
+ size_t nsignatures;
+ uint32_t *signatures;
virCPUx86Data data;
};
@@ -972,6 +973,7 @@ x86ModelFree(virCPUx86ModelPtr model)
return;
VIR_FREE(model->name);
+ VIR_FREE(model->signatures);
virCPUx86DataClear(&model->data);
VIR_FREE(model);
}
@@ -981,7 +983,14 @@ static int
x86ModelCopySignatures(virCPUx86ModelPtr dst,
virCPUx86ModelPtr src)
{
- dst->signature = src->signature;
+ size_t i;
+
+ if (VIR_ALLOC_N(dst->signatures, src->nsignatures) < 0)
+ return -1;
+
+ dst->nsignatures = src->nsignatures;
+ for (i = 0; i < src->nsignatures; i++)
+ dst->signatures[i] = src->signatures[i];
return 0;
}
@@ -1198,12 +1207,18 @@ static int
x86ModelParseSignature(virCPUx86ModelPtr model,
xmlXPathContextPtr ctxt)
{
+ /* Remove inherited signatures. */
+ VIR_FREE(model->signatures);
if (virXPathBoolean("boolean(./signature)", ctxt)) {
unsigned int sigFamily = 0;
unsigned int sigModel = 0;
int rc;
+ model->nsignatures = 1;
+ if (VIR_ALLOC_N(model->signatures, 1) < 0)
+ return -1;
+
rc = virXPathUInt("string(./signature/@family)", ctxt, &sigFamily);
if (rc < 0 || sigFamily == 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -1220,7 +1235,7 @@ x86ModelParseSignature(virCPUx86ModelPtr model,
return -1;
}
- model->signature = x86MakeSignature(sigFamily, sigModel, 0);
+ model->signatures[0] = x86MakeSignature(sigFamily, sigModel, 0);
}
return 0;
@@ -1621,7 +1636,8 @@ x86Compute(virCPUDefPtr host,
&host_model->vendor->cpuid) < 0)
goto error;
- if (x86DataAddSignature(&guest_model->data, host_model->signature) < 0)
+ if (host_model->signatures &&
+ x86DataAddSignature(&guest_model->data, *host_model->signatures) < 0)
goto error;
if (cpu->type == VIR_CPU_TYPE_GUEST
@@ -1727,6 +1743,21 @@ virCPUx86Compare(virCPUDefPtr host,
}
+static bool
+x86ModelHasSignature(virCPUx86ModelPtr model,
+ uint32_t signature)
+{
+ size_t i;
+
+ for (i = 0; i < model->nsignatures; i++) {
+ if (model->signatures[i] == signature)
+ return true;
+ }
+
+ return false;
+}
+
+
/*
* Checks whether a candidate model is a better fit for the CPU data than the
* current model.
@@ -1768,8 +1799,8 @@ x86DecodeUseCandidate(virCPUx86ModelPtr current,
* consider candidates with matching family/model.
*/
if (signature &&
- current->signature == signature &&
- candidate->signature != signature) {
+ x86ModelHasSignature(current, signature) &&
+ !x86ModelHasSignature(candidate, signature)) {
VIR_DEBUG("%s differs in signature from matching %s",
cpuCandidate->model, cpuCurrent->model);
return 0;
@@ -1785,8 +1816,8 @@ x86DecodeUseCandidate(virCPUx86ModelPtr current,
* result in longer list of features.
*/
if (signature &&
- candidate->signature == signature &&
- current->signature != signature) {
+ x86ModelHasSignature(candidate, signature) &&
+ !x86ModelHasSignature(current, signature)) {
VIR_DEBUG("%s provides matching signature", cpuCandidate->model);
return 1;
}
@@ -2854,7 +2885,8 @@ virCPUx86Translate(virCPUDefPtr cpu,
virCPUx86DataAddCPUIDInt(&model->data, &model->vendor->cpuid) < 0)
goto cleanup;
- if (x86DataAddSignature(&model->data, model->signature) < 0)
+ if (model->signatures &&
+ x86DataAddSignature(&model->data, model->signatures[0]) < 0)
goto cleanup;
if (!(translated = virCPUDefCopyWithoutModel(cpu)))
--
2.22.0

View File

@ -0,0 +1,487 @@
From c465e315637d0b2cf01d2957de3d816186e0fd0f Mon Sep 17 00:00:00 2001
Message-Id: <c465e315637d0b2cf01d2957de3d816186e0fd0f@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:25:38 +0200
Subject: [PATCH] cpu_x86: Store virCPUx86DataItem content in union
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The structure can only be used for CPUID data now. Adding a type
indicator and moving the data into a union will let us store alternative
data types.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 370177e2f6784319b2fc86d8fe7a271248a5982e)
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <00cf7daca0cde66e9a90f64435182ef430983b2e.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_x86.c | 202 ++++++++++++++++++++++++---------
src/cpu/cpu_x86_data.h | 10 +-
src/libxl/libxl_capabilities.c | 3 +-
src/qemu/qemu_monitor_json.c | 3 +-
4 files changed, 160 insertions(+), 58 deletions(-)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 11c023ac31..e6da974b31 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -59,7 +59,9 @@ struct _virCPUx86Feature {
};
-#define CPUID(...) { .cpuid = {__VA_ARGS__} }
+#define CPUID(...) \
+ { .type = VIR_CPU_X86_DATA_CPUID, \
+ .data = { .cpuid = {__VA_ARGS__} } }
#define KVM_FEATURE_DEF(Name, Eax_in, Eax) \
static virCPUx86DataItem Name ## _data[] = { \
@@ -193,10 +195,22 @@ static bool
virCPUx86DataItemMatch(const virCPUx86DataItem *item1,
const virCPUx86DataItem *item2)
{
- return (item1->cpuid.eax == item2->cpuid.eax &&
- item1->cpuid.ebx == item2->cpuid.ebx &&
- item1->cpuid.ecx == item2->cpuid.ecx &&
- item1->cpuid.edx == item2->cpuid.edx);
+ const virCPUx86CPUID *cpuid1;
+ const virCPUx86CPUID *cpuid2;
+
+ switch (item1->type) {
+ case VIR_CPU_X86_DATA_CPUID:
+ cpuid1 = &item1->data.cpuid;
+ cpuid2 = &item2->data.cpuid;
+ return (cpuid1->eax == cpuid2->eax &&
+ cpuid1->ebx == cpuid2->ebx &&
+ cpuid1->ecx == cpuid2->ecx &&
+ cpuid1->edx == cpuid2->edx);
+
+ case VIR_CPU_X86_DATA_NONE:
+ default:
+ return false;
+ }
}
@@ -204,10 +218,22 @@ static bool
virCPUx86DataItemMatchMasked(const virCPUx86DataItem *item,
const virCPUx86DataItem *mask)
{
- return ((item->cpuid.eax & mask->cpuid.eax) == mask->cpuid.eax &&
- (item->cpuid.ebx & mask->cpuid.ebx) == mask->cpuid.ebx &&
- (item->cpuid.ecx & mask->cpuid.ecx) == mask->cpuid.ecx &&
- (item->cpuid.edx & mask->cpuid.edx) == mask->cpuid.edx);
+ const virCPUx86CPUID *cpuid;
+ const virCPUx86CPUID *cpuidMask;
+
+ switch (item->type) {
+ case VIR_CPU_X86_DATA_CPUID:
+ cpuid = &item->data.cpuid;
+ cpuidMask = &mask->data.cpuid;
+ return ((cpuid->eax & cpuidMask->eax) == cpuidMask->eax &&
+ (cpuid->ebx & cpuidMask->ebx) == cpuidMask->ebx &&
+ (cpuid->ecx & cpuidMask->ecx) == cpuidMask->ecx &&
+ (cpuid->edx & cpuidMask->edx) == cpuidMask->edx);
+
+ case VIR_CPU_X86_DATA_NONE:
+ default:
+ return false;
+ }
}
@@ -215,13 +241,26 @@ static void
virCPUx86DataItemSetBits(virCPUx86DataItemPtr item,
const virCPUx86DataItem *mask)
{
+ virCPUx86CPUIDPtr cpuid;
+ const virCPUx86CPUID *cpuidMask;
+
if (!mask)
return;
- item->cpuid.eax |= mask->cpuid.eax;
- item->cpuid.ebx |= mask->cpuid.ebx;
- item->cpuid.ecx |= mask->cpuid.ecx;
- item->cpuid.edx |= mask->cpuid.edx;
+ switch (item->type) {
+ case VIR_CPU_X86_DATA_CPUID:
+ cpuid = &item->data.cpuid;
+ cpuidMask = &mask->data.cpuid;
+ cpuid->eax |= cpuidMask->eax;
+ cpuid->ebx |= cpuidMask->ebx;
+ cpuid->ecx |= cpuidMask->ecx;
+ cpuid->edx |= cpuidMask->edx;
+ break;
+
+ case VIR_CPU_X86_DATA_NONE:
+ default:
+ break;
+ }
}
@@ -229,13 +268,26 @@ static void
virCPUx86DataItemClearBits(virCPUx86DataItemPtr item,
const virCPUx86DataItem *mask)
{
+ virCPUx86CPUIDPtr cpuid;
+ const virCPUx86CPUID *cpuidMask;
+
if (!mask)
return;
- item->cpuid.eax &= ~mask->cpuid.eax;
- item->cpuid.ebx &= ~mask->cpuid.ebx;
- item->cpuid.ecx &= ~mask->cpuid.ecx;
- item->cpuid.edx &= ~mask->cpuid.edx;
+ switch (item->type) {
+ case VIR_CPU_X86_DATA_CPUID:
+ cpuid = &item->data.cpuid;
+ cpuidMask = &mask->data.cpuid;
+ cpuid->eax &= ~cpuidMask->eax;
+ cpuid->ebx &= ~cpuidMask->ebx;
+ cpuid->ecx &= ~cpuidMask->ecx;
+ cpuid->edx &= ~cpuidMask->edx;
+ break;
+
+ case VIR_CPU_X86_DATA_NONE:
+ default:
+ break;
+ }
}
@@ -243,13 +295,26 @@ static void
virCPUx86DataItemAndBits(virCPUx86DataItemPtr item,
const virCPUx86DataItem *mask)
{
+ virCPUx86CPUIDPtr cpuid;
+ const virCPUx86CPUID *cpuidMask;
+
if (!mask)
return;
- item->cpuid.eax &= mask->cpuid.eax;
- item->cpuid.ebx &= mask->cpuid.ebx;
- item->cpuid.ecx &= mask->cpuid.ecx;
- item->cpuid.edx &= mask->cpuid.edx;
+ switch (item->type) {
+ case VIR_CPU_X86_DATA_CPUID:
+ cpuid = &item->data.cpuid;
+ cpuidMask = &mask->data.cpuid;
+ cpuid->eax &= cpuidMask->eax;
+ cpuid->ebx &= cpuidMask->ebx;
+ cpuid->ecx &= cpuidMask->ecx;
+ cpuid->edx &= cpuidMask->edx;
+ break;
+
+ case VIR_CPU_X86_DATA_NONE:
+ default:
+ break;
+ }
}
@@ -289,15 +354,29 @@ virCPUx86DataSorter(const void *a, const void *b)
virCPUx86DataItemPtr da = (virCPUx86DataItemPtr) a;
virCPUx86DataItemPtr db = (virCPUx86DataItemPtr) b;
- if (da->cpuid.eax_in > db->cpuid.eax_in)
+ if (da->type > db->type)
return 1;
- else if (da->cpuid.eax_in < db->cpuid.eax_in)
+ else if (da->type < db->type)
return -1;
- if (da->cpuid.ecx_in > db->cpuid.ecx_in)
- return 1;
- else if (da->cpuid.ecx_in < db->cpuid.ecx_in)
- return -1;
+ switch (da->type) {
+ case VIR_CPU_X86_DATA_CPUID:
+ if (da->data.cpuid.eax_in > db->data.cpuid.eax_in)
+ return 1;
+ else if (da->data.cpuid.eax_in < db->data.cpuid.eax_in)
+ return -1;
+
+ if (da->data.cpuid.ecx_in > db->data.cpuid.ecx_in)
+ return 1;
+ else if (da->data.cpuid.ecx_in < db->data.cpuid.ecx_in)
+ return -1;
+
+ break;
+
+ case VIR_CPU_X86_DATA_NONE:
+ default:
+ break;
+ }
return 0;
}
@@ -526,9 +605,9 @@ x86DataToVendor(const virCPUx86Data *data,
static int
virCPUx86VendorToData(const char *vendor,
- virCPUx86DataItemPtr data)
+ virCPUx86DataItemPtr item)
{
- virCPUx86CPUIDPtr cpuid = &data->cpuid;
+ virCPUx86CPUIDPtr cpuid;
if (strlen(vendor) != VENDOR_STRING_LENGTH) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -536,6 +615,8 @@ virCPUx86VendorToData(const char *vendor,
return -1;
}
+ item->type = VIR_CPU_X86_DATA_CPUID;
+ cpuid = &item->data.cpuid;
cpuid->eax_in = 0;
cpuid->ecx_in = 0;
cpuid->ebx = virReadBufInt32LE(vendor);
@@ -611,7 +692,7 @@ x86DataToSignatureFull(const virCPUx86Data *data,
if (!(item = virCPUx86DataGet(data, &leaf1)))
return;
- cpuid = &item->cpuid;
+ cpuid = &item->data.cpuid;
*family = ((cpuid->eax >> 20) & 0xff) + ((cpuid->eax >> 8) & 0xf);
*model = ((cpuid->eax >> 12) & 0xf0) + ((cpuid->eax >> 4) & 0xf);
*stepping = cpuid->eax & 0xf;
@@ -630,7 +711,7 @@ x86DataToSignature(const virCPUx86Data *data)
if (!(item = virCPUx86DataGet(data, &leaf1)))
return 0;
- return item->cpuid.eax & SIGNATURE_MASK;
+ return item->data.cpuid.eax & SIGNATURE_MASK;
}
@@ -885,7 +966,8 @@ x86ParseCPUID(xmlXPathContextPtr ctxt,
ret_eax == -2 || ret_ebx == -2 || ret_ecx == -2 || ret_edx == -2)
return -1;
- cpuid = &item->cpuid;
+ item->type = VIR_CPU_X86_DATA_CPUID;
+ cpuid = &item->data.cpuid;
cpuid->eax_in = eax_in;
cpuid->ecx_in = ecx_in;
cpuid->eax = eax;
@@ -1461,13 +1543,23 @@ virCPUx86DataFormat(const virCPUData *data)
virBufferAddLit(&buf, "<cpudata arch='x86'>\n");
while ((item = virCPUx86DataNext(&iter))) {
- virCPUx86CPUIDPtr cpuid = &item->cpuid;
- virBufferAsprintf(&buf,
- " <cpuid eax_in='0x%08x' ecx_in='0x%08x'"
- " eax='0x%08x' ebx='0x%08x'"
- " ecx='0x%08x' edx='0x%08x'/>\n",
- cpuid->eax_in, cpuid->ecx_in,
- cpuid->eax, cpuid->ebx, cpuid->ecx, cpuid->edx);
+ virCPUx86CPUIDPtr cpuid;
+
+ switch (item->type) {
+ case VIR_CPU_X86_DATA_CPUID:
+ cpuid = &item->data.cpuid;
+ virBufferAsprintf(&buf,
+ " <cpuid eax_in='0x%08x' ecx_in='0x%08x'"
+ " eax='0x%08x' ebx='0x%08x'"
+ " ecx='0x%08x' edx='0x%08x'/>\n",
+ cpuid->eax_in, cpuid->ecx_in,
+ cpuid->eax, cpuid->ebx, cpuid->ecx, cpuid->edx);
+ break;
+
+ case VIR_CPU_X86_DATA_NONE:
+ default:
+ break;
+ }
}
virBufferAddLit(&buf, "</cpudata>\n");
@@ -2226,7 +2318,7 @@ cpuidSetLeaf4(virCPUDataPtr data,
virCPUx86DataItemPtr subLeaf0)
{
virCPUx86DataItem item = *subLeaf0;
- virCPUx86CPUIDPtr cpuid = &item.cpuid;
+ virCPUx86CPUIDPtr cpuid = &item.data.cpuid;
if (virCPUx86DataAdd(data, subLeaf0) < 0)
return -1;
@@ -2250,13 +2342,13 @@ cpuidSetLeaf7(virCPUDataPtr data,
virCPUx86DataItemPtr subLeaf0)
{
virCPUx86DataItem item = CPUID(.eax_in = 0x7);
- virCPUx86CPUIDPtr cpuid = &item.cpuid;
+ virCPUx86CPUIDPtr cpuid = &item.data.cpuid;
uint32_t sub;
if (virCPUx86DataAdd(data, subLeaf0) < 0)
return -1;
- for (sub = 1; sub <= subLeaf0->cpuid.eax; sub++) {
+ for (sub = 1; sub <= subLeaf0->data.cpuid.eax; sub++) {
cpuid->ecx_in = sub;
cpuidCall(cpuid);
if (virCPUx86DataAdd(data, &item) < 0)
@@ -2278,7 +2370,7 @@ cpuidSetLeafB(virCPUDataPtr data,
virCPUx86DataItemPtr subLeaf0)
{
virCPUx86DataItem item = *subLeaf0;
- virCPUx86CPUIDPtr cpuid = &item.cpuid;
+ virCPUx86CPUIDPtr cpuid = &item.data.cpuid;
while (cpuid->ecx & 0xff00) {
if (virCPUx86DataAdd(data, &item) < 0)
@@ -2303,7 +2395,7 @@ cpuidSetLeafD(virCPUDataPtr data,
virCPUx86DataItemPtr subLeaf0)
{
virCPUx86DataItem item = CPUID(.eax_in = 0xd);
- virCPUx86CPUIDPtr cpuid = &item.cpuid;
+ virCPUx86CPUIDPtr cpuid = &item.data.cpuid;
virCPUx86CPUID sub0;
virCPUx86CPUID sub1;
uint32_t sub;
@@ -2316,7 +2408,7 @@ cpuidSetLeafD(virCPUDataPtr data,
if (virCPUx86DataAdd(data, &item) < 0)
return -1;
- sub0 = subLeaf0->cpuid;
+ sub0 = subLeaf0->data.cpuid;
sub1 = *cpuid;
for (sub = 2; sub < 64; sub++) {
if (sub < 32 &&
@@ -2351,8 +2443,8 @@ cpuidSetLeafResID(virCPUDataPtr data,
virCPUx86DataItemPtr subLeaf0,
uint32_t res)
{
- virCPUx86DataItem item = CPUID(.eax_in = subLeaf0->cpuid.eax_in);
- virCPUx86CPUIDPtr cpuid = &item.cpuid;
+ virCPUx86DataItem item = CPUID(.eax_in = subLeaf0->data.cpuid.eax_in);
+ virCPUx86CPUIDPtr cpuid = &item.data.cpuid;
uint32_t sub;
if (virCPUx86DataAdd(data, subLeaf0) < 0)
@@ -2380,11 +2472,11 @@ cpuidSetLeaf12(virCPUDataPtr data,
virCPUx86DataItemPtr subLeaf0)
{
virCPUx86DataItem item = CPUID(.eax_in = 0x7);
- virCPUx86CPUIDPtr cpuid = &item.cpuid;
+ virCPUx86CPUIDPtr cpuid = &item.data.cpuid;
virCPUx86DataItemPtr leaf7;
if (!(leaf7 = virCPUx86DataGet(&data->data.x86, &item)) ||
- !(leaf7->cpuid.ebx & (1 << 2)))
+ !(leaf7->data.cpuid.ebx & (1 << 2)))
return 0;
if (virCPUx86DataAdd(data, subLeaf0) < 0)
@@ -2417,13 +2509,13 @@ cpuidSetLeaf14(virCPUDataPtr data,
virCPUx86DataItemPtr subLeaf0)
{
virCPUx86DataItem item = CPUID(.eax_in = 0x14);
- virCPUx86CPUIDPtr cpuid = &item.cpuid;
+ virCPUx86CPUIDPtr cpuid = &item.data.cpuid;
uint32_t sub;
if (virCPUx86DataAdd(data, subLeaf0) < 0)
return -1;
- for (sub = 1; sub <= subLeaf0->cpuid.eax; sub++) {
+ for (sub = 1; sub <= subLeaf0->data.cpuid.eax; sub++) {
cpuid->ecx_in = sub;
cpuidCall(cpuid);
if (virCPUx86DataAdd(data, &item) < 0)
@@ -2443,16 +2535,16 @@ cpuidSetLeaf17(virCPUDataPtr data,
virCPUx86DataItemPtr subLeaf0)
{
virCPUx86DataItem item = CPUID(.eax_in = 0x17);
- virCPUx86CPUIDPtr cpuid = &item.cpuid;
+ virCPUx86CPUIDPtr cpuid = &item.data.cpuid;
uint32_t sub;
- if (subLeaf0->cpuid.eax < 3)
+ if (subLeaf0->data.cpuid.eax < 3)
return 0;
if (virCPUx86DataAdd(data, subLeaf0) < 0)
return -1;
- for (sub = 1; sub <= subLeaf0->cpuid.eax; sub++) {
+ for (sub = 1; sub <= subLeaf0->data.cpuid.eax; sub++) {
cpuid->ecx_in = sub;
cpuidCall(cpuid);
if (virCPUx86DataAdd(data, &item) < 0)
@@ -2469,7 +2561,7 @@ cpuidSet(uint32_t base, virCPUDataPtr data)
uint32_t max;
uint32_t leaf;
virCPUx86DataItem item = CPUID(.eax_in = base);
- virCPUx86CPUIDPtr cpuid = &item.cpuid;
+ virCPUx86CPUIDPtr cpuid = &item.data.cpuid;
cpuidCall(cpuid);
max = cpuid->eax;
diff --git a/src/cpu/cpu_x86_data.h b/src/cpu/cpu_x86_data.h
index e93b355cf0..da8e91fe71 100644
--- a/src/cpu/cpu_x86_data.h
+++ b/src/cpu/cpu_x86_data.h
@@ -71,10 +71,18 @@ struct _virCPUx86CPUID {
# define VIR_CPU_X86_DATA_INIT { 0 }
+typedef enum {
+ VIR_CPU_X86_DATA_NONE = 0,
+ VIR_CPU_X86_DATA_CPUID,
+} virCPUx86DataType;
+
typedef struct _virCPUx86DataItem virCPUx86DataItem;
typedef virCPUx86DataItem *virCPUx86DataItemPtr;
struct _virCPUx86DataItem {
- virCPUx86CPUID cpuid;
+ virCPUx86DataType type;
+ union {
+ virCPUx86CPUID cpuid;
+ } data;
};
typedef struct _virCPUx86Data virCPUx86Data;
diff --git a/src/libxl/libxl_capabilities.c b/src/libxl/libxl_capabilities.c
index 2b351fbdde..6630aa2c0b 100644
--- a/src/libxl/libxl_capabilities.c
+++ b/src/libxl/libxl_capabilities.c
@@ -70,8 +70,9 @@ libxlCapsAddCPUID(virCPUDataPtr data, virCPUx86CPUID *cpuid, ssize_t ncaps)
virCPUx86DataItem item = { 0 };
size_t i;
+ item.type = VIR_CPU_X86_DATA_CPUID;
for (i = 0; i < ncaps; i++) {
- item.cpuid = cpuid[i];
+ item.data.cpuid = cpuid[i];
if (virCPUx86DataAdd(data, &item) < 0) {
VIR_DEBUG("Failed to add CPUID(%x,%x)",
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index abfaa6e68a..e6ac82e96b 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -7049,9 +7049,10 @@ qemuMonitorJSONParseCPUx86Features(virJSONValuePtr data)
if (!(cpudata = virCPUDataNew(VIR_ARCH_X86_64)))
goto error;
+ item.type = VIR_CPU_X86_DATA_CPUID;
for (i = 0; i < virJSONValueArraySize(data); i++) {
if (qemuMonitorJSONParseCPUx86FeatureWord(virJSONValueArrayGet(data, i),
- &item.cpuid) < 0 ||
+ &item.data.cpuid) < 0 ||
virCPUx86DataAdd(cpudata, &item) < 0)
goto error;
}
--
2.22.0

View File

@ -0,0 +1,147 @@
From 14c5258d4227930fdadcd0bc9de3cae547b56b70 Mon Sep 17 00:00:00 2001
Message-Id: <14c5258d4227930fdadcd0bc9de3cae547b56b70@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:26:07 +0200
Subject: [PATCH] cpu_x86: Turn virCPUx86DataIteratorInit into a function
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Until now, this was a macro usable for direct initialization when a
variable is defined. Turning the macro into a function makes it more
general.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit b8e086a570b14b1f83fc07e25df6da758abe7706)
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
Conflicts:
src/cpu/cpu_x86.c
- commit c9ed87a6103fd4f09e0714f3a2b94c4c975477cd was not
backported
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <eb52120d5047b6581f645dc334a327530261f5ed.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_x86.c | 35 ++++++++++++++++++++++++-----------
1 file changed, 24 insertions(+), 11 deletions(-)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index ead962ae06..75527fd28f 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -187,8 +187,13 @@ struct _virCPUx86DataIterator {
};
-#define virCPUx86DataIteratorInit(data) \
- { data, -1 }
+static void
+virCPUx86DataIteratorInit(virCPUx86DataIteratorPtr iterator,
+ const virCPUx86Data *data)
+{
+ virCPUx86DataIterator iter = { data, -1 };
+ *iterator = iter;
+}
static bool
@@ -538,9 +543,10 @@ static int
x86DataAdd(virCPUx86Data *data1,
const virCPUx86Data *data2)
{
- virCPUx86DataIterator iter = virCPUx86DataIteratorInit(data2);
+ virCPUx86DataIterator iter;
virCPUx86DataItemPtr item;
+ virCPUx86DataIteratorInit(&iter, data2);
while ((item = virCPUx86DataNext(&iter))) {
if (virCPUx86DataAddItem(data1, item) < 0)
return -1;
@@ -554,10 +560,11 @@ static void
x86DataSubtract(virCPUx86Data *data1,
const virCPUx86Data *data2)
{
- virCPUx86DataIterator iter = virCPUx86DataIteratorInit(data1);
+ virCPUx86DataIterator iter;
virCPUx86DataItemPtr item1;
virCPUx86DataItemPtr item2;
+ virCPUx86DataIteratorInit(&iter, data1);
while ((item1 = virCPUx86DataNext(&iter))) {
item2 = virCPUx86DataGet(data2, item1);
virCPUx86DataItemClearBits(item1, item2);
@@ -569,10 +576,11 @@ static void
x86DataIntersect(virCPUx86Data *data1,
const virCPUx86Data *data2)
{
- virCPUx86DataIterator iter = virCPUx86DataIteratorInit(data1);
+ virCPUx86DataIterator iter;
virCPUx86DataItemPtr item1;
virCPUx86DataItemPtr item2;
+ virCPUx86DataIteratorInit(&iter, data1);
while ((item1 = virCPUx86DataNext(&iter))) {
item2 = virCPUx86DataGet(data2, item1);
if (item2)
@@ -586,8 +594,9 @@ x86DataIntersect(virCPUx86Data *data1,
static bool
x86DataIsEmpty(virCPUx86Data *data)
{
- virCPUx86DataIterator iter = virCPUx86DataIteratorInit(data);
+ virCPUx86DataIterator iter;
+ virCPUx86DataIteratorInit(&iter, data);
return !virCPUx86DataNext(&iter);
}
@@ -596,11 +605,11 @@ static bool
x86DataIsSubset(const virCPUx86Data *data,
const virCPUx86Data *subset)
{
-
- virCPUx86DataIterator iter = virCPUx86DataIteratorInit((virCPUx86Data *)subset);
+ virCPUx86DataIterator iter;
const virCPUx86DataItem *item;
const virCPUx86DataItem *itemSubset;
+ virCPUx86DataIteratorInit(&iter, subset);
while ((itemSubset = virCPUx86DataNext(&iter))) {
if (!(item = virCPUx86DataGet(data, itemSubset)) ||
!virCPUx86DataItemMatchMasked(item, itemSubset))
@@ -1313,11 +1322,13 @@ x86ModelCompare(virCPUx86ModelPtr model1,
virCPUx86ModelPtr model2)
{
virCPUx86CompareResult result = EQUAL;
- virCPUx86DataIterator iter1 = virCPUx86DataIteratorInit(&model1->data);
- virCPUx86DataIterator iter2 = virCPUx86DataIteratorInit(&model2->data);
+ virCPUx86DataIterator iter1;
+ virCPUx86DataIterator iter2;
virCPUx86DataItemPtr item1;
virCPUx86DataItemPtr item2;
+ virCPUx86DataIteratorInit(&iter1, &model1->data);
+ virCPUx86DataIteratorInit(&iter2, &model2->data);
while ((item1 = virCPUx86DataNext(&iter1))) {
virCPUx86CompareResult match = SUPERSET;
@@ -1623,10 +1634,12 @@ virCPUx86GetMap(void)
static char *
virCPUx86DataFormat(const virCPUData *data)
{
- virCPUx86DataIterator iter = virCPUx86DataIteratorInit(&data->data.x86);
+ virCPUx86DataIterator iter;
virCPUx86DataItemPtr item;
virBuffer buf = VIR_BUFFER_INITIALIZER;
+ virCPUx86DataIteratorInit(&iter, &data->data.x86);
+
virBufferAddLit(&buf, "<cpudata arch='x86'>\n");
while ((item = virCPUx86DataNext(&iter))) {
virCPUx86CPUIDPtr cpuid;
--
2.22.0

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,979 @@
From 7ea297f4cff68e0f5f44f91e1ba1283fce05de6f Mon Sep 17 00:00:00 2001
Message-Id: <7ea297f4cff68e0f5f44f91e1ba1283fce05de6f@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:24:50 +0200
Subject: [PATCH] cputest: Add data for Intel(R) Core(TM) i7-7600U
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit cd11ea73d01b256437e25bc635c51d08518c8c77)
https://bugzilla.redhat.com/show_bug.cgi?id=1686895
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <6a76550993bbc3e13f59daeea8e03ab0a0891997.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
tests/cputest.c | 1 +
.../x86_64-cpuid-Core-i7-7600U-disabled.xml | 6 +
.../x86_64-cpuid-Core-i7-7600U-enabled.xml | 8 +
.../x86_64-cpuid-Core-i7-7600U-guest.xml | 28 +
.../x86_64-cpuid-Core-i7-7600U-host.xml | 29 +
.../x86_64-cpuid-Core-i7-7600U-json.xml | 13 +
.../x86_64-cpuid-Core-i7-7600U.json | 755 ++++++++++++++++++
.../x86_64-cpuid-Core-i7-7600U.xml | 47 ++
8 files changed, 887 insertions(+)
create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-7600U-disabled.xml
create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-7600U-enabled.xml
create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-7600U-guest.xml
create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-7600U-host.xml
create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-7600U-json.xml
create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-7600U.json
create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-7600U.xml
diff --git a/tests/cputest.c b/tests/cputest.c
index f43144edc9..28d575a784 100644
--- a/tests/cputest.c
+++ b/tests/cputest.c
@@ -1176,6 +1176,7 @@ mymain(void)
DO_TEST_CPUID(VIR_ARCH_X86_64, "Core-i7-5600U", JSON_HOST);
DO_TEST_CPUID(VIR_ARCH_X86_64, "Core-i7-5600U-arat", JSON_HOST);
DO_TEST_CPUID(VIR_ARCH_X86_64, "Core-i7-5600U-ibrs", JSON_HOST);
+ DO_TEST_CPUID(VIR_ARCH_X86_64, "Core-i7-7600U", JSON_MODELS);
DO_TEST_CPUID(VIR_ARCH_X86_64, "Core-i7-7700", JSON_MODELS);
DO_TEST_CPUID(VIR_ARCH_X86_64, "Core2-E6850", JSON_HOST);
DO_TEST_CPUID(VIR_ARCH_X86_64, "Core2-Q9500", JSON_NONE);
diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-7600U-disabled.xml b/tests/cputestdata/x86_64-cpuid-Core-i7-7600U-disabled.xml
new file mode 100644
index 0000000000..0a567bbfae
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Core-i7-7600U-disabled.xml
@@ -0,0 +1,6 @@
+<!-- Features disabled by QEMU -->
+<cpudata arch='x86'>
+ <cpuid eax_in='0x00000001' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x0800c1dc' edx='0xb0600000'/>
+ <cpuid eax_in='0x00000007' ecx_in='0x00' eax='0x00000000' ebx='0x02000000' ecx='0x00000000' edx='0x08000000'/>
+ <cpuid eax_in='0x80000007' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000100'/>
+</cpudata>
diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-7600U-enabled.xml b/tests/cputestdata/x86_64-cpuid-Core-i7-7600U-enabled.xml
new file mode 100644
index 0000000000..b1cdaa802a
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Core-i7-7600U-enabled.xml
@@ -0,0 +1,8 @@
+<!-- Features enabled by QEMU -->
+<cpudata arch='x86'>
+ <cpuid eax_in='0x00000001' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0xf7fa3223' edx='0x0f8bfbff'/>
+ <cpuid eax_in='0x00000006' ecx_in='0x00' eax='0x00000004' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x00000007' ecx_in='0x00' eax='0x00000000' ebx='0x009c4fbb' ecx='0x00000004' edx='0x84000000'/>
+ <cpuid eax_in='0x0000000d' ecx_in='0x01' eax='0x0000000f' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x80000001' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000121' edx='0x2c100800'/>
+</cpudata>
diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-7600U-guest.xml b/tests/cputestdata/x86_64-cpuid-Core-i7-7600U-guest.xml
new file mode 100644
index 0000000000..70a0fc3286
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Core-i7-7600U-guest.xml
@@ -0,0 +1,28 @@
+<cpu mode='custom' match='exact'>
+ <model fallback='forbid'>Skylake-Client-IBRS</model>
+ <vendor>Intel</vendor>
+ <feature policy='require' name='ds'/>
+ <feature policy='require' name='acpi'/>
+ <feature policy='require' name='ss'/>
+ <feature policy='require' name='ht'/>
+ <feature policy='require' name='tm'/>
+ <feature policy='require' name='pbe'/>
+ <feature policy='require' name='dtes64'/>
+ <feature policy='require' name='monitor'/>
+ <feature policy='require' name='ds_cpl'/>
+ <feature policy='require' name='vmx'/>
+ <feature policy='require' name='smx'/>
+ <feature policy='require' name='est'/>
+ <feature policy='require' name='tm2'/>
+ <feature policy='require' name='xtpr'/>
+ <feature policy='require' name='pdcm'/>
+ <feature policy='require' name='osxsave'/>
+ <feature policy='require' name='tsc_adjust'/>
+ <feature policy='require' name='clflushopt'/>
+ <feature policy='require' name='intel-pt'/>
+ <feature policy='require' name='stibp'/>
+ <feature policy='require' name='ssbd'/>
+ <feature policy='require' name='xsaves'/>
+ <feature policy='require' name='pdpe1gb'/>
+ <feature policy='require' name='invtsc'/>
+</cpu>
diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-7600U-host.xml b/tests/cputestdata/x86_64-cpuid-Core-i7-7600U-host.xml
new file mode 100644
index 0000000000..bbdfb6aa61
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Core-i7-7600U-host.xml
@@ -0,0 +1,29 @@
+<cpu>
+ <arch>x86_64</arch>
+ <model>Skylake-Client-IBRS</model>
+ <vendor>Intel</vendor>
+ <feature name='ds'/>
+ <feature name='acpi'/>
+ <feature name='ss'/>
+ <feature name='ht'/>
+ <feature name='tm'/>
+ <feature name='pbe'/>
+ <feature name='dtes64'/>
+ <feature name='monitor'/>
+ <feature name='ds_cpl'/>
+ <feature name='vmx'/>
+ <feature name='smx'/>
+ <feature name='est'/>
+ <feature name='tm2'/>
+ <feature name='xtpr'/>
+ <feature name='pdcm'/>
+ <feature name='osxsave'/>
+ <feature name='tsc_adjust'/>
+ <feature name='clflushopt'/>
+ <feature name='intel-pt'/>
+ <feature name='stibp'/>
+ <feature name='ssbd'/>
+ <feature name='xsaves'/>
+ <feature name='pdpe1gb'/>
+ <feature name='invtsc'/>
+</cpu>
diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-7600U-json.xml b/tests/cputestdata/x86_64-cpuid-Core-i7-7600U-json.xml
new file mode 100644
index 0000000000..48089c6003
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Core-i7-7600U-json.xml
@@ -0,0 +1,13 @@
+<cpu mode='custom' match='exact'>
+ <model fallback='forbid'>Skylake-Client-IBRS</model>
+ <vendor>Intel</vendor>
+ <feature policy='require' name='ss'/>
+ <feature policy='require' name='vmx'/>
+ <feature policy='require' name='hypervisor'/>
+ <feature policy='require' name='tsc_adjust'/>
+ <feature policy='require' name='clflushopt'/>
+ <feature policy='require' name='umip'/>
+ <feature policy='require' name='ssbd'/>
+ <feature policy='require' name='xsaves'/>
+ <feature policy='require' name='pdpe1gb'/>
+</cpu>
diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-7600U.json b/tests/cputestdata/x86_64-cpuid-Core-i7-7600U.json
new file mode 100644
index 0000000000..9a258e6be3
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Core-i7-7600U.json
@@ -0,0 +1,755 @@
+{
+ "return": {
+ "model": {
+ "name": "base",
+ "props": {
+ "phys-bits": 0,
+ "core-id": -1,
+ "xlevel": 2147483656,
+ "cmov": true,
+ "ia64": false,
+ "ssb-no": false,
+ "aes": true,
+ "mmx": true,
+ "rdpid": false,
+ "arat": true,
+ "gfni": false,
+ "ibrs-all": false,
+ "pause-filter": false,
+ "xsavec": true,
+ "intel-pt": false,
+ "hv-frequencies": false,
+ "tsc-frequency": 0,
+ "xd": true,
+ "hv-vendor-id": "",
+ "kvm-asyncpf": true,
+ "kvm_asyncpf": true,
+ "perfctr_core": false,
+ "perfctr-core": false,
+ "mpx": true,
+ "pbe": false,
+ "decodeassists": false,
+ "avx512cd": false,
+ "sse4_1": true,
+ "sse4.1": true,
+ "sse4-1": true,
+ "family": 6,
+ "legacy-cache": true,
+ "vmware-cpuid-freq": true,
+ "wbnoinvd": false,
+ "avx512f": false,
+ "msr": true,
+ "mce": true,
+ "mca": true,
+ "hv-runtime": false,
+ "xcrypt": false,
+ "thread-id": -1,
+ "min-level": 13,
+ "xgetbv1": true,
+ "cid": false,
+ "hv-relaxed": false,
+ "hv-crash": false,
+ "ds": false,
+ "fxsr": true,
+ "xsaveopt": true,
+ "xtpr": false,
+ "hv-evmcs": false,
+ "avx512vl": false,
+ "avx512-vpopcntdq": false,
+ "phe": false,
+ "extapic": false,
+ "3dnowprefetch": true,
+ "avx512vbmi2": false,
+ "cr8legacy": false,
+ "cpuid-0xb": true,
+ "xcrypt-en": false,
+ "kvm_pv_eoi": true,
+ "apic-id": 4294967295,
+ "rsba": false,
+ "pn": false,
+ "dca": false,
+ "vendor": "GenuineIntel",
+ "hv-ipi": false,
+ "pku": false,
+ "smx": false,
+ "cmp_legacy": false,
+ "cmp-legacy": false,
+ "node-id": -1,
+ "avx512-4fmaps": false,
+ "vmcb_clean": false,
+ "vmcb-clean": false,
+ "3dnowext": false,
+ "amd-no-ssb": false,
+ "hle": true,
+ "npt": false,
+ "rdctl-no": false,
+ "memory": "/machine/unattached/system[0]",
+ "clwb": false,
+ "lbrv": false,
+ "adx": true,
+ "ss": true,
+ "pni": true,
+ "svm_lock": false,
+ "svm-lock": false,
+ "pfthreshold": false,
+ "smep": true,
+ "smap": true,
+ "x2apic": true,
+ "avx512vbmi": false,
+ "avx512vnni": false,
+ "hv-stimer": false,
+ "x-hv-synic-kvm-only": false,
+ "i64": true,
+ "flushbyasid": false,
+ "f16c": true,
+ "ace2-en": false,
+ "pat": true,
+ "pae": true,
+ "sse": true,
+ "phe-en": false,
+ "kvm_nopiodelay": true,
+ "kvm-nopiodelay": true,
+ "tm": false,
+ "kvmclock-stable-bit": true,
+ "hypervisor": true,
+ "socket-id": -1,
+ "pcommit": false,
+ "syscall": true,
+ "level": 13,
+ "avx512dq": false,
+ "x-migrate-smi-count": true,
+ "svm": false,
+ "full-cpuid-auto-level": true,
+ "hv-reset": false,
+ "invtsc": false,
+ "sse3": true,
+ "sse2": true,
+ "ssbd": true,
+ "est": false,
+ "avx512ifma": false,
+ "tm2": false,
+ "kvm-pv-ipi": true,
+ "kvm-pv-eoi": true,
+ "cx8": true,
+ "cldemote": false,
+ "hv-reenlightenment": false,
+ "kvm_mmu": false,
+ "kvm-mmu": false,
+ "sse4_2": true,
+ "sse4.2": true,
+ "sse4-2": true,
+ "pge": true,
+ "fill-mtrr-mask": true,
+ "avx512bitalg": false,
+ "nodeid_msr": false,
+ "pdcm": false,
+ "movbe": true,
+ "model": 142,
+ "nrip_save": false,
+ "nrip-save": false,
+ "kvm_pv_unhalt": true,
+ "ssse3": true,
+ "sse4a": false,
+ "invpcid": true,
+ "pdpe1gb": true,
+ "tsc-deadline": true,
+ "skip-l1dfl-vmentry": true,
+ "fma": true,
+ "cx16": true,
+ "de": true,
+ "pconfig": false,
+ "enforce": false,
+ "stepping": 9,
+ "xsave": true,
+ "clflush": true,
+ "skinit": false,
+ "tsc": true,
+ "tce": false,
+ "fpu": true,
+ "ibs": false,
+ "ds_cpl": false,
+ "ds-cpl": false,
+ "host-phys-bits": false,
+ "fma4": false,
+ "la57": false,
+ "osvw": false,
+ "check": true,
+ "hv-spinlocks": -1,
+ "pmu": false,
+ "pmm": false,
+ "apic": true,
+ "spec-ctrl": true,
+ "min-xlevel2": 0,
+ "tsc-adjust": true,
+ "tsc_adjust": true,
+ "kvm-steal-time": true,
+ "kvm_steal_time": true,
+ "kvmclock": true,
+ "l3-cache": true,
+ "lwp": false,
+ "amd-ssbd": false,
+ "ibpb": false,
+ "xop": false,
+ "avx": true,
+ "ace2": false,
+ "avx512bw": false,
+ "acpi": false,
+ "hv-vapic": false,
+ "fsgsbase": true,
+ "ht": false,
+ "nx": true,
+ "pclmulqdq": true,
+ "mmxext": false,
+ "vaes": false,
+ "popcnt": true,
+ "xsaves": true,
+ "tcg-cpuid": true,
+ "lm": true,
+ "umip": true,
+ "pse": true,
+ "avx2": true,
+ "sep": true,
+ "pclmuldq": true,
+ "virt-ssbd": false,
+ "x-hv-max-vps": -1,
+ "nodeid-msr": false,
+ "kvm": true,
+ "misalignsse": false,
+ "min-xlevel": 2147483656,
+ "kvm-pv-unhalt": true,
+ "bmi2": true,
+ "bmi1": true,
+ "realized": false,
+ "tsc_scale": false,
+ "tsc-scale": false,
+ "topoext": false,
+ "hv-vpindex": false,
+ "xlevel2": 0,
+ "clflushopt": true,
+ "kvm-no-smi-migration": false,
+ "monitor": false,
+ "avx512er": false,
+ "pmm-en": false,
+ "pcid": true,
+ "arch-capabilities": false,
+ "3dnow": false,
+ "erms": true,
+ "lahf-lm": true,
+ "lahf_lm": true,
+ "vpclmulqdq": false,
+ "fxsr-opt": false,
+ "hv-synic": false,
+ "xstore": false,
+ "fxsr_opt": false,
+ "kvm-hint-dedicated": false,
+ "rtm": true,
+ "lmce": true,
+ "hv-time": false,
+ "perfctr-nb": false,
+ "perfctr_nb": false,
+ "ffxsr": false,
+ "hv-tlbflush": false,
+ "rdrand": true,
+ "rdseed": true,
+ "avx512-4vnniw": false,
+ "vmx": true,
+ "vme": true,
+ "dtes64": false,
+ "mtrr": true,
+ "rdtscp": true,
+ "pse36": true,
+ "kvm-pv-tlb-flush": true,
+ "tbm": false,
+ "wdt": false,
+ "pause_filter": false,
+ "sha-ni": false,
+ "model-id": "Intel(R) Core(TM) i7-7600U CPU @ 2.80GHz",
+ "abm": true,
+ "avx512pf": false,
+ "xstore-en": false
+ }
+ }
+ },
+ "id": "model-expansion"
+}
+
+
+{
+ "return": [
+ {
+ "name": "max",
+ "typename": "max-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": false
+ },
+ {
+ "name": "host",
+ "typename": "host-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": false
+ },
+ {
+ "name": "base",
+ "typename": "base-x86_64-cpu",
+ "unavailable-features": [],
+ "static": true,
+ "migration-safe": true
+ },
+ {
+ "name": "qemu64",
+ "typename": "qemu64-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "qemu32",
+ "typename": "qemu32-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "phenom",
+ "typename": "phenom-x86_64-cpu",
+ "unavailable-features": [
+ "mmxext",
+ "fxsr-opt",
+ "3dnowext",
+ "3dnow",
+ "sse4a",
+ "npt"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "pentium3",
+ "typename": "pentium3-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "pentium2",
+ "typename": "pentium2-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "pentium",
+ "typename": "pentium-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "n270",
+ "typename": "n270-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "kvm64",
+ "typename": "kvm64-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "kvm32",
+ "typename": "kvm32-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "coreduo",
+ "typename": "coreduo-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "core2duo",
+ "typename": "core2duo-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "athlon",
+ "typename": "athlon-x86_64-cpu",
+ "unavailable-features": [
+ "mmxext",
+ "3dnowext",
+ "3dnow"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Westmere-IBRS",
+ "typename": "Westmere-IBRS-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Westmere",
+ "typename": "Westmere-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Skylake-Server-IBRS",
+ "typename": "Skylake-Server-IBRS-x86_64-cpu",
+ "unavailable-features": [
+ "avx512f",
+ "avx512dq",
+ "clwb",
+ "avx512cd",
+ "avx512bw",
+ "avx512vl",
+ "pku",
+ "avx512f",
+ "avx512f",
+ "avx512f",
+ "pku"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Skylake-Server",
+ "typename": "Skylake-Server-x86_64-cpu",
+ "unavailable-features": [
+ "avx512f",
+ "avx512dq",
+ "clwb",
+ "avx512cd",
+ "avx512bw",
+ "avx512vl",
+ "pku",
+ "avx512f",
+ "avx512f",
+ "avx512f",
+ "pku"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Skylake-Client-IBRS",
+ "typename": "Skylake-Client-IBRS-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Skylake-Client",
+ "typename": "Skylake-Client-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "SandyBridge-IBRS",
+ "typename": "SandyBridge-IBRS-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "SandyBridge",
+ "typename": "SandyBridge-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Penryn",
+ "typename": "Penryn-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Opteron_G5",
+ "typename": "Opteron_G5-x86_64-cpu",
+ "unavailable-features": [
+ "sse4a",
+ "misalignsse",
+ "xop",
+ "fma4",
+ "tbm"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Opteron_G4",
+ "typename": "Opteron_G4-x86_64-cpu",
+ "unavailable-features": [
+ "sse4a",
+ "misalignsse",
+ "xop",
+ "fma4"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Opteron_G3",
+ "typename": "Opteron_G3-x86_64-cpu",
+ "unavailable-features": [
+ "sse4a",
+ "misalignsse"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Opteron_G2",
+ "typename": "Opteron_G2-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Opteron_G1",
+ "typename": "Opteron_G1-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Nehalem-IBRS",
+ "typename": "Nehalem-IBRS-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Nehalem",
+ "typename": "Nehalem-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "KnightsMill",
+ "typename": "KnightsMill-x86_64-cpu",
+ "unavailable-features": [
+ "avx512f",
+ "avx512pf",
+ "avx512er",
+ "avx512cd",
+ "avx512-vpopcntdq",
+ "avx512-4vnniw",
+ "avx512-4fmaps",
+ "avx512f",
+ "avx512f",
+ "avx512f"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "IvyBridge-IBRS",
+ "typename": "IvyBridge-IBRS-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "IvyBridge",
+ "typename": "IvyBridge-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Icelake-Server",
+ "typename": "Icelake-Server-x86_64-cpu",
+ "unavailable-features": [
+ "avx512f",
+ "avx512dq",
+ "clwb",
+ "intel-pt",
+ "avx512cd",
+ "avx512bw",
+ "avx512vl",
+ "avx512vbmi",
+ "pku",
+ "",
+ "avx512vbmi2",
+ "gfni",
+ "vaes",
+ "vpclmulqdq",
+ "avx512vnni",
+ "avx512bitalg",
+ "avx512-vpopcntdq",
+ "la57",
+ "pconfig",
+ "wbnoinvd",
+ "avx512f",
+ "avx512f",
+ "avx512f",
+ "pku"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Icelake-Client",
+ "typename": "Icelake-Client-x86_64-cpu",
+ "unavailable-features": [
+ "intel-pt",
+ "avx512vbmi",
+ "pku",
+ "",
+ "avx512vbmi2",
+ "gfni",
+ "vaes",
+ "vpclmulqdq",
+ "avx512vnni",
+ "avx512bitalg",
+ "avx512-vpopcntdq",
+ "wbnoinvd",
+ "pku"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Haswell-noTSX-IBRS",
+ "typename": "Haswell-noTSX-IBRS-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Haswell-noTSX",
+ "typename": "Haswell-noTSX-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Haswell-IBRS",
+ "typename": "Haswell-IBRS-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Haswell",
+ "typename": "Haswell-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "EPYC-IBPB",
+ "typename": "EPYC-IBPB-x86_64-cpu",
+ "unavailable-features": [
+ "sha-ni",
+ "mmxext",
+ "fxsr-opt",
+ "cr8legacy",
+ "sse4a",
+ "misalignsse",
+ "osvw",
+ "ibpb"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "EPYC",
+ "typename": "EPYC-x86_64-cpu",
+ "unavailable-features": [
+ "sha-ni",
+ "mmxext",
+ "fxsr-opt",
+ "cr8legacy",
+ "sse4a",
+ "misalignsse",
+ "osvw"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Conroe",
+ "typename": "Conroe-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Cascadelake-Server",
+ "typename": "Cascadelake-Server-x86_64-cpu",
+ "unavailable-features": [
+ "avx512f",
+ "avx512dq",
+ "clwb",
+ "intel-pt",
+ "avx512cd",
+ "avx512bw",
+ "avx512vl",
+ "pku",
+ "",
+ "avx512vnni",
+ "avx512f",
+ "avx512f",
+ "avx512f",
+ "pku"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Broadwell-noTSX-IBRS",
+ "typename": "Broadwell-noTSX-IBRS-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Broadwell-noTSX",
+ "typename": "Broadwell-noTSX-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Broadwell-IBRS",
+ "typename": "Broadwell-IBRS-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Broadwell",
+ "typename": "Broadwell-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "486",
+ "typename": "486-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ }
+ ],
+ "id": "definitions"
+}
diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-7600U.xml b/tests/cputestdata/x86_64-cpuid-Core-i7-7600U.xml
new file mode 100644
index 0000000000..d46811e3d3
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Core-i7-7600U.xml
@@ -0,0 +1,47 @@
+<!-- Intel(R) Core(TM) i7-7600U CPU @ 2.80GHz -->
+<cpudata arch='x86'>
+ <cpuid eax_in='0x00000000' ecx_in='0x00' eax='0x00000016' ebx='0x756e6547' ecx='0x6c65746e' edx='0x49656e69'/>
+ <cpuid eax_in='0x00000001' ecx_in='0x00' eax='0x000806e9' ebx='0x03100800' ecx='0x7ffafbff' edx='0xbfebfbff'/>
+ <cpuid eax_in='0x00000002' ecx_in='0x00' eax='0x76036301' ebx='0x00f0b5ff' ecx='0x00000000' edx='0x00c30000'/>
+ <cpuid eax_in='0x00000003' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x00000004' ecx_in='0x00' eax='0x1c004121' ebx='0x01c0003f' ecx='0x0000003f' edx='0x00000000'/>
+ <cpuid eax_in='0x00000004' ecx_in='0x01' eax='0x1c004122' ebx='0x01c0003f' ecx='0x0000003f' edx='0x00000000'/>
+ <cpuid eax_in='0x00000004' ecx_in='0x02' eax='0x1c004143' ebx='0x00c0003f' ecx='0x000003ff' edx='0x00000000'/>
+ <cpuid eax_in='0x00000004' ecx_in='0x03' eax='0x1c03c163' ebx='0x03c0003f' ecx='0x00000fff' edx='0x00000006'/>
+ <cpuid eax_in='0x00000005' ecx_in='0x00' eax='0x00000040' ebx='0x00000040' ecx='0x00000003' edx='0x11142120'/>
+ <cpuid eax_in='0x00000006' ecx_in='0x00' eax='0x000027f7' ebx='0x00000002' ecx='0x00000009' edx='0x00000000'/>
+ <cpuid eax_in='0x00000007' ecx_in='0x00' eax='0x00000000' ebx='0x029c6fbf' ecx='0x00000000' edx='0x9c000000'/>
+ <cpuid eax_in='0x00000008' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x00000009' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x0000000a' ecx_in='0x00' eax='0x07300404' ebx='0x00000000' ecx='0x00000000' edx='0x00000603'/>
+ <cpuid eax_in='0x0000000b' ecx_in='0x00' eax='0x00000001' ebx='0x00000002' ecx='0x00000100' edx='0x00000003'/>
+ <cpuid eax_in='0x0000000b' ecx_in='0x01' eax='0x00000004' ebx='0x00000004' ecx='0x00000201' edx='0x00000003'/>
+ <cpuid eax_in='0x0000000c' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x0000000d' ecx_in='0x00' eax='0x0000001f' ebx='0x00000440' ecx='0x00000440' edx='0x00000000'/>
+ <cpuid eax_in='0x0000000d' ecx_in='0x01' eax='0x0000000f' ebx='0x000003c0' ecx='0x00000100' edx='0x00000000'/>
+ <cpuid eax_in='0x0000000d' ecx_in='0x02' eax='0x00000100' ebx='0x00000240' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x0000000d' ecx_in='0x03' eax='0x00000040' ebx='0x000003c0' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x0000000d' ecx_in='0x04' eax='0x00000040' ebx='0x00000400' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x0000000d' ecx_in='0x08' eax='0x00000080' ebx='0x00000000' ecx='0x00000001' edx='0x00000000'/>
+ <cpuid eax_in='0x0000000e' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x0000000f' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x00000010' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x00000011' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x00000012' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x00000013' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x00000014' ecx_in='0x00' eax='0x00000001' ebx='0x0000000f' ecx='0x00000007' edx='0x00000000'/>
+ <cpuid eax_in='0x00000014' ecx_in='0x01' eax='0x02490002' ebx='0x003f3fff' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x00000015' ecx_in='0x00' eax='0x00000002' ebx='0x000000f2' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x00000016' ecx_in='0x00' eax='0x00000b54' ebx='0x00000f3c' ecx='0x00000064' edx='0x00000000'/>
+ <cpuid eax_in='0x80000000' ecx_in='0x00' eax='0x80000008' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x80000001' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000121' edx='0x2c100800'/>
+ <cpuid eax_in='0x80000002' ecx_in='0x00' eax='0x65746e49' ebx='0x2952286c' ecx='0x726f4320' edx='0x4d542865'/>
+ <cpuid eax_in='0x80000003' ecx_in='0x00' eax='0x37692029' ebx='0x3036372d' ecx='0x43205530' edx='0x40205550'/>
+ <cpuid eax_in='0x80000004' ecx_in='0x00' eax='0x382e3220' ebx='0x7a484730' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x80000005' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x80000006' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x01006040' edx='0x00000000'/>
+ <cpuid eax_in='0x80000007' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000100'/>
+ <cpuid eax_in='0x80000008' ecx_in='0x00' eax='0x00003027' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x80860000' ecx_in='0x00' eax='0x00000b54' ebx='0x00000f3c' ecx='0x00000064' edx='0x00000000'/>
+ <cpuid eax_in='0xc0000000' ecx_in='0x00' eax='0x00000b54' ebx='0x00000f3c' ecx='0x00000064' edx='0x00000000'/>
+</cpudata>
--
2.22.0

View File

@ -0,0 +1,873 @@
From 697bcb394816e4880cdbdb211527f057f4aea564 Mon Sep 17 00:00:00 2001
Message-Id: <697bcb394816e4880cdbdb211527f057f4aea564@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:24:53 +0200
Subject: [PATCH] cputest: Add data for Intel(R) Core(TM) i7-8700
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 87a46f5d8f8b67b22eab8b25cd30a6b9901d6857)
https://bugzilla.redhat.com/show_bug.cgi?id=1686895
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <2d5616ba4b88ef12435b52cfd7c90ce3360a83ef.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
tests/cputest.c | 1 +
.../x86_64-cpuid-Core-i7-8700-disabled.xml | 6 +
.../x86_64-cpuid-Core-i7-8700-enabled.xml | 8 +
.../x86_64-cpuid-Core-i7-8700-guest.xml | 28 +
.../x86_64-cpuid-Core-i7-8700-host.xml | 29 +
.../x86_64-cpuid-Core-i7-8700-json.xml | 12 +
.../x86_64-cpuid-Core-i7-8700.json | 650 ++++++++++++++++++
.../cputestdata/x86_64-cpuid-Core-i7-8700.xml | 47 ++
8 files changed, 781 insertions(+)
create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-8700-disabled.xml
create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-8700-enabled.xml
create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-8700-guest.xml
create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-8700-host.xml
create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-8700-json.xml
create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-8700.json
create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-8700.xml
diff --git a/tests/cputest.c b/tests/cputest.c
index bcbfe2d08a..9e5f807823 100644
--- a/tests/cputest.c
+++ b/tests/cputest.c
@@ -1178,6 +1178,7 @@ mymain(void)
DO_TEST_CPUID(VIR_ARCH_X86_64, "Core-i7-5600U-ibrs", JSON_HOST);
DO_TEST_CPUID(VIR_ARCH_X86_64, "Core-i7-7600U", JSON_MODELS);
DO_TEST_CPUID(VIR_ARCH_X86_64, "Core-i7-7700", JSON_MODELS);
+ DO_TEST_CPUID(VIR_ARCH_X86_64, "Core-i7-8700", JSON_MODELS);
DO_TEST_CPUID(VIR_ARCH_X86_64, "Core2-E6850", JSON_HOST);
DO_TEST_CPUID(VIR_ARCH_X86_64, "Core2-Q9500", JSON_NONE);
DO_TEST_CPUID(VIR_ARCH_X86_64, "EPYC-7601-32-Core", JSON_HOST);
diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-8700-disabled.xml b/tests/cputestdata/x86_64-cpuid-Core-i7-8700-disabled.xml
new file mode 100644
index 0000000000..6a7de576f1
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Core-i7-8700-disabled.xml
@@ -0,0 +1,6 @@
+<!-- Features disabled by QEMU -->
+<cpudata arch='x86'>
+ <cpuid eax_in='0x00000001' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x0800c1fc' edx='0xb0600000'/>
+ <cpuid eax_in='0x00000007' ecx_in='0x00' eax='0x00000000' ebx='0x02000000' ecx='0x00000000' edx='0x08000000'/>
+ <cpuid eax_in='0x80000007' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000100'/>
+</cpudata>
diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-8700-enabled.xml b/tests/cputestdata/x86_64-cpuid-Core-i7-8700-enabled.xml
new file mode 100644
index 0000000000..f0727d497b
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Core-i7-8700-enabled.xml
@@ -0,0 +1,8 @@
+<!-- Features enabled by QEMU -->
+<cpudata arch='x86'>
+ <cpuid eax_in='0x00000001' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0xf7fa3203' edx='0x0f8bfbff'/>
+ <cpuid eax_in='0x00000006' ecx_in='0x00' eax='0x00000004' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x00000007' ecx_in='0x00' eax='0x00000000' ebx='0x009c4fbb' ecx='0x00000004' edx='0x84000000'/>
+ <cpuid eax_in='0x0000000d' ecx_in='0x01' eax='0x0000000f' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x80000001' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000121' edx='0x2c100800'/>
+</cpudata>
diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-8700-guest.xml b/tests/cputestdata/x86_64-cpuid-Core-i7-8700-guest.xml
new file mode 100644
index 0000000000..70a0fc3286
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Core-i7-8700-guest.xml
@@ -0,0 +1,28 @@
+<cpu mode='custom' match='exact'>
+ <model fallback='forbid'>Skylake-Client-IBRS</model>
+ <vendor>Intel</vendor>
+ <feature policy='require' name='ds'/>
+ <feature policy='require' name='acpi'/>
+ <feature policy='require' name='ss'/>
+ <feature policy='require' name='ht'/>
+ <feature policy='require' name='tm'/>
+ <feature policy='require' name='pbe'/>
+ <feature policy='require' name='dtes64'/>
+ <feature policy='require' name='monitor'/>
+ <feature policy='require' name='ds_cpl'/>
+ <feature policy='require' name='vmx'/>
+ <feature policy='require' name='smx'/>
+ <feature policy='require' name='est'/>
+ <feature policy='require' name='tm2'/>
+ <feature policy='require' name='xtpr'/>
+ <feature policy='require' name='pdcm'/>
+ <feature policy='require' name='osxsave'/>
+ <feature policy='require' name='tsc_adjust'/>
+ <feature policy='require' name='clflushopt'/>
+ <feature policy='require' name='intel-pt'/>
+ <feature policy='require' name='stibp'/>
+ <feature policy='require' name='ssbd'/>
+ <feature policy='require' name='xsaves'/>
+ <feature policy='require' name='pdpe1gb'/>
+ <feature policy='require' name='invtsc'/>
+</cpu>
diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-8700-host.xml b/tests/cputestdata/x86_64-cpuid-Core-i7-8700-host.xml
new file mode 100644
index 0000000000..bbdfb6aa61
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Core-i7-8700-host.xml
@@ -0,0 +1,29 @@
+<cpu>
+ <arch>x86_64</arch>
+ <model>Skylake-Client-IBRS</model>
+ <vendor>Intel</vendor>
+ <feature name='ds'/>
+ <feature name='acpi'/>
+ <feature name='ss'/>
+ <feature name='ht'/>
+ <feature name='tm'/>
+ <feature name='pbe'/>
+ <feature name='dtes64'/>
+ <feature name='monitor'/>
+ <feature name='ds_cpl'/>
+ <feature name='vmx'/>
+ <feature name='smx'/>
+ <feature name='est'/>
+ <feature name='tm2'/>
+ <feature name='xtpr'/>
+ <feature name='pdcm'/>
+ <feature name='osxsave'/>
+ <feature name='tsc_adjust'/>
+ <feature name='clflushopt'/>
+ <feature name='intel-pt'/>
+ <feature name='stibp'/>
+ <feature name='ssbd'/>
+ <feature name='xsaves'/>
+ <feature name='pdpe1gb'/>
+ <feature name='invtsc'/>
+</cpu>
diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-8700-json.xml b/tests/cputestdata/x86_64-cpuid-Core-i7-8700-json.xml
new file mode 100644
index 0000000000..fd7539f7ce
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Core-i7-8700-json.xml
@@ -0,0 +1,12 @@
+<cpu mode='custom' match='exact'>
+ <model fallback='forbid'>Skylake-Client-IBRS</model>
+ <vendor>Intel</vendor>
+ <feature policy='require' name='ss'/>
+ <feature policy='require' name='hypervisor'/>
+ <feature policy='require' name='tsc_adjust'/>
+ <feature policy='require' name='clflushopt'/>
+ <feature policy='require' name='umip'/>
+ <feature policy='require' name='ssbd'/>
+ <feature policy='require' name='xsaves'/>
+ <feature policy='require' name='pdpe1gb'/>
+</cpu>
diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-8700.json b/tests/cputestdata/x86_64-cpuid-Core-i7-8700.json
new file mode 100644
index 0000000000..122a1b2985
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Core-i7-8700.json
@@ -0,0 +1,650 @@
+{
+ "return": {
+ "model": {
+ "name": "base",
+ "props": {
+ "phys-bits": 0,
+ "core-id": -1,
+ "xlevel": 2147483656,
+ "cmov": true,
+ "ia64": false,
+ "aes": true,
+ "mmx": true,
+ "rdpid": false,
+ "arat": true,
+ "gfni": false,
+ "pause-filter": false,
+ "xsavec": true,
+ "intel-pt": false,
+ "osxsave": false,
+ "hv-frequencies": false,
+ "tsc-frequency": 0,
+ "xd": true,
+ "hv-vendor-id": "",
+ "kvm-asyncpf": true,
+ "kvm_asyncpf": true,
+ "perfctr_core": false,
+ "perfctr-core": false,
+ "mpx": true,
+ "pbe": false,
+ "decodeassists": false,
+ "avx512cd": false,
+ "sse4_1": true,
+ "sse4.1": true,
+ "sse4-1": true,
+ "family": 6,
+ "legacy-cache": true,
+ "vmware-cpuid-freq": true,
+ "avx512f": false,
+ "msr": true,
+ "mce": true,
+ "mca": true,
+ "hv-runtime": false,
+ "xcrypt": false,
+ "thread-id": -1,
+ "min-level": 13,
+ "xgetbv1": true,
+ "cid": false,
+ "hv-relaxed": false,
+ "hv-crash": false,
+ "ds": false,
+ "fxsr": true,
+ "xsaveopt": true,
+ "xtpr": false,
+ "avx512vl": false,
+ "avx512-vpopcntdq": false,
+ "phe": false,
+ "extapic": false,
+ "3dnowprefetch": true,
+ "avx512vbmi2": false,
+ "cr8legacy": false,
+ "cpuid-0xb": true,
+ "xcrypt-en": false,
+ "kvm_pv_eoi": true,
+ "apic-id": 4294967295,
+ "pn": false,
+ "dca": false,
+ "vendor": "GenuineIntel",
+ "pku": false,
+ "smx": false,
+ "cmp_legacy": false,
+ "cmp-legacy": false,
+ "node-id": -1,
+ "avx512-4fmaps": false,
+ "vmcb_clean": false,
+ "vmcb-clean": false,
+ "3dnowext": false,
+ "hle": true,
+ "npt": false,
+ "memory": "/machine/unattached/system[0]",
+ "clwb": false,
+ "lbrv": false,
+ "adx": true,
+ "ss": true,
+ "pni": true,
+ "svm_lock": false,
+ "svm-lock": false,
+ "pfthreshold": false,
+ "smep": true,
+ "smap": true,
+ "x2apic": true,
+ "avx512vbmi": false,
+ "avx512vnni": false,
+ "hv-stimer": false,
+ "i64": true,
+ "flushbyasid": false,
+ "f16c": true,
+ "ace2-en": false,
+ "pat": true,
+ "pae": true,
+ "sse": true,
+ "phe-en": false,
+ "kvm_nopiodelay": true,
+ "kvm-nopiodelay": true,
+ "tm": false,
+ "kvmclock-stable-bit": true,
+ "hypervisor": true,
+ "socket-id": -1,
+ "pcommit": false,
+ "syscall": true,
+ "level": 13,
+ "avx512dq": false,
+ "svm": false,
+ "full-cpuid-auto-level": true,
+ "hv-reset": false,
+ "invtsc": false,
+ "sse3": true,
+ "sse2": true,
+ "ssbd": true,
+ "est": false,
+ "avx512ifma": false,
+ "tm2": false,
+ "kvm-pv-eoi": true,
+ "cx8": true,
+ "kvm_mmu": false,
+ "kvm-mmu": false,
+ "sse4_2": true,
+ "sse4.2": true,
+ "sse4-2": true,
+ "pge": true,
+ "fill-mtrr-mask": true,
+ "avx512bitalg": false,
+ "nodeid_msr": false,
+ "pdcm": false,
+ "movbe": true,
+ "model": 158,
+ "nrip_save": false,
+ "nrip-save": false,
+ "kvm_pv_unhalt": true,
+ "ssse3": true,
+ "sse4a": false,
+ "invpcid": true,
+ "pdpe1gb": true,
+ "tsc-deadline": true,
+ "fma": true,
+ "cx16": true,
+ "de": true,
+ "enforce": false,
+ "stepping": 10,
+ "xsave": true,
+ "clflush": true,
+ "skinit": false,
+ "tsc": true,
+ "tce": false,
+ "fpu": true,
+ "ibs": false,
+ "ds_cpl": false,
+ "ds-cpl": false,
+ "host-phys-bits": true,
+ "fma4": false,
+ "la57": false,
+ "osvw": false,
+ "check": true,
+ "hv-spinlocks": -1,
+ "pmu": false,
+ "pmm": false,
+ "apic": true,
+ "spec-ctrl": true,
+ "min-xlevel2": 0,
+ "tsc-adjust": true,
+ "tsc_adjust": true,
+ "kvm-steal-time": true,
+ "kvm_steal_time": true,
+ "kvmclock": true,
+ "l3-cache": true,
+ "lwp": false,
+ "ibpb": false,
+ "xop": false,
+ "avx": true,
+ "ospke": false,
+ "ace2": false,
+ "avx512bw": false,
+ "acpi": false,
+ "hv-vapic": false,
+ "fsgsbase": true,
+ "ht": false,
+ "nx": true,
+ "pclmulqdq": true,
+ "mmxext": false,
+ "vaes": false,
+ "popcnt": true,
+ "xsaves": true,
+ "tcg-cpuid": true,
+ "lm": true,
+ "umip": true,
+ "pse": true,
+ "avx2": true,
+ "sep": true,
+ "pclmuldq": true,
+ "virt-ssbd": false,
+ "x-hv-max-vps": -1,
+ "nodeid-msr": false,
+ "kvm": true,
+ "misalignsse": false,
+ "min-xlevel": 2147483656,
+ "kvm-pv-unhalt": true,
+ "bmi2": true,
+ "bmi1": true,
+ "realized": false,
+ "tsc_scale": false,
+ "tsc-scale": false,
+ "topoext": false,
+ "hv-vpindex": false,
+ "xlevel2": 0,
+ "clflushopt": true,
+ "kvm-no-smi-migration": false,
+ "monitor": false,
+ "avx512er": false,
+ "pmm-en": false,
+ "pcid": true,
+ "3dnow": false,
+ "erms": true,
+ "lahf-lm": true,
+ "lahf_lm": true,
+ "vpclmulqdq": false,
+ "fxsr-opt": false,
+ "hv-synic": false,
+ "xstore": false,
+ "fxsr_opt": false,
+ "kvm-hint-dedicated": false,
+ "rtm": true,
+ "lmce": true,
+ "hv-time": false,
+ "perfctr-nb": false,
+ "perfctr_nb": false,
+ "ffxsr": false,
+ "rdrand": true,
+ "rdseed": true,
+ "avx512-4vnniw": false,
+ "vmx": false,
+ "vme": true,
+ "dtes64": false,
+ "mtrr": true,
+ "rdtscp": true,
+ "pse36": true,
+ "kvm-pv-tlb-flush": true,
+ "tbm": false,
+ "wdt": false,
+ "pause_filter": false,
+ "sha-ni": false,
+ "model-id": "Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz",
+ "abm": true,
+ "avx512pf": false,
+ "xstore-en": false
+ }
+ }
+ },
+ "id": "model-expansion"
+}
+
+{
+ "return": [
+ {
+ "name": "max",
+ "typename": "max-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": false
+ },
+ {
+ "name": "host",
+ "typename": "host-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": false
+ },
+ {
+ "name": "base",
+ "typename": "base-x86_64-cpu",
+ "unavailable-features": [],
+ "static": true,
+ "migration-safe": true
+ },
+ {
+ "name": "qemu64",
+ "typename": "qemu64-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "qemu32",
+ "typename": "qemu32-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "phenom",
+ "typename": "phenom-x86_64-cpu",
+ "unavailable-features": [
+ "mmxext",
+ "fxsr-opt",
+ "3dnowext",
+ "3dnow",
+ "sse4a",
+ "npt"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "pentium3",
+ "typename": "pentium3-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "pentium2",
+ "typename": "pentium2-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "pentium",
+ "typename": "pentium-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "n270",
+ "typename": "n270-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "kvm64",
+ "typename": "kvm64-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "kvm32",
+ "typename": "kvm32-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "cpu64-rhel6",
+ "typename": "cpu64-rhel6-x86_64-cpu",
+ "unavailable-features": [
+ "sse4a"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "coreduo",
+ "typename": "coreduo-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "core2duo",
+ "typename": "core2duo-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "athlon",
+ "typename": "athlon-x86_64-cpu",
+ "unavailable-features": [
+ "mmxext",
+ "3dnowext",
+ "3dnow"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Westmere",
+ "typename": "Westmere-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Westmere-IBRS",
+ "typename": "Westmere-IBRS-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Skylake-Server",
+ "typename": "Skylake-Server-x86_64-cpu",
+ "unavailable-features": [
+ "avx512f",
+ "avx512dq",
+ "clwb",
+ "avx512cd",
+ "avx512bw",
+ "avx512vl",
+ "avx512f",
+ "avx512f",
+ "avx512f"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Skylake-Server-IBRS",
+ "typename": "Skylake-Server-IBRS-x86_64-cpu",
+ "unavailable-features": [
+ "avx512f",
+ "avx512dq",
+ "clwb",
+ "avx512cd",
+ "avx512bw",
+ "avx512vl",
+ "avx512f",
+ "avx512f",
+ "avx512f"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Skylake-Client",
+ "typename": "Skylake-Client-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Skylake-Client-IBRS",
+ "typename": "Skylake-Client-IBRS-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "SandyBridge",
+ "typename": "SandyBridge-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "SandyBridge-IBRS",
+ "typename": "SandyBridge-IBRS-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Penryn",
+ "typename": "Penryn-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Opteron_G5",
+ "typename": "Opteron_G5-x86_64-cpu",
+ "unavailable-features": [
+ "sse4a",
+ "misalignsse",
+ "xop",
+ "fma4",
+ "tbm"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Opteron_G4",
+ "typename": "Opteron_G4-x86_64-cpu",
+ "unavailable-features": [
+ "sse4a",
+ "misalignsse",
+ "xop",
+ "fma4"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Opteron_G3",
+ "typename": "Opteron_G3-x86_64-cpu",
+ "unavailable-features": [
+ "sse4a",
+ "misalignsse"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Opteron_G2",
+ "typename": "Opteron_G2-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Opteron_G1",
+ "typename": "Opteron_G1-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Nehalem",
+ "typename": "Nehalem-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Nehalem-IBRS",
+ "typename": "Nehalem-IBRS-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "IvyBridge",
+ "typename": "IvyBridge-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "IvyBridge-IBRS",
+ "typename": "IvyBridge-IBRS-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Haswell",
+ "typename": "Haswell-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Haswell-noTSX",
+ "typename": "Haswell-noTSX-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Haswell-noTSX-IBRS",
+ "typename": "Haswell-noTSX-IBRS-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Haswell-IBRS",
+ "typename": "Haswell-IBRS-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "EPYC",
+ "typename": "EPYC-x86_64-cpu",
+ "unavailable-features": [
+ "sha-ni",
+ "mmxext",
+ "fxsr-opt",
+ "cr8legacy",
+ "sse4a",
+ "misalignsse",
+ "osvw"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "EPYC-IBPB",
+ "typename": "EPYC-IBPB-x86_64-cpu",
+ "unavailable-features": [
+ "sha-ni",
+ "mmxext",
+ "fxsr-opt",
+ "cr8legacy",
+ "sse4a",
+ "misalignsse",
+ "osvw",
+ "ibpb"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Conroe",
+ "typename": "Conroe-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Broadwell",
+ "typename": "Broadwell-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Broadwell-noTSX",
+ "typename": "Broadwell-noTSX-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Broadwell-noTSX-IBRS",
+ "typename": "Broadwell-noTSX-IBRS-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Broadwell-IBRS",
+ "typename": "Broadwell-IBRS-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "486",
+ "typename": "486-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ }
+ ],
+ "id": "definitions"
+}
diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-8700.xml b/tests/cputestdata/x86_64-cpuid-Core-i7-8700.xml
new file mode 100644
index 0000000000..03ba0a3925
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Core-i7-8700.xml
@@ -0,0 +1,47 @@
+<!-- Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz -->
+<cpudata arch='x86'>
+ <cpuid eax_in='0x00000000' ecx_in='0x00' eax='0x00000016' ebx='0x756e6547' ecx='0x6c65746e' edx='0x49656e69'/>
+ <cpuid eax_in='0x00000001' ecx_in='0x00' eax='0x000906ea' ebx='0x01100800' ecx='0x7ffafbff' edx='0xbfebfbff'/>
+ <cpuid eax_in='0x00000002' ecx_in='0x00' eax='0x76036301' ebx='0x00f0b5ff' ecx='0x00000000' edx='0x00c30000'/>
+ <cpuid eax_in='0x00000003' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x00000004' ecx_in='0x00' eax='0x1c004121' ebx='0x01c0003f' ecx='0x0000003f' edx='0x00000000'/>
+ <cpuid eax_in='0x00000004' ecx_in='0x01' eax='0x1c004122' ebx='0x01c0003f' ecx='0x0000003f' edx='0x00000000'/>
+ <cpuid eax_in='0x00000004' ecx_in='0x02' eax='0x1c004143' ebx='0x00c0003f' ecx='0x000003ff' edx='0x00000000'/>
+ <cpuid eax_in='0x00000004' ecx_in='0x03' eax='0x1c03c163' ebx='0x03c0003f' ecx='0x00002fff' edx='0x00000006'/>
+ <cpuid eax_in='0x00000005' ecx_in='0x00' eax='0x00000040' ebx='0x00000040' ecx='0x00000003' edx='0x11142120'/>
+ <cpuid eax_in='0x00000006' ecx_in='0x00' eax='0x000027f7' ebx='0x00000002' ecx='0x00000001' edx='0x00000000'/>
+ <cpuid eax_in='0x00000007' ecx_in='0x00' eax='0x00000000' ebx='0x029c6fbf' ecx='0x40000000' edx='0x9c000000'/>
+ <cpuid eax_in='0x00000008' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x00000009' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x0000000a' ecx_in='0x00' eax='0x07300404' ebx='0x00000000' ecx='0x00000000' edx='0x00000603'/>
+ <cpuid eax_in='0x0000000b' ecx_in='0x00' eax='0x00000001' ebx='0x00000002' ecx='0x00000100' edx='0x00000001'/>
+ <cpuid eax_in='0x0000000b' ecx_in='0x01' eax='0x00000004' ebx='0x0000000c' ecx='0x00000201' edx='0x00000001'/>
+ <cpuid eax_in='0x0000000c' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x0000000d' ecx_in='0x00' eax='0x0000001f' ebx='0x00000440' ecx='0x00000440' edx='0x00000000'/>
+ <cpuid eax_in='0x0000000d' ecx_in='0x01' eax='0x0000000f' ebx='0x000003c0' ecx='0x00000100' edx='0x00000000'/>
+ <cpuid eax_in='0x0000000d' ecx_in='0x02' eax='0x00000100' ebx='0x00000240' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x0000000d' ecx_in='0x03' eax='0x00000040' ebx='0x000003c0' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x0000000d' ecx_in='0x04' eax='0x00000040' ebx='0x00000400' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x0000000d' ecx_in='0x08' eax='0x00000080' ebx='0x00000000' ecx='0x00000001' edx='0x00000000'/>
+ <cpuid eax_in='0x0000000e' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x0000000f' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x00000010' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x00000011' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x00000012' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x00000013' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x00000014' ecx_in='0x00' eax='0x00000001' ebx='0x0000000f' ecx='0x00000007' edx='0x00000000'/>
+ <cpuid eax_in='0x00000014' ecx_in='0x01' eax='0x02490002' ebx='0x003f3fff' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x00000015' ecx_in='0x00' eax='0x00000002' ebx='0x0000010a' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x00000016' ecx_in='0x00' eax='0x00000c80' ebx='0x000011f8' ecx='0x00000064' edx='0x00000000'/>
+ <cpuid eax_in='0x80000000' ecx_in='0x00' eax='0x80000008' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x80000001' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000121' edx='0x2c100800'/>
+ <cpuid eax_in='0x80000002' ecx_in='0x00' eax='0x65746e49' ebx='0x2952286c' ecx='0x726f4320' edx='0x4d542865'/>
+ <cpuid eax_in='0x80000003' ecx_in='0x00' eax='0x37692029' ebx='0x3037382d' ecx='0x50432030' edx='0x20402055'/>
+ <cpuid eax_in='0x80000004' ecx_in='0x00' eax='0x30322e33' ebx='0x007a4847' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x80000005' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x80000006' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x01006040' edx='0x00000000'/>
+ <cpuid eax_in='0x80000007' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000100'/>
+ <cpuid eax_in='0x80000008' ecx_in='0x00' eax='0x00003027' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x80860000' ecx_in='0x00' eax='0x00000c80' ebx='0x000011f8' ecx='0x00000064' edx='0x00000000'/>
+ <cpuid eax_in='0xc0000000' ecx_in='0x00' eax='0x00000c80' ebx='0x000011f8' ecx='0x00000064' edx='0x00000000'/>
+</cpudata>
--
2.22.0

View File

@ -0,0 +1,824 @@
From 4e22f6ec928e62811db06cd717fc286dd1dfba8e Mon Sep 17 00:00:00 2001
Message-Id: <4e22f6ec928e62811db06cd717fc286dd1dfba8e@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:24:49 +0200
Subject: [PATCH] cputest: Add data for Intel(R) Xeon(R) CPU E5-2630 v4
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 8d068f360183ecd55e3213dbe9ba12f7d6470751)
https://bugzilla.redhat.com/show_bug.cgi?id=1686895
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <5bc8830efc48a09ace38df33a83152ae0cf3a5fe.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
tests/cputest.c | 1 +
.../x86_64-cpuid-Xeon-E5-2630-v4-disabled.xml | 7 +
.../x86_64-cpuid-Xeon-E5-2630-v4-enabled.xml | 8 +
.../x86_64-cpuid-Xeon-E5-2630-v4-guest.xml | 31 +
.../x86_64-cpuid-Xeon-E5-2630-v4-host.xml | 35 +
.../x86_64-cpuid-Xeon-E5-2630-v4-json.xml | 11 +
.../x86_64-cpuid-Xeon-E5-2630-v4.json | 596 ++++++++++++++++++
.../x86_64-cpuid-Xeon-E5-2630-v4.xml | 43 ++
8 files changed, 732 insertions(+)
create mode 100644 tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-v4-disabled.xml
create mode 100644 tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-v4-enabled.xml
create mode 100644 tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-v4-guest.xml
create mode 100644 tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-v4-host.xml
create mode 100644 tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-v4-json.xml
create mode 100644 tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-v4.json
create mode 100644 tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-v4.xml
diff --git a/tests/cputest.c b/tests/cputest.c
index fbb2a86af8..f43144edc9 100644
--- a/tests/cputest.c
+++ b/tests/cputest.c
@@ -1195,6 +1195,7 @@ mymain(void)
DO_TEST_CPUID(VIR_ARCH_X86_64, "Xeon-E5-2609-v3", JSON_MODELS);
DO_TEST_CPUID(VIR_ARCH_X86_64, "Xeon-E5-2623-v4", JSON_MODELS);
DO_TEST_CPUID(VIR_ARCH_X86_64, "Xeon-E5-2630-v3", JSON_HOST);
+ DO_TEST_CPUID(VIR_ARCH_X86_64, "Xeon-E5-2630-v4", JSON_MODELS);
DO_TEST_CPUID(VIR_ARCH_X86_64, "Xeon-E5-2650-v3", JSON_HOST);
DO_TEST_CPUID(VIR_ARCH_X86_64, "Xeon-E5-2650-v4", JSON_MODELS);
DO_TEST_CPUID(VIR_ARCH_X86_64, "Xeon-E7-4820", JSON_HOST);
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-v4-disabled.xml b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-v4-disabled.xml
new file mode 100644
index 0000000000..3ffb246167
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-v4-disabled.xml
@@ -0,0 +1,7 @@
+<!-- Features disabled by QEMU -->
+<cpudata arch='x86'>
+ <cpuid eax_in='0x00000001' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x0804c1fc' edx='0xb0600000'/>
+ <cpuid eax_in='0x00000007' ecx_in='0x00' eax='0x00000000' ebx='0x02001000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x0000000f' ecx_in='0x01' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000006'/>
+ <cpuid eax_in='0x80000007' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000100'/>
+</cpudata>
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-v4-enabled.xml b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-v4-enabled.xml
new file mode 100644
index 0000000000..f2d4f2826d
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-v4-enabled.xml
@@ -0,0 +1,8 @@
+<!-- Features enabled by QEMU -->
+<cpudata arch='x86'>
+ <cpuid eax_in='0x00000001' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0xf7fa3203' edx='0x0f8bfbff'/>
+ <cpuid eax_in='0x00000006' ecx_in='0x00' eax='0x00000004' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x00000007' ecx_in='0x00' eax='0x00000000' ebx='0x001c0fbb' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x0000000d' ecx_in='0x01' eax='0x00000001' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x80000001' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000121' edx='0x2c100800'/>
+</cpudata>
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-v4-guest.xml b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-v4-guest.xml
new file mode 100644
index 0000000000..cd7e25b52a
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-v4-guest.xml
@@ -0,0 +1,31 @@
+<cpu mode='custom' match='exact'>
+ <model fallback='forbid'>Skylake-Client</model>
+ <vendor>Intel</vendor>
+ <feature policy='require' name='ds'/>
+ <feature policy='require' name='acpi'/>
+ <feature policy='require' name='ss'/>
+ <feature policy='require' name='ht'/>
+ <feature policy='require' name='tm'/>
+ <feature policy='require' name='pbe'/>
+ <feature policy='require' name='dtes64'/>
+ <feature policy='require' name='monitor'/>
+ <feature policy='require' name='ds_cpl'/>
+ <feature policy='require' name='vmx'/>
+ <feature policy='require' name='smx'/>
+ <feature policy='require' name='est'/>
+ <feature policy='require' name='tm2'/>
+ <feature policy='require' name='xtpr'/>
+ <feature policy='require' name='pdcm'/>
+ <feature policy='require' name='dca'/>
+ <feature policy='require' name='osxsave'/>
+ <feature policy='require' name='tsc_adjust'/>
+ <feature policy='require' name='cmt'/>
+ <feature policy='require' name='intel-pt'/>
+ <feature policy='require' name='mbm_total'/>
+ <feature policy='require' name='mbm_local'/>
+ <feature policy='require' name='pdpe1gb'/>
+ <feature policy='require' name='invtsc'/>
+ <feature policy='disable' name='mpx'/>
+ <feature policy='disable' name='xsavec'/>
+ <feature policy='disable' name='xgetbv1'/>
+</cpu>
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-v4-host.xml b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-v4-host.xml
new file mode 100644
index 0000000000..5dd8d749de
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-v4-host.xml
@@ -0,0 +1,35 @@
+<cpu>
+ <arch>x86_64</arch>
+ <model>Broadwell</model>
+ <vendor>Intel</vendor>
+ <feature name='vme'/>
+ <feature name='ds'/>
+ <feature name='acpi'/>
+ <feature name='ss'/>
+ <feature name='ht'/>
+ <feature name='tm'/>
+ <feature name='pbe'/>
+ <feature name='dtes64'/>
+ <feature name='monitor'/>
+ <feature name='ds_cpl'/>
+ <feature name='vmx'/>
+ <feature name='smx'/>
+ <feature name='est'/>
+ <feature name='tm2'/>
+ <feature name='xtpr'/>
+ <feature name='pdcm'/>
+ <feature name='dca'/>
+ <feature name='osxsave'/>
+ <feature name='f16c'/>
+ <feature name='rdrand'/>
+ <feature name='arat'/>
+ <feature name='tsc_adjust'/>
+ <feature name='cmt'/>
+ <feature name='intel-pt'/>
+ <feature name='xsaveopt'/>
+ <feature name='mbm_total'/>
+ <feature name='mbm_local'/>
+ <feature name='pdpe1gb'/>
+ <feature name='abm'/>
+ <feature name='invtsc'/>
+</cpu>
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-v4-json.xml b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-v4-json.xml
new file mode 100644
index 0000000000..5dfce947b2
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-v4-json.xml
@@ -0,0 +1,11 @@
+<cpu mode='custom' match='exact'>
+ <model fallback='forbid'>Skylake-Client</model>
+ <vendor>Intel</vendor>
+ <feature policy='require' name='ss'/>
+ <feature policy='require' name='hypervisor'/>
+ <feature policy='require' name='tsc_adjust'/>
+ <feature policy='require' name='pdpe1gb'/>
+ <feature policy='disable' name='mpx'/>
+ <feature policy='disable' name='xsavec'/>
+ <feature policy='disable' name='xgetbv1'/>
+</cpu>
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-v4.json b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-v4.json
new file mode 100644
index 0000000000..ee09950fce
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-v4.json
@@ -0,0 +1,596 @@
+{
+ "return": {
+ "model": {
+ "name": "base",
+ "props": {
+ "phys-bits": 0,
+ "core-id": -1,
+ "xlevel": 2147483656,
+ "cmov": true,
+ "ia64": false,
+ "aes": true,
+ "mmx": true,
+ "arat": true,
+ "rdpid": false,
+ "pause-filter": false,
+ "xsavec": false,
+ "osxsave": false,
+ "tsc-frequency": 0,
+ "xd": true,
+ "hv-vendor-id": "",
+ "kvm-asyncpf": true,
+ "kvm_asyncpf": true,
+ "perfctr_core": false,
+ "perfctr-core": false,
+ "mpx": false,
+ "decodeassists": false,
+ "avx512cd": false,
+ "pbe": false,
+ "sse4_1": true,
+ "sse4.1": true,
+ "sse4-1": true,
+ "family": 6,
+ "vmware-cpuid-freq": true,
+ "avx512f": false,
+ "xcrypt": false,
+ "msr": true,
+ "mce": true,
+ "mca": true,
+ "thread-id": -1,
+ "min-level": 13,
+ "xgetbv1": false,
+ "cid": false,
+ "hv-relaxed": false,
+ "fxsr": true,
+ "ds": false,
+ "hv-crash": false,
+ "xsaveopt": true,
+ "xtpr": false,
+ "avx512-vpopcntdq": false,
+ "phe": false,
+ "avx512vl": false,
+ "extapic": false,
+ "3dnowprefetch": true,
+ "cr8legacy": false,
+ "stibp": false,
+ "cpuid-0xb": true,
+ "xcrypt-en": false,
+ "kvm_pv_eoi": true,
+ "apic-id": 4294967295,
+ "pn": false,
+ "dca": false,
+ "vendor": "GenuineIntel",
+ "pku": false,
+ "smx": false,
+ "cmp-legacy": false,
+ "cmp_legacy": false,
+ "avx512-4fmaps": false,
+ "vmcb-clean": false,
+ "vmcb_clean": false,
+ "3dnowext": false,
+ "hle": true,
+ "npt": false,
+ "memory": "/machine/unattached/system[0]",
+ "clwb": false,
+ "lbrv": false,
+ "adx": true,
+ "ss": true,
+ "pni": true,
+ "svm_lock": false,
+ "svm-lock": false,
+ "smep": true,
+ "pfthreshold": false,
+ "smap": true,
+ "x2apic": true,
+ "avx512vbmi": false,
+ "i64": true,
+ "flushbyasid": false,
+ "f16c": true,
+ "ace2-en": false,
+ "pat": true,
+ "pae": true,
+ "sse": true,
+ "phe-en": false,
+ "kvm-nopiodelay": true,
+ "kvm_nopiodelay": true,
+ "tm": false,
+ "kvmclock-stable-bit": true,
+ "hypervisor": true,
+ "socket-id": -1,
+ "pcommit": false,
+ "syscall": true,
+ "level": 13,
+ "avx512dq": false,
+ "svm": false,
+ "full-cpuid-auto-level": true,
+ "invtsc": false,
+ "sse3": true,
+ "sse2": true,
+ "est": false,
+ "avx512ifma": false,
+ "tm2": false,
+ "kvm-pv-eoi": true,
+ "cx8": true,
+ "kvm-mmu": false,
+ "kvm_mmu": false,
+ "sse4_2": true,
+ "sse4.2": true,
+ "sse4-2": true,
+ "pge": true,
+ "fill-mtrr-mask": true,
+ "pdcm": false,
+ "nodeid_msr": false,
+ "model": 79,
+ "movbe": true,
+ "nrip-save": false,
+ "nrip_save": false,
+ "sse4a": false,
+ "ssse3": true,
+ "kvm_pv_unhalt": true,
+ "invpcid": true,
+ "pdpe1gb": true,
+ "tsc-deadline": true,
+ "fma": true,
+ "cx16": true,
+ "de": true,
+ "enforce": false,
+ "stepping": 1,
+ "xsave": true,
+ "clflush": true,
+ "arch-facilities": false,
+ "skinit": false,
+ "tce": false,
+ "tsc": true,
+ "fpu": true,
+ "ds-cpl": false,
+ "ds_cpl": false,
+ "ibs": false,
+ "host-phys-bits": true,
+ "fma4": false,
+ "la57": false,
+ "osvw": false,
+ "check": true,
+ "hv-spinlocks": -1,
+ "pmm": false,
+ "apic": true,
+ "pmu": false,
+ "spec-ctrl": false,
+ "min-xlevel2": 0,
+ "tsc-adjust": true,
+ "tsc_adjust": true,
+ "kvm-steal-time": true,
+ "kvm_steal_time": true,
+ "kvmclock": true,
+ "l3-cache": true,
+ "lwp": false,
+ "xop": false,
+ "ibpb": false,
+ "avx": true,
+ "ospke": false,
+ "ace2": false,
+ "acpi": false,
+ "avx512bw": false,
+ "hv-vapic": false,
+ "fsgsbase": true,
+ "ht": false,
+ "nx": true,
+ "pclmulqdq": true,
+ "mmxext": false,
+ "popcnt": true,
+ "xsaves": false,
+ "lm": true,
+ "umip": false,
+ "avx2": true,
+ "pse": true,
+ "sep": true,
+ "pclmuldq": true,
+ "nodeid-msr": false,
+ "kvm": true,
+ "misalignsse": false,
+ "min-xlevel": 2147483656,
+ "bmi2": true,
+ "bmi1": true,
+ "kvm-pv-unhalt": true,
+ "realized": false,
+ "tsc-scale": false,
+ "tsc_scale": false,
+ "topoext": false,
+ "xlevel2": 0,
+ "clflushopt": false,
+ "kvm-no-smi-migration": false,
+ "monitor": false,
+ "avx512er": false,
+ "pmm-en": false,
+ "pcid": true,
+ "3dnow": false,
+ "erms": true,
+ "lahf-lm": true,
+ "lahf_lm": true,
+ "xstore": false,
+ "fxsr-opt": false,
+ "fxsr_opt": false,
+ "rtm": true,
+ "lmce": true,
+ "hv-time": false,
+ "perfctr-nb": false,
+ "perfctr_nb": false,
+ "ffxsr": false,
+ "rdrand": true,
+ "rdseed": true,
+ "avx512-4vnniw": false,
+ "vme": true,
+ "vmx": false,
+ "dtes64": false,
+ "mtrr": true,
+ "rdtscp": true,
+ "pse36": true,
+ "tbm": false,
+ "wdt": false,
+ "pause_filter": false,
+ "model-id": "Intel(R) Xeon(R) CPU E5-2630 v4 @ 2.20GHz",
+ "sha-ni": false,
+ "abm": true,
+ "avx512pf": false,
+ "xstore-en": false
+ }
+ }
+ },
+ "id": "model-expansion"
+}
+
+
+{
+ "return": [
+ {
+ "name": "max",
+ "typename": "max-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": false
+ },
+ {
+ "name": "host",
+ "typename": "host-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": false
+ },
+ {
+ "name": "base",
+ "typename": "base-x86_64-cpu",
+ "unavailable-features": [],
+ "static": true,
+ "migration-safe": true
+ },
+ {
+ "name": "qemu64",
+ "typename": "qemu64-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "qemu32",
+ "typename": "qemu32-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "phenom",
+ "typename": "phenom-x86_64-cpu",
+ "unavailable-features": [
+ "mmxext",
+ "fxsr-opt",
+ "3dnowext",
+ "3dnow",
+ "sse4a",
+ "npt"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "pentium3",
+ "typename": "pentium3-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "pentium2",
+ "typename": "pentium2-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "pentium",
+ "typename": "pentium-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "n270",
+ "typename": "n270-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "kvm64",
+ "typename": "kvm64-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "kvm32",
+ "typename": "kvm32-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "cpu64-rhel6",
+ "typename": "cpu64-rhel6-x86_64-cpu",
+ "unavailable-features": [
+ "sse4a"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "coreduo",
+ "typename": "coreduo-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "core2duo",
+ "typename": "core2duo-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "athlon",
+ "typename": "athlon-x86_64-cpu",
+ "unavailable-features": [
+ "mmxext",
+ "3dnowext",
+ "3dnow"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Westmere",
+ "typename": "Westmere-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Westmere-IBRS",
+ "typename": "Westmere-IBRS-x86_64-cpu",
+ "unavailable-features": [
+ "spec-ctrl"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Skylake-Client",
+ "typename": "Skylake-Client-x86_64-cpu",
+ "unavailable-features": [
+ "mpx",
+ "xsavec",
+ "xgetbv1",
+ "mpx",
+ "mpx"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Skylake-Client-IBRS",
+ "typename": "Skylake-Client-IBRS-x86_64-cpu",
+ "unavailable-features": [
+ "mpx",
+ "spec-ctrl",
+ "xsavec",
+ "xgetbv1",
+ "mpx",
+ "mpx"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "SandyBridge",
+ "typename": "SandyBridge-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "SandyBridge-IBRS",
+ "typename": "SandyBridge-IBRS-x86_64-cpu",
+ "unavailable-features": [
+ "spec-ctrl"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Penryn",
+ "typename": "Penryn-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Opteron_G5",
+ "typename": "Opteron_G5-x86_64-cpu",
+ "unavailable-features": [
+ "sse4a",
+ "misalignsse",
+ "xop",
+ "fma4",
+ "tbm"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Opteron_G4",
+ "typename": "Opteron_G4-x86_64-cpu",
+ "unavailable-features": [
+ "sse4a",
+ "misalignsse",
+ "xop",
+ "fma4"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Opteron_G3",
+ "typename": "Opteron_G3-x86_64-cpu",
+ "unavailable-features": [
+ "sse4a",
+ "misalignsse"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Opteron_G2",
+ "typename": "Opteron_G2-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Opteron_G1",
+ "typename": "Opteron_G1-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Nehalem",
+ "typename": "Nehalem-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Nehalem-IBRS",
+ "typename": "Nehalem-IBRS-x86_64-cpu",
+ "unavailable-features": [
+ "spec-ctrl"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "IvyBridge",
+ "typename": "IvyBridge-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "IvyBridge-IBRS",
+ "typename": "IvyBridge-IBRS-x86_64-cpu",
+ "unavailable-features": [
+ "spec-ctrl"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Haswell",
+ "typename": "Haswell-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Haswell-noTSX",
+ "typename": "Haswell-noTSX-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Haswell-noTSX-IBRS",
+ "typename": "Haswell-noTSX-IBRS-x86_64-cpu",
+ "unavailable-features": [
+ "spec-ctrl"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Haswell-IBRS",
+ "typename": "Haswell-IBRS-x86_64-cpu",
+ "unavailable-features": [
+ "spec-ctrl"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Conroe",
+ "typename": "Conroe-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Broadwell",
+ "typename": "Broadwell-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Broadwell-noTSX",
+ "typename": "Broadwell-noTSX-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Broadwell-noTSX-IBRS",
+ "typename": "Broadwell-noTSX-IBRS-x86_64-cpu",
+ "unavailable-features": [
+ "spec-ctrl"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Broadwell-IBRS",
+ "typename": "Broadwell-IBRS-x86_64-cpu",
+ "unavailable-features": [
+ "spec-ctrl"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "486",
+ "typename": "486-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ }
+ ],
+ "id": "definitions"
+}
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-v4.xml b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-v4.xml
new file mode 100644
index 0000000000..d74c207104
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-v4.xml
@@ -0,0 +1,43 @@
+<!-- Intel(R) Xeon(R) CPU E5-2630 v4 @ 2.20GHz -->
+<cpudata arch='x86'>
+ <cpuid eax_in='0x00000000' ecx_in='0x00' eax='0x00000014' ebx='0x756e6547' ecx='0x6c65746e' edx='0x49656e69'/>
+ <cpuid eax_in='0x00000001' ecx_in='0x00' eax='0x000406f1' ebx='0x01200800' ecx='0x7ffefbff' edx='0xbfebfbff'/>
+ <cpuid eax_in='0x00000002' ecx_in='0x00' eax='0x76036301' ebx='0x00f0b5ff' ecx='0x00000000' edx='0x00c30000'/>
+ <cpuid eax_in='0x00000003' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x00000004' ecx_in='0x00' eax='0x3c004121' ebx='0x01c0003f' ecx='0x0000003f' edx='0x00000000'/>
+ <cpuid eax_in='0x00000004' ecx_in='0x01' eax='0x3c004122' ebx='0x01c0003f' ecx='0x0000003f' edx='0x00000000'/>
+ <cpuid eax_in='0x00000004' ecx_in='0x02' eax='0x3c004143' ebx='0x01c0003f' ecx='0x000001ff' edx='0x00000000'/>
+ <cpuid eax_in='0x00000004' ecx_in='0x03' eax='0x3c07c163' ebx='0x04c0003f' ecx='0x00004fff' edx='0x00000006'/>
+ <cpuid eax_in='0x00000005' ecx_in='0x00' eax='0x00000040' ebx='0x00000040' ecx='0x00000003' edx='0x00002120'/>
+ <cpuid eax_in='0x00000006' ecx_in='0x00' eax='0x00000077' ebx='0x00000002' ecx='0x00000009' edx='0x00000000'/>
+ <cpuid eax_in='0x00000007' ecx_in='0x00' eax='0x00000000' ebx='0x021cbfbb' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x00000008' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x00000009' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x0000000a' ecx_in='0x00' eax='0x07300403' ebx='0x00000000' ecx='0x00000000' edx='0x00000603'/>
+ <cpuid eax_in='0x0000000b' ecx_in='0x00' eax='0x00000001' ebx='0x00000002' ecx='0x00000100' edx='0x00000001'/>
+ <cpuid eax_in='0x0000000b' ecx_in='0x01' eax='0x00000005' ebx='0x00000014' ecx='0x00000201' edx='0x00000001'/>
+ <cpuid eax_in='0x0000000c' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x0000000d' ecx_in='0x00' eax='0x00000007' ebx='0x00000340' ecx='0x00000340' edx='0x00000000'/>
+ <cpuid eax_in='0x0000000d' ecx_in='0x01' eax='0x00000001' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x0000000d' ecx_in='0x02' eax='0x00000100' ebx='0x00000240' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x0000000e' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x0000000f' ecx_in='0x00' eax='0x00000000' ebx='0x0000004f' ecx='0x00000000' edx='0x00000002'/>
+ <cpuid eax_in='0x0000000f' ecx_in='0x01' eax='0x00000000' ebx='0x0000a000' ecx='0x0000004f' edx='0x00000007'/>
+ <cpuid eax_in='0x00000010' ecx_in='0x00' eax='0x00000000' ebx='0x00000002' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x00000010' ecx_in='0x01' eax='0x00000013' ebx='0x000c0000' ecx='0x00000004' edx='0x0000000f'/>
+ <cpuid eax_in='0x00000011' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x00000012' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x00000013' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x00000014' ecx_in='0x00' eax='0x00000000' ebx='0x00000001' ecx='0x00000001' edx='0x00000000'/>
+ <cpuid eax_in='0x80000000' ecx_in='0x00' eax='0x80000008' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x80000001' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000121' edx='0x2c100800'/>
+ <cpuid eax_in='0x80000002' ecx_in='0x00' eax='0x65746e49' ebx='0x2952286c' ecx='0x6f655820' edx='0x2952286e'/>
+ <cpuid eax_in='0x80000003' ecx_in='0x00' eax='0x55504320' ebx='0x2d354520' ecx='0x30333632' edx='0x20347620'/>
+ <cpuid eax_in='0x80000004' ecx_in='0x00' eax='0x2e322040' ebx='0x48473032' ecx='0x0000007a' edx='0x00000000'/>
+ <cpuid eax_in='0x80000005' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x80000006' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x01006040' edx='0x00000000'/>
+ <cpuid eax_in='0x80000007' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000100'/>
+ <cpuid eax_in='0x80000008' ecx_in='0x00' eax='0x0000302e' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x80860000' ecx_in='0x00' eax='0x00000000' ebx='0x00000001' ecx='0x00000001' edx='0x00000000'/>
+ <cpuid eax_in='0xc0000000' ecx_in='0x00' eax='0x00000000' ebx='0x00000001' ecx='0x00000001' edx='0x00000000'/>
+</cpudata>
--
2.22.0

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,968 @@
From 5a7f0fd05ad3c86dd8f8be7870bd536de2512baa Mon Sep 17 00:00:00 2001
Message-Id: <5a7f0fd05ad3c86dd8f8be7870bd536de2512baa@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:25:20 +0200
Subject: [PATCH] cputest: Add data for Intel(R) Xeon(R) Platinum 8268 CPU
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit e024625735daec9f9f0bc292f06e37d7099805f1)
https://bugzilla.redhat.com/show_bug.cgi?id=1693433
Conflicts:
tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-guest.xml
tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-host.xml
- md-clear feature did not exist at the time of the original
patch, but downstream already has it
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <809df143b79b1052ce3e643d9b97926b5bdd7001.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
tests/cputest.c | 1 +
...6_64-cpuid-Xeon-Platinum-8268-disabled.xml | 7 +
...86_64-cpuid-Xeon-Platinum-8268-enabled.xml | 8 +
.../x86_64-cpuid-Xeon-Platinum-8268-guest.xml | 36 +
.../x86_64-cpuid-Xeon-Platinum-8268-host.xml | 37 +
.../x86_64-cpuid-Xeon-Platinum-8268-json.xml | 13 +
.../x86_64-cpuid-Xeon-Platinum-8268.json | 702 ++++++++++++++++++
.../x86_64-cpuid-Xeon-Platinum-8268.sig | 4 +
.../x86_64-cpuid-Xeon-Platinum-8268.xml | 54 ++
9 files changed, 862 insertions(+)
create mode 100644 tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-disabled.xml
create mode 100644 tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-enabled.xml
create mode 100644 tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-guest.xml
create mode 100644 tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-host.xml
create mode 100644 tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-json.xml
create mode 100644 tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268.json
create mode 100644 tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268.xml
diff --git a/tests/cputest.c b/tests/cputest.c
index 0cb9a57592..e62cda34b7 100644
--- a/tests/cputest.c
+++ b/tests/cputest.c
@@ -1293,6 +1293,7 @@ mymain(void)
DO_TEST_CPUID(VIR_ARCH_X86_64, "Xeon-E7540", JSON_MODELS);
DO_TEST_CPUID(VIR_ARCH_X86_64, "Xeon-Gold-5115", JSON_MODELS);
DO_TEST_CPUID(VIR_ARCH_X86_64, "Xeon-Gold-6148", JSON_HOST);
+ DO_TEST_CPUID(VIR_ARCH_X86_64, "Xeon-Platinum-8268", JSON_HOST);
DO_TEST_CPUID(VIR_ARCH_X86_64, "Xeon-W3520", JSON_HOST);
DO_TEST_CPUID(VIR_ARCH_X86_64, "Xeon-X5460", JSON_NONE);
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-disabled.xml b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-disabled.xml
new file mode 100644
index 0000000000..32522eb9af
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-disabled.xml
@@ -0,0 +1,7 @@
+<!-- Features disabled by QEMU -->
+<cpudata arch='x86'>
+ <cpuid eax_in='0x00000001' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x0804c1fc' edx='0xb0600000'/>
+ <cpuid eax_in='0x00000007' ecx_in='0x00' eax='0x00000000' ebx='0x02001000' ecx='0x00000010' edx='0x28000000'/>
+ <cpuid eax_in='0x0000000f' ecx_in='0x01' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000006'/>
+ <cpuid eax_in='0x80000007' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000100'/>
+</cpudata>
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-enabled.xml b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-enabled.xml
new file mode 100644
index 0000000000..434ac1956a
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-enabled.xml
@@ -0,0 +1,8 @@
+<!-- Features enabled by QEMU -->
+<cpudata arch='x86'>
+ <cpuid eax_in='0x00000001' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0xf7fa3203' edx='0x0f8bfbff'/>
+ <cpuid eax_in='0x00000006' ecx_in='0x00' eax='0x00000004' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x00000007' ecx_in='0x00' eax='0x00000000' ebx='0xd19f4fbb' ecx='0x0000080c' edx='0x84000000'/>
+ <cpuid eax_in='0x0000000d' ecx_in='0x01' eax='0x0000000f' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x80000001' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000121' edx='0x2c100800'/>
+</cpudata>
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-guest.xml b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-guest.xml
new file mode 100644
index 0000000000..2836481454
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-guest.xml
@@ -0,0 +1,36 @@
+<cpu mode='custom' match='exact'>
+ <model fallback='forbid'>Skylake-Server-IBRS</model>
+ <vendor>Intel</vendor>
+ <feature policy='require' name='ds'/>
+ <feature policy='require' name='acpi'/>
+ <feature policy='require' name='ss'/>
+ <feature policy='require' name='ht'/>
+ <feature policy='require' name='tm'/>
+ <feature policy='require' name='pbe'/>
+ <feature policy='require' name='dtes64'/>
+ <feature policy='require' name='monitor'/>
+ <feature policy='require' name='ds_cpl'/>
+ <feature policy='require' name='vmx'/>
+ <feature policy='require' name='smx'/>
+ <feature policy='require' name='est'/>
+ <feature policy='require' name='tm2'/>
+ <feature policy='require' name='xtpr'/>
+ <feature policy='require' name='pdcm'/>
+ <feature policy='require' name='dca'/>
+ <feature policy='require' name='osxsave'/>
+ <feature policy='require' name='tsc_adjust'/>
+ <feature policy='require' name='cmt'/>
+ <feature policy='require' name='clflushopt'/>
+ <feature policy='require' name='intel-pt'/>
+ <feature policy='require' name='pku'/>
+ <feature policy='require' name='ospke'/>
+ <feature policy='require' name='avx512vnni'/>
+ <feature policy='require' name='md-clear'/>
+ <feature policy='require' name='stibp'/>
+ <feature policy='require' name='arch-capabilities'/>
+ <feature policy='require' name='ssbd'/>
+ <feature policy='require' name='xsaves'/>
+ <feature policy='require' name='mbm_total'/>
+ <feature policy='require' name='mbm_local'/>
+ <feature policy='require' name='invtsc'/>
+</cpu>
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-host.xml b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-host.xml
new file mode 100644
index 0000000000..032d8ffeca
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-host.xml
@@ -0,0 +1,37 @@
+<cpu>
+ <arch>x86_64</arch>
+ <model>Skylake-Server-IBRS</model>
+ <vendor>Intel</vendor>
+ <feature name='ds'/>
+ <feature name='acpi'/>
+ <feature name='ss'/>
+ <feature name='ht'/>
+ <feature name='tm'/>
+ <feature name='pbe'/>
+ <feature name='dtes64'/>
+ <feature name='monitor'/>
+ <feature name='ds_cpl'/>
+ <feature name='vmx'/>
+ <feature name='smx'/>
+ <feature name='est'/>
+ <feature name='tm2'/>
+ <feature name='xtpr'/>
+ <feature name='pdcm'/>
+ <feature name='dca'/>
+ <feature name='osxsave'/>
+ <feature name='tsc_adjust'/>
+ <feature name='cmt'/>
+ <feature name='clflushopt'/>
+ <feature name='intel-pt'/>
+ <feature name='pku'/>
+ <feature name='ospke'/>
+ <feature name='avx512vnni'/>
+ <feature name='md-clear'/>
+ <feature name='stibp'/>
+ <feature name='arch-capabilities'/>
+ <feature name='ssbd'/>
+ <feature name='xsaves'/>
+ <feature name='mbm_total'/>
+ <feature name='mbm_local'/>
+ <feature name='invtsc'/>
+</cpu>
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-json.xml b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-json.xml
new file mode 100644
index 0000000000..12431de213
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-json.xml
@@ -0,0 +1,13 @@
+<cpu mode='custom' match='exact'>
+ <model fallback='forbid'>Skylake-Server-IBRS</model>
+ <vendor>Intel</vendor>
+ <feature policy='require' name='ss'/>
+ <feature policy='require' name='hypervisor'/>
+ <feature policy='require' name='tsc_adjust'/>
+ <feature policy='require' name='clflushopt'/>
+ <feature policy='require' name='umip'/>
+ <feature policy='require' name='pku'/>
+ <feature policy='require' name='avx512vnni'/>
+ <feature policy='require' name='ssbd'/>
+ <feature policy='require' name='xsaves'/>
+</cpu>
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268.json b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268.json
new file mode 100644
index 0000000000..71451f893d
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268.json
@@ -0,0 +1,702 @@
+{
+ "return": {
+ "model": {
+ "name": "base",
+ "props": {
+ "phys-bits": 0,
+ "core-id": -1,
+ "xlevel": 2147483656,
+ "cmov": true,
+ "ia64": false,
+ "ssb-no": false,
+ "aes": true,
+ "mmx": true,
+ "rdpid": false,
+ "arat": true,
+ "gfni": false,
+ "ibrs-all": true,
+ "pause-filter": false,
+ "xsavec": true,
+ "intel-pt": false,
+ "hv-frequencies": false,
+ "tsc-frequency": 0,
+ "xd": true,
+ "hv-vendor-id": "",
+ "kvm-asyncpf": true,
+ "kvm_asyncpf": true,
+ "perfctr_core": false,
+ "perfctr-core": false,
+ "mpx": true,
+ "pbe": false,
+ "decodeassists": false,
+ "avx512cd": true,
+ "sse4_1": true,
+ "sse4.1": true,
+ "sse4-1": true,
+ "family": 6,
+ "legacy-cache": true,
+ "vmware-cpuid-freq": true,
+ "wbnoinvd": false,
+ "avx512f": true,
+ "msr": true,
+ "mce": true,
+ "mca": true,
+ "hv-runtime": false,
+ "xcrypt": false,
+ "thread-id": -1,
+ "min-level": 13,
+ "xgetbv1": true,
+ "cid": false,
+ "hv-relaxed": false,
+ "hv-crash": false,
+ "ds": false,
+ "fxsr": true,
+ "xsaveopt": true,
+ "xtpr": false,
+ "hv-evmcs": false,
+ "avx512vl": true,
+ "avx512-vpopcntdq": false,
+ "phe": false,
+ "extapic": false,
+ "3dnowprefetch": true,
+ "avx512vbmi2": false,
+ "cr8legacy": false,
+ "cpuid-0xb": true,
+ "xcrypt-en": false,
+ "kvm_pv_eoi": true,
+ "apic-id": 4294967295,
+ "rsba": false,
+ "pn": false,
+ "dca": false,
+ "vendor": "GenuineIntel",
+ "hv-ipi": false,
+ "pku": true,
+ "smx": false,
+ "cmp_legacy": false,
+ "cmp-legacy": false,
+ "node-id": -1,
+ "avx512-4fmaps": false,
+ "vmcb_clean": false,
+ "vmcb-clean": false,
+ "3dnowext": false,
+ "amd-no-ssb": false,
+ "hle": true,
+ "npt": false,
+ "rdctl-no": true,
+ "memory": "/machine/unattached/system[0]",
+ "clwb": true,
+ "lbrv": false,
+ "adx": true,
+ "ss": true,
+ "pni": true,
+ "svm_lock": false,
+ "svm-lock": false,
+ "pfthreshold": false,
+ "smep": true,
+ "smap": true,
+ "x2apic": true,
+ "avx512vbmi": false,
+ "avx512vnni": true,
+ "hv-stimer": false,
+ "x-hv-synic-kvm-only": true,
+ "i64": true,
+ "flushbyasid": false,
+ "f16c": true,
+ "ace2-en": false,
+ "pat": true,
+ "pae": true,
+ "sse": true,
+ "phe-en": false,
+ "kvm_nopiodelay": true,
+ "kvm-nopiodelay": true,
+ "tm": false,
+ "kvmclock-stable-bit": true,
+ "hypervisor": true,
+ "socket-id": -1,
+ "pcommit": false,
+ "syscall": true,
+ "level": 13,
+ "avx512dq": true,
+ "x-migrate-smi-count": false,
+ "svm": false,
+ "full-cpuid-auto-level": true,
+ "hv-reset": false,
+ "invtsc": false,
+ "sse3": true,
+ "sse2": true,
+ "ssbd": true,
+ "est": false,
+ "avx512ifma": false,
+ "tm2": false,
+ "kvm-pv-ipi": true,
+ "kvm-pv-eoi": true,
+ "cx8": true,
+ "cldemote": false,
+ "hv-reenlightenment": false,
+ "kvm_mmu": false,
+ "kvm-mmu": false,
+ "sse4_2": true,
+ "sse4.2": true,
+ "sse4-2": true,
+ "pge": true,
+ "fill-mtrr-mask": true,
+ "avx512bitalg": false,
+ "nodeid_msr": false,
+ "pdcm": false,
+ "movbe": true,
+ "model": 85,
+ "nrip_save": false,
+ "nrip-save": false,
+ "kvm_pv_unhalt": true,
+ "ssse3": true,
+ "sse4a": false,
+ "invpcid": true,
+ "pdpe1gb": true,
+ "tsc-deadline": true,
+ "skip-l1dfl-vmentry": true,
+ "fma": true,
+ "cx16": true,
+ "de": true,
+ "enforce": false,
+ "stepping": 6,
+ "xsave": true,
+ "clflush": true,
+ "skinit": false,
+ "tsc": true,
+ "tce": false,
+ "fpu": true,
+ "ibs": false,
+ "ds_cpl": false,
+ "ds-cpl": false,
+ "host-phys-bits": true,
+ "fma4": false,
+ "la57": false,
+ "osvw": false,
+ "check": true,
+ "hv-spinlocks": -1,
+ "pmu": false,
+ "pmm": false,
+ "apic": true,
+ "spec-ctrl": true,
+ "min-xlevel2": 0,
+ "tsc-adjust": true,
+ "tsc_adjust": true,
+ "kvm-steal-time": true,
+ "kvm_steal_time": true,
+ "kvmclock": true,
+ "l3-cache": true,
+ "lwp": false,
+ "amd-ssbd": false,
+ "ibpb": false,
+ "xop": false,
+ "avx": true,
+ "ace2": false,
+ "avx512bw": true,
+ "acpi": false,
+ "hv-vapic": false,
+ "fsgsbase": true,
+ "ht": false,
+ "nx": true,
+ "pclmulqdq": true,
+ "mmxext": false,
+ "vaes": false,
+ "popcnt": true,
+ "xsaves": true,
+ "tcg-cpuid": true,
+ "lm": true,
+ "umip": true,
+ "pse": true,
+ "avx2": true,
+ "sep": true,
+ "pclmuldq": true,
+ "virt-ssbd": false,
+ "x-hv-max-vps": -1,
+ "nodeid-msr": false,
+ "kvm": true,
+ "misalignsse": false,
+ "min-xlevel": 2147483656,
+ "kvm-pv-unhalt": true,
+ "bmi2": true,
+ "bmi1": true,
+ "realized": false,
+ "tsc_scale": false,
+ "tsc-scale": false,
+ "topoext": false,
+ "hv-vpindex": false,
+ "xlevel2": 0,
+ "clflushopt": true,
+ "kvm-no-smi-migration": false,
+ "monitor": false,
+ "avx512er": false,
+ "pmm-en": false,
+ "pcid": true,
+ "arch-capabilities": false,
+ "3dnow": false,
+ "erms": true,
+ "lahf-lm": true,
+ "lahf_lm": true,
+ "vpclmulqdq": false,
+ "fxsr-opt": false,
+ "hv-synic": false,
+ "xstore": false,
+ "fxsr_opt": false,
+ "kvm-hint-dedicated": false,
+ "rtm": true,
+ "lmce": true,
+ "hv-time": false,
+ "perfctr-nb": false,
+ "perfctr_nb": false,
+ "ffxsr": false,
+ "hv-tlbflush": false,
+ "rdrand": true,
+ "rdseed": true,
+ "avx512-4vnniw": false,
+ "vmx": false,
+ "vme": true,
+ "dtes64": false,
+ "mtrr": true,
+ "rdtscp": true,
+ "pse36": true,
+ "kvm-pv-tlb-flush": true,
+ "tbm": false,
+ "wdt": false,
+ "pause_filter": false,
+ "sha-ni": false,
+ "model-id": "Intel(R) Xeon(R) Platinum 8268 CPU @ 2.90GHz",
+ "abm": true,
+ "avx512pf": false,
+ "xstore-en": false
+ }
+ }
+ },
+ "id": "model-expansion"
+}
+
+{
+ "return": [
+ {
+ "name": "max",
+ "typename": "max-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": false
+ },
+ {
+ "name": "host",
+ "typename": "host-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": false
+ },
+ {
+ "name": "base",
+ "typename": "base-x86_64-cpu",
+ "unavailable-features": [],
+ "static": true,
+ "migration-safe": true
+ },
+ {
+ "name": "qemu64",
+ "typename": "qemu64-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "qemu32",
+ "typename": "qemu32-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "phenom",
+ "typename": "phenom-x86_64-cpu",
+ "unavailable-features": [
+ "mmxext",
+ "fxsr-opt",
+ "3dnowext",
+ "3dnow",
+ "sse4a",
+ "npt"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "pentium3",
+ "typename": "pentium3-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "pentium2",
+ "typename": "pentium2-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "pentium",
+ "typename": "pentium-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "n270",
+ "typename": "n270-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "kvm64",
+ "typename": "kvm64-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "kvm32",
+ "typename": "kvm32-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "cpu64-rhel6",
+ "typename": "cpu64-rhel6-x86_64-cpu",
+ "unavailable-features": [
+ "sse4a"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "coreduo",
+ "typename": "coreduo-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "core2duo",
+ "typename": "core2duo-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "athlon",
+ "typename": "athlon-x86_64-cpu",
+ "unavailable-features": [
+ "mmxext",
+ "3dnowext",
+ "3dnow"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Westmere-IBRS",
+ "typename": "Westmere-IBRS-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Westmere",
+ "typename": "Westmere-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Skylake-Server-IBRS",
+ "typename": "Skylake-Server-IBRS-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Skylake-Server",
+ "typename": "Skylake-Server-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Skylake-Client-IBRS",
+ "typename": "Skylake-Client-IBRS-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Skylake-Client",
+ "typename": "Skylake-Client-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "SandyBridge-IBRS",
+ "typename": "SandyBridge-IBRS-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "SandyBridge",
+ "typename": "SandyBridge-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Penryn",
+ "typename": "Penryn-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Opteron_G5",
+ "typename": "Opteron_G5-x86_64-cpu",
+ "unavailable-features": [
+ "sse4a",
+ "misalignsse",
+ "xop",
+ "fma4",
+ "tbm"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Opteron_G4",
+ "typename": "Opteron_G4-x86_64-cpu",
+ "unavailable-features": [
+ "sse4a",
+ "misalignsse",
+ "xop",
+ "fma4"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Opteron_G3",
+ "typename": "Opteron_G3-x86_64-cpu",
+ "unavailable-features": [
+ "sse4a",
+ "misalignsse"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Opteron_G2",
+ "typename": "Opteron_G2-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Opteron_G1",
+ "typename": "Opteron_G1-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Nehalem-IBRS",
+ "typename": "Nehalem-IBRS-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Nehalem",
+ "typename": "Nehalem-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "KnightsMill",
+ "typename": "KnightsMill-x86_64-cpu",
+ "unavailable-features": [
+ "avx512pf",
+ "avx512er",
+ "avx512-vpopcntdq",
+ "avx512-4vnniw",
+ "avx512-4fmaps"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "IvyBridge-IBRS",
+ "typename": "IvyBridge-IBRS-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "IvyBridge",
+ "typename": "IvyBridge-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Icelake-Server",
+ "typename": "Icelake-Server-x86_64-cpu",
+ "unavailable-features": [
+ "avx512vbmi",
+ "",
+ "avx512vbmi2",
+ "gfni",
+ "vaes",
+ "vpclmulqdq",
+ "avx512bitalg",
+ "avx512-vpopcntdq",
+ "la57",
+ "wbnoinvd"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Icelake-Client",
+ "typename": "Icelake-Client-x86_64-cpu",
+ "unavailable-features": [
+ "avx512vbmi",
+ "",
+ "avx512vbmi2",
+ "gfni",
+ "vaes",
+ "vpclmulqdq",
+ "avx512bitalg",
+ "avx512-vpopcntdq",
+ "wbnoinvd"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Haswell-noTSX-IBRS",
+ "typename": "Haswell-noTSX-IBRS-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Haswell-noTSX",
+ "typename": "Haswell-noTSX-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Haswell-IBRS",
+ "typename": "Haswell-IBRS-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Haswell",
+ "typename": "Haswell-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "EPYC-IBPB",
+ "typename": "EPYC-IBPB-x86_64-cpu",
+ "unavailable-features": [
+ "sha-ni",
+ "mmxext",
+ "fxsr-opt",
+ "cr8legacy",
+ "sse4a",
+ "misalignsse",
+ "osvw",
+ "ibpb"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "EPYC",
+ "typename": "EPYC-x86_64-cpu",
+ "unavailable-features": [
+ "sha-ni",
+ "mmxext",
+ "fxsr-opt",
+ "cr8legacy",
+ "sse4a",
+ "misalignsse",
+ "osvw"
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Conroe",
+ "typename": "Conroe-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Cascadelake-Server",
+ "typename": "Cascadelake-Server-x86_64-cpu",
+ "unavailable-features": [
+ ""
+ ],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Broadwell-noTSX-IBRS",
+ "typename": "Broadwell-noTSX-IBRS-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Broadwell-noTSX",
+ "typename": "Broadwell-noTSX-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Broadwell-IBRS",
+ "typename": "Broadwell-IBRS-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "Broadwell",
+ "typename": "Broadwell-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ },
+ {
+ "name": "486",
+ "typename": "486-x86_64-cpu",
+ "unavailable-features": [],
+ "static": false,
+ "migration-safe": true
+ }
+ ],
+ "id": "definitions"
+}
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268.sig b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268.sig
new file mode 100644
index 0000000000..018161ff52
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268.sig
@@ -0,0 +1,4 @@
+050656
+family: 6 (0x06)
+model: 85 (0x55)
+stepping: 6 (0x06)
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268.xml b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268.xml
new file mode 100644
index 0000000000..75472d44fe
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268.xml
@@ -0,0 +1,54 @@
+<!-- Intel(R) Xeon(R) Platinum 8268 CPU @ 2.90GHz -->
+<cpudata arch='x86'>
+ <cpuid eax_in='0x00000000' ecx_in='0x00' eax='0x00000016' ebx='0x756e6547' ecx='0x6c65746e' edx='0x49656e69'/>
+ <cpuid eax_in='0x00000001' ecx_in='0x00' eax='0x00050656' ebx='0x44400800' ecx='0x7ffefbff' edx='0xbfebfbff'/>
+ <cpuid eax_in='0x00000002' ecx_in='0x00' eax='0x76036301' ebx='0x00f0b5ff' ecx='0x00000000' edx='0x00c30000'/>
+ <cpuid eax_in='0x00000003' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x00000004' ecx_in='0x00' eax='0x7c004121' ebx='0x01c0003f' ecx='0x0000003f' edx='0x00000000'/>
+ <cpuid eax_in='0x00000004' ecx_in='0x01' eax='0x7c004122' ebx='0x01c0003f' ecx='0x0000003f' edx='0x00000000'/>
+ <cpuid eax_in='0x00000004' ecx_in='0x02' eax='0x7c004143' ebx='0x03c0003f' ecx='0x000003ff' edx='0x00000000'/>
+ <cpuid eax_in='0x00000004' ecx_in='0x03' eax='0x7c0fc163' ebx='0x0280003f' ecx='0x0000cfff' edx='0x00000005'/>
+ <cpuid eax_in='0x00000005' ecx_in='0x00' eax='0x00000040' ebx='0x00000040' ecx='0x00000003' edx='0x00002020'/>
+ <cpuid eax_in='0x00000006' ecx_in='0x00' eax='0x00000077' ebx='0x00000002' ecx='0x00000009' edx='0x00000000'/>
+ <cpuid eax_in='0x00000007' ecx_in='0x00' eax='0x00000000' ebx='0xd39ffffb' ecx='0x00000818' edx='0xbc000400'/>
+ <cpuid eax_in='0x00000008' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x00000009' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x0000000a' ecx_in='0x00' eax='0x07300404' ebx='0x00000000' ecx='0x00000000' edx='0x00000603'/>
+ <cpuid eax_in='0x0000000b' ecx_in='0x00' eax='0x00000001' ebx='0x00000002' ecx='0x00000100' edx='0x00000044'/>
+ <cpuid eax_in='0x0000000b' ecx_in='0x01' eax='0x00000006' ebx='0x00000030' ecx='0x00000201' edx='0x00000044'/>
+ <cpuid eax_in='0x0000000c' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x0000000d' ecx_in='0x00' eax='0x000002ff' ebx='0x00000a88' ecx='0x00000a88' edx='0x00000000'/>
+ <cpuid eax_in='0x0000000d' ecx_in='0x01' eax='0x0000000f' ebx='0x00000a08' ecx='0x00000100' edx='0x00000000'/>
+ <cpuid eax_in='0x0000000d' ecx_in='0x02' eax='0x00000100' ebx='0x00000240' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x0000000d' ecx_in='0x03' eax='0x00000040' ebx='0x000003c0' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x0000000d' ecx_in='0x04' eax='0x00000040' ebx='0x00000400' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x0000000d' ecx_in='0x05' eax='0x00000040' ebx='0x00000440' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x0000000d' ecx_in='0x06' eax='0x00000200' ebx='0x00000480' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x0000000d' ecx_in='0x07' eax='0x00000400' ebx='0x00000680' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x0000000d' ecx_in='0x08' eax='0x00000080' ebx='0x00000000' ecx='0x00000001' edx='0x00000000'/>
+ <cpuid eax_in='0x0000000d' ecx_in='0x09' eax='0x00000008' ebx='0x00000a80' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x0000000e' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x0000000f' ecx_in='0x00' eax='0x00000000' ebx='0x000000cf' ecx='0x00000000' edx='0x00000002'/>
+ <cpuid eax_in='0x0000000f' ecx_in='0x01' eax='0x00000000' ebx='0x0001a000' ecx='0x000000cf' edx='0x00000007'/>
+ <cpuid eax_in='0x00000010' ecx_in='0x00' eax='0x00000000' ebx='0x0000000a' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x00000010' ecx_in='0x01' eax='0x0000000a' ebx='0x00000600' ecx='0x00000004' edx='0x0000000f'/>
+ <cpuid eax_in='0x00000010' ecx_in='0x03' eax='0x00000059' ebx='0x00000000' ecx='0x00000004' edx='0x00000007'/>
+ <cpuid eax_in='0x00000011' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x00000012' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x00000013' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x00000014' ecx_in='0x00' eax='0x00000001' ebx='0x0000000f' ecx='0x00000007' edx='0x00000000'/>
+ <cpuid eax_in='0x00000014' ecx_in='0x01' eax='0x02490002' ebx='0x003f3fff' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x00000015' ecx_in='0x00' eax='0x00000002' ebx='0x000000e8' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x00000016' ecx_in='0x00' eax='0x00000b54' ebx='0x00000f3c' ecx='0x00000064' edx='0x00000000'/>
+ <cpuid eax_in='0x80000000' ecx_in='0x00' eax='0x80000008' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x80000001' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000121' edx='0x2c100800'/>
+ <cpuid eax_in='0x80000002' ecx_in='0x00' eax='0x65746e49' ebx='0x2952286c' ecx='0x6f655820' edx='0x2952286e'/>
+ <cpuid eax_in='0x80000003' ecx_in='0x00' eax='0x616c5020' ebx='0x756e6974' ecx='0x3238206d' edx='0x43203836'/>
+ <cpuid eax_in='0x80000004' ecx_in='0x00' eax='0x40205550' ebx='0x392e3220' ecx='0x7a484730' edx='0x00000000'/>
+ <cpuid eax_in='0x80000005' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x80000006' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x01006040' edx='0x00000000'/>
+ <cpuid eax_in='0x80000007' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000100'/>
+ <cpuid eax_in='0x80000008' ecx_in='0x00' eax='0x0000302e' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x80860000' ecx_in='0x00' eax='0x00000b54' ebx='0x00000f3c' ecx='0x00000064' edx='0x00000000'/>
+ <cpuid eax_in='0xc0000000' ecx_in='0x00' eax='0x00000b54' ebx='0x00000f3c' ecx='0x00000064' edx='0x00000000'/>
+</cpudata>
--
2.22.0

View File

@ -0,0 +1,41 @@
From 7084115edc91fd3cff8ba35af1fc705c917973cf Mon Sep 17 00:00:00 2001
Message-Id: <7084115edc91fd3cff8ba35af1fc705c917973cf@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:25:41 +0200
Subject: [PATCH] cputest: Add support for MSR features to cpu-parse.sh
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The script just parses whatever cpu-gather.sh printed out.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 8904492e21537f3b820e577964e67ad670fa640b)
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
Conflicts:
tests/cputestdata/cpu-parse.sh
- no need to update this script downstream
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <55c3125aef5a2d7bf7b2d7a6fc5c868af7903447.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268.xml | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268.xml b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268.xml
index 75472d44fe..f1261da891 100644
--- a/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268.xml
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268.xml
@@ -51,4 +51,5 @@
<cpuid eax_in='0x80000008' ecx_in='0x00' eax='0x0000302e' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
<cpuid eax_in='0x80860000' ecx_in='0x00' eax='0x00000b54' ebx='0x00000f3c' ecx='0x00000064' edx='0x00000000'/>
<cpuid eax_in='0xc0000000' ecx_in='0x00' eax='0x00000b54' ebx='0x00000f3c' ecx='0x00000064' edx='0x00000000'/>
+ <msr index='0x10a' edx='0x00000000' eax='0x0000002b'/>
</cpudata>
--
2.22.0

View File

@ -0,0 +1,755 @@
From 58b7dda3dda6a768f465f2b8782ef665bd0d7f72 Mon Sep 17 00:00:00 2001
Message-Id: <58b7dda3dda6a768f465f2b8782ef665bd0d7f72@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:25:08 +0200
Subject: [PATCH] cputest: Test CPU signatures
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The signature computation code is not too complicated and it will likely
never change so testing it is not very important. We do it mostly for a
nice side effect of easily accessible signature numbers for all CPU
data files.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit dd08d27fc205c86961b6d957fbb92da5aead5d1b)
https://bugzilla.redhat.com/show_bug.cgi?id=1686895
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <24fc3fddd709251f12a12589605c76634af8fb1b.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
tests/cputest.c | 86 +++++++++++++++++++
tests/cputestdata/x86_64-cpuid-A10-5800K.sig | 4 +
tests/cputestdata/x86_64-cpuid-Atom-D510.sig | 4 +
tests/cputestdata/x86_64-cpuid-Atom-N450.sig | 4 +
.../cputestdata/x86_64-cpuid-Core-i5-2500.sig | 4 +
.../x86_64-cpuid-Core-i5-2540M.sig | 4 +
.../x86_64-cpuid-Core-i5-4670T.sig | 4 +
.../cputestdata/x86_64-cpuid-Core-i5-650.sig | 4 +
.../cputestdata/x86_64-cpuid-Core-i5-6600.sig | 4 +
.../x86_64-cpuid-Core-i7-2600-xsaveopt.sig | 4 +
.../cputestdata/x86_64-cpuid-Core-i7-2600.sig | 4 +
.../x86_64-cpuid-Core-i7-3520M.sig | 4 +
.../x86_64-cpuid-Core-i7-3740QM.sig | 4 +
.../cputestdata/x86_64-cpuid-Core-i7-3770.sig | 4 +
.../x86_64-cpuid-Core-i7-4510U.sig | 4 +
.../x86_64-cpuid-Core-i7-4600U.sig | 4 +
.../x86_64-cpuid-Core-i7-5600U-arat.sig | 4 +
.../x86_64-cpuid-Core-i7-5600U-ibrs.sig | 4 +
.../x86_64-cpuid-Core-i7-5600U.sig | 4 +
.../x86_64-cpuid-Core-i7-7600U.sig | 4 +
.../cputestdata/x86_64-cpuid-Core-i7-7700.sig | 4 +
.../cputestdata/x86_64-cpuid-Core-i7-8700.sig | 4 +
.../cputestdata/x86_64-cpuid-Core2-E6850.sig | 4 +
.../cputestdata/x86_64-cpuid-Core2-Q9500.sig | 4 +
.../x86_64-cpuid-EPYC-7601-32-Core-ibpb.sig | 4 +
.../x86_64-cpuid-EPYC-7601-32-Core.sig | 4 +
tests/cputestdata/x86_64-cpuid-FX-8150.sig | 4 +
.../cputestdata/x86_64-cpuid-Opteron-1352.sig | 4 +
.../cputestdata/x86_64-cpuid-Opteron-2350.sig | 4 +
.../cputestdata/x86_64-cpuid-Opteron-6234.sig | 4 +
.../cputestdata/x86_64-cpuid-Opteron-6282.sig | 4 +
.../x86_64-cpuid-Pentium-P6100.sig | 4 +
tests/cputestdata/x86_64-cpuid-Phenom-B95.sig | 4 +
.../x86_64-cpuid-Ryzen-7-1800X-Eight-Core.sig | 4 +
tests/cputestdata/x86_64-cpuid-Xeon-5110.sig | 4 +
.../x86_64-cpuid-Xeon-E3-1245-v5.sig | 4 +
.../x86_64-cpuid-Xeon-E5-2609-v3.sig | 4 +
.../x86_64-cpuid-Xeon-E5-2623-v4.sig | 4 +
.../x86_64-cpuid-Xeon-E5-2630-v3.sig | 4 +
.../x86_64-cpuid-Xeon-E5-2630-v4.sig | 4 +
.../x86_64-cpuid-Xeon-E5-2650-v3.sig | 4 +
.../x86_64-cpuid-Xeon-E5-2650-v4.sig | 4 +
.../cputestdata/x86_64-cpuid-Xeon-E5-2650.sig | 4 +
.../cputestdata/x86_64-cpuid-Xeon-E7-4820.sig | 4 +
.../cputestdata/x86_64-cpuid-Xeon-E7-4830.sig | 4 +
.../x86_64-cpuid-Xeon-E7-8890-v3.sig | 4 +
tests/cputestdata/x86_64-cpuid-Xeon-E7540.sig | 4 +
.../x86_64-cpuid-Xeon-Gold-5115.sig | 4 +
.../x86_64-cpuid-Xeon-Gold-6148.sig | 4 +
tests/cputestdata/x86_64-cpuid-Xeon-W3520.sig | 4 +
tests/cputestdata/x86_64-cpuid-Xeon-X5460.sig | 4 +
51 files changed, 286 insertions(+)
create mode 100644 tests/cputestdata/x86_64-cpuid-A10-5800K.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-Atom-D510.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-Atom-N450.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i5-2500.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i5-2540M.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i5-4670T.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i5-650.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i5-6600.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-2600-xsaveopt.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-2600.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-3520M.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-3740QM.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-3770.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-4510U.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-4600U.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-5600U-ibrs.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-5600U.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-7600U.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-7700.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-8700.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-Core2-E6850.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-Core2-Q9500.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-EPYC-7601-32-Core-ibpb.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-EPYC-7601-32-Core.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-FX-8150.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-Opteron-1352.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-Opteron-2350.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-Opteron-6234.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-Opteron-6282.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-Pentium-P6100.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-Phenom-B95.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-Ryzen-7-1800X-Eight-Core.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-Xeon-5110.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-Xeon-E3-1245-v5.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-Xeon-E5-2609-v3.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-Xeon-E5-2623-v4.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-v3.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-v4.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-Xeon-E5-2650-v3.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-Xeon-E5-2650-v4.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-Xeon-E5-2650.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-Xeon-E7-4820.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-Xeon-E7-4830.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-Xeon-E7-8890-v3.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-Xeon-E7540.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-Xeon-Gold-5115.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-Xeon-Gold-6148.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-Xeon-W3520.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-Xeon-X5460.sig
diff --git a/tests/cputest.c b/tests/cputest.c
index 9e5f807823..0cb9a57592 100644
--- a/tests/cputest.c
+++ b/tests/cputest.c
@@ -37,6 +37,7 @@
#include "testutils.h"
#include "cpu_conf.h"
#include "cpu/cpu.h"
+#include "cpu/cpu_x86.h"
#include "cpu/cpu_map.h"
#include "virstring.h"
@@ -648,6 +649,62 @@ cpuTestGuestCPUID(const void *arg)
}
+static int
+cpuTestCompareSignature(const struct data *data,
+ virCPUDataPtr hostData)
+{
+ VIR_AUTOFREE(char *) result = NULL;
+ VIR_AUTOFREE(char *) sigStr = NULL;
+ unsigned long signature;
+ unsigned int family;
+ unsigned int model;
+ unsigned int stepping;
+
+ signature = virCPUx86DataGetSignature(hostData, &family, &model, &stepping);
+
+ if (virAsprintf(&result, "%s/cputestdata/%s-cpuid-%s.sig",
+ abs_srcdir, virArchToString(data->arch), data->host) < 0)
+ return -1;
+
+ if (virAsprintf(&sigStr,
+ "%1$06lx\n"
+ "family: %2$3u (0x%2$02x)\n"
+ "model: %3$3u (0x%3$02x)\n"
+ "stepping: %4$3u (0x%4$02x)\n",
+ signature, family, model, stepping) < 0)
+ return -1;
+
+ return virTestCompareToFile(sigStr, result);
+}
+
+
+static int
+cpuTestCPUIDSignature(const void *arg)
+{
+ const struct data *data = arg;
+ virCPUDataPtr hostData = NULL;
+ char *hostFile = NULL;
+ char *host = NULL;
+ int ret = -1;
+
+ if (virAsprintf(&hostFile, "%s/cputestdata/%s-cpuid-%s.xml",
+ abs_srcdir, virArchToString(data->arch), data->host) < 0)
+ goto cleanup;
+
+ if (virTestLoadFile(hostFile, &host) < 0 ||
+ !(hostData = virCPUDataParse(host)))
+ goto cleanup;
+
+ ret = cpuTestCompareSignature(data, hostData);
+
+ cleanup:
+ virCPUDataFree(hostData);
+ VIR_FREE(hostFile);
+ VIR_FREE(host);
+ return ret;
+}
+
+
static int
cpuTestUpdateLiveCompare(virArch arch,
virCPUDefPtr actual,
@@ -869,6 +926,31 @@ cpuTestJSONCPUID(const void *arg)
VIR_FREE(result);
return ret;
}
+
+
+static int
+cpuTestJSONSignature(const void *arg)
+{
+ const struct data *data = arg;
+ virQEMUCapsPtr qemuCaps = NULL;
+ virCPUDataPtr hostData = NULL;
+ qemuMonitorCPUModelInfoPtr modelInfo;
+ int ret = -1;
+
+ if (!(qemuCaps = cpuTestMakeQEMUCaps(data)))
+ goto cleanup;
+
+ modelInfo = virQEMUCapsGetCPUModelInfo(qemuCaps, VIR_DOMAIN_VIRT_KVM);
+ if (!(hostData = virQEMUCapsGetCPUModelX86Data(modelInfo, false)))
+ goto cleanup;
+
+ ret = cpuTestCompareSignature(data, hostData);
+
+ cleanup:
+ virObjectUnref(qemuCaps);
+ virCPUDataFree(hostData);
+ return ret;
+}
#endif
@@ -1014,6 +1096,8 @@ mymain(void)
if (json != JSON_NONE) { \
DO_TEST(arch, cpuTestJSONCPUID, host, host, \
NULL, NULL, json, 0); \
+ DO_TEST(arch, cpuTestJSONSignature, host, host, \
+ NULL, NULL, 0, 0); \
} \
} while (0)
#else
@@ -1026,6 +1110,8 @@ mymain(void)
NULL, NULL, 0, 0); \
DO_TEST(arch, cpuTestGuestCPUID, host, host, \
NULL, NULL, json, 0); \
+ DO_TEST(arch, cpuTestCPUIDSignature, host, host, \
+ NULL, NULL, 0, 0); \
DO_TEST_JSON(arch, host, json); \
if (json != JSON_NONE) { \
DO_TEST(arch, cpuTestUpdateLive, host, host, \
diff --git a/tests/cputestdata/x86_64-cpuid-A10-5800K.sig b/tests/cputestdata/x86_64-cpuid-A10-5800K.sig
new file mode 100644
index 0000000000..8045eda561
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-A10-5800K.sig
@@ -0,0 +1,4 @@
+610f01
+family: 21 (0x15)
+model: 16 (0x10)
+stepping: 1 (0x01)
diff --git a/tests/cputestdata/x86_64-cpuid-Atom-D510.sig b/tests/cputestdata/x86_64-cpuid-Atom-D510.sig
new file mode 100644
index 0000000000..d22d28ff8a
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Atom-D510.sig
@@ -0,0 +1,4 @@
+0106ca
+family: 6 (0x06)
+model: 28 (0x1c)
+stepping: 10 (0x0a)
diff --git a/tests/cputestdata/x86_64-cpuid-Atom-N450.sig b/tests/cputestdata/x86_64-cpuid-Atom-N450.sig
new file mode 100644
index 0000000000..d22d28ff8a
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Atom-N450.sig
@@ -0,0 +1,4 @@
+0106ca
+family: 6 (0x06)
+model: 28 (0x1c)
+stepping: 10 (0x0a)
diff --git a/tests/cputestdata/x86_64-cpuid-Core-i5-2500.sig b/tests/cputestdata/x86_64-cpuid-Core-i5-2500.sig
new file mode 100644
index 0000000000..9b113c3798
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Core-i5-2500.sig
@@ -0,0 +1,4 @@
+0206a7
+family: 6 (0x06)
+model: 42 (0x2a)
+stepping: 7 (0x07)
diff --git a/tests/cputestdata/x86_64-cpuid-Core-i5-2540M.sig b/tests/cputestdata/x86_64-cpuid-Core-i5-2540M.sig
new file mode 100644
index 0000000000..9b113c3798
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Core-i5-2540M.sig
@@ -0,0 +1,4 @@
+0206a7
+family: 6 (0x06)
+model: 42 (0x2a)
+stepping: 7 (0x07)
diff --git a/tests/cputestdata/x86_64-cpuid-Core-i5-4670T.sig b/tests/cputestdata/x86_64-cpuid-Core-i5-4670T.sig
new file mode 100644
index 0000000000..e2fb6c5dd2
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Core-i5-4670T.sig
@@ -0,0 +1,4 @@
+0306c3
+family: 6 (0x06)
+model: 60 (0x3c)
+stepping: 3 (0x03)
diff --git a/tests/cputestdata/x86_64-cpuid-Core-i5-650.sig b/tests/cputestdata/x86_64-cpuid-Core-i5-650.sig
new file mode 100644
index 0000000000..fc7c566de5
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Core-i5-650.sig
@@ -0,0 +1,4 @@
+020652
+family: 6 (0x06)
+model: 37 (0x25)
+stepping: 2 (0x02)
diff --git a/tests/cputestdata/x86_64-cpuid-Core-i5-6600.sig b/tests/cputestdata/x86_64-cpuid-Core-i5-6600.sig
new file mode 100644
index 0000000000..7e57c2ded6
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Core-i5-6600.sig
@@ -0,0 +1,4 @@
+0506e3
+family: 6 (0x06)
+model: 94 (0x5e)
+stepping: 3 (0x03)
diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-2600-xsaveopt.sig b/tests/cputestdata/x86_64-cpuid-Core-i7-2600-xsaveopt.sig
new file mode 100644
index 0000000000..9b113c3798
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Core-i7-2600-xsaveopt.sig
@@ -0,0 +1,4 @@
+0206a7
+family: 6 (0x06)
+model: 42 (0x2a)
+stepping: 7 (0x07)
diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-2600.sig b/tests/cputestdata/x86_64-cpuid-Core-i7-2600.sig
new file mode 100644
index 0000000000..9b113c3798
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Core-i7-2600.sig
@@ -0,0 +1,4 @@
+0206a7
+family: 6 (0x06)
+model: 42 (0x2a)
+stepping: 7 (0x07)
diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-3520M.sig b/tests/cputestdata/x86_64-cpuid-Core-i7-3520M.sig
new file mode 100644
index 0000000000..9c6ea10a83
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Core-i7-3520M.sig
@@ -0,0 +1,4 @@
+0306a9
+family: 6 (0x06)
+model: 58 (0x3a)
+stepping: 9 (0x09)
diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-3740QM.sig b/tests/cputestdata/x86_64-cpuid-Core-i7-3740QM.sig
new file mode 100644
index 0000000000..9c6ea10a83
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Core-i7-3740QM.sig
@@ -0,0 +1,4 @@
+0306a9
+family: 6 (0x06)
+model: 58 (0x3a)
+stepping: 9 (0x09)
diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-3770.sig b/tests/cputestdata/x86_64-cpuid-Core-i7-3770.sig
new file mode 100644
index 0000000000..9c6ea10a83
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Core-i7-3770.sig
@@ -0,0 +1,4 @@
+0306a9
+family: 6 (0x06)
+model: 58 (0x3a)
+stepping: 9 (0x09)
diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-4510U.sig b/tests/cputestdata/x86_64-cpuid-Core-i7-4510U.sig
new file mode 100644
index 0000000000..fd6726a3da
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Core-i7-4510U.sig
@@ -0,0 +1,4 @@
+040651
+family: 6 (0x06)
+model: 69 (0x45)
+stepping: 1 (0x01)
diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-4600U.sig b/tests/cputestdata/x86_64-cpuid-Core-i7-4600U.sig
new file mode 100644
index 0000000000..fd6726a3da
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Core-i7-4600U.sig
@@ -0,0 +1,4 @@
+040651
+family: 6 (0x06)
+model: 69 (0x45)
+stepping: 1 (0x01)
diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat.sig b/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat.sig
new file mode 100644
index 0000000000..dd18d0f76d
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat.sig
@@ -0,0 +1,4 @@
+0306d4
+family: 6 (0x06)
+model: 61 (0x3d)
+stepping: 4 (0x04)
diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-ibrs.sig b/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-ibrs.sig
new file mode 100644
index 0000000000..dd18d0f76d
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-ibrs.sig
@@ -0,0 +1,4 @@
+0306d4
+family: 6 (0x06)
+model: 61 (0x3d)
+stepping: 4 (0x04)
diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-5600U.sig b/tests/cputestdata/x86_64-cpuid-Core-i7-5600U.sig
new file mode 100644
index 0000000000..dd18d0f76d
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Core-i7-5600U.sig
@@ -0,0 +1,4 @@
+0306d4
+family: 6 (0x06)
+model: 61 (0x3d)
+stepping: 4 (0x04)
diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-7600U.sig b/tests/cputestdata/x86_64-cpuid-Core-i7-7600U.sig
new file mode 100644
index 0000000000..8f757722bb
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Core-i7-7600U.sig
@@ -0,0 +1,4 @@
+0806e9
+family: 6 (0x06)
+model: 142 (0x8e)
+stepping: 9 (0x09)
diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-7700.sig b/tests/cputestdata/x86_64-cpuid-Core-i7-7700.sig
new file mode 100644
index 0000000000..d4db84a618
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Core-i7-7700.sig
@@ -0,0 +1,4 @@
+0906e9
+family: 6 (0x06)
+model: 158 (0x9e)
+stepping: 9 (0x09)
diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-8700.sig b/tests/cputestdata/x86_64-cpuid-Core-i7-8700.sig
new file mode 100644
index 0000000000..45d6ea29d0
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Core-i7-8700.sig
@@ -0,0 +1,4 @@
+0906ea
+family: 6 (0x06)
+model: 158 (0x9e)
+stepping: 10 (0x0a)
diff --git a/tests/cputestdata/x86_64-cpuid-Core2-E6850.sig b/tests/cputestdata/x86_64-cpuid-Core2-E6850.sig
new file mode 100644
index 0000000000..2382914bc7
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Core2-E6850.sig
@@ -0,0 +1,4 @@
+0006fb
+family: 6 (0x06)
+model: 15 (0x0f)
+stepping: 11 (0x0b)
diff --git a/tests/cputestdata/x86_64-cpuid-Core2-Q9500.sig b/tests/cputestdata/x86_64-cpuid-Core2-Q9500.sig
new file mode 100644
index 0000000000..9aec5927d0
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Core2-Q9500.sig
@@ -0,0 +1,4 @@
+01067a
+family: 6 (0x06)
+model: 23 (0x17)
+stepping: 10 (0x0a)
diff --git a/tests/cputestdata/x86_64-cpuid-EPYC-7601-32-Core-ibpb.sig b/tests/cputestdata/x86_64-cpuid-EPYC-7601-32-Core-ibpb.sig
new file mode 100644
index 0000000000..8fe15b7991
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-EPYC-7601-32-Core-ibpb.sig
@@ -0,0 +1,4 @@
+800f12
+family: 23 (0x17)
+model: 1 (0x01)
+stepping: 2 (0x02)
diff --git a/tests/cputestdata/x86_64-cpuid-EPYC-7601-32-Core.sig b/tests/cputestdata/x86_64-cpuid-EPYC-7601-32-Core.sig
new file mode 100644
index 0000000000..8fe15b7991
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-EPYC-7601-32-Core.sig
@@ -0,0 +1,4 @@
+800f12
+family: 23 (0x17)
+model: 1 (0x01)
+stepping: 2 (0x02)
diff --git a/tests/cputestdata/x86_64-cpuid-FX-8150.sig b/tests/cputestdata/x86_64-cpuid-FX-8150.sig
new file mode 100644
index 0000000000..4b6440a315
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-FX-8150.sig
@@ -0,0 +1,4 @@
+600f12
+family: 21 (0x15)
+model: 1 (0x01)
+stepping: 2 (0x02)
diff --git a/tests/cputestdata/x86_64-cpuid-Opteron-1352.sig b/tests/cputestdata/x86_64-cpuid-Opteron-1352.sig
new file mode 100644
index 0000000000..d21535b4b9
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Opteron-1352.sig
@@ -0,0 +1,4 @@
+100f23
+family: 16 (0x10)
+model: 2 (0x02)
+stepping: 3 (0x03)
diff --git a/tests/cputestdata/x86_64-cpuid-Opteron-2350.sig b/tests/cputestdata/x86_64-cpuid-Opteron-2350.sig
new file mode 100644
index 0000000000..d21535b4b9
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Opteron-2350.sig
@@ -0,0 +1,4 @@
+100f23
+family: 16 (0x10)
+model: 2 (0x02)
+stepping: 3 (0x03)
diff --git a/tests/cputestdata/x86_64-cpuid-Opteron-6234.sig b/tests/cputestdata/x86_64-cpuid-Opteron-6234.sig
new file mode 100644
index 0000000000..4b6440a315
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Opteron-6234.sig
@@ -0,0 +1,4 @@
+600f12
+family: 21 (0x15)
+model: 1 (0x01)
+stepping: 2 (0x02)
diff --git a/tests/cputestdata/x86_64-cpuid-Opteron-6282.sig b/tests/cputestdata/x86_64-cpuid-Opteron-6282.sig
new file mode 100644
index 0000000000..4b6440a315
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Opteron-6282.sig
@@ -0,0 +1,4 @@
+600f12
+family: 21 (0x15)
+model: 1 (0x01)
+stepping: 2 (0x02)
diff --git a/tests/cputestdata/x86_64-cpuid-Pentium-P6100.sig b/tests/cputestdata/x86_64-cpuid-Pentium-P6100.sig
new file mode 100644
index 0000000000..8712d34023
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Pentium-P6100.sig
@@ -0,0 +1,4 @@
+020655
+family: 6 (0x06)
+model: 37 (0x25)
+stepping: 5 (0x05)
diff --git a/tests/cputestdata/x86_64-cpuid-Phenom-B95.sig b/tests/cputestdata/x86_64-cpuid-Phenom-B95.sig
new file mode 100644
index 0000000000..c93dbebc45
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Phenom-B95.sig
@@ -0,0 +1,4 @@
+100f42
+family: 16 (0x10)
+model: 4 (0x04)
+stepping: 2 (0x02)
diff --git a/tests/cputestdata/x86_64-cpuid-Ryzen-7-1800X-Eight-Core.sig b/tests/cputestdata/x86_64-cpuid-Ryzen-7-1800X-Eight-Core.sig
new file mode 100644
index 0000000000..031bb84902
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Ryzen-7-1800X-Eight-Core.sig
@@ -0,0 +1,4 @@
+800f11
+family: 23 (0x17)
+model: 1 (0x01)
+stepping: 1 (0x01)
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-5110.sig b/tests/cputestdata/x86_64-cpuid-Xeon-5110.sig
new file mode 100644
index 0000000000..15f8400ca6
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-5110.sig
@@ -0,0 +1,4 @@
+0006f6
+family: 6 (0x06)
+model: 15 (0x0f)
+stepping: 6 (0x06)
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-E3-1245-v5.sig b/tests/cputestdata/x86_64-cpuid-Xeon-E3-1245-v5.sig
new file mode 100644
index 0000000000..7e57c2ded6
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-E3-1245-v5.sig
@@ -0,0 +1,4 @@
+0506e3
+family: 6 (0x06)
+model: 94 (0x5e)
+stepping: 3 (0x03)
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2609-v3.sig b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2609-v3.sig
new file mode 100644
index 0000000000..2c548c9934
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2609-v3.sig
@@ -0,0 +1,4 @@
+0306f2
+family: 6 (0x06)
+model: 63 (0x3f)
+stepping: 2 (0x02)
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2623-v4.sig b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2623-v4.sig
new file mode 100644
index 0000000000..4d1622a8ef
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2623-v4.sig
@@ -0,0 +1,4 @@
+0406f1
+family: 6 (0x06)
+model: 79 (0x4f)
+stepping: 1 (0x01)
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-v3.sig b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-v3.sig
new file mode 100644
index 0000000000..2c548c9934
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-v3.sig
@@ -0,0 +1,4 @@
+0306f2
+family: 6 (0x06)
+model: 63 (0x3f)
+stepping: 2 (0x02)
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-v4.sig b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-v4.sig
new file mode 100644
index 0000000000..4d1622a8ef
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-v4.sig
@@ -0,0 +1,4 @@
+0406f1
+family: 6 (0x06)
+model: 79 (0x4f)
+stepping: 1 (0x01)
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2650-v3.sig b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2650-v3.sig
new file mode 100644
index 0000000000..2c548c9934
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2650-v3.sig
@@ -0,0 +1,4 @@
+0306f2
+family: 6 (0x06)
+model: 63 (0x3f)
+stepping: 2 (0x02)
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2650-v4.sig b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2650-v4.sig
new file mode 100644
index 0000000000..4d1622a8ef
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2650-v4.sig
@@ -0,0 +1,4 @@
+0406f1
+family: 6 (0x06)
+model: 79 (0x4f)
+stepping: 1 (0x01)
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2650.sig b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2650.sig
new file mode 100644
index 0000000000..d6493fe186
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2650.sig
@@ -0,0 +1,4 @@
+0206d7
+family: 6 (0x06)
+model: 45 (0x2d)
+stepping: 7 (0x07)
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-E7-4820.sig b/tests/cputestdata/x86_64-cpuid-Xeon-E7-4820.sig
new file mode 100644
index 0000000000..8738e95e41
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-E7-4820.sig
@@ -0,0 +1,4 @@
+0206f2
+family: 6 (0x06)
+model: 47 (0x2f)
+stepping: 2 (0x02)
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-E7-4830.sig b/tests/cputestdata/x86_64-cpuid-Xeon-E7-4830.sig
new file mode 100644
index 0000000000..8738e95e41
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-E7-4830.sig
@@ -0,0 +1,4 @@
+0206f2
+family: 6 (0x06)
+model: 47 (0x2f)
+stepping: 2 (0x02)
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-E7-8890-v3.sig b/tests/cputestdata/x86_64-cpuid-Xeon-E7-8890-v3.sig
new file mode 100644
index 0000000000..8fb489fac9
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-E7-8890-v3.sig
@@ -0,0 +1,4 @@
+0306f4
+family: 6 (0x06)
+model: 63 (0x3f)
+stepping: 4 (0x04)
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-E7540.sig b/tests/cputestdata/x86_64-cpuid-Xeon-E7540.sig
new file mode 100644
index 0000000000..afc150cf82
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-E7540.sig
@@ -0,0 +1,4 @@
+0206e6
+family: 6 (0x06)
+model: 46 (0x2e)
+stepping: 6 (0x06)
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-Gold-5115.sig b/tests/cputestdata/x86_64-cpuid-Xeon-Gold-5115.sig
new file mode 100644
index 0000000000..1a3f3449f0
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-Gold-5115.sig
@@ -0,0 +1,4 @@
+050654
+family: 6 (0x06)
+model: 85 (0x55)
+stepping: 4 (0x04)
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-Gold-6148.sig b/tests/cputestdata/x86_64-cpuid-Xeon-Gold-6148.sig
new file mode 100644
index 0000000000..1a3f3449f0
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-Gold-6148.sig
@@ -0,0 +1,4 @@
+050654
+family: 6 (0x06)
+model: 85 (0x55)
+stepping: 4 (0x04)
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-W3520.sig b/tests/cputestdata/x86_64-cpuid-Xeon-W3520.sig
new file mode 100644
index 0000000000..4b641ba966
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-W3520.sig
@@ -0,0 +1,4 @@
+0106a5
+family: 6 (0x06)
+model: 26 (0x1a)
+stepping: 5 (0x05)
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-X5460.sig b/tests/cputestdata/x86_64-cpuid-Xeon-X5460.sig
new file mode 100644
index 0000000000..e17253472f
--- /dev/null
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-X5460.sig
@@ -0,0 +1,4 @@
+010676
+family: 6 (0x06)
+model: 23 (0x17)
+stepping: 6 (0x06)
--
2.22.0

View File

@ -0,0 +1,59 @@
From 8a9a0815510ef6de1ee34b865a768d0c6fd7b828 Mon Sep 17 00:00:00 2001
Message-Id: <8a9a0815510ef6de1ee34b865a768d0c6fd7b828@dist-git>
From: Michal Privoznik <mprivozn@redhat.com>
Date: Thu, 27 Jun 2019 15:18:14 +0200
Subject: [PATCH] daemon: Register secret driver before storage driver
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The order in which drivers are registered is important because
their stateInitialize and stateAutoStart callback are called in
that order. Well, stateAutoStart is going away and therefore if
there is some dependency between two drivers (e.g. when
initializing storage driver expects secret driver to be available
already), the registration of such drivers must happen in correct
order.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit c6266ddb0214512200c5043f3196d3ca3e73919d)
https://bugzilla.redhat.com/show_bug.cgi?id=1685151
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Message-Id: <f67abc5158c74a295438b5e2f1b8106e8910bfde.1561641375.git.mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
---
src/remote/remote_daemon.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/remote/remote_daemon.c b/src/remote/remote_daemon.c
index 9f3a5f38ad..4cd6784099 100644
--- a/src/remote/remote_daemon.c
+++ b/src/remote/remote_daemon.c
@@ -314,6 +314,10 @@ static int daemonInitialize(void)
if (virDriverLoadModule("interface", "interfaceRegister", false) < 0)
return -1;
#endif
+#ifdef WITH_SECRETS
+ if (virDriverLoadModule("secret", "secretRegister", false) < 0)
+ return -1;
+#endif
#ifdef WITH_STORAGE
if (virDriverLoadModule("storage", "storageRegister", false) < 0)
return -1;
@@ -322,10 +326,6 @@ static int daemonInitialize(void)
if (virDriverLoadModule("nodedev", "nodedevRegister", false) < 0)
return -1;
#endif
-#ifdef WITH_SECRETS
- if (virDriverLoadModule("secret", "secretRegister", false) < 0)
- return -1;
-#endif
#ifdef WITH_NWFILTER
if (virDriverLoadModule("nwfilter", "nwfilterRegister", false) < 0)
return -1;
--
2.22.0

View File

@ -0,0 +1,44 @@
From eb6fef622ded5762649db2d766c1eb3d876859c9 Mon Sep 17 00:00:00 2001
Message-Id: <eb6fef622ded5762649db2d766c1eb3d876859c9@dist-git>
From: Erik Skultety <eskultet@redhat.com>
Date: Mon, 15 Jul 2019 08:52:07 +0200
Subject: [PATCH] docs: schemas: Decouple the virtio options from each other
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Currently, all of the VirtioOptions are under a single <optional>
element, however, neither our parser/formatter or QEMU driver requires
the presence of all the options if only a single one from the set has
been specified, so fix it and silence the schema validator.
Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 87b4e1cd7e7ec23dc69c8082948cd3bb49e18ff3)
https://bugzilla.redhat.com/show_bug.cgi?id=1729675
Signed-off-by: Erik Skultety <eskultet@redhat.com>
Message-Id: <9d20b6d62248ef82a42128c461ef8c94cbc64e09.1563173480.git.eskultet@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
docs/schemas/domaincommon.rng | 2 ++
1 file changed, 2 insertions(+)
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 2b6d4dced6..7d37caa246 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -5417,6 +5417,8 @@
<attribute name="iommu">
<ref name="virOnOff"/>
</attribute>
+ </optional>
+ <optional>
<attribute name="ats">
<ref name="virOnOff"/>
</attribute>
--
2.22.0

View File

@ -0,0 +1,55 @@
From c93476692d7e0373f147c3ed20761ea1fe836e89 Mon Sep 17 00:00:00 2001
Message-Id: <c93476692d7e0373f147c3ed20761ea1fe836e89@dist-git>
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
Date: Mon, 1 Jul 2019 17:08:16 +0200
Subject: [PATCH] internal: introduce a family of NULLSTR macros
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
NULLSTR_EMPTY, the quiet child,
NULLSTR_STAR, the famous one and
NULLSTR_MINUS, the grumpy one.
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
(cherry picked from commit bd5519deb75e9ff8adcd56d34cbe82dd6a341bcb)
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1689297
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Message-Id: <16722b79dbd931a33ef495b863c5716bb5d6e97c.1561993100.git.phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/internal.h | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/src/internal.h b/src/internal.h
index 47ff0479d2..a4f6605a50 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -244,6 +244,21 @@
*/
# define EMPTYSTR(s) ((s) ? (s) : "-")
+/*
+ * Turn a NULL string into an empty string
+ */
+# define NULLSTR_EMPTY(s) ((s) ? (s) : "")
+
+/*
+ * Turn a NULL string into a star
+ */
+# define NULLSTR_STAR(s) ((s) ? (s) : "*")
+
+/*
+ * Turn a NULL string into a minus sign
+ */
+# define NULLSTR_MINUS(s) ((s) ? (s) : "-")
+
/**
* SWAP:
*
--
2.22.0

View File

@ -0,0 +1,73 @@
From b5dbb3bd65642516a773a2cdf67efe977cfec4b4 Mon Sep 17 00:00:00 2001
Message-Id: <b5dbb3bd65642516a773a2cdf67efe977cfec4b4@dist-git>
From: Michal Privoznik <mprivozn@redhat.com>
Date: Thu, 27 Jun 2019 15:55:37 +0200
Subject: [PATCH] lib: Drop UDEVSETTLE
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The udevsettle binary is no longer used anywhere as it was
replaced by 'udevadm settle'. There's no reason for us to even
check for it in configure.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 2944dcb2de014a881c3539a43f989c2a723e87ca)
https://bugzilla.redhat.com/show_bug.cgi?id=1710575
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Message-Id: <b69a2303299a9d69d58d4d54cebd306cdba87c3b.1561643698.git.mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
m4/virt-external-programs.m4 | 5 -----
src/util/virutil.c | 6 +-----
2 files changed, 1 insertion(+), 10 deletions(-)
diff --git a/m4/virt-external-programs.m4 b/m4/virt-external-programs.m4
index ab6149288f..3c915e1a65 100644
--- a/m4/virt-external-programs.m4
+++ b/m4/virt-external-programs.m4
@@ -46,7 +46,6 @@ AC_DEFUN([LIBVIRT_CHECK_EXTERNAL_PROGRAMS], [
AC_PATH_PROG([RADVD], [radvd], [radvd], [$LIBVIRT_SBIN_PATH])
AC_PATH_PROG([TC], [tc], [tc], [$LIBVIRT_SBIN_PATH])
AC_PATH_PROG([UDEVADM], [udevadm], [], [$LIBVIRT_SBIN_PATH])
- AC_PATH_PROG([UDEVSETTLE], [udevsettle], [], [$LIBVIRT_SBIN_PATH])
AC_PATH_PROG([MODPROBE], [modprobe], [modprobe], [$LIBVIRT_SBIN_PATH])
AC_PATH_PROG([RMMOD], [rmmod], [rmmod], [$LIBVIRT_SBIN_PATH])
AC_PATH_PROG([MMCTL], [mm-ctl], [mm-ctl], [$LIBVIRT_SBIN_PATH])
@@ -71,10 +70,6 @@ AC_DEFUN([LIBVIRT_CHECK_EXTERNAL_PROGRAMS], [
AC_DEFINE_UNQUOTED([UDEVADM], ["$UDEVADM"],
[Location or name of the udevadm program])
fi
- if test -n "$UDEVSETTLE"; then
- AC_DEFINE_UNQUOTED([UDEVSETTLE], ["$UDEVSETTLE"],
- [Location or name of the udevsettle program])
- fi
if test -n "$MODPROBE"; then
AC_DEFINE_UNQUOTED([MODPROBE], ["$MODPROBE"],
[Location or name of the modprobe program])
diff --git a/src/util/virutil.c b/src/util/virutil.c
index d37c1ac632..68d3217248 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -1621,14 +1621,10 @@ virSetUIDGIDWithCaps(uid_t uid, gid_t gid, gid_t *groups, int ngroups,
#endif
-#if defined(UDEVADM) || defined(UDEVSETTLE)
+#if defined(UDEVADM)
void virWaitForDevices(void)
{
-# ifdef UDEVADM
const char *const settleprog[] = { UDEVADM, "settle", NULL };
-# else
- const char *const settleprog[] = { UDEVSETTLE, NULL };
-# endif
int exitstatus;
if (access(settleprog[0], X_OK) != 0)
--
2.22.0

View File

@ -0,0 +1,54 @@
From 0fce9e5a4f4e7f12a5eb2fc0cc44f30f26d83157 Mon Sep 17 00:00:00 2001
Message-Id: <0fce9e5a4f4e7f12a5eb2fc0cc44f30f26d83157@dist-git>
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= <berrange@redhat.com>
Date: Wed, 15 May 2019 21:40:57 +0100
Subject: [PATCH] locking: restrict sockets to mode 0600
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The virtlockd daemon's only intended client is the libvirtd daemon. As
such it should never allow clients from other user accounts to connect.
The code already enforces this and drops clients from other UIDs, but
we can get earlier (and thus stronger) protection against DoS by setting
the socket permissions to 0600
Fixes CVE-2019-10132
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
(cherry picked from commit f111e09468693909b1f067aa575efdafd9a262a1)
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <20190515204058.28077-3-berrange@redhat.com>
---
src/locking/virtlockd-admin.socket.in | 1 +
src/locking/virtlockd.socket.in | 1 +
2 files changed, 2 insertions(+)
diff --git a/src/locking/virtlockd-admin.socket.in b/src/locking/virtlockd-admin.socket.in
index 2a7500f3d0..f674c492f7 100644
--- a/src/locking/virtlockd-admin.socket.in
+++ b/src/locking/virtlockd-admin.socket.in
@@ -5,6 +5,7 @@ Before=libvirtd.service
[Socket]
ListenStream=@localstatedir@/run/libvirt/virtlockd-admin-sock
Service=virtlockd.service
+SocketMode=0600
[Install]
WantedBy=sockets.target
diff --git a/src/locking/virtlockd.socket.in b/src/locking/virtlockd.socket.in
index 45e0f20235..d701b27516 100644
--- a/src/locking/virtlockd.socket.in
+++ b/src/locking/virtlockd.socket.in
@@ -4,6 +4,7 @@ Before=libvirtd.service
[Socket]
ListenStream=@localstatedir@/run/libvirt/virtlockd-sock
+SocketMode=0600
[Install]
WantedBy=sockets.target
--
2.22.0

View File

@ -0,0 +1,54 @@
From 3988a7d012fc93eaae82961f72f7c53f26763651 Mon Sep 17 00:00:00 2001
Message-Id: <3988a7d012fc93eaae82961f72f7c53f26763651@dist-git>
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= <berrange@redhat.com>
Date: Wed, 15 May 2019 21:40:58 +0100
Subject: [PATCH] logging: restrict sockets to mode 0600
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The virtlogd daemon's only intended client is the libvirtd daemon. As
such it should never allow clients from other user accounts to connect.
The code already enforces this and drops clients from other UIDs, but
we can get earlier (and thus stronger) protection against DoS by setting
the socket permissions to 0600
Fixes CVE-2019-10132
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
(cherry picked from commit e37bd65f9948c1185456b2cdaa3bd6e875af680f)
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <20190515204058.28077-4-berrange@redhat.com>
---
src/logging/virtlogd-admin.socket.in | 1 +
src/logging/virtlogd.socket.in | 1 +
2 files changed, 2 insertions(+)
diff --git a/src/logging/virtlogd-admin.socket.in b/src/logging/virtlogd-admin.socket.in
index 595e6c4c4b..5c41dfeb7b 100644
--- a/src/logging/virtlogd-admin.socket.in
+++ b/src/logging/virtlogd-admin.socket.in
@@ -5,6 +5,7 @@ Before=libvirtd.service
[Socket]
ListenStream=@localstatedir@/run/libvirt/virtlogd-admin-sock
Service=virtlogd.service
+SocketMode=0600
[Install]
WantedBy=sockets.target
diff --git a/src/logging/virtlogd.socket.in b/src/logging/virtlogd.socket.in
index 22b9360c8d..ae48cdab9a 100644
--- a/src/logging/virtlogd.socket.in
+++ b/src/logging/virtlogd.socket.in
@@ -4,6 +4,7 @@ Before=libvirtd.service
[Socket]
ListenStream=@localstatedir@/run/libvirt/virtlogd-sock
+SocketMode=0600
[Install]
WantedBy=sockets.target
--
2.22.0

View File

@ -0,0 +1,100 @@
From fef35da9603a70a60d29420b9cff0db4fc2f0f82 Mon Sep 17 00:00:00 2001
Message-Id: <fef35da9603a70a60d29420b9cff0db4fc2f0f82@dist-git>
From: Pavel Hrdina <phrdina@redhat.com>
Date: Mon, 1 Jul 2019 17:06:02 +0200
Subject: [PATCH] lxc: Use virCgroupGetMemoryStat
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
(cherry picked from commit e634c7cd0d3265506198e1f58f1af1fd774f06b1)
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1689297
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Message-Id: <28c2e0f232ee1c3bce10654df15aa212d5f09996.1561993099.git.phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/lxc/lxc_cgroup.c | 65 +++++---------------------------------------
1 file changed, 7 insertions(+), 58 deletions(-)
diff --git a/src/lxc/lxc_cgroup.c b/src/lxc/lxc_cgroup.c
index 8e937ec389..d93a19d684 100644
--- a/src/lxc/lxc_cgroup.c
+++ b/src/lxc/lxc_cgroup.c
@@ -220,64 +220,13 @@ static int virLXCCgroupGetMemTotal(virCgroupPtr cgroup,
static int virLXCCgroupGetMemStat(virCgroupPtr cgroup,
virLXCMeminfoPtr meminfo)
{
- int ret = 0;
- FILE *statfd = NULL;
- char *statFile = NULL;
- char *line = NULL;
- size_t n;
-
- ret = virCgroupPathOfController(cgroup, VIR_CGROUP_CONTROLLER_MEMORY,
- "memory.stat", &statFile);
- if (ret != 0) {
- virReportSystemError(-ret, "%s",
- _("cannot get the path of MEMORY cgroup controller"));
- return ret;
- }
-
- statfd = fopen(statFile, "r");
- if (statfd == NULL) {
- ret = -errno;
- goto cleanup;
- }
-
- while (getline(&line, &n, statfd) > 0) {
-
- char *value = strchr(line, ' ');
- char *nl = value ? strchr(line, '\n') : NULL;
- unsigned long long stat_value;
-
- if (!value)
- continue;
-
- if (nl)
- *nl = '\0';
-
- *value = '\0';
-
- if (virStrToLong_ull(value + 1, NULL, 10, &stat_value) < 0) {
- ret = -EINVAL;
- goto cleanup;
- }
- if (STREQ(line, "cache"))
- meminfo->cached = stat_value >> 10;
- else if (STREQ(line, "inactive_anon"))
- meminfo->inactive_anon = stat_value >> 10;
- else if (STREQ(line, "active_anon"))
- meminfo->active_anon = stat_value >> 10;
- else if (STREQ(line, "inactive_file"))
- meminfo->inactive_file = stat_value >> 10;
- else if (STREQ(line, "active_file"))
- meminfo->active_file = stat_value >> 10;
- else if (STREQ(line, "unevictable"))
- meminfo->unevictable = stat_value >> 10;
- }
- ret = 0;
-
- cleanup:
- VIR_FREE(line);
- VIR_FREE(statFile);
- VIR_FORCE_FCLOSE(statfd);
- return ret;
+ return virCgroupGetMemoryStat(cgroup,
+ &meminfo->cached,
+ &meminfo->inactive_anon,
+ &meminfo->active_anon,
+ &meminfo->inactive_file,
+ &meminfo->active_file,
+ &meminfo->unevictable);
}
--
2.22.0

View File

@ -0,0 +1,51 @@
From 899e80657b58f8ef4c0faf452859fd9649d33b79 Mon Sep 17 00:00:00 2001
Message-Id: <899e80657b58f8ef4c0faf452859fd9649d33b79@dist-git>
From: Michal Privoznik <mprivozn@redhat.com>
Date: Thu, 27 Jun 2019 15:55:39 +0200
Subject: [PATCH] m4: Drop needless string checks
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
We provide default values for both MODPROBE and RMMOD and thus
there is no way that their paths can be empty strings.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 3c8d5762a9fcf3f7d23a41d0b49def0387ecddf7)
https://bugzilla.redhat.com/show_bug.cgi?id=1710575
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Message-Id: <cb42f6a7b7462140e463a33a7b421ed441617266.1561643698.git.mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
m4/virt-external-programs.m4 | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/m4/virt-external-programs.m4 b/m4/virt-external-programs.m4
index f1ae104b32..0f995998c3 100644
--- a/m4/virt-external-programs.m4
+++ b/m4/virt-external-programs.m4
@@ -67,14 +67,10 @@ AC_DEFUN([LIBVIRT_CHECK_EXTERNAL_PROGRAMS], [
[Location or name of the ovs-vsctl program])
AC_DEFINE_UNQUOTED([UDEVADM], ["$UDEVADM"],
[Location or name of the udevadm program])
- if test -n "$MODPROBE"; then
- AC_DEFINE_UNQUOTED([MODPROBE], ["$MODPROBE"],
- [Location or name of the modprobe program])
- fi
- if test -n "$RMMOD"; then
- AC_DEFINE_UNQUOTED([RMMOD], ["$RMMOD"],
- [Location or name of the rmmod program])
- fi
+ AC_DEFINE_UNQUOTED([MODPROBE], ["$MODPROBE"],
+ [Location or name of the modprobe program])
+ AC_DEFINE_UNQUOTED([RMMOD], ["$RMMOD"],
+ [Location or name of the rmmod program])
AC_DEFINE_UNQUOTED([SCRUB], ["$SCRUB"],
[Location or name of the scrub program (for wiping algorithms)])
AC_DEFINE_UNQUOTED([ADDR2LINE], ["$ADDR2LINE"],
--
2.22.0

View File

@ -0,0 +1,100 @@
From 1113a43a48b3c15f908a396ec88e9499df10f7b4 Mon Sep 17 00:00:00 2001
Message-Id: <1113a43a48b3c15f908a396ec88e9499df10f7b4@dist-git>
From: Michal Privoznik <mprivozn@redhat.com>
Date: Thu, 27 Jun 2019 15:55:38 +0200
Subject: [PATCH] m4: Provide default value fore UDEVADM
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
It may happen that the system where libvirt is built at doesn't
have udevadm binary but the one where it runs does have it.
If we change how udevadm is run in virWaitForDevices() then we
can safely pass a default value in m4 macro.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 523b799d3c356b9b4ea0b117a60cfc3b603eaffa)
https://bugzilla.redhat.com/show_bug.cgi?id=1710575
Difference to the upstream commit is that I had to drop
VIR_AUTOPTR() of virCommand because that does not exist in the
downstream yet.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Message-Id: <3d2deafb1bf06eddd721fceb15961b27c8dbf0cf.1561643698.git.mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
m4/virt-external-programs.m4 | 9 +++------
src/util/virutil.c | 16 ++++++++--------
2 files changed, 11 insertions(+), 14 deletions(-)
diff --git a/m4/virt-external-programs.m4 b/m4/virt-external-programs.m4
index 3c915e1a65..f1ae104b32 100644
--- a/m4/virt-external-programs.m4
+++ b/m4/virt-external-programs.m4
@@ -45,7 +45,7 @@ AC_DEFUN([LIBVIRT_CHECK_EXTERNAL_PROGRAMS], [
AC_PATH_PROG([DNSMASQ], [dnsmasq], [dnsmasq], [$LIBVIRT_SBIN_PATH])
AC_PATH_PROG([RADVD], [radvd], [radvd], [$LIBVIRT_SBIN_PATH])
AC_PATH_PROG([TC], [tc], [tc], [$LIBVIRT_SBIN_PATH])
- AC_PATH_PROG([UDEVADM], [udevadm], [], [$LIBVIRT_SBIN_PATH])
+ AC_PATH_PROG([UDEVADM], [udevadm], [udevadm], [$LIBVIRT_SBIN_PATH])
AC_PATH_PROG([MODPROBE], [modprobe], [modprobe], [$LIBVIRT_SBIN_PATH])
AC_PATH_PROG([RMMOD], [rmmod], [rmmod], [$LIBVIRT_SBIN_PATH])
AC_PATH_PROG([MMCTL], [mm-ctl], [mm-ctl], [$LIBVIRT_SBIN_PATH])
@@ -65,11 +65,8 @@ AC_DEFUN([LIBVIRT_CHECK_EXTERNAL_PROGRAMS], [
[Location or name of the mm-ctl program])
AC_DEFINE_UNQUOTED([OVSVSCTL], ["$OVSVSCTL"],
[Location or name of the ovs-vsctl program])
-
- if test -n "$UDEVADM"; then
- AC_DEFINE_UNQUOTED([UDEVADM], ["$UDEVADM"],
- [Location or name of the udevadm program])
- fi
+ AC_DEFINE_UNQUOTED([UDEVADM], ["$UDEVADM"],
+ [Location or name of the udevadm program])
if test -n "$MODPROBE"; then
AC_DEFINE_UNQUOTED([MODPROBE], ["$MODPROBE"],
[Location or name of the modprobe program])
diff --git a/src/util/virutil.c b/src/util/virutil.c
index 68d3217248..cd67f54bc2 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -1621,25 +1621,25 @@ virSetUIDGIDWithCaps(uid_t uid, gid_t gid, gid_t *groups, int ngroups,
#endif
-#if defined(UDEVADM)
void virWaitForDevices(void)
{
- const char *const settleprog[] = { UDEVADM, "settle", NULL };
+ virCommandPtr cmd = NULL;
+ VIR_AUTOFREE(char *) udev = NULL;
int exitstatus;
- if (access(settleprog[0], X_OK) != 0)
+ if (!(udev = virFindFileInPath(UDEVADM)))
+ return;
+
+ if (!(cmd = virCommandNewArgList(udev, "settle", NULL)))
return;
/*
* NOTE: we ignore errors here; this is just to make sure that any device
* nodes that are being created finish before we try to scan them.
*/
- ignore_value(virRun(settleprog, &exitstatus));
+ ignore_value(virCommandRun(cmd, &exitstatus));
+ virCommandFree(cmd);
}
-#else
-void virWaitForDevices(void)
-{}
-#endif
#if WITH_DEVMAPPER
bool
--
2.22.0

View File

@ -0,0 +1,164 @@
From a8234641ad57553aa054bded71ed97c94f3100f1 Mon Sep 17 00:00:00 2001
Message-Id: <a8234641ad57553aa054bded71ed97c94f3100f1@dist-git>
From: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Date: Wed, 5 Jun 2019 14:51:10 +0200
Subject: [PATCH] nwfilter: fix adding std MAC and IP values to filter binding
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Commit d1a7c08eb changed filter instantiation code to ignore MAC and IP
variables explicitly specified for filter binding. It just replaces
explicit values with values associated with the binding. Before the
commit virNWFilterCreateVarsFrom was used so that explicit value
take precedence. Let's bring old behavior back.
This is useful. For example if domain has two interfaces it makes
sense to list both mac adresses in MAC var of every interface
filterref. So that if guest make a bond of these interfaces
and start sending frames with one of the mac adresses from
both interfaces we can pass outgress traffic from both
interfaces too.
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
(cherry picked from commit 01e11ebcb6e8f24662b7c67b70134c192785691c)
https://bugzilla.redhat.com/show_bug.cgi?id=1691356
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Acked-by: Daniel P. Berrangé <berrange@redhat.com>
---
src/nwfilter/nwfilter_gentech_driver.c | 92 +++++++++-----------------
1 file changed, 32 insertions(+), 60 deletions(-)
diff --git a/src/nwfilter/nwfilter_gentech_driver.c b/src/nwfilter/nwfilter_gentech_driver.c
index e5dea91f83..ece5d28f41 100644
--- a/src/nwfilter/nwfilter_gentech_driver.c
+++ b/src/nwfilter/nwfilter_gentech_driver.c
@@ -128,60 +128,6 @@ virNWFilterRuleInstFree(virNWFilterRuleInstPtr inst)
}
-/**
- * virNWFilterVarHashmapAddStdValues:
- * @tables: pointer to hash tabel to add values to
- * @macaddr: The string of the MAC address to add to the hash table,
- * may be NULL
- * @ipaddr: The string of the IP address to add to the hash table;
- * may be NULL
- *
- * Returns 0 in case of success, -1 in case an error happened with
- * error having been reported.
- *
- * Adds a couple of standard keys (MAC, IP) to the hash table.
- */
-static int
-virNWFilterVarHashmapAddStdValues(virHashTablePtr table,
- const char *macaddr,
- const virNWFilterVarValue *ipaddr)
-{
- virNWFilterVarValue *val;
-
- if (macaddr) {
- val = virNWFilterVarValueCreateSimpleCopyValue(macaddr);
- if (!val)
- return -1;
-
- if (virHashUpdateEntry(table,
- NWFILTER_STD_VAR_MAC,
- val) < 0) {
- virNWFilterVarValueFree(val);
- virReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("Could not add variable 'MAC' to hashmap"));
- return -1;
- }
- }
-
- if (ipaddr) {
- val = virNWFilterVarValueCopy(ipaddr);
- if (!val)
- return -1;
-
- if (virHashUpdateEntry(table,
- NWFILTER_STD_VAR_IP,
- val) < 0) {
- virNWFilterVarValueFree(val);
- virReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("Could not add variable 'IP' to hashmap"));
- return -1;
- }
- }
-
- return 0;
-}
-
-
/**
* Convert a virHashTable into a string of comma-separated
* variable names.
@@ -707,6 +653,28 @@ virNWFilterDoInstantiate(virNWFilterTechDriverPtr techdriver,
}
+static int
+virNWFilterVarHashmapAddStdValue(virHashTablePtr table,
+ const char *var,
+ const char *value)
+{
+ virNWFilterVarValue *val;
+
+ if (virHashLookup(table, var))
+ return 0;
+
+ if (!(val = virNWFilterVarValueCreateSimpleCopyValue(value)))
+ return -1;
+
+ if (virHashAddEntry(table, var, val) < 0) {
+ virNWFilterVarValueFree(val);
+ return -1;
+ }
+
+ return 0;
+}
+
+
/*
* Call this function while holding the NWFilter filter update lock
*/
@@ -719,7 +687,7 @@ virNWFilterInstantiateFilterUpdate(virNWFilterDriverStatePtr driver,
bool forceWithPendingReq,
bool *foundNewFilter)
{
- int rc;
+ int rc = -1;
const char *drvname = EBIPTABLES_DRIVER_ID;
virNWFilterTechDriverPtr techdriver;
virNWFilterObjPtr obj;
@@ -745,14 +713,18 @@ virNWFilterInstantiateFilterUpdate(virNWFilterDriverStatePtr driver,
return -1;
virMacAddrFormat(&binding->mac, vmmacaddr);
+ if (virNWFilterVarHashmapAddStdValue(binding->filterparams,
+ NWFILTER_STD_VAR_MAC,
+ vmmacaddr) < 0)
+ goto err_exit;
ipaddr = virNWFilterIPAddrMapGetIPAddr(binding->portdevname);
-
- if (virNWFilterVarHashmapAddStdValues(binding->filterparams,
- vmmacaddr, ipaddr) < 0) {
- rc = -1;
+ if (ipaddr &&
+ virNWFilterVarHashmapAddStdValue(binding->filterparams,
+ NWFILTER_STD_VAR_IP,
+ virNWFilterVarValueGetSimple(ipaddr)) < 0)
goto err_exit;
- }
+
filter = virNWFilterObjGetDef(obj);
--
2.22.0

View File

@ -0,0 +1,124 @@
From cb2374042f3e998b90e6ea025dadfae9333b49cd Mon Sep 17 00:00:00 2001
Message-Id: <cb2374042f3e998b90e6ea025dadfae9333b49cd@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:25:51 +0200
Subject: [PATCH] qemu: Add APIs for translating CPU features
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
So far we always used libvirt's name of each CPU feature relying on
backward compatible aliases in QEMU. The new translation table can be
used whenever QEMU mandates or prefers canonical feature names.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 61ee757e2002507d711c195628619b9eff38b57a)
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <5b080656d143733a77780affc6dd0d322216d6e7.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/qemu/qemu_capabilities.c | 64 ++++++++++++++++++++++++++++++++++++
src/qemu/qemu_capabilities.h | 8 +++++
2 files changed, 72 insertions(+)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 851cb73cfc..d2a2f7418a 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -2755,6 +2755,70 @@ virQEMUCapsCPUFilterFeatures(const char *name,
}
+typedef struct _virQEMUCapsCPUFeatureTranslationTable virQEMUCapsCPUFeatureTranslationTable;
+typedef virQEMUCapsCPUFeatureTranslationTable *virQEMUCapsCPUFeatureTranslationTablePtr;
+struct _virQEMUCapsCPUFeatureTranslationTable {
+ const char *libvirt;
+ const char *qemu;
+};
+
+virQEMUCapsCPUFeatureTranslationTable virQEMUCapsCPUFeaturesX86[] = {
+ {"cmp_legacy", "cmp-legacy"},
+ {"ds_cpl", "ds-cpl"},
+ {"fxsr_opt", "fxsr-opt"},
+ {"kvm_pv_eoi", "kvm-pv-eoi"},
+ {"kvm_pv_unhalt", "kvm-pv-unhalt"},
+ {"lahf_lm", "lahf-lm"},
+ {"nodeid_msr", "nodeid-msr"},
+ {"pclmuldq", "pclmulqdq"},
+ {"perfctr_core", "perfctr-core"},
+ {"perfctr_nb", "perfctr-nb"},
+ {"tsc_adjust", "tsc-adjust"},
+ {NULL, NULL}
+};
+
+
+static const char *
+virQEMUCapsCPUFeatureTranslate(virQEMUCapsPtr qemuCaps,
+ const char *feature,
+ bool reversed)
+{
+ virQEMUCapsCPUFeatureTranslationTablePtr table = NULL;
+ virQEMUCapsCPUFeatureTranslationTablePtr entry;
+
+ if (ARCH_IS_X86(qemuCaps->arch))
+ table = virQEMUCapsCPUFeaturesX86;
+
+ if (!table || !feature)
+ return feature;
+
+ for (entry = table; entry->libvirt; entry++) {
+ const char *key = reversed ? entry->qemu : entry->libvirt;
+
+ if (STREQ(feature, key))
+ return reversed ? entry->libvirt : entry->qemu;
+ }
+
+ return feature;
+}
+
+
+const char *
+virQEMUCapsCPUFeatureToQEMU(virQEMUCapsPtr qemuCaps,
+ const char *feature)
+{
+ return virQEMUCapsCPUFeatureTranslate(qemuCaps, feature, false);
+}
+
+
+const char *
+virQEMUCapsCPUFeatureFromQEMU(virQEMUCapsPtr qemuCaps,
+ const char *feature)
+{
+ return virQEMUCapsCPUFeatureTranslate(qemuCaps, feature, true);
+}
+
+
/**
* Returns 0 when host CPU model provided by QEMU was filled in qemuCaps,
* 1 when the caller should fall back to using virCapsPtr->host.cpu,
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index bea4767f3c..8a27acd8a4 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -628,6 +628,14 @@ bool virQEMUCapsGuestIsNative(virArch host,
bool virQEMUCapsCPUFilterFeatures(const char *name,
void *opaque);
+const char *
+virQEMUCapsCPUFeatureToQEMU(virQEMUCapsPtr qemuCaps,
+ const char *feature);
+
+const char *
+virQEMUCapsCPUFeatureFromQEMU(virQEMUCapsPtr qemuCaps,
+ const char *feature);
+
virSEVCapabilityPtr
virQEMUCapsGetSEVCapabilities(virQEMUCapsPtr qemuCaps);
--
2.22.0

View File

@ -0,0 +1,316 @@
From 84d44b33a64b6fd7f77d021249d23dc054243ddf Mon Sep 17 00:00:00 2001
Message-Id: <84d44b33a64b6fd7f77d021249d23dc054243ddf@dist-git>
From: Yi Min Zhao <zyimin@linux.ibm.com>
Date: Mon, 8 Apr 2019 10:57:29 +0200
Subject: [PATCH] qemu: Add hotpluging support for PCI devices on S390 guests
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This commit adds hotplug support for PCI devices on S390 guests.
There's no need to implement hot unplug for zPCI as QEMU implements
an unplug callback which will unplug both PCI and zPCI device in a
cascaded way.
Currently, the following PCI devices are supported:
virtio-blk-pci
virtio-net-pci
virtio-rng-pci
virtio-input-host-pci
virtio-keyboard-pci
virtio-mouse-pci
virtio-tablet-pci
vfio-pci
SCSIVhost device
Signed-off-by: Yi Min Zhao <zyimin@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
(cherry picked from commit 1d1e264f13d14ed05838bae2fcec2ffef26671f2)
https://bugzilla.redhat.com/show_bug.cgi?id=1508149
Conflicts:
* src/qemu/qemu_hotplug.c
+ context
- missing 83fe11e950bc
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Message-Id: <20190408085732.28684-13-abologna@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/qemu/qemu_hotplug.c | 160 +++++++++++++++++++++++++++++++++++++---
1 file changed, 151 insertions(+), 9 deletions(-)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 776cd75474..abe2632556 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -154,6 +154,80 @@ qemuHotplugPrepareDiskAccess(virQEMUDriverPtr driver,
}
+static int
+qemuDomainAttachZPCIDevice(qemuMonitorPtr mon,
+ virDomainDeviceInfoPtr info)
+{
+ char *devstr_zpci = NULL;
+ int ret = -1;
+
+ if (!(devstr_zpci = qemuBuildZPCIDevStr(info)))
+ goto cleanup;
+
+ if (qemuMonitorAddDevice(mon, devstr_zpci) < 0)
+ goto cleanup;
+
+ ret = 0;
+
+ cleanup:
+ VIR_FREE(devstr_zpci);
+ return ret;
+}
+
+
+static int
+qemuDomainDetachZPCIDevice(qemuMonitorPtr mon,
+ virDomainDeviceInfoPtr info)
+{
+ char *zpciAlias = NULL;
+ int ret = -1;
+
+ if (virAsprintf(&zpciAlias, "zpci%d", info->addr.pci.zpci.uid) < 0)
+ goto cleanup;
+
+ if (qemuMonitorDelDevice(mon, zpciAlias) < 0)
+ goto cleanup;
+
+ ret = 0;
+
+ cleanup:
+ VIR_FREE(zpciAlias);
+ return ret;
+}
+
+
+static int
+qemuDomainAttachExtensionDevice(qemuMonitorPtr mon,
+ virDomainDeviceInfoPtr info)
+{
+ if (info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI ||
+ info->addr.pci.extFlags == VIR_PCI_ADDRESS_EXTENSION_NONE) {
+ return 0;
+ }
+
+ if (info->addr.pci.extFlags & VIR_PCI_ADDRESS_EXTENSION_ZPCI)
+ return qemuDomainAttachZPCIDevice(mon, info);
+
+ return 0;
+}
+
+
+static int
+qemuDomainDetachExtensionDevice(qemuMonitorPtr mon,
+ virDomainDeviceInfoPtr info)
+{
+ if (info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI ||
+ info->addr.pci.extFlags == VIR_PCI_ADDRESS_EXTENSION_NONE) {
+ return 0;
+ }
+
+ if (info->addr.pci.extFlags & VIR_PCI_ADDRESS_EXTENSION_ZPCI)
+ return qemuDomainDetachZPCIDevice(mon, info);
+
+ return 0;
+}
+
+
static int
qemuHotplugWaitForTrayEject(virQEMUDriverPtr driver,
virDomainObjPtr vm,
@@ -403,9 +477,14 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver,
if (qemuBlockStorageSourceAttachApply(priv->mon, data) < 0)
goto exit_monitor;
- if (qemuMonitorAddDevice(priv->mon, devstr) < 0)
+ if (qemuDomainAttachExtensionDevice(priv->mon, &disk->info) < 0)
goto exit_monitor;
+ if (qemuMonitorAddDevice(priv->mon, devstr) < 0) {
+ ignore_value(qemuDomainDetachExtensionDevice(priv->mon, &disk->info));
+ goto exit_monitor;
+ }
+
if (qemuDomainObjExitMonitor(driver, vm) < 0) {
ret = -2;
goto error;
@@ -519,7 +598,16 @@ int qemuDomainAttachControllerDevice(virQEMUDriverPtr driver,
goto cleanup;
qemuDomainObjEnterMonitor(driver, vm);
- ret = qemuMonitorAddDevice(priv->mon, devstr);
+
+ if ((ret = qemuDomainAttachExtensionDevice(priv->mon,
+ &controller->info)) < 0) {
+ goto exit_monitor;
+ }
+
+ if ((ret = qemuMonitorAddDevice(priv->mon, devstr)) < 0)
+ ignore_value(qemuDomainDetachExtensionDevice(priv->mon, &controller->info));
+
+ exit_monitor:
if (qemuDomainObjExitMonitor(driver, vm) < 0) {
releaseaddr = false;
ret = -1;
@@ -969,6 +1057,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
}
if (qemuDomainIsS390CCW(vm->def) &&
+ net->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI &&
virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_CCW)) {
net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW;
if (!(ccwaddrs = qemuDomainCCWAddrSetCreateFromDomain(vm->def)))
@@ -1038,7 +1127,15 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
goto try_remove;
qemuDomainObjEnterMonitor(driver, vm);
+
+ if (qemuDomainAttachExtensionDevice(priv->mon, &net->info) < 0) {
+ ignore_value(qemuDomainObjExitMonitor(driver, vm));
+ virDomainAuditNet(vm, NULL, net, "attach", false);
+ goto try_remove;
+ }
+
if (qemuMonitorAddDevice(priv->mon, nicstr) < 0) {
+ ignore_value(qemuDomainDetachExtensionDevice(priv->mon, &net->info));
ignore_value(qemuDomainObjExitMonitor(driver, vm));
virDomainAuditNet(vm, NULL, net, "attach", false);
goto try_remove;
@@ -1256,8 +1353,16 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver,
goto error;
qemuDomainObjEnterMonitor(driver, vm);
- ret = qemuMonitorAddDeviceWithFd(priv->mon, devstr,
- configfd, configfd_name);
+
+ if ((ret = qemuDomainAttachExtensionDevice(priv->mon, hostdev->info)) < 0)
+ goto exit_monitor;
+
+ if ((ret = qemuMonitorAddDeviceWithFd(priv->mon, devstr,
+ configfd, configfd_name)) < 0) {
+ ignore_value(qemuDomainDetachExtensionDevice(priv->mon, hostdev->info));
+ }
+
+ exit_monitor:
if (qemuDomainObjExitMonitor(driver, vm) < 0)
goto error;
@@ -1913,9 +2018,14 @@ qemuDomainAttachRNGDevice(virQEMUDriverPtr driver,
if (qemuMonitorAddObject(priv->mon, &props, &objAlias) < 0)
goto exit_monitor;
- if (qemuMonitorAddDevice(priv->mon, devstr) < 0)
+ if (qemuDomainAttachExtensionDevice(priv->mon, &rng->info) < 0)
goto exit_monitor;
+ if (qemuMonitorAddDevice(priv->mon, devstr) < 0) {
+ ignore_value(qemuDomainDetachExtensionDevice(priv->mon, &rng->info));
+ goto exit_monitor;
+ }
+
if (qemuDomainObjExitMonitor(driver, vm) < 0) {
releaseaddr = false;
goto cleanup;
@@ -2407,8 +2517,16 @@ qemuDomainAttachSCSIVHostDevice(virQEMUDriverPtr driver,
qemuDomainObjEnterMonitor(driver, vm);
- ret = qemuMonitorAddDeviceWithFd(priv->mon, devstr, vhostfd, vhostfdName);
+ if ((ret = qemuDomainAttachExtensionDevice(priv->mon, hostdev->info)) < 0)
+ goto exit_monitor;
+ if ((ret = qemuMonitorAddDeviceWithFd(priv->mon, devstr, vhostfd,
+ vhostfdName)) < 0) {
+ ignore_value(qemuDomainDetachExtensionDevice(priv->mon, hostdev->info));
+ goto exit_monitor;
+ }
+
+ exit_monitor:
if (qemuDomainObjExitMonitor(driver, vm) < 0 || ret < 0)
goto audit;
@@ -2653,9 +2771,14 @@ qemuDomainAttachShmemDevice(virQEMUDriverPtr driver,
release_backing = true;
- if (qemuMonitorAddDevice(priv->mon, shmstr) < 0)
+ if (qemuDomainAttachExtensionDevice(priv->mon, &shmem->info) < 0)
goto exit_monitor;
+ if (qemuMonitorAddDevice(priv->mon, shmstr) < 0) {
+ ignore_value(qemuDomainDetachExtensionDevice(priv->mon, &shmem->info));
+ goto exit_monitor;
+ }
+
if (qemuDomainObjExitMonitor(driver, vm) < 0) {
release_address = false;
goto cleanup;
@@ -2827,9 +2950,15 @@ qemuDomainAttachInputDevice(virQEMUDriverPtr driver,
goto cleanup;
qemuDomainObjEnterMonitor(driver, vm);
- if (qemuMonitorAddDevice(priv->mon, devstr) < 0)
+
+ if (qemuDomainAttachExtensionDevice(priv->mon, &input->info) < 0)
goto exit_monitor;
+ if (qemuMonitorAddDevice(priv->mon, devstr) < 0) {
+ ignore_value(qemuDomainDetachExtensionDevice(priv->mon, &input->info));
+ goto exit_monitor;
+ }
+
if (qemuDomainObjExitMonitor(driver, vm) < 0) {
releaseaddr = false;
goto cleanup;
@@ -2906,9 +3035,15 @@ qemuDomainAttachVsockDevice(virQEMUDriverPtr driver,
goto cleanup;
qemuDomainObjEnterMonitor(driver, vm);
- if (qemuMonitorAddDeviceWithFd(priv->mon, devstr, vsockPriv->vhostfd, fdname) < 0)
+
+ if (qemuDomainAttachExtensionDevice(priv->mon, &vsock->info) < 0)
goto exit_monitor;
+ if (qemuMonitorAddDeviceWithFd(priv->mon, devstr, vsockPriv->vhostfd, fdname) < 0) {
+ ignore_value(qemuDomainDetachExtensionDevice(priv->mon, &vsock->info));
+ goto exit_monitor;
+ }
+
if (qemuDomainObjExitMonitor(driver, vm) < 0) {
releaseaddr = false;
goto cleanup;
@@ -4932,10 +5067,17 @@ int qemuDomainDetachControllerDevice(virQEMUDriverPtr driver,
qemuDomainMarkDeviceForRemoval(vm, &detach->info);
qemuDomainObjEnterMonitor(driver, vm);
+ if (detach->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI &&
+ qemuDomainDetachExtensionDevice(priv->mon, &detach->info)) {
+ goto exit_monitor;
+ }
+
if (qemuMonitorDelDevice(priv->mon, detach->info.alias)) {
ignore_value(qemuDomainObjExitMonitor(driver, vm));
goto cleanup;
}
+
+ exit_monitor:
if (qemuDomainObjExitMonitor(driver, vm) < 0)
goto cleanup;
--
2.22.0

View File

@ -0,0 +1,89 @@
From 3004a0c300e65777cf888a49eddcfdda8cd59941 Mon Sep 17 00:00:00 2001
Message-Id: <3004a0c300e65777cf888a49eddcfdda8cd59941@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:26:00 +0200
Subject: [PATCH] qemu: Add type filter to qemuMonitorJSONParsePropsList
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The function converts a list of QOM properties into a NULL-terminated
array of property names. The new type parameter may be used to limit the
result to properties of a specific type.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 430023e5ee3f7549104f5eb09e3c26563a11882c)
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <aaae4013352ac5c6724550a340921c394a701bcc.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/qemu/qemu_monitor_json.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 8fead72ecf..abf952cd34 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -6067,11 +6067,13 @@ int qemuMonitorJSONSetObjectProperty(qemuMonitorPtr mon,
static int
qemuMonitorJSONParsePropsList(virJSONValuePtr cmd,
virJSONValuePtr reply,
+ const char *type,
char ***props)
{
virJSONValuePtr data;
char **proplist = NULL;
size_t n = 0;
+ size_t count = 0;
size_t i;
int ret = -1;
@@ -6089,17 +6091,21 @@ qemuMonitorJSONParsePropsList(virJSONValuePtr cmd,
virJSONValuePtr child = virJSONValueArrayGet(data, i);
const char *tmp;
+ if (type &&
+ STRNEQ_NULLABLE(virJSONValueObjectGetString(child, "type"), type))
+ continue;
+
if (!(tmp = virJSONValueObjectGetString(child, "name"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("reply data was missing 'name'"));
goto cleanup;
}
- if (VIR_STRDUP(proplist[i], tmp) < 0)
+ if (VIR_STRDUP(proplist[count++], tmp) < 0)
goto cleanup;
}
- ret = n;
+ ret = count;
*props = proplist;
proplist = NULL;
@@ -6132,7 +6138,7 @@ int qemuMonitorJSONGetDeviceProps(qemuMonitorPtr mon,
goto cleanup;
}
- ret = qemuMonitorJSONParsePropsList(cmd, reply, props);
+ ret = qemuMonitorJSONParsePropsList(cmd, reply, NULL, props);
cleanup:
virJSONValueFree(reply);
virJSONValueFree(cmd);
@@ -6164,7 +6170,7 @@ qemuMonitorJSONGetObjectProps(qemuMonitorPtr mon,
goto cleanup;
}
- ret = qemuMonitorJSONParsePropsList(cmd, reply, props);
+ ret = qemuMonitorJSONParsePropsList(cmd, reply, NULL, props);
cleanup:
virJSONValueFree(reply);
virJSONValueFree(cmd);
--
2.22.0

View File

@ -0,0 +1,156 @@
From 9aef6ea4b1d8a79e353bb34ab5559c698cad1eb1 Mon Sep 17 00:00:00 2001
Message-Id: <9aef6ea4b1d8a79e353bb34ab5559c698cad1eb1@dist-git>
From: Yi Min Zhao <zyimin@linux.ibm.com>
Date: Mon, 8 Apr 2019 10:57:26 +0200
Subject: [PATCH] qemu: Add zPCI address definition check
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
We should ensure that QEMU supports zPCI when a zPCI address is defined
in XML and otherwise report an error. This patch introduces a generic
validation function qemuDomainDeviceDefValidateAddress() which calls
qemuDomainDeviceDefValidateZPCIAddress() if address type is PCI address.
Signed-off-by: Yi Min Zhao <zyimin@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
(cherry picked from commit e6565d54db3d52ae38b5934877be4d004c2d5f35)
https://bugzilla.redhat.com/show_bug.cgi?id=1508149
Conflicts:
* src/qemu/qemu_domain.c
+ context
- missing 709f57c25be8
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Message-Id: <20190408085732.28684-10-abologna@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/qemu/qemu_domain.c | 36 +++++++++++++++++++
.../hostdev-vfio-zpci-wrong-arch.xml | 34 ++++++++++++++++++
tests/qemuxml2argvtest.c | 2 ++
3 files changed, 72 insertions(+)
create mode 100644 tests/qemuxml2argvdata/hostdev-vfio-zpci-wrong-arch.xml
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index da961f0de9..8604385aa2 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -5681,6 +5681,38 @@ qemuDomainDeviceDefValidateGraphics(const virDomainGraphicsDef *graphics,
}
+static int
+qemuDomainDeviceDefValidateZPCIAddress(virDomainDeviceInfoPtr info,
+ virQEMUCapsPtr qemuCaps)
+{
+ if (!virZPCIDeviceAddressIsEmpty(&info->addr.pci.zpci) &&
+ !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_ZPCI)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ "%s",
+ _("This QEMU binary doesn't support zPCI"));
+ return -1;
+ }
+
+ return 0;
+}
+
+
+static int
+qemuDomainDeviceDefValidateAddress(const virDomainDeviceDef *dev,
+ virQEMUCapsPtr qemuCaps)
+{
+ virDomainDeviceInfoPtr info;
+
+ if (!(info = virDomainDeviceGetInfo((virDomainDeviceDef *)dev)))
+ return 0;
+
+ if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI)
+ return qemuDomainDeviceDefValidateZPCIAddress(info, qemuCaps);
+
+ return 0;
+}
+
+
static int
qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
const virDomainDef *def,
@@ -5694,6 +5726,9 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
def->emulator)))
return -1;
+ if ((ret = qemuDomainDeviceDefValidateAddress(dev, qemuCaps)) < 0)
+ goto cleanup;
+
switch ((virDomainDeviceType)dev->type) {
case VIR_DOMAIN_DEVICE_NET:
ret = qemuDomainDeviceDefValidateNetwork(dev->data.net);
@@ -5769,6 +5804,7 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
break;
}
+ cleanup:
virObjectUnref(qemuCaps);
return ret;
}
diff --git a/tests/qemuxml2argvdata/hostdev-vfio-zpci-wrong-arch.xml b/tests/qemuxml2argvdata/hostdev-vfio-zpci-wrong-arch.xml
new file mode 100644
index 0000000000..bfb2f83a3b
--- /dev/null
+++ b/tests/qemuxml2argvdata/hostdev-vfio-zpci-wrong-arch.xml
@@ -0,0 +1,34 @@
+<domain type='qemu'>
+ <name>QEMUGuest2</name>
+ <uuid>c7a5fdbd-edaf-9466-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i686</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest2'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <controller type='pci' index='0' model='pci-root'/>
+ <hostdev mode='subsystem' type='pci' managed='yes'>
+ <driver name='vfio'/>
+ <source>
+ <address domain='0x0001' bus='00' slot='00' function='0'/>
+ </source>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'>
+ <zpci uid='0x0019' fid='0x0000001f'/>
+ </address>
+ </hostdev>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 2eb2505971..1066de8bc4 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1632,6 +1632,8 @@ mymain(void)
DO_TEST_PARSE_ERROR("hostdev-mdev-display-missing-graphics",
QEMU_CAPS_DEVICE_VFIO_PCI,
QEMU_CAPS_VFIO_PCI_DISPLAY);
+ DO_TEST_PARSE_ERROR("hostdev-vfio-zpci-wrong-arch",
+ QEMU_CAPS_DEVICE_VFIO_PCI);
DO_TEST("hostdev-vfio-zpci",
QEMU_CAPS_DEVICE_VFIO_PCI,
QEMU_CAPS_DEVICE_ZPCI);
--
2.22.0

Some files were not shown because too many files have changed in this diff Show More