* [Qemu-devel] [PATCH v2 0/2] hw: provide error checking of disable-legacy/modern property usage
@ 2019-02-15 10:32 Daniel P. Berrangé
2019-05-16 12:17 ` [Qemu-devel] [PULL 01/37] " Michael S. Tsirkin
2019-05-16 12:17 ` [Qemu-devel] [PULL 02/37] " Michael S. Tsirkin
0 siblings, 2 replies; 289+ messages in thread
From: Daniel P. Berrangé @ 2019-02-15 10:32 UTC (permalink / raw)
To: qemu-devel
Cc: Michael S. Tsirkin, Gonglei, Marcel Apfelbaum, Eduardo Habkost,
Gerd Hoffmann, Andreas Färber, Daniel P. Berrangé
Changed in v2:
- Fix properties set for v2.6 machine type compat so that it
only affects the virtio devices which support both legacy
and modern modes.
- Revert unneccessary patch allowing optional properties in
machine prop back compat
Daniel P. Berrangé (2):
hw: report invalid disable-legacy|modern usage for virtio-1-only devs
Revert "globals: Allow global properties to be optional"
hw/core/machine.c | 23 ++++++++++++++++++++---
hw/display/virtio-gpu-pci.c | 4 +++-
hw/display/virtio-vga.c | 4 +++-
hw/virtio/virtio-crypto-pci.c | 4 +++-
hw/virtio/virtio-input-pci.c | 4 +++-
hw/virtio/virtio-pci.c | 26 ++++++++++++++++----------
hw/virtio/virtio-pci.h | 31 +++++++++++++++++++++++++------
include/hw/qdev-core.h | 3 ---
qom/object.c | 3 ---
9 files changed, 73 insertions(+), 29 deletions(-)
--
2.20.1
^ permalink raw reply [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v2 1/2] hw: report invalid disable-legacy|modern usage for virtio-1-only devs
@ 2019-05-16 12:17 ` Michael S. Tsirkin
0 siblings, 0 replies; 289+ messages in thread
From: Daniel P. Berrangé @ 2019-02-15 10:32 UTC (permalink / raw)
To: qemu-devel
Cc: Michael S. Tsirkin, Gonglei, Marcel Apfelbaum, Eduardo Habkost,
Gerd Hoffmann, Andreas Färber, Daniel P. Berrangé
A number of virtio devices (gpu, crypto, mouse, keyboard, tablet) only
support the virtio-1 (aka modern) mode. Currently if the user launches
QEMU, setting those devices to enable legacy mode, QEMU will silently
create them in modern mode, ignoring the user's (mistaken) request.
This patch introduces proper data validation so that an attempt to
configure a virtio-1-only devices in legacy mode gets reported as an
error to the user.
Checking this required introduction of a new field to explicitly track
what operating model is to be used for a device, separately from the
disable_modern and disable_legacy fields that record the user's
requested configuration.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
hw/core/machine.c | 23 ++++++++++++++++++++---
hw/display/virtio-gpu-pci.c | 4 +++-
hw/display/virtio-vga.c | 4 +++-
hw/virtio/virtio-crypto-pci.c | 4 +++-
hw/virtio/virtio-input-pci.c | 4 +++-
hw/virtio/virtio-pci.c | 26 ++++++++++++++++----------
hw/virtio/virtio-pci.h | 31 +++++++++++++++++++++++++------
7 files changed, 73 insertions(+), 23 deletions(-)
diff --git a/hw/core/machine.c b/hw/core/machine.c
index 077fbd182a..61fb791e6a 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -96,9 +96,26 @@ const size_t hw_compat_2_7_len = G_N_ELEMENTS(hw_compat_2_7);
GlobalProperty hw_compat_2_6[] = {
{ "virtio-mmio", "format_transport_address", "off" },
- /* Optional because not all virtio-pci devices support legacy mode */
- { "virtio-pci", "disable-modern", "on", .optional = true },
- { "virtio-pci", "disable-legacy", "off", .optional = true },
+ /*
+ * don't include devices which are modern-only
+ * ie keyboard, mouse, tablet, gpu, vga & crypto
+ */
+ { "virtio-9p-pci", "disable-modern", "on" },
+ { "virtio-9p-pci", "disable-legacy", "off" },
+ { "virtio-balloon-pci", "disable-modern", "on" },
+ { "virtio-balloon-pci", "disable-legacy", "off" },
+ { "virtio-blk-pci", "disable-modern", "on" },
+ { "virtio-blk-pci", "disable-legacy", "off" },
+ { "virtio-input-host-pci", "disable-modern", "on" },
+ { "virtio-input-host-pci", "disable-legacy", "off" },
+ { "virtio-net-pci", "disable-modern", "on" },
+ { "virtio-net-pci", "disable-legacy", "off" },
+ { "virtio-rng-pci", "disable-modern", "on" },
+ { "virtio-rng-pci", "disable-legacy", "off" },
+ { "virtio-scsi-pci", "disable-modern", "on" },
+ { "virtio-scsi-pci", "disable-legacy", "off" },
+ { "virtio-serial-pci", "disable-modern", "on" },
+ { "virtio-serial-pci", "disable-legacy", "off" },
};
const size_t hw_compat_2_6_len = G_N_ELEMENTS(hw_compat_2_6);
diff --git a/hw/display/virtio-gpu-pci.c b/hw/display/virtio-gpu-pci.c
index bdcd33c925..0bc4d9d424 100644
--- a/hw/display/virtio-gpu-pci.c
+++ b/hw/display/virtio-gpu-pci.c
@@ -47,7 +47,9 @@ static void virtio_gpu_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
Error *local_error = NULL;
qdev_set_parent_bus(vdev, BUS(&vpci_dev->bus));
- virtio_pci_force_virtio_1(vpci_dev);
+ if (!virtio_pci_force_virtio_1(vpci_dev, errp)) {
+ return;
+ }
object_property_set_bool(OBJECT(vdev), true, "realized", &local_error);
if (local_error) {
diff --git a/hw/display/virtio-vga.c b/hw/display/virtio-vga.c
index 1e48009b74..d63fe8c345 100644
--- a/hw/display/virtio-vga.c
+++ b/hw/display/virtio-vga.c
@@ -145,7 +145,9 @@ static void virtio_vga_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
/* init virtio bits */
qdev_set_parent_bus(DEVICE(g), BUS(&vpci_dev->bus));
- virtio_pci_force_virtio_1(vpci_dev);
+ if (!virtio_pci_force_virtio_1(vpci_dev, errp)) {
+ return;
+ }
object_property_set_bool(OBJECT(g), true, "realized", &err);
if (err) {
error_propagate(errp, err);
diff --git a/hw/virtio/virtio-crypto-pci.c b/hw/virtio/virtio-crypto-pci.c
index 90a6e0dc2e..13807e538b 100644
--- a/hw/virtio/virtio-crypto-pci.c
+++ b/hw/virtio/virtio-crypto-pci.c
@@ -51,7 +51,9 @@ static void virtio_crypto_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
}
qdev_set_parent_bus(vdev, BUS(&vpci_dev->bus));
- virtio_pci_force_virtio_1(vpci_dev);
+ if (!virtio_pci_force_virtio_1(vpci_dev, errp)) {
+ return;
+ }
object_property_set_bool(OBJECT(vdev), true, "realized", errp);
object_property_set_link(OBJECT(vcrypto),
OBJECT(vcrypto->vdev.conf.cryptodev), "cryptodev",
diff --git a/hw/virtio/virtio-input-pci.c b/hw/virtio/virtio-input-pci.c
index 2c1397842b..28477729a3 100644
--- a/hw/virtio/virtio-input-pci.c
+++ b/hw/virtio/virtio-input-pci.c
@@ -48,7 +48,9 @@ static void virtio_input_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
DeviceState *vdev = DEVICE(&vinput->vdev);
qdev_set_parent_bus(vdev, BUS(&vpci_dev->bus));
- virtio_pci_force_virtio_1(vpci_dev);
+ if (!virtio_pci_force_virtio_1(vpci_dev, errp)) {
+ return;
+ }
object_property_set_bool(OBJECT(vdev), true, "realized", errp);
}
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index e978bfe760..ec31ec6cf3 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -1721,16 +1721,22 @@ static void virtio_pci_realize(PCIDevice *pci_dev, Error **errp)
/* PCI BAR regions must be powers of 2 */
pow2ceil(proxy->notify.offset + proxy->notify.size));
- if (proxy->disable_legacy == ON_OFF_AUTO_AUTO) {
- proxy->disable_legacy = pcie_port ? ON_OFF_AUTO_ON : ON_OFF_AUTO_OFF;
- }
-
- if (!virtio_pci_modern(proxy) && !virtio_pci_legacy(proxy)) {
- error_setg(errp, "device cannot work as neither modern nor legacy mode"
- " is enabled");
- error_append_hint(errp, "Set either disable-modern or disable-legacy"
- " to off\n");
- return;
+ if ((proxy->disable_legacy == ON_OFF_AUTO_ON) ||
+ ((proxy->disable_legacy == ON_OFF_AUTO_AUTO) && pcie_port)) {
+ if (proxy->disable_modern) {
+ error_setg(errp, "device cannot work as neither modern nor "
+ "legacy mode is enabled");
+ error_append_hint(errp, "Set either disable-modern or "
+ "disable-legacy to off\n");
+ return;
+ }
+ proxy->mode = VIRTIO_PCI_MODE_MODERN;
+ } else {
+ if (proxy->disable_modern) {
+ proxy->mode = VIRTIO_PCI_MODE_LEGACY;
+ } else {
+ proxy->mode = VIRTIO_PCI_MODE_TRANSITIONAL;
+ }
}
if (pcie_port && pci_is_express(pci_dev)) {
diff --git a/hw/virtio/virtio-pci.h b/hw/virtio/virtio-pci.h
index bd223a6e3b..16ef4c0a3f 100644
--- a/hw/virtio/virtio-pci.h
+++ b/hw/virtio/virtio-pci.h
@@ -15,6 +15,7 @@
#ifndef QEMU_VIRTIO_PCI_H
#define QEMU_VIRTIO_PCI_H
+#include "qapi/error.h"
#include "hw/pci/msi.h"
#include "hw/virtio/virtio-bus.h"
@@ -118,6 +119,12 @@ typedef struct VirtIOPCIQueue {
uint32_t used[2];
} VirtIOPCIQueue;
+typedef enum {
+ VIRTIO_PCI_MODE_LEGACY,
+ VIRTIO_PCI_MODE_TRANSITIONAL,
+ VIRTIO_PCI_MODE_MODERN,
+} VirtIOPCIMode;
+
struct VirtIOPCIProxy {
PCIDevice pci_dev;
MemoryRegion bar;
@@ -142,6 +149,7 @@ struct VirtIOPCIProxy {
bool disable_modern;
bool ignore_backend_features;
OnOffAuto disable_legacy;
+ VirtIOPCIMode mode;
uint32_t class_code;
uint32_t nvectors;
uint32_t dfselect;
@@ -156,23 +164,34 @@ struct VirtIOPCIProxy {
static inline bool virtio_pci_modern(VirtIOPCIProxy *proxy)
{
- return !proxy->disable_modern;
+ return proxy->mode != VIRTIO_PCI_MODE_LEGACY;
}
static inline bool virtio_pci_legacy(VirtIOPCIProxy *proxy)
{
- return proxy->disable_legacy == ON_OFF_AUTO_OFF;
+ return proxy->mode != VIRTIO_PCI_MODE_MODERN;
}
-static inline void virtio_pci_force_virtio_1(VirtIOPCIProxy *proxy)
+static inline bool virtio_pci_force_virtio_1(VirtIOPCIProxy *proxy,
+ Error **errp)
{
- proxy->disable_modern = false;
- proxy->disable_legacy = ON_OFF_AUTO_ON;
+ if (proxy->disable_legacy == ON_OFF_AUTO_OFF) {
+ error_setg(errp, "Unable to set disable-legacy=off on a virtio-1.0 "
+ "only device");
+ return false;
+ }
+ if (proxy->disable_modern == true) {
+ error_setg(errp, "Unable to set disable-modern=on on a virtio-1.0 "
+ "only device");
+ return false;
+ }
+ proxy->mode = VIRTIO_PCI_MODE_MODERN;
+ return true;
}
static inline void virtio_pci_disable_modern(VirtIOPCIProxy *proxy)
{
- proxy->disable_modern = true;
+ proxy->mode = VIRTIO_PCI_MODE_LEGACY;
}
/*
--
2.20.1
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v2 2/2] Revert "globals: Allow global properties to be optional"
@ 2019-05-16 12:17 ` Michael S. Tsirkin
0 siblings, 0 replies; 289+ messages in thread
From: Daniel P. Berrangé @ 2019-02-15 10:32 UTC (permalink / raw)
To: qemu-devel
Cc: Michael S. Tsirkin, Gonglei, Marcel Apfelbaum, Eduardo Habkost,
Gerd Hoffmann, Andreas Färber, Daniel P. Berrangé
This reverts commit d7741743f4f3d2683d1bb6938f88dc0167c21afa.
Relying on setting properties on parents types which may not
be relevant to certain sub-classes had unexpected side-effects
causing bugs in device config defaults. It is preferrable to
be explicit about which devices get which properties, even if
this needs repetition.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
include/hw/qdev-core.h | 3 ---
qom/object.c | 3 ---
2 files changed, 6 deletions(-)
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index 0a84c42756..9614f76ae6 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -250,8 +250,6 @@ struct PropertyInfo {
/**
* GlobalProperty:
* @used: Set to true if property was used when initializing a device.
- * @optional: If set to true, GlobalProperty will be skipped without errors
- * if the property doesn't exist.
*
* An error is fatal for non-hotplugged devices, when the global is applied.
*/
@@ -260,7 +258,6 @@ typedef struct GlobalProperty {
const char *property;
const char *value;
bool used;
- bool optional;
} GlobalProperty;
static inline void
diff --git a/qom/object.c b/qom/object.c
index b8c732063b..4e5226ca12 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -385,9 +385,6 @@ void object_apply_global_props(Object *obj, const GPtrArray *props, Error **errp
if (object_dynamic_cast(obj, p->driver) == NULL) {
continue;
}
- if (p->optional && !object_property_find(obj, p->property, NULL)) {
- continue;
- }
p->used = true;
object_property_parse(obj, p->value, p->property, &err);
if (err != NULL) {
--
2.20.1
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH 0/3] acpi: More trace points
@ 2019-04-02 16:18 Markus Armbruster
2019-05-16 12:19 ` [Qemu-devel] [PULL 11/37] " Michael S. Tsirkin
` (4 more replies)
0 siblings, 5 replies; 289+ messages in thread
From: Markus Armbruster @ 2019-04-02 16:18 UTC (permalink / raw)
To: qemu-devel; +Cc: mst, imammedo, marcel.apfelbaum
I wrote these patches to help me debug an unplug failure. I expect
them to be helpful for others, too.
Markus Armbruster (3):
acpi/piix4: Convert debug printf()s to trace events
acpi/pcihp: Convert debug printf()s to trace events
acpi/pcihp: Add a few more trace points related to unplug
hw/acpi/pcihp.c | 32 +++++++++++++++-----------------
hw/acpi/piix4.c | 14 +++-----------
hw/acpi/trace-events | 16 ++++++++++++++++
3 files changed, 34 insertions(+), 28 deletions(-)
--
2.17.2
^ permalink raw reply [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH 1/3] acpi/piix4: Convert debug printf()s to trace events
@ 2019-05-16 12:19 ` Michael S. Tsirkin
0 siblings, 0 replies; 289+ messages in thread
From: Markus Armbruster @ 2019-04-02 16:18 UTC (permalink / raw)
To: qemu-devel; +Cc: mst, imammedo, marcel.apfelbaum
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
hw/acpi/piix4.c | 14 +++-----------
hw/acpi/trace-events | 4 ++++
2 files changed, 7 insertions(+), 11 deletions(-)
diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
index 9c079d6834..546ba036ed 100644
--- a/hw/acpi/piix4.c
+++ b/hw/acpi/piix4.c
@@ -39,14 +39,7 @@
#include "hw/acpi/acpi_dev_interface.h"
#include "hw/xen/xen.h"
#include "qom/cpu.h"
-
-//#define DEBUG
-
-#ifdef DEBUG
-# define PIIX4_DPRINTF(format, ...) printf(format, ## __VA_ARGS__)
-#else
-# define PIIX4_DPRINTF(format, ...) do { } while (0)
-#endif
+#include "trace.h"
#define GPE_BASE 0xafe0
#define GPE_LEN 4
@@ -596,7 +589,7 @@ static uint64_t gpe_readb(void *opaque, hwaddr addr, unsigned width)
PIIX4PMState *s = opaque;
uint32_t val = acpi_gpe_ioport_readb(&s->ar, addr);
- PIIX4_DPRINTF("gpe read %" HWADDR_PRIx " == %" PRIu32 "\n", addr, val);
+ trace_piix4_gpe_readb(addr, width, val);
return val;
}
@@ -605,10 +598,9 @@ static void gpe_writeb(void *opaque, hwaddr addr, uint64_t val,
{
PIIX4PMState *s = opaque;
+ trace_piix4_gpe_writeb(addr, width, val);
acpi_gpe_ioport_writeb(&s->ar, addr, val);
acpi_update_sci(&s->ar, s->irq);
-
- PIIX4_DPRINTF("gpe write %" HWADDR_PRIx " <== %" PRIu64 "\n", addr, val);
}
static const MemoryRegionOps piix4_gpe_ops = {
diff --git a/hw/acpi/trace-events b/hw/acpi/trace-events
index 6272d8a9e7..825b25cbb0 100644
--- a/hw/acpi/trace-events
+++ b/hw/acpi/trace-events
@@ -31,6 +31,10 @@ cpuhp_acpi_ejecting_cpu(uint32_t idx) "0x%"PRIx32
cpuhp_acpi_write_ost_ev(uint32_t slot, uint32_t ev) "idx[0x%"PRIx32"] OST EVENT: 0x%"PRIx32
cpuhp_acpi_write_ost_status(uint32_t slot, uint32_t st) "idx[0x%"PRIx32"] OST STATUS: 0x%"PRIx32
+# piix4.c
+piix4_gpe_readb(uint64_t addr, unsigned width, uint64_t val) "addr: 0x%" PRIx64 " width: %d ==> 0x%" PRIx64
+piix4_gpe_writeb(uint64_t addr, unsigned width, uint64_t val) "addr: 0x%" PRIx64 " width: %d <== 0x%" PRIx64
+
# tco.c
tco_timer_reload(int ticks, int msec) "ticks=%d (%d ms)"
tco_timer_expired(int timeouts_no, bool strap, bool no_reboot) "timeouts_no=%d no_reboot=%d/%d"
--
2.17.2
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH 2/3] acpi/pcihp: Convert debug printf()s to trace events
@ 2019-05-16 12:19 ` Michael S. Tsirkin
0 siblings, 0 replies; 289+ messages in thread
From: Markus Armbruster @ 2019-04-02 16:18 UTC (permalink / raw)
To: qemu-devel; +Cc: mst, imammedo, marcel.apfelbaum
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
hw/acpi/pcihp.c | 25 ++++++++-----------------
hw/acpi/trace-events | 9 +++++++++
2 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
index 88e4ae1bcd..7729c5338b 100644
--- a/hw/acpi/pcihp.c
+++ b/hw/acpi/pcihp.c
@@ -37,14 +37,7 @@
#include "hw/pci/pci_bus.h"
#include "qapi/error.h"
#include "qom/qom-qobject.h"
-
-//#define DEBUG
-
-#ifdef DEBUG
-# define ACPI_PCIHP_DPRINTF(format, ...) printf(format, ## __VA_ARGS__)
-#else
-# define ACPI_PCIHP_DPRINTF(format, ...) do { } while (0)
-#endif
+#include "trace.h"
#define ACPI_PCIHP_ADDR 0xae00
#define ACPI_PCIHP_SIZE 0x0014
@@ -306,23 +299,23 @@ static uint64_t pci_read(void *opaque, hwaddr addr, unsigned int size)
if (!s->legacy_piix) {
s->acpi_pcihp_pci_status[bsel].up = 0;
}
- ACPI_PCIHP_DPRINTF("pci_up_read %" PRIu32 "\n", val);
+ trace_acpi_pci_up_read(val);
break;
case PCI_DOWN_BASE:
val = s->acpi_pcihp_pci_status[bsel].down;
- ACPI_PCIHP_DPRINTF("pci_down_read %" PRIu32 "\n", val);
+ trace_acpi_pci_down_read(val);
break;
case PCI_EJ_BASE:
/* No feature defined yet */
- ACPI_PCIHP_DPRINTF("pci_features_read %" PRIu32 "\n", val);
+ trace_acpi_pci_features_read(val);
break;
case PCI_RMV_BASE:
val = s->acpi_pcihp_pci_status[bsel].hotplug_enable;
- ACPI_PCIHP_DPRINTF("pci_rmv_read %" PRIu32 "\n", val);
+ trace_acpi_pci_rmv_read(val);
break;
case PCI_SEL_BASE:
val = s->hotplug_select;
- ACPI_PCIHP_DPRINTF("pci_sel_read %" PRIu32 "\n", val);
+ trace_acpi_pci_sel_read(val);
default:
break;
}
@@ -340,13 +333,11 @@ static void pci_write(void *opaque, hwaddr addr, uint64_t data,
break;
}
acpi_pcihp_eject_slot(s, s->hotplug_select, data);
- ACPI_PCIHP_DPRINTF("pciej write %" HWADDR_PRIx " <== %" PRIu64 "\n",
- addr, data);
+ trace_acpi_pci_ej_write(addr, data);
break;
case PCI_SEL_BASE:
s->hotplug_select = s->legacy_piix ? ACPI_PCIHP_BSEL_DEFAULT : data;
- ACPI_PCIHP_DPRINTF("pcisel write %" HWADDR_PRIx " <== %" PRIu64 "\n",
- addr, data);
+ trace_acpi_pci_sel_write(addr, data);
default:
break;
}
diff --git a/hw/acpi/trace-events b/hw/acpi/trace-events
index 825b25cbb0..98a56baa6f 100644
--- a/hw/acpi/trace-events
+++ b/hw/acpi/trace-events
@@ -31,6 +31,15 @@ cpuhp_acpi_ejecting_cpu(uint32_t idx) "0x%"PRIx32
cpuhp_acpi_write_ost_ev(uint32_t slot, uint32_t ev) "idx[0x%"PRIx32"] OST EVENT: 0x%"PRIx32
cpuhp_acpi_write_ost_status(uint32_t slot, uint32_t st) "idx[0x%"PRIx32"] OST STATUS: 0x%"PRIx32
+# pcihp.c
+acpi_pci_up_read(uint32_t val) "%" PRIu32
+acpi_pci_down_read(uint32_t val) "%" PRIu32
+acpi_pci_features_read(uint32_t val) "%" PRIu32
+acpi_pci_rmv_read(uint32_t val) "%" PRIu32
+acpi_pci_sel_read(uint32_t val) "%" PRIu32
+acpi_pci_ej_write(uint64_t addr, uint64_t data) "0x%" PRIx64 " <== %" PRIu64
+acpi_pci_sel_write(uint64_t addr, uint64_t data) "0x%" PRIx64 " <== %" PRIu64
+
# piix4.c
piix4_gpe_readb(uint64_t addr, unsigned width, uint64_t val) "addr: 0x%" PRIx64 " width: %d ==> 0x%" PRIx64
piix4_gpe_writeb(uint64_t addr, unsigned width, uint64_t val) "addr: 0x%" PRIx64 " width: %d <== 0x%" PRIx64
--
2.17.2
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH 3/3] acpi/pcihp: Add a few more trace points related to unplug
@ 2019-05-16 12:19 ` Michael S. Tsirkin
0 siblings, 0 replies; 289+ messages in thread
From: Markus Armbruster @ 2019-04-02 16:19 UTC (permalink / raw)
To: qemu-devel; +Cc: mst, imammedo, marcel.apfelbaum
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
hw/acpi/pcihp.c | 7 +++++++
hw/acpi/trace-events | 3 +++
2 files changed, 10 insertions(+)
diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
index 7729c5338b..613406d09b 100644
--- a/hw/acpi/pcihp.c
+++ b/hw/acpi/pcihp.c
@@ -152,6 +152,8 @@ static void acpi_pcihp_eject_slot(AcpiPciHpState *s, unsigned bsel, unsigned slo
int slot = ctz32(slots);
PCIBus *bus = acpi_pcihp_find_hotplug_bus(s, bsel);
+ trace_acpi_pci_eject_slot(bsel, slot);
+
if (!bus) {
return;
}
@@ -263,6 +265,8 @@ void acpi_pcihp_device_plug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState *s,
void acpi_pcihp_device_unplug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState *s,
DeviceState *dev, Error **errp)
{
+ trace_acpi_pci_unplug(PCI_SLOT(PCI_DEVICE(dev)->devfn),
+ acpi_pcihp_get_bsel(pci_get_bus(PCI_DEVICE(dev))));
object_property_set_bool(OBJECT(dev), false, "realized", NULL);
}
@@ -273,6 +277,9 @@ void acpi_pcihp_device_unplug_request_cb(HotplugHandler *hotplug_dev,
PCIDevice *pdev = PCI_DEVICE(dev);
int slot = PCI_SLOT(pdev->devfn);
int bsel = acpi_pcihp_get_bsel(pci_get_bus(pdev));
+
+ trace_acpi_pci_unplug_request(bsel, slot);
+
if (bsel < 0) {
error_setg(errp, "Unsupported bus. Bus doesn't have property '"
ACPI_PCIHP_PROP_BSEL "' set");
diff --git a/hw/acpi/trace-events b/hw/acpi/trace-events
index 98a56baa6f..96b8273297 100644
--- a/hw/acpi/trace-events
+++ b/hw/acpi/trace-events
@@ -32,6 +32,9 @@ cpuhp_acpi_write_ost_ev(uint32_t slot, uint32_t ev) "idx[0x%"PRIx32"] OST EVENT:
cpuhp_acpi_write_ost_status(uint32_t slot, uint32_t st) "idx[0x%"PRIx32"] OST STATUS: 0x%"PRIx32
# pcihp.c
+acpi_pci_eject_slot(unsigned bsel, unsigned slot) "bsel: %u slot: %u"
+acpi_pci_unplug(int bsel, int slot) "bsel: %d slot: %d"
+acpi_pci_unplug_request(int bsel, int slot) "bsel: %d slot: %d"
acpi_pci_up_read(uint32_t val) "%" PRIu32
acpi_pci_down_read(uint32_t val) "%" PRIu32
acpi_pci_features_read(uint32_t val) "%" PRIu32
--
2.17.2
^ permalink raw reply related [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH 0/3] acpi: More trace points
2019-04-02 16:18 [Qemu-devel] [PATCH 0/3] acpi: More trace points Markus Armbruster
` (2 preceding siblings ...)
2019-05-16 12:19 ` [Qemu-devel] [PULL 13/37] " Michael S. Tsirkin
@ 2019-04-02 19:24 ` Philippe Mathieu-Daudé
2019-05-08 11:19 ` Markus Armbruster
4 siblings, 0 replies; 289+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-04-02 19:24 UTC (permalink / raw)
To: Markus Armbruster, qemu-devel; +Cc: imammedo, mst
On 4/2/19 6:18 PM, Markus Armbruster wrote:
> I wrote these patches to help me debug an unplug failure. I expect
> them to be helpful for others, too.
Appreciated.
FYI I have a WiP branch where I use existing tracepoints to check events
order and timing (using Avocado).
Series:
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>
> Markus Armbruster (3):
> acpi/piix4: Convert debug printf()s to trace events
> acpi/pcihp: Convert debug printf()s to trace events
> acpi/pcihp: Add a few more trace points related to unplug
>
> hw/acpi/pcihp.c | 32 +++++++++++++++-----------------
> hw/acpi/piix4.c | 14 +++-----------
> hw/acpi/trace-events | 16 ++++++++++++++++
> 3 files changed, 34 insertions(+), 28 deletions(-)
>
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH 1/3] acpi/piix4: Convert debug printf()s to trace events
2019-05-16 12:19 ` [Qemu-devel] [PULL 11/37] " Michael S. Tsirkin
(?)
(?)
@ 2019-04-04 10:07 ` Igor Mammedov
-1 siblings, 0 replies; 289+ messages in thread
From: Igor Mammedov @ 2019-04-04 10:07 UTC (permalink / raw)
To: Markus Armbruster; +Cc: qemu-devel, mst, marcel.apfelbaum
On Tue, 2 Apr 2019 18:18:58 +0200
Markus Armbruster <armbru@redhat.com> wrote:
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
> ---
> hw/acpi/piix4.c | 14 +++-----------
> hw/acpi/trace-events | 4 ++++
> 2 files changed, 7 insertions(+), 11 deletions(-)
>
> diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
> index 9c079d6834..546ba036ed 100644
> --- a/hw/acpi/piix4.c
> +++ b/hw/acpi/piix4.c
> @@ -39,14 +39,7 @@
> #include "hw/acpi/acpi_dev_interface.h"
> #include "hw/xen/xen.h"
> #include "qom/cpu.h"
> -
> -//#define DEBUG
> -
> -#ifdef DEBUG
> -# define PIIX4_DPRINTF(format, ...) printf(format, ## __VA_ARGS__)
> -#else
> -# define PIIX4_DPRINTF(format, ...) do { } while (0)
> -#endif
> +#include "trace.h"
>
> #define GPE_BASE 0xafe0
> #define GPE_LEN 4
> @@ -596,7 +589,7 @@ static uint64_t gpe_readb(void *opaque, hwaddr addr, unsigned width)
> PIIX4PMState *s = opaque;
> uint32_t val = acpi_gpe_ioport_readb(&s->ar, addr);
>
> - PIIX4_DPRINTF("gpe read %" HWADDR_PRIx " == %" PRIu32 "\n", addr, val);
> + trace_piix4_gpe_readb(addr, width, val);
> return val;
> }
>
> @@ -605,10 +598,9 @@ static void gpe_writeb(void *opaque, hwaddr addr, uint64_t val,
> {
> PIIX4PMState *s = opaque;
>
> + trace_piix4_gpe_writeb(addr, width, val);
> acpi_gpe_ioport_writeb(&s->ar, addr, val);
> acpi_update_sci(&s->ar, s->irq);
> -
> - PIIX4_DPRINTF("gpe write %" HWADDR_PRIx " <== %" PRIu64 "\n", addr, val);
> }
>
> static const MemoryRegionOps piix4_gpe_ops = {
> diff --git a/hw/acpi/trace-events b/hw/acpi/trace-events
> index 6272d8a9e7..825b25cbb0 100644
> --- a/hw/acpi/trace-events
> +++ b/hw/acpi/trace-events
> @@ -31,6 +31,10 @@ cpuhp_acpi_ejecting_cpu(uint32_t idx) "0x%"PRIx32
> cpuhp_acpi_write_ost_ev(uint32_t slot, uint32_t ev) "idx[0x%"PRIx32"] OST EVENT: 0x%"PRIx32
> cpuhp_acpi_write_ost_status(uint32_t slot, uint32_t st) "idx[0x%"PRIx32"] OST STATUS: 0x%"PRIx32
>
> +# piix4.c
> +piix4_gpe_readb(uint64_t addr, unsigned width, uint64_t val) "addr: 0x%" PRIx64 " width: %d ==> 0x%" PRIx64
> +piix4_gpe_writeb(uint64_t addr, unsigned width, uint64_t val) "addr: 0x%" PRIx64 " width: %d <== 0x%" PRIx64
> +
> # tco.c
> tco_timer_reload(int ticks, int msec) "ticks=%d (%d ms)"
> tco_timer_expired(int timeouts_no, bool strap, bool no_reboot) "timeouts_no=%d no_reboot=%d/%d"
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH 2/3] acpi/pcihp: Convert debug printf()s to trace events
2019-05-16 12:19 ` [Qemu-devel] [PULL 12/37] " Michael S. Tsirkin
(?)
(?)
@ 2019-04-04 10:13 ` Igor Mammedov
-1 siblings, 0 replies; 289+ messages in thread
From: Igor Mammedov @ 2019-04-04 10:13 UTC (permalink / raw)
To: Markus Armbruster; +Cc: qemu-devel, mst, marcel.apfelbaum
On Tue, 2 Apr 2019 18:18:59 +0200
Markus Armbruster <armbru@redhat.com> wrote:
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
> ---
> hw/acpi/pcihp.c | 25 ++++++++-----------------
> hw/acpi/trace-events | 9 +++++++++
> 2 files changed, 17 insertions(+), 17 deletions(-)
>
> diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
> index 88e4ae1bcd..7729c5338b 100644
> --- a/hw/acpi/pcihp.c
> +++ b/hw/acpi/pcihp.c
> @@ -37,14 +37,7 @@
> #include "hw/pci/pci_bus.h"
> #include "qapi/error.h"
> #include "qom/qom-qobject.h"
> -
> -//#define DEBUG
> -
> -#ifdef DEBUG
> -# define ACPI_PCIHP_DPRINTF(format, ...) printf(format, ## __VA_ARGS__)
> -#else
> -# define ACPI_PCIHP_DPRINTF(format, ...) do { } while (0)
> -#endif
> +#include "trace.h"
>
> #define ACPI_PCIHP_ADDR 0xae00
> #define ACPI_PCIHP_SIZE 0x0014
> @@ -306,23 +299,23 @@ static uint64_t pci_read(void *opaque, hwaddr addr, unsigned int size)
> if (!s->legacy_piix) {
> s->acpi_pcihp_pci_status[bsel].up = 0;
> }
> - ACPI_PCIHP_DPRINTF("pci_up_read %" PRIu32 "\n", val);
> + trace_acpi_pci_up_read(val);
> break;
> case PCI_DOWN_BASE:
> val = s->acpi_pcihp_pci_status[bsel].down;
> - ACPI_PCIHP_DPRINTF("pci_down_read %" PRIu32 "\n", val);
> + trace_acpi_pci_down_read(val);
> break;
> case PCI_EJ_BASE:
> /* No feature defined yet */
> - ACPI_PCIHP_DPRINTF("pci_features_read %" PRIu32 "\n", val);
> + trace_acpi_pci_features_read(val);
> break;
> case PCI_RMV_BASE:
> val = s->acpi_pcihp_pci_status[bsel].hotplug_enable;
> - ACPI_PCIHP_DPRINTF("pci_rmv_read %" PRIu32 "\n", val);
> + trace_acpi_pci_rmv_read(val);
> break;
> case PCI_SEL_BASE:
> val = s->hotplug_select;
> - ACPI_PCIHP_DPRINTF("pci_sel_read %" PRIu32 "\n", val);
> + trace_acpi_pci_sel_read(val);
> default:
> break;
> }
> @@ -340,13 +333,11 @@ static void pci_write(void *opaque, hwaddr addr, uint64_t data,
> break;
> }
> acpi_pcihp_eject_slot(s, s->hotplug_select, data);
> - ACPI_PCIHP_DPRINTF("pciej write %" HWADDR_PRIx " <== %" PRIu64 "\n",
> - addr, data);
> + trace_acpi_pci_ej_write(addr, data);
> break;
> case PCI_SEL_BASE:
> s->hotplug_select = s->legacy_piix ? ACPI_PCIHP_BSEL_DEFAULT : data;
> - ACPI_PCIHP_DPRINTF("pcisel write %" HWADDR_PRIx " <== %" PRIu64 "\n",
> - addr, data);
> + trace_acpi_pci_sel_write(addr, data);
> default:
> break;
> }
> diff --git a/hw/acpi/trace-events b/hw/acpi/trace-events
> index 825b25cbb0..98a56baa6f 100644
> --- a/hw/acpi/trace-events
> +++ b/hw/acpi/trace-events
> @@ -31,6 +31,15 @@ cpuhp_acpi_ejecting_cpu(uint32_t idx) "0x%"PRIx32
> cpuhp_acpi_write_ost_ev(uint32_t slot, uint32_t ev) "idx[0x%"PRIx32"] OST EVENT: 0x%"PRIx32
> cpuhp_acpi_write_ost_status(uint32_t slot, uint32_t st) "idx[0x%"PRIx32"] OST STATUS: 0x%"PRIx32
>
> +# pcihp.c
> +acpi_pci_up_read(uint32_t val) "%" PRIu32
> +acpi_pci_down_read(uint32_t val) "%" PRIu32
> +acpi_pci_features_read(uint32_t val) "%" PRIu32
> +acpi_pci_rmv_read(uint32_t val) "%" PRIu32
> +acpi_pci_sel_read(uint32_t val) "%" PRIu32
> +acpi_pci_ej_write(uint64_t addr, uint64_t data) "0x%" PRIx64 " <== %" PRIu64
> +acpi_pci_sel_write(uint64_t addr, uint64_t data) "0x%" PRIx64 " <== %" PRIu64
> +
> # piix4.c
> piix4_gpe_readb(uint64_t addr, unsigned width, uint64_t val) "addr: 0x%" PRIx64 " width: %d ==> 0x%" PRIx64
> piix4_gpe_writeb(uint64_t addr, unsigned width, uint64_t val) "addr: 0x%" PRIx64 " width: %d <== 0x%" PRIx64
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH 3/3] acpi/pcihp: Add a few more trace points related to unplug
2019-05-16 12:19 ` [Qemu-devel] [PULL 13/37] " Michael S. Tsirkin
(?)
(?)
@ 2019-04-04 10:14 ` Igor Mammedov
2019-04-04 12:54 ` Laszlo Ersek
-1 siblings, 1 reply; 289+ messages in thread
From: Igor Mammedov @ 2019-04-04 10:14 UTC (permalink / raw)
To: Markus Armbruster; +Cc: qemu-devel, mst, marcel.apfelbaum
On Tue, 2 Apr 2019 18:19:00 +0200
Markus Armbruster <armbru@redhat.com> wrote:
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
> ---
> hw/acpi/pcihp.c | 7 +++++++
> hw/acpi/trace-events | 3 +++
> 2 files changed, 10 insertions(+)
>
> diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
> index 7729c5338b..613406d09b 100644
> --- a/hw/acpi/pcihp.c
> +++ b/hw/acpi/pcihp.c
> @@ -152,6 +152,8 @@ static void acpi_pcihp_eject_slot(AcpiPciHpState *s, unsigned bsel, unsigned slo
> int slot = ctz32(slots);
> PCIBus *bus = acpi_pcihp_find_hotplug_bus(s, bsel);
>
> + trace_acpi_pci_eject_slot(bsel, slot);
> +
> if (!bus) {
> return;
> }
> @@ -263,6 +265,8 @@ void acpi_pcihp_device_plug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState *s,
> void acpi_pcihp_device_unplug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState *s,
> DeviceState *dev, Error **errp)
> {
> + trace_acpi_pci_unplug(PCI_SLOT(PCI_DEVICE(dev)->devfn),
> + acpi_pcihp_get_bsel(pci_get_bus(PCI_DEVICE(dev))));
> object_property_set_bool(OBJECT(dev), false, "realized", NULL);
> }
>
> @@ -273,6 +277,9 @@ void acpi_pcihp_device_unplug_request_cb(HotplugHandler *hotplug_dev,
> PCIDevice *pdev = PCI_DEVICE(dev);
> int slot = PCI_SLOT(pdev->devfn);
> int bsel = acpi_pcihp_get_bsel(pci_get_bus(pdev));
> +
> + trace_acpi_pci_unplug_request(bsel, slot);
> +
> if (bsel < 0) {
> error_setg(errp, "Unsupported bus. Bus doesn't have property '"
> ACPI_PCIHP_PROP_BSEL "' set");
> diff --git a/hw/acpi/trace-events b/hw/acpi/trace-events
> index 98a56baa6f..96b8273297 100644
> --- a/hw/acpi/trace-events
> +++ b/hw/acpi/trace-events
> @@ -32,6 +32,9 @@ cpuhp_acpi_write_ost_ev(uint32_t slot, uint32_t ev) "idx[0x%"PRIx32"] OST EVENT:
> cpuhp_acpi_write_ost_status(uint32_t slot, uint32_t st) "idx[0x%"PRIx32"] OST STATUS: 0x%"PRIx32
>
> # pcihp.c
> +acpi_pci_eject_slot(unsigned bsel, unsigned slot) "bsel: %u slot: %u"
> +acpi_pci_unplug(int bsel, int slot) "bsel: %d slot: %d"
> +acpi_pci_unplug_request(int bsel, int slot) "bsel: %d slot: %d"
> acpi_pci_up_read(uint32_t val) "%" PRIu32
> acpi_pci_down_read(uint32_t val) "%" PRIu32
> acpi_pci_features_read(uint32_t val) "%" PRIu32
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH 3/3] acpi/pcihp: Add a few more trace points related to unplug
2019-04-04 10:14 ` [Qemu-devel] [PATCH 3/3] " Igor Mammedov
@ 2019-04-04 12:54 ` Laszlo Ersek
2019-04-04 14:19 ` Igor Mammedov
0 siblings, 1 reply; 289+ messages in thread
From: Laszlo Ersek @ 2019-04-04 12:54 UTC (permalink / raw)
To: Igor Mammedov, Markus Armbruster; +Cc: qemu-devel, mst
Hi Igor,
On 04/04/19 12:14, Igor Mammedov wrote:
> On Tue, 2 Apr 2019 18:19:00 +0200
> Markus Armbruster <armbru@redhat.com> wrote:
>
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>
> Reviewed-by: Markus Armbruster <armbru@redhat.com>
did you mean: "R-b: Igor" instead?
Laszlo
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH 3/3] acpi/pcihp: Add a few more trace points related to unplug
2019-04-04 12:54 ` Laszlo Ersek
@ 2019-04-04 14:19 ` Igor Mammedov
0 siblings, 0 replies; 289+ messages in thread
From: Igor Mammedov @ 2019-04-04 14:19 UTC (permalink / raw)
To: Laszlo Ersek; +Cc: Markus Armbruster, qemu-devel, mst
On Thu, 4 Apr 2019 14:54:51 +0200
Laszlo Ersek <lersek@redhat.com> wrote:
> Hi Igor,
>
> On 04/04/19 12:14, Igor Mammedov wrote:
> > On Tue, 2 Apr 2019 18:19:00 +0200
> > Markus Armbruster <armbru@redhat.com> wrote:
> >
> >> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> >
> > Reviewed-by: Markus Armbruster <armbru@redhat.com>
>
> did you mean: "R-b: Igor" instead?
:) yep, copied name from wrong field which is easy feat in claws-mail
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
>
> Laszlo
^ permalink raw reply [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH for-4.1] q35: acpi: do not create dummy MCFG table
@ 2019-04-09 15:00 ` Igor Mammedov
0 siblings, 0 replies; 289+ messages in thread
From: Igor Mammedov @ 2019-04-09 15:00 UTC (permalink / raw)
To: qemu-devel; +Cc: mst, marcel.apfelbaum, ehabkost, richardw.yang
Dummy table (with signature "QEMU") creation came from original SeaBIOS
codebase. And QEMU would have to keep it around if there were Q35 machine
that depended on keeping ACPI tables blob constant size. Luckily there
were no versioned Q35 machine types before commit:
(since 2.3) a1666142db acpi-build: make ROMs RAM blocks resizeable
which obsoleted need to keep ACPI tables blob the same size on source/destination.
Considering the 1st versioned machine is pc-q35-2.4, the dummy table
is not really necessary and it's safe to drop it without breaking
cross version migration in both directions unconditionally.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
hw/i386/acpi-build.c | 18 ++++--------------
1 file changed, 4 insertions(+), 14 deletions(-)
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 416da31..8671e25 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -2401,7 +2401,6 @@ static void
build_mcfg_q35(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
{
AcpiTableMcfg *mcfg;
- const char *sig;
int len = sizeof(*mcfg) + 1 * sizeof(mcfg->allocation[0]);
mcfg = acpi_data_push(table_data, len);
@@ -2411,19 +2410,7 @@ build_mcfg_q35(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
mcfg->allocation[0].start_bus_number = 0;
mcfg->allocation[0].end_bus_number = PCIE_MMCFG_BUS(info->mcfg_size - 1);
- /* MCFG is used for ECAM which can be enabled or disabled by guest.
- * To avoid table size changes (which create migration issues),
- * always create the table even if there are no allocations,
- * but set the signature to a reserved value in this case.
- * ACPI spec requires OSPMs to ignore such tables.
- */
- if (info->mcfg_base == PCIE_BASE_ADDR_UNMAPPED) {
- /* Reserved signature: ignored by OSPM */
- sig = "QEMU";
- } else {
- sig = "MCFG";
- }
- build_header(linker, table_data, (void *)mcfg, sig, len, 1, NULL, NULL);
+ build_header(linker, table_data, (void *)mcfg, "MCFG", len, 1, NULL, NULL);
}
/*
@@ -2592,6 +2579,9 @@ static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg)
}
mcfg->mcfg_base = qnum_get_uint(qobject_to(QNum, o));
qobject_unref(o);
+ if (mcfg->mcfg_base == PCIE_BASE_ADDR_UNMAPPED) {
+ return false;
+ }
o = object_property_get_qobject(pci_host, PCIE_HOST_MCFG_SIZE, NULL);
assert(o);
--
2.7.4
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH for-4.1] q35: acpi: do not create dummy MCFG table
@ 2019-04-09 15:00 ` Igor Mammedov
0 siblings, 0 replies; 289+ messages in thread
From: Igor Mammedov @ 2019-04-09 15:00 UTC (permalink / raw)
To: qemu-devel; +Cc: richardw.yang, ehabkost, mst
Dummy table (with signature "QEMU") creation came from original SeaBIOS
codebase. And QEMU would have to keep it around if there were Q35 machine
that depended on keeping ACPI tables blob constant size. Luckily there
were no versioned Q35 machine types before commit:
(since 2.3) a1666142db acpi-build: make ROMs RAM blocks resizeable
which obsoleted need to keep ACPI tables blob the same size on source/destination.
Considering the 1st versioned machine is pc-q35-2.4, the dummy table
is not really necessary and it's safe to drop it without breaking
cross version migration in both directions unconditionally.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
hw/i386/acpi-build.c | 18 ++++--------------
1 file changed, 4 insertions(+), 14 deletions(-)
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 416da31..8671e25 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -2401,7 +2401,6 @@ static void
build_mcfg_q35(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
{
AcpiTableMcfg *mcfg;
- const char *sig;
int len = sizeof(*mcfg) + 1 * sizeof(mcfg->allocation[0]);
mcfg = acpi_data_push(table_data, len);
@@ -2411,19 +2410,7 @@ build_mcfg_q35(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
mcfg->allocation[0].start_bus_number = 0;
mcfg->allocation[0].end_bus_number = PCIE_MMCFG_BUS(info->mcfg_size - 1);
- /* MCFG is used for ECAM which can be enabled or disabled by guest.
- * To avoid table size changes (which create migration issues),
- * always create the table even if there are no allocations,
- * but set the signature to a reserved value in this case.
- * ACPI spec requires OSPMs to ignore such tables.
- */
- if (info->mcfg_base == PCIE_BASE_ADDR_UNMAPPED) {
- /* Reserved signature: ignored by OSPM */
- sig = "QEMU";
- } else {
- sig = "MCFG";
- }
- build_header(linker, table_data, (void *)mcfg, sig, len, 1, NULL, NULL);
+ build_header(linker, table_data, (void *)mcfg, "MCFG", len, 1, NULL, NULL);
}
/*
@@ -2592,6 +2579,9 @@ static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg)
}
mcfg->mcfg_base = qnum_get_uint(qobject_to(QNum, o));
qobject_unref(o);
+ if (mcfg->mcfg_base == PCIE_BASE_ADDR_UNMAPPED) {
+ return false;
+ }
o = object_property_get_qobject(pci_host, PCIE_HOST_MCFG_SIZE, NULL);
assert(o);
--
2.7.4
^ permalink raw reply related [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH for-4.1] q35: acpi: do not create dummy MCFG table
@ 2019-04-10 1:12 ` Wei Yang
0 siblings, 0 replies; 289+ messages in thread
From: Wei Yang @ 2019-04-10 1:12 UTC (permalink / raw)
To: Igor Mammedov; +Cc: qemu-devel, mst, marcel.apfelbaum, ehabkost, richardw.yang
On Tue, Apr 09, 2019 at 05:00:37PM +0200, Igor Mammedov wrote:
>Dummy table (with signature "QEMU") creation came from original SeaBIOS
>codebase. And QEMU would have to keep it around if there were Q35 machine
>that depended on keeping ACPI tables blob constant size. Luckily there
>were no versioned Q35 machine types before commit:
> (since 2.3) a1666142db acpi-build: make ROMs RAM blocks resizeable
>which obsoleted need to keep ACPI tables blob the same size on source/destination.
>
I am not sure getting the "versioned Q35" correctly. Seems originally there is
q35-1.4?
commit bf3caa3dc17552b323cec6831301a22cfc98ecd5
Author: Paolo Bonzini <pbonzini@redhat.com>
Date: Fri Feb 8 14:06:15 2013 +0100
pc: add compatibility machine types for 1.4
Adds both pc-i440fx-1.4 and pc-q35-1.4.
--
Wei Yang
Help you, Help me
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH for-4.1] q35: acpi: do not create dummy MCFG table
@ 2019-04-10 1:12 ` Wei Yang
0 siblings, 0 replies; 289+ messages in thread
From: Wei Yang @ 2019-04-10 1:12 UTC (permalink / raw)
To: Igor Mammedov; +Cc: ehabkost, richardw.yang, qemu-devel, mst
On Tue, Apr 09, 2019 at 05:00:37PM +0200, Igor Mammedov wrote:
>Dummy table (with signature "QEMU") creation came from original SeaBIOS
>codebase. And QEMU would have to keep it around if there were Q35 machine
>that depended on keeping ACPI tables blob constant size. Luckily there
>were no versioned Q35 machine types before commit:
> (since 2.3) a1666142db acpi-build: make ROMs RAM blocks resizeable
>which obsoleted need to keep ACPI tables blob the same size on source/destination.
>
I am not sure getting the "versioned Q35" correctly. Seems originally there is
q35-1.4?
commit bf3caa3dc17552b323cec6831301a22cfc98ecd5
Author: Paolo Bonzini <pbonzini@redhat.com>
Date: Fri Feb 8 14:06:15 2013 +0100
pc: add compatibility machine types for 1.4
Adds both pc-i440fx-1.4 and pc-q35-1.4.
--
Wei Yang
Help you, Help me
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH for-4.1] q35: acpi: do not create dummy MCFG table
@ 2019-04-10 9:08 ` Igor Mammedov
0 siblings, 0 replies; 289+ messages in thread
From: Igor Mammedov @ 2019-04-10 9:08 UTC (permalink / raw)
To: Wei Yang; +Cc: qemu-devel, mst, marcel.apfelbaum, ehabkost
On Wed, 10 Apr 2019 09:12:31 +0800
Wei Yang <richardw.yang@linux.intel.com> wrote:
> On Tue, Apr 09, 2019 at 05:00:37PM +0200, Igor Mammedov wrote:
> >Dummy table (with signature "QEMU") creation came from original SeaBIOS
> >codebase. And QEMU would have to keep it around if there were Q35 machine
> >that depended on keeping ACPI tables blob constant size. Luckily there
> >were no versioned Q35 machine types before commit:
> > (since 2.3) a1666142db acpi-build: make ROMs RAM blocks resizeable
> >which obsoleted need to keep ACPI tables blob the same size on source/destination.
> >
>
> I am not sure getting the "versioned Q35" correctly. Seems originally there is
> q35-1.4?
>
> commit bf3caa3dc17552b323cec6831301a22cfc98ecd5
> Author: Paolo Bonzini <pbonzini@redhat.com>
> Date: Fri Feb 8 14:06:15 2013 +0100
>
> pc: add compatibility machine types for 1.4
>
> Adds both pc-i440fx-1.4 and pc-q35-1.4.
current upstream has only pc-q35-2.4 as earliest versioned Q35
machine type (try to run: qemu-system-x86_64 -M help)
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH for-4.1] q35: acpi: do not create dummy MCFG table
@ 2019-04-10 9:08 ` Igor Mammedov
0 siblings, 0 replies; 289+ messages in thread
From: Igor Mammedov @ 2019-04-10 9:08 UTC (permalink / raw)
To: Wei Yang; +Cc: ehabkost, qemu-devel, mst
On Wed, 10 Apr 2019 09:12:31 +0800
Wei Yang <richardw.yang@linux.intel.com> wrote:
> On Tue, Apr 09, 2019 at 05:00:37PM +0200, Igor Mammedov wrote:
> >Dummy table (with signature "QEMU") creation came from original SeaBIOS
> >codebase. And QEMU would have to keep it around if there were Q35 machine
> >that depended on keeping ACPI tables blob constant size. Luckily there
> >were no versioned Q35 machine types before commit:
> > (since 2.3) a1666142db acpi-build: make ROMs RAM blocks resizeable
> >which obsoleted need to keep ACPI tables blob the same size on source/destination.
> >
>
> I am not sure getting the "versioned Q35" correctly. Seems originally there is
> q35-1.4?
>
> commit bf3caa3dc17552b323cec6831301a22cfc98ecd5
> Author: Paolo Bonzini <pbonzini@redhat.com>
> Date: Fri Feb 8 14:06:15 2013 +0100
>
> pc: add compatibility machine types for 1.4
>
> Adds both pc-i440fx-1.4 and pc-q35-1.4.
current upstream has only pc-q35-2.4 as earliest versioned Q35
machine type (try to run: qemu-system-x86_64 -M help)
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH for-4.1] q35: acpi: do not create dummy MCFG table
@ 2019-04-10 14:01 ` Wei Yang
0 siblings, 0 replies; 289+ messages in thread
From: Wei Yang @ 2019-04-10 14:01 UTC (permalink / raw)
To: Igor Mammedov; +Cc: Wei Yang, qemu-devel, mst, marcel.apfelbaum, ehabkost
On Wed, Apr 10, 2019 at 11:08:33AM +0200, Igor Mammedov wrote:
>On Wed, 10 Apr 2019 09:12:31 +0800
>Wei Yang <richardw.yang@linux.intel.com> wrote:
>
>> On Tue, Apr 09, 2019 at 05:00:37PM +0200, Igor Mammedov wrote:
>> >Dummy table (with signature "QEMU") creation came from original SeaBIOS
>> >codebase. And QEMU would have to keep it around if there were Q35 machine
>> >that depended on keeping ACPI tables blob constant size. Luckily there
>> >were no versioned Q35 machine types before commit:
>> > (since 2.3) a1666142db acpi-build: make ROMs RAM blocks resizeable
>> >which obsoleted need to keep ACPI tables blob the same size on source/destination.
>> >
>>
>> I am not sure getting the "versioned Q35" correctly. Seems originally there is
>> q35-1.4?
>>
>> commit bf3caa3dc17552b323cec6831301a22cfc98ecd5
>> Author: Paolo Bonzini <pbonzini@redhat.com>
>> Date: Fri Feb 8 14:06:15 2013 +0100
>>
>> pc: add compatibility machine types for 1.4
>>
>> Adds both pc-i440fx-1.4 and pc-q35-1.4.
>
>current upstream has only pc-q35-2.4 as earliest versioned Q35
>machine type (try to run: qemu-system-x86_64 -M help)
Yes, I see those old type are removed. This means we don't want to support
those old types, right? Because those old types can't be migrated to latest
upstream qemu.
--
Wei Yang
Help you, Help me
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH for-4.1] q35: acpi: do not create dummy MCFG table
@ 2019-04-10 14:01 ` Wei Yang
0 siblings, 0 replies; 289+ messages in thread
From: Wei Yang @ 2019-04-10 14:01 UTC (permalink / raw)
To: Igor Mammedov; +Cc: ehabkost, mst, Wei Yang, qemu-devel
On Wed, Apr 10, 2019 at 11:08:33AM +0200, Igor Mammedov wrote:
>On Wed, 10 Apr 2019 09:12:31 +0800
>Wei Yang <richardw.yang@linux.intel.com> wrote:
>
>> On Tue, Apr 09, 2019 at 05:00:37PM +0200, Igor Mammedov wrote:
>> >Dummy table (with signature "QEMU") creation came from original SeaBIOS
>> >codebase. And QEMU would have to keep it around if there were Q35 machine
>> >that depended on keeping ACPI tables blob constant size. Luckily there
>> >were no versioned Q35 machine types before commit:
>> > (since 2.3) a1666142db acpi-build: make ROMs RAM blocks resizeable
>> >which obsoleted need to keep ACPI tables blob the same size on source/destination.
>> >
>>
>> I am not sure getting the "versioned Q35" correctly. Seems originally there is
>> q35-1.4?
>>
>> commit bf3caa3dc17552b323cec6831301a22cfc98ecd5
>> Author: Paolo Bonzini <pbonzini@redhat.com>
>> Date: Fri Feb 8 14:06:15 2013 +0100
>>
>> pc: add compatibility machine types for 1.4
>>
>> Adds both pc-i440fx-1.4 and pc-q35-1.4.
>
>current upstream has only pc-q35-2.4 as earliest versioned Q35
>machine type (try to run: qemu-system-x86_64 -M help)
Yes, I see those old type are removed. This means we don't want to support
those old types, right? Because those old types can't be migrated to latest
upstream qemu.
--
Wei Yang
Help you, Help me
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH for-4.1] q35: acpi: do not create dummy MCFG table
@ 2019-04-10 14:11 ` Igor Mammedov
0 siblings, 0 replies; 289+ messages in thread
From: Igor Mammedov @ 2019-04-10 14:11 UTC (permalink / raw)
To: Wei Yang; +Cc: qemu-devel, mst, marcel.apfelbaum, ehabkost
On Wed, 10 Apr 2019 22:01:53 +0800
Wei Yang <richardw.yang@linux.intel.com> wrote:
> On Wed, Apr 10, 2019 at 11:08:33AM +0200, Igor Mammedov wrote:
> >On Wed, 10 Apr 2019 09:12:31 +0800
> >Wei Yang <richardw.yang@linux.intel.com> wrote:
> >
> >> On Tue, Apr 09, 2019 at 05:00:37PM +0200, Igor Mammedov wrote:
> >> >Dummy table (with signature "QEMU") creation came from original SeaBIOS
> >> >codebase. And QEMU would have to keep it around if there were Q35 machine
> >> >that depended on keeping ACPI tables blob constant size. Luckily there
> >> >were no versioned Q35 machine types before commit:
> >> > (since 2.3) a1666142db acpi-build: make ROMs RAM blocks resizeable
> >> >which obsoleted need to keep ACPI tables blob the same size on source/destination.
> >> >
> >>
> >> I am not sure getting the "versioned Q35" correctly. Seems originally there is
> >> q35-1.4?
> >>
> >> commit bf3caa3dc17552b323cec6831301a22cfc98ecd5
> >> Author: Paolo Bonzini <pbonzini@redhat.com>
> >> Date: Fri Feb 8 14:06:15 2013 +0100
> >>
> >> pc: add compatibility machine types for 1.4
> >>
> >> Adds both pc-i440fx-1.4 and pc-q35-1.4.
> >
> >current upstream has only pc-q35-2.4 as earliest versioned Q35
> >machine type (try to run: qemu-system-x86_64 -M help)
>
> Yes, I see those old type are removed. This means we don't want to support
> those old types, right? Because those old types can't be migrated to latest
> upstream qemu.
Exactly
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH for-4.1] q35: acpi: do not create dummy MCFG table
@ 2019-04-10 14:11 ` Igor Mammedov
0 siblings, 0 replies; 289+ messages in thread
From: Igor Mammedov @ 2019-04-10 14:11 UTC (permalink / raw)
To: Wei Yang; +Cc: ehabkost, qemu-devel, mst
On Wed, 10 Apr 2019 22:01:53 +0800
Wei Yang <richardw.yang@linux.intel.com> wrote:
> On Wed, Apr 10, 2019 at 11:08:33AM +0200, Igor Mammedov wrote:
> >On Wed, 10 Apr 2019 09:12:31 +0800
> >Wei Yang <richardw.yang@linux.intel.com> wrote:
> >
> >> On Tue, Apr 09, 2019 at 05:00:37PM +0200, Igor Mammedov wrote:
> >> >Dummy table (with signature "QEMU") creation came from original SeaBIOS
> >> >codebase. And QEMU would have to keep it around if there were Q35 machine
> >> >that depended on keeping ACPI tables blob constant size. Luckily there
> >> >were no versioned Q35 machine types before commit:
> >> > (since 2.3) a1666142db acpi-build: make ROMs RAM blocks resizeable
> >> >which obsoleted need to keep ACPI tables blob the same size on source/destination.
> >> >
> >>
> >> I am not sure getting the "versioned Q35" correctly. Seems originally there is
> >> q35-1.4?
> >>
> >> commit bf3caa3dc17552b323cec6831301a22cfc98ecd5
> >> Author: Paolo Bonzini <pbonzini@redhat.com>
> >> Date: Fri Feb 8 14:06:15 2013 +0100
> >>
> >> pc: add compatibility machine types for 1.4
> >>
> >> Adds both pc-i440fx-1.4 and pc-q35-1.4.
> >
> >current upstream has only pc-q35-2.4 as earliest versioned Q35
> >machine type (try to run: qemu-system-x86_64 -M help)
>
> Yes, I see those old type are removed. This means we don't want to support
> those old types, right? Because those old types can't be migrated to latest
> upstream qemu.
Exactly
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH for-4.1] q35: acpi: do not create dummy MCFG table
@ 2019-04-10 14:27 ` Wei Yang
0 siblings, 0 replies; 289+ messages in thread
From: Wei Yang @ 2019-04-10 14:27 UTC (permalink / raw)
To: Igor Mammedov; +Cc: qemu-devel, mst, marcel.apfelbaum, ehabkost, richardw.yang
On Tue, Apr 09, 2019 at 05:00:37PM +0200, Igor Mammedov wrote:
>Dummy table (with signature "QEMU") creation came from original SeaBIOS
>codebase. And QEMU would have to keep it around if there were Q35 machine
>that depended on keeping ACPI tables blob constant size. Luckily there
>were no versioned Q35 machine types before commit:
> (since 2.3) a1666142db acpi-build: make ROMs RAM blocks resizeable
>which obsoleted need to keep ACPI tables blob the same size on source/destination.
I think we should keep table blob the same size on source/destination.
But with resizable MemoryRegion, we don't need to reserve some dummy space.
Because we can expand it later.
>
>Considering the 1st versioned machine is pc-q35-2.4, the dummy table
>is not really necessary and it's safe to drop it without breaking
>cross version migration in both directions unconditionally.
>
>Signed-off-by: Igor Mammedov <imammedo@redhat.com>
>---
> hw/i386/acpi-build.c | 18 ++++--------------
> 1 file changed, 4 insertions(+), 14 deletions(-)
>
>diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
>index 416da31..8671e25 100644
>--- a/hw/i386/acpi-build.c
>+++ b/hw/i386/acpi-build.c
>@@ -2401,7 +2401,6 @@ static void
> build_mcfg_q35(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
> {
> AcpiTableMcfg *mcfg;
>- const char *sig;
> int len = sizeof(*mcfg) + 1 * sizeof(mcfg->allocation[0]);
>
> mcfg = acpi_data_push(table_data, len);
>@@ -2411,19 +2410,7 @@ build_mcfg_q35(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
> mcfg->allocation[0].start_bus_number = 0;
> mcfg->allocation[0].end_bus_number = PCIE_MMCFG_BUS(info->mcfg_size - 1);
>
>- /* MCFG is used for ECAM which can be enabled or disabled by guest.
I want to cnfirm what is "enabled or disabled by guest" here.
If we don't reserve mcfg and "guest" enable mcfg during running, the ACPI
table size changed. But the destination still has the original table size,
since destination "guest" keep sleep during this period.
Now the migration would face table size difference and break migration?
>- * To avoid table size changes (which create migration issues),
>- * always create the table even if there are no allocations,
>- * but set the signature to a reserved value in this case.
>- * ACPI spec requires OSPMs to ignore such tables.
>- */
>- if (info->mcfg_base == PCIE_BASE_ADDR_UNMAPPED) {
>- /* Reserved signature: ignored by OSPM */
>- sig = "QEMU";
>- } else {
>- sig = "MCFG";
>- }
>- build_header(linker, table_data, (void *)mcfg, sig, len, 1, NULL, NULL);
>+ build_header(linker, table_data, (void *)mcfg, "MCFG", len, 1, NULL, NULL);
> }
>
> /*
>@@ -2592,6 +2579,9 @@ static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg)
> }
> mcfg->mcfg_base = qnum_get_uint(qobject_to(QNum, o));
> qobject_unref(o);
>+ if (mcfg->mcfg_base == PCIE_BASE_ADDR_UNMAPPED) {
>+ return false;
>+ }
>
> o = object_property_get_qobject(pci_host, PCIE_HOST_MCFG_SIZE, NULL);
> assert(o);
>--
>2.7.4
--
Wei Yang
Help you, Help me
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH for-4.1] q35: acpi: do not create dummy MCFG table
@ 2019-04-10 14:27 ` Wei Yang
0 siblings, 0 replies; 289+ messages in thread
From: Wei Yang @ 2019-04-10 14:27 UTC (permalink / raw)
To: Igor Mammedov; +Cc: ehabkost, richardw.yang, qemu-devel, mst
On Tue, Apr 09, 2019 at 05:00:37PM +0200, Igor Mammedov wrote:
>Dummy table (with signature "QEMU") creation came from original SeaBIOS
>codebase. And QEMU would have to keep it around if there were Q35 machine
>that depended on keeping ACPI tables blob constant size. Luckily there
>were no versioned Q35 machine types before commit:
> (since 2.3) a1666142db acpi-build: make ROMs RAM blocks resizeable
>which obsoleted need to keep ACPI tables blob the same size on source/destination.
I think we should keep table blob the same size on source/destination.
But with resizable MemoryRegion, we don't need to reserve some dummy space.
Because we can expand it later.
>
>Considering the 1st versioned machine is pc-q35-2.4, the dummy table
>is not really necessary and it's safe to drop it without breaking
>cross version migration in both directions unconditionally.
>
>Signed-off-by: Igor Mammedov <imammedo@redhat.com>
>---
> hw/i386/acpi-build.c | 18 ++++--------------
> 1 file changed, 4 insertions(+), 14 deletions(-)
>
>diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
>index 416da31..8671e25 100644
>--- a/hw/i386/acpi-build.c
>+++ b/hw/i386/acpi-build.c
>@@ -2401,7 +2401,6 @@ static void
> build_mcfg_q35(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
> {
> AcpiTableMcfg *mcfg;
>- const char *sig;
> int len = sizeof(*mcfg) + 1 * sizeof(mcfg->allocation[0]);
>
> mcfg = acpi_data_push(table_data, len);
>@@ -2411,19 +2410,7 @@ build_mcfg_q35(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
> mcfg->allocation[0].start_bus_number = 0;
> mcfg->allocation[0].end_bus_number = PCIE_MMCFG_BUS(info->mcfg_size - 1);
>
>- /* MCFG is used for ECAM which can be enabled or disabled by guest.
I want to cnfirm what is "enabled or disabled by guest" here.
If we don't reserve mcfg and "guest" enable mcfg during running, the ACPI
table size changed. But the destination still has the original table size,
since destination "guest" keep sleep during this period.
Now the migration would face table size difference and break migration?
>- * To avoid table size changes (which create migration issues),
>- * always create the table even if there are no allocations,
>- * but set the signature to a reserved value in this case.
>- * ACPI spec requires OSPMs to ignore such tables.
>- */
>- if (info->mcfg_base == PCIE_BASE_ADDR_UNMAPPED) {
>- /* Reserved signature: ignored by OSPM */
>- sig = "QEMU";
>- } else {
>- sig = "MCFG";
>- }
>- build_header(linker, table_data, (void *)mcfg, sig, len, 1, NULL, NULL);
>+ build_header(linker, table_data, (void *)mcfg, "MCFG", len, 1, NULL, NULL);
> }
>
> /*
>@@ -2592,6 +2579,9 @@ static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg)
> }
> mcfg->mcfg_base = qnum_get_uint(qobject_to(QNum, o));
> qobject_unref(o);
>+ if (mcfg->mcfg_base == PCIE_BASE_ADDR_UNMAPPED) {
>+ return false;
>+ }
>
> o = object_property_get_qobject(pci_host, PCIE_HOST_MCFG_SIZE, NULL);
> assert(o);
>--
>2.7.4
--
Wei Yang
Help you, Help me
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH for-4.1] q35: acpi: do not create dummy MCFG table
@ 2019-04-10 15:01 ` Igor Mammedov
0 siblings, 0 replies; 289+ messages in thread
From: Igor Mammedov @ 2019-04-10 15:01 UTC (permalink / raw)
To: Wei Yang; +Cc: qemu-devel, mst, marcel.apfelbaum, ehabkost
On Wed, 10 Apr 2019 22:27:56 +0800
Wei Yang <richardw.yang@linux.intel.com> wrote:
[...]
> >@@ -2411,19 +2410,7 @@ build_mcfg_q35(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
> > mcfg->allocation[0].start_bus_number = 0;
> > mcfg->allocation[0].end_bus_number = PCIE_MMCFG_BUS(info->mcfg_size - 1);
> >
> >- /* MCFG is used for ECAM which can be enabled or disabled by guest.
>
> I want to cnfirm what is "enabled or disabled by guest" here.
Firmware theoretically during PCI initialization may disable ECAM support
and that's when we do no need MCFG. In practice that's not happening
(SeaBIOS or UEFI) but we in case there is out there a firmware that does
disable ECAM we do not generate MCFG.
Note:
ACPI tables generated twice, 1st when QEMU starts and the second time
when firmware accesses fwcfg to read blobs for the 1st time.
The later happens after PCI subsystem was initialized by firmware.
At that time we know if ECAM was enabled or not.
> If we don't reserve mcfg and "guest" enable mcfg during running, the ACPI
> table size changed. But the destination still has the original table size,
> since destination "guest" keep sleep during this period.
>
> Now the migration would face table size difference
with commit a1666142db we do not care as all the tables created on
source will be migrated to destination as is overwriting whatever blobs
destination created on startup.
> and break migration?
nope,
to help you figure out why it works
look at what following git commits did:
git log c8d6f66ae7..a1666142db
and pay attention to 'used_length'
>
> >- * To avoid table size changes (which create migration issues),
> >- * always create the table even if there are no allocations,
> >- * but set the signature to a reserved value in this case.
> >- * ACPI spec requires OSPMs to ignore such tables.
> >- */
> >- if (info->mcfg_base == PCIE_BASE_ADDR_UNMAPPED) {
> >- /* Reserved signature: ignored by OSPM */
> >- sig = "QEMU";
> >- } else {
> >- sig = "MCFG";
> >- }
> >- build_header(linker, table_data, (void *)mcfg, sig, len, 1, NULL, NULL);
> >+ build_header(linker, table_data, (void *)mcfg, "MCFG", len, 1, NULL, NULL);
> > }
> >
> > /*
> >@@ -2592,6 +2579,9 @@ static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg)
> > }
> > mcfg->mcfg_base = qnum_get_uint(qobject_to(QNum, o));
> > qobject_unref(o);
> >+ if (mcfg->mcfg_base == PCIE_BASE_ADDR_UNMAPPED) {
> >+ return false;
> >+ }
> >
> > o = object_property_get_qobject(pci_host, PCIE_HOST_MCFG_SIZE, NULL);
> > assert(o);
> >--
> >2.7.4
>
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH for-4.1] q35: acpi: do not create dummy MCFG table
@ 2019-04-10 15:01 ` Igor Mammedov
0 siblings, 0 replies; 289+ messages in thread
From: Igor Mammedov @ 2019-04-10 15:01 UTC (permalink / raw)
To: Wei Yang; +Cc: ehabkost, qemu-devel, mst
On Wed, 10 Apr 2019 22:27:56 +0800
Wei Yang <richardw.yang@linux.intel.com> wrote:
[...]
> >@@ -2411,19 +2410,7 @@ build_mcfg_q35(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
> > mcfg->allocation[0].start_bus_number = 0;
> > mcfg->allocation[0].end_bus_number = PCIE_MMCFG_BUS(info->mcfg_size - 1);
> >
> >- /* MCFG is used for ECAM which can be enabled or disabled by guest.
>
> I want to cnfirm what is "enabled or disabled by guest" here.
Firmware theoretically during PCI initialization may disable ECAM support
and that's when we do no need MCFG. In practice that's not happening
(SeaBIOS or UEFI) but we in case there is out there a firmware that does
disable ECAM we do not generate MCFG.
Note:
ACPI tables generated twice, 1st when QEMU starts and the second time
when firmware accesses fwcfg to read blobs for the 1st time.
The later happens after PCI subsystem was initialized by firmware.
At that time we know if ECAM was enabled or not.
> If we don't reserve mcfg and "guest" enable mcfg during running, the ACPI
> table size changed. But the destination still has the original table size,
> since destination "guest" keep sleep during this period.
>
> Now the migration would face table size difference
with commit a1666142db we do not care as all the tables created on
source will be migrated to destination as is overwriting whatever blobs
destination created on startup.
> and break migration?
nope,
to help you figure out why it works
look at what following git commits did:
git log c8d6f66ae7..a1666142db
and pay attention to 'used_length'
>
> >- * To avoid table size changes (which create migration issues),
> >- * always create the table even if there are no allocations,
> >- * but set the signature to a reserved value in this case.
> >- * ACPI spec requires OSPMs to ignore such tables.
> >- */
> >- if (info->mcfg_base == PCIE_BASE_ADDR_UNMAPPED) {
> >- /* Reserved signature: ignored by OSPM */
> >- sig = "QEMU";
> >- } else {
> >- sig = "MCFG";
> >- }
> >- build_header(linker, table_data, (void *)mcfg, sig, len, 1, NULL, NULL);
> >+ build_header(linker, table_data, (void *)mcfg, "MCFG", len, 1, NULL, NULL);
> > }
> >
> > /*
> >@@ -2592,6 +2579,9 @@ static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg)
> > }
> > mcfg->mcfg_base = qnum_get_uint(qobject_to(QNum, o));
> > qobject_unref(o);
> >+ if (mcfg->mcfg_base == PCIE_BASE_ADDR_UNMAPPED) {
> >+ return false;
> >+ }
> >
> > o = object_property_get_qobject(pci_host, PCIE_HOST_MCFG_SIZE, NULL);
> > assert(o);
> >--
> >2.7.4
>
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH for-4.1] q35: acpi: do not create dummy MCFG table
@ 2019-04-11 1:32 ` Wei Yang
0 siblings, 0 replies; 289+ messages in thread
From: Wei Yang @ 2019-04-11 1:32 UTC (permalink / raw)
To: Igor Mammedov; +Cc: Wei Yang, qemu-devel, mst, marcel.apfelbaum, ehabkost
On Wed, Apr 10, 2019 at 05:01:50PM +0200, Igor Mammedov wrote:
>On Wed, 10 Apr 2019 22:27:56 +0800
>Wei Yang <richardw.yang@linux.intel.com> wrote:
>
>[...]
>> >@@ -2411,19 +2410,7 @@ build_mcfg_q35(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
>> > mcfg->allocation[0].start_bus_number = 0;
>> > mcfg->allocation[0].end_bus_number = PCIE_MMCFG_BUS(info->mcfg_size - 1);
>> >
>> >- /* MCFG is used for ECAM which can be enabled or disabled by guest.
>>
>> I want to cnfirm what is "enabled or disabled by guest" here.
>
>Firmware theoretically during PCI initialization may disable ECAM support
>and that's when we do no need MCFG. In practice that's not happening
>(SeaBIOS or UEFI) but we in case there is out there a firmware that does
>disable ECAM we do not generate MCFG.
>
>Note:
>ACPI tables generated twice, 1st when QEMU starts and the second time
>when firmware accesses fwcfg to read blobs for the 1st time.
>The later happens after PCI subsystem was initialized by firmware.
>At that time we know if ECAM was enabled or not.
>
That's much clear, thanks :-)
So this is the guest BIOS instead of guest kernel who may disable/enable it.
>> If we don't reserve mcfg and "guest" enable mcfg during running, the ACPI
>> table size changed. But the destination still has the original table size,
>> since destination "guest" keep sleep during this period.
>>
>> Now the migration would face table size difference
>
>with commit a1666142db we do not care as all the tables created on
>source will be migrated to destination as is overwriting whatever blobs
>destination created on startup.
>
>> and break migration?
>nope,
>
>to help you figure out why it works
>look at what following git commits did:
> git log c8d6f66ae7..a1666142db
>and pay attention to 'used_length'
>
To be honest, this is what I feel confused in your previous reply.
First I want to confirm both fields in RAMBlock affects the migration:
* used_length
* max_length
Both of them should be the same on both source/destination, otherwise the
migration would fail.
Then I thought the migration would be broken if source/destination has
different knowledge about acpi table size. Because this will introduce
different value of used_length, even we have resizable MemoryRegion.
The 1st time ACPI generation flow:
acpi_add_rom_blob
rom_add_blob
rom_set_mr
memory_region_init_resizable_ram
qemu_ram_alloc_resizable
new_block->used_length = size
new_block->max_length = max_size
The 2nd time ACPI generation flow:
acpi_ram_update
memory_regioin_ram_resize
qemu_ram_resize
block->used_length = new_size
The max_length is always the same, while used_length would be changed to the
actual table_blob size.
In case source/destination has different knowledge about acpi table size, the
table_blob size(even after aligned) could be different.
This is why I thought there is still some chance to break migration after
resizable MemoryRegion.
Do I miss something?
--
Wei Yang
Help you, Help me
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH for-4.1] q35: acpi: do not create dummy MCFG table
@ 2019-04-11 1:32 ` Wei Yang
0 siblings, 0 replies; 289+ messages in thread
From: Wei Yang @ 2019-04-11 1:32 UTC (permalink / raw)
To: Igor Mammedov; +Cc: ehabkost, mst, Wei Yang, qemu-devel
On Wed, Apr 10, 2019 at 05:01:50PM +0200, Igor Mammedov wrote:
>On Wed, 10 Apr 2019 22:27:56 +0800
>Wei Yang <richardw.yang@linux.intel.com> wrote:
>
>[...]
>> >@@ -2411,19 +2410,7 @@ build_mcfg_q35(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
>> > mcfg->allocation[0].start_bus_number = 0;
>> > mcfg->allocation[0].end_bus_number = PCIE_MMCFG_BUS(info->mcfg_size - 1);
>> >
>> >- /* MCFG is used for ECAM which can be enabled or disabled by guest.
>>
>> I want to cnfirm what is "enabled or disabled by guest" here.
>
>Firmware theoretically during PCI initialization may disable ECAM support
>and that's when we do no need MCFG. In practice that's not happening
>(SeaBIOS or UEFI) but we in case there is out there a firmware that does
>disable ECAM we do not generate MCFG.
>
>Note:
>ACPI tables generated twice, 1st when QEMU starts and the second time
>when firmware accesses fwcfg to read blobs for the 1st time.
>The later happens after PCI subsystem was initialized by firmware.
>At that time we know if ECAM was enabled or not.
>
That's much clear, thanks :-)
So this is the guest BIOS instead of guest kernel who may disable/enable it.
>> If we don't reserve mcfg and "guest" enable mcfg during running, the ACPI
>> table size changed. But the destination still has the original table size,
>> since destination "guest" keep sleep during this period.
>>
>> Now the migration would face table size difference
>
>with commit a1666142db we do not care as all the tables created on
>source will be migrated to destination as is overwriting whatever blobs
>destination created on startup.
>
>> and break migration?
>nope,
>
>to help you figure out why it works
>look at what following git commits did:
> git log c8d6f66ae7..a1666142db
>and pay attention to 'used_length'
>
To be honest, this is what I feel confused in your previous reply.
First I want to confirm both fields in RAMBlock affects the migration:
* used_length
* max_length
Both of them should be the same on both source/destination, otherwise the
migration would fail.
Then I thought the migration would be broken if source/destination has
different knowledge about acpi table size. Because this will introduce
different value of used_length, even we have resizable MemoryRegion.
The 1st time ACPI generation flow:
acpi_add_rom_blob
rom_add_blob
rom_set_mr
memory_region_init_resizable_ram
qemu_ram_alloc_resizable
new_block->used_length = size
new_block->max_length = max_size
The 2nd time ACPI generation flow:
acpi_ram_update
memory_regioin_ram_resize
qemu_ram_resize
block->used_length = new_size
The max_length is always the same, while used_length would be changed to the
actual table_blob size.
In case source/destination has different knowledge about acpi table size, the
table_blob size(even after aligned) could be different.
This is why I thought there is still some chance to break migration after
resizable MemoryRegion.
Do I miss something?
--
Wei Yang
Help you, Help me
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH for-4.1] q35: acpi: do not create dummy MCFG table
@ 2019-04-11 11:46 ` Igor Mammedov
0 siblings, 0 replies; 289+ messages in thread
From: Igor Mammedov @ 2019-04-11 11:46 UTC (permalink / raw)
To: Wei Yang; +Cc: qemu-devel, mst, marcel.apfelbaum, ehabkost
On Thu, 11 Apr 2019 09:32:11 +0800
Wei Yang <richardw.yang@linux.intel.com> wrote:
> On Wed, Apr 10, 2019 at 05:01:50PM +0200, Igor Mammedov wrote:
> >On Wed, 10 Apr 2019 22:27:56 +0800
> >Wei Yang <richardw.yang@linux.intel.com> wrote:
> >
> >[...]
> >> >@@ -2411,19 +2410,7 @@ build_mcfg_q35(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
> >> > mcfg->allocation[0].start_bus_number = 0;
> >> > mcfg->allocation[0].end_bus_number = PCIE_MMCFG_BUS(info->mcfg_size - 1);
> >> >
> >> >- /* MCFG is used for ECAM which can be enabled or disabled by guest.
> >>
> >> I want to cnfirm what is "enabled or disabled by guest" here.
> >
> >Firmware theoretically during PCI initialization may disable ECAM support
> >and that's when we do no need MCFG. In practice that's not happening
> >(SeaBIOS or UEFI) but we in case there is out there a firmware that does
> >disable ECAM we do not generate MCFG.
> >
> >Note:
> >ACPI tables generated twice, 1st when QEMU starts and the second time
> >when firmware accesses fwcfg to read blobs for the 1st time.
> >The later happens after PCI subsystem was initialized by firmware.
> >At that time we know if ECAM was enabled or not.
> >
>
> That's much clear, thanks :-)
>
> So this is the guest BIOS instead of guest kernel who may disable/enable it.
>
> >> If we don't reserve mcfg and "guest" enable mcfg during running, the ACPI
> >> table size changed. But the destination still has the original table size,
> >> since destination "guest" keep sleep during this period.
> >>
> >> Now the migration would face table size difference
> >
> >with commit a1666142db we do not care as all the tables created on
> >source will be migrated to destination as is overwriting whatever blobs
> >destination created on startup.
> >
> >> and break migration?
> >nope,
> >
> >to help you figure out why it works
> >look at what following git commits did:
> > git log c8d6f66ae7..a1666142db
> >and pay attention to 'used_length'
> >
>
> To be honest, this is what I feel confused in your previous reply.
>
> First I want to confirm both fields in RAMBlock affects the migration:
>
> * used_length
> * max_length
>
> Both of them should be the same on both source/destination, otherwise the
> migration would fail.
well, it works fine for me.
Where do you see max_length being used during migration?
> Then I thought the migration would be broken if source/destination has
> different knowledge about acpi table size. Because this will introduce
> different value of used_length, even we have resizable MemoryRegion.
>
> The 1st time ACPI generation flow:
>
> acpi_add_rom_blob
> rom_add_blob
> rom_set_mr
> memory_region_init_resizable_ram
> qemu_ram_alloc_resizable
> new_block->used_length = size
> new_block->max_length = max_size
>
> The 2nd time ACPI generation flow:
>
> acpi_ram_update
> memory_regioin_ram_resize
> qemu_ram_resize
> block->used_length = new_size
>
> The max_length is always the same, while used_length would be changed to the
> actual table_blob size.
>
> In case source/destination has different knowledge about acpi table size, the
> table_blob size(even after aligned) could be different.
>
> This is why I thought there is still some chance to break migration after
> resizable MemoryRegion.
>
> Do I miss something?
yes, you did, max_length does not influence migration stream.
see what above mentioned commits and ram_load() -> "if (length != block->used_length)" do.
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH for-4.1] q35: acpi: do not create dummy MCFG table
@ 2019-04-11 11:46 ` Igor Mammedov
0 siblings, 0 replies; 289+ messages in thread
From: Igor Mammedov @ 2019-04-11 11:46 UTC (permalink / raw)
To: Wei Yang; +Cc: ehabkost, qemu-devel, mst
On Thu, 11 Apr 2019 09:32:11 +0800
Wei Yang <richardw.yang@linux.intel.com> wrote:
> On Wed, Apr 10, 2019 at 05:01:50PM +0200, Igor Mammedov wrote:
> >On Wed, 10 Apr 2019 22:27:56 +0800
> >Wei Yang <richardw.yang@linux.intel.com> wrote:
> >
> >[...]
> >> >@@ -2411,19 +2410,7 @@ build_mcfg_q35(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
> >> > mcfg->allocation[0].start_bus_number = 0;
> >> > mcfg->allocation[0].end_bus_number = PCIE_MMCFG_BUS(info->mcfg_size - 1);
> >> >
> >> >- /* MCFG is used for ECAM which can be enabled or disabled by guest.
> >>
> >> I want to cnfirm what is "enabled or disabled by guest" here.
> >
> >Firmware theoretically during PCI initialization may disable ECAM support
> >and that's when we do no need MCFG. In practice that's not happening
> >(SeaBIOS or UEFI) but we in case there is out there a firmware that does
> >disable ECAM we do not generate MCFG.
> >
> >Note:
> >ACPI tables generated twice, 1st when QEMU starts and the second time
> >when firmware accesses fwcfg to read blobs for the 1st time.
> >The later happens after PCI subsystem was initialized by firmware.
> >At that time we know if ECAM was enabled or not.
> >
>
> That's much clear, thanks :-)
>
> So this is the guest BIOS instead of guest kernel who may disable/enable it.
>
> >> If we don't reserve mcfg and "guest" enable mcfg during running, the ACPI
> >> table size changed. But the destination still has the original table size,
> >> since destination "guest" keep sleep during this period.
> >>
> >> Now the migration would face table size difference
> >
> >with commit a1666142db we do not care as all the tables created on
> >source will be migrated to destination as is overwriting whatever blobs
> >destination created on startup.
> >
> >> and break migration?
> >nope,
> >
> >to help you figure out why it works
> >look at what following git commits did:
> > git log c8d6f66ae7..a1666142db
> >and pay attention to 'used_length'
> >
>
> To be honest, this is what I feel confused in your previous reply.
>
> First I want to confirm both fields in RAMBlock affects the migration:
>
> * used_length
> * max_length
>
> Both of them should be the same on both source/destination, otherwise the
> migration would fail.
well, it works fine for me.
Where do you see max_length being used during migration?
> Then I thought the migration would be broken if source/destination has
> different knowledge about acpi table size. Because this will introduce
> different value of used_length, even we have resizable MemoryRegion.
>
> The 1st time ACPI generation flow:
>
> acpi_add_rom_blob
> rom_add_blob
> rom_set_mr
> memory_region_init_resizable_ram
> qemu_ram_alloc_resizable
> new_block->used_length = size
> new_block->max_length = max_size
>
> The 2nd time ACPI generation flow:
>
> acpi_ram_update
> memory_regioin_ram_resize
> qemu_ram_resize
> block->used_length = new_size
>
> The max_length is always the same, while used_length would be changed to the
> actual table_blob size.
>
> In case source/destination has different knowledge about acpi table size, the
> table_blob size(even after aligned) could be different.
>
> This is why I thought there is still some chance to break migration after
> resizable MemoryRegion.
>
> Do I miss something?
yes, you did, max_length does not influence migration stream.
see what above mentioned commits and ram_load() -> "if (length != block->used_length)" do.
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH for-4.1] q35: acpi: do not create dummy MCFG table
@ 2019-04-11 22:15 ` Wei Yang
0 siblings, 0 replies; 289+ messages in thread
From: Wei Yang @ 2019-04-11 22:15 UTC (permalink / raw)
To: Igor Mammedov; +Cc: Wei Yang, ehabkost, qemu-devel, mst
On Thu, Apr 11, 2019 at 01:46:27PM +0200, Igor Mammedov wrote:
>On Thu, 11 Apr 2019 09:32:11 +0800
>Wei Yang <richardw.yang@linux.intel.com> wrote:
>
[...]
>> To be honest, this is what I feel confused in your previous reply.
>>
>> First I want to confirm both fields in RAMBlock affects the migration:
>>
>> * used_length
>> * max_length
>>
>> Both of them should be the same on both source/destination, otherwise the
>> migration would fail.
>well, it works fine for me.
>Where do you see max_length being used during migration?
>
I asked my colleague, but seems you are right.
>
>> Then I thought the migration would be broken if source/destination has
>> different knowledge about acpi table size. Because this will introduce
>> different value of used_length, even we have resizable MemoryRegion.
>>
>> The 1st time ACPI generation flow:
>>
>> acpi_add_rom_blob
>> rom_add_blob
>> rom_set_mr
>> memory_region_init_resizable_ram
>> qemu_ram_alloc_resizable
>> new_block->used_length = size
>> new_block->max_length = max_size
>>
>> The 2nd time ACPI generation flow:
>>
>> acpi_ram_update
>> memory_regioin_ram_resize
>> qemu_ram_resize
>> block->used_length = new_size
>>
>> The max_length is always the same, while used_length would be changed to the
>> actual table_blob size.
>>
>> In case source/destination has different knowledge about acpi table size, the
>> table_blob size(even after aligned) could be different.
>>
>> This is why I thought there is still some chance to break migration after
>> resizable MemoryRegion.
>>
>> Do I miss something?
>yes, you did, max_length does not influence migration stream.
>see what above mentioned commits and ram_load() -> "if (length != block->used_length)" do.
>
I see this in the code.
So the destination will check length and adjust self's length if it
doesn't equal to the source.
Thanks :-)
--
Wei Yang
Help you, Help me
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH for-4.1] q35: acpi: do not create dummy MCFG table
@ 2019-04-11 22:15 ` Wei Yang
0 siblings, 0 replies; 289+ messages in thread
From: Wei Yang @ 2019-04-11 22:15 UTC (permalink / raw)
To: Igor Mammedov; +Cc: qemu-devel, mst, Wei Yang, ehabkost
On Thu, Apr 11, 2019 at 01:46:27PM +0200, Igor Mammedov wrote:
>On Thu, 11 Apr 2019 09:32:11 +0800
>Wei Yang <richardw.yang@linux.intel.com> wrote:
>
[...]
>> To be honest, this is what I feel confused in your previous reply.
>>
>> First I want to confirm both fields in RAMBlock affects the migration:
>>
>> * used_length
>> * max_length
>>
>> Both of them should be the same on both source/destination, otherwise the
>> migration would fail.
>well, it works fine for me.
>Where do you see max_length being used during migration?
>
I asked my colleague, but seems you are right.
>
>> Then I thought the migration would be broken if source/destination has
>> different knowledge about acpi table size. Because this will introduce
>> different value of used_length, even we have resizable MemoryRegion.
>>
>> The 1st time ACPI generation flow:
>>
>> acpi_add_rom_blob
>> rom_add_blob
>> rom_set_mr
>> memory_region_init_resizable_ram
>> qemu_ram_alloc_resizable
>> new_block->used_length = size
>> new_block->max_length = max_size
>>
>> The 2nd time ACPI generation flow:
>>
>> acpi_ram_update
>> memory_regioin_ram_resize
>> qemu_ram_resize
>> block->used_length = new_size
>>
>> The max_length is always the same, while used_length would be changed to the
>> actual table_blob size.
>>
>> In case source/destination has different knowledge about acpi table size, the
>> table_blob size(even after aligned) could be different.
>>
>> This is why I thought there is still some chance to break migration after
>> resizable MemoryRegion.
>>
>> Do I miss something?
>yes, you did, max_length does not influence migration stream.
>see what above mentioned commits and ram_load() -> "if (length != block->used_length)" do.
>
I see this in the code.
So the destination will check length and adjust self's length if it
doesn't equal to the source.
Thanks :-)
--
Wei Yang
Help you, Help me
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH for-4.1] q35: acpi: do not create dummy MCFG table
@ 2019-04-11 22:16 ` Wei Yang
0 siblings, 0 replies; 289+ messages in thread
From: Wei Yang @ 2019-04-11 22:16 UTC (permalink / raw)
To: Igor Mammedov; +Cc: qemu-devel, richardw.yang, ehabkost, mst
On Tue, Apr 09, 2019 at 05:00:37PM +0200, Igor Mammedov wrote:
>Dummy table (with signature "QEMU") creation came from original SeaBIOS
>codebase. And QEMU would have to keep it around if there were Q35 machine
>that depended on keeping ACPI tables blob constant size. Luckily there
>were no versioned Q35 machine types before commit:
> (since 2.3) a1666142db acpi-build: make ROMs RAM blocks resizeable
>which obsoleted need to keep ACPI tables blob the same size on source/destination.
>
>Considering the 1st versioned machine is pc-q35-2.4, the dummy table
>is not really necessary and it's safe to drop it without breaking
>cross version migration in both directions unconditionally.
>
>Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Wei Yang <richardw.yang@linux.intel.com>
>---
> hw/i386/acpi-build.c | 18 ++++--------------
> 1 file changed, 4 insertions(+), 14 deletions(-)
>
>diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
>index 416da31..8671e25 100644
>--- a/hw/i386/acpi-build.c
>+++ b/hw/i386/acpi-build.c
>@@ -2401,7 +2401,6 @@ static void
> build_mcfg_q35(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
> {
> AcpiTableMcfg *mcfg;
>- const char *sig;
> int len = sizeof(*mcfg) + 1 * sizeof(mcfg->allocation[0]);
>
> mcfg = acpi_data_push(table_data, len);
>@@ -2411,19 +2410,7 @@ build_mcfg_q35(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
> mcfg->allocation[0].start_bus_number = 0;
> mcfg->allocation[0].end_bus_number = PCIE_MMCFG_BUS(info->mcfg_size - 1);
>
>- /* MCFG is used for ECAM which can be enabled or disabled by guest.
>- * To avoid table size changes (which create migration issues),
>- * always create the table even if there are no allocations,
>- * but set the signature to a reserved value in this case.
>- * ACPI spec requires OSPMs to ignore such tables.
>- */
>- if (info->mcfg_base == PCIE_BASE_ADDR_UNMAPPED) {
>- /* Reserved signature: ignored by OSPM */
>- sig = "QEMU";
>- } else {
>- sig = "MCFG";
>- }
>- build_header(linker, table_data, (void *)mcfg, sig, len, 1, NULL, NULL);
>+ build_header(linker, table_data, (void *)mcfg, "MCFG", len, 1, NULL, NULL);
> }
>
> /*
>@@ -2592,6 +2579,9 @@ static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg)
> }
> mcfg->mcfg_base = qnum_get_uint(qobject_to(QNum, o));
> qobject_unref(o);
>+ if (mcfg->mcfg_base == PCIE_BASE_ADDR_UNMAPPED) {
>+ return false;
>+ }
>
> o = object_property_get_qobject(pci_host, PCIE_HOST_MCFG_SIZE, NULL);
> assert(o);
>--
>2.7.4
>
--
Wei Yang
Help you, Help me
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH for-4.1] q35: acpi: do not create dummy MCFG table
@ 2019-04-11 22:16 ` Wei Yang
0 siblings, 0 replies; 289+ messages in thread
From: Wei Yang @ 2019-04-11 22:16 UTC (permalink / raw)
To: Igor Mammedov; +Cc: mst, qemu-devel, ehabkost, richardw.yang
On Tue, Apr 09, 2019 at 05:00:37PM +0200, Igor Mammedov wrote:
>Dummy table (with signature "QEMU") creation came from original SeaBIOS
>codebase. And QEMU would have to keep it around if there were Q35 machine
>that depended on keeping ACPI tables blob constant size. Luckily there
>were no versioned Q35 machine types before commit:
> (since 2.3) a1666142db acpi-build: make ROMs RAM blocks resizeable
>which obsoleted need to keep ACPI tables blob the same size on source/destination.
>
>Considering the 1st versioned machine is pc-q35-2.4, the dummy table
>is not really necessary and it's safe to drop it without breaking
>cross version migration in both directions unconditionally.
>
>Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Wei Yang <richardw.yang@linux.intel.com>
>---
> hw/i386/acpi-build.c | 18 ++++--------------
> 1 file changed, 4 insertions(+), 14 deletions(-)
>
>diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
>index 416da31..8671e25 100644
>--- a/hw/i386/acpi-build.c
>+++ b/hw/i386/acpi-build.c
>@@ -2401,7 +2401,6 @@ static void
> build_mcfg_q35(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
> {
> AcpiTableMcfg *mcfg;
>- const char *sig;
> int len = sizeof(*mcfg) + 1 * sizeof(mcfg->allocation[0]);
>
> mcfg = acpi_data_push(table_data, len);
>@@ -2411,19 +2410,7 @@ build_mcfg_q35(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
> mcfg->allocation[0].start_bus_number = 0;
> mcfg->allocation[0].end_bus_number = PCIE_MMCFG_BUS(info->mcfg_size - 1);
>
>- /* MCFG is used for ECAM which can be enabled or disabled by guest.
>- * To avoid table size changes (which create migration issues),
>- * always create the table even if there are no allocations,
>- * but set the signature to a reserved value in this case.
>- * ACPI spec requires OSPMs to ignore such tables.
>- */
>- if (info->mcfg_base == PCIE_BASE_ADDR_UNMAPPED) {
>- /* Reserved signature: ignored by OSPM */
>- sig = "QEMU";
>- } else {
>- sig = "MCFG";
>- }
>- build_header(linker, table_data, (void *)mcfg, sig, len, 1, NULL, NULL);
>+ build_header(linker, table_data, (void *)mcfg, "MCFG", len, 1, NULL, NULL);
> }
>
> /*
>@@ -2592,6 +2579,9 @@ static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg)
> }
> mcfg->mcfg_base = qnum_get_uint(qobject_to(QNum, o));
> qobject_unref(o);
>+ if (mcfg->mcfg_base == PCIE_BASE_ADDR_UNMAPPED) {
>+ return false;
>+ }
>
> o = object_property_get_qobject(pci_host, PCIE_HOST_MCFG_SIZE, NULL);
> assert(o);
>--
>2.7.4
>
--
Wei Yang
Help you, Help me
^ permalink raw reply [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH 0/2] vhost-user race condition on shutdown
@ 2019-04-16 18:46 Dan Streetman
2019-04-16 18:46 ` [Qemu-devel] [PATCH 1/2] add VirtIONet vhost_stopped flag to prevent multiple stops Dan Streetman
` (2 more replies)
0 siblings, 3 replies; 289+ messages in thread
From: Dan Streetman @ 2019-04-16 18:46 UTC (permalink / raw)
To: Michael S. Tsirkin, Jason Wang, qemu-devel, qemu-stable
From: Dan Streetman <ddstreet@canonical.com>
Buglink: https://launchpad.net/bugs/1823458
This is a race condition between the normal shutdown of a guest
and the handling of its vhost-user net being externally closed.
It's explained in more detail at the bug link; the short version
is that there are 2 problems, fixed by the 2 patches. The first
patch fixes the race condition where multiple threads call
vhost_net_stop(), and the second patch prevents vhost-user from
calling vhost_net_cleanup() on CHR_EVENT_CLOSED, because it will
be cleaned up later and its fields will be accessed when
vhost_net_stop() is called later.
As explained in the bug report, this requires a rather complicated
setup to reproduce, and I'm not able to create a setup to reproduce
it myself. However this has been reported to me/Canonical, and the
reporter is able to reproduce it consistently, so I've used them for
debug and testing. This reproduction was done with the older 2.5
qemu, from Ubuntu Xenial; but the problem does still appear to exist
in upstream qemu, based on review of the code, which is why I'm sending
these patches.
Dan Streetman (2):
add VirtIONet vhost_stopped flag to prevent multiple stops
do not call vhost_net_cleanup() on running net from char user event
hw/net/virtio-net.c | 3 ++-
include/hw/virtio/virtio-net.h | 1 +
net/vhost-user.c | 1 -
3 files changed, 3 insertions(+), 2 deletions(-)
--
2.20.1
^ permalink raw reply [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH 1/2] add VirtIONet vhost_stopped flag to prevent multiple stops
2019-04-16 18:46 [Qemu-devel] [PATCH 0/2] vhost-user race condition on shutdown Dan Streetman
@ 2019-04-16 18:46 ` Dan Streetman
2019-04-19 23:14 ` Michael S. Tsirkin
2019-04-22 2:50 ` Jason Wang
2019-05-16 12:19 ` [Qemu-devel] [PULL 15/37] " Michael S. Tsirkin
2019-04-19 23:12 ` Michael S. Tsirkin
2 siblings, 2 replies; 289+ messages in thread
From: Dan Streetman @ 2019-04-16 18:46 UTC (permalink / raw)
To: Michael S. Tsirkin, Jason Wang, qemu-devel, qemu-stable
From: Dan Streetman <ddstreet@canonical.com>
Buglink: https://launchpad.net/bugs/1823458
There is a race condition when using the vhost-user driver, between a guest
shutdown and the vhost-user interface being closed. This is explained in
more detail at the bug link above; the short explanation is the vhost-user
device can be closed while the main thread is in the middle of stopping
the vhost_net. In this case, the main thread handling shutdown will
enter virtio_net_vhost_status() and move into the n->vhost_started (else)
block, and call vhost_net_stop(); while it is running that function,
another thread is notified that the vhost-user device has been closed,
and (indirectly) calls into virtio_net_vhost_status() also. Since the
vhost_net status hasn't yet changed, the second thread also enters
the n->vhost_started block, and also calls vhost_net_stop(). This
causes problems for the second thread when it tries to stop the network
that's already been stopped.
This adds a flag to the struct that's atomically set to prevent more than
one thread from calling vhost_net_stop(). The atomic_fetch_inc() is likely
overkill and probably could be done with a simple check-and-set, but
since it's a race condition there would still be a (very, very) small
window without using an atomic to set it.
Signed-off-by: Dan Streetman <ddstreet@canonical.com>
---
hw/net/virtio-net.c | 3 ++-
include/hw/virtio/virtio-net.h | 1 +
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index ffe0872fff..d36f50d5dd 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -13,6 +13,7 @@
#include "qemu/osdep.h"
#include "qemu/iov.h"
+#include "qemu/atomic.h"
#include "hw/virtio/virtio.h"
#include "net/net.h"
#include "net/checksum.h"
@@ -240,7 +241,7 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status)
"falling back on userspace virtio", -r);
n->vhost_started = 0;
}
- } else {
+ } else if (atomic_fetch_inc(&n->vhost_stopped) == 0) {
vhost_net_stop(vdev, n->nic->ncs, queues);
n->vhost_started = 0;
}
diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h
index b96f0c643f..d03fd933d0 100644
--- a/include/hw/virtio/virtio-net.h
+++ b/include/hw/virtio/virtio-net.h
@@ -164,6 +164,7 @@ struct VirtIONet {
uint8_t nouni;
uint8_t nobcast;
uint8_t vhost_started;
+ int vhost_stopped;
struct {
uint32_t in_use;
uint32_t first_multi;
--
2.20.1
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH 2/2] do not call vhost_net_cleanup() on running net from char user event
@ 2019-05-16 12:19 ` Michael S. Tsirkin
0 siblings, 0 replies; 289+ messages in thread
From: Dan Streetman @ 2019-04-16 18:46 UTC (permalink / raw)
To: Michael S. Tsirkin, Jason Wang, qemu-devel, qemu-stable
From: Dan Streetman <ddstreet@canonical.com>
Buglink: https://launchpad.net/bugs/1823458
Currently, a user CHR_EVENT_CLOSED event will cause net_vhost_user_event()
to call vhost_user_cleanup(), which calls vhost_net_cleanup() for all
its queues. However, vhost_net_cleanup() must never be called like
this for fully-initialized nets; when other code later calls
vhost_net_stop() - such as from virtio_net_vhost_status() - it will try
to access the already-cleaned-up fields and fail with assertion errors
or segfaults.
The vhost_net_cleanup() will eventually be called from
qemu_cleanup_net_client().
Signed-off-by: Dan Streetman <ddstreet@canonical.com>
---
net/vhost-user.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/net/vhost-user.c b/net/vhost-user.c
index 5a26a24708..51921de443 100644
--- a/net/vhost-user.c
+++ b/net/vhost-user.c
@@ -236,7 +236,6 @@ static void chr_closed_bh(void *opaque)
s = DO_UPCAST(NetVhostUserState, nc, ncs[0]);
qmp_set_link(name, false, &err);
- vhost_user_stop(queues, ncs);
qemu_chr_fe_set_handlers(&s->chr, NULL, NULL, net_vhost_user_event,
NULL, opaque, NULL, true);
--
2.20.1
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v4 0/6] Extract build_mcfg
@ 2019-04-19 0:30 ` Wei Yang
0 siblings, 0 replies; 289+ messages in thread
From: Wei Yang @ 2019-04-19 0:30 UTC (permalink / raw)
To: qemu-devel, qemu-arm
Cc: mst, imammedo, shannon.zhaosl, peter.maydell, marcel.apfelbaum,
yang.zhong, philmd, Wei Yang
This patch set tries to generalize MCFG table build process. And it is
based on one un-merged patch from Igor, which is included in this serials.
v3->v4:
* adjust comment to give more information about MCFG table
v2->v3:
* Includes the un-merged patch from Igor
* use build_append_foo() API to construct MCFG
Igor Mammedov (1):
q35: acpi: do not create dummy MCFG table
Wei Yang (5):
hw/arm/virt-acpi-build: remove unnecessary variable mcfg_start
i386, acpi: remove mcfg_ prefix in AcpiMcfgInfo members
hw/arm/virt-acpi-build: pass AcpiMcfgInfo to build_mcfg()
hw/acpi: Consolidate build_mcfg to pci.c
acpi: pci: use build_append_foo() API to construct MCFG
default-configs/arm-softmmu.mak | 1 +
default-configs/i386-softmmu.mak | 1 +
hw/acpi/Kconfig | 4 +++
hw/acpi/Makefile.objs | 1 +
hw/acpi/pci.c | 55 ++++++++++++++++++++++++++++++++
hw/arm/virt-acpi-build.c | 31 +++++-------------
hw/i386/acpi-build.c | 44 ++++---------------------
include/hw/acpi/acpi-defs.h | 18 -----------
include/hw/acpi/pci.h | 34 ++++++++++++++++++++
9 files changed, 111 insertions(+), 78 deletions(-)
create mode 100644 hw/acpi/pci.c
create mode 100644 include/hw/acpi/pci.h
--
2.19.1
^ permalink raw reply [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v4 0/6] Extract build_mcfg
@ 2019-04-19 0:30 ` Wei Yang
0 siblings, 0 replies; 289+ messages in thread
From: Wei Yang @ 2019-04-19 0:30 UTC (permalink / raw)
To: qemu-devel, qemu-arm
Cc: yang.zhong, peter.maydell, mst, shannon.zhaosl, Wei Yang,
imammedo, philmd
This patch set tries to generalize MCFG table build process. And it is
based on one un-merged patch from Igor, which is included in this serials.
v3->v4:
* adjust comment to give more information about MCFG table
v2->v3:
* Includes the un-merged patch from Igor
* use build_append_foo() API to construct MCFG
Igor Mammedov (1):
q35: acpi: do not create dummy MCFG table
Wei Yang (5):
hw/arm/virt-acpi-build: remove unnecessary variable mcfg_start
i386, acpi: remove mcfg_ prefix in AcpiMcfgInfo members
hw/arm/virt-acpi-build: pass AcpiMcfgInfo to build_mcfg()
hw/acpi: Consolidate build_mcfg to pci.c
acpi: pci: use build_append_foo() API to construct MCFG
default-configs/arm-softmmu.mak | 1 +
default-configs/i386-softmmu.mak | 1 +
hw/acpi/Kconfig | 4 +++
hw/acpi/Makefile.objs | 1 +
hw/acpi/pci.c | 55 ++++++++++++++++++++++++++++++++
hw/arm/virt-acpi-build.c | 31 +++++-------------
hw/i386/acpi-build.c | 44 ++++---------------------
include/hw/acpi/acpi-defs.h | 18 -----------
include/hw/acpi/pci.h | 34 ++++++++++++++++++++
9 files changed, 111 insertions(+), 78 deletions(-)
create mode 100644 hw/acpi/pci.c
create mode 100644 include/hw/acpi/pci.h
--
2.19.1
^ permalink raw reply [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v4 1/6] q35: acpi: do not create dummy MCFG table
@ 2019-04-19 0:30 ` Wei Yang
0 siblings, 0 replies; 289+ messages in thread
From: Wei Yang @ 2019-04-19 0:30 UTC (permalink / raw)
To: qemu-devel, qemu-arm
Cc: mst, imammedo, shannon.zhaosl, peter.maydell, marcel.apfelbaum,
yang.zhong, philmd, Wei Yang
From: Igor Mammedov <imammedo@redhat.com>
Dummy table (with signature "QEMU") creation came from original SeaBIOS
codebase. And QEMU would have to keep it around if there were Q35 machine
that depended on keeping ACPI tables blob constant size. Luckily there
were no versioned Q35 machine types before commit:
(since 2.3) a1666142db acpi-build: make ROMs RAM blocks resizeable
which obsoleted need to keep ACPI tables blob the same size on source/destination.
Considering the 1st versioned machine is pc-q35-2.4, the dummy table
is not really necessary and it's safe to drop it without breaking
cross version migration in both directions unconditionally.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
hw/i386/acpi-build.c | 18 ++++--------------
1 file changed, 4 insertions(+), 14 deletions(-)
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index b17d4a711d..d009176072 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -2401,7 +2401,6 @@ static void
build_mcfg_q35(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
{
AcpiTableMcfg *mcfg;
- const char *sig;
int len = sizeof(*mcfg) + 1 * sizeof(mcfg->allocation[0]);
mcfg = acpi_data_push(table_data, len);
@@ -2411,19 +2410,7 @@ build_mcfg_q35(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
mcfg->allocation[0].start_bus_number = 0;
mcfg->allocation[0].end_bus_number = PCIE_MMCFG_BUS(info->mcfg_size - 1);
- /* MCFG is used for ECAM which can be enabled or disabled by guest.
- * To avoid table size changes (which create migration issues),
- * always create the table even if there are no allocations,
- * but set the signature to a reserved value in this case.
- * ACPI spec requires OSPMs to ignore such tables.
- */
- if (info->mcfg_base == PCIE_BASE_ADDR_UNMAPPED) {
- /* Reserved signature: ignored by OSPM */
- sig = "QEMU";
- } else {
- sig = "MCFG";
- }
- build_header(linker, table_data, (void *)mcfg, sig, len, 1, NULL, NULL);
+ build_header(linker, table_data, (void *)mcfg, "MCFG", len, 1, NULL, NULL);
}
/*
@@ -2592,6 +2579,9 @@ static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg)
}
mcfg->mcfg_base = qnum_get_uint(qobject_to(QNum, o));
qobject_unref(o);
+ if (mcfg->mcfg_base == PCIE_BASE_ADDR_UNMAPPED) {
+ return false;
+ }
o = object_property_get_qobject(pci_host, PCIE_HOST_MCFG_SIZE, NULL);
assert(o);
--
2.19.1
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v4 1/6] q35: acpi: do not create dummy MCFG table
@ 2019-04-19 0:30 ` Wei Yang
0 siblings, 0 replies; 289+ messages in thread
From: Wei Yang @ 2019-04-19 0:30 UTC (permalink / raw)
To: qemu-devel, qemu-arm
Cc: yang.zhong, peter.maydell, mst, shannon.zhaosl, Wei Yang,
imammedo, philmd
From: Igor Mammedov <imammedo@redhat.com>
Dummy table (with signature "QEMU") creation came from original SeaBIOS
codebase. And QEMU would have to keep it around if there were Q35 machine
that depended on keeping ACPI tables blob constant size. Luckily there
were no versioned Q35 machine types before commit:
(since 2.3) a1666142db acpi-build: make ROMs RAM blocks resizeable
which obsoleted need to keep ACPI tables blob the same size on source/destination.
Considering the 1st versioned machine is pc-q35-2.4, the dummy table
is not really necessary and it's safe to drop it without breaking
cross version migration in both directions unconditionally.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
hw/i386/acpi-build.c | 18 ++++--------------
1 file changed, 4 insertions(+), 14 deletions(-)
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index b17d4a711d..d009176072 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -2401,7 +2401,6 @@ static void
build_mcfg_q35(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
{
AcpiTableMcfg *mcfg;
- const char *sig;
int len = sizeof(*mcfg) + 1 * sizeof(mcfg->allocation[0]);
mcfg = acpi_data_push(table_data, len);
@@ -2411,19 +2410,7 @@ build_mcfg_q35(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
mcfg->allocation[0].start_bus_number = 0;
mcfg->allocation[0].end_bus_number = PCIE_MMCFG_BUS(info->mcfg_size - 1);
- /* MCFG is used for ECAM which can be enabled or disabled by guest.
- * To avoid table size changes (which create migration issues),
- * always create the table even if there are no allocations,
- * but set the signature to a reserved value in this case.
- * ACPI spec requires OSPMs to ignore such tables.
- */
- if (info->mcfg_base == PCIE_BASE_ADDR_UNMAPPED) {
- /* Reserved signature: ignored by OSPM */
- sig = "QEMU";
- } else {
- sig = "MCFG";
- }
- build_header(linker, table_data, (void *)mcfg, sig, len, 1, NULL, NULL);
+ build_header(linker, table_data, (void *)mcfg, "MCFG", len, 1, NULL, NULL);
}
/*
@@ -2592,6 +2579,9 @@ static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg)
}
mcfg->mcfg_base = qnum_get_uint(qobject_to(QNum, o));
qobject_unref(o);
+ if (mcfg->mcfg_base == PCIE_BASE_ADDR_UNMAPPED) {
+ return false;
+ }
o = object_property_get_qobject(pci_host, PCIE_HOST_MCFG_SIZE, NULL);
assert(o);
--
2.19.1
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v4 2/6] hw/arm/virt-acpi-build: remove unnecessary variable mcfg_start
@ 2019-04-19 0:30 ` Wei Yang
0 siblings, 0 replies; 289+ messages in thread
From: Wei Yang @ 2019-04-19 0:30 UTC (permalink / raw)
To: qemu-devel, qemu-arm
Cc: mst, imammedo, shannon.zhaosl, peter.maydell, marcel.apfelbaum,
yang.zhong, philmd, Wei Yang
mcfg_start points to the start of MCFG table and is used in
build_header. While this information could be derived from mcfg.
This patch removes the unnecessary variable mcfg_start.
Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
hw/arm/virt-acpi-build.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index 857989362a..e09e7eff8d 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -552,7 +552,6 @@ build_mcfg(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
const MemMapEntry *memmap = vms->memmap;
int ecam_id = VIRT_ECAM_ID(vms->highmem_ecam);
int len = sizeof(*mcfg) + sizeof(mcfg->allocation[0]);
- int mcfg_start = table_data->len;
mcfg = acpi_data_push(table_data, len);
mcfg->allocation[0].address = cpu_to_le64(memmap[ecam_id].base);
@@ -563,8 +562,7 @@ build_mcfg(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
mcfg->allocation[0].end_bus_number =
PCIE_MMCFG_BUS(memmap[ecam_id].size - 1);
- build_header(linker, table_data, (void *)(table_data->data + mcfg_start),
- "MCFG", table_data->len - mcfg_start, 1, NULL, NULL);
+ build_header(linker, table_data, (void *)mcfg, "MCFG", len, 1, NULL, NULL);
}
/* GTDT */
--
2.19.1
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v4 2/6] hw/arm/virt-acpi-build: remove unnecessary variable mcfg_start
@ 2019-04-19 0:30 ` Wei Yang
0 siblings, 0 replies; 289+ messages in thread
From: Wei Yang @ 2019-04-19 0:30 UTC (permalink / raw)
To: qemu-devel, qemu-arm
Cc: yang.zhong, peter.maydell, mst, shannon.zhaosl, Wei Yang,
imammedo, philmd
mcfg_start points to the start of MCFG table and is used in
build_header. While this information could be derived from mcfg.
This patch removes the unnecessary variable mcfg_start.
Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
hw/arm/virt-acpi-build.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index 857989362a..e09e7eff8d 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -552,7 +552,6 @@ build_mcfg(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
const MemMapEntry *memmap = vms->memmap;
int ecam_id = VIRT_ECAM_ID(vms->highmem_ecam);
int len = sizeof(*mcfg) + sizeof(mcfg->allocation[0]);
- int mcfg_start = table_data->len;
mcfg = acpi_data_push(table_data, len);
mcfg->allocation[0].address = cpu_to_le64(memmap[ecam_id].base);
@@ -563,8 +562,7 @@ build_mcfg(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
mcfg->allocation[0].end_bus_number =
PCIE_MMCFG_BUS(memmap[ecam_id].size - 1);
- build_header(linker, table_data, (void *)(table_data->data + mcfg_start),
- "MCFG", table_data->len - mcfg_start, 1, NULL, NULL);
+ build_header(linker, table_data, (void *)mcfg, "MCFG", len, 1, NULL, NULL);
}
/* GTDT */
--
2.19.1
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v4 3/6] i386, acpi: remove mcfg_ prefix in AcpiMcfgInfo members
@ 2019-04-19 0:30 ` Wei Yang
0 siblings, 0 replies; 289+ messages in thread
From: Wei Yang @ 2019-04-19 0:30 UTC (permalink / raw)
To: qemu-devel, qemu-arm
Cc: mst, imammedo, shannon.zhaosl, peter.maydell, marcel.apfelbaum,
yang.zhong, philmd, Wei Yang
This is obvious the member in AcpiMcfgInfo describe MCFG's property.
Remove the mcfg_ prefix.
Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
Suggested-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
hw/i386/acpi-build.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index d009176072..f0d27bffd6 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -87,8 +87,8 @@
#define ACPI_BUILD_IOAPIC_ID 0x0
typedef struct AcpiMcfgInfo {
- uint64_t mcfg_base;
- uint32_t mcfg_size;
+ uint64_t base;
+ uint32_t size;
} AcpiMcfgInfo;
typedef struct AcpiPmInfo {
@@ -2404,11 +2404,11 @@ build_mcfg_q35(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
int len = sizeof(*mcfg) + 1 * sizeof(mcfg->allocation[0]);
mcfg = acpi_data_push(table_data, len);
- mcfg->allocation[0].address = cpu_to_le64(info->mcfg_base);
+ mcfg->allocation[0].address = cpu_to_le64(info->base);
/* Only a single allocation so no need to play with segments */
mcfg->allocation[0].pci_segment = cpu_to_le16(0);
mcfg->allocation[0].start_bus_number = 0;
- mcfg->allocation[0].end_bus_number = PCIE_MMCFG_BUS(info->mcfg_size - 1);
+ mcfg->allocation[0].end_bus_number = PCIE_MMCFG_BUS(info->size - 1);
build_header(linker, table_data, (void *)mcfg, "MCFG", len, 1, NULL, NULL);
}
@@ -2577,15 +2577,15 @@ static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg)
if (!o) {
return false;
}
- mcfg->mcfg_base = qnum_get_uint(qobject_to(QNum, o));
+ mcfg->base = qnum_get_uint(qobject_to(QNum, o));
qobject_unref(o);
- if (mcfg->mcfg_base == PCIE_BASE_ADDR_UNMAPPED) {
+ if (mcfg->base == PCIE_BASE_ADDR_UNMAPPED) {
return false;
}
o = object_property_get_qobject(pci_host, PCIE_HOST_MCFG_SIZE, NULL);
assert(o);
- mcfg->mcfg_size = qnum_get_uint(qobject_to(QNum, o));
+ mcfg->size = qnum_get_uint(qobject_to(QNum, o));
qobject_unref(o);
return true;
}
--
2.19.1
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v4 3/6] i386, acpi: remove mcfg_ prefix in AcpiMcfgInfo members
@ 2019-04-19 0:30 ` Wei Yang
0 siblings, 0 replies; 289+ messages in thread
From: Wei Yang @ 2019-04-19 0:30 UTC (permalink / raw)
To: qemu-devel, qemu-arm
Cc: yang.zhong, peter.maydell, mst, shannon.zhaosl, Wei Yang,
imammedo, philmd
This is obvious the member in AcpiMcfgInfo describe MCFG's property.
Remove the mcfg_ prefix.
Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
Suggested-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
hw/i386/acpi-build.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index d009176072..f0d27bffd6 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -87,8 +87,8 @@
#define ACPI_BUILD_IOAPIC_ID 0x0
typedef struct AcpiMcfgInfo {
- uint64_t mcfg_base;
- uint32_t mcfg_size;
+ uint64_t base;
+ uint32_t size;
} AcpiMcfgInfo;
typedef struct AcpiPmInfo {
@@ -2404,11 +2404,11 @@ build_mcfg_q35(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
int len = sizeof(*mcfg) + 1 * sizeof(mcfg->allocation[0]);
mcfg = acpi_data_push(table_data, len);
- mcfg->allocation[0].address = cpu_to_le64(info->mcfg_base);
+ mcfg->allocation[0].address = cpu_to_le64(info->base);
/* Only a single allocation so no need to play with segments */
mcfg->allocation[0].pci_segment = cpu_to_le16(0);
mcfg->allocation[0].start_bus_number = 0;
- mcfg->allocation[0].end_bus_number = PCIE_MMCFG_BUS(info->mcfg_size - 1);
+ mcfg->allocation[0].end_bus_number = PCIE_MMCFG_BUS(info->size - 1);
build_header(linker, table_data, (void *)mcfg, "MCFG", len, 1, NULL, NULL);
}
@@ -2577,15 +2577,15 @@ static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg)
if (!o) {
return false;
}
- mcfg->mcfg_base = qnum_get_uint(qobject_to(QNum, o));
+ mcfg->base = qnum_get_uint(qobject_to(QNum, o));
qobject_unref(o);
- if (mcfg->mcfg_base == PCIE_BASE_ADDR_UNMAPPED) {
+ if (mcfg->base == PCIE_BASE_ADDR_UNMAPPED) {
return false;
}
o = object_property_get_qobject(pci_host, PCIE_HOST_MCFG_SIZE, NULL);
assert(o);
- mcfg->mcfg_size = qnum_get_uint(qobject_to(QNum, o));
+ mcfg->size = qnum_get_uint(qobject_to(QNum, o));
qobject_unref(o);
return true;
}
--
2.19.1
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v4 4/6] hw/arm/virt-acpi-build: pass AcpiMcfgInfo to build_mcfg()
@ 2019-04-19 0:30 ` Wei Yang
0 siblings, 0 replies; 289+ messages in thread
From: Wei Yang @ 2019-04-19 0:30 UTC (permalink / raw)
To: qemu-devel, qemu-arm
Cc: mst, imammedo, shannon.zhaosl, peter.maydell, marcel.apfelbaum,
yang.zhong, philmd, Wei Yang
To build MCFG, two information is necessary:
* bus number
* base address
Abstract these two information to AcpiMcfgInfo so that build_mcfg and
build_mcfg_q35 will have the same declaration.
Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
---
v3:
* move AcpiMcfgInfo to pci.h
v2:
* for arm platform, construct a AcpiMcfgInfo directly
---
hw/arm/virt-acpi-build.c | 18 +++++++++++-------
hw/i386/acpi-build.c | 6 +-----
include/hw/acpi/pci.h | 33 +++++++++++++++++++++++++++++++++
3 files changed, 45 insertions(+), 12 deletions(-)
create mode 100644 include/hw/acpi/pci.h
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index e09e7eff8d..ebddcde596 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -40,6 +40,7 @@
#include "hw/hw.h"
#include "hw/acpi/aml-build.h"
#include "hw/acpi/utils.h"
+#include "hw/acpi/pci.h"
#include "hw/pci/pcie_host.h"
#include "hw/pci/pci.h"
#include "hw/arm/virt.h"
@@ -546,21 +547,18 @@ build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
}
static void
-build_mcfg(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
+build_mcfg(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
{
AcpiTableMcfg *mcfg;
- const MemMapEntry *memmap = vms->memmap;
- int ecam_id = VIRT_ECAM_ID(vms->highmem_ecam);
int len = sizeof(*mcfg) + sizeof(mcfg->allocation[0]);
mcfg = acpi_data_push(table_data, len);
- mcfg->allocation[0].address = cpu_to_le64(memmap[ecam_id].base);
+ mcfg->allocation[0].address = cpu_to_le64(info->base);
/* Only a single allocation so no need to play with segments */
mcfg->allocation[0].pci_segment = cpu_to_le16(0);
mcfg->allocation[0].start_bus_number = 0;
- mcfg->allocation[0].end_bus_number =
- PCIE_MMCFG_BUS(memmap[ecam_id].size - 1);
+ mcfg->allocation[0].end_bus_number = PCIE_MMCFG_BUS(info->size - 1);
build_header(linker, table_data, (void *)mcfg, "MCFG", len, 1, NULL, NULL);
}
@@ -801,7 +799,13 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables)
build_gtdt(tables_blob, tables->linker, vms);
acpi_add_table(table_offsets, tables_blob);
- build_mcfg(tables_blob, tables->linker, vms);
+ {
+ AcpiMcfgInfo mcfg = {
+ .base = vms->memmap[VIRT_ECAM_ID(vms->highmem_ecam)].base,
+ .size = vms->memmap[VIRT_ECAM_ID(vms->highmem_ecam)].size,
+ };
+ build_mcfg(tables_blob, tables->linker, &mcfg);
+ }
acpi_add_table(table_offsets, tables_blob);
build_spcr(tables_blob, tables->linker, vms);
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index f0d27bffd6..c2de7f4b01 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -58,6 +58,7 @@
#include "hw/acpi/aml-build.h"
#include "hw/acpi/utils.h"
+#include "hw/acpi/pci.h"
#include "qom/qom-qobject.h"
#include "hw/i386/amd_iommu.h"
@@ -86,11 +87,6 @@
/* Default IOAPIC ID */
#define ACPI_BUILD_IOAPIC_ID 0x0
-typedef struct AcpiMcfgInfo {
- uint64_t base;
- uint32_t size;
-} AcpiMcfgInfo;
-
typedef struct AcpiPmInfo {
bool s3_disabled;
bool s4_disabled;
diff --git a/include/hw/acpi/pci.h b/include/hw/acpi/pci.h
new file mode 100644
index 0000000000..124af7d32a
--- /dev/null
+++ b/include/hw/acpi/pci.h
@@ -0,0 +1,33 @@
+/*
+ * Support for generating PCI related ACPI tables and passing them to Guests
+ *
+ * Copyright (C) 2006 Fabrice Bellard
+ * Copyright (C) 2008-2010 Kevin O'Connor <kevin@koconnor.net>
+ * Copyright (C) 2013-2019 Red Hat Inc
+ * Copyright (C) 2019 Intel Corporation
+ *
+ * Author: Wei Yang <richardw.yang@linux.intel.com>
+ * Author: Michael S. Tsirkin <mst@redhat.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef HW_ACPI_PCI_H
+#define HW_ACPI_PCI_H
+
+typedef struct AcpiMcfgInfo {
+ uint64_t base;
+ uint32_t size;
+} AcpiMcfgInfo;
+
+#endif
--
2.19.1
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v4 4/6] hw/arm/virt-acpi-build: pass AcpiMcfgInfo to build_mcfg()
@ 2019-04-19 0:30 ` Wei Yang
0 siblings, 0 replies; 289+ messages in thread
From: Wei Yang @ 2019-04-19 0:30 UTC (permalink / raw)
To: qemu-devel, qemu-arm
Cc: yang.zhong, peter.maydell, mst, shannon.zhaosl, Wei Yang,
imammedo, philmd
To build MCFG, two information is necessary:
* bus number
* base address
Abstract these two information to AcpiMcfgInfo so that build_mcfg and
build_mcfg_q35 will have the same declaration.
Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
---
v3:
* move AcpiMcfgInfo to pci.h
v2:
* for arm platform, construct a AcpiMcfgInfo directly
---
hw/arm/virt-acpi-build.c | 18 +++++++++++-------
hw/i386/acpi-build.c | 6 +-----
include/hw/acpi/pci.h | 33 +++++++++++++++++++++++++++++++++
3 files changed, 45 insertions(+), 12 deletions(-)
create mode 100644 include/hw/acpi/pci.h
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index e09e7eff8d..ebddcde596 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -40,6 +40,7 @@
#include "hw/hw.h"
#include "hw/acpi/aml-build.h"
#include "hw/acpi/utils.h"
+#include "hw/acpi/pci.h"
#include "hw/pci/pcie_host.h"
#include "hw/pci/pci.h"
#include "hw/arm/virt.h"
@@ -546,21 +547,18 @@ build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
}
static void
-build_mcfg(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
+build_mcfg(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
{
AcpiTableMcfg *mcfg;
- const MemMapEntry *memmap = vms->memmap;
- int ecam_id = VIRT_ECAM_ID(vms->highmem_ecam);
int len = sizeof(*mcfg) + sizeof(mcfg->allocation[0]);
mcfg = acpi_data_push(table_data, len);
- mcfg->allocation[0].address = cpu_to_le64(memmap[ecam_id].base);
+ mcfg->allocation[0].address = cpu_to_le64(info->base);
/* Only a single allocation so no need to play with segments */
mcfg->allocation[0].pci_segment = cpu_to_le16(0);
mcfg->allocation[0].start_bus_number = 0;
- mcfg->allocation[0].end_bus_number =
- PCIE_MMCFG_BUS(memmap[ecam_id].size - 1);
+ mcfg->allocation[0].end_bus_number = PCIE_MMCFG_BUS(info->size - 1);
build_header(linker, table_data, (void *)mcfg, "MCFG", len, 1, NULL, NULL);
}
@@ -801,7 +799,13 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables)
build_gtdt(tables_blob, tables->linker, vms);
acpi_add_table(table_offsets, tables_blob);
- build_mcfg(tables_blob, tables->linker, vms);
+ {
+ AcpiMcfgInfo mcfg = {
+ .base = vms->memmap[VIRT_ECAM_ID(vms->highmem_ecam)].base,
+ .size = vms->memmap[VIRT_ECAM_ID(vms->highmem_ecam)].size,
+ };
+ build_mcfg(tables_blob, tables->linker, &mcfg);
+ }
acpi_add_table(table_offsets, tables_blob);
build_spcr(tables_blob, tables->linker, vms);
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index f0d27bffd6..c2de7f4b01 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -58,6 +58,7 @@
#include "hw/acpi/aml-build.h"
#include "hw/acpi/utils.h"
+#include "hw/acpi/pci.h"
#include "qom/qom-qobject.h"
#include "hw/i386/amd_iommu.h"
@@ -86,11 +87,6 @@
/* Default IOAPIC ID */
#define ACPI_BUILD_IOAPIC_ID 0x0
-typedef struct AcpiMcfgInfo {
- uint64_t base;
- uint32_t size;
-} AcpiMcfgInfo;
-
typedef struct AcpiPmInfo {
bool s3_disabled;
bool s4_disabled;
diff --git a/include/hw/acpi/pci.h b/include/hw/acpi/pci.h
new file mode 100644
index 0000000000..124af7d32a
--- /dev/null
+++ b/include/hw/acpi/pci.h
@@ -0,0 +1,33 @@
+/*
+ * Support for generating PCI related ACPI tables and passing them to Guests
+ *
+ * Copyright (C) 2006 Fabrice Bellard
+ * Copyright (C) 2008-2010 Kevin O'Connor <kevin@koconnor.net>
+ * Copyright (C) 2013-2019 Red Hat Inc
+ * Copyright (C) 2019 Intel Corporation
+ *
+ * Author: Wei Yang <richardw.yang@linux.intel.com>
+ * Author: Michael S. Tsirkin <mst@redhat.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef HW_ACPI_PCI_H
+#define HW_ACPI_PCI_H
+
+typedef struct AcpiMcfgInfo {
+ uint64_t base;
+ uint32_t size;
+} AcpiMcfgInfo;
+
+#endif
--
2.19.1
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v4 5/6] hw/acpi: Consolidate build_mcfg to pci.c
@ 2019-04-19 0:30 ` Wei Yang
0 siblings, 0 replies; 289+ messages in thread
From: Wei Yang @ 2019-04-19 0:30 UTC (permalink / raw)
To: qemu-devel, qemu-arm
Cc: mst, imammedo, shannon.zhaosl, peter.maydell, marcel.apfelbaum,
yang.zhong, philmd, Wei Yang
Now we have two identical build_mcfg functions.
Consolidate them in acpi/pci.c.
Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
---
v3:
* adjust changelog based on Igor's suggestion
---
default-configs/arm-softmmu.mak | 1 +
default-configs/i386-softmmu.mak | 1 +
hw/acpi/Kconfig | 4 +++
hw/acpi/Makefile.objs | 1 +
hw/acpi/pci.c | 46 ++++++++++++++++++++++++++++++++
hw/arm/virt-acpi-build.c | 17 ------------
hw/i386/acpi-build.c | 18 +------------
include/hw/acpi/pci.h | 1 +
8 files changed, 55 insertions(+), 34 deletions(-)
create mode 100644 hw/acpi/pci.c
diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak
index 613d19a06d..8f2796e195 100644
--- a/default-configs/arm-softmmu.mak
+++ b/default-configs/arm-softmmu.mak
@@ -144,6 +144,7 @@ CONFIG_XIO3130=y
CONFIG_IOH3420=y
CONFIG_I82801B11=y
CONFIG_ACPI=y
+CONFIG_ACPI_PCI=y
CONFIG_ARM_VIRT=y
CONFIG_SMBIOS=y
CONFIG_ASPEED_SOC=y
diff --git a/default-configs/i386-softmmu.mak b/default-configs/i386-softmmu.mak
index ba3fb3ff50..cd5ea391e8 100644
--- a/default-configs/i386-softmmu.mak
+++ b/default-configs/i386-softmmu.mak
@@ -25,3 +25,4 @@
CONFIG_ISAPC=y
CONFIG_I440FX=y
CONFIG_Q35=y
+CONFIG_ACPI_PCI=y
diff --git a/hw/acpi/Kconfig b/hw/acpi/Kconfig
index eca3beed75..7265843cc3 100644
--- a/hw/acpi/Kconfig
+++ b/hw/acpi/Kconfig
@@ -23,6 +23,10 @@ config ACPI_NVDIMM
bool
depends on ACPI
+config ACPI_PCI
+ bool
+ depends on ACPI
+
config ACPI_VMGENID
bool
default y
diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs
index ba93c5b64a..9bb2101e3b 100644
--- a/hw/acpi/Makefile.objs
+++ b/hw/acpi/Makefile.objs
@@ -11,6 +11,7 @@ common-obj-$(call lnot,$(CONFIG_ACPI_X86)) += acpi-stub.o
common-obj-y += acpi_interface.o
common-obj-y += bios-linker-loader.o
common-obj-y += aml-build.o utils.o
+common-obj-$(CONFIG_ACPI_PCI) += pci.o
common-obj-$(CONFIG_TPM) += tpm.o
common-obj-$(CONFIG_IPMI) += ipmi.o
diff --git a/hw/acpi/pci.c b/hw/acpi/pci.c
new file mode 100644
index 0000000000..fa0fa30bb9
--- /dev/null
+++ b/hw/acpi/pci.c
@@ -0,0 +1,46 @@
+/*
+ * Support for generating PCI related ACPI tables and passing them to Guests
+ *
+ * Copyright (C) 2006 Fabrice Bellard
+ * Copyright (C) 2008-2010 Kevin O'Connor <kevin@koconnor.net>
+ * Copyright (C) 2013-2019 Red Hat Inc
+ * Copyright (C) 2019 Intel Corporation
+ *
+ * Author: Wei Yang <richardw.yang@linux.intel.com>
+ * Author: Michael S. Tsirkin <mst@redhat.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "qemu/osdep.h"
+#include "hw/acpi/aml-build.h"
+#include "hw/acpi/pci.h"
+#include "hw/pci/pcie_host.h"
+
+void build_mcfg(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
+{
+ AcpiTableMcfg *mcfg;
+ int len = sizeof(*mcfg) + sizeof(mcfg->allocation[0]);
+
+ mcfg = acpi_data_push(table_data, len);
+ mcfg->allocation[0].address = cpu_to_le64(info->base);
+
+ /* Only a single allocation so no need to play with segments */
+ mcfg->allocation[0].pci_segment = cpu_to_le16(0);
+ mcfg->allocation[0].start_bus_number = 0;
+ mcfg->allocation[0].end_bus_number = PCIE_MMCFG_BUS(info->size - 1);
+
+ build_header(linker, table_data, (void *)mcfg, "MCFG", len, 1, NULL, NULL);
+}
+
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index ebddcde596..e3353de9e4 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -546,23 +546,6 @@ build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
"SRAT", table_data->len - srat_start, 3, NULL, NULL);
}
-static void
-build_mcfg(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
-{
- AcpiTableMcfg *mcfg;
- int len = sizeof(*mcfg) + sizeof(mcfg->allocation[0]);
-
- mcfg = acpi_data_push(table_data, len);
- mcfg->allocation[0].address = cpu_to_le64(info->base);
-
- /* Only a single allocation so no need to play with segments */
- mcfg->allocation[0].pci_segment = cpu_to_le16(0);
- mcfg->allocation[0].start_bus_number = 0;
- mcfg->allocation[0].end_bus_number = PCIE_MMCFG_BUS(info->size - 1);
-
- build_header(linker, table_data, (void *)mcfg, "MCFG", len, 1, NULL, NULL);
-}
-
/* GTDT */
static void
build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index c2de7f4b01..29980bb3f4 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -2393,22 +2393,6 @@ build_srat(GArray *table_data, BIOSLinker *linker, MachineState *machine)
table_data->len - srat_start, 1, NULL, NULL);
}
-static void
-build_mcfg_q35(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
-{
- AcpiTableMcfg *mcfg;
- int len = sizeof(*mcfg) + 1 * sizeof(mcfg->allocation[0]);
-
- mcfg = acpi_data_push(table_data, len);
- mcfg->allocation[0].address = cpu_to_le64(info->base);
- /* Only a single allocation so no need to play with segments */
- mcfg->allocation[0].pci_segment = cpu_to_le16(0);
- mcfg->allocation[0].start_bus_number = 0;
- mcfg->allocation[0].end_bus_number = PCIE_MMCFG_BUS(info->size - 1);
-
- build_header(linker, table_data, (void *)mcfg, "MCFG", len, 1, NULL, NULL);
-}
-
/*
* VT-d spec 8.1 DMA Remapping Reporting Structure
* (version Oct. 2014 or later)
@@ -2678,7 +2662,7 @@ void acpi_build(AcpiBuildTables *tables, MachineState *machine)
}
if (acpi_get_mcfg(&mcfg)) {
acpi_add_table(table_offsets, tables_blob);
- build_mcfg_q35(tables_blob, tables->linker, &mcfg);
+ build_mcfg(tables_blob, tables->linker, &mcfg);
}
if (x86_iommu_get_default()) {
IommuType IOMMUType = x86_iommu_get_type();
diff --git a/include/hw/acpi/pci.h b/include/hw/acpi/pci.h
index 124af7d32a..8bbd32cf45 100644
--- a/include/hw/acpi/pci.h
+++ b/include/hw/acpi/pci.h
@@ -30,4 +30,5 @@ typedef struct AcpiMcfgInfo {
uint32_t size;
} AcpiMcfgInfo;
+void build_mcfg(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info);
#endif
--
2.19.1
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v4 5/6] hw/acpi: Consolidate build_mcfg to pci.c
@ 2019-04-19 0:30 ` Wei Yang
0 siblings, 0 replies; 289+ messages in thread
From: Wei Yang @ 2019-04-19 0:30 UTC (permalink / raw)
To: qemu-devel, qemu-arm
Cc: yang.zhong, peter.maydell, mst, shannon.zhaosl, Wei Yang,
imammedo, philmd
Now we have two identical build_mcfg functions.
Consolidate them in acpi/pci.c.
Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
---
v3:
* adjust changelog based on Igor's suggestion
---
default-configs/arm-softmmu.mak | 1 +
default-configs/i386-softmmu.mak | 1 +
hw/acpi/Kconfig | 4 +++
hw/acpi/Makefile.objs | 1 +
hw/acpi/pci.c | 46 ++++++++++++++++++++++++++++++++
hw/arm/virt-acpi-build.c | 17 ------------
hw/i386/acpi-build.c | 18 +------------
include/hw/acpi/pci.h | 1 +
8 files changed, 55 insertions(+), 34 deletions(-)
create mode 100644 hw/acpi/pci.c
diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak
index 613d19a06d..8f2796e195 100644
--- a/default-configs/arm-softmmu.mak
+++ b/default-configs/arm-softmmu.mak
@@ -144,6 +144,7 @@ CONFIG_XIO3130=y
CONFIG_IOH3420=y
CONFIG_I82801B11=y
CONFIG_ACPI=y
+CONFIG_ACPI_PCI=y
CONFIG_ARM_VIRT=y
CONFIG_SMBIOS=y
CONFIG_ASPEED_SOC=y
diff --git a/default-configs/i386-softmmu.mak b/default-configs/i386-softmmu.mak
index ba3fb3ff50..cd5ea391e8 100644
--- a/default-configs/i386-softmmu.mak
+++ b/default-configs/i386-softmmu.mak
@@ -25,3 +25,4 @@
CONFIG_ISAPC=y
CONFIG_I440FX=y
CONFIG_Q35=y
+CONFIG_ACPI_PCI=y
diff --git a/hw/acpi/Kconfig b/hw/acpi/Kconfig
index eca3beed75..7265843cc3 100644
--- a/hw/acpi/Kconfig
+++ b/hw/acpi/Kconfig
@@ -23,6 +23,10 @@ config ACPI_NVDIMM
bool
depends on ACPI
+config ACPI_PCI
+ bool
+ depends on ACPI
+
config ACPI_VMGENID
bool
default y
diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs
index ba93c5b64a..9bb2101e3b 100644
--- a/hw/acpi/Makefile.objs
+++ b/hw/acpi/Makefile.objs
@@ -11,6 +11,7 @@ common-obj-$(call lnot,$(CONFIG_ACPI_X86)) += acpi-stub.o
common-obj-y += acpi_interface.o
common-obj-y += bios-linker-loader.o
common-obj-y += aml-build.o utils.o
+common-obj-$(CONFIG_ACPI_PCI) += pci.o
common-obj-$(CONFIG_TPM) += tpm.o
common-obj-$(CONFIG_IPMI) += ipmi.o
diff --git a/hw/acpi/pci.c b/hw/acpi/pci.c
new file mode 100644
index 0000000000..fa0fa30bb9
--- /dev/null
+++ b/hw/acpi/pci.c
@@ -0,0 +1,46 @@
+/*
+ * Support for generating PCI related ACPI tables and passing them to Guests
+ *
+ * Copyright (C) 2006 Fabrice Bellard
+ * Copyright (C) 2008-2010 Kevin O'Connor <kevin@koconnor.net>
+ * Copyright (C) 2013-2019 Red Hat Inc
+ * Copyright (C) 2019 Intel Corporation
+ *
+ * Author: Wei Yang <richardw.yang@linux.intel.com>
+ * Author: Michael S. Tsirkin <mst@redhat.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "qemu/osdep.h"
+#include "hw/acpi/aml-build.h"
+#include "hw/acpi/pci.h"
+#include "hw/pci/pcie_host.h"
+
+void build_mcfg(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
+{
+ AcpiTableMcfg *mcfg;
+ int len = sizeof(*mcfg) + sizeof(mcfg->allocation[0]);
+
+ mcfg = acpi_data_push(table_data, len);
+ mcfg->allocation[0].address = cpu_to_le64(info->base);
+
+ /* Only a single allocation so no need to play with segments */
+ mcfg->allocation[0].pci_segment = cpu_to_le16(0);
+ mcfg->allocation[0].start_bus_number = 0;
+ mcfg->allocation[0].end_bus_number = PCIE_MMCFG_BUS(info->size - 1);
+
+ build_header(linker, table_data, (void *)mcfg, "MCFG", len, 1, NULL, NULL);
+}
+
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index ebddcde596..e3353de9e4 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -546,23 +546,6 @@ build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
"SRAT", table_data->len - srat_start, 3, NULL, NULL);
}
-static void
-build_mcfg(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
-{
- AcpiTableMcfg *mcfg;
- int len = sizeof(*mcfg) + sizeof(mcfg->allocation[0]);
-
- mcfg = acpi_data_push(table_data, len);
- mcfg->allocation[0].address = cpu_to_le64(info->base);
-
- /* Only a single allocation so no need to play with segments */
- mcfg->allocation[0].pci_segment = cpu_to_le16(0);
- mcfg->allocation[0].start_bus_number = 0;
- mcfg->allocation[0].end_bus_number = PCIE_MMCFG_BUS(info->size - 1);
-
- build_header(linker, table_data, (void *)mcfg, "MCFG", len, 1, NULL, NULL);
-}
-
/* GTDT */
static void
build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index c2de7f4b01..29980bb3f4 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -2393,22 +2393,6 @@ build_srat(GArray *table_data, BIOSLinker *linker, MachineState *machine)
table_data->len - srat_start, 1, NULL, NULL);
}
-static void
-build_mcfg_q35(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
-{
- AcpiTableMcfg *mcfg;
- int len = sizeof(*mcfg) + 1 * sizeof(mcfg->allocation[0]);
-
- mcfg = acpi_data_push(table_data, len);
- mcfg->allocation[0].address = cpu_to_le64(info->base);
- /* Only a single allocation so no need to play with segments */
- mcfg->allocation[0].pci_segment = cpu_to_le16(0);
- mcfg->allocation[0].start_bus_number = 0;
- mcfg->allocation[0].end_bus_number = PCIE_MMCFG_BUS(info->size - 1);
-
- build_header(linker, table_data, (void *)mcfg, "MCFG", len, 1, NULL, NULL);
-}
-
/*
* VT-d spec 8.1 DMA Remapping Reporting Structure
* (version Oct. 2014 or later)
@@ -2678,7 +2662,7 @@ void acpi_build(AcpiBuildTables *tables, MachineState *machine)
}
if (acpi_get_mcfg(&mcfg)) {
acpi_add_table(table_offsets, tables_blob);
- build_mcfg_q35(tables_blob, tables->linker, &mcfg);
+ build_mcfg(tables_blob, tables->linker, &mcfg);
}
if (x86_iommu_get_default()) {
IommuType IOMMUType = x86_iommu_get_type();
diff --git a/include/hw/acpi/pci.h b/include/hw/acpi/pci.h
index 124af7d32a..8bbd32cf45 100644
--- a/include/hw/acpi/pci.h
+++ b/include/hw/acpi/pci.h
@@ -30,4 +30,5 @@ typedef struct AcpiMcfgInfo {
uint32_t size;
} AcpiMcfgInfo;
+void build_mcfg(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info);
#endif
--
2.19.1
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v4 6/6] acpi: pci: use build_append_foo() API to construct MCFG
@ 2019-04-19 0:30 ` Wei Yang
0 siblings, 0 replies; 289+ messages in thread
From: Wei Yang @ 2019-04-19 0:30 UTC (permalink / raw)
To: qemu-devel, qemu-arm
Cc: mst, imammedo, shannon.zhaosl, peter.maydell, marcel.apfelbaum,
yang.zhong, philmd, Wei Yang
build_append_foo() API doesn't need explicit endianness conversions
which eliminates a source of errors and it makes build_mcfg() look like
declarative definition of MCFG table in ACPI spec, which makes it easy
to review.
Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
Suggested-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
hw/acpi/pci.c | 33 +++++++++++++++++++++------------
include/hw/acpi/acpi-defs.h | 18 ------------------
2 files changed, 21 insertions(+), 30 deletions(-)
diff --git a/hw/acpi/pci.c b/hw/acpi/pci.c
index fa0fa30bb9..341805e786 100644
--- a/hw/acpi/pci.c
+++ b/hw/acpi/pci.c
@@ -30,17 +30,26 @@
void build_mcfg(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
{
- AcpiTableMcfg *mcfg;
- int len = sizeof(*mcfg) + sizeof(mcfg->allocation[0]);
-
- mcfg = acpi_data_push(table_data, len);
- mcfg->allocation[0].address = cpu_to_le64(info->base);
-
- /* Only a single allocation so no need to play with segments */
- mcfg->allocation[0].pci_segment = cpu_to_le16(0);
- mcfg->allocation[0].start_bus_number = 0;
- mcfg->allocation[0].end_bus_number = PCIE_MMCFG_BUS(info->size - 1);
-
- build_header(linker, table_data, (void *)mcfg, "MCFG", len, 1, NULL, NULL);
+ int mcfg_start = table_data->len;
+
+ acpi_data_push(table_data, sizeof(AcpiTableHeader));
+
+ /*
+ * PCI Firmware Specification, Revision 3.0
+ * 4.1.2 MCFG Table Description.
+ */
+ /* Base address, processor-relative */
+ build_append_int_noprefix(table_data, info->base, 8);
+ /* PCI segment group number */
+ build_append_int_noprefix(table_data, 0, 2);
+ /* Starting PCI Bus number */
+ build_append_int_noprefix(table_data, 0, 1);
+ /* Final PCI Bus number */
+ build_append_int_noprefix(table_data, PCIE_MMCFG_BUS(info->size - 1), 1);
+ /* Reserved */
+ build_append_int_noprefix(table_data, 0, 4);
+
+ build_header(linker, table_data, (void *)(table_data->data + mcfg_start),
+ "MCFG", table_data->len - mcfg_start, 1, NULL, NULL);
}
diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h
index f9aa4bd398..57a3f58b0c 100644
--- a/include/hw/acpi/acpi-defs.h
+++ b/include/hw/acpi/acpi-defs.h
@@ -449,24 +449,6 @@ struct AcpiSratProcessorGiccAffinity {
typedef struct AcpiSratProcessorGiccAffinity AcpiSratProcessorGiccAffinity;
-/* PCI fw r3.0 MCFG table. */
-/* Subtable */
-struct AcpiMcfgAllocation {
- uint64_t address; /* Base address, processor-relative */
- uint16_t pci_segment; /* PCI segment group number */
- uint8_t start_bus_number; /* Starting PCI Bus number */
- uint8_t end_bus_number; /* Final PCI Bus number */
- uint32_t reserved;
-} QEMU_PACKED;
-typedef struct AcpiMcfgAllocation AcpiMcfgAllocation;
-
-struct AcpiTableMcfg {
- ACPI_TABLE_HEADER_DEF;
- uint8_t reserved[8];
- AcpiMcfgAllocation allocation[0];
-} QEMU_PACKED;
-typedef struct AcpiTableMcfg AcpiTableMcfg;
-
/*
* TCPA Description Table
*
--
2.19.1
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v4 6/6] acpi: pci: use build_append_foo() API to construct MCFG
@ 2019-04-19 0:30 ` Wei Yang
0 siblings, 0 replies; 289+ messages in thread
From: Wei Yang @ 2019-04-19 0:30 UTC (permalink / raw)
To: qemu-devel, qemu-arm
Cc: yang.zhong, peter.maydell, mst, shannon.zhaosl, Wei Yang,
imammedo, philmd
build_append_foo() API doesn't need explicit endianness conversions
which eliminates a source of errors and it makes build_mcfg() look like
declarative definition of MCFG table in ACPI spec, which makes it easy
to review.
Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
Suggested-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
hw/acpi/pci.c | 33 +++++++++++++++++++++------------
include/hw/acpi/acpi-defs.h | 18 ------------------
2 files changed, 21 insertions(+), 30 deletions(-)
diff --git a/hw/acpi/pci.c b/hw/acpi/pci.c
index fa0fa30bb9..341805e786 100644
--- a/hw/acpi/pci.c
+++ b/hw/acpi/pci.c
@@ -30,17 +30,26 @@
void build_mcfg(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
{
- AcpiTableMcfg *mcfg;
- int len = sizeof(*mcfg) + sizeof(mcfg->allocation[0]);
-
- mcfg = acpi_data_push(table_data, len);
- mcfg->allocation[0].address = cpu_to_le64(info->base);
-
- /* Only a single allocation so no need to play with segments */
- mcfg->allocation[0].pci_segment = cpu_to_le16(0);
- mcfg->allocation[0].start_bus_number = 0;
- mcfg->allocation[0].end_bus_number = PCIE_MMCFG_BUS(info->size - 1);
-
- build_header(linker, table_data, (void *)mcfg, "MCFG", len, 1, NULL, NULL);
+ int mcfg_start = table_data->len;
+
+ acpi_data_push(table_data, sizeof(AcpiTableHeader));
+
+ /*
+ * PCI Firmware Specification, Revision 3.0
+ * 4.1.2 MCFG Table Description.
+ */
+ /* Base address, processor-relative */
+ build_append_int_noprefix(table_data, info->base, 8);
+ /* PCI segment group number */
+ build_append_int_noprefix(table_data, 0, 2);
+ /* Starting PCI Bus number */
+ build_append_int_noprefix(table_data, 0, 1);
+ /* Final PCI Bus number */
+ build_append_int_noprefix(table_data, PCIE_MMCFG_BUS(info->size - 1), 1);
+ /* Reserved */
+ build_append_int_noprefix(table_data, 0, 4);
+
+ build_header(linker, table_data, (void *)(table_data->data + mcfg_start),
+ "MCFG", table_data->len - mcfg_start, 1, NULL, NULL);
}
diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h
index f9aa4bd398..57a3f58b0c 100644
--- a/include/hw/acpi/acpi-defs.h
+++ b/include/hw/acpi/acpi-defs.h
@@ -449,24 +449,6 @@ struct AcpiSratProcessorGiccAffinity {
typedef struct AcpiSratProcessorGiccAffinity AcpiSratProcessorGiccAffinity;
-/* PCI fw r3.0 MCFG table. */
-/* Subtable */
-struct AcpiMcfgAllocation {
- uint64_t address; /* Base address, processor-relative */
- uint16_t pci_segment; /* PCI segment group number */
- uint8_t start_bus_number; /* Starting PCI Bus number */
- uint8_t end_bus_number; /* Final PCI Bus number */
- uint32_t reserved;
-} QEMU_PACKED;
-typedef struct AcpiMcfgAllocation AcpiMcfgAllocation;
-
-struct AcpiTableMcfg {
- ACPI_TABLE_HEADER_DEF;
- uint8_t reserved[8];
- AcpiMcfgAllocation allocation[0];
-} QEMU_PACKED;
-typedef struct AcpiTableMcfg AcpiTableMcfg;
-
/*
* TCPA Description Table
*
--
2.19.1
^ permalink raw reply related [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH 0/2] vhost-user race condition on shutdown
@ 2019-04-19 23:12 ` Michael S. Tsirkin
0 siblings, 0 replies; 289+ messages in thread
From: Michael S. Tsirkin @ 2019-04-19 23:12 UTC (permalink / raw)
To: Dan Streetman; +Cc: Jason Wang, qemu-devel, qemu-stable, maxime.coquelin
On Tue, Apr 16, 2019 at 02:46:22PM -0400, Dan Streetman wrote:
> From: Dan Streetman <ddstreet@canonical.com>
>
> Buglink: https://launchpad.net/bugs/1823458
Cc Maxime.
> This is a race condition between the normal shutdown of a guest
> and the handling of its vhost-user net being externally closed.
> It's explained in more detail at the bug link; the short version
> is that there are 2 problems, fixed by the 2 patches. The first
> patch fixes the race condition where multiple threads call
> vhost_net_stop(), and the second patch prevents vhost-user from
> calling vhost_net_cleanup() on CHR_EVENT_CLOSED, because it will
> be cleaned up later and its fields will be accessed when
> vhost_net_stop() is called later.
>
> As explained in the bug report, this requires a rather complicated
> setup to reproduce, and I'm not able to create a setup to reproduce
> it myself. However this has been reported to me/Canonical, and the
> reporter is able to reproduce it consistently, so I've used them for
> debug and testing. This reproduction was done with the older 2.5
> qemu, from Ubuntu Xenial; but the problem does still appear to exist
> in upstream qemu, based on review of the code, which is why I'm sending
> these patches.
>
> Dan Streetman (2):
> add VirtIONet vhost_stopped flag to prevent multiple stops
> do not call vhost_net_cleanup() on running net from char user event
>
> hw/net/virtio-net.c | 3 ++-
> include/hw/virtio/virtio-net.h | 1 +
> net/vhost-user.c | 1 -
> 3 files changed, 3 insertions(+), 2 deletions(-)
>
> --
> 2.20.1
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH 0/2] vhost-user race condition on shutdown
@ 2019-04-19 23:12 ` Michael S. Tsirkin
0 siblings, 0 replies; 289+ messages in thread
From: Michael S. Tsirkin @ 2019-04-19 23:12 UTC (permalink / raw)
To: Dan Streetman; +Cc: maxime.coquelin, Jason Wang, qemu-devel, qemu-stable
On Tue, Apr 16, 2019 at 02:46:22PM -0400, Dan Streetman wrote:
> From: Dan Streetman <ddstreet@canonical.com>
>
> Buglink: https://launchpad.net/bugs/1823458
Cc Maxime.
> This is a race condition between the normal shutdown of a guest
> and the handling of its vhost-user net being externally closed.
> It's explained in more detail at the bug link; the short version
> is that there are 2 problems, fixed by the 2 patches. The first
> patch fixes the race condition where multiple threads call
> vhost_net_stop(), and the second patch prevents vhost-user from
> calling vhost_net_cleanup() on CHR_EVENT_CLOSED, because it will
> be cleaned up later and its fields will be accessed when
> vhost_net_stop() is called later.
>
> As explained in the bug report, this requires a rather complicated
> setup to reproduce, and I'm not able to create a setup to reproduce
> it myself. However this has been reported to me/Canonical, and the
> reporter is able to reproduce it consistently, so I've used them for
> debug and testing. This reproduction was done with the older 2.5
> qemu, from Ubuntu Xenial; but the problem does still appear to exist
> in upstream qemu, based on review of the code, which is why I'm sending
> these patches.
>
> Dan Streetman (2):
> add VirtIONet vhost_stopped flag to prevent multiple stops
> do not call vhost_net_cleanup() on running net from char user event
>
> hw/net/virtio-net.c | 3 ++-
> include/hw/virtio/virtio-net.h | 1 +
> net/vhost-user.c | 1 -
> 3 files changed, 3 insertions(+), 2 deletions(-)
>
> --
> 2.20.1
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] add VirtIONet vhost_stopped flag to prevent multiple stops
2019-04-16 18:46 ` [Qemu-devel] [PATCH 1/2] add VirtIONet vhost_stopped flag to prevent multiple stops Dan Streetman
@ 2019-04-19 23:14 ` Michael S. Tsirkin
2019-04-22 20:31 ` Dan Streetman
2019-04-22 2:50 ` Jason Wang
1 sibling, 1 reply; 289+ messages in thread
From: Michael S. Tsirkin @ 2019-04-19 23:14 UTC (permalink / raw)
To: Dan Streetman; +Cc: Jason Wang, qemu-devel, qemu-stable
On Tue, Apr 16, 2019 at 02:46:23PM -0400, Dan Streetman wrote:
> From: Dan Streetman <ddstreet@canonical.com>
>
> Buglink: https://launchpad.net/bugs/1823458
>
> There is a race condition when using the vhost-user driver, between a guest
> shutdown and the vhost-user interface being closed. This is explained in
> more detail at the bug link above; the short explanation is the vhost-user
> device can be closed while the main thread is in the middle of stopping
> the vhost_net. In this case, the main thread handling shutdown will
> enter virtio_net_vhost_status() and move into the n->vhost_started (else)
> block, and call vhost_net_stop(); while it is running that function,
> another thread is notified that the vhost-user device has been closed,
> and (indirectly) calls into virtio_net_vhost_status() also. Since the
> vhost_net status hasn't yet changed, the second thread also enters
> the n->vhost_started block, and also calls vhost_net_stop(). This
> causes problems for the second thread when it tries to stop the network
> that's already been stopped.
>
> This adds a flag to the struct that's atomically set to prevent more than
> one thread from calling vhost_net_stop(). The atomic_fetch_inc() is likely
> overkill and probably could be done with a simple check-and-set, but
> since it's a race condition there would still be a (very, very) small
> window without using an atomic to set it.
How? Isn't all this under the BQL?
>
> Signed-off-by: Dan Streetman <ddstreet@canonical.com>
> ---
> hw/net/virtio-net.c | 3 ++-
> include/hw/virtio/virtio-net.h | 1 +
> 2 files changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
> index ffe0872fff..d36f50d5dd 100644
> --- a/hw/net/virtio-net.c
> +++ b/hw/net/virtio-net.c
> @@ -13,6 +13,7 @@
>
> #include "qemu/osdep.h"
> #include "qemu/iov.h"
> +#include "qemu/atomic.h"
> #include "hw/virtio/virtio.h"
> #include "net/net.h"
> #include "net/checksum.h"
> @@ -240,7 +241,7 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status)
> "falling back on userspace virtio", -r);
> n->vhost_started = 0;
> }
> - } else {
> + } else if (atomic_fetch_inc(&n->vhost_stopped) == 0) {
> vhost_net_stop(vdev, n->nic->ncs, queues);
> n->vhost_started = 0;
> }
> diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h
> index b96f0c643f..d03fd933d0 100644
> --- a/include/hw/virtio/virtio-net.h
> +++ b/include/hw/virtio/virtio-net.h
> @@ -164,6 +164,7 @@ struct VirtIONet {
> uint8_t nouni;
> uint8_t nobcast;
> uint8_t vhost_started;
> + int vhost_stopped;
> struct {
> uint32_t in_use;
> uint32_t first_multi;
OK questions same as any state:
- do we need to migrate this?
- reset it on device reset?
> --
> 2.20.1
^ permalink raw reply [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH] libvhost-user: fix bad vu_log_write
@ 2019-05-16 12:19 ` Michael S. Tsirkin
0 siblings, 0 replies; 289+ messages in thread
From: Li Feng @ 2019-04-20 9:10 UTC (permalink / raw)
To: qemu-devel, mst; +Cc: fengli
Mark dirty as page, the step of each call is 1.
Signed-off-by: Li Feng <fengli@smartx.com>
---
contrib/libvhost-user/libvhost-user.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/contrib/libvhost-user/libvhost-user.c b/contrib/libvhost-user/libvhost-user.c
index e08d6c7b97..2689de6d1c 100644
--- a/contrib/libvhost-user/libvhost-user.c
+++ b/contrib/libvhost-user/libvhost-user.c
@@ -433,7 +433,7 @@ vu_log_write(VuDev *dev, uint64_t address, uint64_t length)
page = address / VHOST_LOG_PAGE;
while (page * VHOST_LOG_PAGE < address + length) {
vu_log_page(dev->log_table, page);
- page += VHOST_LOG_PAGE;
+ page += 1;
}
vu_log_kick(dev);
--
2.11.0
^ permalink raw reply related [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH] libvhost-user: fix bad vu_log_write
@ 2019-04-21 16:48 ` Marc-André Lureau
0 siblings, 0 replies; 289+ messages in thread
From: Marc-André Lureau @ 2019-04-21 16:48 UTC (permalink / raw)
To: Li Feng; +Cc: QEMU, Michael S. Tsirkin, fengli
On Sat, Apr 20, 2019 at 11:11 AM Li Feng <lifeng1519@gmail.com> wrote:
>
> Mark dirty as page, the step of each call is 1.
>
> Signed-off-by: Li Feng <fengli@smartx.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> contrib/libvhost-user/libvhost-user.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/contrib/libvhost-user/libvhost-user.c b/contrib/libvhost-user/libvhost-user.c
> index e08d6c7b97..2689de6d1c 100644
> --- a/contrib/libvhost-user/libvhost-user.c
> +++ b/contrib/libvhost-user/libvhost-user.c
> @@ -433,7 +433,7 @@ vu_log_write(VuDev *dev, uint64_t address, uint64_t length)
> page = address / VHOST_LOG_PAGE;
> while (page * VHOST_LOG_PAGE < address + length) {
> vu_log_page(dev->log_table, page);
> - page += VHOST_LOG_PAGE;
> + page += 1;
> }
>
> vu_log_kick(dev);
> --
> 2.11.0
>
>
--
Marc-André Lureau
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH] libvhost-user: fix bad vu_log_write
@ 2019-04-21 16:48 ` Marc-André Lureau
0 siblings, 0 replies; 289+ messages in thread
From: Marc-André Lureau @ 2019-04-21 16:48 UTC (permalink / raw)
To: Li Feng; +Cc: fengli, QEMU, Michael S. Tsirkin
On Sat, Apr 20, 2019 at 11:11 AM Li Feng <lifeng1519@gmail.com> wrote:
>
> Mark dirty as page, the step of each call is 1.
>
> Signed-off-by: Li Feng <fengli@smartx.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> contrib/libvhost-user/libvhost-user.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/contrib/libvhost-user/libvhost-user.c b/contrib/libvhost-user/libvhost-user.c
> index e08d6c7b97..2689de6d1c 100644
> --- a/contrib/libvhost-user/libvhost-user.c
> +++ b/contrib/libvhost-user/libvhost-user.c
> @@ -433,7 +433,7 @@ vu_log_write(VuDev *dev, uint64_t address, uint64_t length)
> page = address / VHOST_LOG_PAGE;
> while (page * VHOST_LOG_PAGE < address + length) {
> vu_log_page(dev->log_table, page);
> - page += VHOST_LOG_PAGE;
> + page += 1;
> }
>
> vu_log_kick(dev);
> --
> 2.11.0
>
>
--
Marc-André Lureau
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] add VirtIONet vhost_stopped flag to prevent multiple stops
2019-04-16 18:46 ` [Qemu-devel] [PATCH 1/2] add VirtIONet vhost_stopped flag to prevent multiple stops Dan Streetman
2019-04-19 23:14 ` Michael S. Tsirkin
@ 2019-04-22 2:50 ` Jason Wang
2019-04-22 20:14 ` Dan Streetman
1 sibling, 1 reply; 289+ messages in thread
From: Jason Wang @ 2019-04-22 2:50 UTC (permalink / raw)
To: Dan Streetman, Michael S. Tsirkin, qemu-devel, qemu-stable
On 2019/4/17 上午2:46, Dan Streetman wrote:
> From: Dan Streetman <ddstreet@canonical.com>
>
> Buglink: https://launchpad.net/bugs/1823458
>
> There is a race condition when using the vhost-user driver, between a guest
> shutdown and the vhost-user interface being closed. This is explained in
> more detail at the bug link above; the short explanation is the vhost-user
> device can be closed while the main thread is in the middle of stopping
> the vhost_net. In this case, the main thread handling shutdown will
> enter virtio_net_vhost_status() and move into the n->vhost_started (else)
> block, and call vhost_net_stop(); while it is running that function,
> another thread is notified that the vhost-user device has been closed,
> and (indirectly) calls into virtio_net_vhost_status() also.
I think we need figure out why there are multiple vhost_net_stop() calls
simultaneously. E.g vhost-user register fd handlers like:
qemu_chr_fe_set_handlers(&s->chr, NULL, NULL,
net_vhost_user_event, NULL, nc0->name,
NULL,
true);
which uses default main context, so it should only be called only in
main thread.
Thanks
> Since the
> vhost_net status hasn't yet changed, the second thread also enters
> the n->vhost_started block, and also calls vhost_net_stop(). This
> causes problems for the second thread when it tries to stop the network
> that's already been stopped.
>
> This adds a flag to the struct that's atomically set to prevent more than
> one thread from calling vhost_net_stop(). The atomic_fetch_inc() is likely
> overkill and probably could be done with a simple check-and-set, but
> since it's a race condition there would still be a (very, very) small
> window without using an atomic to set it.
>
> Signed-off-by: Dan Streetman <ddstreet@canonical.com>
> ---
> hw/net/virtio-net.c | 3 ++-
> include/hw/virtio/virtio-net.h | 1 +
> 2 files changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
> index ffe0872fff..d36f50d5dd 100644
> --- a/hw/net/virtio-net.c
> +++ b/hw/net/virtio-net.c
> @@ -13,6 +13,7 @@
>
> #include "qemu/osdep.h"
> #include "qemu/iov.h"
> +#include "qemu/atomic.h"
> #include "hw/virtio/virtio.h"
> #include "net/net.h"
> #include "net/checksum.h"
> @@ -240,7 +241,7 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status)
> "falling back on userspace virtio", -r);
> n->vhost_started = 0;
> }
> - } else {
> + } else if (atomic_fetch_inc(&n->vhost_stopped) == 0) {
> vhost_net_stop(vdev, n->nic->ncs, queues);
> n->vhost_started = 0;
> }
> diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h
> index b96f0c643f..d03fd933d0 100644
> --- a/include/hw/virtio/virtio-net.h
> +++ b/include/hw/virtio/virtio-net.h
> @@ -164,6 +164,7 @@ struct VirtIONet {
> uint8_t nouni;
> uint8_t nobcast;
> uint8_t vhost_started;
> + int vhost_stopped;
> struct {
> uint32_t in_use;
> uint32_t first_multi;
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] add VirtIONet vhost_stopped flag to prevent multiple stops
@ 2019-04-22 20:14 ` Dan Streetman
0 siblings, 0 replies; 289+ messages in thread
From: Dan Streetman @ 2019-04-22 20:14 UTC (permalink / raw)
To: Jason Wang; +Cc: Michael S. Tsirkin, qemu-devel, qemu-stable
On Sun, Apr 21, 2019 at 10:50 PM Jason Wang <jasowang@redhat.com> wrote:
>
>
> On 2019/4/17 上午2:46, Dan Streetman wrote:
> > From: Dan Streetman <ddstreet@canonical.com>
> >
> > Buglink: https://launchpad.net/bugs/1823458
> >
> > There is a race condition when using the vhost-user driver, between a guest
> > shutdown and the vhost-user interface being closed. This is explained in
> > more detail at the bug link above; the short explanation is the vhost-user
> > device can be closed while the main thread is in the middle of stopping
> > the vhost_net. In this case, the main thread handling shutdown will
> > enter virtio_net_vhost_status() and move into the n->vhost_started (else)
> > block, and call vhost_net_stop(); while it is running that function,
> > another thread is notified that the vhost-user device has been closed,
> > and (indirectly) calls into virtio_net_vhost_status() also.
>
>
> I think we need figure out why there are multiple vhost_net_stop() calls
> simultaneously. E.g vhost-user register fd handlers like:
>
> qemu_chr_fe_set_handlers(&s->chr, NULL, NULL,
> net_vhost_user_event, NULL, nc0->name,
> NULL,
> true);
>
> which uses default main context, so it should only be called only in
> main thread.
net_vhost_user_event() schedules chr_closed_bh() to do its bottom half
work; does aio_bh_schedule_oneshot() execute its events from the main
thread?
For reference, the call chain is:
chr_closed_bh()
qmp_set_link()
nc->info->link_status_changed() -> virtio_net_set_link_status()
virtio_net_set_status()
virtio_net_vhost_status()
>
> Thanks
>
>
> > Since the
> > vhost_net status hasn't yet changed, the second thread also enters
> > the n->vhost_started block, and also calls vhost_net_stop(). This
> > causes problems for the second thread when it tries to stop the network
> > that's already been stopped.
> >
> > This adds a flag to the struct that's atomically set to prevent more than
> > one thread from calling vhost_net_stop(). The atomic_fetch_inc() is likely
> > overkill and probably could be done with a simple check-and-set, but
> > since it's a race condition there would still be a (very, very) small
> > window without using an atomic to set it.
> >
> > Signed-off-by: Dan Streetman <ddstreet@canonical.com>
> > ---
> > hw/net/virtio-net.c | 3 ++-
> > include/hw/virtio/virtio-net.h | 1 +
> > 2 files changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
> > index ffe0872fff..d36f50d5dd 100644
> > --- a/hw/net/virtio-net.c
> > +++ b/hw/net/virtio-net.c
> > @@ -13,6 +13,7 @@
> >
> > #include "qemu/osdep.h"
> > #include "qemu/iov.h"
> > +#include "qemu/atomic.h"
> > #include "hw/virtio/virtio.h"
> > #include "net/net.h"
> > #include "net/checksum.h"
> > @@ -240,7 +241,7 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status)
> > "falling back on userspace virtio", -r);
> > n->vhost_started = 0;
> > }
> > - } else {
> > + } else if (atomic_fetch_inc(&n->vhost_stopped) == 0) {
> > vhost_net_stop(vdev, n->nic->ncs, queues);
> > n->vhost_started = 0;
> > }
> > diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h
> > index b96f0c643f..d03fd933d0 100644
> > --- a/include/hw/virtio/virtio-net.h
> > +++ b/include/hw/virtio/virtio-net.h
> > @@ -164,6 +164,7 @@ struct VirtIONet {
> > uint8_t nouni;
> > uint8_t nobcast;
> > uint8_t vhost_started;
> > + int vhost_stopped;
> > struct {
> > uint32_t in_use;
> > uint32_t first_multi;
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] add VirtIONet vhost_stopped flag to prevent multiple stops
@ 2019-04-22 20:14 ` Dan Streetman
0 siblings, 0 replies; 289+ messages in thread
From: Dan Streetman @ 2019-04-22 20:14 UTC (permalink / raw)
To: Jason Wang; +Cc: qemu-stable, qemu-devel, Michael S. Tsirkin
On Sun, Apr 21, 2019 at 10:50 PM Jason Wang <jasowang@redhat.com> wrote:
>
>
> On 2019/4/17 上午2:46, Dan Streetman wrote:
> > From: Dan Streetman <ddstreet@canonical.com>
> >
> > Buglink: https://launchpad.net/bugs/1823458
> >
> > There is a race condition when using the vhost-user driver, between a guest
> > shutdown and the vhost-user interface being closed. This is explained in
> > more detail at the bug link above; the short explanation is the vhost-user
> > device can be closed while the main thread is in the middle of stopping
> > the vhost_net. In this case, the main thread handling shutdown will
> > enter virtio_net_vhost_status() and move into the n->vhost_started (else)
> > block, and call vhost_net_stop(); while it is running that function,
> > another thread is notified that the vhost-user device has been closed,
> > and (indirectly) calls into virtio_net_vhost_status() also.
>
>
> I think we need figure out why there are multiple vhost_net_stop() calls
> simultaneously. E.g vhost-user register fd handlers like:
>
> qemu_chr_fe_set_handlers(&s->chr, NULL, NULL,
> net_vhost_user_event, NULL, nc0->name,
> NULL,
> true);
>
> which uses default main context, so it should only be called only in
> main thread.
net_vhost_user_event() schedules chr_closed_bh() to do its bottom half
work; does aio_bh_schedule_oneshot() execute its events from the main
thread?
For reference, the call chain is:
chr_closed_bh()
qmp_set_link()
nc->info->link_status_changed() -> virtio_net_set_link_status()
virtio_net_set_status()
virtio_net_vhost_status()
>
> Thanks
>
>
> > Since the
> > vhost_net status hasn't yet changed, the second thread also enters
> > the n->vhost_started block, and also calls vhost_net_stop(). This
> > causes problems for the second thread when it tries to stop the network
> > that's already been stopped.
> >
> > This adds a flag to the struct that's atomically set to prevent more than
> > one thread from calling vhost_net_stop(). The atomic_fetch_inc() is likely
> > overkill and probably could be done with a simple check-and-set, but
> > since it's a race condition there would still be a (very, very) small
> > window without using an atomic to set it.
> >
> > Signed-off-by: Dan Streetman <ddstreet@canonical.com>
> > ---
> > hw/net/virtio-net.c | 3 ++-
> > include/hw/virtio/virtio-net.h | 1 +
> > 2 files changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
> > index ffe0872fff..d36f50d5dd 100644
> > --- a/hw/net/virtio-net.c
> > +++ b/hw/net/virtio-net.c
> > @@ -13,6 +13,7 @@
> >
> > #include "qemu/osdep.h"
> > #include "qemu/iov.h"
> > +#include "qemu/atomic.h"
> > #include "hw/virtio/virtio.h"
> > #include "net/net.h"
> > #include "net/checksum.h"
> > @@ -240,7 +241,7 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status)
> > "falling back on userspace virtio", -r);
> > n->vhost_started = 0;
> > }
> > - } else {
> > + } else if (atomic_fetch_inc(&n->vhost_stopped) == 0) {
> > vhost_net_stop(vdev, n->nic->ncs, queues);
> > n->vhost_started = 0;
> > }
> > diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h
> > index b96f0c643f..d03fd933d0 100644
> > --- a/include/hw/virtio/virtio-net.h
> > +++ b/include/hw/virtio/virtio-net.h
> > @@ -164,6 +164,7 @@ struct VirtIONet {
> > uint8_t nouni;
> > uint8_t nobcast;
> > uint8_t vhost_started;
> > + int vhost_stopped;
> > struct {
> > uint32_t in_use;
> > uint32_t first_multi;
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] add VirtIONet vhost_stopped flag to prevent multiple stops
2019-04-19 23:14 ` Michael S. Tsirkin
@ 2019-04-22 20:31 ` Dan Streetman
0 siblings, 0 replies; 289+ messages in thread
From: Dan Streetman @ 2019-04-22 20:31 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: Jason Wang, qemu-devel, qemu-stable
On Fri, Apr 19, 2019 at 7:14 PM Michael S. Tsirkin <mst@redhat.com> wrote:
>
> On Tue, Apr 16, 2019 at 02:46:23PM -0400, Dan Streetman wrote:
> > From: Dan Streetman <ddstreet@canonical.com>
> >
> > Buglink: https://launchpad.net/bugs/1823458
> >
> > There is a race condition when using the vhost-user driver, between a guest
> > shutdown and the vhost-user interface being closed. This is explained in
> > more detail at the bug link above; the short explanation is the vhost-user
> > device can be closed while the main thread is in the middle of stopping
> > the vhost_net. In this case, the main thread handling shutdown will
> > enter virtio_net_vhost_status() and move into the n->vhost_started (else)
> > block, and call vhost_net_stop(); while it is running that function,
> > another thread is notified that the vhost-user device has been closed,
> > and (indirectly) calls into virtio_net_vhost_status() also. Since the
> > vhost_net status hasn't yet changed, the second thread also enters
> > the n->vhost_started block, and also calls vhost_net_stop(). This
> > causes problems for the second thread when it tries to stop the network
> > that's already been stopped.
> >
> > This adds a flag to the struct that's atomically set to prevent more than
> > one thread from calling vhost_net_stop(). The atomic_fetch_inc() is likely
> > overkill and probably could be done with a simple check-and-set, but
> > since it's a race condition there would still be a (very, very) small
> > window without using an atomic to set it.
>
> How? Isn't all this under the BQL?
I don't think so, although I'm not deeply familiar with the code.
Note the code path listed in my last email, run from
aio_bh_schedule_oneshot() - does that hold the bql while running?
>
> >
> > Signed-off-by: Dan Streetman <ddstreet@canonical.com>
> > ---
> > hw/net/virtio-net.c | 3 ++-
> > include/hw/virtio/virtio-net.h | 1 +
> > 2 files changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
> > index ffe0872fff..d36f50d5dd 100644
> > --- a/hw/net/virtio-net.c
> > +++ b/hw/net/virtio-net.c
> > @@ -13,6 +13,7 @@
> >
> > #include "qemu/osdep.h"
> > #include "qemu/iov.h"
> > +#include "qemu/atomic.h"
> > #include "hw/virtio/virtio.h"
> > #include "net/net.h"
> > #include "net/checksum.h"
> > @@ -240,7 +241,7 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status)
> > "falling back on userspace virtio", -r);
> > n->vhost_started = 0;
> > }
> > - } else {
> > + } else if (atomic_fetch_inc(&n->vhost_stopped) == 0) {
> > vhost_net_stop(vdev, n->nic->ncs, queues);
> > n->vhost_started = 0;
> > }
> > diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h
> > index b96f0c643f..d03fd933d0 100644
> > --- a/include/hw/virtio/virtio-net.h
> > +++ b/include/hw/virtio/virtio-net.h
> > @@ -164,6 +164,7 @@ struct VirtIONet {
> > uint8_t nouni;
> > uint8_t nobcast;
> > uint8_t vhost_started;
> > + int vhost_stopped;
> > struct {
> > uint32_t in_use;
> > uint32_t first_multi;
>
> OK questions same as any state:
>
> - do we need to migrate this?
> - reset it on device reset?
>
> > --
> > 2.20.1
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] add VirtIONet vhost_stopped flag to prevent multiple stops
@ 2019-04-23 2:58 ` Jason Wang
0 siblings, 0 replies; 289+ messages in thread
From: Jason Wang @ 2019-04-23 2:58 UTC (permalink / raw)
To: Dan Streetman
Cc: Michael S. Tsirkin, qemu-devel, qemu-stable,
marcandre.lureau@redhat.com >> Marc-André Lureau
On 2019/4/23 上午4:14, Dan Streetman wrote:
> On Sun, Apr 21, 2019 at 10:50 PM Jason Wang <jasowang@redhat.com> wrote:
>>
>> On 2019/4/17 上午2:46, Dan Streetman wrote:
>>> From: Dan Streetman <ddstreet@canonical.com>
>>>
>>> Buglink: https://launchpad.net/bugs/1823458
>>>
>>> There is a race condition when using the vhost-user driver, between a guest
>>> shutdown and the vhost-user interface being closed. This is explained in
>>> more detail at the bug link above; the short explanation is the vhost-user
>>> device can be closed while the main thread is in the middle of stopping
>>> the vhost_net. In this case, the main thread handling shutdown will
>>> enter virtio_net_vhost_status() and move into the n->vhost_started (else)
>>> block, and call vhost_net_stop(); while it is running that function,
>>> another thread is notified that the vhost-user device has been closed,
>>> and (indirectly) calls into virtio_net_vhost_status() also.
>>
>> I think we need figure out why there are multiple vhost_net_stop() calls
>> simultaneously. E.g vhost-user register fd handlers like:
>>
>> qemu_chr_fe_set_handlers(&s->chr, NULL, NULL,
>> net_vhost_user_event, NULL, nc0->name,
>> NULL,
>> true);
>>
>> which uses default main context, so it should only be called only in
>> main thread.
> net_vhost_user_event() schedules chr_closed_bh() to do its bottom half
> work; does aio_bh_schedule_oneshot() execute its events from the main
> thread?
I think so if net_vhost_user_event() was called in main thread (it calls
qemu_get_current_aio_context()).
>
> For reference, the call chain is:
>
> chr_closed_bh()
> qmp_set_link()
> nc->info->link_status_changed() -> virtio_net_set_link_status()
> virtio_net_set_status()
> virtio_net_vhost_status()
The code was added by Marc since:
commit e7c83a885f865128ae3cf1946f8cb538b63cbfba
Author: Marc-André Lureau <marcandre.lureau@redhat.com>
Date: Mon Feb 27 14:49:56 2017 +0400
vhost-user: delay vhost_user_stop
Cc him for more thoughts.
Thanks
>> Thanks
>>
>>
>>> Since the
>>> vhost_net status hasn't yet changed, the second thread also enters
>>> the n->vhost_started block, and also calls vhost_net_stop(). This
>>> causes problems for the second thread when it tries to stop the network
>>> that's already been stopped.
>>>
>>> This adds a flag to the struct that's atomically set to prevent more than
>>> one thread from calling vhost_net_stop(). The atomic_fetch_inc() is likely
>>> overkill and probably could be done with a simple check-and-set, but
>>> since it's a race condition there would still be a (very, very) small
>>> window without using an atomic to set it.
>>>
>>> Signed-off-by: Dan Streetman <ddstreet@canonical.com>
>>> ---
>>> hw/net/virtio-net.c | 3 ++-
>>> include/hw/virtio/virtio-net.h | 1 +
>>> 2 files changed, 3 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
>>> index ffe0872fff..d36f50d5dd 100644
>>> --- a/hw/net/virtio-net.c
>>> +++ b/hw/net/virtio-net.c
>>> @@ -13,6 +13,7 @@
>>>
>>> #include "qemu/osdep.h"
>>> #include "qemu/iov.h"
>>> +#include "qemu/atomic.h"
>>> #include "hw/virtio/virtio.h"
>>> #include "net/net.h"
>>> #include "net/checksum.h"
>>> @@ -240,7 +241,7 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status)
>>> "falling back on userspace virtio", -r);
>>> n->vhost_started = 0;
>>> }
>>> - } else {
>>> + } else if (atomic_fetch_inc(&n->vhost_stopped) == 0) {
>>> vhost_net_stop(vdev, n->nic->ncs, queues);
>>> n->vhost_started = 0;
>>> }
>>> diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h
>>> index b96f0c643f..d03fd933d0 100644
>>> --- a/include/hw/virtio/virtio-net.h
>>> +++ b/include/hw/virtio/virtio-net.h
>>> @@ -164,6 +164,7 @@ struct VirtIONet {
>>> uint8_t nouni;
>>> uint8_t nobcast;
>>> uint8_t vhost_started;
>>> + int vhost_stopped;
>>> struct {
>>> uint32_t in_use;
>>> uint32_t first_multi;
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] add VirtIONet vhost_stopped flag to prevent multiple stops
@ 2019-04-23 2:58 ` Jason Wang
0 siblings, 0 replies; 289+ messages in thread
From: Jason Wang @ 2019-04-23 2:58 UTC (permalink / raw)
To: Dan Streetman
Cc: marcandre.lureau@redhat.com >> Marc-André Lureau,
qemu-stable, qemu-devel, Michael S. Tsirkin
On 2019/4/23 上午4:14, Dan Streetman wrote:
> On Sun, Apr 21, 2019 at 10:50 PM Jason Wang <jasowang@redhat.com> wrote:
>>
>> On 2019/4/17 上午2:46, Dan Streetman wrote:
>>> From: Dan Streetman <ddstreet@canonical.com>
>>>
>>> Buglink: https://launchpad.net/bugs/1823458
>>>
>>> There is a race condition when using the vhost-user driver, between a guest
>>> shutdown and the vhost-user interface being closed. This is explained in
>>> more detail at the bug link above; the short explanation is the vhost-user
>>> device can be closed while the main thread is in the middle of stopping
>>> the vhost_net. In this case, the main thread handling shutdown will
>>> enter virtio_net_vhost_status() and move into the n->vhost_started (else)
>>> block, and call vhost_net_stop(); while it is running that function,
>>> another thread is notified that the vhost-user device has been closed,
>>> and (indirectly) calls into virtio_net_vhost_status() also.
>>
>> I think we need figure out why there are multiple vhost_net_stop() calls
>> simultaneously. E.g vhost-user register fd handlers like:
>>
>> qemu_chr_fe_set_handlers(&s->chr, NULL, NULL,
>> net_vhost_user_event, NULL, nc0->name,
>> NULL,
>> true);
>>
>> which uses default main context, so it should only be called only in
>> main thread.
> net_vhost_user_event() schedules chr_closed_bh() to do its bottom half
> work; does aio_bh_schedule_oneshot() execute its events from the main
> thread?
I think so if net_vhost_user_event() was called in main thread (it calls
qemu_get_current_aio_context()).
>
> For reference, the call chain is:
>
> chr_closed_bh()
> qmp_set_link()
> nc->info->link_status_changed() -> virtio_net_set_link_status()
> virtio_net_set_status()
> virtio_net_vhost_status()
The code was added by Marc since:
commit e7c83a885f865128ae3cf1946f8cb538b63cbfba
Author: Marc-André Lureau <marcandre.lureau@redhat.com>
Date: Mon Feb 27 14:49:56 2017 +0400
vhost-user: delay vhost_user_stop
Cc him for more thoughts.
Thanks
>> Thanks
>>
>>
>>> Since the
>>> vhost_net status hasn't yet changed, the second thread also enters
>>> the n->vhost_started block, and also calls vhost_net_stop(). This
>>> causes problems for the second thread when it tries to stop the network
>>> that's already been stopped.
>>>
>>> This adds a flag to the struct that's atomically set to prevent more than
>>> one thread from calling vhost_net_stop(). The atomic_fetch_inc() is likely
>>> overkill and probably could be done with a simple check-and-set, but
>>> since it's a race condition there would still be a (very, very) small
>>> window without using an atomic to set it.
>>>
>>> Signed-off-by: Dan Streetman <ddstreet@canonical.com>
>>> ---
>>> hw/net/virtio-net.c | 3 ++-
>>> include/hw/virtio/virtio-net.h | 1 +
>>> 2 files changed, 3 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
>>> index ffe0872fff..d36f50d5dd 100644
>>> --- a/hw/net/virtio-net.c
>>> +++ b/hw/net/virtio-net.c
>>> @@ -13,6 +13,7 @@
>>>
>>> #include "qemu/osdep.h"
>>> #include "qemu/iov.h"
>>> +#include "qemu/atomic.h"
>>> #include "hw/virtio/virtio.h"
>>> #include "net/net.h"
>>> #include "net/checksum.h"
>>> @@ -240,7 +241,7 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status)
>>> "falling back on userspace virtio", -r);
>>> n->vhost_started = 0;
>>> }
>>> - } else {
>>> + } else if (atomic_fetch_inc(&n->vhost_stopped) == 0) {
>>> vhost_net_stop(vdev, n->nic->ncs, queues);
>>> n->vhost_started = 0;
>>> }
>>> diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h
>>> index b96f0c643f..d03fd933d0 100644
>>> --- a/include/hw/virtio/virtio-net.h
>>> +++ b/include/hw/virtio/virtio-net.h
>>> @@ -164,6 +164,7 @@ struct VirtIONet {
>>> uint8_t nouni;
>>> uint8_t nobcast;
>>> uint8_t vhost_started;
>>> + int vhost_stopped;
>>> struct {
>>> uint32_t in_use;
>>> uint32_t first_multi;
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] add VirtIONet vhost_stopped flag to prevent multiple stops
@ 2019-04-23 8:49 ` Dan Streetman
0 siblings, 0 replies; 289+ messages in thread
From: Dan Streetman @ 2019-04-23 8:49 UTC (permalink / raw)
To: Jason Wang
Cc: Michael S. Tsirkin, qemu-devel, qemu-stable,
marcandre.lureau@redhat.com >> Marc-André Lureau
On Mon, Apr 22, 2019 at 10:59 PM Jason Wang <jasowang@redhat.com> wrote:
>
>
> On 2019/4/23 上午4:14, Dan Streetman wrote:
> > On Sun, Apr 21, 2019 at 10:50 PM Jason Wang <jasowang@redhat.com> wrote:
> >>
> >> On 2019/4/17 上午2:46, Dan Streetman wrote:
> >>> From: Dan Streetman <ddstreet@canonical.com>
> >>>
> >>> Buglink: https://launchpad.net/bugs/1823458
> >>>
> >>> There is a race condition when using the vhost-user driver, between a guest
> >>> shutdown and the vhost-user interface being closed. This is explained in
> >>> more detail at the bug link above; the short explanation is the vhost-user
> >>> device can be closed while the main thread is in the middle of stopping
> >>> the vhost_net. In this case, the main thread handling shutdown will
> >>> enter virtio_net_vhost_status() and move into the n->vhost_started (else)
> >>> block, and call vhost_net_stop(); while it is running that function,
> >>> another thread is notified that the vhost-user device has been closed,
> >>> and (indirectly) calls into virtio_net_vhost_status() also.
> >>
> >> I think we need figure out why there are multiple vhost_net_stop() calls
> >> simultaneously. E.g vhost-user register fd handlers like:
> >>
> >> qemu_chr_fe_set_handlers(&s->chr, NULL, NULL,
> >> net_vhost_user_event, NULL, nc0->name,
> >> NULL,
> >> true);
> >>
> >> which uses default main context, so it should only be called only in
> >> main thread.
> > net_vhost_user_event() schedules chr_closed_bh() to do its bottom half
> > work; does aio_bh_schedule_oneshot() execute its events from the main
> > thread?
>
>
> I think so if net_vhost_user_event() was called in main thread (it calls
> qemu_get_current_aio_context()).
ok, I'll check that, thanks!
I think my other patch, to remove the vhost_user_stop() call
completely from the net_vhost_user_event() handler for
CHR_EVENT_CLOSED, is still relevant; do you have thoughts on that?
>
>
> >
> > For reference, the call chain is:
> >
> > chr_closed_bh()
> > qmp_set_link()
> > nc->info->link_status_changed() -> virtio_net_set_link_status()
> > virtio_net_set_status()
> > virtio_net_vhost_status()
>
>
> The code was added by Marc since:
>
> commit e7c83a885f865128ae3cf1946f8cb538b63cbfba
> Author: Marc-André Lureau <marcandre.lureau@redhat.com>
> Date: Mon Feb 27 14:49:56 2017 +0400
>
> vhost-user: delay vhost_user_stop
>
> Cc him for more thoughts.
>
> Thanks
>
>
> >> Thanks
> >>
> >>
> >>> Since the
> >>> vhost_net status hasn't yet changed, the second thread also enters
> >>> the n->vhost_started block, and also calls vhost_net_stop(). This
> >>> causes problems for the second thread when it tries to stop the network
> >>> that's already been stopped.
> >>>
> >>> This adds a flag to the struct that's atomically set to prevent more than
> >>> one thread from calling vhost_net_stop(). The atomic_fetch_inc() is likely
> >>> overkill and probably could be done with a simple check-and-set, but
> >>> since it's a race condition there would still be a (very, very) small
> >>> window without using an atomic to set it.
> >>>
> >>> Signed-off-by: Dan Streetman <ddstreet@canonical.com>
> >>> ---
> >>> hw/net/virtio-net.c | 3 ++-
> >>> include/hw/virtio/virtio-net.h | 1 +
> >>> 2 files changed, 3 insertions(+), 1 deletion(-)
> >>>
> >>> diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
> >>> index ffe0872fff..d36f50d5dd 100644
> >>> --- a/hw/net/virtio-net.c
> >>> +++ b/hw/net/virtio-net.c
> >>> @@ -13,6 +13,7 @@
> >>>
> >>> #include "qemu/osdep.h"
> >>> #include "qemu/iov.h"
> >>> +#include "qemu/atomic.h"
> >>> #include "hw/virtio/virtio.h"
> >>> #include "net/net.h"
> >>> #include "net/checksum.h"
> >>> @@ -240,7 +241,7 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status)
> >>> "falling back on userspace virtio", -r);
> >>> n->vhost_started = 0;
> >>> }
> >>> - } else {
> >>> + } else if (atomic_fetch_inc(&n->vhost_stopped) == 0) {
> >>> vhost_net_stop(vdev, n->nic->ncs, queues);
> >>> n->vhost_started = 0;
> >>> }
> >>> diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h
> >>> index b96f0c643f..d03fd933d0 100644
> >>> --- a/include/hw/virtio/virtio-net.h
> >>> +++ b/include/hw/virtio/virtio-net.h
> >>> @@ -164,6 +164,7 @@ struct VirtIONet {
> >>> uint8_t nouni;
> >>> uint8_t nobcast;
> >>> uint8_t vhost_started;
> >>> + int vhost_stopped;
> >>> struct {
> >>> uint32_t in_use;
> >>> uint32_t first_multi;
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] add VirtIONet vhost_stopped flag to prevent multiple stops
@ 2019-04-23 8:49 ` Dan Streetman
0 siblings, 0 replies; 289+ messages in thread
From: Dan Streetman @ 2019-04-23 8:49 UTC (permalink / raw)
To: Jason Wang
Cc: marcandre.lureau@redhat.com >> Marc-André Lureau,
qemu-stable, qemu-devel, Michael S. Tsirkin
On Mon, Apr 22, 2019 at 10:59 PM Jason Wang <jasowang@redhat.com> wrote:
>
>
> On 2019/4/23 上午4:14, Dan Streetman wrote:
> > On Sun, Apr 21, 2019 at 10:50 PM Jason Wang <jasowang@redhat.com> wrote:
> >>
> >> On 2019/4/17 上午2:46, Dan Streetman wrote:
> >>> From: Dan Streetman <ddstreet@canonical.com>
> >>>
> >>> Buglink: https://launchpad.net/bugs/1823458
> >>>
> >>> There is a race condition when using the vhost-user driver, between a guest
> >>> shutdown and the vhost-user interface being closed. This is explained in
> >>> more detail at the bug link above; the short explanation is the vhost-user
> >>> device can be closed while the main thread is in the middle of stopping
> >>> the vhost_net. In this case, the main thread handling shutdown will
> >>> enter virtio_net_vhost_status() and move into the n->vhost_started (else)
> >>> block, and call vhost_net_stop(); while it is running that function,
> >>> another thread is notified that the vhost-user device has been closed,
> >>> and (indirectly) calls into virtio_net_vhost_status() also.
> >>
> >> I think we need figure out why there are multiple vhost_net_stop() calls
> >> simultaneously. E.g vhost-user register fd handlers like:
> >>
> >> qemu_chr_fe_set_handlers(&s->chr, NULL, NULL,
> >> net_vhost_user_event, NULL, nc0->name,
> >> NULL,
> >> true);
> >>
> >> which uses default main context, so it should only be called only in
> >> main thread.
> > net_vhost_user_event() schedules chr_closed_bh() to do its bottom half
> > work; does aio_bh_schedule_oneshot() execute its events from the main
> > thread?
>
>
> I think so if net_vhost_user_event() was called in main thread (it calls
> qemu_get_current_aio_context()).
ok, I'll check that, thanks!
I think my other patch, to remove the vhost_user_stop() call
completely from the net_vhost_user_event() handler for
CHR_EVENT_CLOSED, is still relevant; do you have thoughts on that?
>
>
> >
> > For reference, the call chain is:
> >
> > chr_closed_bh()
> > qmp_set_link()
> > nc->info->link_status_changed() -> virtio_net_set_link_status()
> > virtio_net_set_status()
> > virtio_net_vhost_status()
>
>
> The code was added by Marc since:
>
> commit e7c83a885f865128ae3cf1946f8cb538b63cbfba
> Author: Marc-André Lureau <marcandre.lureau@redhat.com>
> Date: Mon Feb 27 14:49:56 2017 +0400
>
> vhost-user: delay vhost_user_stop
>
> Cc him for more thoughts.
>
> Thanks
>
>
> >> Thanks
> >>
> >>
> >>> Since the
> >>> vhost_net status hasn't yet changed, the second thread also enters
> >>> the n->vhost_started block, and also calls vhost_net_stop(). This
> >>> causes problems for the second thread when it tries to stop the network
> >>> that's already been stopped.
> >>>
> >>> This adds a flag to the struct that's atomically set to prevent more than
> >>> one thread from calling vhost_net_stop(). The atomic_fetch_inc() is likely
> >>> overkill and probably could be done with a simple check-and-set, but
> >>> since it's a race condition there would still be a (very, very) small
> >>> window without using an atomic to set it.
> >>>
> >>> Signed-off-by: Dan Streetman <ddstreet@canonical.com>
> >>> ---
> >>> hw/net/virtio-net.c | 3 ++-
> >>> include/hw/virtio/virtio-net.h | 1 +
> >>> 2 files changed, 3 insertions(+), 1 deletion(-)
> >>>
> >>> diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
> >>> index ffe0872fff..d36f50d5dd 100644
> >>> --- a/hw/net/virtio-net.c
> >>> +++ b/hw/net/virtio-net.c
> >>> @@ -13,6 +13,7 @@
> >>>
> >>> #include "qemu/osdep.h"
> >>> #include "qemu/iov.h"
> >>> +#include "qemu/atomic.h"
> >>> #include "hw/virtio/virtio.h"
> >>> #include "net/net.h"
> >>> #include "net/checksum.h"
> >>> @@ -240,7 +241,7 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status)
> >>> "falling back on userspace virtio", -r);
> >>> n->vhost_started = 0;
> >>> }
> >>> - } else {
> >>> + } else if (atomic_fetch_inc(&n->vhost_stopped) == 0) {
> >>> vhost_net_stop(vdev, n->nic->ncs, queues);
> >>> n->vhost_started = 0;
> >>> }
> >>> diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h
> >>> index b96f0c643f..d03fd933d0 100644
> >>> --- a/include/hw/virtio/virtio-net.h
> >>> +++ b/include/hw/virtio/virtio-net.h
> >>> @@ -164,6 +164,7 @@ struct VirtIONet {
> >>> uint8_t nouni;
> >>> uint8_t nobcast;
> >>> uint8_t vhost_started;
> >>> + int vhost_stopped;
> >>> struct {
> >>> uint32_t in_use;
> >>> uint32_t first_multi;
^ permalink raw reply [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v2 0/3] Simplify some not-really-necessary PCI bus callbacks
@ 2019-04-24 4:19 ` David Gibson
0 siblings, 0 replies; 289+ messages in thread
From: David Gibson @ 2019-04-24 4:19 UTC (permalink / raw)
To: Marcel Apfelbaum, qemu-devel, Michael S. Tsirkin,
Alex Williamson, Greg Kurz
Cc: David Gibson, clg, qemu-ppc
c2077e2c "pci: Adjust PCI config limit based on bus topology"
introduced checking the availability of extended config space for
PCI-E devices which are in a bus topology that doesn't permit extended
config space access (e.g. under PCI-E to PCI then PCI to PCI-E
bridges).
This caused some problems for the spapr para-virtual PCI bus which
_does_ allow extended config space access, despite acting in most ways
like a vanilla PCI bus.
Greg Kurz made a fix for that which was merged as 1c685a90263 "pci:
Allow PCI bus subtypes to support extended config space accesses".
While that was an appropriate minimal fix for the 4.0 hard freeze, it
was kind of a hack longer term.
This series implements a simpler way of handling the extended config
space permission, which works for both the normal and weird-PAPR
cases. While we're there, we also make other small cleanups to the
PCI code.
David Gibson (3):
pcie: Remove redundant test in pcie_mmcfg_data_{read,write}()
pci: Simplify pci_bus_is_root()
pcie: Simplify pci_adjust_config_limit()
hw/pci-bridge/pci_expander_bridge.c | 6 ----
hw/pci/pci.c | 55 +++++++++++++----------------
hw/pci/pci_host.c | 13 ++-----
hw/pci/pcie_host.c | 10 ------
hw/ppc/spapr_pci.c | 34 ++++++------------
hw/virtio/virtio-pci.c | 1 +
include/hw/pci/pci.h | 2 --
include/hw/pci/pci_bus.h | 21 +++++++++--
8 files changed, 58 insertions(+), 84 deletions(-)
--
2.20.1
^ permalink raw reply [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v2 0/3] Simplify some not-really-necessary PCI bus callbacks
@ 2019-04-24 4:19 ` David Gibson
0 siblings, 0 replies; 289+ messages in thread
From: David Gibson @ 2019-04-24 4:19 UTC (permalink / raw)
To: Marcel Apfelbaum, qemu-devel, Michael S. Tsirkin,
Alex Williamson, Greg Kurz
Cc: qemu-ppc, clg, David Gibson
c2077e2c "pci: Adjust PCI config limit based on bus topology"
introduced checking the availability of extended config space for
PCI-E devices which are in a bus topology that doesn't permit extended
config space access (e.g. under PCI-E to PCI then PCI to PCI-E
bridges).
This caused some problems for the spapr para-virtual PCI bus which
_does_ allow extended config space access, despite acting in most ways
like a vanilla PCI bus.
Greg Kurz made a fix for that which was merged as 1c685a90263 "pci:
Allow PCI bus subtypes to support extended config space accesses".
While that was an appropriate minimal fix for the 4.0 hard freeze, it
was kind of a hack longer term.
This series implements a simpler way of handling the extended config
space permission, which works for both the normal and weird-PAPR
cases. While we're there, we also make other small cleanups to the
PCI code.
David Gibson (3):
pcie: Remove redundant test in pcie_mmcfg_data_{read,write}()
pci: Simplify pci_bus_is_root()
pcie: Simplify pci_adjust_config_limit()
hw/pci-bridge/pci_expander_bridge.c | 6 ----
hw/pci/pci.c | 55 +++++++++++++----------------
hw/pci/pci_host.c | 13 ++-----
hw/pci/pcie_host.c | 10 ------
hw/ppc/spapr_pci.c | 34 ++++++------------
hw/virtio/virtio-pci.c | 1 +
include/hw/pci/pci.h | 2 --
include/hw/pci/pci_bus.h | 21 +++++++++--
8 files changed, 58 insertions(+), 84 deletions(-)
--
2.20.1
^ permalink raw reply [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v2 1/3] pcie: Remove redundant test in pcie_mmcfg_data_{read, write}()
@ 2019-04-24 4:19 ` David Gibson
0 siblings, 0 replies; 289+ messages in thread
From: David Gibson @ 2019-04-24 4:19 UTC (permalink / raw)
To: Marcel Apfelbaum, qemu-devel, Michael S. Tsirkin,
Alex Williamson, Greg Kurz
Cc: David Gibson, clg, qemu-ppc
These functions have an explicit test for accesses above the device's
config size. But pci_host_config_{read,write}_common() which they're
about to call already have checks against the config space limit and
do the right thing. So, remove the redundant tests.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
hw/pci/pcie_host.c | 10 ----------
1 file changed, 10 deletions(-)
diff --git a/hw/pci/pcie_host.c b/hw/pci/pcie_host.c
index 553db56778..1ee4945a6d 100644
--- a/hw/pci/pcie_host.c
+++ b/hw/pci/pcie_host.c
@@ -47,11 +47,6 @@ static void pcie_mmcfg_data_write(void *opaque, hwaddr mmcfg_addr,
}
addr = PCIE_MMCFG_CONFOFFSET(mmcfg_addr);
limit = pci_config_size(pci_dev);
- if (limit <= addr) {
- /* conventional pci device can be behind pcie-to-pci bridge.
- 256 <= addr < 4K has no effects. */
- return;
- }
pci_host_config_write_common(pci_dev, addr, limit, val, len);
}
@@ -70,11 +65,6 @@ static uint64_t pcie_mmcfg_data_read(void *opaque,
}
addr = PCIE_MMCFG_CONFOFFSET(mmcfg_addr);
limit = pci_config_size(pci_dev);
- if (limit <= addr) {
- /* conventional pci device can be behind pcie-to-pci bridge.
- 256 <= addr < 4K has no effects. */
- return ~0x0;
- }
return pci_host_config_read_common(pci_dev, addr, limit, len);
}
--
2.20.1
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v2 1/3] pcie: Remove redundant test in pcie_mmcfg_data_{read, write}()
@ 2019-04-24 4:19 ` David Gibson
0 siblings, 0 replies; 289+ messages in thread
From: David Gibson @ 2019-04-24 4:19 UTC (permalink / raw)
To: Marcel Apfelbaum, qemu-devel, Michael S. Tsirkin,
Alex Williamson, Greg Kurz
Cc: qemu-ppc, clg, David Gibson
These functions have an explicit test for accesses above the device's
config size. But pci_host_config_{read,write}_common() which they're
about to call already have checks against the config space limit and
do the right thing. So, remove the redundant tests.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
hw/pci/pcie_host.c | 10 ----------
1 file changed, 10 deletions(-)
diff --git a/hw/pci/pcie_host.c b/hw/pci/pcie_host.c
index 553db56778..1ee4945a6d 100644
--- a/hw/pci/pcie_host.c
+++ b/hw/pci/pcie_host.c
@@ -47,11 +47,6 @@ static void pcie_mmcfg_data_write(void *opaque, hwaddr mmcfg_addr,
}
addr = PCIE_MMCFG_CONFOFFSET(mmcfg_addr);
limit = pci_config_size(pci_dev);
- if (limit <= addr) {
- /* conventional pci device can be behind pcie-to-pci bridge.
- 256 <= addr < 4K has no effects. */
- return;
- }
pci_host_config_write_common(pci_dev, addr, limit, val, len);
}
@@ -70,11 +65,6 @@ static uint64_t pcie_mmcfg_data_read(void *opaque,
}
addr = PCIE_MMCFG_CONFOFFSET(mmcfg_addr);
limit = pci_config_size(pci_dev);
- if (limit <= addr) {
- /* conventional pci device can be behind pcie-to-pci bridge.
- 256 <= addr < 4K has no effects. */
- return ~0x0;
- }
return pci_host_config_read_common(pci_dev, addr, limit, len);
}
--
2.20.1
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v2 2/3] pci: Simplify pci_bus_is_root()
@ 2019-04-24 4:19 ` David Gibson
0 siblings, 0 replies; 289+ messages in thread
From: David Gibson @ 2019-04-24 4:19 UTC (permalink / raw)
To: Marcel Apfelbaum, qemu-devel, Michael S. Tsirkin,
Alex Williamson, Greg Kurz
Cc: David Gibson, clg, qemu-ppc, Marcel Apfelbaum, Peter Xu
pci_bus_is_root() currently relies on a method in the PCIBusClass.
But it's always known if a PCI bus is a root bus when we create it, so
using a dynamic method is overkill.
This replaces it with an IS_ROOT bit in a new flags field, which is set on
root buses and otherwise clear. As a bonus this removes the special
is_root logic from pci_expander_bridge, since it already creates its bus
as a root bus.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
---
hw/pci-bridge/pci_expander_bridge.c | 6 ------
hw/pci/pci.c | 14 ++------------
hw/virtio/virtio-pci.c | 1 +
include/hw/pci/pci.h | 1 -
include/hw/pci/pci_bus.h | 12 +++++++++++-
5 files changed, 14 insertions(+), 20 deletions(-)
diff --git a/hw/pci-bridge/pci_expander_bridge.c b/hw/pci-bridge/pci_expander_bridge.c
index e62de4218f..ca66bc721a 100644
--- a/hw/pci-bridge/pci_expander_bridge.c
+++ b/hw/pci-bridge/pci_expander_bridge.c
@@ -66,11 +66,6 @@ static int pxb_bus_num(PCIBus *bus)
return pxb->bus_nr;
}
-static bool pxb_is_root(PCIBus *bus)
-{
- return true; /* by definition */
-}
-
static uint16_t pxb_bus_numa_node(PCIBus *bus)
{
PXBDev *pxb = convert_to_pxb(bus->parent_dev);
@@ -83,7 +78,6 @@ static void pxb_bus_class_init(ObjectClass *class, void *data)
PCIBusClass *pbc = PCI_BUS_CLASS(class);
pbc->bus_num = pxb_bus_num;
- pbc->is_root = pxb_is_root;
pbc->numa_node = pxb_bus_numa_node;
}
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 6d13ef877b..ea5941fb22 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -129,14 +129,9 @@ static void pci_bus_unrealize(BusState *qbus, Error **errp)
vmstate_unregister(NULL, &vmstate_pcibus, bus);
}
-static bool pcibus_is_root(PCIBus *bus)
-{
- return !bus->parent_dev;
-}
-
static int pcibus_num(PCIBus *bus)
{
- if (pcibus_is_root(bus)) {
+ if (pci_bus_is_root(bus)) {
return 0; /* pci host bridge */
}
return bus->parent_dev->config[PCI_SECONDARY_BUS];
@@ -164,7 +159,6 @@ static void pci_bus_class_init(ObjectClass *klass, void *data)
k->unrealize = pci_bus_unrealize;
k->reset = pcibus_reset;
- pbc->is_root = pcibus_is_root;
pbc->bus_num = pcibus_num;
pbc->numa_node = pcibus_numa_node;
pbc->allows_extended_config_space = pcibus_allows_extended_config_space;
@@ -398,6 +392,7 @@ static void pci_root_bus_init(PCIBus *bus, DeviceState *parent,
bus->slot_reserved_mask = 0x0;
bus->address_space_mem = address_space_mem;
bus->address_space_io = address_space_io;
+ bus->flags |= PCI_BUS_IS_ROOT;
/* host bridge */
QLIST_INIT(&bus->child);
@@ -415,11 +410,6 @@ bool pci_bus_is_express(PCIBus *bus)
return object_dynamic_cast(OBJECT(bus), TYPE_PCIE_BUS);
}
-bool pci_bus_is_root(PCIBus *bus)
-{
- return PCI_BUS_GET_CLASS(bus)->is_root(bus);
-}
-
bool pci_bus_allows_extended_config_space(PCIBus *bus)
{
return PCI_BUS_GET_CLASS(bus)->allows_extended_config_space(bus);
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index cb44e19b67..942173d830 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -20,6 +20,7 @@
#include "standard-headers/linux/virtio_pci.h"
#include "hw/virtio/virtio.h"
#include "hw/pci/pci.h"
+#include "hw/pci/pci_bus.h"
#include "qapi/error.h"
#include "qemu/error-report.h"
#include "hw/pci/msi.h"
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
index 0abb06b357..33ccce320c 100644
--- a/include/hw/pci/pci.h
+++ b/include/hw/pci/pci.h
@@ -395,7 +395,6 @@ typedef PCIINTxRoute (*pci_route_irq_fn)(void *opaque, int pin);
#define TYPE_PCIE_BUS "PCIE"
bool pci_bus_is_express(PCIBus *bus);
-bool pci_bus_is_root(PCIBus *bus);
bool pci_bus_allows_extended_config_space(PCIBus *bus);
void pci_root_bus_new_inplace(PCIBus *bus, size_t bus_size, DeviceState *parent,
diff --git a/include/hw/pci/pci_bus.h b/include/hw/pci/pci_bus.h
index f6df834170..aea98d5040 100644
--- a/include/hw/pci/pci_bus.h
+++ b/include/hw/pci/pci_bus.h
@@ -15,14 +15,19 @@ typedef struct PCIBusClass {
BusClass parent_class;
/*< public >*/
- bool (*is_root)(PCIBus *bus);
int (*bus_num)(PCIBus *bus);
uint16_t (*numa_node)(PCIBus *bus);
bool (*allows_extended_config_space)(PCIBus *bus);
} PCIBusClass;
+enum PCIBusFlags {
+ /* This bus is the root of a PCI domain */
+ PCI_BUS_IS_ROOT = 0x0001,
+};
+
struct PCIBus {
BusState qbus;
+ enum PCIBusFlags flags;
PCIIOMMUFunc iommu_fn;
void *iommu_opaque;
uint8_t devfn_min;
@@ -47,4 +52,9 @@ struct PCIBus {
Notifier machine_done;
};
+static inline bool pci_bus_is_root(PCIBus *bus)
+{
+ return !!(bus->flags & PCI_BUS_IS_ROOT);
+}
+
#endif /* QEMU_PCI_BUS_H */
--
2.20.1
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v2 2/3] pci: Simplify pci_bus_is_root()
@ 2019-04-24 4:19 ` David Gibson
0 siblings, 0 replies; 289+ messages in thread
From: David Gibson @ 2019-04-24 4:19 UTC (permalink / raw)
To: Marcel Apfelbaum, qemu-devel, Michael S. Tsirkin,
Alex Williamson, Greg Kurz
Cc: Marcel Apfelbaum, qemu-ppc, clg, Peter Xu, David Gibson
pci_bus_is_root() currently relies on a method in the PCIBusClass.
But it's always known if a PCI bus is a root bus when we create it, so
using a dynamic method is overkill.
This replaces it with an IS_ROOT bit in a new flags field, which is set on
root buses and otherwise clear. As a bonus this removes the special
is_root logic from pci_expander_bridge, since it already creates its bus
as a root bus.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
---
hw/pci-bridge/pci_expander_bridge.c | 6 ------
hw/pci/pci.c | 14 ++------------
hw/virtio/virtio-pci.c | 1 +
include/hw/pci/pci.h | 1 -
include/hw/pci/pci_bus.h | 12 +++++++++++-
5 files changed, 14 insertions(+), 20 deletions(-)
diff --git a/hw/pci-bridge/pci_expander_bridge.c b/hw/pci-bridge/pci_expander_bridge.c
index e62de4218f..ca66bc721a 100644
--- a/hw/pci-bridge/pci_expander_bridge.c
+++ b/hw/pci-bridge/pci_expander_bridge.c
@@ -66,11 +66,6 @@ static int pxb_bus_num(PCIBus *bus)
return pxb->bus_nr;
}
-static bool pxb_is_root(PCIBus *bus)
-{
- return true; /* by definition */
-}
-
static uint16_t pxb_bus_numa_node(PCIBus *bus)
{
PXBDev *pxb = convert_to_pxb(bus->parent_dev);
@@ -83,7 +78,6 @@ static void pxb_bus_class_init(ObjectClass *class, void *data)
PCIBusClass *pbc = PCI_BUS_CLASS(class);
pbc->bus_num = pxb_bus_num;
- pbc->is_root = pxb_is_root;
pbc->numa_node = pxb_bus_numa_node;
}
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 6d13ef877b..ea5941fb22 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -129,14 +129,9 @@ static void pci_bus_unrealize(BusState *qbus, Error **errp)
vmstate_unregister(NULL, &vmstate_pcibus, bus);
}
-static bool pcibus_is_root(PCIBus *bus)
-{
- return !bus->parent_dev;
-}
-
static int pcibus_num(PCIBus *bus)
{
- if (pcibus_is_root(bus)) {
+ if (pci_bus_is_root(bus)) {
return 0; /* pci host bridge */
}
return bus->parent_dev->config[PCI_SECONDARY_BUS];
@@ -164,7 +159,6 @@ static void pci_bus_class_init(ObjectClass *klass, void *data)
k->unrealize = pci_bus_unrealize;
k->reset = pcibus_reset;
- pbc->is_root = pcibus_is_root;
pbc->bus_num = pcibus_num;
pbc->numa_node = pcibus_numa_node;
pbc->allows_extended_config_space = pcibus_allows_extended_config_space;
@@ -398,6 +392,7 @@ static void pci_root_bus_init(PCIBus *bus, DeviceState *parent,
bus->slot_reserved_mask = 0x0;
bus->address_space_mem = address_space_mem;
bus->address_space_io = address_space_io;
+ bus->flags |= PCI_BUS_IS_ROOT;
/* host bridge */
QLIST_INIT(&bus->child);
@@ -415,11 +410,6 @@ bool pci_bus_is_express(PCIBus *bus)
return object_dynamic_cast(OBJECT(bus), TYPE_PCIE_BUS);
}
-bool pci_bus_is_root(PCIBus *bus)
-{
- return PCI_BUS_GET_CLASS(bus)->is_root(bus);
-}
-
bool pci_bus_allows_extended_config_space(PCIBus *bus)
{
return PCI_BUS_GET_CLASS(bus)->allows_extended_config_space(bus);
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index cb44e19b67..942173d830 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -20,6 +20,7 @@
#include "standard-headers/linux/virtio_pci.h"
#include "hw/virtio/virtio.h"
#include "hw/pci/pci.h"
+#include "hw/pci/pci_bus.h"
#include "qapi/error.h"
#include "qemu/error-report.h"
#include "hw/pci/msi.h"
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
index 0abb06b357..33ccce320c 100644
--- a/include/hw/pci/pci.h
+++ b/include/hw/pci/pci.h
@@ -395,7 +395,6 @@ typedef PCIINTxRoute (*pci_route_irq_fn)(void *opaque, int pin);
#define TYPE_PCIE_BUS "PCIE"
bool pci_bus_is_express(PCIBus *bus);
-bool pci_bus_is_root(PCIBus *bus);
bool pci_bus_allows_extended_config_space(PCIBus *bus);
void pci_root_bus_new_inplace(PCIBus *bus, size_t bus_size, DeviceState *parent,
diff --git a/include/hw/pci/pci_bus.h b/include/hw/pci/pci_bus.h
index f6df834170..aea98d5040 100644
--- a/include/hw/pci/pci_bus.h
+++ b/include/hw/pci/pci_bus.h
@@ -15,14 +15,19 @@ typedef struct PCIBusClass {
BusClass parent_class;
/*< public >*/
- bool (*is_root)(PCIBus *bus);
int (*bus_num)(PCIBus *bus);
uint16_t (*numa_node)(PCIBus *bus);
bool (*allows_extended_config_space)(PCIBus *bus);
} PCIBusClass;
+enum PCIBusFlags {
+ /* This bus is the root of a PCI domain */
+ PCI_BUS_IS_ROOT = 0x0001,
+};
+
struct PCIBus {
BusState qbus;
+ enum PCIBusFlags flags;
PCIIOMMUFunc iommu_fn;
void *iommu_opaque;
uint8_t devfn_min;
@@ -47,4 +52,9 @@ struct PCIBus {
Notifier machine_done;
};
+static inline bool pci_bus_is_root(PCIBus *bus)
+{
+ return !!(bus->flags & PCI_BUS_IS_ROOT);
+}
+
#endif /* QEMU_PCI_BUS_H */
--
2.20.1
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v2 3/3] pcie: Simplify pci_adjust_config_limit()
@ 2019-04-24 4:19 ` David Gibson
0 siblings, 0 replies; 289+ messages in thread
From: David Gibson @ 2019-04-24 4:19 UTC (permalink / raw)
To: Marcel Apfelbaum, qemu-devel, Michael S. Tsirkin,
Alex Williamson, Greg Kurz
Cc: David Gibson, clg, qemu-ppc
Since c2077e2c "pci: Adjust PCI config limit based on bus topology",
pci_adjust_config_limit() has been used in the config space read and write
paths to only permit access to extended config space on buses which permit
it. Specifically it prevents access on devices below a vanilla-PCI bus via
some combination of bridges, even if both the host bridge and the device
itself are PCI-E.
It accomplishes this with a somewhat complex call up the chain of bridges
to see if any of them prohibit extended config space access. This is
overly complex, since we can always know if the bus will support such
access at the point it is constructed.
This patch simplifies the test by using a flag in the PCIBus instance
indicating whether extended configuration space is accessible. It is
false for vanilla PCI buses. For PCI-E buses, it is true for root
buses and equal to the parent bus's's capability otherwise.
For the special case of sPAPR's paravirtualized PCI root bus, which
acts mostly like vanilla PCI, but does allow extended config space
access, we override the default value of the flag from the host bridge
code.
This should cause no behavioural change.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>cd
---
hw/pci/pci.c | 41 ++++++++++++++++++++++------------------
hw/pci/pci_host.c | 13 +++----------
hw/ppc/spapr_pci.c | 34 ++++++++++-----------------------
include/hw/pci/pci.h | 1 -
include/hw/pci/pci_bus.h | 9 ++++++++-
5 files changed, 44 insertions(+), 54 deletions(-)
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index ea5941fb22..59ee034331 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -120,6 +120,27 @@ static void pci_bus_realize(BusState *qbus, Error **errp)
vmstate_register(NULL, -1, &vmstate_pcibus, bus);
}
+static void pcie_bus_realize(BusState *qbus, Error **errp)
+{
+ PCIBus *bus = PCI_BUS(qbus);
+
+ pci_bus_realize(qbus, errp);
+
+ /*
+ * A PCI-E bus can support extended config space if it's the root
+ * bus, or if the bus/bridge above it does as well
+ */
+ if (pci_bus_is_root(bus)) {
+ bus->flags |= PCI_BUS_EXTENDED_CONFIG_SPACE;
+ } else {
+ PCIBus *parent_bus = pci_get_bus(bus->parent_dev);
+
+ if (pci_bus_allows_extended_config_space(parent_bus)) {
+ bus->flags |= PCI_BUS_EXTENDED_CONFIG_SPACE;
+ }
+ }
+}
+
static void pci_bus_unrealize(BusState *qbus, Error **errp)
{
PCIBus *bus = PCI_BUS(qbus);
@@ -142,11 +163,6 @@ static uint16_t pcibus_numa_node(PCIBus *bus)
return NUMA_NODE_UNASSIGNED;
}
-static bool pcibus_allows_extended_config_space(PCIBus *bus)
-{
- return false;
-}
-
static void pci_bus_class_init(ObjectClass *klass, void *data)
{
BusClass *k = BUS_CLASS(klass);
@@ -161,7 +177,6 @@ static void pci_bus_class_init(ObjectClass *klass, void *data)
pbc->bus_num = pcibus_num;
pbc->numa_node = pcibus_numa_node;
- pbc->allows_extended_config_space = pcibus_allows_extended_config_space;
}
static const TypeInfo pci_bus_info = {
@@ -182,16 +197,11 @@ static const TypeInfo conventional_pci_interface_info = {
.parent = TYPE_INTERFACE,
};
-static bool pciebus_allows_extended_config_space(PCIBus *bus)
-{
- return true;
-}
-
static void pcie_bus_class_init(ObjectClass *klass, void *data)
{
- PCIBusClass *pbc = PCI_BUS_CLASS(klass);
+ BusClass *k = BUS_CLASS(klass);
- pbc->allows_extended_config_space = pciebus_allows_extended_config_space;
+ k->realize = pcie_bus_realize;
}
static const TypeInfo pcie_bus_info = {
@@ -410,11 +420,6 @@ bool pci_bus_is_express(PCIBus *bus)
return object_dynamic_cast(OBJECT(bus), TYPE_PCIE_BUS);
}
-bool pci_bus_allows_extended_config_space(PCIBus *bus)
-{
- return PCI_BUS_GET_CLASS(bus)->allows_extended_config_space(bus);
-}
-
void pci_root_bus_new_inplace(PCIBus *bus, size_t bus_size, DeviceState *parent,
const char *name,
MemoryRegion *address_space_mem,
diff --git a/hw/pci/pci_host.c b/hw/pci/pci_host.c
index 9d64b2e12f..5f3497256c 100644
--- a/hw/pci/pci_host.c
+++ b/hw/pci/pci_host.c
@@ -53,16 +53,9 @@ static inline PCIDevice *pci_dev_find_by_addr(PCIBus *bus, uint32_t addr)
static void pci_adjust_config_limit(PCIBus *bus, uint32_t *limit)
{
- if (*limit > PCI_CONFIG_SPACE_SIZE) {
- if (!pci_bus_allows_extended_config_space(bus)) {
- *limit = PCI_CONFIG_SPACE_SIZE;
- return;
- }
-
- if (!pci_bus_is_root(bus)) {
- PCIDevice *bridge = pci_bridge_get_device(bus);
- pci_adjust_config_limit(pci_get_bus(bridge), limit);
- }
+ if ((*limit > PCI_CONFIG_SPACE_SIZE) &&
+ !pci_bus_allows_extended_config_space(bus)) {
+ *limit = PCI_CONFIG_SPACE_SIZE;
}
}
diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index f62e6833b8..65a86be29c 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -1638,28 +1638,6 @@ static void spapr_phb_unrealize(DeviceState *dev, Error **errp)
memory_region_del_subregion(get_system_memory(), &sphb->mem32window);
}
-static bool spapr_phb_allows_extended_config_space(PCIBus *bus)
-{
- SpaprPhbState *sphb = SPAPR_PCI_HOST_BRIDGE(BUS(bus)->parent);
-
- return sphb->pcie_ecs;
-}
-
-static void spapr_phb_root_bus_class_init(ObjectClass *klass, void *data)
-{
- PCIBusClass *pbc = PCI_BUS_CLASS(klass);
-
- pbc->allows_extended_config_space = spapr_phb_allows_extended_config_space;
-}
-
-#define TYPE_SPAPR_PHB_ROOT_BUS "pci"
-
-static const TypeInfo spapr_phb_root_bus_info = {
- .name = TYPE_SPAPR_PHB_ROOT_BUS,
- .parent = TYPE_PCI_BUS,
- .class_init = spapr_phb_root_bus_class_init,
-};
-
static void spapr_phb_realize(DeviceState *dev, Error **errp)
{
/* We don't use SPAPR_MACHINE() in order to exit gracefully if the user
@@ -1765,7 +1743,16 @@ static void spapr_phb_realize(DeviceState *dev, Error **errp)
pci_spapr_set_irq, pci_spapr_map_irq, sphb,
&sphb->memspace, &sphb->iospace,
PCI_DEVFN(0, 0), PCI_NUM_PINS,
- TYPE_SPAPR_PHB_ROOT_BUS);
+ TYPE_PCI_BUS);
+
+ /*
+ * Despite resembling a vanilla PCI bus in most ways, the PAPR
+ * para-virtualized PCI bus *does* permit PCI-E extended config
+ * space access
+ */
+ if (sphb->pcie_ecs) {
+ bus->flags |= PCI_BUS_EXTENDED_CONFIG_SPACE;
+ }
phb->bus = bus;
qbus_set_hotplug_handler(BUS(phb->bus), OBJECT(sphb), NULL);
@@ -2348,7 +2335,6 @@ void spapr_pci_rtas_init(void)
static void spapr_pci_register_types(void)
{
type_register_static(&spapr_phb_info);
- type_register_static(&spapr_phb_root_bus_info);
}
type_init(spapr_pci_register_types)
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
index 33ccce320c..0edfaabbb0 100644
--- a/include/hw/pci/pci.h
+++ b/include/hw/pci/pci.h
@@ -395,7 +395,6 @@ typedef PCIINTxRoute (*pci_route_irq_fn)(void *opaque, int pin);
#define TYPE_PCIE_BUS "PCIE"
bool pci_bus_is_express(PCIBus *bus);
-bool pci_bus_allows_extended_config_space(PCIBus *bus);
void pci_root_bus_new_inplace(PCIBus *bus, size_t bus_size, DeviceState *parent,
const char *name,
diff --git a/include/hw/pci/pci_bus.h b/include/hw/pci/pci_bus.h
index aea98d5040..2d5f74b7c1 100644
--- a/include/hw/pci/pci_bus.h
+++ b/include/hw/pci/pci_bus.h
@@ -17,12 +17,13 @@ typedef struct PCIBusClass {
int (*bus_num)(PCIBus *bus);
uint16_t (*numa_node)(PCIBus *bus);
- bool (*allows_extended_config_space)(PCIBus *bus);
} PCIBusClass;
enum PCIBusFlags {
/* This bus is the root of a PCI domain */
PCI_BUS_IS_ROOT = 0x0001,
+ /* PCIe extended configuration space is accessible on this bus */
+ PCI_BUS_EXTENDED_CONFIG_SPACE = 0x0002,
};
struct PCIBus {
@@ -57,4 +58,10 @@ static inline bool pci_bus_is_root(PCIBus *bus)
return !!(bus->flags & PCI_BUS_IS_ROOT);
}
+static inline bool pci_bus_allows_extended_config_space(PCIBus *bus)
+{
+ return !!(bus->flags & PCI_BUS_EXTENDED_CONFIG_SPACE);
+}
+
+
#endif /* QEMU_PCI_BUS_H */
--
2.20.1
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v2 3/3] pcie: Simplify pci_adjust_config_limit()
@ 2019-04-24 4:19 ` David Gibson
0 siblings, 0 replies; 289+ messages in thread
From: David Gibson @ 2019-04-24 4:19 UTC (permalink / raw)
To: Marcel Apfelbaum, qemu-devel, Michael S. Tsirkin,
Alex Williamson, Greg Kurz
Cc: qemu-ppc, clg, David Gibson
Since c2077e2c "pci: Adjust PCI config limit based on bus topology",
pci_adjust_config_limit() has been used in the config space read and write
paths to only permit access to extended config space on buses which permit
it. Specifically it prevents access on devices below a vanilla-PCI bus via
some combination of bridges, even if both the host bridge and the device
itself are PCI-E.
It accomplishes this with a somewhat complex call up the chain of bridges
to see if any of them prohibit extended config space access. This is
overly complex, since we can always know if the bus will support such
access at the point it is constructed.
This patch simplifies the test by using a flag in the PCIBus instance
indicating whether extended configuration space is accessible. It is
false for vanilla PCI buses. For PCI-E buses, it is true for root
buses and equal to the parent bus's's capability otherwise.
For the special case of sPAPR's paravirtualized PCI root bus, which
acts mostly like vanilla PCI, but does allow extended config space
access, we override the default value of the flag from the host bridge
code.
This should cause no behavioural change.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>cd
---
hw/pci/pci.c | 41 ++++++++++++++++++++++------------------
hw/pci/pci_host.c | 13 +++----------
hw/ppc/spapr_pci.c | 34 ++++++++++-----------------------
include/hw/pci/pci.h | 1 -
include/hw/pci/pci_bus.h | 9 ++++++++-
5 files changed, 44 insertions(+), 54 deletions(-)
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index ea5941fb22..59ee034331 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -120,6 +120,27 @@ static void pci_bus_realize(BusState *qbus, Error **errp)
vmstate_register(NULL, -1, &vmstate_pcibus, bus);
}
+static void pcie_bus_realize(BusState *qbus, Error **errp)
+{
+ PCIBus *bus = PCI_BUS(qbus);
+
+ pci_bus_realize(qbus, errp);
+
+ /*
+ * A PCI-E bus can support extended config space if it's the root
+ * bus, or if the bus/bridge above it does as well
+ */
+ if (pci_bus_is_root(bus)) {
+ bus->flags |= PCI_BUS_EXTENDED_CONFIG_SPACE;
+ } else {
+ PCIBus *parent_bus = pci_get_bus(bus->parent_dev);
+
+ if (pci_bus_allows_extended_config_space(parent_bus)) {
+ bus->flags |= PCI_BUS_EXTENDED_CONFIG_SPACE;
+ }
+ }
+}
+
static void pci_bus_unrealize(BusState *qbus, Error **errp)
{
PCIBus *bus = PCI_BUS(qbus);
@@ -142,11 +163,6 @@ static uint16_t pcibus_numa_node(PCIBus *bus)
return NUMA_NODE_UNASSIGNED;
}
-static bool pcibus_allows_extended_config_space(PCIBus *bus)
-{
- return false;
-}
-
static void pci_bus_class_init(ObjectClass *klass, void *data)
{
BusClass *k = BUS_CLASS(klass);
@@ -161,7 +177,6 @@ static void pci_bus_class_init(ObjectClass *klass, void *data)
pbc->bus_num = pcibus_num;
pbc->numa_node = pcibus_numa_node;
- pbc->allows_extended_config_space = pcibus_allows_extended_config_space;
}
static const TypeInfo pci_bus_info = {
@@ -182,16 +197,11 @@ static const TypeInfo conventional_pci_interface_info = {
.parent = TYPE_INTERFACE,
};
-static bool pciebus_allows_extended_config_space(PCIBus *bus)
-{
- return true;
-}
-
static void pcie_bus_class_init(ObjectClass *klass, void *data)
{
- PCIBusClass *pbc = PCI_BUS_CLASS(klass);
+ BusClass *k = BUS_CLASS(klass);
- pbc->allows_extended_config_space = pciebus_allows_extended_config_space;
+ k->realize = pcie_bus_realize;
}
static const TypeInfo pcie_bus_info = {
@@ -410,11 +420,6 @@ bool pci_bus_is_express(PCIBus *bus)
return object_dynamic_cast(OBJECT(bus), TYPE_PCIE_BUS);
}
-bool pci_bus_allows_extended_config_space(PCIBus *bus)
-{
- return PCI_BUS_GET_CLASS(bus)->allows_extended_config_space(bus);
-}
-
void pci_root_bus_new_inplace(PCIBus *bus, size_t bus_size, DeviceState *parent,
const char *name,
MemoryRegion *address_space_mem,
diff --git a/hw/pci/pci_host.c b/hw/pci/pci_host.c
index 9d64b2e12f..5f3497256c 100644
--- a/hw/pci/pci_host.c
+++ b/hw/pci/pci_host.c
@@ -53,16 +53,9 @@ static inline PCIDevice *pci_dev_find_by_addr(PCIBus *bus, uint32_t addr)
static void pci_adjust_config_limit(PCIBus *bus, uint32_t *limit)
{
- if (*limit > PCI_CONFIG_SPACE_SIZE) {
- if (!pci_bus_allows_extended_config_space(bus)) {
- *limit = PCI_CONFIG_SPACE_SIZE;
- return;
- }
-
- if (!pci_bus_is_root(bus)) {
- PCIDevice *bridge = pci_bridge_get_device(bus);
- pci_adjust_config_limit(pci_get_bus(bridge), limit);
- }
+ if ((*limit > PCI_CONFIG_SPACE_SIZE) &&
+ !pci_bus_allows_extended_config_space(bus)) {
+ *limit = PCI_CONFIG_SPACE_SIZE;
}
}
diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index f62e6833b8..65a86be29c 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -1638,28 +1638,6 @@ static void spapr_phb_unrealize(DeviceState *dev, Error **errp)
memory_region_del_subregion(get_system_memory(), &sphb->mem32window);
}
-static bool spapr_phb_allows_extended_config_space(PCIBus *bus)
-{
- SpaprPhbState *sphb = SPAPR_PCI_HOST_BRIDGE(BUS(bus)->parent);
-
- return sphb->pcie_ecs;
-}
-
-static void spapr_phb_root_bus_class_init(ObjectClass *klass, void *data)
-{
- PCIBusClass *pbc = PCI_BUS_CLASS(klass);
-
- pbc->allows_extended_config_space = spapr_phb_allows_extended_config_space;
-}
-
-#define TYPE_SPAPR_PHB_ROOT_BUS "pci"
-
-static const TypeInfo spapr_phb_root_bus_info = {
- .name = TYPE_SPAPR_PHB_ROOT_BUS,
- .parent = TYPE_PCI_BUS,
- .class_init = spapr_phb_root_bus_class_init,
-};
-
static void spapr_phb_realize(DeviceState *dev, Error **errp)
{
/* We don't use SPAPR_MACHINE() in order to exit gracefully if the user
@@ -1765,7 +1743,16 @@ static void spapr_phb_realize(DeviceState *dev, Error **errp)
pci_spapr_set_irq, pci_spapr_map_irq, sphb,
&sphb->memspace, &sphb->iospace,
PCI_DEVFN(0, 0), PCI_NUM_PINS,
- TYPE_SPAPR_PHB_ROOT_BUS);
+ TYPE_PCI_BUS);
+
+ /*
+ * Despite resembling a vanilla PCI bus in most ways, the PAPR
+ * para-virtualized PCI bus *does* permit PCI-E extended config
+ * space access
+ */
+ if (sphb->pcie_ecs) {
+ bus->flags |= PCI_BUS_EXTENDED_CONFIG_SPACE;
+ }
phb->bus = bus;
qbus_set_hotplug_handler(BUS(phb->bus), OBJECT(sphb), NULL);
@@ -2348,7 +2335,6 @@ void spapr_pci_rtas_init(void)
static void spapr_pci_register_types(void)
{
type_register_static(&spapr_phb_info);
- type_register_static(&spapr_phb_root_bus_info);
}
type_init(spapr_pci_register_types)
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
index 33ccce320c..0edfaabbb0 100644
--- a/include/hw/pci/pci.h
+++ b/include/hw/pci/pci.h
@@ -395,7 +395,6 @@ typedef PCIINTxRoute (*pci_route_irq_fn)(void *opaque, int pin);
#define TYPE_PCIE_BUS "PCIE"
bool pci_bus_is_express(PCIBus *bus);
-bool pci_bus_allows_extended_config_space(PCIBus *bus);
void pci_root_bus_new_inplace(PCIBus *bus, size_t bus_size, DeviceState *parent,
const char *name,
diff --git a/include/hw/pci/pci_bus.h b/include/hw/pci/pci_bus.h
index aea98d5040..2d5f74b7c1 100644
--- a/include/hw/pci/pci_bus.h
+++ b/include/hw/pci/pci_bus.h
@@ -17,12 +17,13 @@ typedef struct PCIBusClass {
int (*bus_num)(PCIBus *bus);
uint16_t (*numa_node)(PCIBus *bus);
- bool (*allows_extended_config_space)(PCIBus *bus);
} PCIBusClass;
enum PCIBusFlags {
/* This bus is the root of a PCI domain */
PCI_BUS_IS_ROOT = 0x0001,
+ /* PCIe extended configuration space is accessible on this bus */
+ PCI_BUS_EXTENDED_CONFIG_SPACE = 0x0002,
};
struct PCIBus {
@@ -57,4 +58,10 @@ static inline bool pci_bus_is_root(PCIBus *bus)
return !!(bus->flags & PCI_BUS_IS_ROOT);
}
+static inline bool pci_bus_allows_extended_config_space(PCIBus *bus)
+{
+ return !!(bus->flags & PCI_BUS_EXTENDED_CONFIG_SPACE);
+}
+
+
#endif /* QEMU_PCI_BUS_H */
--
2.20.1
^ permalink raw reply related [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] add VirtIONet vhost_stopped flag to prevent multiple stops
@ 2019-04-24 9:46 ` Jason Wang
0 siblings, 0 replies; 289+ messages in thread
From: Jason Wang @ 2019-04-24 9:46 UTC (permalink / raw)
To: Dan Streetman
Cc: marcandre.lureau@redhat.com >> Marc-André Lureau,
qemu-stable, qemu-devel, Michael S. Tsirkin
On 2019/4/23 下午4:49, Dan Streetman wrote:
>> I think so if net_vhost_user_event() was called in main thread (it calls
>> qemu_get_current_aio_context()).
> ok, I'll check that, thanks!
>
> I think my other patch, to remove the vhost_user_stop() call
> completely from the net_vhost_user_event() handler for
> CHR_EVENT_CLOSED, is still relevant; do you have thoughts on that?
>
I think that patch makes sense.
Thanks
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] add VirtIONet vhost_stopped flag to prevent multiple stops
@ 2019-04-24 9:46 ` Jason Wang
0 siblings, 0 replies; 289+ messages in thread
From: Jason Wang @ 2019-04-24 9:46 UTC (permalink / raw)
To: Dan Streetman
Cc: marcandre.lureau@redhat.com >> Marc-André Lureau,
Michael S. Tsirkin, qemu-stable, qemu-devel
On 2019/4/23 下午4:49, Dan Streetman wrote:
>> I think so if net_vhost_user_event() was called in main thread (it calls
>> qemu_get_current_aio_context()).
> ok, I'll check that, thanks!
>
> I think my other patch, to remove the vhost_user_stop() call
> completely from the net_vhost_user_event() handler for
> CHR_EVENT_CLOSED, is still relevant; do you have thoughts on that?
>
I think that patch makes sense.
Thanks
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH v2 1/3] pcie: Remove redundant test in pcie_mmcfg_data_{read, write}()
@ 2019-04-24 16:04 ` Greg Kurz
0 siblings, 0 replies; 289+ messages in thread
From: Greg Kurz @ 2019-04-24 16:04 UTC (permalink / raw)
To: David Gibson
Cc: Marcel Apfelbaum, qemu-devel, Michael S. Tsirkin,
Alex Williamson, clg, qemu-ppc
On Wed, 24 Apr 2019 14:19:57 +1000
David Gibson <david@gibson.dropbear.id.au> wrote:
> These functions have an explicit test for accesses above the device's
> config size. But pci_host_config_{read,write}_common() which they're
> about to call already have checks against the config space limit and
> do the right thing. So, remove the redundant tests.
>
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> ---
Reviewed-by: Greg Kurz <groug@kaod.org>
> hw/pci/pcie_host.c | 10 ----------
> 1 file changed, 10 deletions(-)
>
> diff --git a/hw/pci/pcie_host.c b/hw/pci/pcie_host.c
> index 553db56778..1ee4945a6d 100644
> --- a/hw/pci/pcie_host.c
> +++ b/hw/pci/pcie_host.c
> @@ -47,11 +47,6 @@ static void pcie_mmcfg_data_write(void *opaque, hwaddr mmcfg_addr,
> }
> addr = PCIE_MMCFG_CONFOFFSET(mmcfg_addr);
> limit = pci_config_size(pci_dev);
> - if (limit <= addr) {
> - /* conventional pci device can be behind pcie-to-pci bridge.
> - 256 <= addr < 4K has no effects. */
> - return;
> - }
> pci_host_config_write_common(pci_dev, addr, limit, val, len);
> }
>
> @@ -70,11 +65,6 @@ static uint64_t pcie_mmcfg_data_read(void *opaque,
> }
> addr = PCIE_MMCFG_CONFOFFSET(mmcfg_addr);
> limit = pci_config_size(pci_dev);
> - if (limit <= addr) {
> - /* conventional pci device can be behind pcie-to-pci bridge.
> - 256 <= addr < 4K has no effects. */
> - return ~0x0;
> - }
> return pci_host_config_read_common(pci_dev, addr, limit, len);
> }
>
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH v2 1/3] pcie: Remove redundant test in pcie_mmcfg_data_{read, write}()
@ 2019-04-24 16:04 ` Greg Kurz
0 siblings, 0 replies; 289+ messages in thread
From: Greg Kurz @ 2019-04-24 16:04 UTC (permalink / raw)
To: David Gibson
Cc: Michael S. Tsirkin, qemu-devel, Alex Williamson, qemu-ppc, clg
On Wed, 24 Apr 2019 14:19:57 +1000
David Gibson <david@gibson.dropbear.id.au> wrote:
> These functions have an explicit test for accesses above the device's
> config size. But pci_host_config_{read,write}_common() which they're
> about to call already have checks against the config space limit and
> do the right thing. So, remove the redundant tests.
>
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> ---
Reviewed-by: Greg Kurz <groug@kaod.org>
> hw/pci/pcie_host.c | 10 ----------
> 1 file changed, 10 deletions(-)
>
> diff --git a/hw/pci/pcie_host.c b/hw/pci/pcie_host.c
> index 553db56778..1ee4945a6d 100644
> --- a/hw/pci/pcie_host.c
> +++ b/hw/pci/pcie_host.c
> @@ -47,11 +47,6 @@ static void pcie_mmcfg_data_write(void *opaque, hwaddr mmcfg_addr,
> }
> addr = PCIE_MMCFG_CONFOFFSET(mmcfg_addr);
> limit = pci_config_size(pci_dev);
> - if (limit <= addr) {
> - /* conventional pci device can be behind pcie-to-pci bridge.
> - 256 <= addr < 4K has no effects. */
> - return;
> - }
> pci_host_config_write_common(pci_dev, addr, limit, val, len);
> }
>
> @@ -70,11 +65,6 @@ static uint64_t pcie_mmcfg_data_read(void *opaque,
> }
> addr = PCIE_MMCFG_CONFOFFSET(mmcfg_addr);
> limit = pci_config_size(pci_dev);
> - if (limit <= addr) {
> - /* conventional pci device can be behind pcie-to-pci bridge.
> - 256 <= addr < 4K has no effects. */
> - return ~0x0;
> - }
> return pci_host_config_read_common(pci_dev, addr, limit, len);
> }
>
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH v2 3/3] pcie: Simplify pci_adjust_config_limit()
@ 2019-04-24 16:09 ` Greg Kurz
0 siblings, 0 replies; 289+ messages in thread
From: Greg Kurz @ 2019-04-24 16:09 UTC (permalink / raw)
To: David Gibson
Cc: Marcel Apfelbaum, qemu-devel, Michael S. Tsirkin,
Alex Williamson, clg, qemu-ppc
On Wed, 24 Apr 2019 14:19:59 +1000
David Gibson <david@gibson.dropbear.id.au> wrote:
> Since c2077e2c "pci: Adjust PCI config limit based on bus topology",
> pci_adjust_config_limit() has been used in the config space read and write
> paths to only permit access to extended config space on buses which permit
> it. Specifically it prevents access on devices below a vanilla-PCI bus via
> some combination of bridges, even if both the host bridge and the device
> itself are PCI-E.
>
> It accomplishes this with a somewhat complex call up the chain of bridges
> to see if any of them prohibit extended config space access. This is
> overly complex, since we can always know if the bus will support such
> access at the point it is constructed.
>
> This patch simplifies the test by using a flag in the PCIBus instance
> indicating whether extended configuration space is accessible. It is
> false for vanilla PCI buses. For PCI-E buses, it is true for root
> buses and equal to the parent bus's's capability otherwise.
>
> For the special case of sPAPR's paravirtualized PCI root bus, which
> acts mostly like vanilla PCI, but does allow extended config space
> access, we override the default value of the flag from the host bridge
> code.
>
> This should cause no behavioural change.
>
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>cd
> ---
Reviewed-by: Greg Kurz <groug@kaod.org>
> hw/pci/pci.c | 41 ++++++++++++++++++++++------------------
> hw/pci/pci_host.c | 13 +++----------
> hw/ppc/spapr_pci.c | 34 ++++++++++-----------------------
> include/hw/pci/pci.h | 1 -
> include/hw/pci/pci_bus.h | 9 ++++++++-
> 5 files changed, 44 insertions(+), 54 deletions(-)
>
> diff --git a/hw/pci/pci.c b/hw/pci/pci.c
> index ea5941fb22..59ee034331 100644
> --- a/hw/pci/pci.c
> +++ b/hw/pci/pci.c
> @@ -120,6 +120,27 @@ static void pci_bus_realize(BusState *qbus, Error **errp)
> vmstate_register(NULL, -1, &vmstate_pcibus, bus);
> }
>
> +static void pcie_bus_realize(BusState *qbus, Error **errp)
> +{
> + PCIBus *bus = PCI_BUS(qbus);
> +
> + pci_bus_realize(qbus, errp);
> +
> + /*
> + * A PCI-E bus can support extended config space if it's the root
> + * bus, or if the bus/bridge above it does as well
> + */
> + if (pci_bus_is_root(bus)) {
> + bus->flags |= PCI_BUS_EXTENDED_CONFIG_SPACE;
> + } else {
> + PCIBus *parent_bus = pci_get_bus(bus->parent_dev);
> +
> + if (pci_bus_allows_extended_config_space(parent_bus)) {
> + bus->flags |= PCI_BUS_EXTENDED_CONFIG_SPACE;
> + }
> + }
> +}
> +
> static void pci_bus_unrealize(BusState *qbus, Error **errp)
> {
> PCIBus *bus = PCI_BUS(qbus);
> @@ -142,11 +163,6 @@ static uint16_t pcibus_numa_node(PCIBus *bus)
> return NUMA_NODE_UNASSIGNED;
> }
>
> -static bool pcibus_allows_extended_config_space(PCIBus *bus)
> -{
> - return false;
> -}
> -
> static void pci_bus_class_init(ObjectClass *klass, void *data)
> {
> BusClass *k = BUS_CLASS(klass);
> @@ -161,7 +177,6 @@ static void pci_bus_class_init(ObjectClass *klass, void *data)
>
> pbc->bus_num = pcibus_num;
> pbc->numa_node = pcibus_numa_node;
> - pbc->allows_extended_config_space = pcibus_allows_extended_config_space;
> }
>
> static const TypeInfo pci_bus_info = {
> @@ -182,16 +197,11 @@ static const TypeInfo conventional_pci_interface_info = {
> .parent = TYPE_INTERFACE,
> };
>
> -static bool pciebus_allows_extended_config_space(PCIBus *bus)
> -{
> - return true;
> -}
> -
> static void pcie_bus_class_init(ObjectClass *klass, void *data)
> {
> - PCIBusClass *pbc = PCI_BUS_CLASS(klass);
> + BusClass *k = BUS_CLASS(klass);
>
> - pbc->allows_extended_config_space = pciebus_allows_extended_config_space;
> + k->realize = pcie_bus_realize;
> }
>
> static const TypeInfo pcie_bus_info = {
> @@ -410,11 +420,6 @@ bool pci_bus_is_express(PCIBus *bus)
> return object_dynamic_cast(OBJECT(bus), TYPE_PCIE_BUS);
> }
>
> -bool pci_bus_allows_extended_config_space(PCIBus *bus)
> -{
> - return PCI_BUS_GET_CLASS(bus)->allows_extended_config_space(bus);
> -}
> -
> void pci_root_bus_new_inplace(PCIBus *bus, size_t bus_size, DeviceState *parent,
> const char *name,
> MemoryRegion *address_space_mem,
> diff --git a/hw/pci/pci_host.c b/hw/pci/pci_host.c
> index 9d64b2e12f..5f3497256c 100644
> --- a/hw/pci/pci_host.c
> +++ b/hw/pci/pci_host.c
> @@ -53,16 +53,9 @@ static inline PCIDevice *pci_dev_find_by_addr(PCIBus *bus, uint32_t addr)
>
> static void pci_adjust_config_limit(PCIBus *bus, uint32_t *limit)
> {
> - if (*limit > PCI_CONFIG_SPACE_SIZE) {
> - if (!pci_bus_allows_extended_config_space(bus)) {
> - *limit = PCI_CONFIG_SPACE_SIZE;
> - return;
> - }
> -
> - if (!pci_bus_is_root(bus)) {
> - PCIDevice *bridge = pci_bridge_get_device(bus);
> - pci_adjust_config_limit(pci_get_bus(bridge), limit);
> - }
> + if ((*limit > PCI_CONFIG_SPACE_SIZE) &&
> + !pci_bus_allows_extended_config_space(bus)) {
> + *limit = PCI_CONFIG_SPACE_SIZE;
> }
> }
>
> diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
> index f62e6833b8..65a86be29c 100644
> --- a/hw/ppc/spapr_pci.c
> +++ b/hw/ppc/spapr_pci.c
> @@ -1638,28 +1638,6 @@ static void spapr_phb_unrealize(DeviceState *dev, Error **errp)
> memory_region_del_subregion(get_system_memory(), &sphb->mem32window);
> }
>
> -static bool spapr_phb_allows_extended_config_space(PCIBus *bus)
> -{
> - SpaprPhbState *sphb = SPAPR_PCI_HOST_BRIDGE(BUS(bus)->parent);
> -
> - return sphb->pcie_ecs;
> -}
> -
> -static void spapr_phb_root_bus_class_init(ObjectClass *klass, void *data)
> -{
> - PCIBusClass *pbc = PCI_BUS_CLASS(klass);
> -
> - pbc->allows_extended_config_space = spapr_phb_allows_extended_config_space;
> -}
> -
> -#define TYPE_SPAPR_PHB_ROOT_BUS "pci"
> -
> -static const TypeInfo spapr_phb_root_bus_info = {
> - .name = TYPE_SPAPR_PHB_ROOT_BUS,
> - .parent = TYPE_PCI_BUS,
> - .class_init = spapr_phb_root_bus_class_init,
> -};
> -
> static void spapr_phb_realize(DeviceState *dev, Error **errp)
> {
> /* We don't use SPAPR_MACHINE() in order to exit gracefully if the user
> @@ -1765,7 +1743,16 @@ static void spapr_phb_realize(DeviceState *dev, Error **errp)
> pci_spapr_set_irq, pci_spapr_map_irq, sphb,
> &sphb->memspace, &sphb->iospace,
> PCI_DEVFN(0, 0), PCI_NUM_PINS,
> - TYPE_SPAPR_PHB_ROOT_BUS);
> + TYPE_PCI_BUS);
> +
> + /*
> + * Despite resembling a vanilla PCI bus in most ways, the PAPR
> + * para-virtualized PCI bus *does* permit PCI-E extended config
> + * space access
> + */
> + if (sphb->pcie_ecs) {
> + bus->flags |= PCI_BUS_EXTENDED_CONFIG_SPACE;
> + }
> phb->bus = bus;
> qbus_set_hotplug_handler(BUS(phb->bus), OBJECT(sphb), NULL);
>
> @@ -2348,7 +2335,6 @@ void spapr_pci_rtas_init(void)
> static void spapr_pci_register_types(void)
> {
> type_register_static(&spapr_phb_info);
> - type_register_static(&spapr_phb_root_bus_info);
> }
>
> type_init(spapr_pci_register_types)
> diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
> index 33ccce320c..0edfaabbb0 100644
> --- a/include/hw/pci/pci.h
> +++ b/include/hw/pci/pci.h
> @@ -395,7 +395,6 @@ typedef PCIINTxRoute (*pci_route_irq_fn)(void *opaque, int pin);
> #define TYPE_PCIE_BUS "PCIE"
>
> bool pci_bus_is_express(PCIBus *bus);
> -bool pci_bus_allows_extended_config_space(PCIBus *bus);
>
> void pci_root_bus_new_inplace(PCIBus *bus, size_t bus_size, DeviceState *parent,
> const char *name,
> diff --git a/include/hw/pci/pci_bus.h b/include/hw/pci/pci_bus.h
> index aea98d5040..2d5f74b7c1 100644
> --- a/include/hw/pci/pci_bus.h
> +++ b/include/hw/pci/pci_bus.h
> @@ -17,12 +17,13 @@ typedef struct PCIBusClass {
>
> int (*bus_num)(PCIBus *bus);
> uint16_t (*numa_node)(PCIBus *bus);
> - bool (*allows_extended_config_space)(PCIBus *bus);
> } PCIBusClass;
>
> enum PCIBusFlags {
> /* This bus is the root of a PCI domain */
> PCI_BUS_IS_ROOT = 0x0001,
> + /* PCIe extended configuration space is accessible on this bus */
> + PCI_BUS_EXTENDED_CONFIG_SPACE = 0x0002,
> };
>
> struct PCIBus {
> @@ -57,4 +58,10 @@ static inline bool pci_bus_is_root(PCIBus *bus)
> return !!(bus->flags & PCI_BUS_IS_ROOT);
> }
>
> +static inline bool pci_bus_allows_extended_config_space(PCIBus *bus)
> +{
> + return !!(bus->flags & PCI_BUS_EXTENDED_CONFIG_SPACE);
> +}
> +
> +
> #endif /* QEMU_PCI_BUS_H */
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH v2 3/3] pcie: Simplify pci_adjust_config_limit()
@ 2019-04-24 16:09 ` Greg Kurz
0 siblings, 0 replies; 289+ messages in thread
From: Greg Kurz @ 2019-04-24 16:09 UTC (permalink / raw)
To: David Gibson
Cc: Michael S. Tsirkin, qemu-devel, Alex Williamson, qemu-ppc, clg
On Wed, 24 Apr 2019 14:19:59 +1000
David Gibson <david@gibson.dropbear.id.au> wrote:
> Since c2077e2c "pci: Adjust PCI config limit based on bus topology",
> pci_adjust_config_limit() has been used in the config space read and write
> paths to only permit access to extended config space on buses which permit
> it. Specifically it prevents access on devices below a vanilla-PCI bus via
> some combination of bridges, even if both the host bridge and the device
> itself are PCI-E.
>
> It accomplishes this with a somewhat complex call up the chain of bridges
> to see if any of them prohibit extended config space access. This is
> overly complex, since we can always know if the bus will support such
> access at the point it is constructed.
>
> This patch simplifies the test by using a flag in the PCIBus instance
> indicating whether extended configuration space is accessible. It is
> false for vanilla PCI buses. For PCI-E buses, it is true for root
> buses and equal to the parent bus's's capability otherwise.
>
> For the special case of sPAPR's paravirtualized PCI root bus, which
> acts mostly like vanilla PCI, but does allow extended config space
> access, we override the default value of the flag from the host bridge
> code.
>
> This should cause no behavioural change.
>
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>cd
> ---
Reviewed-by: Greg Kurz <groug@kaod.org>
> hw/pci/pci.c | 41 ++++++++++++++++++++++------------------
> hw/pci/pci_host.c | 13 +++----------
> hw/ppc/spapr_pci.c | 34 ++++++++++-----------------------
> include/hw/pci/pci.h | 1 -
> include/hw/pci/pci_bus.h | 9 ++++++++-
> 5 files changed, 44 insertions(+), 54 deletions(-)
>
> diff --git a/hw/pci/pci.c b/hw/pci/pci.c
> index ea5941fb22..59ee034331 100644
> --- a/hw/pci/pci.c
> +++ b/hw/pci/pci.c
> @@ -120,6 +120,27 @@ static void pci_bus_realize(BusState *qbus, Error **errp)
> vmstate_register(NULL, -1, &vmstate_pcibus, bus);
> }
>
> +static void pcie_bus_realize(BusState *qbus, Error **errp)
> +{
> + PCIBus *bus = PCI_BUS(qbus);
> +
> + pci_bus_realize(qbus, errp);
> +
> + /*
> + * A PCI-E bus can support extended config space if it's the root
> + * bus, or if the bus/bridge above it does as well
> + */
> + if (pci_bus_is_root(bus)) {
> + bus->flags |= PCI_BUS_EXTENDED_CONFIG_SPACE;
> + } else {
> + PCIBus *parent_bus = pci_get_bus(bus->parent_dev);
> +
> + if (pci_bus_allows_extended_config_space(parent_bus)) {
> + bus->flags |= PCI_BUS_EXTENDED_CONFIG_SPACE;
> + }
> + }
> +}
> +
> static void pci_bus_unrealize(BusState *qbus, Error **errp)
> {
> PCIBus *bus = PCI_BUS(qbus);
> @@ -142,11 +163,6 @@ static uint16_t pcibus_numa_node(PCIBus *bus)
> return NUMA_NODE_UNASSIGNED;
> }
>
> -static bool pcibus_allows_extended_config_space(PCIBus *bus)
> -{
> - return false;
> -}
> -
> static void pci_bus_class_init(ObjectClass *klass, void *data)
> {
> BusClass *k = BUS_CLASS(klass);
> @@ -161,7 +177,6 @@ static void pci_bus_class_init(ObjectClass *klass, void *data)
>
> pbc->bus_num = pcibus_num;
> pbc->numa_node = pcibus_numa_node;
> - pbc->allows_extended_config_space = pcibus_allows_extended_config_space;
> }
>
> static const TypeInfo pci_bus_info = {
> @@ -182,16 +197,11 @@ static const TypeInfo conventional_pci_interface_info = {
> .parent = TYPE_INTERFACE,
> };
>
> -static bool pciebus_allows_extended_config_space(PCIBus *bus)
> -{
> - return true;
> -}
> -
> static void pcie_bus_class_init(ObjectClass *klass, void *data)
> {
> - PCIBusClass *pbc = PCI_BUS_CLASS(klass);
> + BusClass *k = BUS_CLASS(klass);
>
> - pbc->allows_extended_config_space = pciebus_allows_extended_config_space;
> + k->realize = pcie_bus_realize;
> }
>
> static const TypeInfo pcie_bus_info = {
> @@ -410,11 +420,6 @@ bool pci_bus_is_express(PCIBus *bus)
> return object_dynamic_cast(OBJECT(bus), TYPE_PCIE_BUS);
> }
>
> -bool pci_bus_allows_extended_config_space(PCIBus *bus)
> -{
> - return PCI_BUS_GET_CLASS(bus)->allows_extended_config_space(bus);
> -}
> -
> void pci_root_bus_new_inplace(PCIBus *bus, size_t bus_size, DeviceState *parent,
> const char *name,
> MemoryRegion *address_space_mem,
> diff --git a/hw/pci/pci_host.c b/hw/pci/pci_host.c
> index 9d64b2e12f..5f3497256c 100644
> --- a/hw/pci/pci_host.c
> +++ b/hw/pci/pci_host.c
> @@ -53,16 +53,9 @@ static inline PCIDevice *pci_dev_find_by_addr(PCIBus *bus, uint32_t addr)
>
> static void pci_adjust_config_limit(PCIBus *bus, uint32_t *limit)
> {
> - if (*limit > PCI_CONFIG_SPACE_SIZE) {
> - if (!pci_bus_allows_extended_config_space(bus)) {
> - *limit = PCI_CONFIG_SPACE_SIZE;
> - return;
> - }
> -
> - if (!pci_bus_is_root(bus)) {
> - PCIDevice *bridge = pci_bridge_get_device(bus);
> - pci_adjust_config_limit(pci_get_bus(bridge), limit);
> - }
> + if ((*limit > PCI_CONFIG_SPACE_SIZE) &&
> + !pci_bus_allows_extended_config_space(bus)) {
> + *limit = PCI_CONFIG_SPACE_SIZE;
> }
> }
>
> diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
> index f62e6833b8..65a86be29c 100644
> --- a/hw/ppc/spapr_pci.c
> +++ b/hw/ppc/spapr_pci.c
> @@ -1638,28 +1638,6 @@ static void spapr_phb_unrealize(DeviceState *dev, Error **errp)
> memory_region_del_subregion(get_system_memory(), &sphb->mem32window);
> }
>
> -static bool spapr_phb_allows_extended_config_space(PCIBus *bus)
> -{
> - SpaprPhbState *sphb = SPAPR_PCI_HOST_BRIDGE(BUS(bus)->parent);
> -
> - return sphb->pcie_ecs;
> -}
> -
> -static void spapr_phb_root_bus_class_init(ObjectClass *klass, void *data)
> -{
> - PCIBusClass *pbc = PCI_BUS_CLASS(klass);
> -
> - pbc->allows_extended_config_space = spapr_phb_allows_extended_config_space;
> -}
> -
> -#define TYPE_SPAPR_PHB_ROOT_BUS "pci"
> -
> -static const TypeInfo spapr_phb_root_bus_info = {
> - .name = TYPE_SPAPR_PHB_ROOT_BUS,
> - .parent = TYPE_PCI_BUS,
> - .class_init = spapr_phb_root_bus_class_init,
> -};
> -
> static void spapr_phb_realize(DeviceState *dev, Error **errp)
> {
> /* We don't use SPAPR_MACHINE() in order to exit gracefully if the user
> @@ -1765,7 +1743,16 @@ static void spapr_phb_realize(DeviceState *dev, Error **errp)
> pci_spapr_set_irq, pci_spapr_map_irq, sphb,
> &sphb->memspace, &sphb->iospace,
> PCI_DEVFN(0, 0), PCI_NUM_PINS,
> - TYPE_SPAPR_PHB_ROOT_BUS);
> + TYPE_PCI_BUS);
> +
> + /*
> + * Despite resembling a vanilla PCI bus in most ways, the PAPR
> + * para-virtualized PCI bus *does* permit PCI-E extended config
> + * space access
> + */
> + if (sphb->pcie_ecs) {
> + bus->flags |= PCI_BUS_EXTENDED_CONFIG_SPACE;
> + }
> phb->bus = bus;
> qbus_set_hotplug_handler(BUS(phb->bus), OBJECT(sphb), NULL);
>
> @@ -2348,7 +2335,6 @@ void spapr_pci_rtas_init(void)
> static void spapr_pci_register_types(void)
> {
> type_register_static(&spapr_phb_info);
> - type_register_static(&spapr_phb_root_bus_info);
> }
>
> type_init(spapr_pci_register_types)
> diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
> index 33ccce320c..0edfaabbb0 100644
> --- a/include/hw/pci/pci.h
> +++ b/include/hw/pci/pci.h
> @@ -395,7 +395,6 @@ typedef PCIINTxRoute (*pci_route_irq_fn)(void *opaque, int pin);
> #define TYPE_PCIE_BUS "PCIE"
>
> bool pci_bus_is_express(PCIBus *bus);
> -bool pci_bus_allows_extended_config_space(PCIBus *bus);
>
> void pci_root_bus_new_inplace(PCIBus *bus, size_t bus_size, DeviceState *parent,
> const char *name,
> diff --git a/include/hw/pci/pci_bus.h b/include/hw/pci/pci_bus.h
> index aea98d5040..2d5f74b7c1 100644
> --- a/include/hw/pci/pci_bus.h
> +++ b/include/hw/pci/pci_bus.h
> @@ -17,12 +17,13 @@ typedef struct PCIBusClass {
>
> int (*bus_num)(PCIBus *bus);
> uint16_t (*numa_node)(PCIBus *bus);
> - bool (*allows_extended_config_space)(PCIBus *bus);
> } PCIBusClass;
>
> enum PCIBusFlags {
> /* This bus is the root of a PCI domain */
> PCI_BUS_IS_ROOT = 0x0001,
> + /* PCIe extended configuration space is accessible on this bus */
> + PCI_BUS_EXTENDED_CONFIG_SPACE = 0x0002,
> };
>
> struct PCIBus {
> @@ -57,4 +58,10 @@ static inline bool pci_bus_is_root(PCIBus *bus)
> return !!(bus->flags & PCI_BUS_IS_ROOT);
> }
>
> +static inline bool pci_bus_allows_extended_config_space(PCIBus *bus)
> +{
> + return !!(bus->flags & PCI_BUS_EXTENDED_CONFIG_SPACE);
> +}
> +
> +
> #endif /* QEMU_PCI_BUS_H */
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [Qemu-ppc] [PATCH v2 3/3] pcie: Simplify pci_adjust_config_limit()
2019-04-24 4:19 ` David Gibson
(?)
(?)
@ 2019-04-26 6:40 ` Alexey Kardashevskiy
2019-05-07 4:48 ` David Gibson
-1 siblings, 1 reply; 289+ messages in thread
From: Alexey Kardashevskiy @ 2019-04-26 6:40 UTC (permalink / raw)
To: David Gibson, Marcel Apfelbaum, qemu-devel, Michael S. Tsirkin,
Alex Williamson, Greg Kurz
Cc: qemu-ppc, clg
On 24/04/2019 14:19, David Gibson wrote:
> Since c2077e2c "pci: Adjust PCI config limit based on bus topology",
> pci_adjust_config_limit() has been used in the config space read and write
> paths to only permit access to extended config space on buses which permit
> it. Specifically it prevents access on devices below a vanilla-PCI bus via
> some combination of bridges, even if both the host bridge and the device
> itself are PCI-E.
>
> It accomplishes this with a somewhat complex call up the chain of bridges
> to see if any of them prohibit extended config space access. This is
> overly complex, since we can always know if the bus will support such
> access at the point it is constructed.
>
> This patch simplifies the test by using a flag in the PCIBus instance
> indicating whether extended configuration space is accessible. It is
> false for vanilla PCI buses. For PCI-E buses, it is true for root
> buses and equal to the parent bus's's capability otherwise.
>
> For the special case of sPAPR's paravirtualized PCI root bus, which
> acts mostly like vanilla PCI, but does allow extended config space
> access, we override the default value of the flag from the host bridge
> code.
>
> This should cause no behavioural change.
>
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>cd
> ---
> hw/pci/pci.c | 41 ++++++++++++++++++++++------------------
> hw/pci/pci_host.c | 13 +++----------
> hw/ppc/spapr_pci.c | 34 ++++++++++-----------------------
> include/hw/pci/pci.h | 1 -
> include/hw/pci/pci_bus.h | 9 ++++++++-
> 5 files changed, 44 insertions(+), 54 deletions(-)
>
> diff --git a/hw/pci/pci.c b/hw/pci/pci.c
> index ea5941fb22..59ee034331 100644
> --- a/hw/pci/pci.c
> +++ b/hw/pci/pci.c
> @@ -120,6 +120,27 @@ static void pci_bus_realize(BusState *qbus, Error **errp)
> vmstate_register(NULL, -1, &vmstate_pcibus, bus);
> }
>
> +static void pcie_bus_realize(BusState *qbus, Error **errp)
> +{
> + PCIBus *bus = PCI_BUS(qbus);
> +
> + pci_bus_realize(qbus, errp);
> +
> + /*
> + * A PCI-E bus can support extended config space if it's the root
> + * bus, or if the bus/bridge above it does as well
> + */
> + if (pci_bus_is_root(bus)) {
> + bus->flags |= PCI_BUS_EXTENDED_CONFIG_SPACE;
> + } else {
> + PCIBus *parent_bus = pci_get_bus(bus->parent_dev);
g_assert(bus->parent_dev) ?
Slightly confusingly bus->parent_dev is not the same as bus->qbus.parent
and can be NULL, I'd even look into ditching parent_dev and using
bus->qbus.parent instead (if possible).
> +
> + if (pci_bus_allows_extended_config_space(parent_bus)) {
> + bus->flags |= PCI_BUS_EXTENDED_CONFIG_SPACE;
> + }
> + }
> +}
> +
> static void pci_bus_unrealize(BusState *qbus, Error **errp)
> {
> PCIBus *bus = PCI_BUS(qbus);
> @@ -142,11 +163,6 @@ static uint16_t pcibus_numa_node(PCIBus *bus)
> return NUMA_NODE_UNASSIGNED;
> }
>
> -static bool pcibus_allows_extended_config_space(PCIBus *bus)
> -{
> - return false;
> -}
> -
> static void pci_bus_class_init(ObjectClass *klass, void *data)
> {
> BusClass *k = BUS_CLASS(klass);
> @@ -161,7 +177,6 @@ static void pci_bus_class_init(ObjectClass *klass, void *data)
>
> pbc->bus_num = pcibus_num;
> pbc->numa_node = pcibus_numa_node;
> - pbc->allows_extended_config_space = pcibus_allows_extended_config_space;
> }
>
> static const TypeInfo pci_bus_info = {
> @@ -182,16 +197,11 @@ static const TypeInfo conventional_pci_interface_info = {
> .parent = TYPE_INTERFACE,
> };
>
> -static bool pciebus_allows_extended_config_space(PCIBus *bus)
> -{
> - return true;
> -}
> -
> static void pcie_bus_class_init(ObjectClass *klass, void *data)
> {
> - PCIBusClass *pbc = PCI_BUS_CLASS(klass);
> + BusClass *k = BUS_CLASS(klass);
>
> - pbc->allows_extended_config_space = pciebus_allows_extended_config_space;
> + k->realize = pcie_bus_realize;
> }
>
> static const TypeInfo pcie_bus_info = {
> @@ -410,11 +420,6 @@ bool pci_bus_is_express(PCIBus *bus)
> return object_dynamic_cast(OBJECT(bus), TYPE_PCIE_BUS);
> }
>
> -bool pci_bus_allows_extended_config_space(PCIBus *bus)
> -{
> - return PCI_BUS_GET_CLASS(bus)->allows_extended_config_space(bus);
> -}
> -
> void pci_root_bus_new_inplace(PCIBus *bus, size_t bus_size, DeviceState *parent,
> const char *name,
> MemoryRegion *address_space_mem,
> diff --git a/hw/pci/pci_host.c b/hw/pci/pci_host.c
> index 9d64b2e12f..5f3497256c 100644
> --- a/hw/pci/pci_host.c
> +++ b/hw/pci/pci_host.c
> @@ -53,16 +53,9 @@ static inline PCIDevice *pci_dev_find_by_addr(PCIBus *bus, uint32_t addr)
>
> static void pci_adjust_config_limit(PCIBus *bus, uint32_t *limit)
> {
> - if (*limit > PCI_CONFIG_SPACE_SIZE) {
> - if (!pci_bus_allows_extended_config_space(bus)) {
> - *limit = PCI_CONFIG_SPACE_SIZE;
> - return;
> - }
> -
> - if (!pci_bus_is_root(bus)) {
> - PCIDevice *bridge = pci_bridge_get_device(bus);
> - pci_adjust_config_limit(pci_get_bus(bridge), limit);
> - }
> + if ((*limit > PCI_CONFIG_SPACE_SIZE) &&
> + !pci_bus_allows_extended_config_space(bus)) {
> + *limit = PCI_CONFIG_SPACE_SIZE;
> }
> }
>
> diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
> index f62e6833b8..65a86be29c 100644
> --- a/hw/ppc/spapr_pci.c
> +++ b/hw/ppc/spapr_pci.c
> @@ -1638,28 +1638,6 @@ static void spapr_phb_unrealize(DeviceState *dev, Error **errp)
> memory_region_del_subregion(get_system_memory(), &sphb->mem32window);
> }
>
> -static bool spapr_phb_allows_extended_config_space(PCIBus *bus)
> -{
> - SpaprPhbState *sphb = SPAPR_PCI_HOST_BRIDGE(BUS(bus)->parent);
> -
> - return sphb->pcie_ecs;
> -}
> -
> -static void spapr_phb_root_bus_class_init(ObjectClass *klass, void *data)
> -{
> - PCIBusClass *pbc = PCI_BUS_CLASS(klass);
> -
> - pbc->allows_extended_config_space = spapr_phb_allows_extended_config_space;
> -}
> -
> -#define TYPE_SPAPR_PHB_ROOT_BUS "pci"
> -
> -static const TypeInfo spapr_phb_root_bus_info = {
> - .name = TYPE_SPAPR_PHB_ROOT_BUS,
> - .parent = TYPE_PCI_BUS,
> - .class_init = spapr_phb_root_bus_class_init,
> -};
> -
> static void spapr_phb_realize(DeviceState *dev, Error **errp)
> {
> /* We don't use SPAPR_MACHINE() in order to exit gracefully if the user
> @@ -1765,7 +1743,16 @@ static void spapr_phb_realize(DeviceState *dev, Error **errp)
> pci_spapr_set_irq, pci_spapr_map_irq, sphb,
> &sphb->memspace, &sphb->iospace,
> PCI_DEVFN(0, 0), PCI_NUM_PINS,
> - TYPE_SPAPR_PHB_ROOT_BUS);
> + TYPE_PCI_BUS);
> +
> + /*
> + * Despite resembling a vanilla PCI bus in most ways, the PAPR
> + * para-virtualized PCI bus *does* permit PCI-E extended config
> + * space access
> + */
> + if (sphb->pcie_ecs) {
> + bus->flags |= PCI_BUS_EXTENDED_CONFIG_SPACE;
> + }
> phb->bus = bus;
> qbus_set_hotplug_handler(BUS(phb->bus), OBJECT(sphb), NULL);
>
> @@ -2348,7 +2335,6 @@ void spapr_pci_rtas_init(void)
> static void spapr_pci_register_types(void)
> {
> type_register_static(&spapr_phb_info);
> - type_register_static(&spapr_phb_root_bus_info);
> }
>
> type_init(spapr_pci_register_types)
> diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
> index 33ccce320c..0edfaabbb0 100644
> --- a/include/hw/pci/pci.h
> +++ b/include/hw/pci/pci.h
> @@ -395,7 +395,6 @@ typedef PCIINTxRoute (*pci_route_irq_fn)(void *opaque, int pin);
> #define TYPE_PCIE_BUS "PCIE"
>
> bool pci_bus_is_express(PCIBus *bus);
> -bool pci_bus_allows_extended_config_space(PCIBus *bus);
>
> void pci_root_bus_new_inplace(PCIBus *bus, size_t bus_size, DeviceState *parent,
> const char *name,
> diff --git a/include/hw/pci/pci_bus.h b/include/hw/pci/pci_bus.h
> index aea98d5040..2d5f74b7c1 100644
> --- a/include/hw/pci/pci_bus.h
> +++ b/include/hw/pci/pci_bus.h
> @@ -17,12 +17,13 @@ typedef struct PCIBusClass {
>
> int (*bus_num)(PCIBus *bus);
> uint16_t (*numa_node)(PCIBus *bus);
> - bool (*allows_extended_config_space)(PCIBus *bus);
> } PCIBusClass;
>
> enum PCIBusFlags {
> /* This bus is the root of a PCI domain */
> PCI_BUS_IS_ROOT = 0x0001,
> + /* PCIe extended configuration space is accessible on this bus */
> + PCI_BUS_EXTENDED_CONFIG_SPACE = 0x0002,
> };
>
> struct PCIBus {
> @@ -57,4 +58,10 @@ static inline bool pci_bus_is_root(PCIBus *bus)
> return !!(bus->flags & PCI_BUS_IS_ROOT);
> }
>
> +static inline bool pci_bus_allows_extended_config_space(PCIBus *bus)
> +{
> + return !!(bus->flags & PCI_BUS_EXTENDED_CONFIG_SPACE);
> +}
> +
> +
An extra empty line.
Anyway, these are minor comments, so
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> #endif /* QEMU_PCI_BUS_H */
>
--
Alexey
^ permalink raw reply [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v4 00/15] tests: acpi: add UEFI (ARM) testing support
@ 2019-05-02 14:51 ` Igor Mammedov
0 siblings, 0 replies; 289+ messages in thread
From: Igor Mammedov @ 2019-05-02 14:51 UTC (permalink / raw)
To: qemu-devel
Cc: Laszlo Ersek, Michael S. Tsirkin, Gonglei,
Philippe Mathieu-Daudé,
Shannon Zhao, Wei Yang, Andrew Jones, Shameer Kolothum,
Ben Warren, xuwei5, xuwei5, linuxarm
Changelog:
- from v3:
* reshaffle patch order a bit
* move out acpi_parse_rsdp_table() hunk to
"tests: acpi: make pointer to RSDP 64bit"
where it belongs
* move acpi_fetch_rsdp_table(s/uint32_t addr/uint64_t addr/) to
this patch where it belongs from:
"tests: acpi: make RSDT test routine handle XSDT"
* dropping Reviewed-bys due to acpi_fetch_table() change
introduced by earlier patch:
"tests: acpi: make acpi_fetch_table() take size of fetched table pointer"
* update [8/15] commit message to point to commit which introduced
signature_guid value.
* get rid of test_acpi_rsdp_address() in [9/15]
* added new patch
tests: acpi: allow to override default accelerator
* force arm/virt test to use TCG accelerator
- from v2:
* rebase on top current master (with UEFI blobs merged)
* added a Makefile rule to include bios-tables-test to aarch64 tests by
default into 11/13 (kept Reviewed-bys)
* other trivial fixes and cleanups (see per patch changelogs)
- from v1:
* rebase on top
(1) [PATCH for-4.1 v3 00/12] bundle edk2 platform firmware with QEMU
let me to drop edk2 images and drop Makefile magic to unpack them,
Laszlo's series conveniently does it all for me.
* use new path/names for firmware images as supplied by [1]
* reorder patches a bit so that UEFI parts would go after generic changes
Series adds support for ACPI tables located above 4G. It adds 64-bit handling
necessary for testing arm/virt board (i.e. might be not complete wrt spec) and
uses recently merged UEFI (AVMF) firmware/test disk image which provides
an entry point[1] for fetching ACPI tables (RSDP pointer).
Git tree for testing:
https://github.com/imammedo/qemu.git acpi_arm_tests_v4
Ref to previos vesrsion:
[PATCH v3 00/13] tests: acpi: add UEFI (ARM) testing support
https://www.mail-archive.com/qemu-devel@nongnu.org/msg612679.html
CC: Laszlo Ersek <lersek@redhat.com>
CC: "Michael S. Tsirkin" <mst@redhat.com>
CC: Gonglei <arei.gonglei@huawei.com>
CC: Philippe Mathieu-Daudé <philmd@redhat.com>
CC: Shannon Zhao <shannon.zhaosl@gmail.com>
CC: Wei Yang <richardw.yang@linux.intel.com>
CC: Andrew Jones <drjones@redhat.com>
CC: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
CC: Ben Warren <ben@skyportsystems.com>
CC: <xuwei5@hisilicon.com>
CC: <xuwei5@huawei.com>
CC: <shameerali.kolothum.thodi@huawei.com>
CC: <linuxarm@huawei.com>
Igor Mammedov (15):
tests: acpi: rename acpi_parse_rsdp_table() into
acpi_fetch_rsdp_table()
tests: acpi: make acpi_fetch_table() take size of fetched table
pointer
tests: acpi: make RSDT test routine handle XSDT
tests: acpi: make pointer to RSDP 64bit
tests: acpi: fetch X_DSDT if pointer to DSDT is 0
tests: acpi: skip FACS table if board uses hw reduced ACPI profile
tests: acpi: move boot_sector_init() into x86 tests branch
tests: acpi: add acpi_find_rsdp_address_uefi() helper
tests: acpi: add a way to start tests with UEFI firmware
tests: acpi: ignore SMBIOS tests when UEFI firmware is used
tests: acpi: allow to override default accelerator
tests: add expected ACPI tables for arm/virt board
tests: acpi: add simple arm/virt testcase
tests: acpi: refactor rebuild-expected-aml.sh to dump ACPI tables for
a specified list of targets
tests: acpi: print error unable to dump ACPI table during rebuild
tests/acpi-utils.h | 7 +-
tests/Makefile.include | 1 +
tests/acpi-utils.c | 68 +++++++++++----
tests/bios-tables-test.c | 148 +++++++++++++++++++++++---------
tests/data/acpi/rebuild-expected-aml.sh | 23 +++--
tests/data/acpi/virt/APIC | Bin 0 -> 168 bytes
tests/data/acpi/virt/DSDT | Bin 0 -> 18476 bytes
tests/data/acpi/virt/FACP | Bin 0 -> 268 bytes
tests/data/acpi/virt/GTDT | Bin 0 -> 96 bytes
tests/data/acpi/virt/MCFG | Bin 0 -> 60 bytes
tests/data/acpi/virt/SPCR | Bin 0 -> 80 bytes
tests/vmgenid-test.c | 6 +-
12 files changed, 178 insertions(+), 75 deletions(-)
create mode 100644 tests/data/acpi/virt/APIC
create mode 100644 tests/data/acpi/virt/DSDT
create mode 100644 tests/data/acpi/virt/FACP
create mode 100644 tests/data/acpi/virt/GTDT
create mode 100644 tests/data/acpi/virt/MCFG
create mode 100644 tests/data/acpi/virt/SPCR
--
2.7.4
^ permalink raw reply [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v4 00/15] tests: acpi: add UEFI (ARM) testing support
@ 2019-05-02 14:51 ` Igor Mammedov
0 siblings, 0 replies; 289+ messages in thread
From: Igor Mammedov @ 2019-05-02 14:51 UTC (permalink / raw)
To: qemu-devel
Cc: Andrew Jones, Ben Warren, Michael S. Tsirkin, Laszlo Ersek,
linuxarm, Shameer Kolothum, Shannon Zhao, Gonglei, Wei Yang,
xuwei5, xuwei5, Philippe Mathieu-Daudé
Changelog:
- from v3:
* reshaffle patch order a bit
* move out acpi_parse_rsdp_table() hunk to
"tests: acpi: make pointer to RSDP 64bit"
where it belongs
* move acpi_fetch_rsdp_table(s/uint32_t addr/uint64_t addr/) to
this patch where it belongs from:
"tests: acpi: make RSDT test routine handle XSDT"
* dropping Reviewed-bys due to acpi_fetch_table() change
introduced by earlier patch:
"tests: acpi: make acpi_fetch_table() take size of fetched table pointer"
* update [8/15] commit message to point to commit which introduced
signature_guid value.
* get rid of test_acpi_rsdp_address() in [9/15]
* added new patch
tests: acpi: allow to override default accelerator
* force arm/virt test to use TCG accelerator
- from v2:
* rebase on top current master (with UEFI blobs merged)
* added a Makefile rule to include bios-tables-test to aarch64 tests by
default into 11/13 (kept Reviewed-bys)
* other trivial fixes and cleanups (see per patch changelogs)
- from v1:
* rebase on top
(1) [PATCH for-4.1 v3 00/12] bundle edk2 platform firmware with QEMU
let me to drop edk2 images and drop Makefile magic to unpack them,
Laszlo's series conveniently does it all for me.
* use new path/names for firmware images as supplied by [1]
* reorder patches a bit so that UEFI parts would go after generic changes
Series adds support for ACPI tables located above 4G. It adds 64-bit handling
necessary for testing arm/virt board (i.e. might be not complete wrt spec) and
uses recently merged UEFI (AVMF) firmware/test disk image which provides
an entry point[1] for fetching ACPI tables (RSDP pointer).
Git tree for testing:
https://github.com/imammedo/qemu.git acpi_arm_tests_v4
Ref to previos vesrsion:
[PATCH v3 00/13] tests: acpi: add UEFI (ARM) testing support
https://www.mail-archive.com/qemu-devel@nongnu.org/msg612679.html
CC: Laszlo Ersek <lersek@redhat.com>
CC: "Michael S. Tsirkin" <mst@redhat.com>
CC: Gonglei <arei.gonglei@huawei.com>
CC: Philippe Mathieu-Daudé <philmd@redhat.com>
CC: Shannon Zhao <shannon.zhaosl@gmail.com>
CC: Wei Yang <richardw.yang@linux.intel.com>
CC: Andrew Jones <drjones@redhat.com>
CC: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
CC: Ben Warren <ben@skyportsystems.com>
CC: <xuwei5@hisilicon.com>
CC: <xuwei5@huawei.com>
CC: <shameerali.kolothum.thodi@huawei.com>
CC: <linuxarm@huawei.com>
Igor Mammedov (15):
tests: acpi: rename acpi_parse_rsdp_table() into
acpi_fetch_rsdp_table()
tests: acpi: make acpi_fetch_table() take size of fetched table
pointer
tests: acpi: make RSDT test routine handle XSDT
tests: acpi: make pointer to RSDP 64bit
tests: acpi: fetch X_DSDT if pointer to DSDT is 0
tests: acpi: skip FACS table if board uses hw reduced ACPI profile
tests: acpi: move boot_sector_init() into x86 tests branch
tests: acpi: add acpi_find_rsdp_address_uefi() helper
tests: acpi: add a way to start tests with UEFI firmware
tests: acpi: ignore SMBIOS tests when UEFI firmware is used
tests: acpi: allow to override default accelerator
tests: add expected ACPI tables for arm/virt board
tests: acpi: add simple arm/virt testcase
tests: acpi: refactor rebuild-expected-aml.sh to dump ACPI tables for
a specified list of targets
tests: acpi: print error unable to dump ACPI table during rebuild
tests/acpi-utils.h | 7 +-
tests/Makefile.include | 1 +
tests/acpi-utils.c | 68 +++++++++++----
tests/bios-tables-test.c | 148 +++++++++++++++++++++++---------
tests/data/acpi/rebuild-expected-aml.sh | 23 +++--
tests/data/acpi/virt/APIC | Bin 0 -> 168 bytes
tests/data/acpi/virt/DSDT | Bin 0 -> 18476 bytes
tests/data/acpi/virt/FACP | Bin 0 -> 268 bytes
tests/data/acpi/virt/GTDT | Bin 0 -> 96 bytes
tests/data/acpi/virt/MCFG | Bin 0 -> 60 bytes
tests/data/acpi/virt/SPCR | Bin 0 -> 80 bytes
tests/vmgenid-test.c | 6 +-
12 files changed, 178 insertions(+), 75 deletions(-)
create mode 100644 tests/data/acpi/virt/APIC
create mode 100644 tests/data/acpi/virt/DSDT
create mode 100644 tests/data/acpi/virt/FACP
create mode 100644 tests/data/acpi/virt/GTDT
create mode 100644 tests/data/acpi/virt/MCFG
create mode 100644 tests/data/acpi/virt/SPCR
--
2.7.4
^ permalink raw reply [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v4 01/15] tests: acpi: rename acpi_parse_rsdp_table() into acpi_fetch_rsdp_table()
@ 2019-05-02 14:51 ` Igor Mammedov
0 siblings, 0 replies; 289+ messages in thread
From: Igor Mammedov @ 2019-05-02 14:51 UTC (permalink / raw)
To: qemu-devel
Cc: Laszlo Ersek, Michael S. Tsirkin, Gonglei,
Philippe Mathieu-Daudé,
Shannon Zhao, Wei Yang, Andrew Jones, Shameer Kolothum,
Ben Warren, xuwei5, xuwei5, linuxarm
so name would reflect what the function does
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Wei Yang <richardw.yang@linux.intel.com>
---
v4:
* make it as the first patch in series
---
tests/acpi-utils.h | 2 +-
tests/acpi-utils.c | 2 +-
tests/bios-tables-test.c | 2 +-
tests/vmgenid-test.c | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/tests/acpi-utils.h b/tests/acpi-utils.h
index ef388bb..4cd5553 100644
--- a/tests/acpi-utils.h
+++ b/tests/acpi-utils.h
@@ -47,7 +47,7 @@ typedef struct {
uint8_t acpi_calc_checksum(const uint8_t *data, int len);
uint32_t acpi_find_rsdp_address(QTestState *qts);
uint64_t acpi_get_xsdt_address(uint8_t *rsdp_table);
-void acpi_parse_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table);
+void acpi_fetch_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table);
void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
const uint8_t *addr_ptr, const char *sig,
bool verify_checksum);
diff --git a/tests/acpi-utils.c b/tests/acpi-utils.c
index cc33b46..633d8f5 100644
--- a/tests/acpi-utils.c
+++ b/tests/acpi-utils.c
@@ -63,7 +63,7 @@ uint64_t acpi_get_xsdt_address(uint8_t *rsdp_table)
return le64_to_cpu(xsdt_physical_address);
}
-void acpi_parse_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table)
+void acpi_fetch_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table)
{
uint8_t revision;
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index a506dcb..6a678bf 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -89,7 +89,7 @@ static void test_acpi_rsdp_table(test_data *data)
uint8_t *rsdp_table = data->rsdp_table, revision;
uint32_t addr = data->rsdp_addr;
- acpi_parse_rsdp_table(data->qts, addr, rsdp_table);
+ acpi_fetch_rsdp_table(data->qts, addr, rsdp_table);
revision = rsdp_table[15 /* Revision offset */];
switch (revision) {
diff --git a/tests/vmgenid-test.c b/tests/vmgenid-test.c
index ae38ee5..f400184 100644
--- a/tests/vmgenid-test.c
+++ b/tests/vmgenid-test.c
@@ -40,7 +40,7 @@ static uint32_t acpi_find_vgia(QTestState *qts)
g_assert_cmphex(rsdp_offset, <, RSDP_ADDR_INVALID);
- acpi_parse_rsdp_table(qts, rsdp_offset, rsdp_table);
+ acpi_fetch_rsdp_table(qts, rsdp_offset, rsdp_table);
acpi_fetch_table(qts, &rsdt, &rsdt_len, &rsdp_table[16 /* RsdtAddress */],
"RSDT", true);
--
2.7.4
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v4 01/15] tests: acpi: rename acpi_parse_rsdp_table() into acpi_fetch_rsdp_table()
@ 2019-05-02 14:51 ` Igor Mammedov
0 siblings, 0 replies; 289+ messages in thread
From: Igor Mammedov @ 2019-05-02 14:51 UTC (permalink / raw)
To: qemu-devel
Cc: Andrew Jones, Ben Warren, Michael S. Tsirkin, Laszlo Ersek,
linuxarm, Shameer Kolothum, Shannon Zhao, Gonglei, Wei Yang,
xuwei5, xuwei5, Philippe Mathieu-Daudé
so name would reflect what the function does
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Wei Yang <richardw.yang@linux.intel.com>
---
v4:
* make it as the first patch in series
---
tests/acpi-utils.h | 2 +-
tests/acpi-utils.c | 2 +-
tests/bios-tables-test.c | 2 +-
tests/vmgenid-test.c | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/tests/acpi-utils.h b/tests/acpi-utils.h
index ef388bb..4cd5553 100644
--- a/tests/acpi-utils.h
+++ b/tests/acpi-utils.h
@@ -47,7 +47,7 @@ typedef struct {
uint8_t acpi_calc_checksum(const uint8_t *data, int len);
uint32_t acpi_find_rsdp_address(QTestState *qts);
uint64_t acpi_get_xsdt_address(uint8_t *rsdp_table);
-void acpi_parse_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table);
+void acpi_fetch_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table);
void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
const uint8_t *addr_ptr, const char *sig,
bool verify_checksum);
diff --git a/tests/acpi-utils.c b/tests/acpi-utils.c
index cc33b46..633d8f5 100644
--- a/tests/acpi-utils.c
+++ b/tests/acpi-utils.c
@@ -63,7 +63,7 @@ uint64_t acpi_get_xsdt_address(uint8_t *rsdp_table)
return le64_to_cpu(xsdt_physical_address);
}
-void acpi_parse_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table)
+void acpi_fetch_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table)
{
uint8_t revision;
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index a506dcb..6a678bf 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -89,7 +89,7 @@ static void test_acpi_rsdp_table(test_data *data)
uint8_t *rsdp_table = data->rsdp_table, revision;
uint32_t addr = data->rsdp_addr;
- acpi_parse_rsdp_table(data->qts, addr, rsdp_table);
+ acpi_fetch_rsdp_table(data->qts, addr, rsdp_table);
revision = rsdp_table[15 /* Revision offset */];
switch (revision) {
diff --git a/tests/vmgenid-test.c b/tests/vmgenid-test.c
index ae38ee5..f400184 100644
--- a/tests/vmgenid-test.c
+++ b/tests/vmgenid-test.c
@@ -40,7 +40,7 @@ static uint32_t acpi_find_vgia(QTestState *qts)
g_assert_cmphex(rsdp_offset, <, RSDP_ADDR_INVALID);
- acpi_parse_rsdp_table(qts, rsdp_offset, rsdp_table);
+ acpi_fetch_rsdp_table(qts, rsdp_offset, rsdp_table);
acpi_fetch_table(qts, &rsdt, &rsdt_len, &rsdp_table[16 /* RsdtAddress */],
"RSDT", true);
--
2.7.4
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v4 02/15] tests: acpi: make acpi_fetch_table() take size of fetched table pointer
@ 2019-05-02 14:51 ` Igor Mammedov
0 siblings, 0 replies; 289+ messages in thread
From: Igor Mammedov @ 2019-05-02 14:51 UTC (permalink / raw)
To: qemu-devel
Cc: Laszlo Ersek, Michael S. Tsirkin, Gonglei,
Philippe Mathieu-Daudé,
Shannon Zhao, Wei Yang, Andrew Jones, Shameer Kolothum,
Ben Warren, xuwei5, xuwei5, linuxarm
Currently acpi_fetch_table() assumes 32 bit size of table pointer
in ACPI tables. However X_foo variants are 64 bit, prepare
acpi_fetch_table() to handle both by adding an argument
for addr_ptr pointed entry size. Follow up commits will use that
to read XSDT and X_foo entries in ACPI tables.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
tests/acpi-utils.h | 2 +-
tests/acpi-utils.c | 10 ++++++----
tests/bios-tables-test.c | 8 ++++----
tests/vmgenid-test.c | 4 ++--
4 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/tests/acpi-utils.h b/tests/acpi-utils.h
index 4cd5553..92285b7 100644
--- a/tests/acpi-utils.h
+++ b/tests/acpi-utils.h
@@ -49,7 +49,7 @@ uint32_t acpi_find_rsdp_address(QTestState *qts);
uint64_t acpi_get_xsdt_address(uint8_t *rsdp_table);
void acpi_fetch_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table);
void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
- const uint8_t *addr_ptr, const char *sig,
+ const uint8_t *addr_ptr, int addr_size, const char *sig,
bool verify_checksum);
#endif /* TEST_ACPI_UTILS_H */
diff --git a/tests/acpi-utils.c b/tests/acpi-utils.c
index 633d8f5..644c87b 100644
--- a/tests/acpi-utils.c
+++ b/tests/acpi-utils.c
@@ -91,13 +91,15 @@ void acpi_fetch_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table)
* actual one.
*/
void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
- const uint8_t *addr_ptr, const char *sig,
+ const uint8_t *addr_ptr, int addr_size, const char *sig,
bool verify_checksum)
{
- uint32_t addr, len;
+ uint32_t len;
+ uint64_t addr = 0;
- memcpy(&addr, addr_ptr , sizeof(addr));
- addr = le32_to_cpu(addr);
+ g_assert(addr_size == 4 || addr_size == 8);
+ memcpy(&addr, addr_ptr , addr_size);
+ addr = le64_to_cpu(addr);
qtest_memread(qts, addr + 4, &len, 4); /* Length of ACPI table */
*aml_len = le32_to_cpu(len);
*aml = g_malloc0(*aml_len);
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index 6a678bf..86b592c 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -114,14 +114,14 @@ static void test_acpi_rsdt_table(test_data *data)
/* read RSDT table */
acpi_fetch_table(data->qts, &rsdt.aml, &rsdt.aml_len,
- &data->rsdp_table[16 /* RsdtAddress */], "RSDT", true);
+ &data->rsdp_table[16 /* RsdtAddress */], 4, "RSDT", true);
/* Load all tables and add to test list directly RSDT referenced tables */
ACPI_FOREACH_RSDT_ENTRY(rsdt.aml, rsdt.aml_len, ent, 4 /* Entry size */) {
AcpiSdtTable ssdt_table = {};
acpi_fetch_table(data->qts, &ssdt_table.aml, &ssdt_table.aml_len, ent,
- NULL, true);
+ 4, NULL, true);
/* Add table to ASL test tables list */
g_array_append_val(data->tables, ssdt_table);
}
@@ -139,11 +139,11 @@ static void test_acpi_fadt_table(test_data *data)
/* Since DSDT/FACS isn't in RSDT, add them to ASL test list manually */
acpi_fetch_table(data->qts, &table.aml, &table.aml_len,
- fadt_aml + 36 /* FIRMWARE_CTRL */, "FACS", false);
+ fadt_aml + 36 /* FIRMWARE_CTRL */, 4, "FACS", false);
g_array_append_val(data->tables, table);
acpi_fetch_table(data->qts, &table.aml, &table.aml_len,
- fadt_aml + 40 /* DSDT */, "DSDT", true);
+ fadt_aml + 40 /* DSDT */, 4, "DSDT", true);
g_array_append_val(data->tables, table);
memset(fadt_aml + 36, 0, 4); /* sanitize FIRMWARE_CTRL ptr */
diff --git a/tests/vmgenid-test.c b/tests/vmgenid-test.c
index f400184..85d8e64 100644
--- a/tests/vmgenid-test.c
+++ b/tests/vmgenid-test.c
@@ -42,12 +42,12 @@ static uint32_t acpi_find_vgia(QTestState *qts)
acpi_fetch_rsdp_table(qts, rsdp_offset, rsdp_table);
acpi_fetch_table(qts, &rsdt, &rsdt_len, &rsdp_table[16 /* RsdtAddress */],
- "RSDT", true);
+ 4, "RSDT", true);
ACPI_FOREACH_RSDT_ENTRY(rsdt, rsdt_len, ent, 4 /* Entry size */) {
uint8_t *table_aml;
- acpi_fetch_table(qts, &table_aml, &table_length, ent, NULL, true);
+ acpi_fetch_table(qts, &table_aml, &table_length, ent, 4, NULL, true);
if (!memcmp(table_aml + 16 /* OEM Table ID */, "VMGENID", 7)) {
uint32_t vgia_val;
uint8_t *aml = &table_aml[36 /* AML byte-code start */];
--
2.7.4
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v4 02/15] tests: acpi: make acpi_fetch_table() take size of fetched table pointer
@ 2019-05-02 14:51 ` Igor Mammedov
0 siblings, 0 replies; 289+ messages in thread
From: Igor Mammedov @ 2019-05-02 14:51 UTC (permalink / raw)
To: qemu-devel
Cc: Andrew Jones, Ben Warren, Michael S. Tsirkin, Laszlo Ersek,
linuxarm, Shameer Kolothum, Shannon Zhao, Gonglei, Wei Yang,
xuwei5, xuwei5, Philippe Mathieu-Daudé
Currently acpi_fetch_table() assumes 32 bit size of table pointer
in ACPI tables. However X_foo variants are 64 bit, prepare
acpi_fetch_table() to handle both by adding an argument
for addr_ptr pointed entry size. Follow up commits will use that
to read XSDT and X_foo entries in ACPI tables.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
tests/acpi-utils.h | 2 +-
tests/acpi-utils.c | 10 ++++++----
tests/bios-tables-test.c | 8 ++++----
tests/vmgenid-test.c | 4 ++--
4 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/tests/acpi-utils.h b/tests/acpi-utils.h
index 4cd5553..92285b7 100644
--- a/tests/acpi-utils.h
+++ b/tests/acpi-utils.h
@@ -49,7 +49,7 @@ uint32_t acpi_find_rsdp_address(QTestState *qts);
uint64_t acpi_get_xsdt_address(uint8_t *rsdp_table);
void acpi_fetch_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table);
void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
- const uint8_t *addr_ptr, const char *sig,
+ const uint8_t *addr_ptr, int addr_size, const char *sig,
bool verify_checksum);
#endif /* TEST_ACPI_UTILS_H */
diff --git a/tests/acpi-utils.c b/tests/acpi-utils.c
index 633d8f5..644c87b 100644
--- a/tests/acpi-utils.c
+++ b/tests/acpi-utils.c
@@ -91,13 +91,15 @@ void acpi_fetch_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table)
* actual one.
*/
void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
- const uint8_t *addr_ptr, const char *sig,
+ const uint8_t *addr_ptr, int addr_size, const char *sig,
bool verify_checksum)
{
- uint32_t addr, len;
+ uint32_t len;
+ uint64_t addr = 0;
- memcpy(&addr, addr_ptr , sizeof(addr));
- addr = le32_to_cpu(addr);
+ g_assert(addr_size == 4 || addr_size == 8);
+ memcpy(&addr, addr_ptr , addr_size);
+ addr = le64_to_cpu(addr);
qtest_memread(qts, addr + 4, &len, 4); /* Length of ACPI table */
*aml_len = le32_to_cpu(len);
*aml = g_malloc0(*aml_len);
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index 6a678bf..86b592c 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -114,14 +114,14 @@ static void test_acpi_rsdt_table(test_data *data)
/* read RSDT table */
acpi_fetch_table(data->qts, &rsdt.aml, &rsdt.aml_len,
- &data->rsdp_table[16 /* RsdtAddress */], "RSDT", true);
+ &data->rsdp_table[16 /* RsdtAddress */], 4, "RSDT", true);
/* Load all tables and add to test list directly RSDT referenced tables */
ACPI_FOREACH_RSDT_ENTRY(rsdt.aml, rsdt.aml_len, ent, 4 /* Entry size */) {
AcpiSdtTable ssdt_table = {};
acpi_fetch_table(data->qts, &ssdt_table.aml, &ssdt_table.aml_len, ent,
- NULL, true);
+ 4, NULL, true);
/* Add table to ASL test tables list */
g_array_append_val(data->tables, ssdt_table);
}
@@ -139,11 +139,11 @@ static void test_acpi_fadt_table(test_data *data)
/* Since DSDT/FACS isn't in RSDT, add them to ASL test list manually */
acpi_fetch_table(data->qts, &table.aml, &table.aml_len,
- fadt_aml + 36 /* FIRMWARE_CTRL */, "FACS", false);
+ fadt_aml + 36 /* FIRMWARE_CTRL */, 4, "FACS", false);
g_array_append_val(data->tables, table);
acpi_fetch_table(data->qts, &table.aml, &table.aml_len,
- fadt_aml + 40 /* DSDT */, "DSDT", true);
+ fadt_aml + 40 /* DSDT */, 4, "DSDT", true);
g_array_append_val(data->tables, table);
memset(fadt_aml + 36, 0, 4); /* sanitize FIRMWARE_CTRL ptr */
diff --git a/tests/vmgenid-test.c b/tests/vmgenid-test.c
index f400184..85d8e64 100644
--- a/tests/vmgenid-test.c
+++ b/tests/vmgenid-test.c
@@ -42,12 +42,12 @@ static uint32_t acpi_find_vgia(QTestState *qts)
acpi_fetch_rsdp_table(qts, rsdp_offset, rsdp_table);
acpi_fetch_table(qts, &rsdt, &rsdt_len, &rsdp_table[16 /* RsdtAddress */],
- "RSDT", true);
+ 4, "RSDT", true);
ACPI_FOREACH_RSDT_ENTRY(rsdt, rsdt_len, ent, 4 /* Entry size */) {
uint8_t *table_aml;
- acpi_fetch_table(qts, &table_aml, &table_length, ent, NULL, true);
+ acpi_fetch_table(qts, &table_aml, &table_length, ent, 4, NULL, true);
if (!memcmp(table_aml + 16 /* OEM Table ID */, "VMGENID", 7)) {
uint32_t vgia_val;
uint8_t *aml = &table_aml[36 /* AML byte-code start */];
--
2.7.4
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v4 03/15] tests: acpi: make RSDT test routine handle XSDT
@ 2019-05-02 14:51 ` Igor Mammedov
0 siblings, 0 replies; 289+ messages in thread
From: Igor Mammedov @ 2019-05-02 14:51 UTC (permalink / raw)
To: qemu-devel
Cc: Laszlo Ersek, Michael S. Tsirkin, Gonglei,
Philippe Mathieu-Daudé,
Shannon Zhao, Wei Yang, Andrew Jones, Shameer Kolothum,
Ben Warren, xuwei5, xuwei5, linuxarm
If RSDP revision is more than 0 fetch table pointed by XSDT
and fallback to legacy RSDT table otherwise.
While at it drop unused acpi_get_xsdt_address().
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
PS:
it doesn't affect existing pc/q35 machines as they use RSDP.revision == 0
but it will be used by followup patch to enable testing arm/virt
board which uses provides XSDT table.
v4:
* move out acpi_parse_rsdp_table() hunk to
"tests: acpi: make pointer to RSDP 64bit"
where it belongs
---
tests/acpi-utils.h | 1 -
tests/acpi-utils.c | 12 ------------
tests/bios-tables-test.c | 20 ++++++++++++++------
3 files changed, 14 insertions(+), 19 deletions(-)
diff --git a/tests/acpi-utils.h b/tests/acpi-utils.h
index 92285b7..f55ccf9 100644
--- a/tests/acpi-utils.h
+++ b/tests/acpi-utils.h
@@ -46,7 +46,6 @@ typedef struct {
uint8_t acpi_calc_checksum(const uint8_t *data, int len);
uint32_t acpi_find_rsdp_address(QTestState *qts);
-uint64_t acpi_get_xsdt_address(uint8_t *rsdp_table);
void acpi_fetch_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table);
void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
const uint8_t *addr_ptr, int addr_size, const char *sig,
diff --git a/tests/acpi-utils.c b/tests/acpi-utils.c
index 644c87b..a0d49c4 100644
--- a/tests/acpi-utils.c
+++ b/tests/acpi-utils.c
@@ -51,18 +51,6 @@ uint32_t acpi_find_rsdp_address(QTestState *qts)
return off;
}
-uint64_t acpi_get_xsdt_address(uint8_t *rsdp_table)
-{
- uint64_t xsdt_physical_address;
- uint8_t revision = rsdp_table[15 /* Revision offset */];
-
- /* We must have revision 2 if we're looking for an XSDT pointer */
- g_assert(revision == 2);
-
- memcpy(&xsdt_physical_address, &rsdp_table[24 /* XsdtAddress offset */], 8);
- return le64_to_cpu(xsdt_physical_address);
-}
-
void acpi_fetch_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table)
{
uint8_t revision;
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index 86b592c..d6ab121 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -107,21 +107,29 @@ static void test_acpi_rsdp_table(test_data *data)
}
}
-static void test_acpi_rsdt_table(test_data *data)
+static void test_acpi_rxsdt_table(test_data *data)
{
+ const char *sig = "RSDT";
AcpiSdtTable rsdt = {};
+ int entry_size = 4;
+ int addr_off = 16 /* RsdtAddress */;
uint8_t *ent;
- /* read RSDT table */
+ if (data->rsdp_table[15 /* Revision offset */] != 0) {
+ addr_off = 24 /* XsdtAddress */;
+ entry_size = 8;
+ sig = "XSDT";
+ }
+ /* read [RX]SDT table */
acpi_fetch_table(data->qts, &rsdt.aml, &rsdt.aml_len,
- &data->rsdp_table[16 /* RsdtAddress */], 4, "RSDT", true);
+ &data->rsdp_table[addr_off], entry_size, sig, true);
/* Load all tables and add to test list directly RSDT referenced tables */
- ACPI_FOREACH_RSDT_ENTRY(rsdt.aml, rsdt.aml_len, ent, 4 /* Entry size */) {
+ ACPI_FOREACH_RSDT_ENTRY(rsdt.aml, rsdt.aml_len, ent, entry_size) {
AcpiSdtTable ssdt_table = {};
acpi_fetch_table(data->qts, &ssdt_table.aml, &ssdt_table.aml_len, ent,
- 4, NULL, true);
+ entry_size, NULL, true);
/* Add table to ASL test tables list */
g_array_append_val(data->tables, ssdt_table);
}
@@ -521,7 +529,7 @@ static void test_acpi_one(const char *params, test_data *data)
data->tables = g_array_new(false, true, sizeof(AcpiSdtTable));
test_acpi_rsdp_address(data);
test_acpi_rsdp_table(data);
- test_acpi_rsdt_table(data);
+ test_acpi_rxsdt_table(data);
test_acpi_fadt_table(data);
if (iasl) {
--
2.7.4
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v4 03/15] tests: acpi: make RSDT test routine handle XSDT
@ 2019-05-02 14:51 ` Igor Mammedov
0 siblings, 0 replies; 289+ messages in thread
From: Igor Mammedov @ 2019-05-02 14:51 UTC (permalink / raw)
To: qemu-devel
Cc: Andrew Jones, Ben Warren, Michael S. Tsirkin, Laszlo Ersek,
linuxarm, Shameer Kolothum, Shannon Zhao, Gonglei, Wei Yang,
xuwei5, xuwei5, Philippe Mathieu-Daudé
If RSDP revision is more than 0 fetch table pointed by XSDT
and fallback to legacy RSDT table otherwise.
While at it drop unused acpi_get_xsdt_address().
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
PS:
it doesn't affect existing pc/q35 machines as they use RSDP.revision == 0
but it will be used by followup patch to enable testing arm/virt
board which uses provides XSDT table.
v4:
* move out acpi_parse_rsdp_table() hunk to
"tests: acpi: make pointer to RSDP 64bit"
where it belongs
---
tests/acpi-utils.h | 1 -
tests/acpi-utils.c | 12 ------------
tests/bios-tables-test.c | 20 ++++++++++++++------
3 files changed, 14 insertions(+), 19 deletions(-)
diff --git a/tests/acpi-utils.h b/tests/acpi-utils.h
index 92285b7..f55ccf9 100644
--- a/tests/acpi-utils.h
+++ b/tests/acpi-utils.h
@@ -46,7 +46,6 @@ typedef struct {
uint8_t acpi_calc_checksum(const uint8_t *data, int len);
uint32_t acpi_find_rsdp_address(QTestState *qts);
-uint64_t acpi_get_xsdt_address(uint8_t *rsdp_table);
void acpi_fetch_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table);
void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
const uint8_t *addr_ptr, int addr_size, const char *sig,
diff --git a/tests/acpi-utils.c b/tests/acpi-utils.c
index 644c87b..a0d49c4 100644
--- a/tests/acpi-utils.c
+++ b/tests/acpi-utils.c
@@ -51,18 +51,6 @@ uint32_t acpi_find_rsdp_address(QTestState *qts)
return off;
}
-uint64_t acpi_get_xsdt_address(uint8_t *rsdp_table)
-{
- uint64_t xsdt_physical_address;
- uint8_t revision = rsdp_table[15 /* Revision offset */];
-
- /* We must have revision 2 if we're looking for an XSDT pointer */
- g_assert(revision == 2);
-
- memcpy(&xsdt_physical_address, &rsdp_table[24 /* XsdtAddress offset */], 8);
- return le64_to_cpu(xsdt_physical_address);
-}
-
void acpi_fetch_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table)
{
uint8_t revision;
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index 86b592c..d6ab121 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -107,21 +107,29 @@ static void test_acpi_rsdp_table(test_data *data)
}
}
-static void test_acpi_rsdt_table(test_data *data)
+static void test_acpi_rxsdt_table(test_data *data)
{
+ const char *sig = "RSDT";
AcpiSdtTable rsdt = {};
+ int entry_size = 4;
+ int addr_off = 16 /* RsdtAddress */;
uint8_t *ent;
- /* read RSDT table */
+ if (data->rsdp_table[15 /* Revision offset */] != 0) {
+ addr_off = 24 /* XsdtAddress */;
+ entry_size = 8;
+ sig = "XSDT";
+ }
+ /* read [RX]SDT table */
acpi_fetch_table(data->qts, &rsdt.aml, &rsdt.aml_len,
- &data->rsdp_table[16 /* RsdtAddress */], 4, "RSDT", true);
+ &data->rsdp_table[addr_off], entry_size, sig, true);
/* Load all tables and add to test list directly RSDT referenced tables */
- ACPI_FOREACH_RSDT_ENTRY(rsdt.aml, rsdt.aml_len, ent, 4 /* Entry size */) {
+ ACPI_FOREACH_RSDT_ENTRY(rsdt.aml, rsdt.aml_len, ent, entry_size) {
AcpiSdtTable ssdt_table = {};
acpi_fetch_table(data->qts, &ssdt_table.aml, &ssdt_table.aml_len, ent,
- 4, NULL, true);
+ entry_size, NULL, true);
/* Add table to ASL test tables list */
g_array_append_val(data->tables, ssdt_table);
}
@@ -521,7 +529,7 @@ static void test_acpi_one(const char *params, test_data *data)
data->tables = g_array_new(false, true, sizeof(AcpiSdtTable));
test_acpi_rsdp_address(data);
test_acpi_rsdp_table(data);
- test_acpi_rsdt_table(data);
+ test_acpi_rxsdt_table(data);
test_acpi_fadt_table(data);
if (iasl) {
--
2.7.4
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v4 04/15] tests: acpi: make pointer to RSDP 64bit
@ 2019-05-02 14:51 ` Igor Mammedov
0 siblings, 0 replies; 289+ messages in thread
From: Igor Mammedov @ 2019-05-02 14:51 UTC (permalink / raw)
To: qemu-devel
Cc: Laszlo Ersek, Michael S. Tsirkin, Gonglei,
Philippe Mathieu-Daudé,
Shannon Zhao, Wei Yang, Andrew Jones, Shameer Kolothum,
Ben Warren, xuwei5, xuwei5, linuxarm
In case of UEFI, RSDP doesn't have to be located in lowmem,
it could be placed at any address. Make sure that test won't
break if it is placed above the first 4Gb of address space.
PS:
While at it cleanup some local variables as we don't really
need them.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
v4:
- move acpi_fetch_rsdp_table(s/uint32_t addr/uint64_t addr/) to
this patch where it belongs from
"tests: acpi: make RSDT test routine handle XSDT"
(Wei Yang <richardw.yang@linux.intel.com>)
v2:
- s/In case of UEFI/In case of UEFI,/ (Laszlo Ersek <lersek@redhat.com>)
---
tests/acpi-utils.h | 2 +-
tests/acpi-utils.c | 2 +-
tests/bios-tables-test.c | 10 ++++------
3 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/tests/acpi-utils.h b/tests/acpi-utils.h
index f55ccf9..1da6c10 100644
--- a/tests/acpi-utils.h
+++ b/tests/acpi-utils.h
@@ -46,7 +46,7 @@ typedef struct {
uint8_t acpi_calc_checksum(const uint8_t *data, int len);
uint32_t acpi_find_rsdp_address(QTestState *qts);
-void acpi_fetch_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table);
+void acpi_fetch_rsdp_table(QTestState *qts, uint64_t addr, uint8_t *rsdp_table);
void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
const uint8_t *addr_ptr, int addr_size, const char *sig,
bool verify_checksum);
diff --git a/tests/acpi-utils.c b/tests/acpi-utils.c
index a0d49c4..c216b9e 100644
--- a/tests/acpi-utils.c
+++ b/tests/acpi-utils.c
@@ -51,7 +51,7 @@ uint32_t acpi_find_rsdp_address(QTestState *qts)
return off;
}
-void acpi_fetch_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table)
+void acpi_fetch_rsdp_table(QTestState *qts, uint64_t addr, uint8_t *rsdp_table)
{
uint8_t revision;
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index d6ab121..a164d27 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -26,7 +26,7 @@
typedef struct {
const char *machine;
const char *variant;
- uint32_t rsdp_addr;
+ uint64_t rsdp_addr;
uint8_t rsdp_table[36 /* ACPI 2.0+ RSDP size */];
GArray *tables;
uint32_t smbios_ep_addr;
@@ -86,13 +86,11 @@ static void test_acpi_rsdp_address(test_data *data)
static void test_acpi_rsdp_table(test_data *data)
{
- uint8_t *rsdp_table = data->rsdp_table, revision;
- uint32_t addr = data->rsdp_addr;
+ uint8_t *rsdp_table = data->rsdp_table;
- acpi_fetch_rsdp_table(data->qts, addr, rsdp_table);
- revision = rsdp_table[15 /* Revision offset */];
+ acpi_fetch_rsdp_table(data->qts, data->rsdp_addr, rsdp_table);
- switch (revision) {
+ switch (rsdp_table[15 /* Revision offset */]) {
case 0: /* ACPI 1.0 RSDP */
/* With rev 1, checksum is only for the first 20 bytes */
g_assert(!acpi_calc_checksum(rsdp_table, 20));
--
2.7.4
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v4 04/15] tests: acpi: make pointer to RSDP 64bit
@ 2019-05-02 14:51 ` Igor Mammedov
0 siblings, 0 replies; 289+ messages in thread
From: Igor Mammedov @ 2019-05-02 14:51 UTC (permalink / raw)
To: qemu-devel
Cc: Andrew Jones, Ben Warren, Michael S. Tsirkin, Laszlo Ersek,
linuxarm, Shameer Kolothum, Shannon Zhao, Gonglei, Wei Yang,
xuwei5, xuwei5, Philippe Mathieu-Daudé
In case of UEFI, RSDP doesn't have to be located in lowmem,
it could be placed at any address. Make sure that test won't
break if it is placed above the first 4Gb of address space.
PS:
While at it cleanup some local variables as we don't really
need them.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
v4:
- move acpi_fetch_rsdp_table(s/uint32_t addr/uint64_t addr/) to
this patch where it belongs from
"tests: acpi: make RSDT test routine handle XSDT"
(Wei Yang <richardw.yang@linux.intel.com>)
v2:
- s/In case of UEFI/In case of UEFI,/ (Laszlo Ersek <lersek@redhat.com>)
---
tests/acpi-utils.h | 2 +-
tests/acpi-utils.c | 2 +-
tests/bios-tables-test.c | 10 ++++------
3 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/tests/acpi-utils.h b/tests/acpi-utils.h
index f55ccf9..1da6c10 100644
--- a/tests/acpi-utils.h
+++ b/tests/acpi-utils.h
@@ -46,7 +46,7 @@ typedef struct {
uint8_t acpi_calc_checksum(const uint8_t *data, int len);
uint32_t acpi_find_rsdp_address(QTestState *qts);
-void acpi_fetch_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table);
+void acpi_fetch_rsdp_table(QTestState *qts, uint64_t addr, uint8_t *rsdp_table);
void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
const uint8_t *addr_ptr, int addr_size, const char *sig,
bool verify_checksum);
diff --git a/tests/acpi-utils.c b/tests/acpi-utils.c
index a0d49c4..c216b9e 100644
--- a/tests/acpi-utils.c
+++ b/tests/acpi-utils.c
@@ -51,7 +51,7 @@ uint32_t acpi_find_rsdp_address(QTestState *qts)
return off;
}
-void acpi_fetch_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table)
+void acpi_fetch_rsdp_table(QTestState *qts, uint64_t addr, uint8_t *rsdp_table)
{
uint8_t revision;
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index d6ab121..a164d27 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -26,7 +26,7 @@
typedef struct {
const char *machine;
const char *variant;
- uint32_t rsdp_addr;
+ uint64_t rsdp_addr;
uint8_t rsdp_table[36 /* ACPI 2.0+ RSDP size */];
GArray *tables;
uint32_t smbios_ep_addr;
@@ -86,13 +86,11 @@ static void test_acpi_rsdp_address(test_data *data)
static void test_acpi_rsdp_table(test_data *data)
{
- uint8_t *rsdp_table = data->rsdp_table, revision;
- uint32_t addr = data->rsdp_addr;
+ uint8_t *rsdp_table = data->rsdp_table;
- acpi_fetch_rsdp_table(data->qts, addr, rsdp_table);
- revision = rsdp_table[15 /* Revision offset */];
+ acpi_fetch_rsdp_table(data->qts, data->rsdp_addr, rsdp_table);
- switch (revision) {
+ switch (rsdp_table[15 /* Revision offset */]) {
case 0: /* ACPI 1.0 RSDP */
/* With rev 1, checksum is only for the first 20 bytes */
g_assert(!acpi_calc_checksum(rsdp_table, 20));
--
2.7.4
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v4 05/15] tests: acpi: fetch X_DSDT if pointer to DSDT is 0
@ 2019-05-02 14:51 ` Igor Mammedov
0 siblings, 0 replies; 289+ messages in thread
From: Igor Mammedov @ 2019-05-02 14:51 UTC (permalink / raw)
To: qemu-devel
Cc: Laszlo Ersek, Michael S. Tsirkin, Gonglei,
Philippe Mathieu-Daudé,
Shannon Zhao, Wei Yang, Andrew Jones, Shameer Kolothum,
Ben Warren, xuwei5, xuwei5, linuxarm
that way it would be possible to test a DSDT pointed by
64bit X_DSDT field in FADT.
PS:
it will allow to enable testing arm/virt board, which sets
only newer X_DSDT field.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
v4:
* dropping Reviewed-bys due to acpi_fetch_table() change
introduced by earlier patch:
"tests: acpi: make acpi_fetch_table() take size of fetched table pointer"
v2:
add 'val = le32_to_cpu(val)' even if it doesn't necessary
it works as reminder that value copied from table is in
little-endian format (Philippe Mathieu-Daudé <philmd@redhat.com>)
---
tests/bios-tables-test.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index a164d27..d165a1b 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -140,6 +140,9 @@ static void test_acpi_fadt_table(test_data *data)
AcpiSdtTable table = g_array_index(data->tables, typeof(table), 0);
uint8_t *fadt_aml = table.aml;
uint32_t fadt_len = table.aml_len;
+ uint32_t val;
+ int dsdt_offset = 40 /* DSDT */;
+ int dsdt_entry_size = 4;
g_assert(compare_signature(&table, "FACP"));
@@ -148,8 +151,14 @@ static void test_acpi_fadt_table(test_data *data)
fadt_aml + 36 /* FIRMWARE_CTRL */, 4, "FACS", false);
g_array_append_val(data->tables, table);
+ memcpy(&val, fadt_aml + dsdt_offset, 4);
+ val = le32_to_cpu(val);
+ if (!val) {
+ dsdt_offset = 140 /* X_DSDT */;
+ dsdt_entry_size = 8;
+ }
acpi_fetch_table(data->qts, &table.aml, &table.aml_len,
- fadt_aml + 40 /* DSDT */, 4, "DSDT", true);
+ fadt_aml + dsdt_offset, dsdt_entry_size, "DSDT", true);
g_array_append_val(data->tables, table);
memset(fadt_aml + 36, 0, 4); /* sanitize FIRMWARE_CTRL ptr */
--
2.7.4
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v4 05/15] tests: acpi: fetch X_DSDT if pointer to DSDT is 0
@ 2019-05-02 14:51 ` Igor Mammedov
0 siblings, 0 replies; 289+ messages in thread
From: Igor Mammedov @ 2019-05-02 14:51 UTC (permalink / raw)
To: qemu-devel
Cc: Andrew Jones, Ben Warren, Michael S. Tsirkin, Laszlo Ersek,
linuxarm, Shameer Kolothum, Shannon Zhao, Gonglei, Wei Yang,
xuwei5, xuwei5, Philippe Mathieu-Daudé
that way it would be possible to test a DSDT pointed by
64bit X_DSDT field in FADT.
PS:
it will allow to enable testing arm/virt board, which sets
only newer X_DSDT field.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
v4:
* dropping Reviewed-bys due to acpi_fetch_table() change
introduced by earlier patch:
"tests: acpi: make acpi_fetch_table() take size of fetched table pointer"
v2:
add 'val = le32_to_cpu(val)' even if it doesn't necessary
it works as reminder that value copied from table is in
little-endian format (Philippe Mathieu-Daudé <philmd@redhat.com>)
---
tests/bios-tables-test.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index a164d27..d165a1b 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -140,6 +140,9 @@ static void test_acpi_fadt_table(test_data *data)
AcpiSdtTable table = g_array_index(data->tables, typeof(table), 0);
uint8_t *fadt_aml = table.aml;
uint32_t fadt_len = table.aml_len;
+ uint32_t val;
+ int dsdt_offset = 40 /* DSDT */;
+ int dsdt_entry_size = 4;
g_assert(compare_signature(&table, "FACP"));
@@ -148,8 +151,14 @@ static void test_acpi_fadt_table(test_data *data)
fadt_aml + 36 /* FIRMWARE_CTRL */, 4, "FACS", false);
g_array_append_val(data->tables, table);
+ memcpy(&val, fadt_aml + dsdt_offset, 4);
+ val = le32_to_cpu(val);
+ if (!val) {
+ dsdt_offset = 140 /* X_DSDT */;
+ dsdt_entry_size = 8;
+ }
acpi_fetch_table(data->qts, &table.aml, &table.aml_len,
- fadt_aml + 40 /* DSDT */, 4, "DSDT", true);
+ fadt_aml + dsdt_offset, dsdt_entry_size, "DSDT", true);
g_array_append_val(data->tables, table);
memset(fadt_aml + 36, 0, 4); /* sanitize FIRMWARE_CTRL ptr */
--
2.7.4
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v4 06/15] tests: acpi: skip FACS table if board uses hw reduced ACPI profile
@ 2019-05-02 14:51 ` Igor Mammedov
0 siblings, 0 replies; 289+ messages in thread
From: Igor Mammedov @ 2019-05-02 14:51 UTC (permalink / raw)
To: qemu-devel
Cc: Laszlo Ersek, Michael S. Tsirkin, Gonglei,
Philippe Mathieu-Daudé,
Shannon Zhao, Wei Yang, Andrew Jones, Shameer Kolothum,
Ben Warren, xuwei5, xuwei5, linuxarm
If FADT has HW_REDUCED_ACPI flag set, do not attempt to fetch
FACS as it's not provided by the board.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Wei Yang <richardw.yang@linux.intel.com>
---
tests/bios-tables-test.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index d165a1b..e2fc341 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -147,9 +147,13 @@ static void test_acpi_fadt_table(test_data *data)
g_assert(compare_signature(&table, "FACP"));
/* Since DSDT/FACS isn't in RSDT, add them to ASL test list manually */
- acpi_fetch_table(data->qts, &table.aml, &table.aml_len,
- fadt_aml + 36 /* FIRMWARE_CTRL */, 4, "FACS", false);
- g_array_append_val(data->tables, table);
+ memcpy(&val, fadt_aml + 112 /* Flags */, 4);
+ val = le32_to_cpu(val);
+ if (!(val & 1UL << 20 /* HW_REDUCED_ACPI */)) {
+ acpi_fetch_table(data->qts, &table.aml, &table.aml_len,
+ fadt_aml + 36 /* FIRMWARE_CTRL */, 4, "FACS", false);
+ g_array_append_val(data->tables, table);
+ }
memcpy(&val, fadt_aml + dsdt_offset, 4);
val = le32_to_cpu(val);
--
2.7.4
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v4 06/15] tests: acpi: skip FACS table if board uses hw reduced ACPI profile
@ 2019-05-02 14:51 ` Igor Mammedov
0 siblings, 0 replies; 289+ messages in thread
From: Igor Mammedov @ 2019-05-02 14:51 UTC (permalink / raw)
To: qemu-devel
Cc: Andrew Jones, Ben Warren, Michael S. Tsirkin, Laszlo Ersek,
linuxarm, Shameer Kolothum, Shannon Zhao, Gonglei, Wei Yang,
xuwei5, xuwei5, Philippe Mathieu-Daudé
If FADT has HW_REDUCED_ACPI flag set, do not attempt to fetch
FACS as it's not provided by the board.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Wei Yang <richardw.yang@linux.intel.com>
---
tests/bios-tables-test.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index d165a1b..e2fc341 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -147,9 +147,13 @@ static void test_acpi_fadt_table(test_data *data)
g_assert(compare_signature(&table, "FACP"));
/* Since DSDT/FACS isn't in RSDT, add them to ASL test list manually */
- acpi_fetch_table(data->qts, &table.aml, &table.aml_len,
- fadt_aml + 36 /* FIRMWARE_CTRL */, 4, "FACS", false);
- g_array_append_val(data->tables, table);
+ memcpy(&val, fadt_aml + 112 /* Flags */, 4);
+ val = le32_to_cpu(val);
+ if (!(val & 1UL << 20 /* HW_REDUCED_ACPI */)) {
+ acpi_fetch_table(data->qts, &table.aml, &table.aml_len,
+ fadt_aml + 36 /* FIRMWARE_CTRL */, 4, "FACS", false);
+ g_array_append_val(data->tables, table);
+ }
memcpy(&val, fadt_aml + dsdt_offset, 4);
val = le32_to_cpu(val);
--
2.7.4
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v4 07/15] tests: acpi: move boot_sector_init() into x86 tests branch
@ 2019-05-02 14:51 ` Igor Mammedov
0 siblings, 0 replies; 289+ messages in thread
From: Igor Mammedov @ 2019-05-02 14:51 UTC (permalink / raw)
To: qemu-devel
Cc: Laszlo Ersek, Michael S. Tsirkin, Gonglei,
Philippe Mathieu-Daudé,
Shannon Zhao, Wei Yang, Andrew Jones, Shameer Kolothum,
Ben Warren, xuwei5, xuwei5, linuxarm
boot_sector_init() won't be used by arm/virt board, so move it from
global scope to x86 branch that uses it.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
v3:
- fix checkpatch errors triggered by moved old code (ident/space/braces)
---
tests/bios-tables-test.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index e2fc341..4d13a3c 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -788,13 +788,14 @@ int main(int argc, char *argv[])
const char *arch = qtest_get_arch();
int ret;
- ret = boot_sector_init(disk);
- if(ret)
- return ret;
-
g_test_init(&argc, &argv, NULL);
if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
+ ret = boot_sector_init(disk);
+ if (ret) {
+ return ret;
+ }
+
qtest_add_func("acpi/piix4", test_acpi_piix4_tcg);
qtest_add_func("acpi/piix4/bridge", test_acpi_piix4_tcg_bridge);
qtest_add_func("acpi/q35", test_acpi_q35_tcg);
--
2.7.4
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v4 07/15] tests: acpi: move boot_sector_init() into x86 tests branch
@ 2019-05-02 14:51 ` Igor Mammedov
0 siblings, 0 replies; 289+ messages in thread
From: Igor Mammedov @ 2019-05-02 14:51 UTC (permalink / raw)
To: qemu-devel
Cc: Andrew Jones, Ben Warren, Michael S. Tsirkin, Laszlo Ersek,
linuxarm, Shameer Kolothum, Shannon Zhao, Gonglei, Wei Yang,
xuwei5, xuwei5, Philippe Mathieu-Daudé
boot_sector_init() won't be used by arm/virt board, so move it from
global scope to x86 branch that uses it.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
v3:
- fix checkpatch errors triggered by moved old code (ident/space/braces)
---
tests/bios-tables-test.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index e2fc341..4d13a3c 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -788,13 +788,14 @@ int main(int argc, char *argv[])
const char *arch = qtest_get_arch();
int ret;
- ret = boot_sector_init(disk);
- if(ret)
- return ret;
-
g_test_init(&argc, &argv, NULL);
if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
+ ret = boot_sector_init(disk);
+ if (ret) {
+ return ret;
+ }
+
qtest_add_func("acpi/piix4", test_acpi_piix4_tcg);
qtest_add_func("acpi/piix4/bridge", test_acpi_piix4_tcg_bridge);
qtest_add_func("acpi/q35", test_acpi_q35_tcg);
--
2.7.4
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v4 08/15] tests: acpi: add acpi_find_rsdp_address_uefi() helper
@ 2019-05-02 14:51 ` Igor Mammedov
0 siblings, 0 replies; 289+ messages in thread
From: Igor Mammedov @ 2019-05-02 14:51 UTC (permalink / raw)
To: qemu-devel
Cc: Laszlo Ersek, Michael S. Tsirkin, Gonglei,
Philippe Mathieu-Daudé,
Shannon Zhao, Wei Yang, Andrew Jones, Shameer Kolothum,
Ben Warren, xuwei5, xuwei5, linuxarm
introduce UEFI specific counterpart to acpi_find_rsdp_address()
that will help to find RSDP address when [OA]VMF is used as
firmware. It requires guest firmware or other guest app to place
1Mb aligned UefiTestSupport structure (defined in this patch)
in RAM with UefiTestSupport::signature_guid set to
AB87A6B1-2034-BDA0-71BD-375007757785
For test app details see commit
(09a274d82f tests: introduce "uefi-test-tools" with the BiosTablesTest UEFI app)
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Wei Yang <richardw.yang@linux.intel.com>
---
v4:
* update commit message to point to commit which introduced
signature_guid value.
v3:
* fix checkpatch error (separate opening brace from values in AcpiTestSupportGuid initializer)
v2:
* Laszlo Ersek <lersek@redhat.com>
- s/uefi_find_rsdp_addr/acpi_find_rsdp_address_uefi/
- use GUID_SIZE instead of opencodding size
- make AcpiTestSupportGuid const
- s/TCI/TCG/
---
tests/acpi-utils.h | 2 ++
tests/acpi-utils.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 46 insertions(+)
diff --git a/tests/acpi-utils.h b/tests/acpi-utils.h
index 1da6c10..52c529e 100644
--- a/tests/acpi-utils.h
+++ b/tests/acpi-utils.h
@@ -46,6 +46,8 @@ typedef struct {
uint8_t acpi_calc_checksum(const uint8_t *data, int len);
uint32_t acpi_find_rsdp_address(QTestState *qts);
+uint64_t acpi_find_rsdp_address_uefi(QTestState *qts, uint64_t start,
+ uint64_t size);
void acpi_fetch_rsdp_table(QTestState *qts, uint64_t addr, uint8_t *rsdp_table);
void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
const uint8_t *addr_ptr, int addr_size, const char *sig,
diff --git a/tests/acpi-utils.c b/tests/acpi-utils.c
index c216b9e..d2a202e 100644
--- a/tests/acpi-utils.c
+++ b/tests/acpi-utils.c
@@ -101,3 +101,47 @@ void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
g_assert(!acpi_calc_checksum(*aml, *aml_len));
}
}
+
+#define GUID_SIZE 16
+static const uint8_t AcpiTestSupportGuid[GUID_SIZE] = {
+ 0xb1, 0xa6, 0x87, 0xab,
+ 0x34, 0x20,
+ 0xa0, 0xbd,
+ 0x71, 0xbd, 0x37, 0x50, 0x07, 0x75, 0x77, 0x85 };
+
+typedef struct {
+ uint8_t signature_guid[GUID_SIZE];
+ uint64_t rsdp10;
+ uint64_t rsdp20;
+} __attribute__((packed)) UefiTestSupport;
+
+/* Wait at most 600 seconds (test is slow with TCG and --enable-debug) */
+#define TEST_DELAY (1 * G_USEC_PER_SEC / 10)
+#define TEST_CYCLES MAX((600 * G_USEC_PER_SEC / TEST_DELAY), 1)
+#define MB 0x100000ULL
+uint64_t acpi_find_rsdp_address_uefi(QTestState *qts, uint64_t start,
+ uint64_t size)
+{
+ int i, j;
+ uint8_t data[GUID_SIZE];
+
+ for (i = 0; i < TEST_CYCLES; ++i) {
+ for (j = 0; j < size / MB; j++) {
+ /* look for GUID at every 1Mb block */
+ uint64_t addr = start + j * MB;
+
+ qtest_memread(qts, addr, data, sizeof(data));
+ if (!memcmp(AcpiTestSupportGuid, data, sizeof(data))) {
+ UefiTestSupport ret;
+
+ qtest_memread(qts, addr, &ret, sizeof(ret));
+ ret.rsdp10 = le64_to_cpu(ret.rsdp10);
+ ret.rsdp20 = le64_to_cpu(ret.rsdp20);
+ return ret.rsdp20 ? ret.rsdp20 : ret.rsdp10;
+ }
+ }
+ g_usleep(TEST_DELAY);
+ }
+ g_assert_not_reached();
+ return 0;
+}
--
2.7.4
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v4 08/15] tests: acpi: add acpi_find_rsdp_address_uefi() helper
@ 2019-05-02 14:51 ` Igor Mammedov
0 siblings, 0 replies; 289+ messages in thread
From: Igor Mammedov @ 2019-05-02 14:51 UTC (permalink / raw)
To: qemu-devel
Cc: Andrew Jones, Ben Warren, Michael S. Tsirkin, Laszlo Ersek,
linuxarm, Shameer Kolothum, Shannon Zhao, Gonglei, Wei Yang,
xuwei5, xuwei5, Philippe Mathieu-Daudé
introduce UEFI specific counterpart to acpi_find_rsdp_address()
that will help to find RSDP address when [OA]VMF is used as
firmware. It requires guest firmware or other guest app to place
1Mb aligned UefiTestSupport structure (defined in this patch)
in RAM with UefiTestSupport::signature_guid set to
AB87A6B1-2034-BDA0-71BD-375007757785
For test app details see commit
(09a274d82f tests: introduce "uefi-test-tools" with the BiosTablesTest UEFI app)
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Wei Yang <richardw.yang@linux.intel.com>
---
v4:
* update commit message to point to commit which introduced
signature_guid value.
v3:
* fix checkpatch error (separate opening brace from values in AcpiTestSupportGuid initializer)
v2:
* Laszlo Ersek <lersek@redhat.com>
- s/uefi_find_rsdp_addr/acpi_find_rsdp_address_uefi/
- use GUID_SIZE instead of opencodding size
- make AcpiTestSupportGuid const
- s/TCI/TCG/
---
tests/acpi-utils.h | 2 ++
tests/acpi-utils.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 46 insertions(+)
diff --git a/tests/acpi-utils.h b/tests/acpi-utils.h
index 1da6c10..52c529e 100644
--- a/tests/acpi-utils.h
+++ b/tests/acpi-utils.h
@@ -46,6 +46,8 @@ typedef struct {
uint8_t acpi_calc_checksum(const uint8_t *data, int len);
uint32_t acpi_find_rsdp_address(QTestState *qts);
+uint64_t acpi_find_rsdp_address_uefi(QTestState *qts, uint64_t start,
+ uint64_t size);
void acpi_fetch_rsdp_table(QTestState *qts, uint64_t addr, uint8_t *rsdp_table);
void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
const uint8_t *addr_ptr, int addr_size, const char *sig,
diff --git a/tests/acpi-utils.c b/tests/acpi-utils.c
index c216b9e..d2a202e 100644
--- a/tests/acpi-utils.c
+++ b/tests/acpi-utils.c
@@ -101,3 +101,47 @@ void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
g_assert(!acpi_calc_checksum(*aml, *aml_len));
}
}
+
+#define GUID_SIZE 16
+static const uint8_t AcpiTestSupportGuid[GUID_SIZE] = {
+ 0xb1, 0xa6, 0x87, 0xab,
+ 0x34, 0x20,
+ 0xa0, 0xbd,
+ 0x71, 0xbd, 0x37, 0x50, 0x07, 0x75, 0x77, 0x85 };
+
+typedef struct {
+ uint8_t signature_guid[GUID_SIZE];
+ uint64_t rsdp10;
+ uint64_t rsdp20;
+} __attribute__((packed)) UefiTestSupport;
+
+/* Wait at most 600 seconds (test is slow with TCG and --enable-debug) */
+#define TEST_DELAY (1 * G_USEC_PER_SEC / 10)
+#define TEST_CYCLES MAX((600 * G_USEC_PER_SEC / TEST_DELAY), 1)
+#define MB 0x100000ULL
+uint64_t acpi_find_rsdp_address_uefi(QTestState *qts, uint64_t start,
+ uint64_t size)
+{
+ int i, j;
+ uint8_t data[GUID_SIZE];
+
+ for (i = 0; i < TEST_CYCLES; ++i) {
+ for (j = 0; j < size / MB; j++) {
+ /* look for GUID at every 1Mb block */
+ uint64_t addr = start + j * MB;
+
+ qtest_memread(qts, addr, data, sizeof(data));
+ if (!memcmp(AcpiTestSupportGuid, data, sizeof(data))) {
+ UefiTestSupport ret;
+
+ qtest_memread(qts, addr, &ret, sizeof(ret));
+ ret.rsdp10 = le64_to_cpu(ret.rsdp10);
+ ret.rsdp20 = le64_to_cpu(ret.rsdp20);
+ return ret.rsdp20 ? ret.rsdp20 : ret.rsdp10;
+ }
+ }
+ g_usleep(TEST_DELAY);
+ }
+ g_assert_not_reached();
+ return 0;
+}
--
2.7.4
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v4 09/15] tests: acpi: add a way to start tests with UEFI firmware
@ 2019-05-02 14:51 ` Igor Mammedov
0 siblings, 0 replies; 289+ messages in thread
From: Igor Mammedov @ 2019-05-02 14:51 UTC (permalink / raw)
To: qemu-devel
Cc: Laszlo Ersek, Michael S. Tsirkin, Gonglei,
Philippe Mathieu-Daudé,
Shannon Zhao, Wei Yang, Andrew Jones, Shameer Kolothum,
Ben Warren, xuwei5, xuwei5, linuxarm
For testcase to use UEFI firmware, one needs to provide and specify
firmware and varstore blob names in test_data { uefi_fl1, uefi_fl2 }
fields respectively and RAM start address plus size where to look for
test structure signature. Additionally testcase should specify
bootable cdrom image from uefi-boot-images with EFI test utility.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
---
v4:
* fixup commit message (typo/spelling) (Wei Yang <richardw.yang@linux.intel.com>)
* get rid of test_acpi_rsdp_address()
v3:
* drop data_dir prefix and firmware will come from pc-bios directly
* add cdrom option so test could use it for providing boot cdrom image
* add TODO comment convert '-drive if=pflash' to new syntax (Laszlo)
v2:
* move RAM start address and size to test_data, as it could differ
between boards (and even versions)
dfd
---
tests/bios-tables-test.c | 52 ++++++++++++++++++++++++++++++++----------------
1 file changed, 35 insertions(+), 17 deletions(-)
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index 4d13a3c..84e1ce2 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -26,6 +26,11 @@
typedef struct {
const char *machine;
const char *variant;
+ const char *uefi_fl1;
+ const char *uefi_fl2;
+ const char *cd;
+ const uint64_t ram_start;
+ const uint64_t scan_len;
uint64_t rsdp_addr;
uint8_t rsdp_table[36 /* ACPI 2.0+ RSDP size */];
GArray *tables;
@@ -77,13 +82,6 @@ static void free_test_data(test_data *data)
g_array_free(data->tables, true);
}
-static void test_acpi_rsdp_address(test_data *data)
-{
- uint32_t off = acpi_find_rsdp_address(data->qts);
- g_assert_cmphex(off, <, 0x100000);
- data->rsdp_addr = off;
-}
-
static void test_acpi_rsdp_table(test_data *data)
{
uint8_t *rsdp_table = data->rsdp_table;
@@ -524,21 +522,41 @@ static void test_smbios_structs(test_data *data)
static void test_acpi_one(const char *params, test_data *data)
{
char *args;
-
- /* Disable kernel irqchip to be able to override apic irq0. */
- args = g_strdup_printf("-machine %s,accel=%s,kernel-irqchip=off "
- "-net none -display none %s "
- "-drive id=hd0,if=none,file=%s,format=raw "
- "-device ide-hd,drive=hd0 ",
- data->machine, "kvm:tcg",
- params ? params : "", disk);
+ bool use_uefi = data->uefi_fl1 && data->uefi_fl2;
+
+ if (use_uefi) {
+ /*
+ * TODO: convert '-drive if=pflash' to new syntax (see e33763be7cd3)
+ * when arm/virt boad starts to support it.
+ */
+ args = g_strdup_printf("-machine %s,accel=%s -nodefaults -nographic "
+ "-drive if=pflash,format=raw,file=%s,readonly "
+ "-drive if=pflash,format=raw,file=%s,snapshot=on -cdrom %s %s",
+ data->machine, "kvm:tcg", data->uefi_fl1, data->uefi_fl2,
+ data->cd, params ? params : "");
+
+ } else {
+ /* Disable kernel irqchip to be able to override apic irq0. */
+ args = g_strdup_printf("-machine %s,accel=%s,kernel-irqchip=off "
+ "-net none -display none %s "
+ "-drive id=hd0,if=none,file=%s,format=raw "
+ "-device ide-hd,drive=hd0 ",
+ data->machine, "kvm:tcg", params ? params : "", disk);
+ }
data->qts = qtest_init(args);
- boot_sector_test(data->qts);
+ if (use_uefi) {
+ g_assert(data->scan_len);
+ data->rsdp_addr = acpi_find_rsdp_address_uefi(data->qts,
+ data->ram_start, data->scan_len);
+ } else {
+ boot_sector_test(data->qts);
+ data->rsdp_addr = acpi_find_rsdp_address(data->qts);
+ g_assert_cmphex(data->rsdp_addr, <, 0x100000);
+ }
data->tables = g_array_new(false, true, sizeof(AcpiSdtTable));
- test_acpi_rsdp_address(data);
test_acpi_rsdp_table(data);
test_acpi_rxsdt_table(data);
test_acpi_fadt_table(data);
--
2.7.4
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v4 09/15] tests: acpi: add a way to start tests with UEFI firmware
@ 2019-05-02 14:51 ` Igor Mammedov
0 siblings, 0 replies; 289+ messages in thread
From: Igor Mammedov @ 2019-05-02 14:51 UTC (permalink / raw)
To: qemu-devel
Cc: Andrew Jones, Ben Warren, Michael S. Tsirkin, Laszlo Ersek,
linuxarm, Shameer Kolothum, Shannon Zhao, Gonglei, Wei Yang,
xuwei5, xuwei5, Philippe Mathieu-Daudé
For testcase to use UEFI firmware, one needs to provide and specify
firmware and varstore blob names in test_data { uefi_fl1, uefi_fl2 }
fields respectively and RAM start address plus size where to look for
test structure signature. Additionally testcase should specify
bootable cdrom image from uefi-boot-images with EFI test utility.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
---
v4:
* fixup commit message (typo/spelling) (Wei Yang <richardw.yang@linux.intel.com>)
* get rid of test_acpi_rsdp_address()
v3:
* drop data_dir prefix and firmware will come from pc-bios directly
* add cdrom option so test could use it for providing boot cdrom image
* add TODO comment convert '-drive if=pflash' to new syntax (Laszlo)
v2:
* move RAM start address and size to test_data, as it could differ
between boards (and even versions)
dfd
---
tests/bios-tables-test.c | 52 ++++++++++++++++++++++++++++++++----------------
1 file changed, 35 insertions(+), 17 deletions(-)
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index 4d13a3c..84e1ce2 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -26,6 +26,11 @@
typedef struct {
const char *machine;
const char *variant;
+ const char *uefi_fl1;
+ const char *uefi_fl2;
+ const char *cd;
+ const uint64_t ram_start;
+ const uint64_t scan_len;
uint64_t rsdp_addr;
uint8_t rsdp_table[36 /* ACPI 2.0+ RSDP size */];
GArray *tables;
@@ -77,13 +82,6 @@ static void free_test_data(test_data *data)
g_array_free(data->tables, true);
}
-static void test_acpi_rsdp_address(test_data *data)
-{
- uint32_t off = acpi_find_rsdp_address(data->qts);
- g_assert_cmphex(off, <, 0x100000);
- data->rsdp_addr = off;
-}
-
static void test_acpi_rsdp_table(test_data *data)
{
uint8_t *rsdp_table = data->rsdp_table;
@@ -524,21 +522,41 @@ static void test_smbios_structs(test_data *data)
static void test_acpi_one(const char *params, test_data *data)
{
char *args;
-
- /* Disable kernel irqchip to be able to override apic irq0. */
- args = g_strdup_printf("-machine %s,accel=%s,kernel-irqchip=off "
- "-net none -display none %s "
- "-drive id=hd0,if=none,file=%s,format=raw "
- "-device ide-hd,drive=hd0 ",
- data->machine, "kvm:tcg",
- params ? params : "", disk);
+ bool use_uefi = data->uefi_fl1 && data->uefi_fl2;
+
+ if (use_uefi) {
+ /*
+ * TODO: convert '-drive if=pflash' to new syntax (see e33763be7cd3)
+ * when arm/virt boad starts to support it.
+ */
+ args = g_strdup_printf("-machine %s,accel=%s -nodefaults -nographic "
+ "-drive if=pflash,format=raw,file=%s,readonly "
+ "-drive if=pflash,format=raw,file=%s,snapshot=on -cdrom %s %s",
+ data->machine, "kvm:tcg", data->uefi_fl1, data->uefi_fl2,
+ data->cd, params ? params : "");
+
+ } else {
+ /* Disable kernel irqchip to be able to override apic irq0. */
+ args = g_strdup_printf("-machine %s,accel=%s,kernel-irqchip=off "
+ "-net none -display none %s "
+ "-drive id=hd0,if=none,file=%s,format=raw "
+ "-device ide-hd,drive=hd0 ",
+ data->machine, "kvm:tcg", params ? params : "", disk);
+ }
data->qts = qtest_init(args);
- boot_sector_test(data->qts);
+ if (use_uefi) {
+ g_assert(data->scan_len);
+ data->rsdp_addr = acpi_find_rsdp_address_uefi(data->qts,
+ data->ram_start, data->scan_len);
+ } else {
+ boot_sector_test(data->qts);
+ data->rsdp_addr = acpi_find_rsdp_address(data->qts);
+ g_assert_cmphex(data->rsdp_addr, <, 0x100000);
+ }
data->tables = g_array_new(false, true, sizeof(AcpiSdtTable));
- test_acpi_rsdp_address(data);
test_acpi_rsdp_table(data);
test_acpi_rxsdt_table(data);
test_acpi_fadt_table(data);
--
2.7.4
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v4 10/15] tests: acpi: ignore SMBIOS tests when UEFI firmware is used
@ 2019-05-02 14:51 ` Igor Mammedov
0 siblings, 0 replies; 289+ messages in thread
From: Igor Mammedov @ 2019-05-02 14:51 UTC (permalink / raw)
To: qemu-devel
Cc: Laszlo Ersek, Michael S. Tsirkin, Gonglei,
Philippe Mathieu-Daudé,
Shannon Zhao, Wei Yang, Andrew Jones, Shameer Kolothum,
Ben Warren, xuwei5, xuwei5, linuxarm
once FW provides a pointer to SMBIOS entry point like it does for
RSDP it should be possible to enable this one the same way.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
---
v3:
- add ref to a uefi-test-tools feature req into comment (Laszlo)
---
tests/bios-tables-test.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index 84e1ce2..8302ffc 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -569,8 +569,15 @@ static void test_acpi_one(const char *params, test_data *data)
}
}
- test_smbios_entry_point(data);
- test_smbios_structs(data);
+ /*
+ * TODO: make SMBIOS tests work with UEFI firmware,
+ * Bug on uefi-test-tools to provide entry point:
+ * https://bugs.launchpad.net/qemu/+bug/1821884
+ */
+ if (!use_uefi) {
+ test_smbios_entry_point(data);
+ test_smbios_structs(data);
+ }
assert(!global_qtest);
qtest_quit(data->qts);
--
2.7.4
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v4 10/15] tests: acpi: ignore SMBIOS tests when UEFI firmware is used
@ 2019-05-02 14:51 ` Igor Mammedov
0 siblings, 0 replies; 289+ messages in thread
From: Igor Mammedov @ 2019-05-02 14:51 UTC (permalink / raw)
To: qemu-devel
Cc: Andrew Jones, Ben Warren, Michael S. Tsirkin, Laszlo Ersek,
linuxarm, Shameer Kolothum, Shannon Zhao, Gonglei, Wei Yang,
xuwei5, xuwei5, Philippe Mathieu-Daudé
once FW provides a pointer to SMBIOS entry point like it does for
RSDP it should be possible to enable this one the same way.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
---
v3:
- add ref to a uefi-test-tools feature req into comment (Laszlo)
---
tests/bios-tables-test.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index 84e1ce2..8302ffc 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -569,8 +569,15 @@ static void test_acpi_one(const char *params, test_data *data)
}
}
- test_smbios_entry_point(data);
- test_smbios_structs(data);
+ /*
+ * TODO: make SMBIOS tests work with UEFI firmware,
+ * Bug on uefi-test-tools to provide entry point:
+ * https://bugs.launchpad.net/qemu/+bug/1821884
+ */
+ if (!use_uefi) {
+ test_smbios_entry_point(data);
+ test_smbios_structs(data);
+ }
assert(!global_qtest);
qtest_quit(data->qts);
--
2.7.4
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v4 11/15] tests: acpi: allow to override default accelerator
@ 2019-05-02 14:51 ` Igor Mammedov
0 siblings, 0 replies; 289+ messages in thread
From: Igor Mammedov @ 2019-05-02 14:51 UTC (permalink / raw)
To: qemu-devel
Cc: Laszlo Ersek, Michael S. Tsirkin, Gonglei,
Philippe Mathieu-Daudé,
Shannon Zhao, Wei Yang, Andrew Jones, Shameer Kolothum,
Ben Warren, xuwei5, xuwei5, linuxarm
By default test cases were run with 'kvm:tcg' accelerators to speed up
tests execution. While it works for x86, were change of accelerator
doesn't affect ACPI tables, the approach doesn't works for ARM usecase
though.
In arm/virt case, KVM mode requires using 'host' cpu model, which
isn't available in TCG mode. That could be worked around with 'max'
cpu model, which works both for KVM and TCG. However in KVM mode it
is necessary to specify matching GIC version, which also could use
'max' value to automatically pick GIC version suitable for host's CPU.
Depending on host cpu type, different GIC versions would be used,
which in turn leads to different ACPI tables (APIC) generated.
As result while comparing with reference blobs, test would fail if
host's GIC version won't match the version on the host where
reference blobs where generated.
Let's keep testing simple for now and allow ARM tests run in TCG only
mode. To do so introduce 'accel' parameter in test configuration, so
test case could override default "kvm:tcg" with accelerator of choice.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
tests/bios-tables-test.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index 8302ffc..39c1e24 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -24,6 +24,7 @@
#define ACPI_REBUILD_EXPECTED_AML "TEST_ACPI_REBUILD_AML"
typedef struct {
+ const char *accel;
const char *machine;
const char *variant;
const char *uefi_fl1;
@@ -532,8 +533,8 @@ static void test_acpi_one(const char *params, test_data *data)
args = g_strdup_printf("-machine %s,accel=%s -nodefaults -nographic "
"-drive if=pflash,format=raw,file=%s,readonly "
"-drive if=pflash,format=raw,file=%s,snapshot=on -cdrom %s %s",
- data->machine, "kvm:tcg", data->uefi_fl1, data->uefi_fl2,
- data->cd, params ? params : "");
+ data->machine, data->accel ? data->accel : "kvm:tcg",
+ data->uefi_fl1, data->uefi_fl2, data->cd, params ? params : "");
} else {
/* Disable kernel irqchip to be able to override apic irq0. */
@@ -541,7 +542,8 @@ static void test_acpi_one(const char *params, test_data *data)
"-net none -display none %s "
"-drive id=hd0,if=none,file=%s,format=raw "
"-device ide-hd,drive=hd0 ",
- data->machine, "kvm:tcg", params ? params : "", disk);
+ data->machine, data->accel ? data->accel : "kvm:tcg",
+ params ? params : "", disk);
}
data->qts = qtest_init(args);
--
2.7.4
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v4 11/15] tests: acpi: allow to override default accelerator
@ 2019-05-02 14:51 ` Igor Mammedov
0 siblings, 0 replies; 289+ messages in thread
From: Igor Mammedov @ 2019-05-02 14:51 UTC (permalink / raw)
To: qemu-devel
Cc: Andrew Jones, Ben Warren, Michael S. Tsirkin, Laszlo Ersek,
linuxarm, Shameer Kolothum, Shannon Zhao, Gonglei, Wei Yang,
xuwei5, xuwei5, Philippe Mathieu-Daudé
By default test cases were run with 'kvm:tcg' accelerators to speed up
tests execution. While it works for x86, were change of accelerator
doesn't affect ACPI tables, the approach doesn't works for ARM usecase
though.
In arm/virt case, KVM mode requires using 'host' cpu model, which
isn't available in TCG mode. That could be worked around with 'max'
cpu model, which works both for KVM and TCG. However in KVM mode it
is necessary to specify matching GIC version, which also could use
'max' value to automatically pick GIC version suitable for host's CPU.
Depending on host cpu type, different GIC versions would be used,
which in turn leads to different ACPI tables (APIC) generated.
As result while comparing with reference blobs, test would fail if
host's GIC version won't match the version on the host where
reference blobs where generated.
Let's keep testing simple for now and allow ARM tests run in TCG only
mode. To do so introduce 'accel' parameter in test configuration, so
test case could override default "kvm:tcg" with accelerator of choice.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
tests/bios-tables-test.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index 8302ffc..39c1e24 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -24,6 +24,7 @@
#define ACPI_REBUILD_EXPECTED_AML "TEST_ACPI_REBUILD_AML"
typedef struct {
+ const char *accel;
const char *machine;
const char *variant;
const char *uefi_fl1;
@@ -532,8 +533,8 @@ static void test_acpi_one(const char *params, test_data *data)
args = g_strdup_printf("-machine %s,accel=%s -nodefaults -nographic "
"-drive if=pflash,format=raw,file=%s,readonly "
"-drive if=pflash,format=raw,file=%s,snapshot=on -cdrom %s %s",
- data->machine, "kvm:tcg", data->uefi_fl1, data->uefi_fl2,
- data->cd, params ? params : "");
+ data->machine, data->accel ? data->accel : "kvm:tcg",
+ data->uefi_fl1, data->uefi_fl2, data->cd, params ? params : "");
} else {
/* Disable kernel irqchip to be able to override apic irq0. */
@@ -541,7 +542,8 @@ static void test_acpi_one(const char *params, test_data *data)
"-net none -display none %s "
"-drive id=hd0,if=none,file=%s,format=raw "
"-device ide-hd,drive=hd0 ",
- data->machine, "kvm:tcg", params ? params : "", disk);
+ data->machine, data->accel ? data->accel : "kvm:tcg",
+ params ? params : "", disk);
}
data->qts = qtest_init(args);
--
2.7.4
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v4 12/15] tests: add expected ACPI tables for arm/virt board
@ 2019-05-02 14:52 ` Igor Mammedov
0 siblings, 0 replies; 289+ messages in thread
From: Igor Mammedov @ 2019-05-02 14:52 UTC (permalink / raw)
To: qemu-devel
Cc: Laszlo Ersek, Michael S. Tsirkin, Gonglei,
Philippe Mathieu-Daudé,
Shannon Zhao, Wei Yang, Andrew Jones, Shameer Kolothum,
Ben Warren, xuwei5, xuwei5, linuxarm
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
this patch is ahead fo "tests: acpi: add simple arm/virt testcase"
to keep 'make check' working during bisection and not to pollute
code with binary blobs which are not reviewable.
---
tests/data/acpi/virt/APIC | Bin 0 -> 168 bytes
tests/data/acpi/virt/DSDT | Bin 0 -> 18476 bytes
tests/data/acpi/virt/FACP | Bin 0 -> 268 bytes
tests/data/acpi/virt/GTDT | Bin 0 -> 96 bytes
tests/data/acpi/virt/MCFG | Bin 0 -> 60 bytes
tests/data/acpi/virt/SPCR | Bin 0 -> 80 bytes
6 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 tests/data/acpi/virt/APIC
create mode 100644 tests/data/acpi/virt/DSDT
create mode 100644 tests/data/acpi/virt/FACP
create mode 100644 tests/data/acpi/virt/GTDT
create mode 100644 tests/data/acpi/virt/MCFG
create mode 100644 tests/data/acpi/virt/SPCR
diff --git a/tests/data/acpi/virt/APIC b/tests/data/acpi/virt/APIC
new file mode 100644
index 0000000000000000000000000000000000000000..797dfde2841c51b7e72065602e99ce1714347f0d
GIT binary patch
literal 168
zcmZ<^@N{0mz`($~*~#D8BUr&HBEZ=ZD8>jB1F=Cg4Dd+6SPUF6788)c?E~X6Fu>G{
hBZPn~MyPrgD9sGlkD?67;f3451Xcqw&w(L;0RYV=2>}2A
literal 0
HcmV?d00001
diff --git a/tests/data/acpi/virt/DSDT b/tests/data/acpi/virt/DSDT
new file mode 100644
index 0000000000000000000000000000000000000000..20e85c7f89f645c69935c615c07084e221419960
GIT binary patch
literal 18476
zcmc)ScU)EVAII^7km3at6myGa+R|dUS|(gjDG>rqi;BuJN5jfYEla7?tSq%Xt!(eT
zr!AYd_uhN&!S8+U(D&=t`StIw9$oH>d%mB0pK#D~&LeJRL*=*uql2K;?26j>=!V`E
z6YJuY`dmg31mXSgWB#J~S-UqiR5Ud<cZ(Mn7iTw(uCB~0kJnWzh6dS9<Etx!#^$Q5
zcx_Gk!TOrf#l<BhsRy&0;`I#$-C~^=whh9GZG-$EIH7frk<mvrM_ZLw*5`%~G&Yxv
z9Mh1RGG=Ujt)>jdl!92h)D&$WWX;hthf7M5uZl}Dl25#TNmhEvu#pquBa=&ZuBsU?
zNU5HsVO)7EM{DBc|GlzR+b&ufK3RFzF7@fJLGsy(?FFt|xgHw}TBWeXJ_0W|JtBPC
ze~f4qtRGR58c`9xic&YHN5oo1&B(GDr9Pu9az<v<jMg@z%x4UWoRJkZBim*S@)?68
zXKWBPBW5!O`-~xxGg?Q@$h8?me8$ko8Ev9ww6hsQea5iJ8QD=Y@@>X2pRsl1jJ8oT
zI@pY@ZAJ-xjMnWRv8Wk^He(x~5xJZ4ha|nLZ)h{N^%>FoX>Qc(=wdUr^BK|mX<pQf
zZZ>0kpAo&Ewu_q4!)6Tk8PWS``=}YcY{m{gBYHp0kDAfjW{mI|(fesZ)QpX6M!C<3
z-cLJ3&DhvxRQQbO{j_7$jQ%zwZZk@w_tV0t8JpUSN}mzEpLU9xvANBt@)^<l>4s4=
z2H1>|J|lWR?Hn~@OPevuXGHI(U7}_b+YJ3Rp7<Lo{JWtvdOz(NHKWvKRQrtR{j^)u
zj6pVIN1qYBpLUO$F~nx<<TIl8(;iVXhS`iUJ|lWR?HM&=8=FyMGs>d((_T?CwzC;y
zeMa<tS`;;7xXq|d%~<euW?j5G^+M{#))ki*57U85TnA*yDhm%|sz&LyqGGIWbzr4i
z9iiog>%s@e)fW`SdejB+pgPzu=p7X6ze?Sk6-*5#>0_Xck_RDm_2W7&y)ZK;$m)=j
zmDAD^jB3z`<oyiYF9|y2hM$kMQk146Q&ARl$ji!YX~_t}HQFv!;VNy|F8Nquoi<Hp
zxKi^I+v=DpxoxV#mFZ1&KomZsHchNlhAY$0l9^bUeg&C9xH7$IW^$!AO{`RgEA@&J
z&!VHl<hH3w855i804k+Sr#m-*bA!ZlrkxukSEgUQ(w(j0)FH86L3&diaJf_I&Ngti
zfwK*rN_S?%nVndf{*veb&7DejwuMs%^U1GX;!Dz&PNh3zaK_-&0i8RQ?#zKR2hJQi
zmG0CTg?&GB;nV@3JC*LtgEJ4#JUW%`YzJpMICa42PNh5B!`U9r_H-)Usgo&l=EJE2
zOm`~XSpa7NoCS0$-Pr-o4shy#)SXIqc7(GdoE_;@y0Z|@LO68*>rSORJHgor&Q5eH
z-MJy08^WmrUUw?p*%{8xaCW9s=}w($+V`^yoH{^ur_!BW;p_@$S2~sM>;`8yICVhn
zPNh4$!`U6q?sO{M*#piVaOwcuol1B1gtI4{J?T`svlpDb;M4)TJC*J%g0l$DB081s
z><wpcICX&UPNh5hz}W}RK6EPGxe=Tj!Ko7hcPic47tX$L_N7zl&W+*R7*3r)xKruQ
zesK1Kvmc#GclL*~Kb$(@aHrCpo4~mVoSV?8bmyjUZVIPPP~53>=Vowj2IppUD&4s`
zoSVa`6B>6a-MIyvTfn&mol18OfO7zxIstO0(wzh090=z?I+gC+63#8*)CrS2mG0aM
z&aL3wicY0FbzRQ>ye)=PCs^)Ox>J|qv@(6<SpsJXol1A=BAiyHk337^)Crk8mG0D~
zH?2$`-<H8yMyJx9y5MHcL2&8>&Yenk>N1--2g5m-PNh3_am}1V;M579JC*L#B{g#n
zg>xvKN_Xl)nmLETsS`wZD&48eXXe}*&aLTGx>Fa;%()GmI-zu@(w(|gX3lNl+?GzI
zJ9UA~oZG>v6Hs?5-KooB=G-36?depyQy0U`IUG)%u)0&}PF(^s=MHf0K&R53Bj6kX
z=LkBL?ktD19L{n&mG0C<E^}7ESwW}Low~GT&N!TLI+gC!1ud;ip8;3GSxKkTow|&r
zmFYi+s^F}mQ|V4!yfWuVI7iZ{bf+#^nR67Jqv%w+Qx~etIU3H<bSmAc%Twm8hO?SZ
zr8{*|%A7mGxg(uQcj{7<Id_6{Cpwkx)CDMWj)8Lwol1A=vXeP$;H;rj=}uj2GUr%0
z$I_{Er!Fy>vlh-;I+gCMgR>6KIy#l^+!@ZD;oO-{r9124tcSCnPNh2=;B0`iflj46
z$H6%c&T(`q-8ml4@o<i(Q|ZoK;M@hyUFcN0a{`<b;G96G(w!6GoCxPcI+gC+70zAZ
z+?7tHJ9mR~H#m2rQ|Zn|I2++?q*Lk6-QnCF&fV!$x^oXW_keQ`I+gC+6V5&1+>=hF
zJDcEag0qQEr91b6b1yjeqEqS4z2V#&&b{eWx^o{m_knXCI+gC61m`3;C()^N=e}_6
z3+KLcD&488-uCD1esJzbr_!C1;hYTTWIC1Z+#k;U;oP52r8}p<IR(xsbSm9B70#(}
zPNh@n&S`K?gL4|4N_S3&b2^;U=~TM&05}hT^8h-P?mQ6A1K~W7PNh2!g7Y9a5291)
z&V%7R7|w&~RJwBpoHO8@L8sE4hroFVoQKe<bmyUP9t!87bSm9>7@UW}c^I8acg}=!
zCY&?rRJ!wUI1h*Oa5|OloCW7BIA_tRbmtLp9s%bObSm9B8_wBq&Zbl8&N*<-fpZR>
zN_WnMb1s~7=~TM&NH~v#^GG_C?mP<4qu@M>PNh5N!8s4kd2}k>c{H3y!+A8FN_QRu
z=P_^|L#NW6^WmHi=X^Sq?py%p0yr1YsdQ&EoXv1H)2Vdlv2Y#>=dpAu-FY0G$H93V
zol18e59jf49#5yzoeSYy2<JjNmF`>w=OQ>4(W!LjVmKGWxtLC+J5PY~1UOHiQ|Znn
za4vy!37txJo(SiOaGpq~(w!&4c@mr_(W!Lj$#9+w=gD*`-MJLbrEo5#Q|ZoA;5-G+
zQ|MH>^Hexbh4WN8mF`>y=Q22#(W!LjayXa6xtva=J6FKD0?rk5D&2V+oTtHg8l6ga
zo(|{faGp-5(w%3(c?O(k(5ZCinQ)#7=b3aW-FX(AXTf<Eol19}4d>Z#o=vCHo#()L
z4xH!EsdVSLaGne2xpXSsc^;hS!Fe8?N_U<Q=lO7+Pp8tI7r=P|oEOlkbmxU|UI^!f
zbSmAs63&%yuB21x&Wqr@2+oV>RJ!wGI4_3tVmg)Xyadim;Jk!Rr8`%_xeCrzbSm9>
zDV&$Wc`2PrcU}hPWpG|br_!C5!+ANJm(!_q=M`{X0p}HTD&2V{oL9nmC7nulUIph>
za9%~H(w$esc{Q9@)2VdlHE>=7=QVUH-FYpX*TQ)%ol19J2j_KgUPq_Wo!7&8J)GCm
zsdVQJaNYpt4Rk8qc_W-R!g(W|N_XA_=S^_lM5of7H^X@|oHx^{bmuK_-U8<>bSm9>
zE1b8&c`Kbtcisl)ZE)U3r_!Cb!+ATLx6`R~=N)j~0p}fbD&2V}oOi-`C!I=n-Ua7f
zaNb3y(w%q1c{iMQ)2VdlJ#gLw=RI^P-FYvZ_riHEol1A!2j_io-bbg>o%h3eKb-f|
zsdVQ9a6SO%19U3g`5>GR!ucSbN_Rd4=R<HlM5of7tKnP?=W05Y?tB=|hv9sfPNh2^
zf%6eKAE8s}&PU;V6wXKKRJ!vqI3I)aF*=p*d>qcl;e4D<r90QaxdzTPbSmBX1e{O6
z`2?LxcRmT{lW;ysr_!BI!TA)NPtmD#=hJXL4d>HzD&6@EoX^1d44q1MJ`3lwa6U_?
z(w%GJTnpz~I+gBx4$kM`e2z|~JD-R1c{rb^Q|ZnZ;Cunj7wA;F^F=scg!4r@mF|2A
z&X?ePiB6?EUxxE#IA5ky>CRW+d<D)|=v2D%RXAUT^Hn;P?tBf-*Wi4OPNh3vhx2tf
zU#C;)&NtwE1I{<-RJ!v`INyZxO*)nCd<)LE;Czctr90n-^KCfarc>$8ci?;n&Uffk
zy7OH)--YvCI+gBx56<`Ce2-40JKu-%eK_BzQ|ZnR;QRp259n07^Fug4g!4l>mG1lq
z&X3^yh)$(DKZf&TI6tOS>CR8!`~=QV=v2D%Q#e0`^HVyN?)(hS&*1!wPNh3Phx2nd
zKc`da&M)Bn0?se!RJ!v^IKPDROFEVA{0h#m;QWeCr8~cd^J_T2rc>$8Z{Yj}&Tr^c
zy7OB&zlHN#I+gDH4$kl3{EkkgJHLnXdpN(RQ|Znh;QRs3ALvxN^G7&;g!4x_mG1lr
z&Y$4?iB6?Ee}?mCIDe*7>CRu^`~}Wm=v2D%S2%x#^H(~R?)(kT-{Aa>PNh44hx2zh
zf2ULF&OhM%1I|C_RJ!v|IRAw6Pdb(E{0q*%;QWhDr91zI^KUr+rc>$87C2krY@t(`
zbT&3uXX$^8vEMh17mrN-KB;c&^rjx|VmXO7^5`2R-^e3;qYr+ruys>IeM3fSRO<I%
z!(UeYU!yjT7?u1SN2PvU``<?Oix`#s97m;oYy00u^^X{p{9I~OVSZD*qC8mDP8;Tr
z&`n`&`|y2Fg6#T=@goaHw~5VMoENmp)gwWmZ$=PgEb1Htxf$VI{gdC)^7ruM-Igu&
zNJegEvb1$#^A<gt5iHrl)+9EVuiKXJpY-ObkKyO%1grjU&z#*bzOF9Fj*qJ!6BLeZ
z+f>^S&ss7)h*wT1Svj`NiYWyhWBH9WZ<PH~)MLaM6K0k_u>C8OmrRdkX@gRI%+|-U
z8DWHT!aHT*s2N9wx3Qi<_+e#-<twIU%$TPKOJdo{(Os6WShsERf&9b+Gr|SoBdexg
zl%HCXm3U;;^umEnl?^pnEBhp0)!LzJK57^|w`N)A&uhA_j@PVgyJDKYkeL}7;f>w|
zCa1oxxGDL|)s4+HS@l)vx2#F-LE(GJgg*#nvEqMxyAr#GzF9>hQs1W3hy3tk_y#kh
z+l;EKP5s1`C*DVANccWF>wb|tH9P&T8$ss!chlJ<F+$r`RTuP)^**V)_Lt<pdO-VH
q*Pxf~WCr0A=(!5>nyQM+f`xSx>MLUN8=H&5JIVJQNjl<q-v0n?ptJx0
literal 0
HcmV?d00001
diff --git a/tests/data/acpi/virt/FACP b/tests/data/acpi/virt/FACP
new file mode 100644
index 0000000000000000000000000000000000000000..27de99f51bfe846b1f8796ace49d83f5b33a1aed
GIT binary patch
literal 268
ycmZ>BbPnKQWME+3?d0$55v<@85#a0w6axw|fY>0Kx<CNcIA#XwTY+i=(L4a*H3tCz
literal 0
HcmV?d00001
diff --git a/tests/data/acpi/virt/GTDT b/tests/data/acpi/virt/GTDT
new file mode 100644
index 0000000000000000000000000000000000000000..10107a65e958ff6495bb8c17d63d0539690f59f6
GIT binary patch
literal 96
zcmZ<{aS2IaU|?Xn>E!S15v<@85#a0&6k`O6f!H7#8OTC8azL5|h^3)?DJYFj0RVOU
B2mt^9
literal 0
HcmV?d00001
diff --git a/tests/data/acpi/virt/MCFG b/tests/data/acpi/virt/MCFG
new file mode 100644
index 0000000000000000000000000000000000000000..e8987e1af0ec3829770bf4fe11fab02b06160dd2
GIT binary patch
literal 60
scmeZuc5}C3U|?YMck*}k2v%^42ypfViZKGkKx`0=1Oyx)oc|yS05YNo0RR91
literal 0
HcmV?d00001
diff --git a/tests/data/acpi/virt/SPCR b/tests/data/acpi/virt/SPCR
new file mode 100644
index 0000000000000000000000000000000000000000..377271a0e7817cc21a28c02123a89facad63604f
GIT binary patch
literal 80
zcmWFza1IJ!U|?VpcJg=j2v%^42yhMtiZKGkKx`1r48#l^3?L>agsBLmm>C$E7#RKo
I0Z0r60QF4^0RR91
literal 0
HcmV?d00001
--
2.7.4
^ permalink raw reply [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v4 12/15] tests: add expected ACPI tables for arm/virt board
@ 2019-05-02 14:52 ` Igor Mammedov
0 siblings, 0 replies; 289+ messages in thread
From: Igor Mammedov @ 2019-05-02 14:52 UTC (permalink / raw)
To: qemu-devel
Cc: Andrew Jones, Ben Warren, Michael S. Tsirkin, Laszlo Ersek,
linuxarm, Shameer Kolothum, Shannon Zhao, Gonglei, Wei Yang,
xuwei5, xuwei5, Philippe Mathieu-Daudé
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
this patch is ahead fo "tests: acpi: add simple arm/virt testcase"
to keep 'make check' working during bisection and not to pollute
code with binary blobs which are not reviewable.
---
tests/data/acpi/virt/APIC | Bin 0 -> 168 bytes
tests/data/acpi/virt/DSDT | Bin 0 -> 18476 bytes
tests/data/acpi/virt/FACP | Bin 0 -> 268 bytes
tests/data/acpi/virt/GTDT | Bin 0 -> 96 bytes
tests/data/acpi/virt/MCFG | Bin 0 -> 60 bytes
tests/data/acpi/virt/SPCR | Bin 0 -> 80 bytes
6 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 tests/data/acpi/virt/APIC
create mode 100644 tests/data/acpi/virt/DSDT
create mode 100644 tests/data/acpi/virt/FACP
create mode 100644 tests/data/acpi/virt/GTDT
create mode 100644 tests/data/acpi/virt/MCFG
create mode 100644 tests/data/acpi/virt/SPCR
diff --git a/tests/data/acpi/virt/APIC b/tests/data/acpi/virt/APIC
new file mode 100644
index 0000000000000000000000000000000000000000..797dfde2841c51b7e72065602e99ce1714347f0d
GIT binary patch
literal 168
zcmZ<^@N{0mz`($~*~#D8BUr&HBEZ=ZD8>jB1F=Cg4Dd+6SPUF6788)c?E~X6Fu>G{
hBZPn~MyPrgD9sGlkD?67;f3451Xcqw&w(L;0RYV=2>}2A
literal 0
HcmV?d00001
diff --git a/tests/data/acpi/virt/DSDT b/tests/data/acpi/virt/DSDT
new file mode 100644
index 0000000000000000000000000000000000000000..20e85c7f89f645c69935c615c07084e221419960
GIT binary patch
literal 18476
zcmc)ScU)EVAII^7km3at6myGa+R|dUS|(gjDG>rqi;BuJN5jfYEla7?tSq%Xt!(eT
zr!AYd_uhN&!S8+U(D&=t`StIw9$oH>d%mB0pK#D~&LeJRL*=*uql2K;?26j>=!V`E
z6YJuY`dmg31mXSgWB#J~S-UqiR5Ud<cZ(Mn7iTw(uCB~0kJnWzh6dS9<Etx!#^$Q5
zcx_Gk!TOrf#l<BhsRy&0;`I#$-C~^=whh9GZG-$EIH7frk<mvrM_ZLw*5`%~G&Yxv
z9Mh1RGG=Ujt)>jdl!92h)D&$WWX;hthf7M5uZl}Dl25#TNmhEvu#pquBa=&ZuBsU?
zNU5HsVO)7EM{DBc|GlzR+b&ufK3RFzF7@fJLGsy(?FFt|xgHw}TBWeXJ_0W|JtBPC
ze~f4qtRGR58c`9xic&YHN5oo1&B(GDr9Pu9az<v<jMg@z%x4UWoRJkZBim*S@)?68
zXKWBPBW5!O`-~xxGg?Q@$h8?me8$ko8Ev9ww6hsQea5iJ8QD=Y@@>X2pRsl1jJ8oT
zI@pY@ZAJ-xjMnWRv8Wk^He(x~5xJZ4ha|nLZ)h{N^%>FoX>Qc(=wdUr^BK|mX<pQf
zZZ>0kpAo&Ewu_q4!)6Tk8PWS``=}YcY{m{gBYHp0kDAfjW{mI|(fesZ)QpX6M!C<3
z-cLJ3&DhvxRQQbO{j_7$jQ%zwZZk@w_tV0t8JpUSN}mzEpLU9xvANBt@)^<l>4s4=
z2H1>|J|lWR?Hn~@OPevuXGHI(U7}_b+YJ3Rp7<Lo{JWtvdOz(NHKWvKRQrtR{j^)u
zj6pVIN1qYBpLUO$F~nx<<TIl8(;iVXhS`iUJ|lWR?HM&=8=FyMGs>d((_T?CwzC;y
zeMa<tS`;;7xXq|d%~<euW?j5G^+M{#))ki*57U85TnA*yDhm%|sz&LyqGGIWbzr4i
z9iiog>%s@e)fW`SdejB+pgPzu=p7X6ze?Sk6-*5#>0_Xck_RDm_2W7&y)ZK;$m)=j
zmDAD^jB3z`<oyiYF9|y2hM$kMQk146Q&ARl$ji!YX~_t}HQFv!;VNy|F8Nquoi<Hp
zxKi^I+v=DpxoxV#mFZ1&KomZsHchNlhAY$0l9^bUeg&C9xH7$IW^$!AO{`RgEA@&J
z&!VHl<hH3w855i804k+Sr#m-*bA!ZlrkxukSEgUQ(w(j0)FH86L3&diaJf_I&Ngti
zfwK*rN_S?%nVndf{*veb&7DejwuMs%^U1GX;!Dz&PNh3zaK_-&0i8RQ?#zKR2hJQi
zmG0CTg?&GB;nV@3JC*LtgEJ4#JUW%`YzJpMICa42PNh5B!`U9r_H-)Usgo&l=EJE2
zOm`~XSpa7NoCS0$-Pr-o4shy#)SXIqc7(GdoE_;@y0Z|@LO68*>rSORJHgor&Q5eH
z-MJy08^WmrUUw?p*%{8xaCW9s=}w($+V`^yoH{^ur_!BW;p_@$S2~sM>;`8yICVhn
zPNh4$!`U6q?sO{M*#piVaOwcuol1B1gtI4{J?T`svlpDb;M4)TJC*J%g0l$DB081s
z><wpcICX&UPNh5hz}W}RK6EPGxe=Tj!Ko7hcPic47tX$L_N7zl&W+*R7*3r)xKruQ
zesK1Kvmc#GclL*~Kb$(@aHrCpo4~mVoSV?8bmyjUZVIPPP~53>=Vowj2IppUD&4s`
zoSVa`6B>6a-MIyvTfn&mol18OfO7zxIstO0(wzh090=z?I+gC+63#8*)CrS2mG0aM
z&aL3wicY0FbzRQ>ye)=PCs^)Ox>J|qv@(6<SpsJXol1A=BAiyHk337^)Crk8mG0D~
zH?2$`-<H8yMyJx9y5MHcL2&8>&Yenk>N1--2g5m-PNh3_am}1V;M579JC*L#B{g#n
zg>xvKN_Xl)nmLETsS`wZD&48eXXe}*&aLTGx>Fa;%()GmI-zu@(w(|gX3lNl+?GzI
zJ9UA~oZG>v6Hs?5-KooB=G-36?depyQy0U`IUG)%u)0&}PF(^s=MHf0K&R53Bj6kX
z=LkBL?ktD19L{n&mG0C<E^}7ESwW}Low~GT&N!TLI+gC!1ud;ip8;3GSxKkTow|&r
zmFYi+s^F}mQ|V4!yfWuVI7iZ{bf+#^nR67Jqv%w+Qx~etIU3H<bSmAc%Twm8hO?SZ
zr8{*|%A7mGxg(uQcj{7<Id_6{Cpwkx)CDMWj)8Lwol1A=vXeP$;H;rj=}uj2GUr%0
z$I_{Er!Fy>vlh-;I+gCMgR>6KIy#l^+!@ZD;oO-{r9124tcSCnPNh2=;B0`iflj46
z$H6%c&T(`q-8ml4@o<i(Q|ZoK;M@hyUFcN0a{`<b;G96G(w!6GoCxPcI+gC+70zAZ
z+?7tHJ9mR~H#m2rQ|Zn|I2++?q*Lk6-QnCF&fV!$x^oXW_keQ`I+gC+6V5&1+>=hF
zJDcEag0qQEr91b6b1yjeqEqS4z2V#&&b{eWx^o{m_knXCI+gC61m`3;C()^N=e}_6
z3+KLcD&488-uCD1esJzbr_!C1;hYTTWIC1Z+#k;U;oP52r8}p<IR(xsbSm9B70#(}
zPNh@n&S`K?gL4|4N_S3&b2^;U=~TM&05}hT^8h-P?mQ6A1K~W7PNh2!g7Y9a5291)
z&V%7R7|w&~RJwBpoHO8@L8sE4hroFVoQKe<bmyUP9t!87bSm9>7@UW}c^I8acg}=!
zCY&?rRJ!wUI1h*Oa5|OloCW7BIA_tRbmtLp9s%bObSm9B8_wBq&Zbl8&N*<-fpZR>
zN_WnMb1s~7=~TM&NH~v#^GG_C?mP<4qu@M>PNh5N!8s4kd2}k>c{H3y!+A8FN_QRu
z=P_^|L#NW6^WmHi=X^Sq?py%p0yr1YsdQ&EoXv1H)2Vdlv2Y#>=dpAu-FY0G$H93V
zol18e59jf49#5yzoeSYy2<JjNmF`>w=OQ>4(W!LjVmKGWxtLC+J5PY~1UOHiQ|Znn
za4vy!37txJo(SiOaGpq~(w!&4c@mr_(W!Lj$#9+w=gD*`-MJLbrEo5#Q|ZoA;5-G+
zQ|MH>^Hexbh4WN8mF`>y=Q22#(W!LjayXa6xtva=J6FKD0?rk5D&2V+oTtHg8l6ga
zo(|{faGp-5(w%3(c?O(k(5ZCinQ)#7=b3aW-FX(AXTf<Eol19}4d>Z#o=vCHo#()L
z4xH!EsdVSLaGne2xpXSsc^;hS!Fe8?N_U<Q=lO7+Pp8tI7r=P|oEOlkbmxU|UI^!f
zbSmAs63&%yuB21x&Wqr@2+oV>RJ!wGI4_3tVmg)Xyadim;Jk!Rr8`%_xeCrzbSm9>
zDV&$Wc`2PrcU}hPWpG|br_!C5!+ANJm(!_q=M`{X0p}HTD&2V{oL9nmC7nulUIph>
za9%~H(w$esc{Q9@)2VdlHE>=7=QVUH-FYpX*TQ)%ol19J2j_KgUPq_Wo!7&8J)GCm
zsdVQJaNYpt4Rk8qc_W-R!g(W|N_XA_=S^_lM5of7H^X@|oHx^{bmuK_-U8<>bSm9>
zE1b8&c`Kbtcisl)ZE)U3r_!Cb!+ATLx6`R~=N)j~0p}fbD&2V}oOi-`C!I=n-Ua7f
zaNb3y(w%q1c{iMQ)2VdlJ#gLw=RI^P-FYvZ_riHEol1A!2j_io-bbg>o%h3eKb-f|
zsdVQ9a6SO%19U3g`5>GR!ucSbN_Rd4=R<HlM5of7tKnP?=W05Y?tB=|hv9sfPNh2^
zf%6eKAE8s}&PU;V6wXKKRJ!vqI3I)aF*=p*d>qcl;e4D<r90QaxdzTPbSmBX1e{O6
z`2?LxcRmT{lW;ysr_!BI!TA)NPtmD#=hJXL4d>HzD&6@EoX^1d44q1MJ`3lwa6U_?
z(w%GJTnpz~I+gBx4$kM`e2z|~JD-R1c{rb^Q|ZnZ;Cunj7wA;F^F=scg!4r@mF|2A
z&X?ePiB6?EUxxE#IA5ky>CRW+d<D)|=v2D%RXAUT^Hn;P?tBf-*Wi4OPNh3vhx2tf
zU#C;)&NtwE1I{<-RJ!v`INyZxO*)nCd<)LE;Czctr90n-^KCfarc>$8ci?;n&Uffk
zy7OH)--YvCI+gBx56<`Ce2-40JKu-%eK_BzQ|ZnR;QRp259n07^Fug4g!4l>mG1lq
z&X3^yh)$(DKZf&TI6tOS>CR8!`~=QV=v2D%Q#e0`^HVyN?)(hS&*1!wPNh3Phx2nd
zKc`da&M)Bn0?se!RJ!v^IKPDROFEVA{0h#m;QWeCr8~cd^J_T2rc>$8Z{Yj}&Tr^c
zy7OB&zlHN#I+gDH4$kl3{EkkgJHLnXdpN(RQ|Znh;QRs3ALvxN^G7&;g!4x_mG1lr
z&Y$4?iB6?Ee}?mCIDe*7>CRu^`~}Wm=v2D%S2%x#^H(~R?)(kT-{Aa>PNh44hx2zh
zf2ULF&OhM%1I|C_RJ!v|IRAw6Pdb(E{0q*%;QWhDr91zI^KUr+rc>$87C2krY@t(`
zbT&3uXX$^8vEMh17mrN-KB;c&^rjx|VmXO7^5`2R-^e3;qYr+ruys>IeM3fSRO<I%
z!(UeYU!yjT7?u1SN2PvU``<?Oix`#s97m;oYy00u^^X{p{9I~OVSZD*qC8mDP8;Tr
z&`n`&`|y2Fg6#T=@goaHw~5VMoENmp)gwWmZ$=PgEb1Htxf$VI{gdC)^7ruM-Igu&
zNJegEvb1$#^A<gt5iHrl)+9EVuiKXJpY-ObkKyO%1grjU&z#*bzOF9Fj*qJ!6BLeZ
z+f>^S&ss7)h*wT1Svj`NiYWyhWBH9WZ<PH~)MLaM6K0k_u>C8OmrRdkX@gRI%+|-U
z8DWHT!aHT*s2N9wx3Qi<_+e#-<twIU%$TPKOJdo{(Os6WShsERf&9b+Gr|SoBdexg
zl%HCXm3U;;^umEnl?^pnEBhp0)!LzJK57^|w`N)A&uhA_j@PVgyJDKYkeL}7;f>w|
zCa1oxxGDL|)s4+HS@l)vx2#F-LE(GJgg*#nvEqMxyAr#GzF9>hQs1W3hy3tk_y#kh
z+l;EKP5s1`C*DVANccWF>wb|tH9P&T8$ss!chlJ<F+$r`RTuP)^**V)_Lt<pdO-VH
q*Pxf~WCr0A=(!5>nyQM+f`xSx>MLUN8=H&5JIVJQNjl<q-v0n?ptJx0
literal 0
HcmV?d00001
diff --git a/tests/data/acpi/virt/FACP b/tests/data/acpi/virt/FACP
new file mode 100644
index 0000000000000000000000000000000000000000..27de99f51bfe846b1f8796ace49d83f5b33a1aed
GIT binary patch
literal 268
ycmZ>BbPnKQWME+3?d0$55v<@85#a0w6axw|fY>0Kx<CNcIA#XwTY+i=(L4a*H3tCz
literal 0
HcmV?d00001
diff --git a/tests/data/acpi/virt/GTDT b/tests/data/acpi/virt/GTDT
new file mode 100644
index 0000000000000000000000000000000000000000..10107a65e958ff6495bb8c17d63d0539690f59f6
GIT binary patch
literal 96
zcmZ<{aS2IaU|?Xn>E!S15v<@85#a0&6k`O6f!H7#8OTC8azL5|h^3)?DJYFj0RVOU
B2mt^9
literal 0
HcmV?d00001
diff --git a/tests/data/acpi/virt/MCFG b/tests/data/acpi/virt/MCFG
new file mode 100644
index 0000000000000000000000000000000000000000..e8987e1af0ec3829770bf4fe11fab02b06160dd2
GIT binary patch
literal 60
scmeZuc5}C3U|?YMck*}k2v%^42ypfViZKGkKx`0=1Oyx)oc|yS05YNo0RR91
literal 0
HcmV?d00001
diff --git a/tests/data/acpi/virt/SPCR b/tests/data/acpi/virt/SPCR
new file mode 100644
index 0000000000000000000000000000000000000000..377271a0e7817cc21a28c02123a89facad63604f
GIT binary patch
literal 80
zcmWFza1IJ!U|?VpcJg=j2v%^42yhMtiZKGkKx`1r48#l^3?L>agsBLmm>C$E7#RKo
I0Z0r60QF4^0RR91
literal 0
HcmV?d00001
--
2.7.4
^ permalink raw reply [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v4 13/15] tests: acpi: add simple arm/virt testcase
@ 2019-05-02 14:52 ` Igor Mammedov
0 siblings, 0 replies; 289+ messages in thread
From: Igor Mammedov @ 2019-05-02 14:52 UTC (permalink / raw)
To: qemu-devel
Cc: Laszlo Ersek, Michael S. Tsirkin, Gonglei,
Philippe Mathieu-Daudé,
Shannon Zhao, Wei Yang, Andrew Jones, Shameer Kolothum,
Ben Warren, xuwei5, xuwei5, linuxarm
adds simple arm/virt test case that starts guest with
bios-tables-test.aarch64.iso.qcow2 boot image which
initializes UefiTestSupport* structure in RAM once
guest is booted.
* see commit: tests: acpi: add acpi_find_rsdp_address_uefi() helper
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
v4:
* force test to use TCG accelerator
v3:
* use firmware blobs directly from pc-bios directory
* use bios-tables-test.aarch64.iso.qcow2 as test boot image
* drop leftover qtest-uefi-images-aarch64 iMakefile rule from
previos version (Laszlo)
* add Makefile rule to include bios-tables-test into
check-qtest-aarch64 target
v2:
* specify in test_data where board's RAM starts and RAM size
fixup! tests: acpi: add simple arm/virt testcase
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
tests/Makefile.include | 1 +
tests/bios-tables-test.c | 18 ++++++++++++++++++
2 files changed, 19 insertions(+)
diff --git a/tests/Makefile.include b/tests/Makefile.include
index e2432d5..983c8b1 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -267,6 +267,7 @@ check-qtest-arm-y += tests/hexloader-test$(EXESUF)
check-qtest-aarch64-y = tests/numa-test$(EXESUF)
check-qtest-aarch64-y += tests/boot-serial-test$(EXESUF)
check-qtest-aarch64-y += tests/migration-test$(EXESUF)
+check-qtest-aarch64-y += tests/bios-tables-test$(EXESUF)
check-qtest-microblazeel-y += $(check-qtest-microblaze-y)
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index 39c1e24..eaa1b0c 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -810,6 +810,22 @@ static void test_acpi_piix4_tcg_dimm_pxm(void)
test_acpi_tcg_dimm_pxm(MACHINE_PC);
}
+static void test_acpi_virt_tcg(void)
+{
+ test_data data = {
+ .machine = "virt",
+ .accel = "tcg",
+ .uefi_fl1 = "pc-bios/edk2-aarch64-code.fd",
+ .uefi_fl2 = "pc-bios/edk2-arm-vars.fd",
+ .cd = "tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2",
+ .ram_start = 0x40000000ULL,
+ .scan_len = 128ULL * 1024 * 1024,
+ };
+
+ test_acpi_one("-cpu cortex-a57", &data);
+ free_test_data(&data);
+}
+
int main(int argc, char *argv[])
{
const char *arch = qtest_get_arch();
@@ -838,6 +854,8 @@ int main(int argc, char *argv[])
qtest_add_func("acpi/q35/numamem", test_acpi_q35_tcg_numamem);
qtest_add_func("acpi/piix4/dimmpxm", test_acpi_piix4_tcg_dimm_pxm);
qtest_add_func("acpi/q35/dimmpxm", test_acpi_q35_tcg_dimm_pxm);
+ } else if (strcmp(arch, "aarch64") == 0) {
+ qtest_add_func("acpi/virt", test_acpi_virt_tcg);
}
ret = g_test_run();
boot_sector_cleanup(disk);
--
2.7.4
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v4 13/15] tests: acpi: add simple arm/virt testcase
@ 2019-05-02 14:52 ` Igor Mammedov
0 siblings, 0 replies; 289+ messages in thread
From: Igor Mammedov @ 2019-05-02 14:52 UTC (permalink / raw)
To: qemu-devel
Cc: Andrew Jones, Ben Warren, Michael S. Tsirkin, Laszlo Ersek,
linuxarm, Shameer Kolothum, Shannon Zhao, Gonglei, Wei Yang,
xuwei5, xuwei5, Philippe Mathieu-Daudé
adds simple arm/virt test case that starts guest with
bios-tables-test.aarch64.iso.qcow2 boot image which
initializes UefiTestSupport* structure in RAM once
guest is booted.
* see commit: tests: acpi: add acpi_find_rsdp_address_uefi() helper
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
v4:
* force test to use TCG accelerator
v3:
* use firmware blobs directly from pc-bios directory
* use bios-tables-test.aarch64.iso.qcow2 as test boot image
* drop leftover qtest-uefi-images-aarch64 iMakefile rule from
previos version (Laszlo)
* add Makefile rule to include bios-tables-test into
check-qtest-aarch64 target
v2:
* specify in test_data where board's RAM starts and RAM size
fixup! tests: acpi: add simple arm/virt testcase
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
tests/Makefile.include | 1 +
tests/bios-tables-test.c | 18 ++++++++++++++++++
2 files changed, 19 insertions(+)
diff --git a/tests/Makefile.include b/tests/Makefile.include
index e2432d5..983c8b1 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -267,6 +267,7 @@ check-qtest-arm-y += tests/hexloader-test$(EXESUF)
check-qtest-aarch64-y = tests/numa-test$(EXESUF)
check-qtest-aarch64-y += tests/boot-serial-test$(EXESUF)
check-qtest-aarch64-y += tests/migration-test$(EXESUF)
+check-qtest-aarch64-y += tests/bios-tables-test$(EXESUF)
check-qtest-microblazeel-y += $(check-qtest-microblaze-y)
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index 39c1e24..eaa1b0c 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -810,6 +810,22 @@ static void test_acpi_piix4_tcg_dimm_pxm(void)
test_acpi_tcg_dimm_pxm(MACHINE_PC);
}
+static void test_acpi_virt_tcg(void)
+{
+ test_data data = {
+ .machine = "virt",
+ .accel = "tcg",
+ .uefi_fl1 = "pc-bios/edk2-aarch64-code.fd",
+ .uefi_fl2 = "pc-bios/edk2-arm-vars.fd",
+ .cd = "tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2",
+ .ram_start = 0x40000000ULL,
+ .scan_len = 128ULL * 1024 * 1024,
+ };
+
+ test_acpi_one("-cpu cortex-a57", &data);
+ free_test_data(&data);
+}
+
int main(int argc, char *argv[])
{
const char *arch = qtest_get_arch();
@@ -838,6 +854,8 @@ int main(int argc, char *argv[])
qtest_add_func("acpi/q35/numamem", test_acpi_q35_tcg_numamem);
qtest_add_func("acpi/piix4/dimmpxm", test_acpi_piix4_tcg_dimm_pxm);
qtest_add_func("acpi/q35/dimmpxm", test_acpi_q35_tcg_dimm_pxm);
+ } else if (strcmp(arch, "aarch64") == 0) {
+ qtest_add_func("acpi/virt", test_acpi_virt_tcg);
}
ret = g_test_run();
boot_sector_cleanup(disk);
--
2.7.4
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v4 14/15] tests: acpi: refactor rebuild-expected-aml.sh to dump ACPI tables for a specified list of targets
@ 2019-05-02 14:52 ` Igor Mammedov
0 siblings, 0 replies; 289+ messages in thread
From: Igor Mammedov @ 2019-05-02 14:52 UTC (permalink / raw)
To: qemu-devel
Cc: Laszlo Ersek, Michael S. Tsirkin, Gonglei,
Philippe Mathieu-Daudé,
Shannon Zhao, Wei Yang, Andrew Jones, Shameer Kolothum,
Ben Warren, xuwei5, xuwei5, linuxarm
Make initial list contain aarch64 and x86_64 targets.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
v4:
* fix typo (Wei Yang <richardw.yang@linux.intel.com>)
v2:
* fix up error message (Philippe Mathieu-Daudé <philmd@redhat.com>)
---
tests/data/acpi/rebuild-expected-aml.sh | 23 +++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/tests/data/acpi/rebuild-expected-aml.sh b/tests/data/acpi/rebuild-expected-aml.sh
index abdff70..07f7e3f 100755
--- a/tests/data/acpi/rebuild-expected-aml.sh
+++ b/tests/data/acpi/rebuild-expected-aml.sh
@@ -7,21 +7,12 @@
#
# Authors:
# Marcel Apfelbaum <marcel.a@redhat.com>
+# Igor Mammedov <imammedo@redhat.com>
#
# This work is licensed under the terms of the GNU GPLv2.
# See the COPYING.LIB file in the top-level directory.
-qemu=
-
-if [ -e x86_64-softmmu/qemu-system-x86_64 ]; then
- qemu="x86_64-softmmu/qemu-system-x86_64"
-elif [ -e i386-softmmu/qemu-system-i386 ]; then
- qemu="i386-softmmu/qemu-system-i386"
-else
- echo "Run 'make' to build the qemu exectutable!"
- echo "Run this script from the build directory."
- exit 1;
-fi
+qemu_bins="aarch64-softmmu/qemu-system-aarch64 x86_64-softmmu/qemu-system-x86_64"
if [ ! -e "tests/bios-tables-test" ]; then
echo "Test: bios-tables-test is required! Run make check before this script."
@@ -29,6 +20,14 @@ if [ ! -e "tests/bios-tables-test" ]; then
exit 1;
fi
-TEST_ACPI_REBUILD_AML=y QTEST_QEMU_BINARY=$qemu tests/bios-tables-test
+for qemu in $qemu_bins; do
+ if [ ! -e $qemu ]; then
+ echo "Run 'make' to build the following QEMU executables: $qemu_bins"
+ echo "Also, run this script from the build directory."
+ exit 1;
+ fi
+ TEST_ACPI_REBUILD_AML=y QTEST_QEMU_BINARY=$qemu tests/bios-tables-test
+done
+
echo "The files were rebuilt and can be added to git."
--
2.7.4
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v4 14/15] tests: acpi: refactor rebuild-expected-aml.sh to dump ACPI tables for a specified list of targets
@ 2019-05-02 14:52 ` Igor Mammedov
0 siblings, 0 replies; 289+ messages in thread
From: Igor Mammedov @ 2019-05-02 14:52 UTC (permalink / raw)
To: qemu-devel
Cc: Andrew Jones, Ben Warren, Michael S. Tsirkin, Laszlo Ersek,
linuxarm, Shameer Kolothum, Shannon Zhao, Gonglei, Wei Yang,
xuwei5, xuwei5, Philippe Mathieu-Daudé
Make initial list contain aarch64 and x86_64 targets.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
v4:
* fix typo (Wei Yang <richardw.yang@linux.intel.com>)
v2:
* fix up error message (Philippe Mathieu-Daudé <philmd@redhat.com>)
---
tests/data/acpi/rebuild-expected-aml.sh | 23 +++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/tests/data/acpi/rebuild-expected-aml.sh b/tests/data/acpi/rebuild-expected-aml.sh
index abdff70..07f7e3f 100755
--- a/tests/data/acpi/rebuild-expected-aml.sh
+++ b/tests/data/acpi/rebuild-expected-aml.sh
@@ -7,21 +7,12 @@
#
# Authors:
# Marcel Apfelbaum <marcel.a@redhat.com>
+# Igor Mammedov <imammedo@redhat.com>
#
# This work is licensed under the terms of the GNU GPLv2.
# See the COPYING.LIB file in the top-level directory.
-qemu=
-
-if [ -e x86_64-softmmu/qemu-system-x86_64 ]; then
- qemu="x86_64-softmmu/qemu-system-x86_64"
-elif [ -e i386-softmmu/qemu-system-i386 ]; then
- qemu="i386-softmmu/qemu-system-i386"
-else
- echo "Run 'make' to build the qemu exectutable!"
- echo "Run this script from the build directory."
- exit 1;
-fi
+qemu_bins="aarch64-softmmu/qemu-system-aarch64 x86_64-softmmu/qemu-system-x86_64"
if [ ! -e "tests/bios-tables-test" ]; then
echo "Test: bios-tables-test is required! Run make check before this script."
@@ -29,6 +20,14 @@ if [ ! -e "tests/bios-tables-test" ]; then
exit 1;
fi
-TEST_ACPI_REBUILD_AML=y QTEST_QEMU_BINARY=$qemu tests/bios-tables-test
+for qemu in $qemu_bins; do
+ if [ ! -e $qemu ]; then
+ echo "Run 'make' to build the following QEMU executables: $qemu_bins"
+ echo "Also, run this script from the build directory."
+ exit 1;
+ fi
+ TEST_ACPI_REBUILD_AML=y QTEST_QEMU_BINARY=$qemu tests/bios-tables-test
+done
+
echo "The files were rebuilt and can be added to git."
--
2.7.4
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v4 15/15] tests: acpi: print error unable to dump ACPI table during rebuild
@ 2019-05-02 14:52 ` Igor Mammedov
0 siblings, 0 replies; 289+ messages in thread
From: Igor Mammedov @ 2019-05-02 14:52 UTC (permalink / raw)
To: qemu-devel
Cc: Laszlo Ersek, Michael S. Tsirkin, Gonglei,
Philippe Mathieu-Daudé,
Shannon Zhao, Wei Yang, Andrew Jones, Shameer Kolothum,
Ben Warren, xuwei5, xuwei5, linuxarm
Instead of just asserting print the error that lead to assert first.
While at it move assert into rebuild branch, which removes redundant
check done in case of !rebuild branch is taken (the later is taken
care of by g_assert_no_error).
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Wei Yang <richardw.yang@linux.intel.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
v4:
* fix typo in commit message (Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>)
---
tests/bios-tables-test.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index eaa1b0c..6cb8b16 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -195,11 +195,14 @@ static void dump_aml_files(test_data *data, bool rebuild)
sdt->aml, ext);
fd = g_open(aml_file, O_WRONLY|O_TRUNC|O_CREAT,
S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH);
+ if (fd < 0) {
+ perror(aml_file);
+ }
+ g_assert(fd >= 0);
} else {
fd = g_file_open_tmp("aml-XXXXXX", &sdt->aml_file, &error);
g_assert_no_error(error);
}
- g_assert(fd >= 0);
ret = qemu_write_full(fd, sdt->aml, sdt->aml_len);
g_assert(ret == sdt->aml_len);
--
2.7.4
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PATCH v4 15/15] tests: acpi: print error unable to dump ACPI table during rebuild
@ 2019-05-02 14:52 ` Igor Mammedov
0 siblings, 0 replies; 289+ messages in thread
From: Igor Mammedov @ 2019-05-02 14:52 UTC (permalink / raw)
To: qemu-devel
Cc: Andrew Jones, Ben Warren, Michael S. Tsirkin, Laszlo Ersek,
linuxarm, Shameer Kolothum, Shannon Zhao, Gonglei, Wei Yang,
xuwei5, xuwei5, Philippe Mathieu-Daudé
Instead of just asserting print the error that lead to assert first.
While at it move assert into rebuild branch, which removes redundant
check done in case of !rebuild branch is taken (the later is taken
care of by g_assert_no_error).
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Wei Yang <richardw.yang@linux.intel.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
v4:
* fix typo in commit message (Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>)
---
tests/bios-tables-test.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index eaa1b0c..6cb8b16 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -195,11 +195,14 @@ static void dump_aml_files(test_data *data, bool rebuild)
sdt->aml, ext);
fd = g_open(aml_file, O_WRONLY|O_TRUNC|O_CREAT,
S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH);
+ if (fd < 0) {
+ perror(aml_file);
+ }
+ g_assert(fd >= 0);
} else {
fd = g_file_open_tmp("aml-XXXXXX", &sdt->aml_file, &error);
g_assert_no_error(error);
}
- g_assert(fd >= 0);
ret = qemu_write_full(fd, sdt->aml, sdt->aml_len);
g_assert(ret == sdt->aml_len);
--
2.7.4
^ permalink raw reply related [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH v4 00/15] tests: acpi: add UEFI (ARM) testing support
@ 2019-05-02 15:16 ` Wei Xu
0 siblings, 0 replies; 289+ messages in thread
From: Wei Xu @ 2019-05-02 15:16 UTC (permalink / raw)
To: Igor Mammedov, qemu-devel
Cc: Laszlo Ersek, Michael S. Tsirkin, Gonglei,
Philippe Mathieu-Daudé,
Shannon Zhao, Wei Yang, Andrew Jones, Shameer Kolothum,
Ben Warren, xuwei5, linuxarm
Hi Ignor,
On 5/2/2019 3:51 PM, Igor Mammedov wrote:
> Changelog:
> - from v3:
> * reshaffle patch order a bit
> * move out acpi_parse_rsdp_table() hunk to
> "tests: acpi: make pointer to RSDP 64bit"
> where it belongs
> * move acpi_fetch_rsdp_table(s/uint32_t addr/uint64_t addr/) to
> this patch where it belongs from:
> "tests: acpi: make RSDT test routine handle XSDT"
> * dropping Reviewed-bys due to acpi_fetch_table() change
> introduced by earlier patch:
> "tests: acpi: make acpi_fetch_table() take size of fetched table pointer"
> * update [8/15] commit message to point to commit which introduced
> signature_guid value.
> * get rid of test_acpi_rsdp_address() in [9/15]
> * added new patch
> tests: acpi: allow to override default accelerator
> * force arm/virt test to use TCG accelerator
> - from v2:
> * rebase on top current master (with UEFI blobs merged)
> * added a Makefile rule to include bios-tables-test to aarch64 tests by
> default into 11/13 (kept Reviewed-bys)
> * other trivial fixes and cleanups (see per patch changelogs)
>
> - from v1:
> * rebase on top
> (1) [PATCH for-4.1 v3 00/12] bundle edk2 platform firmware with QEMU
> let me to drop edk2 images and drop Makefile magic to unpack them,
> Laszlo's series conveniently does it all for me.
> * use new path/names for firmware images as supplied by [1]
> * reorder patches a bit so that UEFI parts would go after generic changes
>
> Series adds support for ACPI tables located above 4G. It adds 64-bit handling
> necessary for testing arm/virt board (i.e. might be not complete wrt spec) and
> uses recently merged UEFI (AVMF) firmware/test disk image which provides
> an entry point[1] for fetching ACPI tables (RSDP pointer).
>
> Git tree for testing:
> https://github.com/imammedo/qemu.git acpi_arm_tests_v4
>
> Ref to previos vesrsion:
> [PATCH v3 00/13] tests: acpi: add UEFI (ARM) testing support
> https://www.mail-archive.com/qemu-devel@nongnu.org/msg612679.html
>
> CC: Laszlo Ersek <lersek@redhat.com>
> CC: "Michael S. Tsirkin" <mst@redhat.com>
> CC: Gonglei <arei.gonglei@huawei.com>
> CC: Philippe Mathieu-Daudé <philmd@redhat.com>
> CC: Shannon Zhao <shannon.zhaosl@gmail.com>
> CC: Wei Yang <richardw.yang@linux.intel.com>
> CC: Andrew Jones <drjones@redhat.com>
> CC: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
> CC: Ben Warren <ben@skyportsystems.com>
> CC: <xuwei5@hisilicon.com>
> CC: <xuwei5@huawei.com>
> CC: <shameerali.kolothum.thodi@huawei.com>
> CC: <linuxarm@huawei.com>
>
> Igor Mammedov (15):
> tests: acpi: rename acpi_parse_rsdp_table() into
> acpi_fetch_rsdp_table()
> tests: acpi: make acpi_fetch_table() take size of fetched table
> pointer
> tests: acpi: make RSDT test routine handle XSDT
> tests: acpi: make pointer to RSDP 64bit
> tests: acpi: fetch X_DSDT if pointer to DSDT is 0
> tests: acpi: skip FACS table if board uses hw reduced ACPI profile
> tests: acpi: move boot_sector_init() into x86 tests branch
> tests: acpi: add acpi_find_rsdp_address_uefi() helper
> tests: acpi: add a way to start tests with UEFI firmware
> tests: acpi: ignore SMBIOS tests when UEFI firmware is used
> tests: acpi: allow to override default accelerator
> tests: add expected ACPI tables for arm/virt board
> tests: acpi: add simple arm/virt testcase
> tests: acpi: refactor rebuild-expected-aml.sh to dump ACPI tables for
> a specified list of targets
> tests: acpi: print error unable to dump ACPI table during rebuild
>
> tests/acpi-utils.h | 7 +-
> tests/Makefile.include | 1 +
> tests/acpi-utils.c | 68 +++++++++++----
> tests/bios-tables-test.c | 148 +++++++++++++++++++++++---------
> tests/data/acpi/rebuild-expected-aml.sh | 23 +++--
> tests/data/acpi/virt/APIC | Bin 0 -> 168 bytes
> tests/data/acpi/virt/DSDT | Bin 0 -> 18476 bytes
> tests/data/acpi/virt/FACP | Bin 0 -> 268 bytes
> tests/data/acpi/virt/GTDT | Bin 0 -> 96 bytes
> tests/data/acpi/virt/MCFG | Bin 0 -> 60 bytes
> tests/data/acpi/virt/SPCR | Bin 0 -> 80 bytes
> tests/vmgenid-test.c | 6 +-
> 12 files changed, 178 insertions(+), 75 deletions(-)
> create mode 100644 tests/data/acpi/virt/APIC
> create mode 100644 tests/data/acpi/virt/DSDT
> create mode 100644 tests/data/acpi/virt/FACP
> create mode 100644 tests/data/acpi/virt/GTDT
> create mode 100644 tests/data/acpi/virt/MCFG
> create mode 100644 tests/data/acpi/virt/SPCR
>
Tested the series on the hisilicon D05 board(arm64 based), so FWIW:
Tested-by: Wei Xu <xuwei5@hisilicon.com>
Thanks!
Best Regards,
Wei
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH v4 00/15] tests: acpi: add UEFI (ARM) testing support
@ 2019-05-02 15:16 ` Wei Xu
0 siblings, 0 replies; 289+ messages in thread
From: Wei Xu @ 2019-05-02 15:16 UTC (permalink / raw)
To: Igor Mammedov, qemu-devel
Cc: Andrew Jones, Ben Warren, Michael S. Tsirkin, Laszlo Ersek,
linuxarm, Shameer Kolothum, Shannon Zhao, Gonglei, Wei Yang,
xuwei5, Philippe Mathieu-Daudé
Hi Ignor,
On 5/2/2019 3:51 PM, Igor Mammedov wrote:
> Changelog:
> - from v3:
> * reshaffle patch order a bit
> * move out acpi_parse_rsdp_table() hunk to
> "tests: acpi: make pointer to RSDP 64bit"
> where it belongs
> * move acpi_fetch_rsdp_table(s/uint32_t addr/uint64_t addr/) to
> this patch where it belongs from:
> "tests: acpi: make RSDT test routine handle XSDT"
> * dropping Reviewed-bys due to acpi_fetch_table() change
> introduced by earlier patch:
> "tests: acpi: make acpi_fetch_table() take size of fetched table pointer"
> * update [8/15] commit message to point to commit which introduced
> signature_guid value.
> * get rid of test_acpi_rsdp_address() in [9/15]
> * added new patch
> tests: acpi: allow to override default accelerator
> * force arm/virt test to use TCG accelerator
> - from v2:
> * rebase on top current master (with UEFI blobs merged)
> * added a Makefile rule to include bios-tables-test to aarch64 tests by
> default into 11/13 (kept Reviewed-bys)
> * other trivial fixes and cleanups (see per patch changelogs)
>
> - from v1:
> * rebase on top
> (1) [PATCH for-4.1 v3 00/12] bundle edk2 platform firmware with QEMU
> let me to drop edk2 images and drop Makefile magic to unpack them,
> Laszlo's series conveniently does it all for me.
> * use new path/names for firmware images as supplied by [1]
> * reorder patches a bit so that UEFI parts would go after generic changes
>
> Series adds support for ACPI tables located above 4G. It adds 64-bit handling
> necessary for testing arm/virt board (i.e. might be not complete wrt spec) and
> uses recently merged UEFI (AVMF) firmware/test disk image which provides
> an entry point[1] for fetching ACPI tables (RSDP pointer).
>
> Git tree for testing:
> https://github.com/imammedo/qemu.git acpi_arm_tests_v4
>
> Ref to previos vesrsion:
> [PATCH v3 00/13] tests: acpi: add UEFI (ARM) testing support
> https://www.mail-archive.com/qemu-devel@nongnu.org/msg612679.html
>
> CC: Laszlo Ersek <lersek@redhat.com>
> CC: "Michael S. Tsirkin" <mst@redhat.com>
> CC: Gonglei <arei.gonglei@huawei.com>
> CC: Philippe Mathieu-Daudé <philmd@redhat.com>
> CC: Shannon Zhao <shannon.zhaosl@gmail.com>
> CC: Wei Yang <richardw.yang@linux.intel.com>
> CC: Andrew Jones <drjones@redhat.com>
> CC: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
> CC: Ben Warren <ben@skyportsystems.com>
> CC: <xuwei5@hisilicon.com>
> CC: <xuwei5@huawei.com>
> CC: <shameerali.kolothum.thodi@huawei.com>
> CC: <linuxarm@huawei.com>
>
> Igor Mammedov (15):
> tests: acpi: rename acpi_parse_rsdp_table() into
> acpi_fetch_rsdp_table()
> tests: acpi: make acpi_fetch_table() take size of fetched table
> pointer
> tests: acpi: make RSDT test routine handle XSDT
> tests: acpi: make pointer to RSDP 64bit
> tests: acpi: fetch X_DSDT if pointer to DSDT is 0
> tests: acpi: skip FACS table if board uses hw reduced ACPI profile
> tests: acpi: move boot_sector_init() into x86 tests branch
> tests: acpi: add acpi_find_rsdp_address_uefi() helper
> tests: acpi: add a way to start tests with UEFI firmware
> tests: acpi: ignore SMBIOS tests when UEFI firmware is used
> tests: acpi: allow to override default accelerator
> tests: add expected ACPI tables for arm/virt board
> tests: acpi: add simple arm/virt testcase
> tests: acpi: refactor rebuild-expected-aml.sh to dump ACPI tables for
> a specified list of targets
> tests: acpi: print error unable to dump ACPI table during rebuild
>
> tests/acpi-utils.h | 7 +-
> tests/Makefile.include | 1 +
> tests/acpi-utils.c | 68 +++++++++++----
> tests/bios-tables-test.c | 148 +++++++++++++++++++++++---------
> tests/data/acpi/rebuild-expected-aml.sh | 23 +++--
> tests/data/acpi/virt/APIC | Bin 0 -> 168 bytes
> tests/data/acpi/virt/DSDT | Bin 0 -> 18476 bytes
> tests/data/acpi/virt/FACP | Bin 0 -> 268 bytes
> tests/data/acpi/virt/GTDT | Bin 0 -> 96 bytes
> tests/data/acpi/virt/MCFG | Bin 0 -> 60 bytes
> tests/data/acpi/virt/SPCR | Bin 0 -> 80 bytes
> tests/vmgenid-test.c | 6 +-
> 12 files changed, 178 insertions(+), 75 deletions(-)
> create mode 100644 tests/data/acpi/virt/APIC
> create mode 100644 tests/data/acpi/virt/DSDT
> create mode 100644 tests/data/acpi/virt/FACP
> create mode 100644 tests/data/acpi/virt/GTDT
> create mode 100644 tests/data/acpi/virt/MCFG
> create mode 100644 tests/data/acpi/virt/SPCR
>
Tested the series on the hisilicon D05 board(arm64 based), so FWIW:
Tested-by: Wei Xu <xuwei5@hisilicon.com>
Thanks!
Best Regards,
Wei
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH v4 11/15] tests: acpi: allow to override default accelerator
2019-05-02 14:51 ` [Qemu-devel] [PATCH v4 11/15] " Igor Mammedov
` (2 preceding siblings ...)
(?)
@ 2019-05-02 18:36 ` Laszlo Ersek
-1 siblings, 0 replies; 289+ messages in thread
From: Laszlo Ersek @ 2019-05-02 18:36 UTC (permalink / raw)
To: Igor Mammedov, qemu-devel
Cc: Andrew Jones, Ben Warren, Michael S. Tsirkin, linuxarm,
Shameer Kolothum, Shannon Zhao, Gonglei, Wei Yang, xuwei5,
xuwei5, Philippe Mathieu-Daudé
On 05/02/19 16:51, Igor Mammedov wrote:
> By default test cases were run with 'kvm:tcg' accelerators to speed up
> tests execution. While it works for x86, were change of accelerator
> doesn't affect ACPI tables, the approach doesn't works for ARM usecase
> though.
>
> In arm/virt case, KVM mode requires using 'host' cpu model, which
> isn't available in TCG mode. That could be worked around with 'max'
> cpu model, which works both for KVM and TCG. However in KVM mode it
> is necessary to specify matching GIC version, which also could use
> 'max' value to automatically pick GIC version suitable for host's CPU.
> Depending on host cpu type, different GIC versions would be used,
> which in turn leads to different ACPI tables (APIC) generated.
> As result while comparing with reference blobs, test would fail if
> host's GIC version won't match the version on the host where
> reference blobs where generated.
>
> Let's keep testing simple for now and allow ARM tests run in TCG only
> mode. To do so introduce 'accel' parameter in test configuration, so
> test case could override default "kvm:tcg" with accelerator of choice.
>
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
> tests/bios-tables-test.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
> index 8302ffc..39c1e24 100644
> --- a/tests/bios-tables-test.c
> +++ b/tests/bios-tables-test.c
> @@ -24,6 +24,7 @@
> #define ACPI_REBUILD_EXPECTED_AML "TEST_ACPI_REBUILD_AML"
>
> typedef struct {
> + const char *accel;
> const char *machine;
> const char *variant;
> const char *uefi_fl1;
> @@ -532,8 +533,8 @@ static void test_acpi_one(const char *params, test_data *data)
> args = g_strdup_printf("-machine %s,accel=%s -nodefaults -nographic "
> "-drive if=pflash,format=raw,file=%s,readonly "
> "-drive if=pflash,format=raw,file=%s,snapshot=on -cdrom %s %s",
> - data->machine, "kvm:tcg", data->uefi_fl1, data->uefi_fl2,
> - data->cd, params ? params : "");
> + data->machine, data->accel ? data->accel : "kvm:tcg",
> + data->uefi_fl1, data->uefi_fl2, data->cd, params ? params : "");
>
> } else {
> /* Disable kernel irqchip to be able to override apic irq0. */
> @@ -541,7 +542,8 @@ static void test_acpi_one(const char *params, test_data *data)
> "-net none -display none %s "
> "-drive id=hd0,if=none,file=%s,format=raw "
> "-device ide-hd,drive=hd0 ",
> - data->machine, "kvm:tcg", params ? params : "", disk);
> + data->machine, data->accel ? data->accel : "kvm:tcg",
> + params ? params : "", disk);
> }
>
> data->qts = qtest_init(args);
>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH v4 13/15] tests: acpi: add simple arm/virt testcase
2019-05-02 14:52 ` [Qemu-devel] [PATCH v4 13/15] " Igor Mammedov
` (2 preceding siblings ...)
(?)
@ 2019-05-02 18:38 ` Laszlo Ersek
-1 siblings, 0 replies; 289+ messages in thread
From: Laszlo Ersek @ 2019-05-02 18:38 UTC (permalink / raw)
To: Igor Mammedov, qemu-devel
Cc: Andrew Jones, Ben Warren, Michael S. Tsirkin, linuxarm,
Shameer Kolothum, Shannon Zhao, Gonglei, Wei Yang, xuwei5,
xuwei5, Philippe Mathieu-Daudé
On 05/02/19 16:52, Igor Mammedov wrote:
> adds simple arm/virt test case that starts guest with
> bios-tables-test.aarch64.iso.qcow2 boot image which
> initializes UefiTestSupport* structure in RAM once
> guest is booted.
>
> * see commit: tests: acpi: add acpi_find_rsdp_address_uefi() helper
>
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> v4:
> * force test to use TCG accelerator
> v3:
> * use firmware blobs directly from pc-bios directory
> * use bios-tables-test.aarch64.iso.qcow2 as test boot image
> * drop leftover qtest-uefi-images-aarch64 iMakefile rule from
> previos version (Laszlo)
> * add Makefile rule to include bios-tables-test into
> check-qtest-aarch64 target
> v2:
> * specify in test_data where board's RAM starts and RAM size
>
> fixup! tests: acpi: add simple arm/virt testcase
>
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
> tests/Makefile.include | 1 +
> tests/bios-tables-test.c | 18 ++++++++++++++++++
> 2 files changed, 19 insertions(+)
>
> diff --git a/tests/Makefile.include b/tests/Makefile.include
> index e2432d5..983c8b1 100644
> --- a/tests/Makefile.include
> +++ b/tests/Makefile.include
> @@ -267,6 +267,7 @@ check-qtest-arm-y += tests/hexloader-test$(EXESUF)
> check-qtest-aarch64-y = tests/numa-test$(EXESUF)
> check-qtest-aarch64-y += tests/boot-serial-test$(EXESUF)
> check-qtest-aarch64-y += tests/migration-test$(EXESUF)
> +check-qtest-aarch64-y += tests/bios-tables-test$(EXESUF)
>
> check-qtest-microblazeel-y += $(check-qtest-microblaze-y)
>
> diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
> index 39c1e24..eaa1b0c 100644
> --- a/tests/bios-tables-test.c
> +++ b/tests/bios-tables-test.c
> @@ -810,6 +810,22 @@ static void test_acpi_piix4_tcg_dimm_pxm(void)
> test_acpi_tcg_dimm_pxm(MACHINE_PC);
> }
>
> +static void test_acpi_virt_tcg(void)
> +{
> + test_data data = {
> + .machine = "virt",
> + .accel = "tcg",
> + .uefi_fl1 = "pc-bios/edk2-aarch64-code.fd",
> + .uefi_fl2 = "pc-bios/edk2-arm-vars.fd",
> + .cd = "tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2",
> + .ram_start = 0x40000000ULL,
> + .scan_len = 128ULL * 1024 * 1024,
> + };
> +
> + test_acpi_one("-cpu cortex-a57", &data);
> + free_test_data(&data);
> +}
> +
> int main(int argc, char *argv[])
> {
> const char *arch = qtest_get_arch();
> @@ -838,6 +854,8 @@ int main(int argc, char *argv[])
> qtest_add_func("acpi/q35/numamem", test_acpi_q35_tcg_numamem);
> qtest_add_func("acpi/piix4/dimmpxm", test_acpi_piix4_tcg_dimm_pxm);
> qtest_add_func("acpi/q35/dimmpxm", test_acpi_q35_tcg_dimm_pxm);
> + } else if (strcmp(arch, "aarch64") == 0) {
> + qtest_add_func("acpi/virt", test_acpi_virt_tcg);
> }
> ret = g_test_run();
> boot_sector_cleanup(disk);
>
my R-b stands
thanks
Laszlo
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH v4 02/15] tests: acpi: make acpi_fetch_table() take size of fetched table pointer
@ 2019-05-05 0:58 ` Wei Yang
0 siblings, 0 replies; 289+ messages in thread
From: Wei Yang @ 2019-05-05 0:58 UTC (permalink / raw)
To: Igor Mammedov
Cc: qemu-devel, Laszlo Ersek, Michael S. Tsirkin, Gonglei,
Philippe Mathieu-Daudé,
Shannon Zhao, Wei Yang, Andrew Jones, Shameer Kolothum,
Ben Warren, xuwei5, xuwei5, linuxarm
On Thu, May 02, 2019 at 04:51:50PM +0200, Igor Mammedov wrote:
>Currently acpi_fetch_table() assumes 32 bit size of table pointer
>in ACPI tables. However X_foo variants are 64 bit, prepare
>acpi_fetch_table() to handle both by adding an argument
>for addr_ptr pointed entry size. Follow up commits will use that
>to read XSDT and X_foo entries in ACPI tables.
>
>Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Wei Yang <richardw.yang@linux.intel.com>
>---
> tests/acpi-utils.h | 2 +-
> tests/acpi-utils.c | 10 ++++++----
> tests/bios-tables-test.c | 8 ++++----
> tests/vmgenid-test.c | 4 ++--
> 4 files changed, 13 insertions(+), 11 deletions(-)
>
>diff --git a/tests/acpi-utils.h b/tests/acpi-utils.h
>index 4cd5553..92285b7 100644
>--- a/tests/acpi-utils.h
>+++ b/tests/acpi-utils.h
>@@ -49,7 +49,7 @@ uint32_t acpi_find_rsdp_address(QTestState *qts);
> uint64_t acpi_get_xsdt_address(uint8_t *rsdp_table);
> void acpi_fetch_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table);
> void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
>- const uint8_t *addr_ptr, const char *sig,
>+ const uint8_t *addr_ptr, int addr_size, const char *sig,
> bool verify_checksum);
>
> #endif /* TEST_ACPI_UTILS_H */
>diff --git a/tests/acpi-utils.c b/tests/acpi-utils.c
>index 633d8f5..644c87b 100644
>--- a/tests/acpi-utils.c
>+++ b/tests/acpi-utils.c
>@@ -91,13 +91,15 @@ void acpi_fetch_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table)
> * actual one.
> */
> void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
>- const uint8_t *addr_ptr, const char *sig,
>+ const uint8_t *addr_ptr, int addr_size, const char *sig,
> bool verify_checksum)
> {
>- uint32_t addr, len;
>+ uint32_t len;
>+ uint64_t addr = 0;
>
>- memcpy(&addr, addr_ptr , sizeof(addr));
>- addr = le32_to_cpu(addr);
>+ g_assert(addr_size == 4 || addr_size == 8);
>+ memcpy(&addr, addr_ptr , addr_size);
>+ addr = le64_to_cpu(addr);
> qtest_memread(qts, addr + 4, &len, 4); /* Length of ACPI table */
> *aml_len = le32_to_cpu(len);
> *aml = g_malloc0(*aml_len);
>diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
>index 6a678bf..86b592c 100644
>--- a/tests/bios-tables-test.c
>+++ b/tests/bios-tables-test.c
>@@ -114,14 +114,14 @@ static void test_acpi_rsdt_table(test_data *data)
>
> /* read RSDT table */
> acpi_fetch_table(data->qts, &rsdt.aml, &rsdt.aml_len,
>- &data->rsdp_table[16 /* RsdtAddress */], "RSDT", true);
>+ &data->rsdp_table[16 /* RsdtAddress */], 4, "RSDT", true);
>
> /* Load all tables and add to test list directly RSDT referenced tables */
> ACPI_FOREACH_RSDT_ENTRY(rsdt.aml, rsdt.aml_len, ent, 4 /* Entry size */) {
> AcpiSdtTable ssdt_table = {};
>
> acpi_fetch_table(data->qts, &ssdt_table.aml, &ssdt_table.aml_len, ent,
>- NULL, true);
>+ 4, NULL, true);
> /* Add table to ASL test tables list */
> g_array_append_val(data->tables, ssdt_table);
> }
>@@ -139,11 +139,11 @@ static void test_acpi_fadt_table(test_data *data)
>
> /* Since DSDT/FACS isn't in RSDT, add them to ASL test list manually */
> acpi_fetch_table(data->qts, &table.aml, &table.aml_len,
>- fadt_aml + 36 /* FIRMWARE_CTRL */, "FACS", false);
>+ fadt_aml + 36 /* FIRMWARE_CTRL */, 4, "FACS", false);
> g_array_append_val(data->tables, table);
>
> acpi_fetch_table(data->qts, &table.aml, &table.aml_len,
>- fadt_aml + 40 /* DSDT */, "DSDT", true);
>+ fadt_aml + 40 /* DSDT */, 4, "DSDT", true);
> g_array_append_val(data->tables, table);
>
> memset(fadt_aml + 36, 0, 4); /* sanitize FIRMWARE_CTRL ptr */
>diff --git a/tests/vmgenid-test.c b/tests/vmgenid-test.c
>index f400184..85d8e64 100644
>--- a/tests/vmgenid-test.c
>+++ b/tests/vmgenid-test.c
>@@ -42,12 +42,12 @@ static uint32_t acpi_find_vgia(QTestState *qts)
>
> acpi_fetch_rsdp_table(qts, rsdp_offset, rsdp_table);
> acpi_fetch_table(qts, &rsdt, &rsdt_len, &rsdp_table[16 /* RsdtAddress */],
>- "RSDT", true);
>+ 4, "RSDT", true);
>
> ACPI_FOREACH_RSDT_ENTRY(rsdt, rsdt_len, ent, 4 /* Entry size */) {
> uint8_t *table_aml;
>
>- acpi_fetch_table(qts, &table_aml, &table_length, ent, NULL, true);
>+ acpi_fetch_table(qts, &table_aml, &table_length, ent, 4, NULL, true);
> if (!memcmp(table_aml + 16 /* OEM Table ID */, "VMGENID", 7)) {
> uint32_t vgia_val;
> uint8_t *aml = &table_aml[36 /* AML byte-code start */];
>--
>2.7.4
--
Wei Yang
Help you, Help me
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH v4 02/15] tests: acpi: make acpi_fetch_table() take size of fetched table pointer
@ 2019-05-05 0:58 ` Wei Yang
0 siblings, 0 replies; 289+ messages in thread
From: Wei Yang @ 2019-05-05 0:58 UTC (permalink / raw)
To: Igor Mammedov
Cc: Andrew Jones, Ben Warren, Michael S. Tsirkin, Laszlo Ersek,
qemu-devel, Shameer Kolothum, linuxarm, Shannon Zhao, Gonglei,
Wei Yang, xuwei5, xuwei5, Philippe Mathieu-Daudé
On Thu, May 02, 2019 at 04:51:50PM +0200, Igor Mammedov wrote:
>Currently acpi_fetch_table() assumes 32 bit size of table pointer
>in ACPI tables. However X_foo variants are 64 bit, prepare
>acpi_fetch_table() to handle both by adding an argument
>for addr_ptr pointed entry size. Follow up commits will use that
>to read XSDT and X_foo entries in ACPI tables.
>
>Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Wei Yang <richardw.yang@linux.intel.com>
>---
> tests/acpi-utils.h | 2 +-
> tests/acpi-utils.c | 10 ++++++----
> tests/bios-tables-test.c | 8 ++++----
> tests/vmgenid-test.c | 4 ++--
> 4 files changed, 13 insertions(+), 11 deletions(-)
>
>diff --git a/tests/acpi-utils.h b/tests/acpi-utils.h
>index 4cd5553..92285b7 100644
>--- a/tests/acpi-utils.h
>+++ b/tests/acpi-utils.h
>@@ -49,7 +49,7 @@ uint32_t acpi_find_rsdp_address(QTestState *qts);
> uint64_t acpi_get_xsdt_address(uint8_t *rsdp_table);
> void acpi_fetch_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table);
> void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
>- const uint8_t *addr_ptr, const char *sig,
>+ const uint8_t *addr_ptr, int addr_size, const char *sig,
> bool verify_checksum);
>
> #endif /* TEST_ACPI_UTILS_H */
>diff --git a/tests/acpi-utils.c b/tests/acpi-utils.c
>index 633d8f5..644c87b 100644
>--- a/tests/acpi-utils.c
>+++ b/tests/acpi-utils.c
>@@ -91,13 +91,15 @@ void acpi_fetch_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table)
> * actual one.
> */
> void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
>- const uint8_t *addr_ptr, const char *sig,
>+ const uint8_t *addr_ptr, int addr_size, const char *sig,
> bool verify_checksum)
> {
>- uint32_t addr, len;
>+ uint32_t len;
>+ uint64_t addr = 0;
>
>- memcpy(&addr, addr_ptr , sizeof(addr));
>- addr = le32_to_cpu(addr);
>+ g_assert(addr_size == 4 || addr_size == 8);
>+ memcpy(&addr, addr_ptr , addr_size);
>+ addr = le64_to_cpu(addr);
> qtest_memread(qts, addr + 4, &len, 4); /* Length of ACPI table */
> *aml_len = le32_to_cpu(len);
> *aml = g_malloc0(*aml_len);
>diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
>index 6a678bf..86b592c 100644
>--- a/tests/bios-tables-test.c
>+++ b/tests/bios-tables-test.c
>@@ -114,14 +114,14 @@ static void test_acpi_rsdt_table(test_data *data)
>
> /* read RSDT table */
> acpi_fetch_table(data->qts, &rsdt.aml, &rsdt.aml_len,
>- &data->rsdp_table[16 /* RsdtAddress */], "RSDT", true);
>+ &data->rsdp_table[16 /* RsdtAddress */], 4, "RSDT", true);
>
> /* Load all tables and add to test list directly RSDT referenced tables */
> ACPI_FOREACH_RSDT_ENTRY(rsdt.aml, rsdt.aml_len, ent, 4 /* Entry size */) {
> AcpiSdtTable ssdt_table = {};
>
> acpi_fetch_table(data->qts, &ssdt_table.aml, &ssdt_table.aml_len, ent,
>- NULL, true);
>+ 4, NULL, true);
> /* Add table to ASL test tables list */
> g_array_append_val(data->tables, ssdt_table);
> }
>@@ -139,11 +139,11 @@ static void test_acpi_fadt_table(test_data *data)
>
> /* Since DSDT/FACS isn't in RSDT, add them to ASL test list manually */
> acpi_fetch_table(data->qts, &table.aml, &table.aml_len,
>- fadt_aml + 36 /* FIRMWARE_CTRL */, "FACS", false);
>+ fadt_aml + 36 /* FIRMWARE_CTRL */, 4, "FACS", false);
> g_array_append_val(data->tables, table);
>
> acpi_fetch_table(data->qts, &table.aml, &table.aml_len,
>- fadt_aml + 40 /* DSDT */, "DSDT", true);
>+ fadt_aml + 40 /* DSDT */, 4, "DSDT", true);
> g_array_append_val(data->tables, table);
>
> memset(fadt_aml + 36, 0, 4); /* sanitize FIRMWARE_CTRL ptr */
>diff --git a/tests/vmgenid-test.c b/tests/vmgenid-test.c
>index f400184..85d8e64 100644
>--- a/tests/vmgenid-test.c
>+++ b/tests/vmgenid-test.c
>@@ -42,12 +42,12 @@ static uint32_t acpi_find_vgia(QTestState *qts)
>
> acpi_fetch_rsdp_table(qts, rsdp_offset, rsdp_table);
> acpi_fetch_table(qts, &rsdt, &rsdt_len, &rsdp_table[16 /* RsdtAddress */],
>- "RSDT", true);
>+ 4, "RSDT", true);
>
> ACPI_FOREACH_RSDT_ENTRY(rsdt, rsdt_len, ent, 4 /* Entry size */) {
> uint8_t *table_aml;
>
>- acpi_fetch_table(qts, &table_aml, &table_length, ent, NULL, true);
>+ acpi_fetch_table(qts, &table_aml, &table_length, ent, 4, NULL, true);
> if (!memcmp(table_aml + 16 /* OEM Table ID */, "VMGENID", 7)) {
> uint32_t vgia_val;
> uint8_t *aml = &table_aml[36 /* AML byte-code start */];
>--
>2.7.4
--
Wei Yang
Help you, Help me
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH v4 03/15] tests: acpi: make RSDT test routine handle XSDT
@ 2019-05-05 1:14 ` Wei Yang
0 siblings, 0 replies; 289+ messages in thread
From: Wei Yang @ 2019-05-05 1:14 UTC (permalink / raw)
To: Igor Mammedov
Cc: qemu-devel, Laszlo Ersek, Michael S. Tsirkin, Gonglei,
Philippe Mathieu-Daudé,
Shannon Zhao, Wei Yang, Andrew Jones, Shameer Kolothum,
Ben Warren, xuwei5, xuwei5, linuxarm
On Thu, May 02, 2019 at 04:51:51PM +0200, Igor Mammedov wrote:
>If RSDP revision is more than 0 fetch table pointed by XSDT
>and fallback to legacy RSDT table otherwise.
>
>While at it drop unused acpi_get_xsdt_address().
>
>Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Wei Yang <richardw.yang@linux.intel.com>
>---
>PS:
> it doesn't affect existing pc/q35 machines as they use RSDP.revision == 0
> but it will be used by followup patch to enable testing arm/virt
> board which uses provides XSDT table.
>
>v4:
> * move out acpi_parse_rsdp_table() hunk to
> "tests: acpi: make pointer to RSDP 64bit"
> where it belongs
>---
> tests/acpi-utils.h | 1 -
> tests/acpi-utils.c | 12 ------------
> tests/bios-tables-test.c | 20 ++++++++++++++------
> 3 files changed, 14 insertions(+), 19 deletions(-)
>
>diff --git a/tests/acpi-utils.h b/tests/acpi-utils.h
>index 92285b7..f55ccf9 100644
>--- a/tests/acpi-utils.h
>+++ b/tests/acpi-utils.h
>@@ -46,7 +46,6 @@ typedef struct {
>
> uint8_t acpi_calc_checksum(const uint8_t *data, int len);
> uint32_t acpi_find_rsdp_address(QTestState *qts);
>-uint64_t acpi_get_xsdt_address(uint8_t *rsdp_table);
> void acpi_fetch_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table);
> void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
> const uint8_t *addr_ptr, int addr_size, const char *sig,
>diff --git a/tests/acpi-utils.c b/tests/acpi-utils.c
>index 644c87b..a0d49c4 100644
>--- a/tests/acpi-utils.c
>+++ b/tests/acpi-utils.c
>@@ -51,18 +51,6 @@ uint32_t acpi_find_rsdp_address(QTestState *qts)
> return off;
> }
>
>-uint64_t acpi_get_xsdt_address(uint8_t *rsdp_table)
>-{
>- uint64_t xsdt_physical_address;
>- uint8_t revision = rsdp_table[15 /* Revision offset */];
>-
>- /* We must have revision 2 if we're looking for an XSDT pointer */
>- g_assert(revision == 2);
>-
>- memcpy(&xsdt_physical_address, &rsdp_table[24 /* XsdtAddress offset */], 8);
>- return le64_to_cpu(xsdt_physical_address);
>-}
>-
> void acpi_fetch_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table)
> {
> uint8_t revision;
>diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
>index 86b592c..d6ab121 100644
>--- a/tests/bios-tables-test.c
>+++ b/tests/bios-tables-test.c
>@@ -107,21 +107,29 @@ static void test_acpi_rsdp_table(test_data *data)
> }
> }
>
>-static void test_acpi_rsdt_table(test_data *data)
>+static void test_acpi_rxsdt_table(test_data *data)
> {
>+ const char *sig = "RSDT";
> AcpiSdtTable rsdt = {};
>+ int entry_size = 4;
>+ int addr_off = 16 /* RsdtAddress */;
> uint8_t *ent;
>
>- /* read RSDT table */
>+ if (data->rsdp_table[15 /* Revision offset */] != 0) {
>+ addr_off = 24 /* XsdtAddress */;
>+ entry_size = 8;
>+ sig = "XSDT";
>+ }
>+ /* read [RX]SDT table */
> acpi_fetch_table(data->qts, &rsdt.aml, &rsdt.aml_len,
>- &data->rsdp_table[16 /* RsdtAddress */], 4, "RSDT", true);
>+ &data->rsdp_table[addr_off], entry_size, sig, true);
>
> /* Load all tables and add to test list directly RSDT referenced tables */
>- ACPI_FOREACH_RSDT_ENTRY(rsdt.aml, rsdt.aml_len, ent, 4 /* Entry size */) {
>+ ACPI_FOREACH_RSDT_ENTRY(rsdt.aml, rsdt.aml_len, ent, entry_size) {
> AcpiSdtTable ssdt_table = {};
>
> acpi_fetch_table(data->qts, &ssdt_table.aml, &ssdt_table.aml_len, ent,
>- 4, NULL, true);
>+ entry_size, NULL, true);
> /* Add table to ASL test tables list */
> g_array_append_val(data->tables, ssdt_table);
> }
>@@ -521,7 +529,7 @@ static void test_acpi_one(const char *params, test_data *data)
> data->tables = g_array_new(false, true, sizeof(AcpiSdtTable));
> test_acpi_rsdp_address(data);
> test_acpi_rsdp_table(data);
>- test_acpi_rsdt_table(data);
>+ test_acpi_rxsdt_table(data);
> test_acpi_fadt_table(data);
>
> if (iasl) {
>--
>2.7.4
--
Wei Yang
Help you, Help me
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH v4 03/15] tests: acpi: make RSDT test routine handle XSDT
@ 2019-05-05 1:14 ` Wei Yang
0 siblings, 0 replies; 289+ messages in thread
From: Wei Yang @ 2019-05-05 1:14 UTC (permalink / raw)
To: Igor Mammedov
Cc: Andrew Jones, Ben Warren, Michael S. Tsirkin, Laszlo Ersek,
qemu-devel, Shameer Kolothum, linuxarm, Shannon Zhao, Gonglei,
Wei Yang, xuwei5, xuwei5, Philippe Mathieu-Daudé
On Thu, May 02, 2019 at 04:51:51PM +0200, Igor Mammedov wrote:
>If RSDP revision is more than 0 fetch table pointed by XSDT
>and fallback to legacy RSDT table otherwise.
>
>While at it drop unused acpi_get_xsdt_address().
>
>Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Wei Yang <richardw.yang@linux.intel.com>
>---
>PS:
> it doesn't affect existing pc/q35 machines as they use RSDP.revision == 0
> but it will be used by followup patch to enable testing arm/virt
> board which uses provides XSDT table.
>
>v4:
> * move out acpi_parse_rsdp_table() hunk to
> "tests: acpi: make pointer to RSDP 64bit"
> where it belongs
>---
> tests/acpi-utils.h | 1 -
> tests/acpi-utils.c | 12 ------------
> tests/bios-tables-test.c | 20 ++++++++++++++------
> 3 files changed, 14 insertions(+), 19 deletions(-)
>
>diff --git a/tests/acpi-utils.h b/tests/acpi-utils.h
>index 92285b7..f55ccf9 100644
>--- a/tests/acpi-utils.h
>+++ b/tests/acpi-utils.h
>@@ -46,7 +46,6 @@ typedef struct {
>
> uint8_t acpi_calc_checksum(const uint8_t *data, int len);
> uint32_t acpi_find_rsdp_address(QTestState *qts);
>-uint64_t acpi_get_xsdt_address(uint8_t *rsdp_table);
> void acpi_fetch_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table);
> void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
> const uint8_t *addr_ptr, int addr_size, const char *sig,
>diff --git a/tests/acpi-utils.c b/tests/acpi-utils.c
>index 644c87b..a0d49c4 100644
>--- a/tests/acpi-utils.c
>+++ b/tests/acpi-utils.c
>@@ -51,18 +51,6 @@ uint32_t acpi_find_rsdp_address(QTestState *qts)
> return off;
> }
>
>-uint64_t acpi_get_xsdt_address(uint8_t *rsdp_table)
>-{
>- uint64_t xsdt_physical_address;
>- uint8_t revision = rsdp_table[15 /* Revision offset */];
>-
>- /* We must have revision 2 if we're looking for an XSDT pointer */
>- g_assert(revision == 2);
>-
>- memcpy(&xsdt_physical_address, &rsdp_table[24 /* XsdtAddress offset */], 8);
>- return le64_to_cpu(xsdt_physical_address);
>-}
>-
> void acpi_fetch_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table)
> {
> uint8_t revision;
>diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
>index 86b592c..d6ab121 100644
>--- a/tests/bios-tables-test.c
>+++ b/tests/bios-tables-test.c
>@@ -107,21 +107,29 @@ static void test_acpi_rsdp_table(test_data *data)
> }
> }
>
>-static void test_acpi_rsdt_table(test_data *data)
>+static void test_acpi_rxsdt_table(test_data *data)
> {
>+ const char *sig = "RSDT";
> AcpiSdtTable rsdt = {};
>+ int entry_size = 4;
>+ int addr_off = 16 /* RsdtAddress */;
> uint8_t *ent;
>
>- /* read RSDT table */
>+ if (data->rsdp_table[15 /* Revision offset */] != 0) {
>+ addr_off = 24 /* XsdtAddress */;
>+ entry_size = 8;
>+ sig = "XSDT";
>+ }
>+ /* read [RX]SDT table */
> acpi_fetch_table(data->qts, &rsdt.aml, &rsdt.aml_len,
>- &data->rsdp_table[16 /* RsdtAddress */], 4, "RSDT", true);
>+ &data->rsdp_table[addr_off], entry_size, sig, true);
>
> /* Load all tables and add to test list directly RSDT referenced tables */
>- ACPI_FOREACH_RSDT_ENTRY(rsdt.aml, rsdt.aml_len, ent, 4 /* Entry size */) {
>+ ACPI_FOREACH_RSDT_ENTRY(rsdt.aml, rsdt.aml_len, ent, entry_size) {
> AcpiSdtTable ssdt_table = {};
>
> acpi_fetch_table(data->qts, &ssdt_table.aml, &ssdt_table.aml_len, ent,
>- 4, NULL, true);
>+ entry_size, NULL, true);
> /* Add table to ASL test tables list */
> g_array_append_val(data->tables, ssdt_table);
> }
>@@ -521,7 +529,7 @@ static void test_acpi_one(const char *params, test_data *data)
> data->tables = g_array_new(false, true, sizeof(AcpiSdtTable));
> test_acpi_rsdp_address(data);
> test_acpi_rsdp_table(data);
>- test_acpi_rsdt_table(data);
>+ test_acpi_rxsdt_table(data);
> test_acpi_fadt_table(data);
>
> if (iasl) {
>--
>2.7.4
--
Wei Yang
Help you, Help me
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH v4 04/15] tests: acpi: make pointer to RSDP 64bit
@ 2019-05-05 1:18 ` Wei Yang
0 siblings, 0 replies; 289+ messages in thread
From: Wei Yang @ 2019-05-05 1:18 UTC (permalink / raw)
To: Igor Mammedov
Cc: qemu-devel, Laszlo Ersek, Michael S. Tsirkin, Gonglei,
Philippe Mathieu-Daudé,
Shannon Zhao, Wei Yang, Andrew Jones, Shameer Kolothum,
Ben Warren, xuwei5, xuwei5, linuxarm
On Thu, May 02, 2019 at 04:51:52PM +0200, Igor Mammedov wrote:
>In case of UEFI, RSDP doesn't have to be located in lowmem,
>it could be placed at any address. Make sure that test won't
>break if it is placed above the first 4Gb of address space.
>
>PS:
>While at it cleanup some local variables as we don't really
>need them.
>
>Signed-off-by: Igor Mammedov <imammedo@redhat.com>
>Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Wei Yang <richardw.yang@linux.intel.com>
>---
>v4:
> - move acpi_fetch_rsdp_table(s/uint32_t addr/uint64_t addr/) to
> this patch where it belongs from
> "tests: acpi: make RSDT test routine handle XSDT"
> (Wei Yang <richardw.yang@linux.intel.com>)
>v2:
> - s/In case of UEFI/In case of UEFI,/ (Laszlo Ersek <lersek@redhat.com>)
>---
> tests/acpi-utils.h | 2 +-
> tests/acpi-utils.c | 2 +-
> tests/bios-tables-test.c | 10 ++++------
> 3 files changed, 6 insertions(+), 8 deletions(-)
>
>diff --git a/tests/acpi-utils.h b/tests/acpi-utils.h
>index f55ccf9..1da6c10 100644
>--- a/tests/acpi-utils.h
>+++ b/tests/acpi-utils.h
>@@ -46,7 +46,7 @@ typedef struct {
>
> uint8_t acpi_calc_checksum(const uint8_t *data, int len);
> uint32_t acpi_find_rsdp_address(QTestState *qts);
>-void acpi_fetch_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table);
>+void acpi_fetch_rsdp_table(QTestState *qts, uint64_t addr, uint8_t *rsdp_table);
> void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
> const uint8_t *addr_ptr, int addr_size, const char *sig,
> bool verify_checksum);
>diff --git a/tests/acpi-utils.c b/tests/acpi-utils.c
>index a0d49c4..c216b9e 100644
>--- a/tests/acpi-utils.c
>+++ b/tests/acpi-utils.c
>@@ -51,7 +51,7 @@ uint32_t acpi_find_rsdp_address(QTestState *qts)
> return off;
> }
>
>-void acpi_fetch_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table)
>+void acpi_fetch_rsdp_table(QTestState *qts, uint64_t addr, uint8_t *rsdp_table)
> {
> uint8_t revision;
>
>diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
>index d6ab121..a164d27 100644
>--- a/tests/bios-tables-test.c
>+++ b/tests/bios-tables-test.c
>@@ -26,7 +26,7 @@
> typedef struct {
> const char *machine;
> const char *variant;
>- uint32_t rsdp_addr;
>+ uint64_t rsdp_addr;
> uint8_t rsdp_table[36 /* ACPI 2.0+ RSDP size */];
> GArray *tables;
> uint32_t smbios_ep_addr;
>@@ -86,13 +86,11 @@ static void test_acpi_rsdp_address(test_data *data)
>
> static void test_acpi_rsdp_table(test_data *data)
> {
>- uint8_t *rsdp_table = data->rsdp_table, revision;
>- uint32_t addr = data->rsdp_addr;
>+ uint8_t *rsdp_table = data->rsdp_table;
>
>- acpi_fetch_rsdp_table(data->qts, addr, rsdp_table);
>- revision = rsdp_table[15 /* Revision offset */];
>+ acpi_fetch_rsdp_table(data->qts, data->rsdp_addr, rsdp_table);
>
>- switch (revision) {
>+ switch (rsdp_table[15 /* Revision offset */]) {
> case 0: /* ACPI 1.0 RSDP */
> /* With rev 1, checksum is only for the first 20 bytes */
> g_assert(!acpi_calc_checksum(rsdp_table, 20));
>--
>2.7.4
--
Wei Yang
Help you, Help me
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH v4 04/15] tests: acpi: make pointer to RSDP 64bit
@ 2019-05-05 1:18 ` Wei Yang
0 siblings, 0 replies; 289+ messages in thread
From: Wei Yang @ 2019-05-05 1:18 UTC (permalink / raw)
To: Igor Mammedov
Cc: Andrew Jones, Ben Warren, Michael S. Tsirkin, Laszlo Ersek,
qemu-devel, Shameer Kolothum, linuxarm, Shannon Zhao, Gonglei,
Wei Yang, xuwei5, xuwei5, Philippe Mathieu-Daudé
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="UTF-8", Size: 3202 bytes --]
On Thu, May 02, 2019 at 04:51:52PM +0200, Igor Mammedov wrote:
>In case of UEFI, RSDP doesn't have to be located in lowmem,
>it could be placed at any address. Make sure that test won't
>break if it is placed above the first 4Gb of address space.
>
>PS:
>While at it cleanup some local variables as we don't really
>need them.
>
>Signed-off-by: Igor Mammedov <imammedo@redhat.com>
>Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Wei Yang <richardw.yang@linux.intel.com>
>---
>v4:
> - move acpi_fetch_rsdp_table(s/uint32_t addr/uint64_t addr/) to
> this patch where it belongs from
> "tests: acpi: make RSDT test routine handle XSDT"
> (Wei Yang <richardw.yang@linux.intel.com>)
>v2:
> - s/In case of UEFI/In case of UEFI,/ (Laszlo Ersek <lersek@redhat.com>)
>---
> tests/acpi-utils.h | 2 +-
> tests/acpi-utils.c | 2 +-
> tests/bios-tables-test.c | 10 ++++------
> 3 files changed, 6 insertions(+), 8 deletions(-)
>
>diff --git a/tests/acpi-utils.h b/tests/acpi-utils.h
>index f55ccf9..1da6c10 100644
>--- a/tests/acpi-utils.h
>+++ b/tests/acpi-utils.h
>@@ -46,7 +46,7 @@ typedef struct {
>
> uint8_t acpi_calc_checksum(const uint8_t *data, int len);
> uint32_t acpi_find_rsdp_address(QTestState *qts);
>-void acpi_fetch_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table);
>+void acpi_fetch_rsdp_table(QTestState *qts, uint64_t addr, uint8_t *rsdp_table);
> void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
> const uint8_t *addr_ptr, int addr_size, const char *sig,
> bool verify_checksum);
>diff --git a/tests/acpi-utils.c b/tests/acpi-utils.c
>index a0d49c4..c216b9e 100644
>--- a/tests/acpi-utils.c
>+++ b/tests/acpi-utils.c
>@@ -51,7 +51,7 @@ uint32_t acpi_find_rsdp_address(QTestState *qts)
> return off;
> }
>
>-void acpi_fetch_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table)
>+void acpi_fetch_rsdp_table(QTestState *qts, uint64_t addr, uint8_t *rsdp_table)
> {
> uint8_t revision;
>
>diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
>index d6ab121..a164d27 100644
>--- a/tests/bios-tables-test.c
>+++ b/tests/bios-tables-test.c
>@@ -26,7 +26,7 @@
> typedef struct {
> const char *machine;
> const char *variant;
>- uint32_t rsdp_addr;
>+ uint64_t rsdp_addr;
> uint8_t rsdp_table[36 /* ACPI 2.0+ RSDP size */];
> GArray *tables;
> uint32_t smbios_ep_addr;
>@@ -86,13 +86,11 @@ static void test_acpi_rsdp_address(test_data *data)
>
> static void test_acpi_rsdp_table(test_data *data)
> {
>- uint8_t *rsdp_table = data->rsdp_table, revision;
>- uint32_t addr = data->rsdp_addr;
>+ uint8_t *rsdp_table = data->rsdp_table;
>
>- acpi_fetch_rsdp_table(data->qts, addr, rsdp_table);
>- revision = rsdp_table[15 /* Revision offset */];
>+ acpi_fetch_rsdp_table(data->qts, data->rsdp_addr, rsdp_table);
>
>- switch (revision) {
>+ switch (rsdp_table[15 /* Revision offset */]) {
> case 0: /* ACPI 1.0 RSDP */
> /* With rev 1, checksum is only for the first 20 bytes */
> g_assert(!acpi_calc_checksum(rsdp_table, 20));
>--
>2.7.4
--
Wei Yang
Help you, Help me
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH v4 05/15] tests: acpi: fetch X_DSDT if pointer to DSDT is 0
@ 2019-05-05 1:27 ` Wei Yang
0 siblings, 0 replies; 289+ messages in thread
From: Wei Yang @ 2019-05-05 1:27 UTC (permalink / raw)
To: Igor Mammedov
Cc: qemu-devel, Laszlo Ersek, Michael S. Tsirkin, Gonglei,
Philippe Mathieu-Daudé,
Shannon Zhao, Wei Yang, Andrew Jones, Shameer Kolothum,
Ben Warren, xuwei5, xuwei5, linuxarm
On Thu, May 02, 2019 at 04:51:53PM +0200, Igor Mammedov wrote:
>that way it would be possible to test a DSDT pointed by
>64bit X_DSDT field in FADT.
>
>PS:
>it will allow to enable testing arm/virt board, which sets
>only newer X_DSDT field.
>
>Signed-off-by: Igor Mammedov <imammedo@redhat.com>
>---
>v4:
> * dropping Reviewed-bys due to acpi_fetch_table() change
> introduced by earlier patch:
> "tests: acpi: make acpi_fetch_table() take size of fetched table pointer"
>v2:
> add 'val = le32_to_cpu(val)' even if it doesn't necessary
> it works as reminder that value copied from table is in
> little-endian format (Philippe Mathieu-Daudé <philmd@redhat.com>)
>---
> tests/bios-tables-test.c | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
>
>diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
>index a164d27..d165a1b 100644
>--- a/tests/bios-tables-test.c
>+++ b/tests/bios-tables-test.c
>@@ -140,6 +140,9 @@ static void test_acpi_fadt_table(test_data *data)
> AcpiSdtTable table = g_array_index(data->tables, typeof(table), 0);
> uint8_t *fadt_aml = table.aml;
> uint32_t fadt_len = table.aml_len;
>+ uint32_t val;
>+ int dsdt_offset = 40 /* DSDT */;
>+ int dsdt_entry_size = 4;
>
> g_assert(compare_signature(&table, "FACP"));
>
>@@ -148,8 +151,14 @@ static void test_acpi_fadt_table(test_data *data)
> fadt_aml + 36 /* FIRMWARE_CTRL */, 4, "FACS", false);
> g_array_append_val(data->tables, table);
>
>+ memcpy(&val, fadt_aml + dsdt_offset, 4);
>+ val = le32_to_cpu(val);
>+ if (!val) {
>+ dsdt_offset = 140 /* X_DSDT */;
In case we can point out where we get it, e.g. ACPI 5, Table 5-34 FADT Format.
This may be more helpful for reviewing and maintaining.
Do you think so?
>+ dsdt_entry_size = 8;
>+ }
> acpi_fetch_table(data->qts, &table.aml, &table.aml_len,
>- fadt_aml + 40 /* DSDT */, 4, "DSDT", true);
>+ fadt_aml + dsdt_offset, dsdt_entry_size, "DSDT", true);
> g_array_append_val(data->tables, table);
>
> memset(fadt_aml + 36, 0, 4); /* sanitize FIRMWARE_CTRL ptr */
>--
>2.7.4
--
Wei Yang
Help you, Help me
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH v4 05/15] tests: acpi: fetch X_DSDT if pointer to DSDT is 0
@ 2019-05-05 1:27 ` Wei Yang
0 siblings, 0 replies; 289+ messages in thread
From: Wei Yang @ 2019-05-05 1:27 UTC (permalink / raw)
To: Igor Mammedov
Cc: Andrew Jones, Ben Warren, Michael S. Tsirkin, Laszlo Ersek,
qemu-devel, Shameer Kolothum, linuxarm, Shannon Zhao, Gonglei,
Wei Yang, xuwei5, xuwei5, Philippe Mathieu-Daudé
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="UTF-8", Size: 2204 bytes --]
On Thu, May 02, 2019 at 04:51:53PM +0200, Igor Mammedov wrote:
>that way it would be possible to test a DSDT pointed by
>64bit X_DSDT field in FADT.
>
>PS:
>it will allow to enable testing arm/virt board, which sets
>only newer X_DSDT field.
>
>Signed-off-by: Igor Mammedov <imammedo@redhat.com>
>---
>v4:
> * dropping Reviewed-bys due to acpi_fetch_table() change
> introduced by earlier patch:
> "tests: acpi: make acpi_fetch_table() take size of fetched table pointer"
>v2:
> add 'val = le32_to_cpu(val)' even if it doesn't necessary
> it works as reminder that value copied from table is in
> little-endian format (Philippe Mathieu-Daudé <philmd@redhat.com>)
>---
> tests/bios-tables-test.c | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
>
>diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
>index a164d27..d165a1b 100644
>--- a/tests/bios-tables-test.c
>+++ b/tests/bios-tables-test.c
>@@ -140,6 +140,9 @@ static void test_acpi_fadt_table(test_data *data)
> AcpiSdtTable table = g_array_index(data->tables, typeof(table), 0);
> uint8_t *fadt_aml = table.aml;
> uint32_t fadt_len = table.aml_len;
>+ uint32_t val;
>+ int dsdt_offset = 40 /* DSDT */;
>+ int dsdt_entry_size = 4;
>
> g_assert(compare_signature(&table, "FACP"));
>
>@@ -148,8 +151,14 @@ static void test_acpi_fadt_table(test_data *data)
> fadt_aml + 36 /* FIRMWARE_CTRL */, 4, "FACS", false);
> g_array_append_val(data->tables, table);
>
>+ memcpy(&val, fadt_aml + dsdt_offset, 4);
>+ val = le32_to_cpu(val);
>+ if (!val) {
>+ dsdt_offset = 140 /* X_DSDT */;
In case we can point out where we get it, e.g. ACPI 5, Table 5-34 FADT Format.
This may be more helpful for reviewing and maintaining.
Do you think so?
>+ dsdt_entry_size = 8;
>+ }
> acpi_fetch_table(data->qts, &table.aml, &table.aml_len,
>- fadt_aml + 40 /* DSDT */, 4, "DSDT", true);
>+ fadt_aml + dsdt_offset, dsdt_entry_size, "DSDT", true);
> g_array_append_val(data->tables, table);
>
> memset(fadt_aml + 36, 0, 4); /* sanitize FIRMWARE_CTRL ptr */
>--
>2.7.4
--
Wei Yang
Help you, Help me
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH v4 14/15] tests: acpi: refactor rebuild-expected-aml.sh to dump ACPI tables for a specified list of targets
@ 2019-05-05 1:30 ` Wei Yang
0 siblings, 0 replies; 289+ messages in thread
From: Wei Yang @ 2019-05-05 1:30 UTC (permalink / raw)
To: Igor Mammedov
Cc: qemu-devel, Laszlo Ersek, Michael S. Tsirkin, Gonglei,
Philippe Mathieu-Daudé,
Shannon Zhao, Wei Yang, Andrew Jones, Shameer Kolothum,
Ben Warren, xuwei5, xuwei5, linuxarm
On Thu, May 02, 2019 at 04:52:02PM +0200, Igor Mammedov wrote:
>Make initial list contain aarch64 and x86_64 targets.
>
>Signed-off-by: Igor Mammedov <imammedo@redhat.com>
>Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Wei Yang <richardw.yang@linux.intel.com>
>---
>v4:
> * fix typo (Wei Yang <richardw.yang@linux.intel.com>)
>v2:
> * fix up error message (Philippe Mathieu-Daudé <philmd@redhat.com>)
>---
> tests/data/acpi/rebuild-expected-aml.sh | 23 +++++++++++------------
> 1 file changed, 11 insertions(+), 12 deletions(-)
>
>diff --git a/tests/data/acpi/rebuild-expected-aml.sh b/tests/data/acpi/rebuild-expected-aml.sh
>index abdff70..07f7e3f 100755
>--- a/tests/data/acpi/rebuild-expected-aml.sh
>+++ b/tests/data/acpi/rebuild-expected-aml.sh
>@@ -7,21 +7,12 @@
> #
> # Authors:
> # Marcel Apfelbaum <marcel.a@redhat.com>
>+# Igor Mammedov <imammedo@redhat.com>
> #
> # This work is licensed under the terms of the GNU GPLv2.
> # See the COPYING.LIB file in the top-level directory.
>
>-qemu=
>-
>-if [ -e x86_64-softmmu/qemu-system-x86_64 ]; then
>- qemu="x86_64-softmmu/qemu-system-x86_64"
>-elif [ -e i386-softmmu/qemu-system-i386 ]; then
>- qemu="i386-softmmu/qemu-system-i386"
>-else
>- echo "Run 'make' to build the qemu exectutable!"
>- echo "Run this script from the build directory."
>- exit 1;
>-fi
>+qemu_bins="aarch64-softmmu/qemu-system-aarch64 x86_64-softmmu/qemu-system-x86_64"
>
> if [ ! -e "tests/bios-tables-test" ]; then
> echo "Test: bios-tables-test is required! Run make check before this script."
>@@ -29,6 +20,14 @@ if [ ! -e "tests/bios-tables-test" ]; then
> exit 1;
> fi
>
>-TEST_ACPI_REBUILD_AML=y QTEST_QEMU_BINARY=$qemu tests/bios-tables-test
>+for qemu in $qemu_bins; do
>+ if [ ! -e $qemu ]; then
>+ echo "Run 'make' to build the following QEMU executables: $qemu_bins"
>+ echo "Also, run this script from the build directory."
>+ exit 1;
>+ fi
>+ TEST_ACPI_REBUILD_AML=y QTEST_QEMU_BINARY=$qemu tests/bios-tables-test
>+done
>+
>
> echo "The files were rebuilt and can be added to git."
>--
>2.7.4
--
Wei Yang
Help you, Help me
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH v4 14/15] tests: acpi: refactor rebuild-expected-aml.sh to dump ACPI tables for a specified list of targets
@ 2019-05-05 1:30 ` Wei Yang
0 siblings, 0 replies; 289+ messages in thread
From: Wei Yang @ 2019-05-05 1:30 UTC (permalink / raw)
To: Igor Mammedov
Cc: Andrew Jones, Ben Warren, Michael S. Tsirkin, Laszlo Ersek,
qemu-devel, Shameer Kolothum, linuxarm, Shannon Zhao, Gonglei,
Wei Yang, xuwei5, xuwei5, Philippe Mathieu-Daudé
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="UTF-8", Size: 2158 bytes --]
On Thu, May 02, 2019 at 04:52:02PM +0200, Igor Mammedov wrote:
>Make initial list contain aarch64 and x86_64 targets.
>
>Signed-off-by: Igor Mammedov <imammedo@redhat.com>
>Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Wei Yang <richardw.yang@linux.intel.com>
>---
>v4:
> * fix typo (Wei Yang <richardw.yang@linux.intel.com>)
>v2:
> * fix up error message (Philippe Mathieu-Daudé <philmd@redhat.com>)
>---
> tests/data/acpi/rebuild-expected-aml.sh | 23 +++++++++++------------
> 1 file changed, 11 insertions(+), 12 deletions(-)
>
>diff --git a/tests/data/acpi/rebuild-expected-aml.sh b/tests/data/acpi/rebuild-expected-aml.sh
>index abdff70..07f7e3f 100755
>--- a/tests/data/acpi/rebuild-expected-aml.sh
>+++ b/tests/data/acpi/rebuild-expected-aml.sh
>@@ -7,21 +7,12 @@
> #
> # Authors:
> # Marcel Apfelbaum <marcel.a@redhat.com>
>+# Igor Mammedov <imammedo@redhat.com>
> #
> # This work is licensed under the terms of the GNU GPLv2.
> # See the COPYING.LIB file in the top-level directory.
>
>-qemu=
>-
>-if [ -e x86_64-softmmu/qemu-system-x86_64 ]; then
>- qemu="x86_64-softmmu/qemu-system-x86_64"
>-elif [ -e i386-softmmu/qemu-system-i386 ]; then
>- qemu="i386-softmmu/qemu-system-i386"
>-else
>- echo "Run 'make' to build the qemu exectutable!"
>- echo "Run this script from the build directory."
>- exit 1;
>-fi
>+qemu_bins="aarch64-softmmu/qemu-system-aarch64 x86_64-softmmu/qemu-system-x86_64"
>
> if [ ! -e "tests/bios-tables-test" ]; then
> echo "Test: bios-tables-test is required! Run make check before this script."
>@@ -29,6 +20,14 @@ if [ ! -e "tests/bios-tables-test" ]; then
> exit 1;
> fi
>
>-TEST_ACPI_REBUILD_AML=y QTEST_QEMU_BINARY=$qemu tests/bios-tables-test
>+for qemu in $qemu_bins; do
>+ if [ ! -e $qemu ]; then
>+ echo "Run 'make' to build the following QEMU executables: $qemu_bins"
>+ echo "Also, run this script from the build directory."
>+ exit 1;
>+ fi
>+ TEST_ACPI_REBUILD_AML=y QTEST_QEMU_BINARY=$qemu tests/bios-tables-test
>+done
>+
>
> echo "The files were rebuilt and can be added to git."
>--
>2.7.4
--
Wei Yang
Help you, Help me
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [Qemu-ppc] [PATCH v2 3/3] pcie: Simplify pci_adjust_config_limit()
2019-04-26 6:40 ` [Qemu-devel] [Qemu-ppc] " Alexey Kardashevskiy
@ 2019-05-07 4:48 ` David Gibson
2019-05-12 18:13 ` Michael S. Tsirkin
0 siblings, 1 reply; 289+ messages in thread
From: David Gibson @ 2019-05-07 4:48 UTC (permalink / raw)
To: Alexey Kardashevskiy
Cc: Michael S. Tsirkin, Greg Kurz, qemu-devel, Alex Williamson,
qemu-ppc, clg
[-- Attachment #1: Type: text/plain, Size: 3929 bytes --]
On Fri, Apr 26, 2019 at 04:40:17PM +1000, Alexey Kardashevskiy wrote:
>
>
> On 24/04/2019 14:19, David Gibson wrote:
> > Since c2077e2c "pci: Adjust PCI config limit based on bus topology",
> > pci_adjust_config_limit() has been used in the config space read and write
> > paths to only permit access to extended config space on buses which permit
> > it. Specifically it prevents access on devices below a vanilla-PCI bus via
> > some combination of bridges, even if both the host bridge and the device
> > itself are PCI-E.
> >
> > It accomplishes this with a somewhat complex call up the chain of bridges
> > to see if any of them prohibit extended config space access. This is
> > overly complex, since we can always know if the bus will support such
> > access at the point it is constructed.
> >
> > This patch simplifies the test by using a flag in the PCIBus instance
> > indicating whether extended configuration space is accessible. It is
> > false for vanilla PCI buses. For PCI-E buses, it is true for root
> > buses and equal to the parent bus's's capability otherwise.
> >
> > For the special case of sPAPR's paravirtualized PCI root bus, which
> > acts mostly like vanilla PCI, but does allow extended config space
> > access, we override the default value of the flag from the host bridge
> > code.
> >
> > This should cause no behavioural change.
> >
> > Signed-off-by: David Gibson <david@gibson.dropbear.id.au>cd
> > ---
> > hw/pci/pci.c | 41 ++++++++++++++++++++++------------------
> > hw/pci/pci_host.c | 13 +++----------
> > hw/ppc/spapr_pci.c | 34 ++++++++++-----------------------
> > include/hw/pci/pci.h | 1 -
> > include/hw/pci/pci_bus.h | 9 ++++++++-
> > 5 files changed, 44 insertions(+), 54 deletions(-)
> >
> > diff --git a/hw/pci/pci.c b/hw/pci/pci.c
> > index ea5941fb22..59ee034331 100644
> > --- a/hw/pci/pci.c
> > +++ b/hw/pci/pci.c
> > @@ -120,6 +120,27 @@ static void pci_bus_realize(BusState *qbus, Error **errp)
> > vmstate_register(NULL, -1, &vmstate_pcibus, bus);
> > }
> >
> > +static void pcie_bus_realize(BusState *qbus, Error **errp)
> > +{
> > + PCIBus *bus = PCI_BUS(qbus);
> > +
> > + pci_bus_realize(qbus, errp);
> > +
> > + /*
> > + * A PCI-E bus can support extended config space if it's the root
> > + * bus, or if the bus/bridge above it does as well
> > + */
> > + if (pci_bus_is_root(bus)) {
> > + bus->flags |= PCI_BUS_EXTENDED_CONFIG_SPACE;
> > + } else {
> > + PCIBus *parent_bus = pci_get_bus(bus->parent_dev);
>
>
> g_assert(bus->parent_dev) ?
>
> Slightly confusingly bus->parent_dev is not the same as bus->qbus.parent
> and can be NULL, I'd even look into ditching parent_dev and using
> bus->qbus.parent instead (if possible).
Oh boy, the can of worms I reached into following up that simple
comment. Yes, they're subtly different, and yes it's confusing. In
practice parent_dev is NULL when on a root bus, that's not a PXB bus,
and otherwise equal to qbus.parent.
After a *lot* of thinking about this, I think parent_dev is actually
correct here - we're explicitly looking at the parent as a P2P bridge,
not anything else.
But, I'll try to do some later cleanups making the parent_dev /
qbus.parent confusion a bit better.
> > +static inline bool pci_bus_allows_extended_config_space(PCIBus *bus)
> > +{
> > + return !!(bus->flags & PCI_BUS_EXTENDED_CONFIG_SPACE);
> > +}
> > +
> > +
>
> An extra empty line.
>
> Anyway, these are minor comments, so
>
> Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
>
>
>
>
> > #endif /* QEMU_PCI_BUS_H */
> >
>
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH v4 05/15] tests: acpi: fetch X_DSDT if pointer to DSDT is 0
2019-05-05 1:27 ` Wei Yang
(?)
@ 2019-05-07 10:04 ` Igor Mammedov
2019-05-08 5:51 ` Wei Yang
-1 siblings, 1 reply; 289+ messages in thread
From: Igor Mammedov @ 2019-05-07 10:04 UTC (permalink / raw)
To: Wei Yang
Cc: Andrew Jones, Ben Warren, Michael S. Tsirkin,
Philippe Mathieu-Daudé,
qemu-devel, Shameer Kolothum, linuxarm, Shannon Zhao, Gonglei,
xuwei5, xuwei5, Laszlo Ersek
On Sun, 5 May 2019 09:27:45 +0800
Wei Yang <richardw.yang@linux.intel.com> wrote:
> On Thu, May 02, 2019 at 04:51:53PM +0200, Igor Mammedov wrote:
> >that way it would be possible to test a DSDT pointed by
> >64bit X_DSDT field in FADT.
> >
> >PS:
> >it will allow to enable testing arm/virt board, which sets
> >only newer X_DSDT field.
> >
> >Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> >---
> >v4:
> > * dropping Reviewed-bys due to acpi_fetch_table() change
> > introduced by earlier patch:
> > "tests: acpi: make acpi_fetch_table() take size of fetched table pointer"
> >v2:
> > add 'val = le32_to_cpu(val)' even if it doesn't necessary
> > it works as reminder that value copied from table is in
> > little-endian format (Philippe Mathieu-Daudé <philmd@redhat.com>)
> >---
> > tests/bios-tables-test.c | 11 ++++++++++-
> > 1 file changed, 10 insertions(+), 1 deletion(-)
> >
> >diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
> >index a164d27..d165a1b 100644
> >--- a/tests/bios-tables-test.c
> >+++ b/tests/bios-tables-test.c
> >@@ -140,6 +140,9 @@ static void test_acpi_fadt_table(test_data *data)
> > AcpiSdtTable table = g_array_index(data->tables, typeof(table), 0);
> > uint8_t *fadt_aml = table.aml;
> > uint32_t fadt_len = table.aml_len;
> >+ uint32_t val;
> >+ int dsdt_offset = 40 /* DSDT */;
> >+ int dsdt_entry_size = 4;
> >
> > g_assert(compare_signature(&table, "FACP"));
> >
> >@@ -148,8 +151,14 @@ static void test_acpi_fadt_table(test_data *data)
> > fadt_aml + 36 /* FIRMWARE_CTRL */, 4, "FACS", false);
> > g_array_append_val(data->tables, table);
> >
> >+ memcpy(&val, fadt_aml + dsdt_offset, 4);
> >+ val = le32_to_cpu(val);
> >+ if (!val) {
> >+ dsdt_offset = 140 /* X_DSDT */;
>
> In case we can point out where we get it, e.g. ACPI 5, Table 5-34 FADT Format.
>
> This may be more helpful for reviewing and maintaining.
for fields we typically use only verbatim field name, so it would be easy
to find by searching for it in spec. In this case it is obvious about which
table it applies to, so reference to spec for a field probably excessive.
Complete reference necessary for tables and API functions that implement
ACPI primitive.
>
> Do you think so?
>
> >+ dsdt_entry_size = 8;
> >+ }
> > acpi_fetch_table(data->qts, &table.aml, &table.aml_len,
> >- fadt_aml + 40 /* DSDT */, 4, "DSDT", true);
> >+ fadt_aml + dsdt_offset, dsdt_entry_size, "DSDT", true);
> > g_array_append_val(data->tables, table);
> >
> > memset(fadt_aml + 36, 0, 4); /* sanitize FIRMWARE_CTRL ptr */
> >--
> >2.7.4
>
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH v4 05/15] tests: acpi: fetch X_DSDT if pointer to DSDT is 0
2019-05-07 10:04 ` Igor Mammedov
@ 2019-05-08 5:51 ` Wei Yang
0 siblings, 0 replies; 289+ messages in thread
From: Wei Yang @ 2019-05-08 5:51 UTC (permalink / raw)
To: Igor Mammedov
Cc: Andrew Jones, Ben Warren, Michael S. Tsirkin,
Philippe Mathieu-Daudé,
qemu-devel, Shameer Kolothum, linuxarm, Shannon Zhao, Gonglei,
Wei Yang, xuwei5, xuwei5, Laszlo Ersek
On Tue, May 07, 2019 at 12:04:08PM +0200, Igor Mammedov wrote:
>On Sun, 5 May 2019 09:27:45 +0800
>Wei Yang <richardw.yang@linux.intel.com> wrote:
>
>> On Thu, May 02, 2019 at 04:51:53PM +0200, Igor Mammedov wrote:
>> >that way it would be possible to test a DSDT pointed by
>> >64bit X_DSDT field in FADT.
>> >
>> >PS:
>> >it will allow to enable testing arm/virt board, which sets
>> >only newer X_DSDT field.
>> >
>> >Signed-off-by: Igor Mammedov <imammedo@redhat.com>
>> >---
>> >v4:
>> > * dropping Reviewed-bys due to acpi_fetch_table() change
>> > introduced by earlier patch:
>> > "tests: acpi: make acpi_fetch_table() take size of fetched table pointer"
>> >v2:
>> > add 'val = le32_to_cpu(val)' even if it doesn't necessary
>> > it works as reminder that value copied from table is in
>> > little-endian format (Philippe Mathieu-Daudé <philmd@redhat.com>)
>> >---
>> > tests/bios-tables-test.c | 11 ++++++++++-
>> > 1 file changed, 10 insertions(+), 1 deletion(-)
>> >
>> >diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
>> >index a164d27..d165a1b 100644
>> >--- a/tests/bios-tables-test.c
>> >+++ b/tests/bios-tables-test.c
>> >@@ -140,6 +140,9 @@ static void test_acpi_fadt_table(test_data *data)
>> > AcpiSdtTable table = g_array_index(data->tables, typeof(table), 0);
>> > uint8_t *fadt_aml = table.aml;
>> > uint32_t fadt_len = table.aml_len;
>> >+ uint32_t val;
>> >+ int dsdt_offset = 40 /* DSDT */;
>> >+ int dsdt_entry_size = 4;
>> >
>> > g_assert(compare_signature(&table, "FACP"));
>> >
>> >@@ -148,8 +151,14 @@ static void test_acpi_fadt_table(test_data *data)
>> > fadt_aml + 36 /* FIRMWARE_CTRL */, 4, "FACS", false);
>> > g_array_append_val(data->tables, table);
>> >
>> >+ memcpy(&val, fadt_aml + dsdt_offset, 4);
>> >+ val = le32_to_cpu(val);
>> >+ if (!val) {
>> >+ dsdt_offset = 140 /* X_DSDT */;
>>
>> In case we can point out where we get it, e.g. ACPI 5, Table 5-34 FADT Format.
>>
>> This may be more helpful for reviewing and maintaining.
>
>for fields we typically use only verbatim field name, so it would be easy
>to find by searching for it in spec. In this case it is obvious about which
>table it applies to, so reference to spec for a field probably excessive.
>
>Complete reference necessary for tables and API functions that implement
>ACPI primitive.
>
That's fine.
Reviewed-by: Wei Yang <richardw.yang@linux.intel.com>
--
Wei Yang
Help you, Help me
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH v4 10/15] tests: acpi: ignore SMBIOS tests when UEFI firmware is used
2019-05-02 14:51 ` [Qemu-devel] [PATCH v4 10/15] " Igor Mammedov
` (2 preceding siblings ...)
(?)
@ 2019-05-08 6:12 ` Philippe Mathieu-Daudé
-1 siblings, 0 replies; 289+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-05-08 6:12 UTC (permalink / raw)
To: Igor Mammedov, qemu-devel
Cc: Andrew Jones, Ben Warren, Michael S. Tsirkin, linuxarm,
Shameer Kolothum, Shannon Zhao, Gonglei, Wei Yang, xuwei5,
xuwei5, Laszlo Ersek
On 5/2/19 4:51 PM, Igor Mammedov wrote:
> once FW provides a pointer to SMBIOS entry point like it does for
> RSDP it should be possible to enable this one the same way.
>
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> v3:
> - add ref to a uefi-test-tools feature req into comment (Laszlo)
> ---
> tests/bios-tables-test.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
> index 84e1ce2..8302ffc 100644
> --- a/tests/bios-tables-test.c
> +++ b/tests/bios-tables-test.c
> @@ -569,8 +569,15 @@ static void test_acpi_one(const char *params, test_data *data)
> }
> }
>
> - test_smbios_entry_point(data);
> - test_smbios_structs(data);
> + /*
> + * TODO: make SMBIOS tests work with UEFI firmware,
> + * Bug on uefi-test-tools to provide entry point:
> + * https://bugs.launchpad.net/qemu/+bug/1821884
> + */
> + if (!use_uefi) {
> + test_smbios_entry_point(data);
> + test_smbios_structs(data);
> + }
>
> assert(!global_qtest);
> qtest_quit(data->qts);
>
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH v4 07/15] tests: acpi: move boot_sector_init() into x86 tests branch
2019-05-02 14:51 ` [Qemu-devel] [PATCH v4 07/15] " Igor Mammedov
` (2 preceding siblings ...)
(?)
@ 2019-05-08 6:13 ` Philippe Mathieu-Daudé
-1 siblings, 0 replies; 289+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-05-08 6:13 UTC (permalink / raw)
To: Igor Mammedov, qemu-devel
Cc: Andrew Jones, Ben Warren, Michael S. Tsirkin, linuxarm,
Shameer Kolothum, Shannon Zhao, Gonglei, Wei Yang, xuwei5,
xuwei5, Laszlo Ersek
On 5/2/19 4:51 PM, Igor Mammedov wrote:
> boot_sector_init() won't be used by arm/virt board, so move it from
> global scope to x86 branch that uses it.
>
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> v3:
> - fix checkpatch errors triggered by moved old code (ident/space/braces)
> ---
> tests/bios-tables-test.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
> index e2fc341..4d13a3c 100644
> --- a/tests/bios-tables-test.c
> +++ b/tests/bios-tables-test.c
> @@ -788,13 +788,14 @@ int main(int argc, char *argv[])
> const char *arch = qtest_get_arch();
> int ret;
>
> - ret = boot_sector_init(disk);
> - if(ret)
> - return ret;
> -
> g_test_init(&argc, &argv, NULL);
>
> if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
> + ret = boot_sector_init(disk);
> + if (ret) {
> + return ret;
> + }
> +
> qtest_add_func("acpi/piix4", test_acpi_piix4_tcg);
> qtest_add_func("acpi/piix4/bridge", test_acpi_piix4_tcg_bridge);
> qtest_add_func("acpi/q35", test_acpi_q35_tcg);
>
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH v4 04/15] tests: acpi: make pointer to RSDP 64bit
2019-05-02 14:51 ` [Qemu-devel] [PATCH v4 04/15] " Igor Mammedov
` (3 preceding siblings ...)
(?)
@ 2019-05-08 6:15 ` Philippe Mathieu-Daudé
-1 siblings, 0 replies; 289+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-05-08 6:15 UTC (permalink / raw)
To: Igor Mammedov, qemu-devel
Cc: Andrew Jones, Ben Warren, Michael S. Tsirkin, linuxarm,
Shameer Kolothum, Shannon Zhao, Gonglei, Wei Yang, xuwei5,
xuwei5, Laszlo Ersek
On 5/2/19 4:51 PM, Igor Mammedov wrote:
> In case of UEFI, RSDP doesn't have to be located in lowmem,
> it could be placed at any address. Make sure that test won't
> break if it is placed above the first 4Gb of address space.
>
> PS:
> While at it cleanup some local variables as we don't really
> need them.
>
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> v4:
> - move acpi_fetch_rsdp_table(s/uint32_t addr/uint64_t addr/) to
> this patch where it belongs from
> "tests: acpi: make RSDT test routine handle XSDT"
> (Wei Yang <richardw.yang@linux.intel.com>)
> v2:
> - s/In case of UEFI/In case of UEFI,/ (Laszlo Ersek <lersek@redhat.com>)
> ---
> tests/acpi-utils.h | 2 +-
> tests/acpi-utils.c | 2 +-
> tests/bios-tables-test.c | 10 ++++------
> 3 files changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/tests/acpi-utils.h b/tests/acpi-utils.h
> index f55ccf9..1da6c10 100644
> --- a/tests/acpi-utils.h
> +++ b/tests/acpi-utils.h
> @@ -46,7 +46,7 @@ typedef struct {
>
> uint8_t acpi_calc_checksum(const uint8_t *data, int len);
> uint32_t acpi_find_rsdp_address(QTestState *qts);
> -void acpi_fetch_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table);
> +void acpi_fetch_rsdp_table(QTestState *qts, uint64_t addr, uint8_t *rsdp_table);
> void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
> const uint8_t *addr_ptr, int addr_size, const char *sig,
> bool verify_checksum);
> diff --git a/tests/acpi-utils.c b/tests/acpi-utils.c
> index a0d49c4..c216b9e 100644
> --- a/tests/acpi-utils.c
> +++ b/tests/acpi-utils.c
> @@ -51,7 +51,7 @@ uint32_t acpi_find_rsdp_address(QTestState *qts)
> return off;
> }
>
> -void acpi_fetch_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table)
> +void acpi_fetch_rsdp_table(QTestState *qts, uint64_t addr, uint8_t *rsdp_table)
> {
> uint8_t revision;
>
> diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
> index d6ab121..a164d27 100644
> --- a/tests/bios-tables-test.c
> +++ b/tests/bios-tables-test.c
> @@ -26,7 +26,7 @@
> typedef struct {
> const char *machine;
> const char *variant;
> - uint32_t rsdp_addr;
> + uint64_t rsdp_addr;
> uint8_t rsdp_table[36 /* ACPI 2.0+ RSDP size */];
> GArray *tables;
> uint32_t smbios_ep_addr;
> @@ -86,13 +86,11 @@ static void test_acpi_rsdp_address(test_data *data)
>
> static void test_acpi_rsdp_table(test_data *data)
> {
> - uint8_t *rsdp_table = data->rsdp_table, revision;
> - uint32_t addr = data->rsdp_addr;
> + uint8_t *rsdp_table = data->rsdp_table;
>
> - acpi_fetch_rsdp_table(data->qts, addr, rsdp_table);
> - revision = rsdp_table[15 /* Revision offset */];
> + acpi_fetch_rsdp_table(data->qts, data->rsdp_addr, rsdp_table);
>
> - switch (revision) {
> + switch (rsdp_table[15 /* Revision offset */]) {
> case 0: /* ACPI 1.0 RSDP */
> /* With rev 1, checksum is only for the first 20 bytes */
> g_assert(!acpi_calc_checksum(rsdp_table, 20));
>
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH 0/3] acpi: More trace points
2019-04-02 16:18 [Qemu-devel] [PATCH 0/3] acpi: More trace points Markus Armbruster
` (3 preceding siblings ...)
2019-04-02 19:24 ` [Qemu-devel] [PATCH 0/3] acpi: More trace points Philippe Mathieu-Daudé
@ 2019-05-08 11:19 ` Markus Armbruster
2019-05-08 16:30 ` Michael S. Tsirkin
4 siblings, 1 reply; 289+ messages in thread
From: Markus Armbruster @ 2019-05-08 11:19 UTC (permalink / raw)
To: mst; +Cc: imammedo, qemu-devel
Ping?
Markus Armbruster <armbru@redhat.com> writes:
> I wrote these patches to help me debug an unplug failure. I expect
> them to be helpful for others, too.
>
> Markus Armbruster (3):
> acpi/piix4: Convert debug printf()s to trace events
> acpi/pcihp: Convert debug printf()s to trace events
> acpi/pcihp: Add a few more trace points related to unplug
>
> hw/acpi/pcihp.c | 32 +++++++++++++++-----------------
> hw/acpi/piix4.c | 14 +++-----------
> hw/acpi/trace-events | 16 ++++++++++++++++
> 3 files changed, 34 insertions(+), 28 deletions(-)
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH 0/3] acpi: More trace points
2019-05-08 11:19 ` Markus Armbruster
@ 2019-05-08 16:30 ` Michael S. Tsirkin
0 siblings, 0 replies; 289+ messages in thread
From: Michael S. Tsirkin @ 2019-05-08 16:30 UTC (permalink / raw)
To: Markus Armbruster; +Cc: imammedo, qemu-devel
tagged, thanks!
On Wed, May 08, 2019 at 01:19:47PM +0200, Markus Armbruster wrote:
> Ping?
>
> Markus Armbruster <armbru@redhat.com> writes:
>
> > I wrote these patches to help me debug an unplug failure. I expect
> > them to be helpful for others, too.
> >
> > Markus Armbruster (3):
> > acpi/piix4: Convert debug printf()s to trace events
> > acpi/pcihp: Convert debug printf()s to trace events
> > acpi/pcihp: Add a few more trace points related to unplug
> >
> > hw/acpi/pcihp.c | 32 +++++++++++++++-----------------
> > hw/acpi/piix4.c | 14 +++-----------
> > hw/acpi/trace-events | 16 ++++++++++++++++
> > 3 files changed, 34 insertions(+), 28 deletions(-)
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH v4 0/6] Extract build_mcfg
2019-04-19 0:30 ` Wei Yang
` (6 preceding siblings ...)
(?)
@ 2019-05-10 21:22 ` Wei Yang
2019-05-10 23:59 ` Michael S. Tsirkin
-1 siblings, 1 reply; 289+ messages in thread
From: Wei Yang @ 2019-05-10 21:22 UTC (permalink / raw)
To: Wei Yang
Cc: yang.zhong, peter.maydell, mst, qemu-devel, shannon.zhaosl,
qemu-arm, imammedo, philmd
Hi, Igor
You would take this one? Or what should I do next?
On Fri, Apr 19, 2019 at 08:30:47AM +0800, Wei Yang wrote:
>This patch set tries to generalize MCFG table build process. And it is
>based on one un-merged patch from Igor, which is included in this serials.
>
>v3->v4:
> * adjust comment to give more information about MCFG table
>
>v2->v3:
> * Includes the un-merged patch from Igor
> * use build_append_foo() API to construct MCFG
>
>Igor Mammedov (1):
> q35: acpi: do not create dummy MCFG table
>
>Wei Yang (5):
> hw/arm/virt-acpi-build: remove unnecessary variable mcfg_start
> i386, acpi: remove mcfg_ prefix in AcpiMcfgInfo members
> hw/arm/virt-acpi-build: pass AcpiMcfgInfo to build_mcfg()
> hw/acpi: Consolidate build_mcfg to pci.c
> acpi: pci: use build_append_foo() API to construct MCFG
>
> default-configs/arm-softmmu.mak | 1 +
> default-configs/i386-softmmu.mak | 1 +
> hw/acpi/Kconfig | 4 +++
> hw/acpi/Makefile.objs | 1 +
> hw/acpi/pci.c | 55 ++++++++++++++++++++++++++++++++
> hw/arm/virt-acpi-build.c | 31 +++++-------------
> hw/i386/acpi-build.c | 44 ++++---------------------
> include/hw/acpi/acpi-defs.h | 18 -----------
> include/hw/acpi/pci.h | 34 ++++++++++++++++++++
> 9 files changed, 111 insertions(+), 78 deletions(-)
> create mode 100644 hw/acpi/pci.c
> create mode 100644 include/hw/acpi/pci.h
>
>--
>2.19.1
>
--
Wei Yang
Help you, Help me
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH v4 0/6] Extract build_mcfg
2019-05-10 21:22 ` [Qemu-devel] [PATCH v4 0/6] Extract build_mcfg Wei Yang
@ 2019-05-10 23:59 ` Michael S. Tsirkin
2019-05-11 0:10 ` Wei Yang
0 siblings, 1 reply; 289+ messages in thread
From: Michael S. Tsirkin @ 2019-05-10 23:59 UTC (permalink / raw)
To: Wei Yang
Cc: yang.zhong, peter.maydell, qemu-devel, shannon.zhaosl, qemu-arm,
Wei Yang, imammedo, philmd
I merged this will send pull request soon.
On Fri, May 10, 2019 at 09:22:10PM +0000, Wei Yang wrote:
> Hi, Igor
>
> You would take this one? Or what should I do next?
>
> On Fri, Apr 19, 2019 at 08:30:47AM +0800, Wei Yang wrote:
> >This patch set tries to generalize MCFG table build process. And it is
> >based on one un-merged patch from Igor, which is included in this serials.
> >
> >v3->v4:
> > * adjust comment to give more information about MCFG table
> >
> >v2->v3:
> > * Includes the un-merged patch from Igor
> > * use build_append_foo() API to construct MCFG
> >
> >Igor Mammedov (1):
> > q35: acpi: do not create dummy MCFG table
> >
> >Wei Yang (5):
> > hw/arm/virt-acpi-build: remove unnecessary variable mcfg_start
> > i386, acpi: remove mcfg_ prefix in AcpiMcfgInfo members
> > hw/arm/virt-acpi-build: pass AcpiMcfgInfo to build_mcfg()
> > hw/acpi: Consolidate build_mcfg to pci.c
> > acpi: pci: use build_append_foo() API to construct MCFG
> >
> > default-configs/arm-softmmu.mak | 1 +
> > default-configs/i386-softmmu.mak | 1 +
> > hw/acpi/Kconfig | 4 +++
> > hw/acpi/Makefile.objs | 1 +
> > hw/acpi/pci.c | 55 ++++++++++++++++++++++++++++++++
> > hw/arm/virt-acpi-build.c | 31 +++++-------------
> > hw/i386/acpi-build.c | 44 ++++---------------------
> > include/hw/acpi/acpi-defs.h | 18 -----------
> > include/hw/acpi/pci.h | 34 ++++++++++++++++++++
> > 9 files changed, 111 insertions(+), 78 deletions(-)
> > create mode 100644 hw/acpi/pci.c
> > create mode 100644 include/hw/acpi/pci.h
> >
> >--
> >2.19.1
> >
>
> --
> Wei Yang
> Help you, Help me
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH v4 0/6] Extract build_mcfg
2019-05-10 23:59 ` Michael S. Tsirkin
@ 2019-05-11 0:10 ` Wei Yang
0 siblings, 0 replies; 289+ messages in thread
From: Wei Yang @ 2019-05-11 0:10 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: yang.zhong, peter.maydell, qemu-devel, Wei Yang, shannon.zhaosl,
qemu-arm, Wei Yang, imammedo, philmd
On Fri, May 10, 2019 at 07:59:43PM -0400, Michael S. Tsirkin wrote:
>I merged this will send pull request soon.
>
Ah, Thanks :-)
--
Wei Yang
Help you, Help me
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [Qemu-ppc] [PATCH v2 3/3] pcie: Simplify pci_adjust_config_limit()
2019-05-07 4:48 ` David Gibson
@ 2019-05-12 18:13 ` Michael S. Tsirkin
2019-05-13 6:20 ` David Gibson
0 siblings, 1 reply; 289+ messages in thread
From: Michael S. Tsirkin @ 2019-05-12 18:13 UTC (permalink / raw)
To: David Gibson
Cc: Alexey Kardashevskiy, qemu-devel, Greg Kurz, Alex Williamson,
qemu-ppc, clg
On Tue, May 07, 2019 at 02:48:38PM +1000, David Gibson wrote:
> On Fri, Apr 26, 2019 at 04:40:17PM +1000, Alexey Kardashevskiy wrote:
> >
> >
> > On 24/04/2019 14:19, David Gibson wrote:
> > > Since c2077e2c "pci: Adjust PCI config limit based on bus topology",
> > > pci_adjust_config_limit() has been used in the config space read and write
> > > paths to only permit access to extended config space on buses which permit
> > > it. Specifically it prevents access on devices below a vanilla-PCI bus via
> > > some combination of bridges, even if both the host bridge and the device
> > > itself are PCI-E.
> > >
> > > It accomplishes this with a somewhat complex call up the chain of bridges
> > > to see if any of them prohibit extended config space access. This is
> > > overly complex, since we can always know if the bus will support such
> > > access at the point it is constructed.
> > >
> > > This patch simplifies the test by using a flag in the PCIBus instance
> > > indicating whether extended configuration space is accessible. It is
> > > false for vanilla PCI buses. For PCI-E buses, it is true for root
> > > buses and equal to the parent bus's's capability otherwise.
> > >
> > > For the special case of sPAPR's paravirtualized PCI root bus, which
> > > acts mostly like vanilla PCI, but does allow extended config space
> > > access, we override the default value of the flag from the host bridge
> > > code.
> > >
> > > This should cause no behavioural change.
> > >
> > > Signed-off-by: David Gibson <david@gibson.dropbear.id.au>cd
> > > ---
> > > hw/pci/pci.c | 41 ++++++++++++++++++++++------------------
> > > hw/pci/pci_host.c | 13 +++----------
> > > hw/ppc/spapr_pci.c | 34 ++++++++++-----------------------
> > > include/hw/pci/pci.h | 1 -
> > > include/hw/pci/pci_bus.h | 9 ++++++++-
> > > 5 files changed, 44 insertions(+), 54 deletions(-)
> > >
> > > diff --git a/hw/pci/pci.c b/hw/pci/pci.c
> > > index ea5941fb22..59ee034331 100644
> > > --- a/hw/pci/pci.c
> > > +++ b/hw/pci/pci.c
> > > @@ -120,6 +120,27 @@ static void pci_bus_realize(BusState *qbus, Error **errp)
> > > vmstate_register(NULL, -1, &vmstate_pcibus, bus);
> > > }
> > >
> > > +static void pcie_bus_realize(BusState *qbus, Error **errp)
> > > +{
> > > + PCIBus *bus = PCI_BUS(qbus);
> > > +
> > > + pci_bus_realize(qbus, errp);
> > > +
> > > + /*
> > > + * A PCI-E bus can support extended config space if it's the root
> > > + * bus, or if the bus/bridge above it does as well
> > > + */
> > > + if (pci_bus_is_root(bus)) {
> > > + bus->flags |= PCI_BUS_EXTENDED_CONFIG_SPACE;
> > > + } else {
> > > + PCIBus *parent_bus = pci_get_bus(bus->parent_dev);
> >
> >
> > g_assert(bus->parent_dev) ?
> >
> > Slightly confusingly bus->parent_dev is not the same as bus->qbus.parent
> > and can be NULL, I'd even look into ditching parent_dev and using
> > bus->qbus.parent instead (if possible).
>
> Oh boy, the can of worms I reached into following up that simple
> comment. Yes, they're subtly different, and yes it's confusing. In
> practice parent_dev is NULL when on a root bus, that's not a PXB bus,
> and otherwise equal to qbus.parent.
>
> After a *lot* of thinking about this, I think parent_dev is actually
> correct here - we're explicitly looking at the parent as a P2P bridge,
> not anything else.
>
> But, I'll try to do some later cleanups making the parent_dev /
> qbus.parent confusion a bit better.
> > > +static inline bool pci_bus_allows_extended_config_space(PCIBus *bus)
> > > +{
> > > + return !!(bus->flags & PCI_BUS_EXTENDED_CONFIG_SPACE);
> > > +}
> > > +
> > > +
> >
> > An extra empty line.
> >
> > Anyway, these are minor comments, so
> >
> > Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> >
> >
> >
> >
> > > #endif /* QEMU_PCI_BUS_H */
> > >
> >
Pls address comments and repost ok?
> --
> David Gibson | I'll have my music baroque, and my code
> david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
> | _way_ _around_!
> http://www.ozlabs.org/~dgibson
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH v4 01/15] tests: acpi: rename acpi_parse_rsdp_table() into acpi_fetch_rsdp_table()
2019-05-02 14:51 ` [Qemu-devel] [PATCH v4 01/15] " Igor Mammedov
` (2 preceding siblings ...)
(?)
@ 2019-05-12 18:19 ` Michael S. Tsirkin
2019-05-13 9:04 ` Igor Mammedov
-1 siblings, 1 reply; 289+ messages in thread
From: Michael S. Tsirkin @ 2019-05-12 18:19 UTC (permalink / raw)
To: Igor Mammedov
Cc: Andrew Jones, Ben Warren, Laszlo Ersek, qemu-devel,
Shameer Kolothum, linuxarm, Shannon Zhao, Gonglei, Wei Yang,
xuwei5, xuwei5, Philippe Mathieu-Daudé
On Thu, May 02, 2019 at 04:51:49PM +0200, Igor Mammedov wrote:
> so name would reflect what the function does
>
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> Reviewed-by: Wei Yang <richardw.yang@linux.intel.com>
> ---
> v4:
> * make it as the first patch in series
> ---
FYI this trips up git am.
Don't do two --- please: just one is enough,
second is not needed.
> tests/acpi-utils.h | 2 +-
> tests/acpi-utils.c | 2 +-
> tests/bios-tables-test.c | 2 +-
> tests/vmgenid-test.c | 2 +-
> 4 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/tests/acpi-utils.h b/tests/acpi-utils.h
> index ef388bb..4cd5553 100644
> --- a/tests/acpi-utils.h
> +++ b/tests/acpi-utils.h
> @@ -47,7 +47,7 @@ typedef struct {
> uint8_t acpi_calc_checksum(const uint8_t *data, int len);
> uint32_t acpi_find_rsdp_address(QTestState *qts);
> uint64_t acpi_get_xsdt_address(uint8_t *rsdp_table);
> -void acpi_parse_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table);
> +void acpi_fetch_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table);
> void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
> const uint8_t *addr_ptr, const char *sig,
> bool verify_checksum);
> diff --git a/tests/acpi-utils.c b/tests/acpi-utils.c
> index cc33b46..633d8f5 100644
> --- a/tests/acpi-utils.c
> +++ b/tests/acpi-utils.c
> @@ -63,7 +63,7 @@ uint64_t acpi_get_xsdt_address(uint8_t *rsdp_table)
> return le64_to_cpu(xsdt_physical_address);
> }
>
> -void acpi_parse_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table)
> +void acpi_fetch_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table)
> {
> uint8_t revision;
>
> diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
> index a506dcb..6a678bf 100644
> --- a/tests/bios-tables-test.c
> +++ b/tests/bios-tables-test.c
> @@ -89,7 +89,7 @@ static void test_acpi_rsdp_table(test_data *data)
> uint8_t *rsdp_table = data->rsdp_table, revision;
> uint32_t addr = data->rsdp_addr;
>
> - acpi_parse_rsdp_table(data->qts, addr, rsdp_table);
> + acpi_fetch_rsdp_table(data->qts, addr, rsdp_table);
> revision = rsdp_table[15 /* Revision offset */];
>
> switch (revision) {
> diff --git a/tests/vmgenid-test.c b/tests/vmgenid-test.c
> index ae38ee5..f400184 100644
> --- a/tests/vmgenid-test.c
> +++ b/tests/vmgenid-test.c
> @@ -40,7 +40,7 @@ static uint32_t acpi_find_vgia(QTestState *qts)
> g_assert_cmphex(rsdp_offset, <, RSDP_ADDR_INVALID);
>
>
> - acpi_parse_rsdp_table(qts, rsdp_offset, rsdp_table);
> + acpi_fetch_rsdp_table(qts, rsdp_offset, rsdp_table);
> acpi_fetch_table(qts, &rsdt, &rsdt_len, &rsdp_table[16 /* RsdtAddress */],
> "RSDT", true);
>
> --
> 2.7.4
On Thu, May 02, 2019 at 04:51:50PM +0200, Igor Mammedov wrote:
> Currently acpi_fetch_table() assumes 32 bit size of table pointer
> in ACPI tables. However X_foo variants are 64 bit, prepare
> acpi_fetch_table() to handle both by adding an argument
> for addr_ptr pointed entry size. Follow up commits will use that
> to read XSDT and X_foo entries in ACPI tables.
>
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
> tests/acpi-utils.h | 2 +-
> tests/acpi-utils.c | 10 ++++++----
> tests/bios-tables-test.c | 8 ++++----
> tests/vmgenid-test.c | 4 ++--
> 4 files changed, 13 insertions(+), 11 deletions(-)
>
> diff --git a/tests/acpi-utils.h b/tests/acpi-utils.h
> index 4cd5553..92285b7 100644
> --- a/tests/acpi-utils.h
> +++ b/tests/acpi-utils.h
> @@ -49,7 +49,7 @@ uint32_t acpi_find_rsdp_address(QTestState *qts);
> uint64_t acpi_get_xsdt_address(uint8_t *rsdp_table);
> void acpi_fetch_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table);
> void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
> - const uint8_t *addr_ptr, const char *sig,
> + const uint8_t *addr_ptr, int addr_size, const char *sig,
> bool verify_checksum);
>
> #endif /* TEST_ACPI_UTILS_H */
> diff --git a/tests/acpi-utils.c b/tests/acpi-utils.c
> index 633d8f5..644c87b 100644
> --- a/tests/acpi-utils.c
> +++ b/tests/acpi-utils.c
> @@ -91,13 +91,15 @@ void acpi_fetch_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table)
> * actual one.
> */
> void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
> - const uint8_t *addr_ptr, const char *sig,
> + const uint8_t *addr_ptr, int addr_size, const char *sig,
> bool verify_checksum)
> {
> - uint32_t addr, len;
> + uint32_t len;
> + uint64_t addr = 0;
>
> - memcpy(&addr, addr_ptr , sizeof(addr));
> - addr = le32_to_cpu(addr);
> + g_assert(addr_size == 4 || addr_size == 8);
> + memcpy(&addr, addr_ptr , addr_size);
> + addr = le64_to_cpu(addr);
> qtest_memread(qts, addr + 4, &len, 4); /* Length of ACPI table */
> *aml_len = le32_to_cpu(len);
> *aml = g_malloc0(*aml_len);
> diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
> index 6a678bf..86b592c 100644
> --- a/tests/bios-tables-test.c
> +++ b/tests/bios-tables-test.c
> @@ -114,14 +114,14 @@ static void test_acpi_rsdt_table(test_data *data)
>
> /* read RSDT table */
> acpi_fetch_table(data->qts, &rsdt.aml, &rsdt.aml_len,
> - &data->rsdp_table[16 /* RsdtAddress */], "RSDT", true);
> + &data->rsdp_table[16 /* RsdtAddress */], 4, "RSDT", true);
>
> /* Load all tables and add to test list directly RSDT referenced tables */
> ACPI_FOREACH_RSDT_ENTRY(rsdt.aml, rsdt.aml_len, ent, 4 /* Entry size */) {
> AcpiSdtTable ssdt_table = {};
>
> acpi_fetch_table(data->qts, &ssdt_table.aml, &ssdt_table.aml_len, ent,
> - NULL, true);
> + 4, NULL, true);
> /* Add table to ASL test tables list */
> g_array_append_val(data->tables, ssdt_table);
> }
> @@ -139,11 +139,11 @@ static void test_acpi_fadt_table(test_data *data)
>
> /* Since DSDT/FACS isn't in RSDT, add them to ASL test list manually */
> acpi_fetch_table(data->qts, &table.aml, &table.aml_len,
> - fadt_aml + 36 /* FIRMWARE_CTRL */, "FACS", false);
> + fadt_aml + 36 /* FIRMWARE_CTRL */, 4, "FACS", false);
> g_array_append_val(data->tables, table);
>
> acpi_fetch_table(data->qts, &table.aml, &table.aml_len,
> - fadt_aml + 40 /* DSDT */, "DSDT", true);
> + fadt_aml + 40 /* DSDT */, 4, "DSDT", true);
> g_array_append_val(data->tables, table);
>
> memset(fadt_aml + 36, 0, 4); /* sanitize FIRMWARE_CTRL ptr */
> diff --git a/tests/vmgenid-test.c b/tests/vmgenid-test.c
> index f400184..85d8e64 100644
> --- a/tests/vmgenid-test.c
> +++ b/tests/vmgenid-test.c
> @@ -42,12 +42,12 @@ static uint32_t acpi_find_vgia(QTestState *qts)
>
> acpi_fetch_rsdp_table(qts, rsdp_offset, rsdp_table);
> acpi_fetch_table(qts, &rsdt, &rsdt_len, &rsdp_table[16 /* RsdtAddress */],
> - "RSDT", true);
> + 4, "RSDT", true);
>
> ACPI_FOREACH_RSDT_ENTRY(rsdt, rsdt_len, ent, 4 /* Entry size */) {
> uint8_t *table_aml;
>
> - acpi_fetch_table(qts, &table_aml, &table_length, ent, NULL, true);
> + acpi_fetch_table(qts, &table_aml, &table_length, ent, 4, NULL, true);
> if (!memcmp(table_aml + 16 /* OEM Table ID */, "VMGENID", 7)) {
> uint32_t vgia_val;
> uint8_t *aml = &table_aml[36 /* AML byte-code start */];
> --
> 2.7.4
On Thu, May 02, 2019 at 04:51:51PM +0200, Igor Mammedov wrote:
> If RSDP revision is more than 0 fetch table pointed by XSDT
> and fallback to legacy RSDT table otherwise.
>
> While at it drop unused acpi_get_xsdt_address().
>
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
> PS:
> it doesn't affect existing pc/q35 machines as they use RSDP.revision == 0
> but it will be used by followup patch to enable testing arm/virt
> board which uses provides XSDT table.
>
> v4:
> * move out acpi_parse_rsdp_table() hunk to
> "tests: acpi: make pointer to RSDP 64bit"
> where it belongs
> ---
> tests/acpi-utils.h | 1 -
> tests/acpi-utils.c | 12 ------------
> tests/bios-tables-test.c | 20 ++++++++++++++------
> 3 files changed, 14 insertions(+), 19 deletions(-)
>
> diff --git a/tests/acpi-utils.h b/tests/acpi-utils.h
> index 92285b7..f55ccf9 100644
> --- a/tests/acpi-utils.h
> +++ b/tests/acpi-utils.h
> @@ -46,7 +46,6 @@ typedef struct {
>
> uint8_t acpi_calc_checksum(const uint8_t *data, int len);
> uint32_t acpi_find_rsdp_address(QTestState *qts);
> -uint64_t acpi_get_xsdt_address(uint8_t *rsdp_table);
> void acpi_fetch_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table);
> void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
> const uint8_t *addr_ptr, int addr_size, const char *sig,
> diff --git a/tests/acpi-utils.c b/tests/acpi-utils.c
> index 644c87b..a0d49c4 100644
> --- a/tests/acpi-utils.c
> +++ b/tests/acpi-utils.c
> @@ -51,18 +51,6 @@ uint32_t acpi_find_rsdp_address(QTestState *qts)
> return off;
> }
>
> -uint64_t acpi_get_xsdt_address(uint8_t *rsdp_table)
> -{
> - uint64_t xsdt_physical_address;
> - uint8_t revision = rsdp_table[15 /* Revision offset */];
> -
> - /* We must have revision 2 if we're looking for an XSDT pointer */
> - g_assert(revision == 2);
> -
> - memcpy(&xsdt_physical_address, &rsdp_table[24 /* XsdtAddress offset */], 8);
> - return le64_to_cpu(xsdt_physical_address);
> -}
> -
> void acpi_fetch_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table)
> {
> uint8_t revision;
> diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
> index 86b592c..d6ab121 100644
> --- a/tests/bios-tables-test.c
> +++ b/tests/bios-tables-test.c
> @@ -107,21 +107,29 @@ static void test_acpi_rsdp_table(test_data *data)
> }
> }
>
> -static void test_acpi_rsdt_table(test_data *data)
> +static void test_acpi_rxsdt_table(test_data *data)
> {
> + const char *sig = "RSDT";
> AcpiSdtTable rsdt = {};
> + int entry_size = 4;
> + int addr_off = 16 /* RsdtAddress */;
> uint8_t *ent;
>
> - /* read RSDT table */
> + if (data->rsdp_table[15 /* Revision offset */] != 0) {
> + addr_off = 24 /* XsdtAddress */;
> + entry_size = 8;
> + sig = "XSDT";
> + }
> + /* read [RX]SDT table */
> acpi_fetch_table(data->qts, &rsdt.aml, &rsdt.aml_len,
> - &data->rsdp_table[16 /* RsdtAddress */], 4, "RSDT", true);
> + &data->rsdp_table[addr_off], entry_size, sig, true);
>
> /* Load all tables and add to test list directly RSDT referenced tables */
> - ACPI_FOREACH_RSDT_ENTRY(rsdt.aml, rsdt.aml_len, ent, 4 /* Entry size */) {
> + ACPI_FOREACH_RSDT_ENTRY(rsdt.aml, rsdt.aml_len, ent, entry_size) {
> AcpiSdtTable ssdt_table = {};
>
> acpi_fetch_table(data->qts, &ssdt_table.aml, &ssdt_table.aml_len, ent,
> - 4, NULL, true);
> + entry_size, NULL, true);
> /* Add table to ASL test tables list */
> g_array_append_val(data->tables, ssdt_table);
> }
> @@ -521,7 +529,7 @@ static void test_acpi_one(const char *params, test_data *data)
> data->tables = g_array_new(false, true, sizeof(AcpiSdtTable));
> test_acpi_rsdp_address(data);
> test_acpi_rsdp_table(data);
> - test_acpi_rsdt_table(data);
> + test_acpi_rxsdt_table(data);
> test_acpi_fadt_table(data);
>
> if (iasl) {
> --
> 2.7.4
On Thu, May 02, 2019 at 04:51:52PM +0200, Igor Mammedov wrote:
> In case of UEFI, RSDP doesn't have to be located in lowmem,
> it could be placed at any address. Make sure that test won't
> break if it is placed above the first 4Gb of address space.
>
> PS:
> While at it cleanup some local variables as we don't really
> need them.
>
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> v4:
> - move acpi_fetch_rsdp_table(s/uint32_t addr/uint64_t addr/) to
> this patch where it belongs from
> "tests: acpi: make RSDT test routine handle XSDT"
> (Wei Yang <richardw.yang@linux.intel.com>)
> v2:
> - s/In case of UEFI/In case of UEFI,/ (Laszlo Ersek <lersek@redhat.com>)
> ---
> tests/acpi-utils.h | 2 +-
> tests/acpi-utils.c | 2 +-
> tests/bios-tables-test.c | 10 ++++------
> 3 files changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/tests/acpi-utils.h b/tests/acpi-utils.h
> index f55ccf9..1da6c10 100644
> --- a/tests/acpi-utils.h
> +++ b/tests/acpi-utils.h
> @@ -46,7 +46,7 @@ typedef struct {
>
> uint8_t acpi_calc_checksum(const uint8_t *data, int len);
> uint32_t acpi_find_rsdp_address(QTestState *qts);
> -void acpi_fetch_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table);
> +void acpi_fetch_rsdp_table(QTestState *qts, uint64_t addr, uint8_t *rsdp_table);
> void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
> const uint8_t *addr_ptr, int addr_size, const char *sig,
> bool verify_checksum);
> diff --git a/tests/acpi-utils.c b/tests/acpi-utils.c
> index a0d49c4..c216b9e 100644
> --- a/tests/acpi-utils.c
> +++ b/tests/acpi-utils.c
> @@ -51,7 +51,7 @@ uint32_t acpi_find_rsdp_address(QTestState *qts)
> return off;
> }
>
> -void acpi_fetch_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table)
> +void acpi_fetch_rsdp_table(QTestState *qts, uint64_t addr, uint8_t *rsdp_table)
> {
> uint8_t revision;
>
> diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
> index d6ab121..a164d27 100644
> --- a/tests/bios-tables-test.c
> +++ b/tests/bios-tables-test.c
> @@ -26,7 +26,7 @@
> typedef struct {
> const char *machine;
> const char *variant;
> - uint32_t rsdp_addr;
> + uint64_t rsdp_addr;
> uint8_t rsdp_table[36 /* ACPI 2.0+ RSDP size */];
> GArray *tables;
> uint32_t smbios_ep_addr;
> @@ -86,13 +86,11 @@ static void test_acpi_rsdp_address(test_data *data)
>
> static void test_acpi_rsdp_table(test_data *data)
> {
> - uint8_t *rsdp_table = data->rsdp_table, revision;
> - uint32_t addr = data->rsdp_addr;
> + uint8_t *rsdp_table = data->rsdp_table;
>
> - acpi_fetch_rsdp_table(data->qts, addr, rsdp_table);
> - revision = rsdp_table[15 /* Revision offset */];
> + acpi_fetch_rsdp_table(data->qts, data->rsdp_addr, rsdp_table);
>
> - switch (revision) {
> + switch (rsdp_table[15 /* Revision offset */]) {
> case 0: /* ACPI 1.0 RSDP */
> /* With rev 1, checksum is only for the first 20 bytes */
> g_assert(!acpi_calc_checksum(rsdp_table, 20));
> --
> 2.7.4
On Thu, May 02, 2019 at 04:51:53PM +0200, Igor Mammedov wrote:
> that way it would be possible to test a DSDT pointed by
> 64bit X_DSDT field in FADT.
>
> PS:
> it will allow to enable testing arm/virt board, which sets
> only newer X_DSDT field.
>
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
> v4:
> * dropping Reviewed-bys due to acpi_fetch_table() change
> introduced by earlier patch:
> "tests: acpi: make acpi_fetch_table() take size of fetched table pointer"
> v2:
> add 'val = le32_to_cpu(val)' even if it doesn't necessary
> it works as reminder that value copied from table is in
> little-endian format (Philippe Mathieu-Daudé <philmd@redhat.com>)
> ---
> tests/bios-tables-test.c | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
> index a164d27..d165a1b 100644
> --- a/tests/bios-tables-test.c
> +++ b/tests/bios-tables-test.c
> @@ -140,6 +140,9 @@ static void test_acpi_fadt_table(test_data *data)
> AcpiSdtTable table = g_array_index(data->tables, typeof(table), 0);
> uint8_t *fadt_aml = table.aml;
> uint32_t fadt_len = table.aml_len;
> + uint32_t val;
> + int dsdt_offset = 40 /* DSDT */;
> + int dsdt_entry_size = 4;
>
> g_assert(compare_signature(&table, "FACP"));
>
> @@ -148,8 +151,14 @@ static void test_acpi_fadt_table(test_data *data)
> fadt_aml + 36 /* FIRMWARE_CTRL */, 4, "FACS", false);
> g_array_append_val(data->tables, table);
>
> + memcpy(&val, fadt_aml + dsdt_offset, 4);
> + val = le32_to_cpu(val);
> + if (!val) {
> + dsdt_offset = 140 /* X_DSDT */;
> + dsdt_entry_size = 8;
> + }
> acpi_fetch_table(data->qts, &table.aml, &table.aml_len,
> - fadt_aml + 40 /* DSDT */, 4, "DSDT", true);
> + fadt_aml + dsdt_offset, dsdt_entry_size, "DSDT", true);
> g_array_append_val(data->tables, table);
>
> memset(fadt_aml + 36, 0, 4); /* sanitize FIRMWARE_CTRL ptr */
> --
> 2.7.4
On Thu, May 02, 2019 at 04:51:54PM +0200, Igor Mammedov wrote:
> If FADT has HW_REDUCED_ACPI flag set, do not attempt to fetch
> FACS as it's not provided by the board.
>
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> Reviewed-by: Wei Yang <richardw.yang@linux.intel.com>
> ---
> tests/bios-tables-test.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
> index d165a1b..e2fc341 100644
> --- a/tests/bios-tables-test.c
> +++ b/tests/bios-tables-test.c
> @@ -147,9 +147,13 @@ static void test_acpi_fadt_table(test_data *data)
> g_assert(compare_signature(&table, "FACP"));
>
> /* Since DSDT/FACS isn't in RSDT, add them to ASL test list manually */
> - acpi_fetch_table(data->qts, &table.aml, &table.aml_len,
> - fadt_aml + 36 /* FIRMWARE_CTRL */, 4, "FACS", false);
> - g_array_append_val(data->tables, table);
> + memcpy(&val, fadt_aml + 112 /* Flags */, 4);
> + val = le32_to_cpu(val);
> + if (!(val & 1UL << 20 /* HW_REDUCED_ACPI */)) {
> + acpi_fetch_table(data->qts, &table.aml, &table.aml_len,
> + fadt_aml + 36 /* FIRMWARE_CTRL */, 4, "FACS", false);
> + g_array_append_val(data->tables, table);
> + }
>
> memcpy(&val, fadt_aml + dsdt_offset, 4);
> val = le32_to_cpu(val);
> --
> 2.7.4
On Thu, May 02, 2019 at 04:51:55PM +0200, Igor Mammedov wrote:
> boot_sector_init() won't be used by arm/virt board, so move it from
> global scope to x86 branch that uses it.
>
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> v3:
> - fix checkpatch errors triggered by moved old code (ident/space/braces)
> ---
> tests/bios-tables-test.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
> index e2fc341..4d13a3c 100644
> --- a/tests/bios-tables-test.c
> +++ b/tests/bios-tables-test.c
> @@ -788,13 +788,14 @@ int main(int argc, char *argv[])
> const char *arch = qtest_get_arch();
> int ret;
>
> - ret = boot_sector_init(disk);
> - if(ret)
> - return ret;
> -
> g_test_init(&argc, &argv, NULL);
>
> if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
> + ret = boot_sector_init(disk);
> + if (ret) {
> + return ret;
> + }
> +
> qtest_add_func("acpi/piix4", test_acpi_piix4_tcg);
> qtest_add_func("acpi/piix4/bridge", test_acpi_piix4_tcg_bridge);
> qtest_add_func("acpi/q35", test_acpi_q35_tcg);
> --
> 2.7.4
On Thu, May 02, 2019 at 04:51:56PM +0200, Igor Mammedov wrote:
> introduce UEFI specific counterpart to acpi_find_rsdp_address()
> that will help to find RSDP address when [OA]VMF is used as
> firmware. It requires guest firmware or other guest app to place
> 1Mb aligned UefiTestSupport structure (defined in this patch)
> in RAM with UefiTestSupport::signature_guid set to
> AB87A6B1-2034-BDA0-71BD-375007757785
> For test app details see commit
> (09a274d82f tests: introduce "uefi-test-tools" with the BiosTablesTest UEFI app)
>
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
> Reviewed-by: Wei Yang <richardw.yang@linux.intel.com>
> ---
> v4:
> * update commit message to point to commit which introduced
> signature_guid value.
> v3:
> * fix checkpatch error (separate opening brace from values in AcpiTestSupportGuid initializer)
> v2:
> * Laszlo Ersek <lersek@redhat.com>
> - s/uefi_find_rsdp_addr/acpi_find_rsdp_address_uefi/
> - use GUID_SIZE instead of opencodding size
> - make AcpiTestSupportGuid const
> - s/TCI/TCG/
> ---
> tests/acpi-utils.h | 2 ++
> tests/acpi-utils.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 46 insertions(+)
>
> diff --git a/tests/acpi-utils.h b/tests/acpi-utils.h
> index 1da6c10..52c529e 100644
> --- a/tests/acpi-utils.h
> +++ b/tests/acpi-utils.h
> @@ -46,6 +46,8 @@ typedef struct {
>
> uint8_t acpi_calc_checksum(const uint8_t *data, int len);
> uint32_t acpi_find_rsdp_address(QTestState *qts);
> +uint64_t acpi_find_rsdp_address_uefi(QTestState *qts, uint64_t start,
> + uint64_t size);
> void acpi_fetch_rsdp_table(QTestState *qts, uint64_t addr, uint8_t *rsdp_table);
> void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
> const uint8_t *addr_ptr, int addr_size, const char *sig,
> diff --git a/tests/acpi-utils.c b/tests/acpi-utils.c
> index c216b9e..d2a202e 100644
> --- a/tests/acpi-utils.c
> +++ b/tests/acpi-utils.c
> @@ -101,3 +101,47 @@ void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
> g_assert(!acpi_calc_checksum(*aml, *aml_len));
> }
> }
> +
> +#define GUID_SIZE 16
> +static const uint8_t AcpiTestSupportGuid[GUID_SIZE] = {
> + 0xb1, 0xa6, 0x87, 0xab,
> + 0x34, 0x20,
> + 0xa0, 0xbd,
> + 0x71, 0xbd, 0x37, 0x50, 0x07, 0x75, 0x77, 0x85 };
> +
> +typedef struct {
> + uint8_t signature_guid[GUID_SIZE];
> + uint64_t rsdp10;
> + uint64_t rsdp20;
> +} __attribute__((packed)) UefiTestSupport;
> +
> +/* Wait at most 600 seconds (test is slow with TCG and --enable-debug) */
> +#define TEST_DELAY (1 * G_USEC_PER_SEC / 10)
> +#define TEST_CYCLES MAX((600 * G_USEC_PER_SEC / TEST_DELAY), 1)
> +#define MB 0x100000ULL
> +uint64_t acpi_find_rsdp_address_uefi(QTestState *qts, uint64_t start,
> + uint64_t size)
> +{
> + int i, j;
> + uint8_t data[GUID_SIZE];
> +
> + for (i = 0; i < TEST_CYCLES; ++i) {
> + for (j = 0; j < size / MB; j++) {
> + /* look for GUID at every 1Mb block */
> + uint64_t addr = start + j * MB;
> +
> + qtest_memread(qts, addr, data, sizeof(data));
> + if (!memcmp(AcpiTestSupportGuid, data, sizeof(data))) {
> + UefiTestSupport ret;
> +
> + qtest_memread(qts, addr, &ret, sizeof(ret));
> + ret.rsdp10 = le64_to_cpu(ret.rsdp10);
> + ret.rsdp20 = le64_to_cpu(ret.rsdp20);
> + return ret.rsdp20 ? ret.rsdp20 : ret.rsdp10;
> + }
> + }
> + g_usleep(TEST_DELAY);
> + }
> + g_assert_not_reached();
> + return 0;
> +}
> --
> 2.7.4
On Thu, May 02, 2019 at 04:51:57PM +0200, Igor Mammedov wrote:
> For testcase to use UEFI firmware, one needs to provide and specify
> firmware and varstore blob names in test_data { uefi_fl1, uefi_fl2 }
> fields respectively and RAM start address plus size where to look for
> test structure signature. Additionally testcase should specify
> bootable cdrom image from uefi-boot-images with EFI test utility.
>
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
> ---
> v4:
> * fixup commit message (typo/spelling) (Wei Yang <richardw.yang@linux.intel.com>)
> * get rid of test_acpi_rsdp_address()
> v3:
> * drop data_dir prefix and firmware will come from pc-bios directly
> * add cdrom option so test could use it for providing boot cdrom image
> * add TODO comment convert '-drive if=pflash' to new syntax (Laszlo)
> v2:
> * move RAM start address and size to test_data, as it could differ
> between boards (and even versions)
>
> dfd
> ---
> tests/bios-tables-test.c | 52 ++++++++++++++++++++++++++++++++----------------
> 1 file changed, 35 insertions(+), 17 deletions(-)
>
> diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
> index 4d13a3c..84e1ce2 100644
> --- a/tests/bios-tables-test.c
> +++ b/tests/bios-tables-test.c
> @@ -26,6 +26,11 @@
> typedef struct {
> const char *machine;
> const char *variant;
> + const char *uefi_fl1;
> + const char *uefi_fl2;
> + const char *cd;
> + const uint64_t ram_start;
> + const uint64_t scan_len;
> uint64_t rsdp_addr;
> uint8_t rsdp_table[36 /* ACPI 2.0+ RSDP size */];
> GArray *tables;
> @@ -77,13 +82,6 @@ static void free_test_data(test_data *data)
> g_array_free(data->tables, true);
> }
>
> -static void test_acpi_rsdp_address(test_data *data)
> -{
> - uint32_t off = acpi_find_rsdp_address(data->qts);
> - g_assert_cmphex(off, <, 0x100000);
> - data->rsdp_addr = off;
> -}
> -
> static void test_acpi_rsdp_table(test_data *data)
> {
> uint8_t *rsdp_table = data->rsdp_table;
> @@ -524,21 +522,41 @@ static void test_smbios_structs(test_data *data)
> static void test_acpi_one(const char *params, test_data *data)
> {
> char *args;
> -
> - /* Disable kernel irqchip to be able to override apic irq0. */
> - args = g_strdup_printf("-machine %s,accel=%s,kernel-irqchip=off "
> - "-net none -display none %s "
> - "-drive id=hd0,if=none,file=%s,format=raw "
> - "-device ide-hd,drive=hd0 ",
> - data->machine, "kvm:tcg",
> - params ? params : "", disk);
> + bool use_uefi = data->uefi_fl1 && data->uefi_fl2;
> +
> + if (use_uefi) {
> + /*
> + * TODO: convert '-drive if=pflash' to new syntax (see e33763be7cd3)
> + * when arm/virt boad starts to support it.
> + */
> + args = g_strdup_printf("-machine %s,accel=%s -nodefaults -nographic "
> + "-drive if=pflash,format=raw,file=%s,readonly "
> + "-drive if=pflash,format=raw,file=%s,snapshot=on -cdrom %s %s",
> + data->machine, "kvm:tcg", data->uefi_fl1, data->uefi_fl2,
> + data->cd, params ? params : "");
> +
> + } else {
> + /* Disable kernel irqchip to be able to override apic irq0. */
> + args = g_strdup_printf("-machine %s,accel=%s,kernel-irqchip=off "
> + "-net none -display none %s "
> + "-drive id=hd0,if=none,file=%s,format=raw "
> + "-device ide-hd,drive=hd0 ",
> + data->machine, "kvm:tcg", params ? params : "", disk);
> + }
>
> data->qts = qtest_init(args);
>
> - boot_sector_test(data->qts);
> + if (use_uefi) {
> + g_assert(data->scan_len);
> + data->rsdp_addr = acpi_find_rsdp_address_uefi(data->qts,
> + data->ram_start, data->scan_len);
> + } else {
> + boot_sector_test(data->qts);
> + data->rsdp_addr = acpi_find_rsdp_address(data->qts);
> + g_assert_cmphex(data->rsdp_addr, <, 0x100000);
> + }
>
> data->tables = g_array_new(false, true, sizeof(AcpiSdtTable));
> - test_acpi_rsdp_address(data);
> test_acpi_rsdp_table(data);
> test_acpi_rxsdt_table(data);
> test_acpi_fadt_table(data);
> --
> 2.7.4
On Thu, May 02, 2019 at 04:51:58PM +0200, Igor Mammedov wrote:
> once FW provides a pointer to SMBIOS entry point like it does for
> RSDP it should be possible to enable this one the same way.
>
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
> ---
> v3:
> - add ref to a uefi-test-tools feature req into comment (Laszlo)
> ---
> tests/bios-tables-test.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
> index 84e1ce2..8302ffc 100644
> --- a/tests/bios-tables-test.c
> +++ b/tests/bios-tables-test.c
> @@ -569,8 +569,15 @@ static void test_acpi_one(const char *params, test_data *data)
> }
> }
>
> - test_smbios_entry_point(data);
> - test_smbios_structs(data);
> + /*
> + * TODO: make SMBIOS tests work with UEFI firmware,
> + * Bug on uefi-test-tools to provide entry point:
> + * https://bugs.launchpad.net/qemu/+bug/1821884
> + */
> + if (!use_uefi) {
> + test_smbios_entry_point(data);
> + test_smbios_structs(data);
> + }
>
> assert(!global_qtest);
> qtest_quit(data->qts);
> --
> 2.7.4
On Thu, May 02, 2019 at 04:51:59PM +0200, Igor Mammedov wrote:
> By default test cases were run with 'kvm:tcg' accelerators to speed up
> tests execution. While it works for x86, were change of accelerator
> doesn't affect ACPI tables, the approach doesn't works for ARM usecase
> though.
>
> In arm/virt case, KVM mode requires using 'host' cpu model, which
> isn't available in TCG mode. That could be worked around with 'max'
> cpu model, which works both for KVM and TCG. However in KVM mode it
> is necessary to specify matching GIC version, which also could use
> 'max' value to automatically pick GIC version suitable for host's CPU.
> Depending on host cpu type, different GIC versions would be used,
> which in turn leads to different ACPI tables (APIC) generated.
> As result while comparing with reference blobs, test would fail if
> host's GIC version won't match the version on the host where
> reference blobs where generated.
>
> Let's keep testing simple for now and allow ARM tests run in TCG only
> mode. To do so introduce 'accel' parameter in test configuration, so
> test case could override default "kvm:tcg" with accelerator of choice.
>
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
> tests/bios-tables-test.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
> index 8302ffc..39c1e24 100644
> --- a/tests/bios-tables-test.c
> +++ b/tests/bios-tables-test.c
> @@ -24,6 +24,7 @@
> #define ACPI_REBUILD_EXPECTED_AML "TEST_ACPI_REBUILD_AML"
>
> typedef struct {
> + const char *accel;
> const char *machine;
> const char *variant;
> const char *uefi_fl1;
> @@ -532,8 +533,8 @@ static void test_acpi_one(const char *params, test_data *data)
> args = g_strdup_printf("-machine %s,accel=%s -nodefaults -nographic "
> "-drive if=pflash,format=raw,file=%s,readonly "
> "-drive if=pflash,format=raw,file=%s,snapshot=on -cdrom %s %s",
> - data->machine, "kvm:tcg", data->uefi_fl1, data->uefi_fl2,
> - data->cd, params ? params : "");
> + data->machine, data->accel ? data->accel : "kvm:tcg",
> + data->uefi_fl1, data->uefi_fl2, data->cd, params ? params : "");
>
> } else {
> /* Disable kernel irqchip to be able to override apic irq0. */
> @@ -541,7 +542,8 @@ static void test_acpi_one(const char *params, test_data *data)
> "-net none -display none %s "
> "-drive id=hd0,if=none,file=%s,format=raw "
> "-device ide-hd,drive=hd0 ",
> - data->machine, "kvm:tcg", params ? params : "", disk);
> + data->machine, data->accel ? data->accel : "kvm:tcg",
> + params ? params : "", disk);
> }
>
> data->qts = qtest_init(args);
> --
> 2.7.4
On Thu, May 02, 2019 at 04:52:00PM +0200, Igor Mammedov wrote:
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> this patch is ahead fo "tests: acpi: add simple arm/virt testcase"
> to keep 'make check' working during bisection and not to pollute
> code with binary blobs which are not reviewable.
> ---
> tests/data/acpi/virt/APIC | Bin 0 -> 168 bytes
> tests/data/acpi/virt/DSDT | Bin 0 -> 18476 bytes
> tests/data/acpi/virt/FACP | Bin 0 -> 268 bytes
> tests/data/acpi/virt/GTDT | Bin 0 -> 96 bytes
> tests/data/acpi/virt/MCFG | Bin 0 -> 60 bytes
> tests/data/acpi/virt/SPCR | Bin 0 -> 80 bytes
> 6 files changed, 0 insertions(+), 0 deletions(-)
> create mode 100644 tests/data/acpi/virt/APIC
> create mode 100644 tests/data/acpi/virt/DSDT
> create mode 100644 tests/data/acpi/virt/FACP
> create mode 100644 tests/data/acpi/virt/GTDT
> create mode 100644 tests/data/acpi/virt/MCFG
> create mode 100644 tests/data/acpi/virt/SPCR
>
> diff --git a/tests/data/acpi/virt/APIC b/tests/data/acpi/virt/APIC
> new file mode 100644
> index 0000000000000000000000000000000000000000..797dfde2841c51b7e72065602e99ce1714347f0d
> GIT binary patch
> literal 168
> zcmZ<^@N{0mz`($~*~#D8BUr&HBEZ=ZD8>jB1F=Cg4Dd+6SPUF6788)c?E~X6Fu>G{
> hBZPn~MyPrgD9sGlkD?67;f3451Xcqw&w(L;0RYV=2>}2A
>
> literal 0
> HcmV?d00001
>
> diff --git a/tests/data/acpi/virt/DSDT b/tests/data/acpi/virt/DSDT
> new file mode 100644
> index 0000000000000000000000000000000000000000..20e85c7f89f645c69935c615c07084e221419960
> GIT binary patch
> literal 18476
> zcmc)ScU)EVAII^7km3at6myGa+R|dUS|(gjDG>rqi;BuJN5jfYEla7?tSq%Xt!(eT
> zr!AYd_uhN&!S8+U(D&=t`StIw9$oH>d%mB0pK#D~&LeJRL*=*uql2K;?26j>=!V`E
> z6YJuY`dmg31mXSgWB#J~S-UqiR5Ud<cZ(Mn7iTw(uCB~0kJnWzh6dS9<Etx!#^$Q5
> zcx_Gk!TOrf#l<BhsRy&0;`I#$-C~^=whh9GZG-$EIH7frk<mvrM_ZLw*5`%~G&Yxv
> z9Mh1RGG=Ujt)>jdl!92h)D&$WWX;hthf7M5uZl}Dl25#TNmhEvu#pquBa=&ZuBsU?
> zNU5HsVO)7EM{DBc|GlzR+b&ufK3RFzF7@fJLGsy(?FFt|xgHw}TBWeXJ_0W|JtBPC
> ze~f4qtRGR58c`9xic&YHN5oo1&B(GDr9Pu9az<v<jMg@z%x4UWoRJkZBim*S@)?68
> zXKWBPBW5!O`-~xxGg?Q@$h8?me8$ko8Ev9ww6hsQea5iJ8QD=Y@@>X2pRsl1jJ8oT
> zI@pY@ZAJ-xjMnWRv8Wk^He(x~5xJZ4ha|nLZ)h{N^%>FoX>Qc(=wdUr^BK|mX<pQf
> zZZ>0kpAo&Ewu_q4!)6Tk8PWS``=}YcY{m{gBYHp0kDAfjW{mI|(fesZ)QpX6M!C<3
> z-cLJ3&DhvxRQQbO{j_7$jQ%zwZZk@w_tV0t8JpUSN}mzEpLU9xvANBt@)^<l>4s4=
> z2H1>|J|lWR?Hn~@OPevuXGHI(U7}_b+YJ3Rp7<Lo{JWtvdOz(NHKWvKRQrtR{j^)u
> zj6pVIN1qYBpLUO$F~nx<<TIl8(;iVXhS`iUJ|lWR?HM&=8=FyMGs>d((_T?CwzC;y
> zeMa<tS`;;7xXq|d%~<euW?j5G^+M{#))ki*57U85TnA*yDhm%|sz&LyqGGIWbzr4i
> z9iiog>%s@e)fW`SdejB+pgPzu=p7X6ze?Sk6-*5#>0_Xck_RDm_2W7&y)ZK;$m)=j
> zmDAD^jB3z`<oyiYF9|y2hM$kMQk146Q&ARl$ji!YX~_t}HQFv!;VNy|F8Nquoi<Hp
> zxKi^I+v=DpxoxV#mFZ1&KomZsHchNlhAY$0l9^bUeg&C9xH7$IW^$!AO{`RgEA@&J
> z&!VHl<hH3w855i804k+Sr#m-*bA!ZlrkxukSEgUQ(w(j0)FH86L3&diaJf_I&Ngti
> zfwK*rN_S?%nVndf{*veb&7DejwuMs%^U1GX;!Dz&PNh3zaK_-&0i8RQ?#zKR2hJQi
> zmG0CTg?&GB;nV@3JC*LtgEJ4#JUW%`YzJpMICa42PNh5B!`U9r_H-)Usgo&l=EJE2
> zOm`~XSpa7NoCS0$-Pr-o4shy#)SXIqc7(GdoE_;@y0Z|@LO68*>rSORJHgor&Q5eH
> z-MJy08^WmrUUw?p*%{8xaCW9s=}w($+V`^yoH{^ur_!BW;p_@$S2~sM>;`8yICVhn
> zPNh4$!`U6q?sO{M*#piVaOwcuol1B1gtI4{J?T`svlpDb;M4)TJC*J%g0l$DB081s
> z><wpcICX&UPNh5hz}W}RK6EPGxe=Tj!Ko7hcPic47tX$L_N7zl&W+*R7*3r)xKruQ
> zesK1Kvmc#GclL*~Kb$(@aHrCpo4~mVoSV?8bmyjUZVIPPP~53>=Vowj2IppUD&4s`
> zoSVa`6B>6a-MIyvTfn&mol18OfO7zxIstO0(wzh090=z?I+gC+63#8*)CrS2mG0aM
> z&aL3wicY0FbzRQ>ye)=PCs^)Ox>J|qv@(6<SpsJXol1A=BAiyHk337^)Crk8mG0D~
> zH?2$`-<H8yMyJx9y5MHcL2&8>&Yenk>N1--2g5m-PNh3_am}1V;M579JC*L#B{g#n
> zg>xvKN_Xl)nmLETsS`wZD&48eXXe}*&aLTGx>Fa;%()GmI-zu@(w(|gX3lNl+?GzI
> zJ9UA~oZG>v6Hs?5-KooB=G-36?depyQy0U`IUG)%u)0&}PF(^s=MHf0K&R53Bj6kX
> z=LkBL?ktD19L{n&mG0C<E^}7ESwW}Low~GT&N!TLI+gC!1ud;ip8;3GSxKkTow|&r
> zmFYi+s^F}mQ|V4!yfWuVI7iZ{bf+#^nR67Jqv%w+Qx~etIU3H<bSmAc%Twm8hO?SZ
> zr8{*|%A7mGxg(uQcj{7<Id_6{Cpwkx)CDMWj)8Lwol1A=vXeP$;H;rj=}uj2GUr%0
> z$I_{Er!Fy>vlh-;I+gCMgR>6KIy#l^+!@ZD;oO-{r9124tcSCnPNh2=;B0`iflj46
> z$H6%c&T(`q-8ml4@o<i(Q|ZoK;M@hyUFcN0a{`<b;G96G(w!6GoCxPcI+gC+70zAZ
> z+?7tHJ9mR~H#m2rQ|Zn|I2++?q*Lk6-QnCF&fV!$x^oXW_keQ`I+gC+6V5&1+>=hF
> zJDcEag0qQEr91b6b1yjeqEqS4z2V#&&b{eWx^o{m_knXCI+gC61m`3;C()^N=e}_6
> z3+KLcD&488-uCD1esJzbr_!C1;hYTTWIC1Z+#k;U;oP52r8}p<IR(xsbSm9B70#(}
> zPNh@n&S`K?gL4|4N_S3&b2^;U=~TM&05}hT^8h-P?mQ6A1K~W7PNh2!g7Y9a5291)
> z&V%7R7|w&~RJwBpoHO8@L8sE4hroFVoQKe<bmyUP9t!87bSm9>7@UW}c^I8acg}=!
> zCY&?rRJ!wUI1h*Oa5|OloCW7BIA_tRbmtLp9s%bObSm9B8_wBq&Zbl8&N*<-fpZR>
> zN_WnMb1s~7=~TM&NH~v#^GG_C?mP<4qu@M>PNh5N!8s4kd2}k>c{H3y!+A8FN_QRu
> z=P_^|L#NW6^WmHi=X^Sq?py%p0yr1YsdQ&EoXv1H)2Vdlv2Y#>=dpAu-FY0G$H93V
> zol18e59jf49#5yzoeSYy2<JjNmF`>w=OQ>4(W!LjVmKGWxtLC+J5PY~1UOHiQ|Znn
> za4vy!37txJo(SiOaGpq~(w!&4c@mr_(W!Lj$#9+w=gD*`-MJLbrEo5#Q|ZoA;5-G+
> zQ|MH>^Hexbh4WN8mF`>y=Q22#(W!LjayXa6xtva=J6FKD0?rk5D&2V+oTtHg8l6ga
> zo(|{faGp-5(w%3(c?O(k(5ZCinQ)#7=b3aW-FX(AXTf<Eol19}4d>Z#o=vCHo#()L
> z4xH!EsdVSLaGne2xpXSsc^;hS!Fe8?N_U<Q=lO7+Pp8tI7r=P|oEOlkbmxU|UI^!f
> zbSmAs63&%yuB21x&Wqr@2+oV>RJ!wGI4_3tVmg)Xyadim;Jk!Rr8`%_xeCrzbSm9>
> zDV&$Wc`2PrcU}hPWpG|br_!C5!+ANJm(!_q=M`{X0p}HTD&2V{oL9nmC7nulUIph>
> za9%~H(w$esc{Q9@)2VdlHE>=7=QVUH-FYpX*TQ)%ol19J2j_KgUPq_Wo!7&8J)GCm
> zsdVQJaNYpt4Rk8qc_W-R!g(W|N_XA_=S^_lM5of7H^X@|oHx^{bmuK_-U8<>bSm9>
> zE1b8&c`Kbtcisl)ZE)U3r_!Cb!+ATLx6`R~=N)j~0p}fbD&2V}oOi-`C!I=n-Ua7f
> zaNb3y(w%q1c{iMQ)2VdlJ#gLw=RI^P-FYvZ_riHEol1A!2j_io-bbg>o%h3eKb-f|
> zsdVQ9a6SO%19U3g`5>GR!ucSbN_Rd4=R<HlM5of7tKnP?=W05Y?tB=|hv9sfPNh2^
> zf%6eKAE8s}&PU;V6wXKKRJ!vqI3I)aF*=p*d>qcl;e4D<r90QaxdzTPbSmBX1e{O6
> z`2?LxcRmT{lW;ysr_!BI!TA)NPtmD#=hJXL4d>HzD&6@EoX^1d44q1MJ`3lwa6U_?
> z(w%GJTnpz~I+gBx4$kM`e2z|~JD-R1c{rb^Q|ZnZ;Cunj7wA;F^F=scg!4r@mF|2A
> z&X?ePiB6?EUxxE#IA5ky>CRW+d<D)|=v2D%RXAUT^Hn;P?tBf-*Wi4OPNh3vhx2tf
> zU#C;)&NtwE1I{<-RJ!v`INyZxO*)nCd<)LE;Czctr90n-^KCfarc>$8ci?;n&Uffk
> zy7OH)--YvCI+gBx56<`Ce2-40JKu-%eK_BzQ|ZnR;QRp259n07^Fug4g!4l>mG1lq
> z&X3^yh)$(DKZf&TI6tOS>CR8!`~=QV=v2D%Q#e0`^HVyN?)(hS&*1!wPNh3Phx2nd
> zKc`da&M)Bn0?se!RJ!v^IKPDROFEVA{0h#m;QWeCr8~cd^J_T2rc>$8Z{Yj}&Tr^c
> zy7OB&zlHN#I+gDH4$kl3{EkkgJHLnXdpN(RQ|Znh;QRs3ALvxN^G7&;g!4x_mG1lr
> z&Y$4?iB6?Ee}?mCIDe*7>CRu^`~}Wm=v2D%S2%x#^H(~R?)(kT-{Aa>PNh44hx2zh
> zf2ULF&OhM%1I|C_RJ!v|IRAw6Pdb(E{0q*%;QWhDr91zI^KUr+rc>$87C2krY@t(`
> zbT&3uXX$^8vEMh17mrN-KB;c&^rjx|VmXO7^5`2R-^e3;qYr+ruys>IeM3fSRO<I%
> z!(UeYU!yjT7?u1SN2PvU``<?Oix`#s97m;oYy00u^^X{p{9I~OVSZD*qC8mDP8;Tr
> z&`n`&`|y2Fg6#T=@goaHw~5VMoENmp)gwWmZ$=PgEb1Htxf$VI{gdC)^7ruM-Igu&
> zNJegEvb1$#^A<gt5iHrl)+9EVuiKXJpY-ObkKyO%1grjU&z#*bzOF9Fj*qJ!6BLeZ
> z+f>^S&ss7)h*wT1Svj`NiYWyhWBH9WZ<PH~)MLaM6K0k_u>C8OmrRdkX@gRI%+|-U
> z8DWHT!aHT*s2N9wx3Qi<_+e#-<twIU%$TPKOJdo{(Os6WShsERf&9b+Gr|SoBdexg
> zl%HCXm3U;;^umEnl?^pnEBhp0)!LzJK57^|w`N)A&uhA_j@PVgyJDKYkeL}7;f>w|
> zCa1oxxGDL|)s4+HS@l)vx2#F-LE(GJgg*#nvEqMxyAr#GzF9>hQs1W3hy3tk_y#kh
> z+l;EKP5s1`C*DVANccWF>wb|tH9P&T8$ss!chlJ<F+$r`RTuP)^**V)_Lt<pdO-VH
> q*Pxf~WCr0A=(!5>nyQM+f`xSx>MLUN8=H&5JIVJQNjl<q-v0n?ptJx0
>
> literal 0
> HcmV?d00001
>
> diff --git a/tests/data/acpi/virt/FACP b/tests/data/acpi/virt/FACP
> new file mode 100644
> index 0000000000000000000000000000000000000000..27de99f51bfe846b1f8796ace49d83f5b33a1aed
> GIT binary patch
> literal 268
> ycmZ>BbPnKQWME+3?d0$55v<@85#a0w6axw|fY>0Kx<CNcIA#XwTY+i=(L4a*H3tCz
>
> literal 0
> HcmV?d00001
>
> diff --git a/tests/data/acpi/virt/GTDT b/tests/data/acpi/virt/GTDT
> new file mode 100644
> index 0000000000000000000000000000000000000000..10107a65e958ff6495bb8c17d63d0539690f59f6
> GIT binary patch
> literal 96
> zcmZ<{aS2IaU|?Xn>E!S15v<@85#a0&6k`O6f!H7#8OTC8azL5|h^3)?DJYFj0RVOU
> B2mt^9
>
> literal 0
> HcmV?d00001
>
> diff --git a/tests/data/acpi/virt/MCFG b/tests/data/acpi/virt/MCFG
> new file mode 100644
> index 0000000000000000000000000000000000000000..e8987e1af0ec3829770bf4fe11fab02b06160dd2
> GIT binary patch
> literal 60
> scmeZuc5}C3U|?YMck*}k2v%^42ypfViZKGkKx`0=1Oyx)oc|yS05YNo0RR91
>
> literal 0
> HcmV?d00001
>
> diff --git a/tests/data/acpi/virt/SPCR b/tests/data/acpi/virt/SPCR
> new file mode 100644
> index 0000000000000000000000000000000000000000..377271a0e7817cc21a28c02123a89facad63604f
> GIT binary patch
> literal 80
> zcmWFza1IJ!U|?VpcJg=j2v%^42yhMtiZKGkKx`1r48#l^3?L>agsBLmm>C$E7#RKo
> I0Z0r60QF4^0RR91
>
> literal 0
> HcmV?d00001
>
> --
> 2.7.4
On Thu, May 02, 2019 at 04:52:01PM +0200, Igor Mammedov wrote:
> adds simple arm/virt test case that starts guest with
> bios-tables-test.aarch64.iso.qcow2 boot image which
> initializes UefiTestSupport* structure in RAM once
> guest is booted.
>
> * see commit: tests: acpi: add acpi_find_rsdp_address_uefi() helper
>
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> v4:
> * force test to use TCG accelerator
> v3:
> * use firmware blobs directly from pc-bios directory
> * use bios-tables-test.aarch64.iso.qcow2 as test boot image
> * drop leftover qtest-uefi-images-aarch64 iMakefile rule from
> previos version (Laszlo)
> * add Makefile rule to include bios-tables-test into
> check-qtest-aarch64 target
> v2:
> * specify in test_data where board's RAM starts and RAM size
>
> fixup! tests: acpi: add simple arm/virt testcase
>
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
> tests/Makefile.include | 1 +
> tests/bios-tables-test.c | 18 ++++++++++++++++++
> 2 files changed, 19 insertions(+)
>
> diff --git a/tests/Makefile.include b/tests/Makefile.include
> index e2432d5..983c8b1 100644
> --- a/tests/Makefile.include
> +++ b/tests/Makefile.include
> @@ -267,6 +267,7 @@ check-qtest-arm-y += tests/hexloader-test$(EXESUF)
> check-qtest-aarch64-y = tests/numa-test$(EXESUF)
> check-qtest-aarch64-y += tests/boot-serial-test$(EXESUF)
> check-qtest-aarch64-y += tests/migration-test$(EXESUF)
> +check-qtest-aarch64-y += tests/bios-tables-test$(EXESUF)
>
> check-qtest-microblazeel-y += $(check-qtest-microblaze-y)
>
> diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
> index 39c1e24..eaa1b0c 100644
> --- a/tests/bios-tables-test.c
> +++ b/tests/bios-tables-test.c
> @@ -810,6 +810,22 @@ static void test_acpi_piix4_tcg_dimm_pxm(void)
> test_acpi_tcg_dimm_pxm(MACHINE_PC);
> }
>
> +static void test_acpi_virt_tcg(void)
> +{
> + test_data data = {
> + .machine = "virt",
> + .accel = "tcg",
> + .uefi_fl1 = "pc-bios/edk2-aarch64-code.fd",
> + .uefi_fl2 = "pc-bios/edk2-arm-vars.fd",
> + .cd = "tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2",
> + .ram_start = 0x40000000ULL,
> + .scan_len = 128ULL * 1024 * 1024,
> + };
> +
> + test_acpi_one("-cpu cortex-a57", &data);
> + free_test_data(&data);
> +}
> +
> int main(int argc, char *argv[])
> {
> const char *arch = qtest_get_arch();
> @@ -838,6 +854,8 @@ int main(int argc, char *argv[])
> qtest_add_func("acpi/q35/numamem", test_acpi_q35_tcg_numamem);
> qtest_add_func("acpi/piix4/dimmpxm", test_acpi_piix4_tcg_dimm_pxm);
> qtest_add_func("acpi/q35/dimmpxm", test_acpi_q35_tcg_dimm_pxm);
> + } else if (strcmp(arch, "aarch64") == 0) {
> + qtest_add_func("acpi/virt", test_acpi_virt_tcg);
> }
> ret = g_test_run();
> boot_sector_cleanup(disk);
> --
> 2.7.4
On Thu, May 02, 2019 at 04:52:02PM +0200, Igor Mammedov wrote:
> Make initial list contain aarch64 and x86_64 targets.
>
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> v4:
> * fix typo (Wei Yang <richardw.yang@linux.intel.com>)
> v2:
> * fix up error message (Philippe Mathieu-Daudé <philmd@redhat.com>)
> ---
> tests/data/acpi/rebuild-expected-aml.sh | 23 +++++++++++------------
> 1 file changed, 11 insertions(+), 12 deletions(-)
>
> diff --git a/tests/data/acpi/rebuild-expected-aml.sh b/tests/data/acpi/rebuild-expected-aml.sh
> index abdff70..07f7e3f 100755
> --- a/tests/data/acpi/rebuild-expected-aml.sh
> +++ b/tests/data/acpi/rebuild-expected-aml.sh
> @@ -7,21 +7,12 @@
> #
> # Authors:
> # Marcel Apfelbaum <marcel.a@redhat.com>
> +# Igor Mammedov <imammedo@redhat.com>
> #
> # This work is licensed under the terms of the GNU GPLv2.
> # See the COPYING.LIB file in the top-level directory.
>
> -qemu=
> -
> -if [ -e x86_64-softmmu/qemu-system-x86_64 ]; then
> - qemu="x86_64-softmmu/qemu-system-x86_64"
> -elif [ -e i386-softmmu/qemu-system-i386 ]; then
> - qemu="i386-softmmu/qemu-system-i386"
> -else
> - echo "Run 'make' to build the qemu exectutable!"
> - echo "Run this script from the build directory."
> - exit 1;
> -fi
> +qemu_bins="aarch64-softmmu/qemu-system-aarch64 x86_64-softmmu/qemu-system-x86_64"
>
> if [ ! -e "tests/bios-tables-test" ]; then
> echo "Test: bios-tables-test is required! Run make check before this script."
> @@ -29,6 +20,14 @@ if [ ! -e "tests/bios-tables-test" ]; then
> exit 1;
> fi
>
> -TEST_ACPI_REBUILD_AML=y QTEST_QEMU_BINARY=$qemu tests/bios-tables-test
> +for qemu in $qemu_bins; do
> + if [ ! -e $qemu ]; then
> + echo "Run 'make' to build the following QEMU executables: $qemu_bins"
> + echo "Also, run this script from the build directory."
> + exit 1;
> + fi
> + TEST_ACPI_REBUILD_AML=y QTEST_QEMU_BINARY=$qemu tests/bios-tables-test
> +done
> +
>
> echo "The files were rebuilt and can be added to git."
> --
> 2.7.4
On Thu, May 02, 2019 at 04:52:03PM +0200, Igor Mammedov wrote:
> Instead of just asserting print the error that lead to assert first.
> While at it move assert into rebuild branch, which removes redundant
> check done in case of !rebuild branch is taken (the later is taken
> care of by g_assert_no_error).
>
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> Reviewed-by: Wei Yang <richardw.yang@linux.intel.com>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> v4:
> * fix typo in commit message (Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>)
> ---
> tests/bios-tables-test.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
> index eaa1b0c..6cb8b16 100644
> --- a/tests/bios-tables-test.c
> +++ b/tests/bios-tables-test.c
> @@ -195,11 +195,14 @@ static void dump_aml_files(test_data *data, bool rebuild)
> sdt->aml, ext);
> fd = g_open(aml_file, O_WRONLY|O_TRUNC|O_CREAT,
> S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH);
> + if (fd < 0) {
> + perror(aml_file);
> + }
> + g_assert(fd >= 0);
> } else {
> fd = g_file_open_tmp("aml-XXXXXX", &sdt->aml_file, &error);
> g_assert_no_error(error);
> }
> - g_assert(fd >= 0);
>
> ret = qemu_write_full(fd, sdt->aml, sdt->aml_len);
> g_assert(ret == sdt->aml_len);
> --
> 2.7.4
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [Qemu-ppc] [PATCH v2 3/3] pcie: Simplify pci_adjust_config_limit()
2019-05-12 18:13 ` Michael S. Tsirkin
@ 2019-05-13 6:20 ` David Gibson
0 siblings, 0 replies; 289+ messages in thread
From: David Gibson @ 2019-05-13 6:20 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: Alexey Kardashevskiy, qemu-devel, Greg Kurz, Alex Williamson,
qemu-ppc, clg
[-- Attachment #1: Type: text/plain, Size: 4503 bytes --]
On Sun, May 12, 2019 at 02:13:30PM -0400, Michael S. Tsirkin wrote:
> On Tue, May 07, 2019 at 02:48:38PM +1000, David Gibson wrote:
> > On Fri, Apr 26, 2019 at 04:40:17PM +1000, Alexey Kardashevskiy wrote:
> > >
> > >
> > > On 24/04/2019 14:19, David Gibson wrote:
> > > > Since c2077e2c "pci: Adjust PCI config limit based on bus topology",
> > > > pci_adjust_config_limit() has been used in the config space read and write
> > > > paths to only permit access to extended config space on buses which permit
> > > > it. Specifically it prevents access on devices below a vanilla-PCI bus via
> > > > some combination of bridges, even if both the host bridge and the device
> > > > itself are PCI-E.
> > > >
> > > > It accomplishes this with a somewhat complex call up the chain of bridges
> > > > to see if any of them prohibit extended config space access. This is
> > > > overly complex, since we can always know if the bus will support such
> > > > access at the point it is constructed.
> > > >
> > > > This patch simplifies the test by using a flag in the PCIBus instance
> > > > indicating whether extended configuration space is accessible. It is
> > > > false for vanilla PCI buses. For PCI-E buses, it is true for root
> > > > buses and equal to the parent bus's's capability otherwise.
> > > >
> > > > For the special case of sPAPR's paravirtualized PCI root bus, which
> > > > acts mostly like vanilla PCI, but does allow extended config space
> > > > access, we override the default value of the flag from the host bridge
> > > > code.
> > > >
> > > > This should cause no behavioural change.
> > > >
> > > > Signed-off-by: David Gibson <david@gibson.dropbear.id.au>cd
> > > > ---
> > > > hw/pci/pci.c | 41 ++++++++++++++++++++++------------------
> > > > hw/pci/pci_host.c | 13 +++----------
> > > > hw/ppc/spapr_pci.c | 34 ++++++++++-----------------------
> > > > include/hw/pci/pci.h | 1 -
> > > > include/hw/pci/pci_bus.h | 9 ++++++++-
> > > > 5 files changed, 44 insertions(+), 54 deletions(-)
> > > >
> > > > diff --git a/hw/pci/pci.c b/hw/pci/pci.c
> > > > index ea5941fb22..59ee034331 100644
> > > > --- a/hw/pci/pci.c
> > > > +++ b/hw/pci/pci.c
> > > > @@ -120,6 +120,27 @@ static void pci_bus_realize(BusState *qbus, Error **errp)
> > > > vmstate_register(NULL, -1, &vmstate_pcibus, bus);
> > > > }
> > > >
> > > > +static void pcie_bus_realize(BusState *qbus, Error **errp)
> > > > +{
> > > > + PCIBus *bus = PCI_BUS(qbus);
> > > > +
> > > > + pci_bus_realize(qbus, errp);
> > > > +
> > > > + /*
> > > > + * A PCI-E bus can support extended config space if it's the root
> > > > + * bus, or if the bus/bridge above it does as well
> > > > + */
> > > > + if (pci_bus_is_root(bus)) {
> > > > + bus->flags |= PCI_BUS_EXTENDED_CONFIG_SPACE;
> > > > + } else {
> > > > + PCIBus *parent_bus = pci_get_bus(bus->parent_dev);
> > >
> > >
> > > g_assert(bus->parent_dev) ?
> > >
> > > Slightly confusingly bus->parent_dev is not the same as bus->qbus.parent
> > > and can be NULL, I'd even look into ditching parent_dev and using
> > > bus->qbus.parent instead (if possible).
> >
> > Oh boy, the can of worms I reached into following up that simple
> > comment. Yes, they're subtly different, and yes it's confusing. In
> > practice parent_dev is NULL when on a root bus, that's not a PXB bus,
> > and otherwise equal to qbus.parent.
> >
> > After a *lot* of thinking about this, I think parent_dev is actually
> > correct here - we're explicitly looking at the parent as a P2P bridge,
> > not anything else.
> >
> > But, I'll try to do some later cleanups making the parent_dev /
> > qbus.parent confusion a bit better.
> > > > +static inline bool pci_bus_allows_extended_config_space(PCIBus *bus)
> > > > +{
> > > > + return !!(bus->flags & PCI_BUS_EXTENDED_CONFIG_SPACE);
> > > > +}
> > > > +
> > > > +
> > >
> > > An extra empty line.
> > >
> > > Anyway, these are minor comments, so
> > >
> > > Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> > >
> > >
> > >
> > >
> > > > #endif /* QEMU_PCI_BUS_H */
> > > >
> > >
>
> Pls address comments and repost ok?
Done.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH v4 01/15] tests: acpi: rename acpi_parse_rsdp_table() into acpi_fetch_rsdp_table()
2019-05-12 18:19 ` Michael S. Tsirkin
@ 2019-05-13 9:04 ` Igor Mammedov
2019-05-13 9:35 ` Igor Mammedov
0 siblings, 1 reply; 289+ messages in thread
From: Igor Mammedov @ 2019-05-13 9:04 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: Andrew Jones, Ben Warren, Laszlo Ersek, qemu-devel,
Shameer Kolothum, linuxarm, Shannon Zhao, Gonglei, Wei Yang,
xuwei5, xuwei5, Philippe Mathieu-Daudé
On Sun, 12 May 2019 14:19:08 -0400
"Michael S. Tsirkin" <mst@redhat.com> wrote:
> On Thu, May 02, 2019 at 04:51:49PM +0200, Igor Mammedov wrote:
> > so name would reflect what the function does
> >
> > Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> > Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> > Reviewed-by: Wei Yang <richardw.yang@linux.intel.com>
> > ---
> > v4:
> > * make it as the first patch in series
> > ---
>
>
> FYI this trips up git am.
> Don't do two --- please: just one is enough,
> second is not needed.
strange, git am works for me just fine.
I've always formated par patch comments this way and I think it's rather
common approach on the list.
What version of git do you use?
Anyways,
shall I rebase and resend series? (it doesn't apply to master anymore)
>
[...]
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH v4 01/15] tests: acpi: rename acpi_parse_rsdp_table() into acpi_fetch_rsdp_table()
2019-05-13 9:04 ` Igor Mammedov
@ 2019-05-13 9:35 ` Igor Mammedov
0 siblings, 0 replies; 289+ messages in thread
From: Igor Mammedov @ 2019-05-13 9:35 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: Andrew Jones, Ben Warren, Philippe Mathieu-Daudé,
linuxarm, Shameer Kolothum, qemu-devel, Shannon Zhao, Gonglei,
Wei Yang, xuwei5, xuwei5, Laszlo Ersek
On Mon, 13 May 2019 11:04:40 +0200
Igor Mammedov <imammedo@redhat.com> wrote:
> On Sun, 12 May 2019 14:19:08 -0400
> "Michael S. Tsirkin" <mst@redhat.com> wrote:
>
> > On Thu, May 02, 2019 at 04:51:49PM +0200, Igor Mammedov wrote:
> > > so name would reflect what the function does
> > >
> > > Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> > > Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> > > Reviewed-by: Wei Yang <richardw.yang@linux.intel.com>
> > > ---
> > > v4:
> > > * make it as the first patch in series
> > > ---
> >
> >
> > FYI this trips up git am.
> > Don't do two --- please: just one is enough,
> > second is not needed.
>
> strange, git am works for me just fine.
> I've always formated par patch comments this way and I think it's rather
> common approach on the list.
>
> What version of git do you use?
>
[...]
> (it doesn't apply to master anymore)
never mind, it applies just fine (I've missed one patch when applying)
>
> >
> [...]
>
>
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH v4 6/6] acpi: pci: use build_append_foo() API to construct MCFG
2019-04-19 0:30 ` Wei Yang
(?)
@ 2019-05-15 1:10 ` Michael S. Tsirkin
2019-05-15 5:29 ` Philippe Mathieu-Daudé
2019-05-15 8:46 ` Wei Yang
-1 siblings, 2 replies; 289+ messages in thread
From: Michael S. Tsirkin @ 2019-05-15 1:10 UTC (permalink / raw)
To: Wei Yang
Cc: yang.zhong, peter.maydell, qemu-devel, shannon.zhaosl, qemu-arm,
imammedo, philmd
On Fri, Apr 19, 2019 at 08:30:53AM +0800, Wei Yang wrote:
> build_append_foo() API doesn't need explicit endianness conversions
> which eliminates a source of errors and it makes build_mcfg() look like
> declarative definition of MCFG table in ACPI spec, which makes it easy
> to review.
>
> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
> Suggested-by: Igor Mammedov <imammedo@redhat.com>
> Reviewed-by: Igor Mammedov <imammedo@redhat.com>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Causes a regression with an invalid MCFG produced.
Dropped.
> ---
> hw/acpi/pci.c | 33 +++++++++++++++++++++------------
> include/hw/acpi/acpi-defs.h | 18 ------------------
> 2 files changed, 21 insertions(+), 30 deletions(-)
>
> diff --git a/hw/acpi/pci.c b/hw/acpi/pci.c
> index fa0fa30bb9..341805e786 100644
> --- a/hw/acpi/pci.c
> +++ b/hw/acpi/pci.c
> @@ -30,17 +30,26 @@
>
> void build_mcfg(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
> {
> - AcpiTableMcfg *mcfg;
> - int len = sizeof(*mcfg) + sizeof(mcfg->allocation[0]);
> -
> - mcfg = acpi_data_push(table_data, len);
> - mcfg->allocation[0].address = cpu_to_le64(info->base);
> -
> - /* Only a single allocation so no need to play with segments */
> - mcfg->allocation[0].pci_segment = cpu_to_le16(0);
> - mcfg->allocation[0].start_bus_number = 0;
> - mcfg->allocation[0].end_bus_number = PCIE_MMCFG_BUS(info->size - 1);
> -
> - build_header(linker, table_data, (void *)mcfg, "MCFG", len, 1, NULL, NULL);
> + int mcfg_start = table_data->len;
> +
> + acpi_data_push(table_data, sizeof(AcpiTableHeader));
> +
> + /*
> + * PCI Firmware Specification, Revision 3.0
> + * 4.1.2 MCFG Table Description.
> + */
> + /* Base address, processor-relative */
> + build_append_int_noprefix(table_data, info->base, 8);
> + /* PCI segment group number */
> + build_append_int_noprefix(table_data, 0, 2);
> + /* Starting PCI Bus number */
> + build_append_int_noprefix(table_data, 0, 1);
> + /* Final PCI Bus number */
> + build_append_int_noprefix(table_data, PCIE_MMCFG_BUS(info->size - 1), 1);
> + /* Reserved */
> + build_append_int_noprefix(table_data, 0, 4);
> +
> + build_header(linker, table_data, (void *)(table_data->data + mcfg_start),
> + "MCFG", table_data->len - mcfg_start, 1, NULL, NULL);
> }
>
> diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h
> index f9aa4bd398..57a3f58b0c 100644
> --- a/include/hw/acpi/acpi-defs.h
> +++ b/include/hw/acpi/acpi-defs.h
> @@ -449,24 +449,6 @@ struct AcpiSratProcessorGiccAffinity {
>
> typedef struct AcpiSratProcessorGiccAffinity AcpiSratProcessorGiccAffinity;
>
> -/* PCI fw r3.0 MCFG table. */
> -/* Subtable */
> -struct AcpiMcfgAllocation {
> - uint64_t address; /* Base address, processor-relative */
> - uint16_t pci_segment; /* PCI segment group number */
> - uint8_t start_bus_number; /* Starting PCI Bus number */
> - uint8_t end_bus_number; /* Final PCI Bus number */
> - uint32_t reserved;
> -} QEMU_PACKED;
> -typedef struct AcpiMcfgAllocation AcpiMcfgAllocation;
> -
> -struct AcpiTableMcfg {
> - ACPI_TABLE_HEADER_DEF;
> - uint8_t reserved[8];
> - AcpiMcfgAllocation allocation[0];
> -} QEMU_PACKED;
> -typedef struct AcpiTableMcfg AcpiTableMcfg;
> -
> /*
> * TCPA Description Table
> *
> --
> 2.19.1
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH v4 6/6] acpi: pci: use build_append_foo() API to construct MCFG
2019-05-15 1:10 ` Michael S. Tsirkin
@ 2019-05-15 5:29 ` Philippe Mathieu-Daudé
2019-05-15 8:53 ` Wei Yang
2019-05-16 7:41 ` Wei Yang
2019-05-15 8:46 ` Wei Yang
1 sibling, 2 replies; 289+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-05-15 5:29 UTC (permalink / raw)
To: Michael S. Tsirkin, Wei Yang
Cc: yang.zhong, peter.maydell, qemu-devel, shannon.zhaosl, qemu-arm,
imammedo
On 5/15/19 3:10 AM, Michael S. Tsirkin wrote:
> On Fri, Apr 19, 2019 at 08:30:53AM +0800, Wei Yang wrote:
>> build_append_foo() API doesn't need explicit endianness conversions
>> which eliminates a source of errors and it makes build_mcfg() look like
>> declarative definition of MCFG table in ACPI spec, which makes it easy
>> to review.
>>
>> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
>> Suggested-by: Igor Mammedov <imammedo@redhat.com>
>> Reviewed-by: Igor Mammedov <imammedo@redhat.com>
>> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>
> Causes a regression with an invalid MCFG produced.
> Dropped.
>
>> ---
>> hw/acpi/pci.c | 33 +++++++++++++++++++++------------
>> include/hw/acpi/acpi-defs.h | 18 ------------------
>> 2 files changed, 21 insertions(+), 30 deletions(-)
>>
>> diff --git a/hw/acpi/pci.c b/hw/acpi/pci.c
>> index fa0fa30bb9..341805e786 100644
>> --- a/hw/acpi/pci.c
>> +++ b/hw/acpi/pci.c
>> @@ -30,17 +30,26 @@
>>
>> void build_mcfg(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
>> {
>> - AcpiTableMcfg *mcfg;
>> - int len = sizeof(*mcfg) + sizeof(mcfg->allocation[0]);
>> -
>> - mcfg = acpi_data_push(table_data, len);
>> - mcfg->allocation[0].address = cpu_to_le64(info->base);
>> -
>> - /* Only a single allocation so no need to play with segments */
>> - mcfg->allocation[0].pci_segment = cpu_to_le16(0);
>> - mcfg->allocation[0].start_bus_number = 0;
>> - mcfg->allocation[0].end_bus_number = PCIE_MMCFG_BUS(info->size - 1);
>> -
>> - build_header(linker, table_data, (void *)mcfg, "MCFG", len, 1, NULL, NULL);
>> + int mcfg_start = table_data->len;
>> +
>> + acpi_data_push(table_data, sizeof(AcpiTableHeader));
Ah, it seems we missed AcpiTableMcfg.reserved[8]...:
build_append_int_noprefix(table_data, 0, 8);
>> +
>> + /*
>> + * PCI Firmware Specification, Revision 3.0
>> + * 4.1.2 MCFG Table Description.
>> + */
>> + /* Base address, processor-relative */
>> + build_append_int_noprefix(table_data, info->base, 8);
>> + /* PCI segment group number */
>> + build_append_int_noprefix(table_data, 0, 2);
>> + /* Starting PCI Bus number */
>> + build_append_int_noprefix(table_data, 0, 1);
>> + /* Final PCI Bus number */
>> + build_append_int_noprefix(table_data, PCIE_MMCFG_BUS(info->size - 1), 1);
>> + /* Reserved */
>> + build_append_int_noprefix(table_data, 0, 4);
>> +
>> + build_header(linker, table_data, (void *)(table_data->data + mcfg_start),
>> + "MCFG", table_data->len - mcfg_start, 1, NULL, NULL);
>> }
>>
>> diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h
>> index f9aa4bd398..57a3f58b0c 100644
>> --- a/include/hw/acpi/acpi-defs.h
>> +++ b/include/hw/acpi/acpi-defs.h
>> @@ -449,24 +449,6 @@ struct AcpiSratProcessorGiccAffinity {
>>
>> typedef struct AcpiSratProcessorGiccAffinity AcpiSratProcessorGiccAffinity;
>>
>> -/* PCI fw r3.0 MCFG table. */
>> -/* Subtable */
>> -struct AcpiMcfgAllocation {
>> - uint64_t address; /* Base address, processor-relative */
>> - uint16_t pci_segment; /* PCI segment group number */
>> - uint8_t start_bus_number; /* Starting PCI Bus number */
>> - uint8_t end_bus_number; /* Final PCI Bus number */
>> - uint32_t reserved;
>> -} QEMU_PACKED;
>> -typedef struct AcpiMcfgAllocation AcpiMcfgAllocation;
>> -
>> -struct AcpiTableMcfg {
>> - ACPI_TABLE_HEADER_DEF;
>> - uint8_t reserved[8];
--------^
Thanks Michael for testing...
Wei, can you add a MCFG test in tests/bios-tables-test.c?
Regards,
Phil.
>> - AcpiMcfgAllocation allocation[0];
>> -} QEMU_PACKED;
>> -typedef struct AcpiTableMcfg AcpiTableMcfg;
>> -
>> /*
>> * TCPA Description Table
>> *
>> --
>> 2.19.1
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH v4 6/6] acpi: pci: use build_append_foo() API to construct MCFG
2019-05-15 1:10 ` Michael S. Tsirkin
2019-05-15 5:29 ` Philippe Mathieu-Daudé
@ 2019-05-15 8:46 ` Wei Yang
1 sibling, 0 replies; 289+ messages in thread
From: Wei Yang @ 2019-05-15 8:46 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: yang.zhong, peter.maydell, qemu-devel, shannon.zhaosl, qemu-arm,
Wei Yang, imammedo, philmd
On Tue, May 14, 2019 at 09:10:34PM -0400, Michael S. Tsirkin wrote:
>On Fri, Apr 19, 2019 at 08:30:53AM +0800, Wei Yang wrote:
>> build_append_foo() API doesn't need explicit endianness conversions
>> which eliminates a source of errors and it makes build_mcfg() look like
>> declarative definition of MCFG table in ACPI spec, which makes it easy
>> to review.
>>
>> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
>> Suggested-by: Igor Mammedov <imammedo@redhat.com>
>> Reviewed-by: Igor Mammedov <imammedo@redhat.com>
>> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>
>Causes a regression with an invalid MCFG produced.
>Dropped.
>
Any more information about this regression? How to reproduce it?
--
Wei Yang
Help you, Help me
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH v4 6/6] acpi: pci: use build_append_foo() API to construct MCFG
2019-05-15 5:29 ` Philippe Mathieu-Daudé
@ 2019-05-15 8:53 ` Wei Yang
2019-05-16 7:41 ` Wei Yang
1 sibling, 0 replies; 289+ messages in thread
From: Wei Yang @ 2019-05-15 8:53 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: yang.zhong, peter.maydell, Michael S. Tsirkin, qemu-devel,
shannon.zhaosl, qemu-arm, Wei Yang, imammedo
On Wed, May 15, 2019 at 07:29:17AM +0200, Philippe Mathieu-Daudé wrote:
>On 5/15/19 3:10 AM, Michael S. Tsirkin wrote:
>> On Fri, Apr 19, 2019 at 08:30:53AM +0800, Wei Yang wrote:
>>> build_append_foo() API doesn't need explicit endianness conversions
>>> which eliminates a source of errors and it makes build_mcfg() look like
>>> declarative definition of MCFG table in ACPI spec, which makes it easy
>>> to review.
>>>
>>> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
>>> Suggested-by: Igor Mammedov <imammedo@redhat.com>
>>> Reviewed-by: Igor Mammedov <imammedo@redhat.com>
>>> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>>
>> Causes a regression with an invalid MCFG produced.
>> Dropped.
>>
>>> ---
>>> hw/acpi/pci.c | 33 +++++++++++++++++++++------------
>>> include/hw/acpi/acpi-defs.h | 18 ------------------
>>> 2 files changed, 21 insertions(+), 30 deletions(-)
>>>
>>> diff --git a/hw/acpi/pci.c b/hw/acpi/pci.c
>>> index fa0fa30bb9..341805e786 100644
>>> --- a/hw/acpi/pci.c
>>> +++ b/hw/acpi/pci.c
>>> @@ -30,17 +30,26 @@
>>>
>>> void build_mcfg(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
>>> {
>>> - AcpiTableMcfg *mcfg;
>>> - int len = sizeof(*mcfg) + sizeof(mcfg->allocation[0]);
>>> -
>>> - mcfg = acpi_data_push(table_data, len);
>>> - mcfg->allocation[0].address = cpu_to_le64(info->base);
>>> -
>>> - /* Only a single allocation so no need to play with segments */
>>> - mcfg->allocation[0].pci_segment = cpu_to_le16(0);
>>> - mcfg->allocation[0].start_bus_number = 0;
>>> - mcfg->allocation[0].end_bus_number = PCIE_MMCFG_BUS(info->size - 1);
>>> -
>>> - build_header(linker, table_data, (void *)mcfg, "MCFG", len, 1, NULL, NULL);
>>> + int mcfg_start = table_data->len;
>>> +
>>> + acpi_data_push(table_data, sizeof(AcpiTableHeader));
>
>Ah, it seems we missed AcpiTableMcfg.reserved[8]...:
>
> build_append_int_noprefix(table_data, 0, 8);
>
Hmm... you are right. Shame on me.
>>> +
>>> + /*
>>> + * PCI Firmware Specification, Revision 3.0
>>> + * 4.1.2 MCFG Table Description.
>>> + */
>>> + /* Base address, processor-relative */
>>> + build_append_int_noprefix(table_data, info->base, 8);
>>> + /* PCI segment group number */
>>> + build_append_int_noprefix(table_data, 0, 2);
>>> + /* Starting PCI Bus number */
>>> + build_append_int_noprefix(table_data, 0, 1);
>>> + /* Final PCI Bus number */
>>> + build_append_int_noprefix(table_data, PCIE_MMCFG_BUS(info->size - 1), 1);
>>> + /* Reserved */
>>> + build_append_int_noprefix(table_data, 0, 4);
>>> +
>>> + build_header(linker, table_data, (void *)(table_data->data + mcfg_start),
>>> + "MCFG", table_data->len - mcfg_start, 1, NULL, NULL);
>>> }
>>>
>>> diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h
>>> index f9aa4bd398..57a3f58b0c 100644
>>> --- a/include/hw/acpi/acpi-defs.h
>>> +++ b/include/hw/acpi/acpi-defs.h
>>> @@ -449,24 +449,6 @@ struct AcpiSratProcessorGiccAffinity {
>>>
>>> typedef struct AcpiSratProcessorGiccAffinity AcpiSratProcessorGiccAffinity;
>>>
>>> -/* PCI fw r3.0 MCFG table. */
>>> -/* Subtable */
>>> -struct AcpiMcfgAllocation {
>>> - uint64_t address; /* Base address, processor-relative */
>>> - uint16_t pci_segment; /* PCI segment group number */
>>> - uint8_t start_bus_number; /* Starting PCI Bus number */
>>> - uint8_t end_bus_number; /* Final PCI Bus number */
>>> - uint32_t reserved;
>>> -} QEMU_PACKED;
>>> -typedef struct AcpiMcfgAllocation AcpiMcfgAllocation;
>>> -
>>> -struct AcpiTableMcfg {
>>> - ACPI_TABLE_HEADER_DEF;
>>> - uint8_t reserved[8];
>
> --------^
>
>Thanks Michael for testing...
>
>Wei, can you add a MCFG test in tests/bios-tables-test.c?
>
Sure, let me prepare the test.
>Regards,
>
>Phil.
>
>>> - AcpiMcfgAllocation allocation[0];
>>> -} QEMU_PACKED;
>>> -typedef struct AcpiTableMcfg AcpiTableMcfg;
>>> -
>>> /*
>>> * TCPA Description Table
>>> *
>>> --
>>> 2.19.1
--
Wei Yang
Help you, Help me
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH v4 6/6] acpi: pci: use build_append_foo() API to construct MCFG
2019-05-15 5:29 ` Philippe Mathieu-Daudé
2019-05-15 8:53 ` Wei Yang
@ 2019-05-16 7:41 ` Wei Yang
2019-05-16 11:01 ` Philippe Mathieu-Daudé
1 sibling, 1 reply; 289+ messages in thread
From: Wei Yang @ 2019-05-16 7:41 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: yang.zhong, peter.maydell, Michael S. Tsirkin, qemu-devel,
shannon.zhaosl, qemu-arm, Wei Yang, imammedo
On Wed, May 15, 2019 at 07:29:17AM +0200, Philippe Mathieu-Daudé wrote:
>
>Thanks Michael for testing...
>
>Wei, can you add a MCFG test in tests/bios-tables-test.c?
>
I took a look into the test, current q35 has already has a reference MCFG in
tests/data/acpi/q35/MCFG.
And there would be a warning message when reserved[8] is missed.
/x86_64/acpi/q35/bridge: acpi-test: Warning! MCFG mismatch.
Is this enough? Or what more information prefer to add?
>Regards,
>
>Phil.
>
>>> - AcpiMcfgAllocation allocation[0];
>>> -} QEMU_PACKED;
>>> -typedef struct AcpiTableMcfg AcpiTableMcfg;
>>> -
>>> /*
>>> * TCPA Description Table
>>> *
>>> --
>>> 2.19.1
--
Wei Yang
Help you, Help me
^ permalink raw reply [flat|nested] 289+ messages in thread
* Re: [Qemu-devel] [PATCH v4 6/6] acpi: pci: use build_append_foo() API to construct MCFG
2019-05-16 7:41 ` Wei Yang
@ 2019-05-16 11:01 ` Philippe Mathieu-Daudé
2019-05-16 17:00 ` Igor Mammedov
0 siblings, 1 reply; 289+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-05-16 11:01 UTC (permalink / raw)
To: Wei Yang
Cc: Yang Zhong, Peter Maydell, Michael S. Tsirkin, QEMU Developers,
Shannon Zhao, qemu-arm, Igor Mammedov
On Thu, May 16, 2019 at 9:41 AM Wei Yang <richardw.yang@linux.intel.com> wrote:
>
> On Wed, May 15, 2019 at 07:29:17AM +0200, Philippe Mathieu-Daudé wrote:
> >
> >Thanks Michael for testing...
> >
> >Wei, can you add a MCFG test in tests/bios-tables-test.c?
> >
>
> I took a look into the test, current q35 has already has a reference MCFG in
> tests/data/acpi/q35/MCFG.
>
> And there would be a warning message when reserved[8] is missed.
>
> /x86_64/acpi/q35/bridge: acpi-test: Warning! MCFG mismatch.
>
> Is this enough? Or what more information prefer to add?
Well, the test has to fail for any mismatch (not a simple warning).
A mismatch failure seems to be enough IMHO.
> >>> - AcpiMcfgAllocation allocation[0];
> >>> -} QEMU_PACKED;
> >>> -typedef struct AcpiTableMcfg AcpiTableMcfg;
> >>> -
> >>> /*
> >>> * TCPA Description Table
> >>> *
> >>> --
> >>> 2.19.1
>
> --
> Wei Yang
> Help you, Help me
^ permalink raw reply [flat|nested] 289+ messages in thread
* [Qemu-devel] [PULL 00/37] pci, pc, virtio: features, fixes
@ 2019-05-16 12:17 Michael S. Tsirkin
2019-05-20 23:10 ` [Qemu-devel] [PULL v2 03/36] " Michael S. Tsirkin
` (8 more replies)
0 siblings, 9 replies; 289+ messages in thread
From: Michael S. Tsirkin @ 2019-05-16 12:17 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell
The following changes since commit efb4f3b62c69383a7308d7b739a3193e7c0ccae8:
Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging (2019-05-10 14:49:36 +0100)
are available in the Git repository at:
git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream
for you to fetch changes up to 0534d255dae78450d90d59db0f3a9a46b32ebd73:
tests: acpi: print error unable to dump ACPI table during rebuild (2019-05-14 21:19:14 -0400)
----------------------------------------------------------------
pci, pc, virtio: features, fixes
reconnect for vhost blk
tests for UEFI
misc other stuff
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
----------------------------------------------------------------
Dan Streetman (1):
do not call vhost_net_cleanup() on running net from char user event
Daniel P. Berrangé (2):
hw: report invalid disable-legacy|modern usage for virtio-1-only devs
Revert "globals: Allow global properties to be optional"
David Gibson (2):
pcie: Remove redundant test in pcie_mmcfg_data_{read,write}()
pci: Simplify pci_bus_is_root()
Igor Mammedov (16):
q35: acpi: do not create dummy MCFG table
tests: acpi: rename acpi_parse_rsdp_table() into acpi_fetch_rsdp_table()
tests: acpi: make acpi_fetch_table() take size of fetched table pointer
tests: acpi: make RSDT test routine handle XSDT
tests: acpi: make pointer to RSDP 64bit
tests: acpi: fetch X_DSDT if pointer to DSDT is 0
tests: acpi: skip FACS table if board uses hw reduced ACPI profile
tests: acpi: move boot_sector_init() into x86 tests branch
tests: acpi: add acpi_find_rsdp_address_uefi() helper
tests: acpi: add a way to start tests with UEFI firmware
tests: acpi: ignore SMBIOS tests when UEFI firmware is used
tests: acpi: allow to override default accelerator
tests: add expected ACPI tables for arm/virt board
tests: acpi: add simple arm/virt testcase
tests: acpi: refactor rebuild-expected-aml.sh to dump ACPI tables for a specified list of targets
tests: acpi: print error unable to dump ACPI table during rebuild
Li Feng (1):
libvhost-user: fix bad vu_log_write
Marc-André Lureau (1):
docs: reST-ify vhost-user documentation
Markus Armbruster (3):
acpi/piix4: Convert debug printf()s to trace events
acpi/pcihp: Convert debug printf()s to trace events
acpi/pcihp: Add a few more trace points related to unplug
Wei Yang (4):
hw/arm/virt-acpi-build: remove unnecessary variable mcfg_start
i386, acpi: remove mcfg_ prefix in AcpiMcfgInfo members
hw/arm/virt-acpi-build: pass AcpiMcfgInfo to build_mcfg()
hw/acpi: Consolidate build_mcfg to pci.c
Xie Yongji (7):
virtio: Introduce started flag to VirtioDevice
virtio: Use started flag in virtio_vmstate_change()
vhost-user-blk: Use started flag in vhost_user_blk_set_status()
vhost-user-blk: Only start vhost-user backend with the first kick
vhost-user-blk: Add return value for vhost_user_blk_start()
vhost-user-blk: Add support to reconnect backend
contrib/vhost-user-blk: enable inflight I/O tracking
docs/interop/vhost-user.txt | 1219 ----------------------------
default-configs/arm-softmmu.mak | 1 +
default-configs/i386-softmmu.mak | 1 +
hw/virtio/virtio-pci.h | 31 +-
include/hw/acpi/pci.h | 34 +
include/hw/pci/pci.h | 1 -
include/hw/pci/pci_bus.h | 12 +-
include/hw/qdev-core.h | 3 -
include/hw/virtio/vhost-user-blk.h | 3 +
include/hw/virtio/virtio.h | 2 +
tests/acpi-utils.h | 7 +-
contrib/libvhost-user/libvhost-user.c | 2 +-
contrib/vhost-user-blk/vhost-user-blk.c | 3 +-
hw/acpi/pci.c | 46 ++
hw/acpi/pcihp.c | 32 +-
hw/acpi/piix4.c | 14 +-
hw/arm/virt-acpi-build.c | 31 +-
hw/block/vhost-user-blk.c | 175 +++-
hw/core/machine.c | 23 +-
hw/display/virtio-gpu-pci.c | 4 +-
hw/display/virtio-vga.c | 4 +-
hw/i386/acpi-build.c | 44 +-
hw/pci-bridge/pci_expander_bridge.c | 6 -
hw/pci/pci.c | 14 +-
hw/pci/pcie_host.c | 10 -
hw/virtio/virtio-crypto-pci.c | 4 +-
hw/virtio/virtio-input-pci.c | 4 +-
hw/virtio/virtio-pci.c | 27 +-
hw/virtio/virtio.c | 54 +-
net/vhost-user.c | 1 -
qom/object.c | 3 -
tests/acpi-utils.c | 68 +-
tests/bios-tables-test.c | 146 +++-
tests/vmgenid-test.c | 6 +-
MAINTAINERS | 2 +-
docs/interop/index.rst | 2 +-
docs/interop/vhost-user.rst | 1351 +++++++++++++++++++++++++++++++
hw/acpi/Kconfig | 4 +
hw/acpi/Makefile.objs | 1 +
hw/acpi/trace-events | 16 +
tests/Makefile.include | 1 +
tests/data/acpi/rebuild-expected-aml.sh | 23 +-
tests/data/acpi/virt/APIC | Bin 0 -> 168 bytes
tests/data/acpi/virt/DSDT | Bin 0 -> 18476 bytes
tests/data/acpi/virt/FACP | Bin 0 -> 268 bytes
tests/data/acpi/virt/GTDT | Bin 0 -> 96 bytes
tests/data/acpi/virt/MCFG | Bin 0 -> 60 bytes
tests/data/acpi/virt/SPCR | Bin 0 -> 80 bytes
48 files changed, 1956 insertions(+), 1479 deletions(-)
delete mode 100644 docs/interop/vhost-user.txt
create mode 100644 include/hw/acpi/pci.h
create mode 100644 hw/acpi/pci.c
create mode 100644 docs/interop/vhost-user.rst
create mode 100644 tests/data/acpi/virt/APIC
create mode 100644 tests/data/acpi/virt/DSDT
create mode 100644 tests/data/acpi/virt/FACP
create mode 100644 tests/data/acpi/virt/GTDT
create mode 100644 tests/data/acpi/virt/MCFG
create mode 100644 tests/data/acpi/virt/SPCR
^ permalink raw reply [flat|nested] 289+ messages in thread
* [Qemu-devel] [PULL 01/37] hw: report invalid disable-legacy|modern usage for virtio-1-only devs
@ 2019-05-16 12:17 ` Michael S. Tsirkin
0 siblings, 0 replies; 289+ messages in thread
From: Michael S. Tsirkin @ 2019-05-16 12:17 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Daniel P. Berrangé,
Eduardo Habkost, Gonglei, Gerd Hoffmann
From: Daniel P. Berrangé <berrange@redhat.com>
A number of virtio devices (gpu, crypto, mouse, keyboard, tablet) only
support the virtio-1 (aka modern) mode. Currently if the user launches
QEMU, setting those devices to enable legacy mode, QEMU will silently
create them in modern mode, ignoring the user's (mistaken) request.
This patch introduces proper data validation so that an attempt to
configure a virtio-1-only devices in legacy mode gets reported as an
error to the user.
Checking this required introduction of a new field to explicitly track
what operating model is to be used for a device, separately from the
disable_modern and disable_legacy fields that record the user's
requested configuration.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <20190215103239.28640-2-berrange@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/virtio/virtio-pci.h | 31 +++++++++++++++++++++++++------
hw/core/machine.c | 23 ++++++++++++++++++++---
hw/display/virtio-gpu-pci.c | 4 +++-
hw/display/virtio-vga.c | 4 +++-
hw/virtio/virtio-crypto-pci.c | 4 +++-
hw/virtio/virtio-input-pci.c | 4 +++-
hw/virtio/virtio-pci.c | 26 ++++++++++++++++----------
7 files changed, 73 insertions(+), 23 deletions(-)
diff --git a/hw/virtio/virtio-pci.h b/hw/virtio/virtio-pci.h
index 18581854ca..bfea2892a5 100644
--- a/hw/virtio/virtio-pci.h
+++ b/hw/virtio/virtio-pci.h
@@ -15,6 +15,7 @@
#ifndef QEMU_VIRTIO_PCI_H
#define QEMU_VIRTIO_PCI_H
+#include "qapi/error.h"
#include "hw/pci/msi.h"
#include "hw/virtio/virtio-bus.h"
@@ -118,6 +119,12 @@ typedef struct VirtIOPCIQueue {
uint32_t used[2];
} VirtIOPCIQueue;
+typedef enum {
+ VIRTIO_PCI_MODE_LEGACY,
+ VIRTIO_PCI_MODE_TRANSITIONAL,
+ VIRTIO_PCI_MODE_MODERN,
+} VirtIOPCIMode;
+
struct VirtIOPCIProxy {
PCIDevice pci_dev;
MemoryRegion bar;
@@ -142,6 +149,7 @@ struct VirtIOPCIProxy {
bool disable_modern;
bool ignore_backend_features;
OnOffAuto disable_legacy;
+ VirtIOPCIMode mode;
uint32_t class_code;
uint32_t nvectors;
uint32_t dfselect;
@@ -156,23 +164,34 @@ struct VirtIOPCIProxy {
static inline bool virtio_pci_modern(VirtIOPCIProxy *proxy)
{
- return !proxy->disable_modern;
+ return proxy->mode != VIRTIO_PCI_MODE_LEGACY;
}
static inline bool virtio_pci_legacy(VirtIOPCIProxy *proxy)
{
- return proxy->disable_legacy == ON_OFF_AUTO_OFF;
+ return proxy->mode != VIRTIO_PCI_MODE_MODERN;
}
-static inline void virtio_pci_force_virtio_1(VirtIOPCIProxy *proxy)
+static inline bool virtio_pci_force_virtio_1(VirtIOPCIProxy *proxy,
+ Error **errp)
{
- proxy->disable_modern = false;
- proxy->disable_legacy = ON_OFF_AUTO_ON;
+ if (proxy->disable_legacy == ON_OFF_AUTO_OFF) {
+ error_setg(errp, "Unable to set disable-legacy=off on a virtio-1.0 "
+ "only device");
+ return false;
+ }
+ if (proxy->disable_modern == true) {
+ error_setg(errp, "Unable to set disable-modern=on on a virtio-1.0 "
+ "only device");
+ return false;
+ }
+ proxy->mode = VIRTIO_PCI_MODE_MODERN;
+ return true;
}
static inline void virtio_pci_disable_modern(VirtIOPCIProxy *proxy)
{
- proxy->disable_modern = true;
+ proxy->mode = VIRTIO_PCI_MODE_LEGACY;
}
/*
diff --git a/hw/core/machine.c b/hw/core/machine.c
index 5d046a43e3..934c1bcceb 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -102,9 +102,26 @@ const size_t hw_compat_2_7_len = G_N_ELEMENTS(hw_compat_2_7);
GlobalProperty hw_compat_2_6[] = {
{ "virtio-mmio", "format_transport_address", "off" },
- /* Optional because not all virtio-pci devices support legacy mode */
- { "virtio-pci", "disable-modern", "on", .optional = true },
- { "virtio-pci", "disable-legacy", "off", .optional = true },
+ /*
+ * don't include devices which are modern-only
+ * ie keyboard, mouse, tablet, gpu, vga & crypto
+ */
+ { "virtio-9p-pci", "disable-modern", "on" },
+ { "virtio-9p-pci", "disable-legacy", "off" },
+ { "virtio-balloon-pci", "disable-modern", "on" },
+ { "virtio-balloon-pci", "disable-legacy", "off" },
+ { "virtio-blk-pci", "disable-modern", "on" },
+ { "virtio-blk-pci", "disable-legacy", "off" },
+ { "virtio-input-host-pci", "disable-modern", "on" },
+ { "virtio-input-host-pci", "disable-legacy", "off" },
+ { "virtio-net-pci", "disable-modern", "on" },
+ { "virtio-net-pci", "disable-legacy", "off" },
+ { "virtio-rng-pci", "disable-modern", "on" },
+ { "virtio-rng-pci", "disable-legacy", "off" },
+ { "virtio-scsi-pci", "disable-modern", "on" },
+ { "virtio-scsi-pci", "disable-legacy", "off" },
+ { "virtio-serial-pci", "disable-modern", "on" },
+ { "virtio-serial-pci", "disable-legacy", "off" },
};
const size_t hw_compat_2_6_len = G_N_ELEMENTS(hw_compat_2_6);
diff --git a/hw/display/virtio-gpu-pci.c b/hw/display/virtio-gpu-pci.c
index bdcd33c925..0bc4d9d424 100644
--- a/hw/display/virtio-gpu-pci.c
+++ b/hw/display/virtio-gpu-pci.c
@@ -47,7 +47,9 @@ static void virtio_gpu_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
Error *local_error = NULL;
qdev_set_parent_bus(vdev, BUS(&vpci_dev->bus));
- virtio_pci_force_virtio_1(vpci_dev);
+ if (!virtio_pci_force_virtio_1(vpci_dev, errp)) {
+ return;
+ }
object_property_set_bool(OBJECT(vdev), true, "realized", &local_error);
if (local_error) {
diff --git a/hw/display/virtio-vga.c b/hw/display/virtio-vga.c
index a2b803b75f..5d57bf5b0c 100644
--- a/hw/display/virtio-vga.c
+++ b/hw/display/virtio-vga.c
@@ -154,7 +154,9 @@ static void virtio_vga_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
/* init virtio bits */
qdev_set_parent_bus(DEVICE(g), BUS(&vpci_dev->bus));
- virtio_pci_force_virtio_1(vpci_dev);
+ if (!virtio_pci_force_virtio_1(vpci_dev, errp)) {
+ return;
+ }
object_property_set_bool(OBJECT(g), true, "realized", &err);
if (err) {
error_propagate(errp, err);
diff --git a/hw/virtio/virtio-crypto-pci.c b/hw/virtio/virtio-crypto-pci.c
index 90a6e0dc2e..13807e538b 100644
--- a/hw/virtio/virtio-crypto-pci.c
+++ b/hw/virtio/virtio-crypto-pci.c
@@ -51,7 +51,9 @@ static void virtio_crypto_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
}
qdev_set_parent_bus(vdev, BUS(&vpci_dev->bus));
- virtio_pci_force_virtio_1(vpci_dev);
+ if (!virtio_pci_force_virtio_1(vpci_dev, errp)) {
+ return;
+ }
object_property_set_bool(OBJECT(vdev), true, "realized", errp);
object_property_set_link(OBJECT(vcrypto),
OBJECT(vcrypto->vdev.conf.cryptodev), "cryptodev",
diff --git a/hw/virtio/virtio-input-pci.c b/hw/virtio/virtio-input-pci.c
index 2c1397842b..28477729a3 100644
--- a/hw/virtio/virtio-input-pci.c
+++ b/hw/virtio/virtio-input-pci.c
@@ -48,7 +48,9 @@ static void virtio_input_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
DeviceState *vdev = DEVICE(&vinput->vdev);
qdev_set_parent_bus(vdev, BUS(&vpci_dev->bus));
- virtio_pci_force_virtio_1(vpci_dev);
+ if (!virtio_pci_force_virtio_1(vpci_dev, errp)) {
+ return;
+ }
object_property_set_bool(OBJECT(vdev), true, "realized", errp);
}
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index cb44e19b67..509c1ff555 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -1721,16 +1721,22 @@ static void virtio_pci_realize(PCIDevice *pci_dev, Error **errp)
/* PCI BAR regions must be powers of 2 */
pow2ceil(proxy->notify.offset + proxy->notify.size));
- if (proxy->disable_legacy == ON_OFF_AUTO_AUTO) {
- proxy->disable_legacy = pcie_port ? ON_OFF_AUTO_ON : ON_OFF_AUTO_OFF;
- }
-
- if (!virtio_pci_modern(proxy) && !virtio_pci_legacy(proxy)) {
- error_setg(errp, "device cannot work as neither modern nor legacy mode"
- " is enabled");
- error_append_hint(errp, "Set either disable-modern or disable-legacy"
- " to off\n");
- return;
+ if ((proxy->disable_legacy == ON_OFF_AUTO_ON) ||
+ ((proxy->disable_legacy == ON_OFF_AUTO_AUTO) && pcie_port)) {
+ if (proxy->disable_modern) {
+ error_setg(errp, "device cannot work as neither modern nor "
+ "legacy mode is enabled");
+ error_append_hint(errp, "Set either disable-modern or "
+ "disable-legacy to off\n");
+ return;
+ }
+ proxy->mode = VIRTIO_PCI_MODE_MODERN;
+ } else {
+ if (proxy->disable_modern) {
+ proxy->mode = VIRTIO_PCI_MODE_LEGACY;
+ } else {
+ proxy->mode = VIRTIO_PCI_MODE_TRANSITIONAL;
+ }
}
if (pcie_port && pci_is_express(pci_dev)) {
--
MST
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PULL 02/37] Revert "globals: Allow global properties to be optional"
@ 2019-05-16 12:17 ` Michael S. Tsirkin
0 siblings, 0 replies; 289+ messages in thread
From: Michael S. Tsirkin @ 2019-05-16 12:17 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Daniel P. Berrangé, Andreas Färber
From: Daniel P. Berrangé <berrange@redhat.com>
This reverts commit d7741743f4f3d2683d1bb6938f88dc0167c21afa.
Relying on setting properties on parents types which may not
be relevant to certain sub-classes had unexpected side-effects
causing bugs in device config defaults. It is preferrable to
be explicit about which devices get which properties, even if
this needs repetition.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <20190215103239.28640-3-berrange@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
include/hw/qdev-core.h | 3 ---
qom/object.c | 3 ---
2 files changed, 6 deletions(-)
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index 33ed3b8dde..fa55dc10ae 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -251,8 +251,6 @@ struct PropertyInfo {
/**
* GlobalProperty:
* @used: Set to true if property was used when initializing a device.
- * @optional: If set to true, GlobalProperty will be skipped without errors
- * if the property doesn't exist.
*
* An error is fatal for non-hotplugged devices, when the global is applied.
*/
@@ -261,7 +259,6 @@ typedef struct GlobalProperty {
const char *property;
const char *value;
bool used;
- bool optional;
} GlobalProperty;
static inline void
diff --git a/qom/object.c b/qom/object.c
index d3412e7fdc..99c4fa707e 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -385,9 +385,6 @@ void object_apply_global_props(Object *obj, const GPtrArray *props, Error **errp
if (object_dynamic_cast(obj, p->driver) == NULL) {
continue;
}
- if (p->optional && !object_property_find(obj, p->property, NULL)) {
- continue;
- }
p->used = true;
object_property_parse(obj, p->value, p->property, &err);
if (err != NULL) {
--
MST
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PULL 03/37] docs: reST-ify vhost-user documentation
@ 2019-05-20 23:10 ` Michael S. Tsirkin
0 siblings, 0 replies; 289+ messages in thread
From: Michael S. Tsirkin @ 2019-05-16 12:17 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Jens Freimann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20190315180735.13096-1-marcandre.lureau@redhat.com>
Reviewed-by: Jens Freimann <jfreimann@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
docs/interop/vhost-user.txt | 1219 -------------------------------
MAINTAINERS | 2 +-
docs/interop/index.rst | 2 +-
docs/interop/vhost-user.rst | 1351 +++++++++++++++++++++++++++++++++++
4 files changed, 1353 insertions(+), 1221 deletions(-)
delete mode 100644 docs/interop/vhost-user.txt
create mode 100644 docs/interop/vhost-user.rst
diff --git a/docs/interop/vhost-user.txt b/docs/interop/vhost-user.txt
deleted file mode 100644
index 4dbd530cb9..0000000000
--- a/docs/interop/vhost-user.txt
+++ /dev/null
@@ -1,1219 +0,0 @@
-Vhost-user Protocol
-===================
-
-Copyright (c) 2014 Virtual Open Systems Sarl.
-
-This work is licensed under the terms of the GNU GPL, version 2 or later.
-See the COPYING file in the top-level directory.
-===================
-
-This protocol is aiming to complement the ioctl interface used to control the
-vhost implementation in the Linux kernel. It implements the control plane needed
-to establish virtqueue sharing with a user space process on the same host. It
-uses communication over a Unix domain socket to share file descriptors in the
-ancillary data of the message.
-
-The protocol defines 2 sides of the communication, master and slave. Master is
-the application that shares its virtqueues, in our case QEMU. Slave is the
-consumer of the virtqueues.
-
-In the current implementation QEMU is the Master, and the Slave is the
-external process consuming the virtio queues, for example a software
-Ethernet switch running in user space, such as Snabbswitch, or a block
-device backend processing read & write to a virtual disk. In order to
-facilitate interoperability between various backend implementations,
-it is recommended to follow the "Backend program conventions"
-described in this document.
-
-Master and slave can be either a client (i.e. connecting) or server (listening)
-in the socket communication.
-
-Message Specification
----------------------
-
-Note that all numbers are in the machine native byte order. A vhost-user message
-consists of 3 header fields and a payload:
-
-------------------------------------
-| request | flags | size | payload |
-------------------------------------
-
- * Request: 32-bit type of the request
- * Flags: 32-bit bit field:
- - Lower 2 bits are the version (currently 0x01)
- - Bit 2 is the reply flag - needs to be sent on each reply from the slave
- - Bit 3 is the need_reply flag - see VHOST_USER_PROTOCOL_F_REPLY_ACK for
- details.
- * Size - 32-bit size of the payload
-
-
-Depending on the request type, payload can be:
-
- * A single 64-bit integer
- -------
- | u64 |
- -------
-
- u64: a 64-bit unsigned integer
-
- * A vring state description
- ---------------
- | index | num |
- ---------------
-
- Index: a 32-bit index
- Num: a 32-bit number
-
- * A vring address description
- --------------------------------------------------------------
- | index | flags | size | descriptor | used | available | log |
- --------------------------------------------------------------
-
- Index: a 32-bit vring index
- Flags: a 32-bit vring flags
- Descriptor: a 64-bit ring address of the vring descriptor table
- Used: a 64-bit ring address of the vring used ring
- Available: a 64-bit ring address of the vring available ring
- Log: a 64-bit guest address for logging
-
- Note that a ring address is an IOVA if VIRTIO_F_IOMMU_PLATFORM has been
- negotiated. Otherwise it is a user address.
-
- * Memory regions description
- ---------------------------------------------------
- | num regions | padding | region0 | ... | region7 |
- ---------------------------------------------------
-
- Num regions: a 32-bit number of regions
- Padding: 32-bit
-
- A region is:
- -----------------------------------------------------
- | guest address | size | user address | mmap offset |
- -----------------------------------------------------
-
- Guest address: a 64-bit guest address of the region
- Size: a 64-bit size
- User address: a 64-bit user address
- mmap offset: 64-bit offset where region starts in the mapped memory
-
-* Log description
- ---------------------------
- | log size | log offset |
- ---------------------------
- log size: size of area used for logging
- log offset: offset from start of supplied file descriptor
- where logging starts (i.e. where guest address 0 would be logged)
-
- * An IOTLB message
- ---------------------------------------------------------
- | iova | size | user address | permissions flags | type |
- ---------------------------------------------------------
-
- IOVA: a 64-bit I/O virtual address programmed by the guest
- Size: a 64-bit size
- User address: a 64-bit user address
- Permissions: an 8-bit value:
- - 0: No access
- - 1: Read access
- - 2: Write access
- - 3: Read/Write access
- Type: an 8-bit IOTLB message type:
- - 1: IOTLB miss
- - 2: IOTLB update
- - 3: IOTLB invalidate
- - 4: IOTLB access fail
-
- * Virtio device config space
- -----------------------------------
- | offset | size | flags | payload |
- -----------------------------------
-
- Offset: a 32-bit offset of virtio device's configuration space
- Size: a 32-bit configuration space access size in bytes
- Flags: a 32-bit value:
- - 0: Vhost master messages used for writeable fields
- - 1: Vhost master messages used for live migration
- Payload: Size bytes array holding the contents of the virtio
- device's configuration space
-
- * Vring area description
- -----------------------
- | u64 | size | offset |
- -----------------------
-
- u64: a 64-bit integer contains vring index and flags
- Size: a 64-bit size of this area
- Offset: a 64-bit offset of this area from the start of the
- supplied file descriptor
-
- * Inflight description
- -----------------------------------------------------
- | mmap size | mmap offset | num queues | queue size |
- -----------------------------------------------------
-
- mmap size: a 64-bit size of area to track inflight I/O
- mmap offset: a 64-bit offset of this area from the start
- of the supplied file descriptor
- num queues: a 16-bit number of virtqueues
- queue size: a 16-bit size of virtqueues
-
-In QEMU the vhost-user message is implemented with the following struct:
-
-typedef struct VhostUserMsg {
- VhostUserRequest request;
- uint32_t flags;
- uint32_t size;
- union {
- uint64_t u64;
- struct vhost_vring_state state;
- struct vhost_vring_addr addr;
- VhostUserMemory memory;
- VhostUserLog log;
- struct vhost_iotlb_msg iotlb;
- VhostUserConfig config;
- VhostUserVringArea area;
- VhostUserInflight inflight;
- };
-} QEMU_PACKED VhostUserMsg;
-
-Communication
--------------
-
-The protocol for vhost-user is based on the existing implementation of vhost
-for the Linux Kernel. Most messages that can be sent via the Unix domain socket
-implementing vhost-user have an equivalent ioctl to the kernel implementation.
-
-The communication consists of master sending message requests and slave sending
-message replies. Most of the requests don't require replies. Here is a list of
-the ones that do:
-
- * VHOST_USER_GET_FEATURES
- * VHOST_USER_GET_PROTOCOL_FEATURES
- * VHOST_USER_GET_VRING_BASE
- * VHOST_USER_SET_LOG_BASE (if VHOST_USER_PROTOCOL_F_LOG_SHMFD)
- * VHOST_USER_GET_INFLIGHT_FD (if VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD)
-
-[ Also see the section on REPLY_ACK protocol extension. ]
-
-There are several messages that the master sends with file descriptors passed
-in the ancillary data:
-
- * VHOST_USER_SET_MEM_TABLE
- * VHOST_USER_SET_LOG_BASE (if VHOST_USER_PROTOCOL_F_LOG_SHMFD)
- * VHOST_USER_SET_LOG_FD
- * VHOST_USER_SET_VRING_KICK
- * VHOST_USER_SET_VRING_CALL
- * VHOST_USER_SET_VRING_ERR
- * VHOST_USER_SET_SLAVE_REQ_FD
- * VHOST_USER_SET_INFLIGHT_FD (if VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD)
-
-If Master is unable to send the full message or receives a wrong reply it will
-close the connection. An optional reconnection mechanism can be implemented.
-
-Any protocol extensions are gated by protocol feature bits,
-which allows full backwards compatibility on both master
-and slave.
-As older slaves don't support negotiating protocol features,
-a feature bit was dedicated for this purpose:
-#define VHOST_USER_F_PROTOCOL_FEATURES 30
-
-Starting and stopping rings
-----------------------
-Client must only process each ring when it is started.
-
-Client must only pass data between the ring and the
-backend, when the ring is enabled.
-
-If ring is started but disabled, client must process the
-ring without talking to the backend.
-
-For example, for a networking device, in the disabled state
-client must not supply any new RX packets, but must process
-and discard any TX packets.
-
-If VHOST_USER_F_PROTOCOL_FEATURES has not been negotiated, the ring is initialized
-in an enabled state.
-
-If VHOST_USER_F_PROTOCOL_FEATURES has been negotiated, the ring is initialized
-in a disabled state. Client must not pass data to/from the backend until ring is enabled by
-VHOST_USER_SET_VRING_ENABLE with parameter 1, or after it has been disabled by
-VHOST_USER_SET_VRING_ENABLE with parameter 0.
-
-Each ring is initialized in a stopped state, client must not process it until
-ring is started, or after it has been stopped.
-
-Client must start ring upon receiving a kick (that is, detecting that file
-descriptor is readable) on the descriptor specified by
-VHOST_USER_SET_VRING_KICK, and stop ring upon receiving
-VHOST_USER_GET_VRING_BASE.
-
-While processing the rings (whether they are enabled or not), client must
-support changing some configuration aspects on the fly.
-
-Multiple queue support
-----------------------
-
-Multiple queue is treated as a protocol extension, hence the slave has to
-implement protocol features first. The multiple queues feature is supported
-only when the protocol feature VHOST_USER_PROTOCOL_F_MQ (bit 0) is set.
-
-The max number of queue pairs the slave supports can be queried with message
-VHOST_USER_GET_QUEUE_NUM. Master should stop when the number of
-requested queues is bigger than that.
-
-As all queues share one connection, the master uses a unique index for each
-queue in the sent message to identify a specified queue. One queue pair
-is enabled initially. More queues are enabled dynamically, by sending
-message VHOST_USER_SET_VRING_ENABLE.
-
-Migration
----------
-
-During live migration, the master may need to track the modifications
-the slave makes to the memory mapped regions. The client should mark
-the dirty pages in a log. Once it complies to this logging, it may
-declare the VHOST_F_LOG_ALL vhost feature.
-
-To start/stop logging of data/used ring writes, server may send messages
-VHOST_USER_SET_FEATURES with VHOST_F_LOG_ALL and VHOST_USER_SET_VRING_ADDR with
-VHOST_VRING_F_LOG in ring's flags set to 1/0, respectively.
-
-All the modifications to memory pointed by vring "descriptor" should
-be marked. Modifications to "used" vring should be marked if
-VHOST_VRING_F_LOG is part of ring's flags.
-
-Dirty pages are of size:
-#define VHOST_LOG_PAGE 0x1000
-
-The log memory fd is provided in the ancillary data of
-VHOST_USER_SET_LOG_BASE message when the slave has
-VHOST_USER_PROTOCOL_F_LOG_SHMFD protocol feature.
-
-The size of the log is supplied as part of VhostUserMsg
-which should be large enough to cover all known guest
-addresses. Log starts at the supplied offset in the
-supplied file descriptor.
-The log covers from address 0 to the maximum of guest
-regions. In pseudo-code, to mark page at "addr" as dirty:
-
-page = addr / VHOST_LOG_PAGE
-log[page / 8] |= 1 << page % 8
-
-Where addr is the guest physical address.
-
-Use atomic operations, as the log may be concurrently manipulated.
-
-Note that when logging modifications to the used ring (when VHOST_VRING_F_LOG
-is set for this ring), log_guest_addr should be used to calculate the log
-offset: the write to first byte of the used ring is logged at this offset from
-log start. Also note that this value might be outside the legal guest physical
-address range (i.e. does not have to be covered by the VhostUserMemory table),
-but the bit offset of the last byte of the ring must fall within
-the size supplied by VhostUserLog.
-
-VHOST_USER_SET_LOG_FD is an optional message with an eventfd in
-ancillary data, it may be used to inform the master that the log has
-been modified.
-
-Once the source has finished migration, rings will be stopped by
-the source. No further update must be done before rings are
-restarted.
-
-In postcopy migration the slave is started before all the memory has been
-received from the source host, and care must be taken to avoid accessing pages
-that have yet to be received. The slave opens a 'userfault'-fd and registers
-the memory with it; this fd is then passed back over to the master.
-The master services requests on the userfaultfd for pages that are accessed
-and when the page is available it performs WAKE ioctl's on the userfaultfd
-to wake the stalled slave. The client indicates support for this via the
-VHOST_USER_PROTOCOL_F_PAGEFAULT feature.
-
-Memory access
--------------
-
-The master sends a list of vhost memory regions to the slave using the
-VHOST_USER_SET_MEM_TABLE message. Each region has two base addresses: a guest
-address and a user address.
-
-Messages contain guest addresses and/or user addresses to reference locations
-within the shared memory. The mapping of these addresses works as follows.
-
-User addresses map to the vhost memory region containing that user address.
-
-When the VIRTIO_F_IOMMU_PLATFORM feature has not been negotiated:
-
- * Guest addresses map to the vhost memory region containing that guest
- address.
-
-When the VIRTIO_F_IOMMU_PLATFORM feature has been negotiated:
-
- * Guest addresses are also called I/O virtual addresses (IOVAs). They are
- translated to user addresses via the IOTLB.
-
- * The vhost memory region guest address is not used.
-
-IOMMU support
--------------
-
-When the VIRTIO_F_IOMMU_PLATFORM feature has been negotiated, the master
-sends IOTLB entries update & invalidation by sending VHOST_USER_IOTLB_MSG
-requests to the slave with a struct vhost_iotlb_msg as payload. For update
-events, the iotlb payload has to be filled with the update message type (2),
-the I/O virtual address, the size, the user virtual address, and the
-permissions flags. Addresses and size must be within vhost memory regions set
-via the VHOST_USER_SET_MEM_TABLE request. For invalidation events, the iotlb
-payload has to be filled with the invalidation message type (3), the I/O virtual
-address and the size. On success, the slave is expected to reply with a zero
-payload, non-zero otherwise.
-
-The slave relies on the slave communcation channel (see "Slave communication"
-section below) to send IOTLB miss and access failure events, by sending
-VHOST_USER_SLAVE_IOTLB_MSG requests to the master with a struct vhost_iotlb_msg
-as payload. For miss events, the iotlb payload has to be filled with the miss
-message type (1), the I/O virtual address and the permissions flags. For access
-failure event, the iotlb payload has to be filled with the access failure
-message type (4), the I/O virtual address and the permissions flags.
-For synchronization purpose, the slave may rely on the reply-ack feature,
-so the master may send a reply when operation is completed if the reply-ack
-feature is negotiated and slaves requests a reply. For miss events, completed
-operation means either master sent an update message containing the IOTLB entry
-containing requested address and permission, or master sent nothing if the IOTLB
-miss message is invalid (invalid IOVA or permission).
-
-The master isn't expected to take the initiative to send IOTLB update messages,
-as the slave sends IOTLB miss messages for the guest virtual memory areas it
-needs to access.
-
-Slave communication
--------------------
-
-An optional communication channel is provided if the slave declares
-VHOST_USER_PROTOCOL_F_SLAVE_REQ protocol feature, to allow the slave to make
-requests to the master.
-
-The fd is provided via VHOST_USER_SET_SLAVE_REQ_FD ancillary data.
-
-A slave may then send VHOST_USER_SLAVE_* messages to the master
-using this fd communication channel.
-
-If VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD protocol feature is negotiated,
-slave can send file descriptors (at most 8 descriptors in each message)
-to master via ancillary data using this fd communication channel.
-
-Inflight I/O tracking
----------------------
-
-To support reconnecting after restart or crash, slave may need to resubmit
-inflight I/Os. If virtqueue is processed in order, we can easily achieve
-that by getting the inflight descriptors from descriptor table (split virtqueue)
-or descriptor ring (packed virtqueue). However, it can't work when we process
-descriptors out-of-order because some entries which store the information of
-inflight descriptors in available ring (split virtqueue) or descriptor
-ring (packed virtqueue) might be overrided by new entries. To solve this
-problem, slave need to allocate an extra buffer to store this information of inflight
-descriptors and share it with master for persistent. VHOST_USER_GET_INFLIGHT_FD and
-VHOST_USER_SET_INFLIGHT_FD are used to transfer this buffer between master
-and slave. And the format of this buffer is described below:
-
--------------------------------------------------------
-| queue0 region | queue1 region | ... | queueN region |
--------------------------------------------------------
-
-N is the number of available virtqueues. Slave could get it from num queues
-field of VhostUserInflight.
-
-For split virtqueue, queue region can be implemented as:
-
-typedef struct DescStateSplit {
- /* Indicate whether this descriptor is inflight or not.
- * Only available for head-descriptor. */
- uint8_t inflight;
-
- /* Padding */
- uint8_t padding[5];
-
- /* Maintain a list for the last batch of used descriptors.
- * Only available when batching is used for submitting */
- uint16_t next;
-
- /* Used to preserve the order of fetching available descriptors.
- * Only available for head-descriptor. */
- uint64_t counter;
-} DescStateSplit;
-
-typedef struct QueueRegionSplit {
- /* The feature flags of this region. Now it's initialized to 0. */
- uint64_t features;
-
- /* The version of this region. It's 1 currently.
- * Zero value indicates an uninitialized buffer */
- uint16_t version;
-
- /* The size of DescStateSplit array. It's equal to the virtqueue
- * size. Slave could get it from queue size field of VhostUserInflight. */
- uint16_t desc_num;
-
- /* The head of list that track the last batch of used descriptors. */
- uint16_t last_batch_head;
-
- /* Store the idx value of used ring */
- uint16_t used_idx;
-
- /* Used to track the state of each descriptor in descriptor table */
- DescStateSplit desc[0];
-} QueueRegionSplit;
-
-To track inflight I/O, the queue region should be processed as follows:
-
-When receiving available buffers from the driver:
-
- 1. Get the next available head-descriptor index from available ring, i
-
- 2. Set desc[i].counter to the value of global counter
-
- 3. Increase global counter by 1
-
- 4. Set desc[i].inflight to 1
-
-When supplying used buffers to the driver:
-
- 1. Get corresponding used head-descriptor index, i
-
- 2. Set desc[i].next to last_batch_head
-
- 3. Set last_batch_head to i
-
- 4. Steps 1,2,3 may be performed repeatedly if batching is possible
-
- 5. Increase the idx value of used ring by the size of the batch
-
- 6. Set the inflight field of each DescStateSplit entry in the batch to 0
-
- 7. Set used_idx to the idx value of used ring
-
-When reconnecting:
-
- 1. If the value of used_idx does not match the idx value of used ring (means
- the inflight field of DescStateSplit entries in last batch may be incorrect),
-
- (a) Subtract the value of used_idx from the idx value of used ring to get
- last batch size of DescStateSplit entries
-
- (b) Set the inflight field of each DescStateSplit entry to 0 in last batch
- list which starts from last_batch_head
-
- (c) Set used_idx to the idx value of used ring
-
- 2. Resubmit inflight DescStateSplit entries in order of their counter value
-
-For packed virtqueue, queue region can be implemented as:
-
-typedef struct DescStatePacked {
- /* Indicate whether this descriptor is inflight or not.
- * Only available for head-descriptor. */
- uint8_t inflight;
-
- /* Padding */
- uint8_t padding;
-
- /* Link to the next free entry */
- uint16_t next;
-
- /* Link to the last entry of descriptor list.
- * Only available for head-descriptor. */
- uint16_t last;
-
- /* The length of descriptor list.
- * Only available for head-descriptor. */
- uint16_t num;
-
- /* Used to preserve the order of fetching available descriptors.
- * Only available for head-descriptor. */
- uint64_t counter;
-
- /* The buffer id */
- uint16_t id;
-
- /* The descriptor flags */
- uint16_t flags;
-
- /* The buffer length */
- uint32_t len;
-
- /* The buffer address */
- uint64_t addr;
-} DescStatePacked;
-
-typedef struct QueueRegionPacked {
- /* The feature flags of this region. Now it's initialized to 0. */
- uint64_t features;
-
- /* The version of this region. It's 1 currently.
- * Zero value indicates an uninitialized buffer */
- uint16_t version;
-
- /* The size of DescStatePacked array. It's equal to the virtqueue
- * size. Slave could get it from queue size field of VhostUserInflight. */
- uint16_t desc_num;
-
- /* The head of free DescStatePacked entry list */
- uint16_t free_head;
-
- /* The old head of free DescStatePacked entry list */
- uint16_t old_free_head;
-
- /* The used index of descriptor ring */
- uint16_t used_idx;
-
- /* The old used index of descriptor ring */
- uint16_t old_used_idx;
-
- /* Device ring wrap counter */
- uint8_t used_wrap_counter;
-
- /* The old device ring wrap counter */
- uint8_t old_used_wrap_counter;
-
- /* Padding */
- uint8_t padding[7];
-
- /* Used to track the state of each descriptor fetched from descriptor ring */
- DescStatePacked desc[0];
-} QueueRegionPacked;
-
-To track inflight I/O, the queue region should be processed as follows:
-
-When receiving available buffers from the driver:
-
- 1. Get the next available descriptor entry from descriptor ring, d
-
- 2. If d is head descriptor,
-
- (a) Set desc[old_free_head].num to 0
-
- (b) Set desc[old_free_head].counter to the value of global counter
-
- (c) Increase global counter by 1
-
- (d) Set desc[old_free_head].inflight to 1
-
- 3. If d is last descriptor, set desc[old_free_head].last to free_head
-
- 4. Increase desc[old_free_head].num by 1
-
- 5. Set desc[free_head].addr, desc[free_head].len, desc[free_head].flags,
- desc[free_head].id to d.addr, d.len, d.flags, d.id
-
- 6. Set free_head to desc[free_head].next
-
- 7. If d is last descriptor, set old_free_head to free_head
-
-When supplying used buffers to the driver:
-
- 1. Get corresponding used head-descriptor entry from descriptor ring, d
-
- 2. Get corresponding DescStatePacked entry, e
-
- 3. Set desc[e.last].next to free_head
-
- 4. Set free_head to the index of e
-
- 5. Steps 1,2,3,4 may be performed repeatedly if batching is possible
-
- 6. Increase used_idx by the size of the batch and update used_wrap_counter if needed
-
- 7. Update d.flags
-
- 8. Set the inflight field of each head DescStatePacked entry in the batch to 0
-
- 9. Set old_free_head, old_used_idx, old_used_wrap_counter to free_head, used_idx,
- used_wrap_counter
-
-When reconnecting:
-
- 1. If used_idx does not match old_used_idx (means the inflight field of DescStatePacked
- entries in last batch may be incorrect),
-
- (a) Get the next descriptor ring entry through old_used_idx, d
-
- (b) Use old_used_wrap_counter to calculate the available flags
-
- (c) If d.flags is not equal to the calculated flags value (means slave has
- submitted the buffer to guest driver before crash, so it has to commit the
- in-progres update), set old_free_head, old_used_idx, old_used_wrap_counter
- to free_head, used_idx, used_wrap_counter
-
- 2. Set free_head, used_idx, used_wrap_counter to old_free_head, old_used_idx,
- old_used_wrap_counter (roll back any in-progress update)
-
- 3. Set the inflight field of each DescStatePacked entry in free list to 0
-
- 4. Resubmit inflight DescStatePacked entries in order of their counter value
-
-Protocol features
------------------
-
-#define VHOST_USER_PROTOCOL_F_MQ 0
-#define VHOST_USER_PROTOCOL_F_LOG_SHMFD 1
-#define VHOST_USER_PROTOCOL_F_RARP 2
-#define VHOST_USER_PROTOCOL_F_REPLY_ACK 3
-#define VHOST_USER_PROTOCOL_F_MTU 4
-#define VHOST_USER_PROTOCOL_F_SLAVE_REQ 5
-#define VHOST_USER_PROTOCOL_F_CROSS_ENDIAN 6
-#define VHOST_USER_PROTOCOL_F_CRYPTO_SESSION 7
-#define VHOST_USER_PROTOCOL_F_PAGEFAULT 8
-#define VHOST_USER_PROTOCOL_F_CONFIG 9
-#define VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD 10
-#define VHOST_USER_PROTOCOL_F_HOST_NOTIFIER 11
-#define VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD 12
-
-Master message types
---------------------
-
- * VHOST_USER_GET_FEATURES
-
- Id: 1
- Equivalent ioctl: VHOST_GET_FEATURES
- Master payload: N/A
- Slave payload: u64
-
- Get from the underlying vhost implementation the features bitmask.
- Feature bit VHOST_USER_F_PROTOCOL_FEATURES signals slave support for
- VHOST_USER_GET_PROTOCOL_FEATURES and VHOST_USER_SET_PROTOCOL_FEATURES.
-
- * VHOST_USER_SET_FEATURES
-
- Id: 2
- Ioctl: VHOST_SET_FEATURES
- Master payload: u64
-
- Enable features in the underlying vhost implementation using a bitmask.
- Feature bit VHOST_USER_F_PROTOCOL_FEATURES signals slave support for
- VHOST_USER_GET_PROTOCOL_FEATURES and VHOST_USER_SET_PROTOCOL_FEATURES.
-
- * VHOST_USER_GET_PROTOCOL_FEATURES
-
- Id: 15
- Equivalent ioctl: VHOST_GET_FEATURES
- Master payload: N/A
- Slave payload: u64
-
- Get the protocol feature bitmask from the underlying vhost implementation.
- Only legal if feature bit VHOST_USER_F_PROTOCOL_FEATURES is present in
- VHOST_USER_GET_FEATURES.
- Note: slave that reported VHOST_USER_F_PROTOCOL_FEATURES must support
- this message even before VHOST_USER_SET_FEATURES was called.
-
- * VHOST_USER_SET_PROTOCOL_FEATURES
-
- Id: 16
- Ioctl: VHOST_SET_FEATURES
- Master payload: u64
-
- Enable protocol features in the underlying vhost implementation.
- Only legal if feature bit VHOST_USER_F_PROTOCOL_FEATURES is present in
- VHOST_USER_GET_FEATURES.
- Note: slave that reported VHOST_USER_F_PROTOCOL_FEATURES must support
- this message even before VHOST_USER_SET_FEATURES was called.
-
- * VHOST_USER_SET_OWNER
-
- Id: 3
- Equivalent ioctl: VHOST_SET_OWNER
- Master payload: N/A
-
- Issued when a new connection is established. It sets the current Master
- as an owner of the session. This can be used on the Slave as a
- "session start" flag.
-
- * VHOST_USER_RESET_OWNER
-
- Id: 4
- Master payload: N/A
-
- This is no longer used. Used to be sent to request disabling
- all rings, but some clients interpreted it to also discard
- connection state (this interpretation would lead to bugs).
- It is recommended that clients either ignore this message,
- or use it to disable all rings.
-
- * VHOST_USER_SET_MEM_TABLE
-
- Id: 5
- Equivalent ioctl: VHOST_SET_MEM_TABLE
- Master payload: memory regions description
- Slave payload: (postcopy only) memory regions description
-
- Sets the memory map regions on the slave so it can translate the vring
- addresses. In the ancillary data there is an array of file descriptors
- for each memory mapped region. The size and ordering of the fds matches
- the number and ordering of memory regions.
-
- When VHOST_USER_POSTCOPY_LISTEN has been received, SET_MEM_TABLE replies with
- the bases of the memory mapped regions to the master. The slave must
- have mmap'd the regions but not yet accessed them and should not yet generate
- a userfault event. Note NEED_REPLY_MASK is not set in this case.
- QEMU will then reply back to the list of mappings with an empty
- VHOST_USER_SET_MEM_TABLE as an acknowledgment; only upon reception of this
- message may the guest start accessing the memory and generating faults.
-
- * VHOST_USER_SET_LOG_BASE
-
- Id: 6
- Equivalent ioctl: VHOST_SET_LOG_BASE
- Master payload: u64
- Slave payload: N/A
-
- Sets logging shared memory space.
- When slave has VHOST_USER_PROTOCOL_F_LOG_SHMFD protocol
- feature, the log memory fd is provided in the ancillary data of
- VHOST_USER_SET_LOG_BASE message, the size and offset of shared
- memory area provided in the message.
-
-
- * VHOST_USER_SET_LOG_FD
-
- Id: 7
- Equivalent ioctl: VHOST_SET_LOG_FD
- Master payload: N/A
-
- Sets the logging file descriptor, which is passed as ancillary data.
-
- * VHOST_USER_SET_VRING_NUM
-
- Id: 8
- Equivalent ioctl: VHOST_SET_VRING_NUM
- Master payload: vring state description
-
- Set the size of the queue.
-
- * VHOST_USER_SET_VRING_ADDR
-
- Id: 9
- Equivalent ioctl: VHOST_SET_VRING_ADDR
- Master payload: vring address description
- Slave payload: N/A
-
- Sets the addresses of the different aspects of the vring.
-
- * VHOST_USER_SET_VRING_BASE
-
- Id: 10
- Equivalent ioctl: VHOST_SET_VRING_BASE
- Master payload: vring state description
-
- Sets the base offset in the available vring.
-
- * VHOST_USER_GET_VRING_BASE
-
- Id: 11
- Equivalent ioctl: VHOST_USER_GET_VRING_BASE
- Master payload: vring state description
- Slave payload: vring state description
-
- Get the available vring base offset.
-
- * VHOST_USER_SET_VRING_KICK
-
- Id: 12
- Equivalent ioctl: VHOST_SET_VRING_KICK
- Master payload: u64
-
- Set the event file descriptor for adding buffers to the vring. It
- is passed in the ancillary data.
- Bits (0-7) of the payload contain the vring index. Bit 8 is the
- invalid FD flag. This flag is set when there is no file descriptor
- in the ancillary data. This signals that polling should be used
- instead of waiting for a kick.
-
- * VHOST_USER_SET_VRING_CALL
-
- Id: 13
- Equivalent ioctl: VHOST_SET_VRING_CALL
- Master payload: u64
-
- Set the event file descriptor to signal when buffers are used. It
- is passed in the ancillary data.
- Bits (0-7) of the payload contain the vring index. Bit 8 is the
- invalid FD flag. This flag is set when there is no file descriptor
- in the ancillary data. This signals that polling will be used
- instead of waiting for the call.
-
- * VHOST_USER_SET_VRING_ERR
-
- Id: 14
- Equivalent ioctl: VHOST_SET_VRING_ERR
- Master payload: u64
-
- Set the event file descriptor to signal when error occurs. It
- is passed in the ancillary data.
- Bits (0-7) of the payload contain the vring index. Bit 8 is the
- invalid FD flag. This flag is set when there is no file descriptor
- in the ancillary data.
-
- * VHOST_USER_GET_QUEUE_NUM
-
- Id: 17
- Equivalent ioctl: N/A
- Master payload: N/A
- Slave payload: u64
-
- Query how many queues the backend supports. This request should be
- sent only when VHOST_USER_PROTOCOL_F_MQ is set in queried protocol
- features by VHOST_USER_GET_PROTOCOL_FEATURES.
-
- * VHOST_USER_SET_VRING_ENABLE
-
- Id: 18
- Equivalent ioctl: N/A
- Master payload: vring state description
-
- Signal slave to enable or disable corresponding vring.
- This request should be sent only when VHOST_USER_F_PROTOCOL_FEATURES
- has been negotiated.
-
- * VHOST_USER_SEND_RARP
-
- Id: 19
- Equivalent ioctl: N/A
- Master payload: u64
-
- Ask vhost user backend to broadcast a fake RARP to notify the migration
- is terminated for guest that does not support GUEST_ANNOUNCE.
- Only legal if feature bit VHOST_USER_F_PROTOCOL_FEATURES is present in
- VHOST_USER_GET_FEATURES and protocol feature bit VHOST_USER_PROTOCOL_F_RARP
- is present in VHOST_USER_GET_PROTOCOL_FEATURES.
- The first 6 bytes of the payload contain the mac address of the guest to
- allow the vhost user backend to construct and broadcast the fake RARP.
-
- * VHOST_USER_NET_SET_MTU
-
- Id: 20
- Equivalent ioctl: N/A
- Master payload: u64
-
- Set host MTU value exposed to the guest.
- This request should be sent only when VIRTIO_NET_F_MTU feature has been
- successfully negotiated, VHOST_USER_F_PROTOCOL_FEATURES is present in
- VHOST_USER_GET_FEATURES and protocol feature bit
- VHOST_USER_PROTOCOL_F_NET_MTU is present in
- VHOST_USER_GET_PROTOCOL_FEATURES.
- If VHOST_USER_PROTOCOL_F_REPLY_ACK is negotiated, slave must respond
- with zero in case the specified MTU is valid, or non-zero otherwise.
-
- * VHOST_USER_SET_SLAVE_REQ_FD
-
- Id: 21
- Equivalent ioctl: N/A
- Master payload: N/A
-
- Set the socket file descriptor for slave initiated requests. It is passed
- in the ancillary data.
- This request should be sent only when VHOST_USER_F_PROTOCOL_FEATURES
- has been negotiated, and protocol feature bit VHOST_USER_PROTOCOL_F_SLAVE_REQ
- bit is present in VHOST_USER_GET_PROTOCOL_FEATURES.
- If VHOST_USER_PROTOCOL_F_REPLY_ACK is negotiated, slave must respond
- with zero for success, non-zero otherwise.
-
- * VHOST_USER_IOTLB_MSG
-
- Id: 22
- Equivalent ioctl: N/A (equivalent to VHOST_IOTLB_MSG message type)
- Master payload: struct vhost_iotlb_msg
- Slave payload: u64
-
- Send IOTLB messages with struct vhost_iotlb_msg as payload.
- Master sends such requests to update and invalidate entries in the device
- IOTLB. The slave has to acknowledge the request with sending zero as u64
- payload for success, non-zero otherwise.
- This request should be send only when VIRTIO_F_IOMMU_PLATFORM feature
- has been successfully negotiated.
-
- * VHOST_USER_SET_VRING_ENDIAN
-
- Id: 23
- Equivalent ioctl: VHOST_SET_VRING_ENDIAN
- Master payload: vring state description
-
- Set the endianness of a VQ for legacy devices. Little-endian is indicated
- with state.num set to 0 and big-endian is indicated with state.num set
- to 1. Other values are invalid.
- This request should be sent only when VHOST_USER_PROTOCOL_F_CROSS_ENDIAN
- has been negotiated.
- Backends that negotiated this feature should handle both endiannesses
- and expect this message once (per VQ) during device configuration
- (ie. before the master starts the VQ).
-
- * VHOST_USER_GET_CONFIG
-
- Id: 24
- Equivalent ioctl: N/A
- Master payload: virtio device config space
- Slave payload: virtio device config space
-
- When VHOST_USER_PROTOCOL_F_CONFIG is negotiated, this message is
- submitted by the vhost-user master to fetch the contents of the virtio
- device configuration space, vhost-user slave's payload size MUST match
- master's request, vhost-user slave uses zero length of payload to
- indicate an error to vhost-user master. The vhost-user master may
- cache the contents to avoid repeated VHOST_USER_GET_CONFIG calls.
-
-* VHOST_USER_SET_CONFIG
-
- Id: 25
- Equivalent ioctl: N/A
- Master payload: virtio device config space
- Slave payload: N/A
-
- When VHOST_USER_PROTOCOL_F_CONFIG is negotiated, this message is
- submitted by the vhost-user master when the Guest changes the virtio
- device configuration space and also can be used for live migration
- on the destination host. The vhost-user slave must check the flags
- field, and slaves MUST NOT accept SET_CONFIG for read-only
- configuration space fields unless the live migration bit is set.
-
-* VHOST_USER_CREATE_CRYPTO_SESSION
-
- Id: 26
- Equivalent ioctl: N/A
- Master payload: crypto session description
- Slave payload: crypto session description
-
- Create a session for crypto operation. The server side must return the
- session id, 0 or positive for success, negative for failure.
- This request should be sent only when VHOST_USER_PROTOCOL_F_CRYPTO_SESSION
- feature has been successfully negotiated.
- It's a required feature for crypto devices.
-
-* VHOST_USER_CLOSE_CRYPTO_SESSION
-
- Id: 27
- Equivalent ioctl: N/A
- Master payload: u64
-
- Close a session for crypto operation which was previously
- created by VHOST_USER_CREATE_CRYPTO_SESSION.
- This request should be sent only when VHOST_USER_PROTOCOL_F_CRYPTO_SESSION
- feature has been successfully negotiated.
- It's a required feature for crypto devices.
-
- * VHOST_USER_POSTCOPY_ADVISE
- Id: 28
- Master payload: N/A
- Slave payload: userfault fd
-
- When VHOST_USER_PROTOCOL_F_PAGEFAULT is supported, the
- master advises slave that a migration with postcopy enabled is underway,
- the slave must open a userfaultfd for later use.
- Note that at this stage the migration is still in precopy mode.
-
- * VHOST_USER_POSTCOPY_LISTEN
- Id: 29
- Master payload: N/A
-
- Master advises slave that a transition to postcopy mode has happened.
- The slave must ensure that shared memory is registered with userfaultfd
- to cause faulting of non-present pages.
-
- This is always sent sometime after a VHOST_USER_POSTCOPY_ADVISE, and
- thus only when VHOST_USER_PROTOCOL_F_PAGEFAULT is supported.
-
- * VHOST_USER_POSTCOPY_END
- Id: 30
- Slave payload: u64
-
- Master advises that postcopy migration has now completed. The
- slave must disable the userfaultfd. The response is an acknowledgement
- only.
- When VHOST_USER_PROTOCOL_F_PAGEFAULT is supported, this message
- is sent at the end of the migration, after VHOST_USER_POSTCOPY_LISTEN
- was previously sent.
- The value returned is an error indication; 0 is success.
-
- * VHOST_USER_GET_INFLIGHT_FD
- Id: 31
- Equivalent ioctl: N/A
- Master payload: inflight description
-
- When VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD protocol feature has been
- successfully negotiated, this message is submitted by master to get
- a shared buffer from slave. The shared buffer will be used to track
- inflight I/O by slave. QEMU should retrieve a new one when vm reset.
-
- * VHOST_USER_SET_INFLIGHT_FD
- Id: 32
- Equivalent ioctl: N/A
- Master payload: inflight description
-
- When VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD protocol feature has been
- successfully negotiated, this message is submitted by master to send
- the shared inflight buffer back to slave so that slave could get
- inflight I/O after a crash or restart.
-
-Slave message types
--------------------
-
- * VHOST_USER_SLAVE_IOTLB_MSG
-
- Id: 1
- Equivalent ioctl: N/A (equivalent to VHOST_IOTLB_MSG message type)
- Slave payload: struct vhost_iotlb_msg
- Master payload: N/A
-
- Send IOTLB messages with struct vhost_iotlb_msg as payload.
- Slave sends such requests to notify of an IOTLB miss, or an IOTLB
- access failure. If VHOST_USER_PROTOCOL_F_REPLY_ACK is negotiated,
- and slave set the VHOST_USER_NEED_REPLY flag, master must respond with
- zero when operation is successfully completed, or non-zero otherwise.
- This request should be send only when VIRTIO_F_IOMMU_PLATFORM feature
- has been successfully negotiated.
-
-* VHOST_USER_SLAVE_CONFIG_CHANGE_MSG
-
- Id: 2
- Equivalent ioctl: N/A
- Slave payload: N/A
- Master payload: N/A
-
- When VHOST_USER_PROTOCOL_F_CONFIG is negotiated, vhost-user slave sends
- such messages to notify that the virtio device's configuration space has
- changed, for those host devices which can support such feature, host
- driver can send VHOST_USER_GET_CONFIG message to slave to get the latest
- content. If VHOST_USER_PROTOCOL_F_REPLY_ACK is negotiated, and slave set
- the VHOST_USER_NEED_REPLY flag, master must respond with zero when
- operation is successfully completed, or non-zero otherwise.
-
- * VHOST_USER_SLAVE_VRING_HOST_NOTIFIER_MSG
-
- Id: 3
- Equivalent ioctl: N/A
- Slave payload: vring area description
- Master payload: N/A
-
- Sets host notifier for a specified queue. The queue index is contained
- in the u64 field of the vring area description. The host notifier is
- described by the file descriptor (typically it's a VFIO device fd) which
- is passed as ancillary data and the size (which is mmap size and should
- be the same as host page size) and offset (which is mmap offset) carried
- in the vring area description. QEMU can mmap the file descriptor based
- on the size and offset to get a memory range. Registering a host notifier
- means mapping this memory range to the VM as the specified queue's notify
- MMIO region. Slave sends this request to tell QEMU to de-register the
- existing notifier if any and register the new notifier if the request is
- sent with a file descriptor.
- This request should be sent only when VHOST_USER_PROTOCOL_F_HOST_NOTIFIER
- protocol feature has been successfully negotiated.
-
-VHOST_USER_PROTOCOL_F_REPLY_ACK:
--------------------------------
-The original vhost-user specification only demands replies for certain
-commands. This differs from the vhost protocol implementation where commands
-are sent over an ioctl() call and block until the client has completed.
-
-With this protocol extension negotiated, the sender (QEMU) can set the
-"need_reply" [Bit 3] flag to any command. This indicates that
-the client MUST respond with a Payload VhostUserMsg indicating success or
-failure. The payload should be set to zero on success or non-zero on failure,
-unless the message already has an explicit reply body.
-
-The response payload gives QEMU a deterministic indication of the result
-of the command. Today, QEMU is expected to terminate the main vhost-user
-loop upon receiving such errors. In future, qemu could be taught to be more
-resilient for selective requests.
-
-For the message types that already solicit a reply from the client, the
-presence of VHOST_USER_PROTOCOL_F_REPLY_ACK or need_reply bit being set brings
-no behavioural change. (See the 'Communication' section for details.)
-
-Backend program conventions
----------------------------
-
-vhost-user backends can provide various devices & services and may
-need to be configured manually depending on the use case. However, it
-is a good idea to follow the conventions listed here when
-possible. Users, QEMU or libvirt, can then rely on some common
-behaviour to avoid heterogenous configuration and management of the
-backend programs and facilitate interoperability.
-
-Each backend installed on a host system should come with at least one
-JSON file that conforms to the vhost-user.json schema. Each file
-informs the management applications about the backend type, and binary
-location. In addition, it defines rules for management apps for
-picking the highest priority backend when multiple match the search
-criteria (see @VhostUserBackend documentation in the schema file).
-
-If the backend is not capable of enabling a requested feature on the
-host (such as 3D acceleration with virgl), or the initialization
-failed, the backend should fail to start early and exit with a status
-!= 0. It may also print a message to stderr for further details.
-
-The backend program must not daemonize itself, but it may be
-daemonized by the management layer. It may also have a restricted
-access to the system.
-
-File descriptors 0, 1 and 2 will exist, and have regular
-stdin/stdout/stderr usage (they may have been redirected to /dev/null
-by the management layer, or to a log handler).
-
-The backend program must end (as quickly and cleanly as possible) when
-the SIGTERM signal is received. Eventually, it may receive SIGKILL by
-the management layer after a few seconds.
-
-The following command line options have an expected behaviour. They
-are mandatory, unless explicitly said differently:
-
-* --socket-path=PATH
-
-This option specify the location of the vhost-user Unix domain socket.
-It is incompatible with --fd.
-
-* --fd=FDNUM
-
-When this argument is given, the backend program is started with the
-vhost-user socket as file descriptor FDNUM. It is incompatible with
---socket-path.
-
-* --print-capabilities
-
-Output to stdout the backend capabilities in JSON format, and then
-exit successfully. Other options and arguments should be ignored, and
-the backend program should not perform its normal function. The
-capabilities can be reported dynamically depending on the host
-capabilities.
-
-The JSON output is described in the vhost-user.json schema, by
-@VHostUserBackendCapabilities. Example:
-{
- "type": "foo",
- "features": [
- "feature-a",
- "feature-b"
- ]
-}
-
-vhost-user-input
-----------------
-
-Command line options:
-
-* --evdev-path=PATH (optional)
-
-Specify the linux input device.
-
-* --no-grab (optional)
-
-Do no request exclusive access to the input device.
-
-vhost-user-gpu
---------------
-
-Command line options:
-
-* --render-node=PATH (optional)
-
-Specify the GPU DRM render node.
-
-* --virgl (optional)
-
-Enable virgl rendering support.
diff --git a/MAINTAINERS b/MAINTAINERS
index 66ddbda9c9..562d0ee0c6 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1476,7 +1476,7 @@ M: Michael S. Tsirkin <mst@redhat.com>
S: Supported
F: hw/*/*vhost*
F: docs/interop/vhost-user.json
-F: docs/interop/vhost-user.txt
+F: docs/interop/vhost-user.rst
F: contrib/vhost-user-*/
virtio
diff --git a/docs/interop/index.rst b/docs/interop/index.rst
index 2df977dd52..a037bd67ec 100644
--- a/docs/interop/index.rst
+++ b/docs/interop/index.rst
@@ -15,4 +15,4 @@ Contents:
bitmaps
live-block-operations
pr-helper
-
+ vhost-user
diff --git a/docs/interop/vhost-user.rst b/docs/interop/vhost-user.rst
new file mode 100644
index 0000000000..7f3232c798
--- /dev/null
+++ b/docs/interop/vhost-user.rst
@@ -0,0 +1,1351 @@
+===================
+Vhost-user Protocol
+===================
+:Copyright: 2014 Virtual Open Systems Sarl.
+:Licence: This work is licensed under the terms of the GNU GPL,
+ version 2 or later. See the COPYING file in the top-level
+ directory.
+
+.. contents:: Table of Contents
+
+Introduction
+============
+
+This protocol is aiming to complement the ``ioctl`` interface used to
+control the vhost implementation in the Linux kernel. It implements
+the control plane needed to establish virtqueue sharing with a user
+space process on the same host. It uses communication over a Unix
+domain socket to share file descriptors in the ancillary data of the
+message.
+
+The protocol defines 2 sides of the communication, *master* and
+*slave*. *Master* is the application that shares its virtqueues, in
+our case QEMU. *Slave* is the consumer of the virtqueues.
+
+In the current implementation QEMU is the *master*, and the *slave* is
+the external process consuming the virtio queues, for example a
+software Ethernet switch running in user space, such as Snabbswitch,
+or a block device backend processing read & write to a virtual
+disk. In order to facilitate interoperability between various backend
+implementations, it is recommended to follow the :ref:`Backend program
+conventions <backend_conventions>`.
+
+*Master* and *slave* can be either a client (i.e. connecting) or
+server (listening) in the socket communication.
+
+Message Specification
+=====================
+
+.. Note:: All numbers are in the machine native byte order.
+
+A vhost-user message consists of 3 header fields and a payload.
+
++---------+-------+------+---------+
+| request | flags | size | payload |
++---------+-------+------+---------+
+
+Header
+------
+
+:request: 32-bit type of the request
+
+:flags: 32-bit bit field
+
+- Lower 2 bits are the version (currently 0x01)
+- Bit 2 is the reply flag - needs to be sent on each reply from the slave
+- Bit 3 is the need_reply flag - see :ref:`REPLY_ACK <reply_ack>` for
+ details.
+
+:size: 32-bit size of the payload
+
+Payload
+-------
+
+Depending on the request type, **payload** can be:
+
+A single 64-bit integer
+^^^^^^^^^^^^^^^^^^^^^^^
+
++-----+
+| u64 |
++-----+
+
+:u64: a 64-bit unsigned integer
+
+A vring state description
+^^^^^^^^^^^^^^^^^^^^^^^^^
+
++-------+-----+
+| index | num |
++-------+-----+
+
+:index: a 32-bit index
+
+:num: a 32-bit number
+
+A vring address description
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
++-------+-------+------+------------+------+-----------+-----+
+| index | flags | size | descriptor | used | available | log |
++-------+-------+------+------------+------+-----------+-----+
+
+:index: a 32-bit vring index
+
+:flags: a 32-bit vring flags
+
+:descriptor: a 64-bit ring address of the vring descriptor table
+
+:used: a 64-bit ring address of the vring used ring
+
+:available: a 64-bit ring address of the vring available ring
+
+:log: a 64-bit guest address for logging
+
+Note that a ring address is an IOVA if ``VIRTIO_F_IOMMU_PLATFORM`` has
+been negotiated. Otherwise it is a user address.
+
+Memory regions description
+^^^^^^^^^^^^^^^^^^^^^^^^^^
+
++-------------+---------+---------+-----+---------+
+| num regions | padding | region0 | ... | region7 |
++-------------+---------+---------+-----+---------+
+
+:num regions: a 32-bit number of regions
+
+:padding: 32-bit
+
+A region is:
+
++---------------+------+--------------+-------------+
+| guest address | size | user address | mmap offset |
++---------------+------+--------------+-------------+
+
+:guest address: a 64-bit guest address of the region
+
+:size: a 64-bit size
+
+:user address: a 64-bit user address
+
+:mmap offset: 64-bit offset where region starts in the mapped memory
+
+Log description
+^^^^^^^^^^^^^^^
+
++----------+------------+
+| log size | log offset |
++----------+------------+
+
+:log size: size of area used for logging
+
+:log offset: offset from start of supplied file descriptor where
+ logging starts (i.e. where guest address 0 would be
+ logged)
+
+An IOTLB message
+^^^^^^^^^^^^^^^^
+
++------+------+--------------+-------------------+------+
+| iova | size | user address | permissions flags | type |
++------+------+--------------+-------------------+------+
+
+:iova: a 64-bit I/O virtual address programmed by the guest
+
+:size: a 64-bit size
+
+:user address: a 64-bit user address
+
+:permissions flags: an 8-bit value:
+ - 0: No access
+ - 1: Read access
+ - 2: Write access
+ - 3: Read/Write access
+
+:type: an 8-bit IOTLB message type:
+ - 1: IOTLB miss
+ - 2: IOTLB update
+ - 3: IOTLB invalidate
+ - 4: IOTLB access fail
+
+Virtio device config space
+^^^^^^^^^^^^^^^^^^^^^^^^^^
+
++--------+------+-------+---------+
+| offset | size | flags | payload |
++--------+------+-------+---------+
+
+:offset: a 32-bit offset of virtio device's configuration space
+
+:size: a 32-bit configuration space access size in bytes
+
+:flags: a 32-bit value:
+ - 0: Vhost master messages used for writeable fields
+ - 1: Vhost master messages used for live migration
+
+:payload: Size bytes array holding the contents of the virtio
+ device's configuration space
+
+Vring area description
+^^^^^^^^^^^^^^^^^^^^^^
+
++-----+------+--------+
+| u64 | size | offset |
++-----+------+--------+
+
+:u64: a 64-bit integer contains vring index and flags
+
+:size: a 64-bit size of this area
+
+:offset: a 64-bit offset of this area from the start of the
+ supplied file descriptor
+
+Inflight description
+^^^^^^^^^^^^^^^^^^^^
+
++-----------+-------------+------------+------------+
+| mmap size | mmap offset | num queues | queue size |
++-----------+-------------+------------+------------+
+
+:mmap size: a 64-bit size of area to track inflight I/O
+
+:mmap offset: a 64-bit offset of this area from the start
+ of the supplied file descriptor
+
+:num queues: a 16-bit number of virtqueues
+
+:queue size: a 16-bit size of virtqueues
+
+C structure
+-----------
+
+In QEMU the vhost-user message is implemented with the following struct:
+
+.. code:: c
+
+ typedef struct VhostUserMsg {
+ VhostUserRequest request;
+ uint32_t flags;
+ uint32_t size;
+ union {
+ uint64_t u64;
+ struct vhost_vring_state state;
+ struct vhost_vring_addr addr;
+ VhostUserMemory memory;
+ VhostUserLog log;
+ struct vhost_iotlb_msg iotlb;
+ VhostUserConfig config;
+ VhostUserVringArea area;
+ VhostUserInflight inflight;
+ };
+ } QEMU_PACKED VhostUserMsg;
+
+Communication
+=============
+
+The protocol for vhost-user is based on the existing implementation of
+vhost for the Linux Kernel. Most messages that can be sent via the
+Unix domain socket implementing vhost-user have an equivalent ioctl to
+the kernel implementation.
+
+The communication consists of *master* sending message requests and
+*slave* sending message replies. Most of the requests don't require
+replies. Here is a list of the ones that do:
+
+* ``VHOST_USER_GET_FEATURES``
+* ``VHOST_USER_GET_PROTOCOL_FEATURES``
+* ``VHOST_USER_GET_VRING_BASE``
+* ``VHOST_USER_SET_LOG_BASE`` (if ``VHOST_USER_PROTOCOL_F_LOG_SHMFD``)
+* ``VHOST_USER_GET_INFLIGHT_FD`` (if ``VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD``)
+
+.. seealso::
+
+ :ref:`REPLY_ACK <reply_ack>`
+ The section on ``REPLY_ACK`` protocol extension.
+
+There are several messages that the master sends with file descriptors passed
+in the ancillary data:
+
+* ``VHOST_USER_SET_MEM_TABLE``
+* ``VHOST_USER_SET_LOG_BASE`` (if ``VHOST_USER_PROTOCOL_F_LOG_SHMFD``)
+* ``VHOST_USER_SET_LOG_FD``
+* ``VHOST_USER_SET_VRING_KICK``
+* ``VHOST_USER_SET_VRING_CALL``
+* ``VHOST_USER_SET_VRING_ERR``
+* ``VHOST_USER_SET_SLAVE_REQ_FD``
+* ``VHOST_USER_SET_INFLIGHT_FD`` (if ``VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD``)
+
+If *master* is unable to send the full message or receives a wrong
+reply it will close the connection. An optional reconnection mechanism
+can be implemented.
+
+Any protocol extensions are gated by protocol feature bits, which
+allows full backwards compatibility on both master and slave. As
+older slaves don't support negotiating protocol features, a feature
+bit was dedicated for this purpose::
+
+ #define VHOST_USER_F_PROTOCOL_FEATURES 30
+
+Starting and stopping rings
+---------------------------
+
+Client must only process each ring when it is started.
+
+Client must only pass data between the ring and the backend, when the
+ring is enabled.
+
+If ring is started but disabled, client must process the ring without
+talking to the backend.
+
+For example, for a networking device, in the disabled state client
+must not supply any new RX packets, but must process and discard any
+TX packets.
+
+If ``VHOST_USER_F_PROTOCOL_FEATURES`` has not been negotiated, the
+ring is initialized in an enabled state.
+
+If ``VHOST_USER_F_PROTOCOL_FEATURES`` has been negotiated, the ring is
+initialized in a disabled state. Client must not pass data to/from the
+backend until ring is enabled by ``VHOST_USER_SET_VRING_ENABLE`` with
+parameter 1, or after it has been disabled by
+``VHOST_USER_SET_VRING_ENABLE`` with parameter 0.
+
+Each ring is initialized in a stopped state, client must not process
+it until ring is started, or after it has been stopped.
+
+Client must start ring upon receiving a kick (that is, detecting that
+file descriptor is readable) on the descriptor specified by
+``VHOST_USER_SET_VRING_KICK``, and stop ring upon receiving
+``VHOST_USER_GET_VRING_BASE``.
+
+While processing the rings (whether they are enabled or not), client
+must support changing some configuration aspects on the fly.
+
+Multiple queue support
+----------------------
+
+Multiple queue is treated as a protocol extension, hence the slave has
+to implement protocol features first. The multiple queues feature is
+supported only when the protocol feature ``VHOST_USER_PROTOCOL_F_MQ``
+(bit 0) is set.
+
+The max number of queue pairs the slave supports can be queried with
+message ``VHOST_USER_GET_QUEUE_NUM``. Master should stop when the
+number of requested queues is bigger than that.
+
+As all queues share one connection, the master uses a unique index for each
+queue in the sent message to identify a specified queue. One queue pair
+is enabled initially. More queues are enabled dynamically, by sending
+message ``VHOST_USER_SET_VRING_ENABLE``.
+
+Migration
+---------
+
+During live migration, the master may need to track the modifications
+the slave makes to the memory mapped regions. The client should mark
+the dirty pages in a log. Once it complies to this logging, it may
+declare the ``VHOST_F_LOG_ALL`` vhost feature.
+
+To start/stop logging of data/used ring writes, server may send
+messages ``VHOST_USER_SET_FEATURES`` with ``VHOST_F_LOG_ALL`` and
+``VHOST_USER_SET_VRING_ADDR`` with ``VHOST_VRING_F_LOG`` in ring's
+flags set to 1/0, respectively.
+
+All the modifications to memory pointed by vring "descriptor" should
+be marked. Modifications to "used" vring should be marked if
+``VHOST_VRING_F_LOG`` is part of ring's flags.
+
+Dirty pages are of size::
+
+ #define VHOST_LOG_PAGE 0x1000
+
+The log memory fd is provided in the ancillary data of
+``VHOST_USER_SET_LOG_BASE`` message when the slave has
+``VHOST_USER_PROTOCOL_F_LOG_SHMFD`` protocol feature.
+
+The size of the log is supplied as part of ``VhostUserMsg`` which
+should be large enough to cover all known guest addresses. Log starts
+at the supplied offset in the supplied file descriptor. The log
+covers from address 0 to the maximum of guest regions. In pseudo-code,
+to mark page at ``addr`` as dirty::
+
+ page = addr / VHOST_LOG_PAGE
+ log[page / 8] |= 1 << page % 8
+
+Where ``addr`` is the guest physical address.
+
+Use atomic operations, as the log may be concurrently manipulated.
+
+Note that when logging modifications to the used ring (when
+``VHOST_VRING_F_LOG`` is set for this ring), ``log_guest_addr`` should
+be used to calculate the log offset: the write to first byte of the
+used ring is logged at this offset from log start. Also note that this
+value might be outside the legal guest physical address range
+(i.e. does not have to be covered by the ``VhostUserMemory`` table), but
+the bit offset of the last byte of the ring must fall within the size
+supplied by ``VhostUserLog``.
+
+``VHOST_USER_SET_LOG_FD`` is an optional message with an eventfd in
+ancillary data, it may be used to inform the master that the log has
+been modified.
+
+Once the source has finished migration, rings will be stopped by the
+source. No further update must be done before rings are restarted.
+
+In postcopy migration the slave is started before all the memory has
+been received from the source host, and care must be taken to avoid
+accessing pages that have yet to be received. The slave opens a
+'userfault'-fd and registers the memory with it; this fd is then
+passed back over to the master. The master services requests on the
+userfaultfd for pages that are accessed and when the page is available
+it performs WAKE ioctl's on the userfaultfd to wake the stalled
+slave. The client indicates support for this via the
+``VHOST_USER_PROTOCOL_F_PAGEFAULT`` feature.
+
+Memory access
+-------------
+
+The master sends a list of vhost memory regions to the slave using the
+``VHOST_USER_SET_MEM_TABLE`` message. Each region has two base
+addresses: a guest address and a user address.
+
+Messages contain guest addresses and/or user addresses to reference locations
+within the shared memory. The mapping of these addresses works as follows.
+
+User addresses map to the vhost memory region containing that user address.
+
+When the ``VIRTIO_F_IOMMU_PLATFORM`` feature has not been negotiated:
+
+* Guest addresses map to the vhost memory region containing that guest
+ address.
+
+When the ``VIRTIO_F_IOMMU_PLATFORM`` feature has been negotiated:
+
+* Guest addresses are also called I/O virtual addresses (IOVAs). They are
+ translated to user addresses via the IOTLB.
+
+* The vhost memory region guest address is not used.
+
+IOMMU support
+-------------
+
+When the ``VIRTIO_F_IOMMU_PLATFORM`` feature has been negotiated, the
+master sends IOTLB entries update & invalidation by sending
+``VHOST_USER_IOTLB_MSG`` requests to the slave with a ``struct
+vhost_iotlb_msg`` as payload. For update events, the ``iotlb`` payload
+has to be filled with the update message type (2), the I/O virtual
+address, the size, the user virtual address, and the permissions
+flags. Addresses and size must be within vhost memory regions set via
+the ``VHOST_USER_SET_MEM_TABLE`` request. For invalidation events, the
+``iotlb`` payload has to be filled with the invalidation message type
+(3), the I/O virtual address and the size. On success, the slave is
+expected to reply with a zero payload, non-zero otherwise.
+
+The slave relies on the slave communcation channel (see :ref:`Slave
+communication <slave_communication>` section below) to send IOTLB miss
+and access failure events, by sending ``VHOST_USER_SLAVE_IOTLB_MSG``
+requests to the master with a ``struct vhost_iotlb_msg`` as
+payload. For miss events, the iotlb payload has to be filled with the
+miss message type (1), the I/O virtual address and the permissions
+flags. For access failure event, the iotlb payload has to be filled
+with the access failure message type (4), the I/O virtual address and
+the permissions flags. For synchronization purpose, the slave may
+rely on the reply-ack feature, so the master may send a reply when
+operation is completed if the reply-ack feature is negotiated and
+slaves requests a reply. For miss events, completed operation means
+either master sent an update message containing the IOTLB entry
+containing requested address and permission, or master sent nothing if
+the IOTLB miss message is invalid (invalid IOVA or permission).
+
+The master isn't expected to take the initiative to send IOTLB update
+messages, as the slave sends IOTLB miss messages for the guest virtual
+memory areas it needs to access.
+
+.. _slave_communication:
+
+Slave communication
+-------------------
+
+An optional communication channel is provided if the slave declares
+``VHOST_USER_PROTOCOL_F_SLAVE_REQ`` protocol feature, to allow the
+slave to make requests to the master.
+
+The fd is provided via ``VHOST_USER_SET_SLAVE_REQ_FD`` ancillary data.
+
+A slave may then send ``VHOST_USER_SLAVE_*`` messages to the master
+using this fd communication channel.
+
+If ``VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD`` protocol feature is
+negotiated, slave can send file descriptors (at most 8 descriptors in
+each message) to master via ancillary data using this fd communication
+channel.
+
+Inflight I/O tracking
+---------------------
+
+To support reconnecting after restart or crash, slave may need to
+resubmit inflight I/Os. If virtqueue is processed in order, we can
+easily achieve that by getting the inflight descriptors from
+descriptor table (split virtqueue) or descriptor ring (packed
+virtqueue). However, it can't work when we process descriptors
+out-of-order because some entries which store the information of
+inflight descriptors in available ring (split virtqueue) or descriptor
+ring (packed virtqueue) might be overrided by new entries. To solve
+this problem, slave need to allocate an extra buffer to store this
+information of inflight descriptors and share it with master for
+persistent. ``VHOST_USER_GET_INFLIGHT_FD`` and
+``VHOST_USER_SET_INFLIGHT_FD`` are used to transfer this buffer
+between master and slave. And the format of this buffer is described
+below:
+
++---------------+---------------+-----+---------------+
+| queue0 region | queue1 region | ... | queueN region |
++---------------+---------------+-----+---------------+
+
+N is the number of available virtqueues. Slave could get it from num
+queues field of ``VhostUserInflight``.
+
+For split virtqueue, queue region can be implemented as:
+
+.. code:: c
+
+ typedef struct DescStateSplit {
+ /* Indicate whether this descriptor is inflight or not.
+ * Only available for head-descriptor. */
+ uint8_t inflight;
+
+ /* Padding */
+ uint8_t padding[5];
+
+ /* Maintain a list for the last batch of used descriptors.
+ * Only available when batching is used for submitting */
+ uint16_t next;
+
+ /* Used to preserve the order of fetching available descriptors.
+ * Only available for head-descriptor. */
+ uint64_t counter;
+ } DescStateSplit;
+
+ typedef struct QueueRegionSplit {
+ /* The feature flags of this region. Now it's initialized to 0. */
+ uint64_t features;
+
+ /* The version of this region. It's 1 currently.
+ * Zero value indicates an uninitialized buffer */
+ uint16_t version;
+
+ /* The size of DescStateSplit array. It's equal to the virtqueue
+ * size. Slave could get it from queue size field of VhostUserInflight. */
+ uint16_t desc_num;
+
+ /* The head of list that track the last batch of used descriptors. */
+ uint16_t last_batch_head;
+
+ /* Store the idx value of used ring */
+ uint16_t used_idx;
+
+ /* Used to track the state of each descriptor in descriptor table */
+ DescStateSplit desc[0];
+ } QueueRegionSplit;
+
+To track inflight I/O, the queue region should be processed as follows:
+
+When receiving available buffers from the driver:
+
+#. Get the next available head-descriptor index from available ring, ``i``
+
+#. Set ``desc[i].counter`` to the value of global counter
+
+#. Increase global counter by 1
+
+#. Set ``desc[i].inflight`` to 1
+
+When supplying used buffers to the driver:
+
+1. Get corresponding used head-descriptor index, i
+
+2. Set ``desc[i].next`` to ``last_batch_head``
+
+3. Set ``last_batch_head`` to ``i``
+
+#. Steps 1,2,3 may be performed repeatedly if batching is possible
+
+#. Increase the ``idx`` value of used ring by the size of the batch
+
+#. Set the ``inflight`` field of each ``DescStateSplit`` entry in the batch to 0
+
+#. Set ``used_idx`` to the ``idx`` value of used ring
+
+When reconnecting:
+
+#. If the value of ``used_idx`` does not match the ``idx`` value of
+ used ring (means the inflight field of ``DescStateSplit`` entries in
+ last batch may be incorrect),
+
+ a. Subtract the value of ``used_idx`` from the ``idx`` value of
+ used ring to get last batch size of ``DescStateSplit`` entries
+
+ #. Set the ``inflight`` field of each ``DescStateSplit`` entry to 0 in last batch
+ list which starts from ``last_batch_head``
+
+ #. Set ``used_idx`` to the ``idx`` value of used ring
+
+#. Resubmit inflight ``DescStateSplit`` entries in order of their
+ counter value
+
+For packed virtqueue, queue region can be implemented as:
+
+.. code:: c
+
+ typedef struct DescStatePacked {
+ /* Indicate whether this descriptor is inflight or not.
+ * Only available for head-descriptor. */
+ uint8_t inflight;
+
+ /* Padding */
+ uint8_t padding;
+
+ /* Link to the next free entry */
+ uint16_t next;
+
+ /* Link to the last entry of descriptor list.
+ * Only available for head-descriptor. */
+ uint16_t last;
+
+ /* The length of descriptor list.
+ * Only available for head-descriptor. */
+ uint16_t num;
+
+ /* Used to preserve the order of fetching available descriptors.
+ * Only available for head-descriptor. */
+ uint64_t counter;
+
+ /* The buffer id */
+ uint16_t id;
+
+ /* The descriptor flags */
+ uint16_t flags;
+
+ /* The buffer length */
+ uint32_t len;
+
+ /* The buffer address */
+ uint64_t addr;
+ } DescStatePacked;
+
+ typedef struct QueueRegionPacked {
+ /* The feature flags of this region. Now it's initialized to 0. */
+ uint64_t features;
+
+ /* The version of this region. It's 1 currently.
+ * Zero value indicates an uninitialized buffer */
+ uint16_t version;
+
+ /* The size of DescStatePacked array. It's equal to the virtqueue
+ * size. Slave could get it from queue size field of VhostUserInflight. */
+ uint16_t desc_num;
+
+ /* The head of free DescStatePacked entry list */
+ uint16_t free_head;
+
+ /* The old head of free DescStatePacked entry list */
+ uint16_t old_free_head;
+
+ /* The used index of descriptor ring */
+ uint16_t used_idx;
+
+ /* The old used index of descriptor ring */
+ uint16_t old_used_idx;
+
+ /* Device ring wrap counter */
+ uint8_t used_wrap_counter;
+
+ /* The old device ring wrap counter */
+ uint8_t old_used_wrap_counter;
+
+ /* Padding */
+ uint8_t padding[7];
+
+ /* Used to track the state of each descriptor fetched from descriptor ring */
+ DescStatePacked desc[0];
+ } QueueRegionPacked;
+
+To track inflight I/O, the queue region should be processed as follows:
+
+When receiving available buffers from the driver:
+
+#. Get the next available descriptor entry from descriptor ring, ``d``
+
+#. If ``d`` is head descriptor,
+
+ a. Set ``desc[old_free_head].num`` to 0
+
+ #. Set ``desc[old_free_head].counter`` to the value of global counter
+
+ #. Increase global counter by 1
+
+ #. Set ``desc[old_free_head].inflight`` to 1
+
+#. If ``d`` is last descriptor, set ``desc[old_free_head].last`` to
+ ``free_head``
+
+#. Increase ``desc[old_free_head].num`` by 1
+
+#. Set ``desc[free_head].addr``, ``desc[free_head].len``,
+ ``desc[free_head].flags``, ``desc[free_head].id`` to ``d.addr``,
+ ``d.len``, ``d.flags``, ``d.id``
+
+#. Set ``free_head`` to ``desc[free_head].next``
+
+#. If ``d`` is last descriptor, set ``old_free_head`` to ``free_head``
+
+When supplying used buffers to the driver:
+
+1. Get corresponding used head-descriptor entry from descriptor ring,
+ ``d``
+
+2. Get corresponding ``DescStatePacked`` entry, ``e``
+
+3. Set ``desc[e.last].next`` to ``free_head``
+
+4. Set ``free_head`` to the index of ``e``
+
+#. Steps 1,2,3,4 may be performed repeatedly if batching is possible
+
+#. Increase ``used_idx`` by the size of the batch and update
+ ``used_wrap_counter`` if needed
+
+#. Update ``d.flags``
+
+#. Set the ``inflight`` field of each head ``DescStatePacked`` entry
+ in the batch to 0
+
+#. Set ``old_free_head``, ``old_used_idx``, ``old_used_wrap_counter``
+ to ``free_head``, ``used_idx``, ``used_wrap_counter``
+
+When reconnecting:
+
+#. If ``used_idx`` does not match ``old_used_idx`` (means the
+ ``inflight`` field of ``DescStatePacked`` entries in last batch may
+ be incorrect),
+
+ a. Get the next descriptor ring entry through ``old_used_idx``, ``d``
+
+ #. Use ``old_used_wrap_counter`` to calculate the available flags
+
+ #. If ``d.flags`` is not equal to the calculated flags value (means
+ slave has submitted the buffer to guest driver before crash, so
+ it has to commit the in-progres update), set ``old_free_head``,
+ ``old_used_idx``, ``old_used_wrap_counter`` to ``free_head``,
+ ``used_idx``, ``used_wrap_counter``
+
+#. Set ``free_head``, ``used_idx``, ``used_wrap_counter`` to
+ ``old_free_head``, ``old_used_idx``, ``old_used_wrap_counter``
+ (roll back any in-progress update)
+
+#. Set the ``inflight`` field of each ``DescStatePacked`` entry in
+ free list to 0
+
+#. Resubmit inflight ``DescStatePacked`` entries in order of their
+ counter value
+
+Protocol features
+-----------------
+
+.. code:: c
+
+ #define VHOST_USER_PROTOCOL_F_MQ 0
+ #define VHOST_USER_PROTOCOL_F_LOG_SHMFD 1
+ #define VHOST_USER_PROTOCOL_F_RARP 2
+ #define VHOST_USER_PROTOCOL_F_REPLY_ACK 3
+ #define VHOST_USER_PROTOCOL_F_MTU 4
+ #define VHOST_USER_PROTOCOL_F_SLAVE_REQ 5
+ #define VHOST_USER_PROTOCOL_F_CROSS_ENDIAN 6
+ #define VHOST_USER_PROTOCOL_F_CRYPTO_SESSION 7
+ #define VHOST_USER_PROTOCOL_F_PAGEFAULT 8
+ #define VHOST_USER_PROTOCOL_F_CONFIG 9
+ #define VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD 10
+ #define VHOST_USER_PROTOCOL_F_HOST_NOTIFIER 11
+ #define VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD 12
+
+Master message types
+--------------------
+
+``VHOST_USER_GET_FEATURES``
+ :id: 1
+ :equivalent ioctl: ``VHOST_GET_FEATURES``
+ :master payload: N/A
+ :slave payload: ``u64``
+
+ Get from the underlying vhost implementation the features bitmask.
+ Feature bit ``VHOST_USER_F_PROTOCOL_FEATURES`` signals slave support
+ for ``VHOST_USER_GET_PROTOCOL_FEATURES`` and
+ ``VHOST_USER_SET_PROTOCOL_FEATURES``.
+
+``VHOST_USER_SET_FEATURES``
+ :id: 2
+ :equivalent ioctl: ``VHOST_SET_FEATURES``
+ :master payload: ``u64``
+
+ Enable features in the underlying vhost implementation using a
+ bitmask. Feature bit ``VHOST_USER_F_PROTOCOL_FEATURES`` signals
+ slave support for ``VHOST_USER_GET_PROTOCOL_FEATURES`` and
+ ``VHOST_USER_SET_PROTOCOL_FEATURES``.
+
+``VHOST_USER_GET_PROTOCOL_FEATURES``
+ :id: 15
+ :equivalent ioctl: ``VHOST_GET_FEATURES``
+ :master payload: N/A
+ :slave payload: ``u64``
+
+ Get the protocol feature bitmask from the underlying vhost
+ implementation. Only legal if feature bit
+ ``VHOST_USER_F_PROTOCOL_FEATURES`` is present in
+ ``VHOST_USER_GET_FEATURES``.
+
+.. Note::
+ Slave that reported ``VHOST_USER_F_PROTOCOL_FEATURES`` must
+ support this message even before ``VHOST_USER_SET_FEATURES`` was
+ called.
+
+``VHOST_USER_SET_PROTOCOL_FEATURES``
+ :id: 16
+ :equivalent ioctl: ``VHOST_SET_FEATURES``
+ :master payload: ``u64``
+
+ Enable protocol features in the underlying vhost implementation.
+
+ Only legal if feature bit ``VHOST_USER_F_PROTOCOL_FEATURES`` is present in
+ ``VHOST_USER_GET_FEATURES``.
+
+.. Note::
+ Slave that reported ``VHOST_USER_F_PROTOCOL_FEATURES`` must support
+ this message even before ``VHOST_USER_SET_FEATURES`` was called.
+
+``VHOST_USER_SET_OWNER``
+ :id: 3
+ :equivalent ioctl: ``VHOST_SET_OWNER``
+ :master payload: N/A
+
+ Issued when a new connection is established. It sets the current
+ *master* as an owner of the session. This can be used on the *slave*
+ as a "session start" flag.
+
+``VHOST_USER_RESET_OWNER``
+ :id: 4
+ :master payload: N/A
+
+.. admonition:: Deprecated
+
+ This is no longer used. Used to be sent to request disabling all
+ rings, but some clients interpreted it to also discard connection
+ state (this interpretation would lead to bugs). It is recommended
+ that clients either ignore this message, or use it to disable all
+ rings.
+
+``VHOST_USER_SET_MEM_TABLE``
+ :id: 5
+ :equivalent ioctl: ``VHOST_SET_MEM_TABLE``
+ :master payload: memory regions description
+ :slave payload: (postcopy only) memory regions description
+
+ Sets the memory map regions on the slave so it can translate the
+ vring addresses. In the ancillary data there is an array of file
+ descriptors for each memory mapped region. The size and ordering of
+ the fds matches the number and ordering of memory regions.
+
+ When ``VHOST_USER_POSTCOPY_LISTEN`` has been received,
+ ``SET_MEM_TABLE`` replies with the bases of the memory mapped
+ regions to the master. The slave must have mmap'd the regions but
+ not yet accessed them and should not yet generate a userfault
+ event.
+
+.. Note::
+ ``NEED_REPLY_MASK`` is not set in this case. QEMU will then
+ reply back to the list of mappings with an empty
+ ``VHOST_USER_SET_MEM_TABLE`` as an acknowledgement; only upon
+ reception of this message may the guest start accessing the memory
+ and generating faults.
+
+``VHOST_USER_SET_LOG_BASE``
+ :id: 6
+ :equivalent ioctl: ``VHOST_SET_LOG_BASE``
+ :master payload: u64
+ :slave payload: N/A
+
+ Sets logging shared memory space.
+
+ When slave has ``VHOST_USER_PROTOCOL_F_LOG_SHMFD`` protocol feature,
+ the log memory fd is provided in the ancillary data of
+ ``VHOST_USER_SET_LOG_BASE`` message, the size and offset of shared
+ memory area provided in the message.
+
+``VHOST_USER_SET_LOG_FD``
+ :id: 7
+ :equivalent ioctl: ``VHOST_SET_LOG_FD``
+ :master payload: N/A
+
+ Sets the logging file descriptor, which is passed as ancillary data.
+
+``VHOST_USER_SET_VRING_NUM``
+ :id: 8
+ :equivalent ioctl: ``VHOST_SET_VRING_NUM``
+ :master payload: vring state description
+
+ Set the size of the queue.
+
+``VHOST_USER_SET_VRING_ADDR``
+ :id: 9
+ :equivalent ioctl: ``VHOST_SET_VRING_ADDR``
+ :master payload: vring address description
+ :slave payload: N/A
+
+ Sets the addresses of the different aspects of the vring.
+
+``VHOST_USER_SET_VRING_BASE``
+ :id: 10
+ :equivalent ioctl: ``VHOST_SET_VRING_BASE``
+ :master payload: vring state description
+
+ Sets the base offset in the available vring.
+
+``VHOST_USER_GET_VRING_BASE``
+ :id: 11
+ :equivalent ioctl: ``VHOST_USER_GET_VRING_BASE``
+ :master payload: vring state description
+ :slave payload: vring state description
+
+ Get the available vring base offset.
+
+``VHOST_USER_SET_VRING_KICK``
+ :id: 12
+ :equivalent ioctl: ``VHOST_SET_VRING_KICK``
+ :master payload: ``u64``
+
+ Set the event file descriptor for adding buffers to the vring. It is
+ passed in the ancillary data.
+
+ Bits (0-7) of the payload contain the vring index. Bit 8 is the
+ invalid FD flag. This flag is set when there is no file descriptor
+ in the ancillary data. This signals that polling should be used
+ instead of waiting for a kick.
+
+``VHOST_USER_SET_VRING_CALL``
+ :id: 13
+ :equivalent ioctl: ``VHOST_SET_VRING_CALL``
+ :master payload: ``u64``
+
+ Set the event file descriptor to signal when buffers are used. It is
+ passed in the ancillary data.
+
+ Bits (0-7) of the payload contain the vring index. Bit 8 is the
+ invalid FD flag. This flag is set when there is no file descriptor
+ in the ancillary data. This signals that polling will be used
+ instead of waiting for the call.
+
+``VHOST_USER_SET_VRING_ERR``
+ :id: 14
+ :equivalent ioctl: ``VHOST_SET_VRING_ERR``
+ :master payload: ``u64``
+
+ Set the event file descriptor to signal when error occurs. It is
+ passed in the ancillary data.
+
+ Bits (0-7) of the payload contain the vring index. Bit 8 is the
+ invalid FD flag. This flag is set when there is no file descriptor
+ in the ancillary data.
+
+``VHOST_USER_GET_QUEUE_NUM``
+ :id: 17
+ :equivalent ioctl: N/A
+ :master payload: N/A
+ :slave payload: u64
+
+ Query how many queues the backend supports.
+
+ This request should be sent only when ``VHOST_USER_PROTOCOL_F_MQ``
+ is set in queried protocol features by
+ ``VHOST_USER_GET_PROTOCOL_FEATURES``.
+
+``VHOST_USER_SET_VRING_ENABLE``
+ :id: 18
+ :equivalent ioctl: N/A
+ :master payload: vring state description
+
+ Signal slave to enable or disable corresponding vring.
+
+ This request should be sent only when
+ ``VHOST_USER_F_PROTOCOL_FEATURES`` has been negotiated.
+
+``VHOST_USER_SEND_RARP``
+ :id: 19
+ :equivalent ioctl: N/A
+ :master payload: ``u64``
+
+ Ask vhost user backend to broadcast a fake RARP to notify the migration
+ is terminated for guest that does not support GUEST_ANNOUNCE.
+
+ Only legal if feature bit ``VHOST_USER_F_PROTOCOL_FEATURES`` is
+ present in ``VHOST_USER_GET_FEATURES`` and protocol feature bit
+ ``VHOST_USER_PROTOCOL_F_RARP`` is present in
+ ``VHOST_USER_GET_PROTOCOL_FEATURES``. The first 6 bytes of the
+ payload contain the mac address of the guest to allow the vhost user
+ backend to construct and broadcast the fake RARP.
+
+``VHOST_USER_NET_SET_MTU``
+ :id: 20
+ :equivalent ioctl: N/A
+ :master payload: ``u64``
+
+ Set host MTU value exposed to the guest.
+
+ This request should be sent only when ``VIRTIO_NET_F_MTU`` feature
+ has been successfully negotiated, ``VHOST_USER_F_PROTOCOL_FEATURES``
+ is present in ``VHOST_USER_GET_FEATURES`` and protocol feature bit
+ ``VHOST_USER_PROTOCOL_F_NET_MTU`` is present in
+ ``VHOST_USER_GET_PROTOCOL_FEATURES``.
+
+ If ``VHOST_USER_PROTOCOL_F_REPLY_ACK`` is negotiated, slave must
+ respond with zero in case the specified MTU is valid, or non-zero
+ otherwise.
+
+``VHOST_USER_SET_SLAVE_REQ_FD``
+ :id: 21
+ :equivalent ioctl: N/A
+ :master payload: N/A
+
+ Set the socket file descriptor for slave initiated requests. It is passed
+ in the ancillary data.
+
+ This request should be sent only when
+ ``VHOST_USER_F_PROTOCOL_FEATURES`` has been negotiated, and protocol
+ feature bit ``VHOST_USER_PROTOCOL_F_SLAVE_REQ`` bit is present in
+ ``VHOST_USER_GET_PROTOCOL_FEATURES``. If
+ ``VHOST_USER_PROTOCOL_F_REPLY_ACK`` is negotiated, slave must
+ respond with zero for success, non-zero otherwise.
+
+``VHOST_USER_IOTLB_MSG``
+ :id: 22
+ :equivalent ioctl: N/A (equivalent to ``VHOST_IOTLB_MSG`` message type)
+ :master payload: ``struct vhost_iotlb_msg``
+ :slave payload: ``u64``
+
+ Send IOTLB messages with ``struct vhost_iotlb_msg`` as payload.
+
+ Master sends such requests to update and invalidate entries in the
+ device IOTLB. The slave has to acknowledge the request with sending
+ zero as ``u64`` payload for success, non-zero otherwise.
+
+ This request should be send only when ``VIRTIO_F_IOMMU_PLATFORM``
+ feature has been successfully negotiated.
+
+``VHOST_USER_SET_VRING_ENDIAN``
+ :id: 23
+ :equivalent ioctl: ``VHOST_SET_VRING_ENDIAN``
+ :master payload: vring state description
+
+ Set the endianness of a VQ for legacy devices. Little-endian is
+ indicated with state.num set to 0 and big-endian is indicated with
+ state.num set to 1. Other values are invalid.
+
+ This request should be sent only when
+ ``VHOST_USER_PROTOCOL_F_CROSS_ENDIAN`` has been negotiated.
+ Backends that negotiated this feature should handle both
+ endiannesses and expect this message once (per VQ) during device
+ configuration (ie. before the master starts the VQ).
+
+``VHOST_USER_GET_CONFIG``
+ :id: 24
+ :equivalent ioctl: N/A
+ :master payload: virtio device config space
+ :slave payload: virtio device config space
+
+ When ``VHOST_USER_PROTOCOL_F_CONFIG`` is negotiated, this message is
+ submitted by the vhost-user master to fetch the contents of the
+ virtio device configuration space, vhost-user slave's payload size
+ MUST match master's request, vhost-user slave uses zero length of
+ payload to indicate an error to vhost-user master. The vhost-user
+ master may cache the contents to avoid repeated
+ ``VHOST_USER_GET_CONFIG`` calls.
+
+``VHOST_USER_SET_CONFIG``
+ :id: 25
+ :equivalent ioctl: N/A
+ :master payload: virtio device config space
+ :slave payload: N/A
+
+ When ``VHOST_USER_PROTOCOL_F_CONFIG`` is negotiated, this message is
+ submitted by the vhost-user master when the Guest changes the virtio
+ device configuration space and also can be used for live migration
+ on the destination host. The vhost-user slave must check the flags
+ field, and slaves MUST NOT accept SET_CONFIG for read-only
+ configuration space fields unless the live migration bit is set.
+
+``VHOST_USER_CREATE_CRYPTO_SESSION``
+ :id: 26
+ :equivalent ioctl: N/A
+ :master payload: crypto session description
+ :slave payload: crypto session description
+
+ Create a session for crypto operation. The server side must return
+ the session id, 0 or positive for success, negative for failure.
+ This request should be sent only when
+ ``VHOST_USER_PROTOCOL_F_CRYPTO_SESSION`` feature has been
+ successfully negotiated. It's a required feature for crypto
+ devices.
+
+``VHOST_USER_CLOSE_CRYPTO_SESSION``
+ :id: 27
+ :equivalent ioctl: N/A
+ :master payload: ``u64``
+
+ Close a session for crypto operation which was previously
+ created by ``VHOST_USER_CREATE_CRYPTO_SESSION``.
+
+ This request should be sent only when
+ ``VHOST_USER_PROTOCOL_F_CRYPTO_SESSION`` feature has been
+ successfully negotiated. It's a required feature for crypto
+ devices.
+
+``VHOST_USER_POSTCOPY_ADVISE``
+ :id: 28
+ :master payload: N/A
+ :slave payload: userfault fd
+
+ When ``VHOST_USER_PROTOCOL_F_PAGEFAULT`` is supported, the master
+ advises slave that a migration with postcopy enabled is underway,
+ the slave must open a userfaultfd for later use. Note that at this
+ stage the migration is still in precopy mode.
+
+``VHOST_USER_POSTCOPY_LISTEN``
+ :id: 29
+ :master payload: N/A
+
+ Master advises slave that a transition to postcopy mode has
+ happened. The slave must ensure that shared memory is registered
+ with userfaultfd to cause faulting of non-present pages.
+
+ This is always sent sometime after a ``VHOST_USER_POSTCOPY_ADVISE``,
+ and thus only when ``VHOST_USER_PROTOCOL_F_PAGEFAULT`` is supported.
+
+``VHOST_USER_POSTCOPY_END``
+ :id: 30
+ :slave payload: ``u64``
+
+ Master advises that postcopy migration has now completed. The slave
+ must disable the userfaultfd. The response is an acknowledgement
+ only.
+
+ When ``VHOST_USER_PROTOCOL_F_PAGEFAULT`` is supported, this message
+ is sent at the end of the migration, after
+ ``VHOST_USER_POSTCOPY_LISTEN`` was previously sent.
+
+ The value returned is an error indication; 0 is success.
+
+``VHOST_USER_GET_INFLIGHT_FD``
+ :id: 31
+ :equivalent ioctl: N/A
+ :master payload: inflight description
+
+ When ``VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD`` protocol feature has
+ been successfully negotiated, this message is submitted by master to
+ get a shared buffer from slave. The shared buffer will be used to
+ track inflight I/O by slave. QEMU should retrieve a new one when vm
+ reset.
+
+``VHOST_USER_SET_INFLIGHT_FD``
+ :id: 32
+ :equivalent ioctl: N/A
+ :master payload: inflight description
+
+ When ``VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD`` protocol feature has
+ been successfully negotiated, this message is submitted by master to
+ send the shared inflight buffer back to slave so that slave could
+ get inflight I/O after a crash or restart.
+
+Slave message types
+-------------------
+
+``VHOST_USER_SLAVE_IOTLB_MSG``
+ :id: 1
+ :equivalent ioctl: N/A (equivalent to ``VHOST_IOTLB_MSG`` message type)
+ :slave payload: ``struct vhost_iotlb_msg``
+ :master payload: N/A
+
+ Send IOTLB messages with ``struct vhost_iotlb_msg`` as payload.
+ Slave sends such requests to notify of an IOTLB miss, or an IOTLB
+ access failure. If ``VHOST_USER_PROTOCOL_F_REPLY_ACK`` is
+ negotiated, and slave set the ``VHOST_USER_NEED_REPLY`` flag, master
+ must respond with zero when operation is successfully completed, or
+ non-zero otherwise. This request should be send only when
+ ``VIRTIO_F_IOMMU_PLATFORM`` feature has been successfully
+ negotiated.
+
+``VHOST_USER_SLAVE_CONFIG_CHANGE_MSG``
+ :id: 2
+ :equivalent ioctl: N/A
+ :slave payload: N/A
+ :master payload: N/A
+
+ When ``VHOST_USER_PROTOCOL_F_CONFIG`` is negotiated, vhost-user
+ slave sends such messages to notify that the virtio device's
+ configuration space has changed, for those host devices which can
+ support such feature, host driver can send ``VHOST_USER_GET_CONFIG``
+ message to slave to get the latest content. If
+ ``VHOST_USER_PROTOCOL_F_REPLY_ACK`` is negotiated, and slave set the
+ ``VHOST_USER_NEED_REPLY`` flag, master must respond with zero when
+ operation is successfully completed, or non-zero otherwise.
+
+``VHOST_USER_SLAVE_VRING_HOST_NOTIFIER_MSG``
+ :id: 3
+ :equivalent ioctl: N/A
+ :slave payload: vring area description
+ :master payload: N/A
+
+ Sets host notifier for a specified queue. The queue index is
+ contained in the ``u64`` field of the vring area description. The
+ host notifier is described by the file descriptor (typically it's a
+ VFIO device fd) which is passed as ancillary data and the size
+ (which is mmap size and should be the same as host page size) and
+ offset (which is mmap offset) carried in the vring area
+ description. QEMU can mmap the file descriptor based on the size and
+ offset to get a memory range. Registering a host notifier means
+ mapping this memory range to the VM as the specified queue's notify
+ MMIO region. Slave sends this request to tell QEMU to de-register
+ the existing notifier if any and register the new notifier if the
+ request is sent with a file descriptor.
+
+ This request should be sent only when
+ ``VHOST_USER_PROTOCOL_F_HOST_NOTIFIER`` protocol feature has been
+ successfully negotiated.
+
+.. _reply_ack:
+
+VHOST_USER_PROTOCOL_F_REPLY_ACK
+-------------------------------
+
+The original vhost-user specification only demands replies for certain
+commands. This differs from the vhost protocol implementation where
+commands are sent over an ``ioctl()`` call and block until the client
+has completed.
+
+With this protocol extension negotiated, the sender (QEMU) can set the
+``need_reply`` [Bit 3] flag to any command. This indicates that the
+client MUST respond with a Payload ``VhostUserMsg`` indicating success
+or failure. The payload should be set to zero on success or non-zero
+on failure, unless the message already has an explicit reply body.
+
+The response payload gives QEMU a deterministic indication of the result
+of the command. Today, QEMU is expected to terminate the main vhost-user
+loop upon receiving such errors. In future, qemu could be taught to be more
+resilient for selective requests.
+
+For the message types that already solicit a reply from the client,
+the presence of ``VHOST_USER_PROTOCOL_F_REPLY_ACK`` or need_reply bit
+being set brings no behavioural change. (See the Communication_
+section for details.)
+
+.. _backend_conventions:
+
+Backend program conventions
+===========================
+
+vhost-user backends can provide various devices & services and may
+need to be configured manually depending on the use case. However, it
+is a good idea to follow the conventions listed here when
+possible. Users, QEMU or libvirt, can then rely on some common
+behaviour to avoid heterogenous configuration and management of the
+backend programs and facilitate interoperability.
+
+Each backend installed on a host system should come with at least one
+JSON file that conforms to the vhost-user.json schema. Each file
+informs the management applications about the backend type, and binary
+location. In addition, it defines rules for management apps for
+picking the highest priority backend when multiple match the search
+criteria (see ``@VhostUserBackend`` documentation in the schema file).
+
+If the backend is not capable of enabling a requested feature on the
+host (such as 3D acceleration with virgl), or the initialization
+failed, the backend should fail to start early and exit with a status
+!= 0. It may also print a message to stderr for further details.
+
+The backend program must not daemonize itself, but it may be
+daemonized by the management layer. It may also have a restricted
+access to the system.
+
+File descriptors 0, 1 and 2 will exist, and have regular
+stdin/stdout/stderr usage (they may have been redirected to /dev/null
+by the management layer, or to a log handler).
+
+The backend program must end (as quickly and cleanly as possible) when
+the SIGTERM signal is received. Eventually, it may receive SIGKILL by
+the management layer after a few seconds.
+
+The following command line options have an expected behaviour. They
+are mandatory, unless explicitly said differently:
+
+--socket-path=PATH
+
+ This option specify the location of the vhost-user Unix domain socket.
+ It is incompatible with --fd.
+
+--fd=FDNUM
+
+ When this argument is given, the backend program is started with the
+ vhost-user socket as file descriptor FDNUM. It is incompatible with
+ --socket-path.
+
+--print-capabilities
+
+ Output to stdout the backend capabilities in JSON format, and then
+ exit successfully. Other options and arguments should be ignored, and
+ the backend program should not perform its normal function. The
+ capabilities can be reported dynamically depending on the host
+ capabilities.
+
+The JSON output is described in the ``vhost-user.json`` schema, by
+```@VHostUserBackendCapabilities``. Example:
+
+.. code:: json
+
+ {
+ "type": "foo",
+ "features": [
+ "feature-a",
+ "feature-b"
+ ]
+ }
+
+vhost-user-input
+----------------
+
+Command line options:
+
+--evdev-path=PATH
+
+ Specify the linux input device.
+
+ (optional)
+
+--no-grab
+
+ Do no request exclusive access to the input device.
+
+ (optional)
+
+vhost-user-gpu
+--------------
+
+Command line options:
+
+--render-node=PATH
+
+ Specify the GPU DRM render node.
+
+ (optional)
+
+--virgl
+
+ Enable virgl rendering support.
+
+ (optional)
--
MST
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PULL 04/37] virtio: Introduce started flag to VirtioDevice
@ 2019-05-20 23:10 ` Michael S. Tsirkin
0 siblings, 0 replies; 289+ messages in thread
From: Michael S. Tsirkin @ 2019-05-16 12:18 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Xie Yongji, Zhang Yu
From: Xie Yongji <xieyongji@baidu.com>
The virtio 1.0 transitional devices support driver uses the device
before setting the DRIVER_OK status bit. So we introduce a started
flag to indicate whether driver has started the device or not.
Signed-off-by: Xie Yongji <xieyongji@baidu.com>
Signed-off-by: Zhang Yu <zhangyu31@baidu.com>
Message-Id: <20190320112646.3712-2-xieyongji@baidu.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
include/hw/virtio/virtio.h | 2 ++
hw/virtio/virtio.c | 52 ++++++++++++++++++++++++++++++++++++--
2 files changed, 52 insertions(+), 2 deletions(-)
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index ce9516236a..fea08bcc44 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -105,6 +105,8 @@ struct VirtIODevice
uint16_t device_id;
bool vm_running;
bool broken; /* device in invalid state, needs reset */
+ bool started;
+ bool start_on_kick; /* virtio 1.0 transitional devices support that */
VMChangeStateEntry *vmstate;
char *bus_name;
uint8_t device_endian;
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 2626a895cb..af7b59b4ae 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -1162,10 +1162,16 @@ int virtio_set_status(VirtIODevice *vdev, uint8_t val)
}
}
}
+ vdev->started = val & VIRTIO_CONFIG_S_DRIVER_OK;
+ if (unlikely(vdev->start_on_kick && vdev->started)) {
+ vdev->start_on_kick = false;
+ }
+
if (k->set_status) {
k->set_status(vdev, val);
}
vdev->status = val;
+
return 0;
}
@@ -1208,6 +1214,9 @@ void virtio_reset(void *opaque)
k->reset(vdev);
}
+ vdev->start_on_kick = (virtio_host_has_feature(vdev, VIRTIO_F_VERSION_1) &&
+ !virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1));
+ vdev->started = false;
vdev->broken = false;
vdev->guest_features = 0;
vdev->queue_sel = 0;
@@ -1518,14 +1527,21 @@ void virtio_queue_set_align(VirtIODevice *vdev, int n, int align)
static bool virtio_queue_notify_aio_vq(VirtQueue *vq)
{
+ bool ret = false;
+
if (vq->vring.desc && vq->handle_aio_output) {
VirtIODevice *vdev = vq->vdev;
trace_virtio_queue_notify(vdev, vq - vdev->vq, vq);
- return vq->handle_aio_output(vdev, vq);
+ ret = vq->handle_aio_output(vdev, vq);
+
+ if (unlikely(vdev->start_on_kick)) {
+ vdev->started = true;
+ vdev->start_on_kick = false;
+ }
}
- return false;
+ return ret;
}
static void virtio_queue_notify_vq(VirtQueue *vq)
@@ -1539,6 +1555,11 @@ static void virtio_queue_notify_vq(VirtQueue *vq)
trace_virtio_queue_notify(vdev, vq - vdev->vq, vq);
vq->handle_output(vdev, vq);
+
+ if (unlikely(vdev->start_on_kick)) {
+ vdev->started = true;
+ vdev->start_on_kick = false;
+ }
}
}
@@ -1556,6 +1577,11 @@ void virtio_queue_notify(VirtIODevice *vdev, int n)
} else if (vq->handle_output) {
vq->handle_output(vdev, vq);
}
+
+ if (unlikely(vdev->start_on_kick)) {
+ vdev->started = true;
+ vdev->start_on_kick = false;
+ }
}
uint16_t virtio_queue_vector(VirtIODevice *vdev, int n)
@@ -1770,6 +1796,13 @@ static bool virtio_broken_needed(void *opaque)
return vdev->broken;
}
+static bool virtio_started_needed(void *opaque)
+{
+ VirtIODevice *vdev = opaque;
+
+ return vdev->started;
+}
+
static const VMStateDescription vmstate_virtqueue = {
.name = "virtqueue_state",
.version_id = 1,
@@ -1898,6 +1931,17 @@ static const VMStateDescription vmstate_virtio_broken = {
}
};
+static const VMStateDescription vmstate_virtio_started = {
+ .name = "virtio/started",
+ .version_id = 1,
+ .minimum_version_id = 1,
+ .needed = &virtio_started_needed,
+ .fields = (VMStateField[]) {
+ VMSTATE_BOOL(started, VirtIODevice),
+ VMSTATE_END_OF_LIST()
+ }
+};
+
static const VMStateDescription vmstate_virtio = {
.name = "virtio",
.version_id = 1,
@@ -1913,6 +1957,7 @@ static const VMStateDescription vmstate_virtio = {
&vmstate_virtio_ringsize,
&vmstate_virtio_broken,
&vmstate_virtio_extra_state,
+ &vmstate_virtio_started,
NULL
}
};
@@ -2286,6 +2331,9 @@ void virtio_init(VirtIODevice *vdev, const char *name,
g_malloc0(sizeof(*vdev->vector_queues) * nvectors);
}
+ vdev->start_on_kick = (virtio_host_has_feature(vdev, VIRTIO_F_VERSION_1) &&
+ !virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1));
+ vdev->started = false;
vdev->device_id = device_id;
vdev->status = 0;
atomic_set(&vdev->isr, 0);
--
MST
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PULL 05/37] virtio: Use started flag in virtio_vmstate_change()
@ 2019-05-20 23:10 ` Michael S. Tsirkin
0 siblings, 0 replies; 289+ messages in thread
From: Michael S. Tsirkin @ 2019-05-16 12:18 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Xie Yongji, Zhang Yu
From: Xie Yongji <xieyongji@baidu.com>
Currently, we use DRIVER_OK status bit to check whether guest
driver has started the device in virtio_vmstate_change(). But it's
not the case for virtio 1.0 transitional devices. If migration completes
between kicking virtqueue and setting VIRTIO_CONFIG_S_DRIVER_OK, guest
may be hung. So here we use started flag to check guest state instead.
Signed-off-by: Xie Yongji <xieyongji@baidu.com>
Signed-off-by: Zhang Yu <zhangyu31@baidu.com>
Message-Id: <20190320112646.3712-3-xieyongji@baidu.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/virtio/virtio.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index af7b59b4ae..b8d36cd4b7 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -2291,7 +2291,7 @@ static void virtio_vmstate_change(void *opaque, int running, RunState state)
VirtIODevice *vdev = opaque;
BusState *qbus = qdev_get_parent_bus(DEVICE(vdev));
VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
- bool backend_run = running && (vdev->status & VIRTIO_CONFIG_S_DRIVER_OK);
+ bool backend_run = running && vdev->started;
vdev->vm_running = running;
if (backend_run) {
--
MST
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PULL 06/37] vhost-user-blk: Use started flag in vhost_user_blk_set_status()
@ 2019-05-20 23:10 ` Michael S. Tsirkin
0 siblings, 0 replies; 289+ messages in thread
From: Michael S. Tsirkin @ 2019-05-16 12:18 UTC (permalink / raw)
To: qemu-devel
Cc: Kevin Wolf, Peter Maydell, Zhang Yu, qemu-block, Max Reitz, Xie Yongji
From: Xie Yongji <xieyongji@baidu.com>
Use started flag in vhost_user_blk_set_status() to decide if
starting vhost-user backend or not.
Signed-off-by: Xie Yongji <xieyongji@baidu.com>
Signed-off-by: Zhang Yu <zhangyu31@baidu.com>
Message-Id: <20190320112646.3712-4-xieyongji@baidu.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/block/vhost-user-blk.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c
index 28b81368f7..700c1dd111 100644
--- a/hw/block/vhost-user-blk.c
+++ b/hw/block/vhost-user-blk.c
@@ -190,7 +190,7 @@ static void vhost_user_blk_stop(VirtIODevice *vdev)
static void vhost_user_blk_set_status(VirtIODevice *vdev, uint8_t status)
{
VHostUserBlk *s = VHOST_USER_BLK(vdev);
- bool should_start = status & VIRTIO_CONFIG_S_DRIVER_OK;
+ bool should_start = vdev->started;
if (!vdev->vm_running) {
should_start = false;
@@ -350,7 +350,7 @@ static void vhost_user_blk_device_unrealize(DeviceState *dev, Error **errp)
VHostUserBlk *s = VHOST_USER_BLK(dev);
struct vhost_virtqueue *vqs = s->dev.vqs;
- vhost_user_blk_set_status(vdev, 0);
+ virtio_set_status(vdev, 0);
vhost_dev_cleanup(&s->dev);
vhost_dev_free_inflight(s->inflight);
g_free(vqs);
--
MST
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PULL 07/37] vhost-user-blk: Only start vhost-user backend with the first kick
@ 2019-05-20 23:10 ` Michael S. Tsirkin
0 siblings, 0 replies; 289+ messages in thread
From: Michael S. Tsirkin @ 2019-05-16 12:18 UTC (permalink / raw)
To: qemu-devel
Cc: Kevin Wolf, Peter Maydell, Zhang Yu, qemu-block, Max Reitz, Xie Yongji
From: Xie Yongji <xieyongji@baidu.com>
We should only start vhost-user backend at the first kick for
virtio 1.0 transitional devices.
Signed-off-by: Xie Yongji <xieyongji@baidu.com>
Signed-off-by: Zhang Yu <zhangyu31@baidu.com>
Message-Id: <20190320112646.3712-5-xieyongji@baidu.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/block/vhost-user-blk.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c
index 700c1dd111..39e1adc60a 100644
--- a/hw/block/vhost-user-blk.c
+++ b/hw/block/vhost-user-blk.c
@@ -239,8 +239,7 @@ static void vhost_user_blk_handle_output(VirtIODevice *vdev, VirtQueue *vq)
VHostUserBlk *s = VHOST_USER_BLK(vdev);
int i;
- if (!(virtio_host_has_feature(vdev, VIRTIO_F_VERSION_1) &&
- !virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1))) {
+ if (!vdev->start_on_kick) {
return;
}
--
MST
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PULL 08/37] vhost-user-blk: Add return value for vhost_user_blk_start()
@ 2019-05-20 23:10 ` Michael S. Tsirkin
0 siblings, 0 replies; 289+ messages in thread
From: Michael S. Tsirkin @ 2019-05-16 12:18 UTC (permalink / raw)
To: qemu-devel
Cc: Kevin Wolf, Peter Maydell, Zhang Yu, qemu-block, Max Reitz, Xie Yongji
From: Xie Yongji <xieyongji@baidu.com>
Add a return value for vhost_user_blk_start() to check whether
we start vhost-user backend successfully or not.
Signed-off-by: Xie Yongji <xieyongji@baidu.com>
Signed-off-by: Zhang Yu <zhangyu31@baidu.com>
Message-Id: <20190320112646.3712-6-xieyongji@baidu.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/block/vhost-user-blk.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c
index 39e1adc60a..6802c19d65 100644
--- a/hw/block/vhost-user-blk.c
+++ b/hw/block/vhost-user-blk.c
@@ -103,7 +103,7 @@ const VhostDevConfigOps blk_ops = {
.vhost_dev_config_notifier = vhost_user_blk_handle_config_change,
};
-static void vhost_user_blk_start(VirtIODevice *vdev)
+static int vhost_user_blk_start(VirtIODevice *vdev)
{
VHostUserBlk *s = VHOST_USER_BLK(vdev);
BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev)));
@@ -112,13 +112,13 @@ static void vhost_user_blk_start(VirtIODevice *vdev)
if (!k->set_guest_notifiers) {
error_report("binding does not support guest notifiers");
- return;
+ return -ENOSYS;
}
ret = vhost_dev_enable_notifiers(&s->dev, vdev);
if (ret < 0) {
error_report("Error enabling host notifiers: %d", -ret);
- return;
+ return ret;
}
ret = k->set_guest_notifiers(qbus->parent, s->dev.nvqs, true);
@@ -157,12 +157,13 @@ static void vhost_user_blk_start(VirtIODevice *vdev)
vhost_virtqueue_mask(&s->dev, vdev, i, false);
}
- return;
+ return ret;
err_guest_notifiers:
k->set_guest_notifiers(qbus->parent, s->dev.nvqs, false);
err_host_notifiers:
vhost_dev_disable_notifiers(&s->dev, vdev);
+ return ret;
}
static void vhost_user_blk_stop(VirtIODevice *vdev)
--
MST
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PULL 09/37] vhost-user-blk: Add support to reconnect backend
@ 2019-05-20 23:10 ` Michael S. Tsirkin
0 siblings, 0 replies; 289+ messages in thread
From: Michael S. Tsirkin @ 2019-05-16 12:18 UTC (permalink / raw)
To: qemu-devel
Cc: Kevin Wolf, Peter Maydell, Xie Yongji, qemu-block, Max Reitz,
Zhang Yu, Ni Xun
From: Xie Yongji <xieyongji@baidu.com>
Since we now support the message VHOST_USER_GET_INFLIGHT_FD
and VHOST_USER_SET_INFLIGHT_FD. The backend is able to restart
safely because it can track inflight I/O in shared memory.
This patch allows qemu to reconnect the backend after
connection closed.
Signed-off-by: Xie Yongji <xieyongji@baidu.com>
Signed-off-by: Ni Xun <nixun@baidu.com>
Signed-off-by: Zhang Yu <zhangyu31@baidu.com>
Message-Id: <20190320112646.3712-7-xieyongji@baidu.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
include/hw/virtio/vhost-user-blk.h | 3 +
hw/block/vhost-user-blk.c | 159 ++++++++++++++++++++++++-----
2 files changed, 139 insertions(+), 23 deletions(-)
diff --git a/include/hw/virtio/vhost-user-blk.h b/include/hw/virtio/vhost-user-blk.h
index 68634bee61..51457fb857 100644
--- a/include/hw/virtio/vhost-user-blk.h
+++ b/include/hw/virtio/vhost-user-blk.h
@@ -38,6 +38,9 @@ typedef struct VHostUserBlk {
struct vhost_dev dev;
struct vhost_inflight *inflight;
VhostUserState vhost_user;
+ struct vhost_virtqueue *vqs;
+ guint watch;
+ bool connected;
} VHostUserBlk;
#endif
diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c
index 6802c19d65..9cb61336a6 100644
--- a/hw/block/vhost-user-blk.c
+++ b/hw/block/vhost-user-blk.c
@@ -192,17 +192,27 @@ static void vhost_user_blk_set_status(VirtIODevice *vdev, uint8_t status)
{
VHostUserBlk *s = VHOST_USER_BLK(vdev);
bool should_start = vdev->started;
+ int ret;
if (!vdev->vm_running) {
should_start = false;
}
+ if (!s->connected) {
+ return;
+ }
+
if (s->dev.started == should_start) {
return;
}
if (should_start) {
- vhost_user_blk_start(vdev);
+ ret = vhost_user_blk_start(vdev);
+ if (ret < 0) {
+ error_report("vhost-user-blk: vhost start failed: %s",
+ strerror(-ret));
+ qemu_chr_fe_disconnect(&s->chardev);
+ }
} else {
vhost_user_blk_stop(vdev);
}
@@ -238,12 +248,16 @@ static uint64_t vhost_user_blk_get_features(VirtIODevice *vdev,
static void vhost_user_blk_handle_output(VirtIODevice *vdev, VirtQueue *vq)
{
VHostUserBlk *s = VHOST_USER_BLK(vdev);
- int i;
+ int i, ret;
if (!vdev->start_on_kick) {
return;
}
+ if (!s->connected) {
+ return;
+ }
+
if (s->dev.started) {
return;
}
@@ -251,7 +265,13 @@ static void vhost_user_blk_handle_output(VirtIODevice *vdev, VirtQueue *vq)
/* Some guests kick before setting VIRTIO_CONFIG_S_DRIVER_OK so start
* vhost here instead of waiting for .set_status().
*/
- vhost_user_blk_start(vdev);
+ ret = vhost_user_blk_start(vdev);
+ if (ret < 0) {
+ error_report("vhost-user-blk: vhost start failed: %s",
+ strerror(-ret));
+ qemu_chr_fe_disconnect(&s->chardev);
+ return;
+ }
/* Kick right away to begin processing requests already in vring */
for (i = 0; i < s->dev.nvqs; i++) {
@@ -271,11 +291,103 @@ static void vhost_user_blk_reset(VirtIODevice *vdev)
vhost_dev_free_inflight(s->inflight);
}
+static int vhost_user_blk_connect(DeviceState *dev)
+{
+ VirtIODevice *vdev = VIRTIO_DEVICE(dev);
+ VHostUserBlk *s = VHOST_USER_BLK(vdev);
+ int ret = 0;
+
+ if (s->connected) {
+ return 0;
+ }
+ s->connected = true;
+
+ s->dev.nvqs = s->num_queues;
+ s->dev.vqs = s->vqs;
+ s->dev.vq_index = 0;
+ s->dev.backend_features = 0;
+
+ vhost_dev_set_config_notifier(&s->dev, &blk_ops);
+
+ ret = vhost_dev_init(&s->dev, &s->vhost_user, VHOST_BACKEND_TYPE_USER, 0);
+ if (ret < 0) {
+ error_report("vhost-user-blk: vhost initialization failed: %s",
+ strerror(-ret));
+ return ret;
+ }
+
+ /* restore vhost state */
+ if (vdev->started) {
+ ret = vhost_user_blk_start(vdev);
+ if (ret < 0) {
+ error_report("vhost-user-blk: vhost start failed: %s",
+ strerror(-ret));
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
+static void vhost_user_blk_disconnect(DeviceState *dev)
+{
+ VirtIODevice *vdev = VIRTIO_DEVICE(dev);
+ VHostUserBlk *s = VHOST_USER_BLK(vdev);
+
+ if (!s->connected) {
+ return;
+ }
+ s->connected = false;
+
+ if (s->dev.started) {
+ vhost_user_blk_stop(vdev);
+ }
+
+ vhost_dev_cleanup(&s->dev);
+}
+
+static gboolean vhost_user_blk_watch(GIOChannel *chan, GIOCondition cond,
+ void *opaque)
+{
+ DeviceState *dev = opaque;
+ VirtIODevice *vdev = VIRTIO_DEVICE(dev);
+ VHostUserBlk *s = VHOST_USER_BLK(vdev);
+
+ qemu_chr_fe_disconnect(&s->chardev);
+
+ return true;
+}
+
+static void vhost_user_blk_event(void *opaque, int event)
+{
+ DeviceState *dev = opaque;
+ VirtIODevice *vdev = VIRTIO_DEVICE(dev);
+ VHostUserBlk *s = VHOST_USER_BLK(vdev);
+
+ switch (event) {
+ case CHR_EVENT_OPENED:
+ if (vhost_user_blk_connect(dev) < 0) {
+ qemu_chr_fe_disconnect(&s->chardev);
+ return;
+ }
+ s->watch = qemu_chr_fe_add_watch(&s->chardev, G_IO_HUP,
+ vhost_user_blk_watch, dev);
+ break;
+ case CHR_EVENT_CLOSED:
+ vhost_user_blk_disconnect(dev);
+ if (s->watch) {
+ g_source_remove(s->watch);
+ s->watch = 0;
+ }
+ break;
+ }
+}
+
static void vhost_user_blk_device_realize(DeviceState *dev, Error **errp)
{
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
VHostUserBlk *s = VHOST_USER_BLK(vdev);
- struct vhost_virtqueue *vqs = NULL;
+ Error *err = NULL;
int i, ret;
if (!s->chardev.chr) {
@@ -306,27 +418,29 @@ static void vhost_user_blk_device_realize(DeviceState *dev, Error **errp)
}
s->inflight = g_new0(struct vhost_inflight, 1);
+ s->vqs = g_new(struct vhost_virtqueue, s->num_queues);
+ s->watch = 0;
+ s->connected = false;
- s->dev.nvqs = s->num_queues;
- s->dev.vqs = g_new(struct vhost_virtqueue, s->dev.nvqs);
- s->dev.vq_index = 0;
- s->dev.backend_features = 0;
- vqs = s->dev.vqs;
+ qemu_chr_fe_set_handlers(&s->chardev, NULL, NULL, vhost_user_blk_event,
+ NULL, (void *)dev, NULL, true);
- vhost_dev_set_config_notifier(&s->dev, &blk_ops);
-
- ret = vhost_dev_init(&s->dev, &s->vhost_user, VHOST_BACKEND_TYPE_USER, 0);
- if (ret < 0) {
- error_setg(errp, "vhost-user-blk: vhost initialization failed: %s",
- strerror(-ret));
+reconnect:
+ if (qemu_chr_fe_wait_connected(&s->chardev, &err) < 0) {
+ error_report_err(err);
goto virtio_err;
}
+ /* check whether vhost_user_blk_connect() failed or not */
+ if (!s->connected) {
+ goto reconnect;
+ }
+
ret = vhost_dev_get_config(&s->dev, (uint8_t *)&s->blkcfg,
- sizeof(struct virtio_blk_config));
+ sizeof(struct virtio_blk_config));
if (ret < 0) {
- error_setg(errp, "vhost-user-blk: get block config failed");
- goto vhost_err;
+ error_report("vhost-user-blk: get block config failed");
+ goto reconnect;
}
if (s->blkcfg.num_queues != s->num_queues) {
@@ -335,10 +449,8 @@ static void vhost_user_blk_device_realize(DeviceState *dev, Error **errp)
return;
-vhost_err:
- vhost_dev_cleanup(&s->dev);
virtio_err:
- g_free(vqs);
+ g_free(s->vqs);
g_free(s->inflight);
virtio_cleanup(vdev);
vhost_user_cleanup(&s->vhost_user);
@@ -348,12 +460,13 @@ static void vhost_user_blk_device_unrealize(DeviceState *dev, Error **errp)
{
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
VHostUserBlk *s = VHOST_USER_BLK(dev);
- struct vhost_virtqueue *vqs = s->dev.vqs;
virtio_set_status(vdev, 0);
+ qemu_chr_fe_set_handlers(&s->chardev, NULL, NULL, NULL,
+ NULL, NULL, NULL, false);
vhost_dev_cleanup(&s->dev);
vhost_dev_free_inflight(s->inflight);
- g_free(vqs);
+ g_free(s->vqs);
g_free(s->inflight);
virtio_cleanup(vdev);
vhost_user_cleanup(&s->vhost_user);
--
MST
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PULL 10/37] contrib/vhost-user-blk: enable inflight I/O tracking
@ 2019-05-20 23:10 ` Michael S. Tsirkin
0 siblings, 0 replies; 289+ messages in thread
From: Michael S. Tsirkin @ 2019-05-16 12:18 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Xie Yongji, Zhang Yu
From: Xie Yongji <xieyongji@baidu.com>
This patch enables inflight I/O tracking for
vhost-user-blk backend so that we could restart it safely.
Signed-off-by: Xie Yongji <xieyongji@baidu.com>
Signed-off-by: Zhang Yu <zhangyu31@baidu.com>
Message-Id: <20190320112646.3712-8-xieyongji@baidu.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
contrib/vhost-user-blk/vhost-user-blk.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/contrib/vhost-user-blk/vhost-user-blk.c b/contrib/vhost-user-blk/vhost-user-blk.c
index 43583f2659..86a3987744 100644
--- a/contrib/vhost-user-blk/vhost-user-blk.c
+++ b/contrib/vhost-user-blk/vhost-user-blk.c
@@ -398,7 +398,8 @@ vub_get_features(VuDev *dev)
static uint64_t
vub_get_protocol_features(VuDev *dev)
{
- return 1ull << VHOST_USER_PROTOCOL_F_CONFIG;
+ return 1ull << VHOST_USER_PROTOCOL_F_CONFIG |
+ 1ull << VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD;
}
static int
--
MST
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PULL 11/37] acpi/piix4: Convert debug printf()s to trace events
@ 2019-05-16 12:19 ` Michael S. Tsirkin
0 siblings, 0 replies; 289+ messages in thread
From: Michael S. Tsirkin @ 2019-05-16 12:19 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Philippe Mathieu-Daudé,
Markus Armbruster, Igor Mammedov
From: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20190402161900.7374-2-armbru@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
hw/acpi/piix4.c | 14 +++-----------
hw/acpi/trace-events | 4 ++++
2 files changed, 7 insertions(+), 11 deletions(-)
diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
index 9c079d6834..546ba036ed 100644
--- a/hw/acpi/piix4.c
+++ b/hw/acpi/piix4.c
@@ -39,14 +39,7 @@
#include "hw/acpi/acpi_dev_interface.h"
#include "hw/xen/xen.h"
#include "qom/cpu.h"
-
-//#define DEBUG
-
-#ifdef DEBUG
-# define PIIX4_DPRINTF(format, ...) printf(format, ## __VA_ARGS__)
-#else
-# define PIIX4_DPRINTF(format, ...) do { } while (0)
-#endif
+#include "trace.h"
#define GPE_BASE 0xafe0
#define GPE_LEN 4
@@ -596,7 +589,7 @@ static uint64_t gpe_readb(void *opaque, hwaddr addr, unsigned width)
PIIX4PMState *s = opaque;
uint32_t val = acpi_gpe_ioport_readb(&s->ar, addr);
- PIIX4_DPRINTF("gpe read %" HWADDR_PRIx " == %" PRIu32 "\n", addr, val);
+ trace_piix4_gpe_readb(addr, width, val);
return val;
}
@@ -605,10 +598,9 @@ static void gpe_writeb(void *opaque, hwaddr addr, uint64_t val,
{
PIIX4PMState *s = opaque;
+ trace_piix4_gpe_writeb(addr, width, val);
acpi_gpe_ioport_writeb(&s->ar, addr, val);
acpi_update_sci(&s->ar, s->irq);
-
- PIIX4_DPRINTF("gpe write %" HWADDR_PRIx " <== %" PRIu64 "\n", addr, val);
}
static const MemoryRegionOps piix4_gpe_ops = {
diff --git a/hw/acpi/trace-events b/hw/acpi/trace-events
index 6272d8a9e7..825b25cbb0 100644
--- a/hw/acpi/trace-events
+++ b/hw/acpi/trace-events
@@ -31,6 +31,10 @@ cpuhp_acpi_ejecting_cpu(uint32_t idx) "0x%"PRIx32
cpuhp_acpi_write_ost_ev(uint32_t slot, uint32_t ev) "idx[0x%"PRIx32"] OST EVENT: 0x%"PRIx32
cpuhp_acpi_write_ost_status(uint32_t slot, uint32_t st) "idx[0x%"PRIx32"] OST STATUS: 0x%"PRIx32
+# piix4.c
+piix4_gpe_readb(uint64_t addr, unsigned width, uint64_t val) "addr: 0x%" PRIx64 " width: %d ==> 0x%" PRIx64
+piix4_gpe_writeb(uint64_t addr, unsigned width, uint64_t val) "addr: 0x%" PRIx64 " width: %d <== 0x%" PRIx64
+
# tco.c
tco_timer_reload(int ticks, int msec) "ticks=%d (%d ms)"
tco_timer_expired(int timeouts_no, bool strap, bool no_reboot) "timeouts_no=%d no_reboot=%d/%d"
--
MST
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PULL 12/37] acpi/pcihp: Convert debug printf()s to trace events
@ 2019-05-16 12:19 ` Michael S. Tsirkin
0 siblings, 0 replies; 289+ messages in thread
From: Michael S. Tsirkin @ 2019-05-16 12:19 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Philippe Mathieu-Daudé,
Markus Armbruster, Igor Mammedov
From: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20190402161900.7374-3-armbru@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
hw/acpi/pcihp.c | 25 ++++++++-----------------
hw/acpi/trace-events | 9 +++++++++
2 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
index 88e4ae1bcd..7729c5338b 100644
--- a/hw/acpi/pcihp.c
+++ b/hw/acpi/pcihp.c
@@ -37,14 +37,7 @@
#include "hw/pci/pci_bus.h"
#include "qapi/error.h"
#include "qom/qom-qobject.h"
-
-//#define DEBUG
-
-#ifdef DEBUG
-# define ACPI_PCIHP_DPRINTF(format, ...) printf(format, ## __VA_ARGS__)
-#else
-# define ACPI_PCIHP_DPRINTF(format, ...) do { } while (0)
-#endif
+#include "trace.h"
#define ACPI_PCIHP_ADDR 0xae00
#define ACPI_PCIHP_SIZE 0x0014
@@ -306,23 +299,23 @@ static uint64_t pci_read(void *opaque, hwaddr addr, unsigned int size)
if (!s->legacy_piix) {
s->acpi_pcihp_pci_status[bsel].up = 0;
}
- ACPI_PCIHP_DPRINTF("pci_up_read %" PRIu32 "\n", val);
+ trace_acpi_pci_up_read(val);
break;
case PCI_DOWN_BASE:
val = s->acpi_pcihp_pci_status[bsel].down;
- ACPI_PCIHP_DPRINTF("pci_down_read %" PRIu32 "\n", val);
+ trace_acpi_pci_down_read(val);
break;
case PCI_EJ_BASE:
/* No feature defined yet */
- ACPI_PCIHP_DPRINTF("pci_features_read %" PRIu32 "\n", val);
+ trace_acpi_pci_features_read(val);
break;
case PCI_RMV_BASE:
val = s->acpi_pcihp_pci_status[bsel].hotplug_enable;
- ACPI_PCIHP_DPRINTF("pci_rmv_read %" PRIu32 "\n", val);
+ trace_acpi_pci_rmv_read(val);
break;
case PCI_SEL_BASE:
val = s->hotplug_select;
- ACPI_PCIHP_DPRINTF("pci_sel_read %" PRIu32 "\n", val);
+ trace_acpi_pci_sel_read(val);
default:
break;
}
@@ -340,13 +333,11 @@ static void pci_write(void *opaque, hwaddr addr, uint64_t data,
break;
}
acpi_pcihp_eject_slot(s, s->hotplug_select, data);
- ACPI_PCIHP_DPRINTF("pciej write %" HWADDR_PRIx " <== %" PRIu64 "\n",
- addr, data);
+ trace_acpi_pci_ej_write(addr, data);
break;
case PCI_SEL_BASE:
s->hotplug_select = s->legacy_piix ? ACPI_PCIHP_BSEL_DEFAULT : data;
- ACPI_PCIHP_DPRINTF("pcisel write %" HWADDR_PRIx " <== %" PRIu64 "\n",
- addr, data);
+ trace_acpi_pci_sel_write(addr, data);
default:
break;
}
diff --git a/hw/acpi/trace-events b/hw/acpi/trace-events
index 825b25cbb0..98a56baa6f 100644
--- a/hw/acpi/trace-events
+++ b/hw/acpi/trace-events
@@ -31,6 +31,15 @@ cpuhp_acpi_ejecting_cpu(uint32_t idx) "0x%"PRIx32
cpuhp_acpi_write_ost_ev(uint32_t slot, uint32_t ev) "idx[0x%"PRIx32"] OST EVENT: 0x%"PRIx32
cpuhp_acpi_write_ost_status(uint32_t slot, uint32_t st) "idx[0x%"PRIx32"] OST STATUS: 0x%"PRIx32
+# pcihp.c
+acpi_pci_up_read(uint32_t val) "%" PRIu32
+acpi_pci_down_read(uint32_t val) "%" PRIu32
+acpi_pci_features_read(uint32_t val) "%" PRIu32
+acpi_pci_rmv_read(uint32_t val) "%" PRIu32
+acpi_pci_sel_read(uint32_t val) "%" PRIu32
+acpi_pci_ej_write(uint64_t addr, uint64_t data) "0x%" PRIx64 " <== %" PRIu64
+acpi_pci_sel_write(uint64_t addr, uint64_t data) "0x%" PRIx64 " <== %" PRIu64
+
# piix4.c
piix4_gpe_readb(uint64_t addr, unsigned width, uint64_t val) "addr: 0x%" PRIx64 " width: %d ==> 0x%" PRIx64
piix4_gpe_writeb(uint64_t addr, unsigned width, uint64_t val) "addr: 0x%" PRIx64 " width: %d <== 0x%" PRIx64
--
MST
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PULL 13/37] acpi/pcihp: Add a few more trace points related to unplug
@ 2019-05-16 12:19 ` Michael S. Tsirkin
0 siblings, 0 replies; 289+ messages in thread
From: Michael S. Tsirkin @ 2019-05-16 12:19 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Philippe Mathieu-Daudé,
Markus Armbruster, Igor Mammedov
From: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20190402161900.7374-4-armbru@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
hw/acpi/pcihp.c | 7 +++++++
hw/acpi/trace-events | 3 +++
2 files changed, 10 insertions(+)
diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
index 7729c5338b..613406d09b 100644
--- a/hw/acpi/pcihp.c
+++ b/hw/acpi/pcihp.c
@@ -152,6 +152,8 @@ static void acpi_pcihp_eject_slot(AcpiPciHpState *s, unsigned bsel, unsigned slo
int slot = ctz32(slots);
PCIBus *bus = acpi_pcihp_find_hotplug_bus(s, bsel);
+ trace_acpi_pci_eject_slot(bsel, slot);
+
if (!bus) {
return;
}
@@ -263,6 +265,8 @@ void acpi_pcihp_device_plug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState *s,
void acpi_pcihp_device_unplug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState *s,
DeviceState *dev, Error **errp)
{
+ trace_acpi_pci_unplug(PCI_SLOT(PCI_DEVICE(dev)->devfn),
+ acpi_pcihp_get_bsel(pci_get_bus(PCI_DEVICE(dev))));
object_property_set_bool(OBJECT(dev), false, "realized", NULL);
}
@@ -273,6 +277,9 @@ void acpi_pcihp_device_unplug_request_cb(HotplugHandler *hotplug_dev,
PCIDevice *pdev = PCI_DEVICE(dev);
int slot = PCI_SLOT(pdev->devfn);
int bsel = acpi_pcihp_get_bsel(pci_get_bus(pdev));
+
+ trace_acpi_pci_unplug_request(bsel, slot);
+
if (bsel < 0) {
error_setg(errp, "Unsupported bus. Bus doesn't have property '"
ACPI_PCIHP_PROP_BSEL "' set");
diff --git a/hw/acpi/trace-events b/hw/acpi/trace-events
index 98a56baa6f..96b8273297 100644
--- a/hw/acpi/trace-events
+++ b/hw/acpi/trace-events
@@ -32,6 +32,9 @@ cpuhp_acpi_write_ost_ev(uint32_t slot, uint32_t ev) "idx[0x%"PRIx32"] OST EVENT:
cpuhp_acpi_write_ost_status(uint32_t slot, uint32_t st) "idx[0x%"PRIx32"] OST STATUS: 0x%"PRIx32
# pcihp.c
+acpi_pci_eject_slot(unsigned bsel, unsigned slot) "bsel: %u slot: %u"
+acpi_pci_unplug(int bsel, int slot) "bsel: %d slot: %d"
+acpi_pci_unplug_request(int bsel, int slot) "bsel: %d slot: %d"
acpi_pci_up_read(uint32_t val) "%" PRIu32
acpi_pci_down_read(uint32_t val) "%" PRIu32
acpi_pci_features_read(uint32_t val) "%" PRIu32
--
MST
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PULL 14/37] q35: acpi: do not create dummy MCFG table
@ 2019-04-09 15:00 ` Igor Mammedov
0 siblings, 0 replies; 289+ messages in thread
From: Michael S. Tsirkin @ 2019-05-16 12:19 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Eduardo Habkost, Wei Yang, Igor Mammedov,
Paolo Bonzini, Richard Henderson
From: Igor Mammedov <imammedo@redhat.com>
Dummy table (with signature "QEMU") creation came from original SeaBIOS
codebase. And QEMU would have to keep it around if there were Q35 machine
that depended on keeping ACPI tables blob constant size. Luckily there
were no versioned Q35 machine types before commit:
(since 2.3) a1666142db acpi-build: make ROMs RAM blocks resizeable
which obsoleted need to keep ACPI tables blob the same size on source/destination.
Considering the 1st versioned machine is pc-q35-2.4, the dummy table
is not really necessary and it's safe to drop it without breaking
cross version migration in both directions unconditionally.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Message-Id: <1554822037-329838-1-git-send-email-imammedo@redhat.com>
Reviewed-by: Wei Yang <richardw.yang@linux.intel.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/i386/acpi-build.c | 18 ++++--------------
1 file changed, 4 insertions(+), 14 deletions(-)
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 416da318ae..8671e25af4 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -2401,7 +2401,6 @@ static void
build_mcfg_q35(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
{
AcpiTableMcfg *mcfg;
- const char *sig;
int len = sizeof(*mcfg) + 1 * sizeof(mcfg->allocation[0]);
mcfg = acpi_data_push(table_data, len);
@@ -2411,19 +2410,7 @@ build_mcfg_q35(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
mcfg->allocation[0].start_bus_number = 0;
mcfg->allocation[0].end_bus_number = PCIE_MMCFG_BUS(info->mcfg_size - 1);
- /* MCFG is used for ECAM which can be enabled or disabled by guest.
- * To avoid table size changes (which create migration issues),
- * always create the table even if there are no allocations,
- * but set the signature to a reserved value in this case.
- * ACPI spec requires OSPMs to ignore such tables.
- */
- if (info->mcfg_base == PCIE_BASE_ADDR_UNMAPPED) {
- /* Reserved signature: ignored by OSPM */
- sig = "QEMU";
- } else {
- sig = "MCFG";
- }
- build_header(linker, table_data, (void *)mcfg, sig, len, 1, NULL, NULL);
+ build_header(linker, table_data, (void *)mcfg, "MCFG", len, 1, NULL, NULL);
}
/*
@@ -2592,6 +2579,9 @@ static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg)
}
mcfg->mcfg_base = qnum_get_uint(qobject_to(QNum, o));
qobject_unref(o);
+ if (mcfg->mcfg_base == PCIE_BASE_ADDR_UNMAPPED) {
+ return false;
+ }
o = object_property_get_qobject(pci_host, PCIE_HOST_MCFG_SIZE, NULL);
assert(o);
--
MST
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PULL 15/37] do not call vhost_net_cleanup() on running net from char user event
@ 2019-05-16 12:19 ` Michael S. Tsirkin
0 siblings, 0 replies; 289+ messages in thread
From: Michael S. Tsirkin @ 2019-05-16 12:19 UTC (permalink / raw)
To: qemu-devel; +Cc: Dan Streetman, Peter Maydell, Jason Wang
From: Dan Streetman <ddstreet@canonical.com>
Buglink: https://launchpad.net/bugs/1823458
Currently, a user CHR_EVENT_CLOSED event will cause net_vhost_user_event()
to call vhost_user_cleanup(), which calls vhost_net_cleanup() for all
its queues. However, vhost_net_cleanup() must never be called like
this for fully-initialized nets; when other code later calls
vhost_net_stop() - such as from virtio_net_vhost_status() - it will try
to access the already-cleaned-up fields and fail with assertion errors
or segfaults.
The vhost_net_cleanup() will eventually be called from
qemu_cleanup_net_client().
Signed-off-by: Dan Streetman <ddstreet@canonical.com>
Message-Id: <20190416184624.15397-3-dan.streetman@canonical.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
net/vhost-user.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/net/vhost-user.c b/net/vhost-user.c
index 5a26a24708..51921de443 100644
--- a/net/vhost-user.c
+++ b/net/vhost-user.c
@@ -236,7 +236,6 @@ static void chr_closed_bh(void *opaque)
s = DO_UPCAST(NetVhostUserState, nc, ncs[0]);
qmp_set_link(name, false, &err);
- vhost_user_stop(queues, ncs);
qemu_chr_fe_set_handlers(&s->chr, NULL, NULL, net_vhost_user_event,
NULL, opaque, NULL, true);
--
MST
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PULL 16/37] hw/arm/virt-acpi-build: remove unnecessary variable mcfg_start
@ 2019-04-19 0:30 ` Wei Yang
0 siblings, 0 replies; 289+ messages in thread
From: Michael S. Tsirkin @ 2019-05-16 12:19 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Shannon Zhao, qemu-arm, Wei Yang, Igor Mammedov,
Philippe Mathieu-Daudé
From: Wei Yang <richardw.yang@linux.intel.com>
mcfg_start points to the start of MCFG table and is used in
build_header. While this information could be derived from mcfg.
This patch removes the unnecessary variable mcfg_start.
Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20190419003053.8260-3-richardw.yang@linux.intel.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/arm/virt-acpi-build.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index bf9c0bc2f4..12dbaf3846 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -552,7 +552,6 @@ build_mcfg(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
const MemMapEntry *memmap = vms->memmap;
int ecam_id = VIRT_ECAM_ID(vms->highmem_ecam);
int len = sizeof(*mcfg) + sizeof(mcfg->allocation[0]);
- int mcfg_start = table_data->len;
mcfg = acpi_data_push(table_data, len);
mcfg->allocation[0].address = cpu_to_le64(memmap[ecam_id].base);
@@ -563,8 +562,7 @@ build_mcfg(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
mcfg->allocation[0].end_bus_number =
PCIE_MMCFG_BUS(memmap[ecam_id].size - 1);
- build_header(linker, table_data, (void *)(table_data->data + mcfg_start),
- "MCFG", table_data->len - mcfg_start, 1, NULL, NULL);
+ build_header(linker, table_data, (void *)mcfg, "MCFG", len, 1, NULL, NULL);
}
/* GTDT */
--
MST
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PULL 17/37] i386, acpi: remove mcfg_ prefix in AcpiMcfgInfo members
@ 2019-04-19 0:30 ` Wei Yang
0 siblings, 0 replies; 289+ messages in thread
From: Michael S. Tsirkin @ 2019-05-16 12:19 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Eduardo Habkost, Wei Yang, Igor Mammedov,
Paolo Bonzini, Philippe Mathieu-Daudé,
Richard Henderson
From: Wei Yang <richardw.yang@linux.intel.com>
This is obvious the member in AcpiMcfgInfo describe MCFG's property.
Remove the mcfg_ prefix.
Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
Suggested-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20190419003053.8260-4-richardw.yang@linux.intel.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/i386/acpi-build.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 8671e25af4..6df7bb3abc 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -87,8 +87,8 @@
#define ACPI_BUILD_IOAPIC_ID 0x0
typedef struct AcpiMcfgInfo {
- uint64_t mcfg_base;
- uint32_t mcfg_size;
+ uint64_t base;
+ uint32_t size;
} AcpiMcfgInfo;
typedef struct AcpiPmInfo {
@@ -2404,11 +2404,11 @@ build_mcfg_q35(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
int len = sizeof(*mcfg) + 1 * sizeof(mcfg->allocation[0]);
mcfg = acpi_data_push(table_data, len);
- mcfg->allocation[0].address = cpu_to_le64(info->mcfg_base);
+ mcfg->allocation[0].address = cpu_to_le64(info->base);
/* Only a single allocation so no need to play with segments */
mcfg->allocation[0].pci_segment = cpu_to_le16(0);
mcfg->allocation[0].start_bus_number = 0;
- mcfg->allocation[0].end_bus_number = PCIE_MMCFG_BUS(info->mcfg_size - 1);
+ mcfg->allocation[0].end_bus_number = PCIE_MMCFG_BUS(info->size - 1);
build_header(linker, table_data, (void *)mcfg, "MCFG", len, 1, NULL, NULL);
}
@@ -2577,15 +2577,15 @@ static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg)
if (!o) {
return false;
}
- mcfg->mcfg_base = qnum_get_uint(qobject_to(QNum, o));
+ mcfg->base = qnum_get_uint(qobject_to(QNum, o));
qobject_unref(o);
- if (mcfg->mcfg_base == PCIE_BASE_ADDR_UNMAPPED) {
+ if (mcfg->base == PCIE_BASE_ADDR_UNMAPPED) {
return false;
}
o = object_property_get_qobject(pci_host, PCIE_HOST_MCFG_SIZE, NULL);
assert(o);
- mcfg->mcfg_size = qnum_get_uint(qobject_to(QNum, o));
+ mcfg->size = qnum_get_uint(qobject_to(QNum, o));
qobject_unref(o);
return true;
}
--
MST
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PULL 18/37] hw/arm/virt-acpi-build: pass AcpiMcfgInfo to build_mcfg()
@ 2019-04-19 0:30 ` Wei Yang
0 siblings, 0 replies; 289+ messages in thread
From: Michael S. Tsirkin @ 2019-05-16 12:19 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Eduardo Habkost, Shannon Zhao, qemu-arm, Wei Yang,
Igor Mammedov, Paolo Bonzini, Philippe Mathieu-Daudé,
Richard Henderson
From: Wei Yang <richardw.yang@linux.intel.com>
To build MCFG, two information is necessary:
* bus number
* base address
Abstract these two information to AcpiMcfgInfo so that build_mcfg and
build_mcfg_q35 will have the same declaration.
Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Message-Id: <20190419003053.8260-5-richardw.yang@linux.intel.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
include/hw/acpi/pci.h | 33 +++++++++++++++++++++++++++++++++
hw/arm/virt-acpi-build.c | 18 +++++++++++-------
hw/i386/acpi-build.c | 6 +-----
3 files changed, 45 insertions(+), 12 deletions(-)
create mode 100644 include/hw/acpi/pci.h
diff --git a/include/hw/acpi/pci.h b/include/hw/acpi/pci.h
new file mode 100644
index 0000000000..124af7d32a
--- /dev/null
+++ b/include/hw/acpi/pci.h
@@ -0,0 +1,33 @@
+/*
+ * Support for generating PCI related ACPI tables and passing them to Guests
+ *
+ * Copyright (C) 2006 Fabrice Bellard
+ * Copyright (C) 2008-2010 Kevin O'Connor <kevin@koconnor.net>
+ * Copyright (C) 2013-2019 Red Hat Inc
+ * Copyright (C) 2019 Intel Corporation
+ *
+ * Author: Wei Yang <richardw.yang@linux.intel.com>
+ * Author: Michael S. Tsirkin <mst@redhat.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef HW_ACPI_PCI_H
+#define HW_ACPI_PCI_H
+
+typedef struct AcpiMcfgInfo {
+ uint64_t base;
+ uint32_t size;
+} AcpiMcfgInfo;
+
+#endif
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index 12dbaf3846..e7c96d658e 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -40,6 +40,7 @@
#include "hw/loader.h"
#include "hw/hw.h"
#include "hw/acpi/aml-build.h"
+#include "hw/acpi/pci.h"
#include "hw/pci/pcie_host.h"
#include "hw/pci/pci.h"
#include "hw/arm/virt.h"
@@ -546,21 +547,18 @@ build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
}
static void
-build_mcfg(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
+build_mcfg(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
{
AcpiTableMcfg *mcfg;
- const MemMapEntry *memmap = vms->memmap;
- int ecam_id = VIRT_ECAM_ID(vms->highmem_ecam);
int len = sizeof(*mcfg) + sizeof(mcfg->allocation[0]);
mcfg = acpi_data_push(table_data, len);
- mcfg->allocation[0].address = cpu_to_le64(memmap[ecam_id].base);
+ mcfg->allocation[0].address = cpu_to_le64(info->base);
/* Only a single allocation so no need to play with segments */
mcfg->allocation[0].pci_segment = cpu_to_le16(0);
mcfg->allocation[0].start_bus_number = 0;
- mcfg->allocation[0].end_bus_number =
- PCIE_MMCFG_BUS(memmap[ecam_id].size - 1);
+ mcfg->allocation[0].end_bus_number = PCIE_MMCFG_BUS(info->size - 1);
build_header(linker, table_data, (void *)mcfg, "MCFG", len, 1, NULL, NULL);
}
@@ -801,7 +799,13 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables)
build_gtdt(tables_blob, tables->linker, vms);
acpi_add_table(table_offsets, tables_blob);
- build_mcfg(tables_blob, tables->linker, vms);
+ {
+ AcpiMcfgInfo mcfg = {
+ .base = vms->memmap[VIRT_ECAM_ID(vms->highmem_ecam)].base,
+ .size = vms->memmap[VIRT_ECAM_ID(vms->highmem_ecam)].size,
+ };
+ build_mcfg(tables_blob, tables->linker, &mcfg);
+ }
acpi_add_table(table_offsets, tables_blob);
build_spcr(tables_blob, tables->linker, vms);
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 6df7bb3abc..dbd3a6cac2 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -58,6 +58,7 @@
#include "hw/i386/x86-iommu.h"
#include "hw/acpi/aml-build.h"
+#include "hw/acpi/pci.h"
#include "qom/qom-qobject.h"
#include "hw/i386/amd_iommu.h"
@@ -86,11 +87,6 @@
/* Default IOAPIC ID */
#define ACPI_BUILD_IOAPIC_ID 0x0
-typedef struct AcpiMcfgInfo {
- uint64_t base;
- uint32_t size;
-} AcpiMcfgInfo;
-
typedef struct AcpiPmInfo {
bool s3_disabled;
bool s4_disabled;
--
MST
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PULL 19/37] hw/acpi: Consolidate build_mcfg to pci.c
@ 2019-04-19 0:30 ` Wei Yang
0 siblings, 0 replies; 289+ messages in thread
From: Michael S. Tsirkin @ 2019-05-16 12:19 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Eduardo Habkost, Shannon Zhao, qemu-arm, Wei Yang,
Igor Mammedov, Paolo Bonzini, Philippe Mathieu-Daudé,
Richard Henderson
From: Wei Yang <richardw.yang@linux.intel.com>
Now we have two identical build_mcfg functions.
Consolidate them in acpi/pci.c.
Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Message-Id: <20190419003053.8260-6-richardw.yang@linux.intel.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
default-configs/arm-softmmu.mak | 1 +
default-configs/i386-softmmu.mak | 1 +
include/hw/acpi/pci.h | 1 +
hw/acpi/pci.c | 46 ++++++++++++++++++++++++++++++++
hw/arm/virt-acpi-build.c | 17 ------------
hw/i386/acpi-build.c | 18 +------------
hw/acpi/Kconfig | 4 +++
hw/acpi/Makefile.objs | 1 +
8 files changed, 55 insertions(+), 34 deletions(-)
create mode 100644 hw/acpi/pci.c
diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak
index 613d19a06d..8f2796e195 100644
--- a/default-configs/arm-softmmu.mak
+++ b/default-configs/arm-softmmu.mak
@@ -144,6 +144,7 @@ CONFIG_XIO3130=y
CONFIG_IOH3420=y
CONFIG_I82801B11=y
CONFIG_ACPI=y
+CONFIG_ACPI_PCI=y
CONFIG_ARM_VIRT=y
CONFIG_SMBIOS=y
CONFIG_ASPEED_SOC=y
diff --git a/default-configs/i386-softmmu.mak b/default-configs/i386-softmmu.mak
index ba3fb3ff50..cd5ea391e8 100644
--- a/default-configs/i386-softmmu.mak
+++ b/default-configs/i386-softmmu.mak
@@ -25,3 +25,4 @@
CONFIG_ISAPC=y
CONFIG_I440FX=y
CONFIG_Q35=y
+CONFIG_ACPI_PCI=y
diff --git a/include/hw/acpi/pci.h b/include/hw/acpi/pci.h
index 124af7d32a..8bbd32cf45 100644
--- a/include/hw/acpi/pci.h
+++ b/include/hw/acpi/pci.h
@@ -30,4 +30,5 @@ typedef struct AcpiMcfgInfo {
uint32_t size;
} AcpiMcfgInfo;
+void build_mcfg(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info);
#endif
diff --git a/hw/acpi/pci.c b/hw/acpi/pci.c
new file mode 100644
index 0000000000..fa0fa30bb9
--- /dev/null
+++ b/hw/acpi/pci.c
@@ -0,0 +1,46 @@
+/*
+ * Support for generating PCI related ACPI tables and passing them to Guests
+ *
+ * Copyright (C) 2006 Fabrice Bellard
+ * Copyright (C) 2008-2010 Kevin O'Connor <kevin@koconnor.net>
+ * Copyright (C) 2013-2019 Red Hat Inc
+ * Copyright (C) 2019 Intel Corporation
+ *
+ * Author: Wei Yang <richardw.yang@linux.intel.com>
+ * Author: Michael S. Tsirkin <mst@redhat.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "qemu/osdep.h"
+#include "hw/acpi/aml-build.h"
+#include "hw/acpi/pci.h"
+#include "hw/pci/pcie_host.h"
+
+void build_mcfg(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
+{
+ AcpiTableMcfg *mcfg;
+ int len = sizeof(*mcfg) + sizeof(mcfg->allocation[0]);
+
+ mcfg = acpi_data_push(table_data, len);
+ mcfg->allocation[0].address = cpu_to_le64(info->base);
+
+ /* Only a single allocation so no need to play with segments */
+ mcfg->allocation[0].pci_segment = cpu_to_le16(0);
+ mcfg->allocation[0].start_bus_number = 0;
+ mcfg->allocation[0].end_bus_number = PCIE_MMCFG_BUS(info->size - 1);
+
+ build_header(linker, table_data, (void *)mcfg, "MCFG", len, 1, NULL, NULL);
+}
+
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index e7c96d658e..4a64f9985c 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -546,23 +546,6 @@ build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
"SRAT", table_data->len - srat_start, 3, NULL, NULL);
}
-static void
-build_mcfg(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
-{
- AcpiTableMcfg *mcfg;
- int len = sizeof(*mcfg) + sizeof(mcfg->allocation[0]);
-
- mcfg = acpi_data_push(table_data, len);
- mcfg->allocation[0].address = cpu_to_le64(info->base);
-
- /* Only a single allocation so no need to play with segments */
- mcfg->allocation[0].pci_segment = cpu_to_le16(0);
- mcfg->allocation[0].start_bus_number = 0;
- mcfg->allocation[0].end_bus_number = PCIE_MMCFG_BUS(info->size - 1);
-
- build_header(linker, table_data, (void *)mcfg, "MCFG", len, 1, NULL, NULL);
-}
-
/* GTDT */
static void
build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index dbd3a6cac2..2fecccb13f 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -2393,22 +2393,6 @@ build_srat(GArray *table_data, BIOSLinker *linker, MachineState *machine)
table_data->len - srat_start, 1, NULL, NULL);
}
-static void
-build_mcfg_q35(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
-{
- AcpiTableMcfg *mcfg;
- int len = sizeof(*mcfg) + 1 * sizeof(mcfg->allocation[0]);
-
- mcfg = acpi_data_push(table_data, len);
- mcfg->allocation[0].address = cpu_to_le64(info->base);
- /* Only a single allocation so no need to play with segments */
- mcfg->allocation[0].pci_segment = cpu_to_le16(0);
- mcfg->allocation[0].start_bus_number = 0;
- mcfg->allocation[0].end_bus_number = PCIE_MMCFG_BUS(info->size - 1);
-
- build_header(linker, table_data, (void *)mcfg, "MCFG", len, 1, NULL, NULL);
-}
-
/*
* VT-d spec 8.1 DMA Remapping Reporting Structure
* (version Oct. 2014 or later)
@@ -2678,7 +2662,7 @@ void acpi_build(AcpiBuildTables *tables, MachineState *machine)
}
if (acpi_get_mcfg(&mcfg)) {
acpi_add_table(table_offsets, tables_blob);
- build_mcfg_q35(tables_blob, tables->linker, &mcfg);
+ build_mcfg(tables_blob, tables->linker, &mcfg);
}
if (x86_iommu_get_default()) {
IommuType IOMMUType = x86_iommu_get_type();
diff --git a/hw/acpi/Kconfig b/hw/acpi/Kconfig
index eca3beed75..7265843cc3 100644
--- a/hw/acpi/Kconfig
+++ b/hw/acpi/Kconfig
@@ -23,6 +23,10 @@ config ACPI_NVDIMM
bool
depends on ACPI
+config ACPI_PCI
+ bool
+ depends on ACPI
+
config ACPI_VMGENID
bool
default y
diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs
index 2d46e3789a..661a9b8c2f 100644
--- a/hw/acpi/Makefile.objs
+++ b/hw/acpi/Makefile.objs
@@ -11,6 +11,7 @@ common-obj-$(call lnot,$(CONFIG_ACPI_X86)) += acpi-stub.o
common-obj-y += acpi_interface.o
common-obj-y += bios-linker-loader.o
common-obj-y += aml-build.o
+common-obj-$(CONFIG_ACPI_PCI) += pci.o
common-obj-$(CONFIG_TPM) += tpm.o
common-obj-$(CONFIG_IPMI) += ipmi.o
--
MST
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PULL 20/37] libvhost-user: fix bad vu_log_write
@ 2019-05-16 12:19 ` Michael S. Tsirkin
0 siblings, 0 replies; 289+ messages in thread
From: Michael S. Tsirkin @ 2019-05-16 12:19 UTC (permalink / raw)
To: qemu-devel
Cc: Li Feng, Peter Maydell, Zhang Yu, Dr. David Alan Gilbert,
Li Feng, Marc-André Lureau, Xie Yongji
From: Li Feng <lifeng1519@gmail.com>
Mark dirty as page, the step of each call is 1.
Signed-off-by: Li Feng <fengli@smartx.com>
Message-Id: <20190420091016.213160-1-fengli@smartx.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
contrib/libvhost-user/libvhost-user.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/contrib/libvhost-user/libvhost-user.c b/contrib/libvhost-user/libvhost-user.c
index e08d6c7b97..2689de6d1c 100644
--- a/contrib/libvhost-user/libvhost-user.c
+++ b/contrib/libvhost-user/libvhost-user.c
@@ -433,7 +433,7 @@ vu_log_write(VuDev *dev, uint64_t address, uint64_t length)
page = address / VHOST_LOG_PAGE;
while (page * VHOST_LOG_PAGE < address + length) {
vu_log_page(dev->log_table, page);
- page += VHOST_LOG_PAGE;
+ page += 1;
}
vu_log_kick(dev);
--
MST
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PULL 21/37] pcie: Remove redundant test in pcie_mmcfg_data_{read, write}()
@ 2019-04-24 4:19 ` David Gibson
0 siblings, 0 replies; 289+ messages in thread
From: Michael S. Tsirkin @ 2019-05-16 12:19 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, David Gibson
From: David Gibson <david@gibson.dropbear.id.au>
These functions have an explicit test for accesses above the device's
config size. But pci_host_config_{read,write}_common() which they're
about to call already have checks against the config space limit and
do the right thing. So, remove the redundant tests.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Message-Id: <20190424041959.4087-2-david@gibson.dropbear.id.au>
---
hw/pci/pcie_host.c | 10 ----------
1 file changed, 10 deletions(-)
diff --git a/hw/pci/pcie_host.c b/hw/pci/pcie_host.c
index 553db56778..1ee4945a6d 100644
--- a/hw/pci/pcie_host.c
+++ b/hw/pci/pcie_host.c
@@ -47,11 +47,6 @@ static void pcie_mmcfg_data_write(void *opaque, hwaddr mmcfg_addr,
}
addr = PCIE_MMCFG_CONFOFFSET(mmcfg_addr);
limit = pci_config_size(pci_dev);
- if (limit <= addr) {
- /* conventional pci device can be behind pcie-to-pci bridge.
- 256 <= addr < 4K has no effects. */
- return;
- }
pci_host_config_write_common(pci_dev, addr, limit, val, len);
}
@@ -70,11 +65,6 @@ static uint64_t pcie_mmcfg_data_read(void *opaque,
}
addr = PCIE_MMCFG_CONFOFFSET(mmcfg_addr);
limit = pci_config_size(pci_dev);
- if (limit <= addr) {
- /* conventional pci device can be behind pcie-to-pci bridge.
- 256 <= addr < 4K has no effects. */
- return ~0x0;
- }
return pci_host_config_read_common(pci_dev, addr, limit, len);
}
--
MST
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PULL 22/37] pci: Simplify pci_bus_is_root()
@ 2019-04-24 4:19 ` David Gibson
0 siblings, 0 replies; 289+ messages in thread
From: Michael S. Tsirkin @ 2019-05-16 12:20 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Greg Kurz, Peter Xu, Marcel Apfelbaum, David Gibson
From: David Gibson <david@gibson.dropbear.id.au>
pci_bus_is_root() currently relies on a method in the PCIBusClass.
But it's always known if a PCI bus is a root bus when we create it, so
using a dynamic method is overkill.
This replaces it with an IS_ROOT bit in a new flags field, which is set on
root buses and otherwise clear. As a bonus this removes the special
is_root logic from pci_expander_bridge, since it already creates its bus
as a root bus.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Message-Id: <20190424041959.4087-3-david@gibson.dropbear.id.au>
---
include/hw/pci/pci.h | 1 -
include/hw/pci/pci_bus.h | 12 +++++++++++-
hw/pci-bridge/pci_expander_bridge.c | 6 ------
hw/pci/pci.c | 14 ++------------
hw/virtio/virtio-pci.c | 1 +
5 files changed, 14 insertions(+), 20 deletions(-)
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
index fdd4c43d3a..edf44de21d 100644
--- a/include/hw/pci/pci.h
+++ b/include/hw/pci/pci.h
@@ -395,7 +395,6 @@ typedef PCIINTxRoute (*pci_route_irq_fn)(void *opaque, int pin);
#define TYPE_PCIE_BUS "PCIE"
bool pci_bus_is_express(PCIBus *bus);
-bool pci_bus_is_root(PCIBus *bus);
bool pci_bus_allows_extended_config_space(PCIBus *bus);
void pci_root_bus_new_inplace(PCIBus *bus, size_t bus_size, DeviceState *parent,
diff --git a/include/hw/pci/pci_bus.h b/include/hw/pci/pci_bus.h
index f6df834170..aea98d5040 100644
--- a/include/hw/pci/pci_bus.h
+++ b/include/hw/pci/pci_bus.h
@@ -15,14 +15,19 @@ typedef struct PCIBusClass {
BusClass parent_class;
/*< public >*/
- bool (*is_root)(PCIBus *bus);
int (*bus_num)(PCIBus *bus);
uint16_t (*numa_node)(PCIBus *bus);
bool (*allows_extended_config_space)(PCIBus *bus);
} PCIBusClass;
+enum PCIBusFlags {
+ /* This bus is the root of a PCI domain */
+ PCI_BUS_IS_ROOT = 0x0001,
+};
+
struct PCIBus {
BusState qbus;
+ enum PCIBusFlags flags;
PCIIOMMUFunc iommu_fn;
void *iommu_opaque;
uint8_t devfn_min;
@@ -47,4 +52,9 @@ struct PCIBus {
Notifier machine_done;
};
+static inline bool pci_bus_is_root(PCIBus *bus)
+{
+ return !!(bus->flags & PCI_BUS_IS_ROOT);
+}
+
#endif /* QEMU_PCI_BUS_H */
diff --git a/hw/pci-bridge/pci_expander_bridge.c b/hw/pci-bridge/pci_expander_bridge.c
index e62de4218f..ca66bc721a 100644
--- a/hw/pci-bridge/pci_expander_bridge.c
+++ b/hw/pci-bridge/pci_expander_bridge.c
@@ -66,11 +66,6 @@ static int pxb_bus_num(PCIBus *bus)
return pxb->bus_nr;
}
-static bool pxb_is_root(PCIBus *bus)
-{
- return true; /* by definition */
-}
-
static uint16_t pxb_bus_numa_node(PCIBus *bus)
{
PXBDev *pxb = convert_to_pxb(bus->parent_dev);
@@ -83,7 +78,6 @@ static void pxb_bus_class_init(ObjectClass *class, void *data)
PCIBusClass *pbc = PCI_BUS_CLASS(class);
pbc->bus_num = pxb_bus_num;
- pbc->is_root = pxb_is_root;
pbc->numa_node = pxb_bus_numa_node;
}
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index a78023f669..b386777045 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -129,14 +129,9 @@ static void pci_bus_unrealize(BusState *qbus, Error **errp)
vmstate_unregister(NULL, &vmstate_pcibus, bus);
}
-static bool pcibus_is_root(PCIBus *bus)
-{
- return !bus->parent_dev;
-}
-
static int pcibus_num(PCIBus *bus)
{
- if (pcibus_is_root(bus)) {
+ if (pci_bus_is_root(bus)) {
return 0; /* pci host bridge */
}
return bus->parent_dev->config[PCI_SECONDARY_BUS];
@@ -164,7 +159,6 @@ static void pci_bus_class_init(ObjectClass *klass, void *data)
k->unrealize = pci_bus_unrealize;
k->reset = pcibus_reset;
- pbc->is_root = pcibus_is_root;
pbc->bus_num = pcibus_num;
pbc->numa_node = pcibus_numa_node;
pbc->allows_extended_config_space = pcibus_allows_extended_config_space;
@@ -398,6 +392,7 @@ static void pci_root_bus_init(PCIBus *bus, DeviceState *parent,
bus->slot_reserved_mask = 0x0;
bus->address_space_mem = address_space_mem;
bus->address_space_io = address_space_io;
+ bus->flags |= PCI_BUS_IS_ROOT;
/* host bridge */
QLIST_INIT(&bus->child);
@@ -415,11 +410,6 @@ bool pci_bus_is_express(PCIBus *bus)
return object_dynamic_cast(OBJECT(bus), TYPE_PCIE_BUS);
}
-bool pci_bus_is_root(PCIBus *bus)
-{
- return PCI_BUS_GET_CLASS(bus)->is_root(bus);
-}
-
bool pci_bus_allows_extended_config_space(PCIBus *bus)
{
return PCI_BUS_GET_CLASS(bus)->allows_extended_config_space(bus);
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index 509c1ff555..9056cdfa3c 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -20,6 +20,7 @@
#include "standard-headers/linux/virtio_pci.h"
#include "hw/virtio/virtio.h"
#include "hw/pci/pci.h"
+#include "hw/pci/pci_bus.h"
#include "qapi/error.h"
#include "qemu/error-report.h"
#include "hw/pci/msi.h"
--
MST
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PULL 23/37] tests: acpi: rename acpi_parse_rsdp_table() into acpi_fetch_rsdp_table()
@ 2019-05-02 14:51 ` Igor Mammedov
0 siblings, 0 replies; 289+ messages in thread
From: Michael S. Tsirkin @ 2019-05-16 12:20 UTC (permalink / raw)
To: qemu-devel
Cc: Laurent Vivier, Peter Maydell, Thomas Huth, Ben Warren, Wei Yang,
Paolo Bonzini, Igor Mammedov, Philippe Mathieu-Daudé
From: Igor Mammedov <imammedo@redhat.com>
so name would reflect what the function does
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Wei Yang <richardw.yang@linux.intel.com>
Message-Id: <1556808723-226478-2-git-send-email-imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
tests/acpi-utils.h | 2 +-
tests/acpi-utils.c | 2 +-
tests/bios-tables-test.c | 2 +-
tests/vmgenid-test.c | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/tests/acpi-utils.h b/tests/acpi-utils.h
index ef388bbf12..4cd5553586 100644
--- a/tests/acpi-utils.h
+++ b/tests/acpi-utils.h
@@ -47,7 +47,7 @@ typedef struct {
uint8_t acpi_calc_checksum(const uint8_t *data, int len);
uint32_t acpi_find_rsdp_address(QTestState *qts);
uint64_t acpi_get_xsdt_address(uint8_t *rsdp_table);
-void acpi_parse_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table);
+void acpi_fetch_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table);
void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
const uint8_t *addr_ptr, const char *sig,
bool verify_checksum);
diff --git a/tests/acpi-utils.c b/tests/acpi-utils.c
index cc33b460ab..633d8f513d 100644
--- a/tests/acpi-utils.c
+++ b/tests/acpi-utils.c
@@ -63,7 +63,7 @@ uint64_t acpi_get_xsdt_address(uint8_t *rsdp_table)
return le64_to_cpu(xsdt_physical_address);
}
-void acpi_parse_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table)
+void acpi_fetch_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table)
{
uint8_t revision;
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index a506dcbb29..6a678bf761 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -89,7 +89,7 @@ static void test_acpi_rsdp_table(test_data *data)
uint8_t *rsdp_table = data->rsdp_table, revision;
uint32_t addr = data->rsdp_addr;
- acpi_parse_rsdp_table(data->qts, addr, rsdp_table);
+ acpi_fetch_rsdp_table(data->qts, addr, rsdp_table);
revision = rsdp_table[15 /* Revision offset */];
switch (revision) {
diff --git a/tests/vmgenid-test.c b/tests/vmgenid-test.c
index ae38ee5ac0..f400184268 100644
--- a/tests/vmgenid-test.c
+++ b/tests/vmgenid-test.c
@@ -40,7 +40,7 @@ static uint32_t acpi_find_vgia(QTestState *qts)
g_assert_cmphex(rsdp_offset, <, RSDP_ADDR_INVALID);
- acpi_parse_rsdp_table(qts, rsdp_offset, rsdp_table);
+ acpi_fetch_rsdp_table(qts, rsdp_offset, rsdp_table);
acpi_fetch_table(qts, &rsdt, &rsdt_len, &rsdp_table[16 /* RsdtAddress */],
"RSDT", true);
--
MST
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PULL 24/37] tests: acpi: make acpi_fetch_table() take size of fetched table pointer
@ 2019-05-02 14:51 ` Igor Mammedov
0 siblings, 0 replies; 289+ messages in thread
From: Michael S. Tsirkin @ 2019-05-16 12:20 UTC (permalink / raw)
To: qemu-devel
Cc: Laurent Vivier, Peter Maydell, Thomas Huth, Ben Warren, Wei Yang,
Igor Mammedov, Paolo Bonzini
From: Igor Mammedov <imammedo@redhat.com>
Currently acpi_fetch_table() assumes 32 bit size of table pointer
in ACPI tables. However X_foo variants are 64 bit, prepare
acpi_fetch_table() to handle both by adding an argument
for addr_ptr pointed entry size. Follow up commits will use that
to read XSDT and X_foo entries in ACPI tables.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Message-Id: <1556808723-226478-3-git-send-email-imammedo@redhat.com>
Reviewed-by: Wei Yang <richardw.yang@linux.intel.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
tests/acpi-utils.h | 2 +-
tests/acpi-utils.c | 10 ++++++----
tests/bios-tables-test.c | 8 ++++----
tests/vmgenid-test.c | 4 ++--
4 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/tests/acpi-utils.h b/tests/acpi-utils.h
index 4cd5553586..92285b75b3 100644
--- a/tests/acpi-utils.h
+++ b/tests/acpi-utils.h
@@ -49,7 +49,7 @@ uint32_t acpi_find_rsdp_address(QTestState *qts);
uint64_t acpi_get_xsdt_address(uint8_t *rsdp_table);
void acpi_fetch_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table);
void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
- const uint8_t *addr_ptr, const char *sig,
+ const uint8_t *addr_ptr, int addr_size, const char *sig,
bool verify_checksum);
#endif /* TEST_ACPI_UTILS_H */
diff --git a/tests/acpi-utils.c b/tests/acpi-utils.c
index 633d8f513d..644c87b5f9 100644
--- a/tests/acpi-utils.c
+++ b/tests/acpi-utils.c
@@ -91,13 +91,15 @@ void acpi_fetch_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table)
* actual one.
*/
void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
- const uint8_t *addr_ptr, const char *sig,
+ const uint8_t *addr_ptr, int addr_size, const char *sig,
bool verify_checksum)
{
- uint32_t addr, len;
+ uint32_t len;
+ uint64_t addr = 0;
- memcpy(&addr, addr_ptr , sizeof(addr));
- addr = le32_to_cpu(addr);
+ g_assert(addr_size == 4 || addr_size == 8);
+ memcpy(&addr, addr_ptr , addr_size);
+ addr = le64_to_cpu(addr);
qtest_memread(qts, addr + 4, &len, 4); /* Length of ACPI table */
*aml_len = le32_to_cpu(len);
*aml = g_malloc0(*aml_len);
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index 6a678bf761..86b592c67f 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -114,14 +114,14 @@ static void test_acpi_rsdt_table(test_data *data)
/* read RSDT table */
acpi_fetch_table(data->qts, &rsdt.aml, &rsdt.aml_len,
- &data->rsdp_table[16 /* RsdtAddress */], "RSDT", true);
+ &data->rsdp_table[16 /* RsdtAddress */], 4, "RSDT", true);
/* Load all tables and add to test list directly RSDT referenced tables */
ACPI_FOREACH_RSDT_ENTRY(rsdt.aml, rsdt.aml_len, ent, 4 /* Entry size */) {
AcpiSdtTable ssdt_table = {};
acpi_fetch_table(data->qts, &ssdt_table.aml, &ssdt_table.aml_len, ent,
- NULL, true);
+ 4, NULL, true);
/* Add table to ASL test tables list */
g_array_append_val(data->tables, ssdt_table);
}
@@ -139,11 +139,11 @@ static void test_acpi_fadt_table(test_data *data)
/* Since DSDT/FACS isn't in RSDT, add them to ASL test list manually */
acpi_fetch_table(data->qts, &table.aml, &table.aml_len,
- fadt_aml + 36 /* FIRMWARE_CTRL */, "FACS", false);
+ fadt_aml + 36 /* FIRMWARE_CTRL */, 4, "FACS", false);
g_array_append_val(data->tables, table);
acpi_fetch_table(data->qts, &table.aml, &table.aml_len,
- fadt_aml + 40 /* DSDT */, "DSDT", true);
+ fadt_aml + 40 /* DSDT */, 4, "DSDT", true);
g_array_append_val(data->tables, table);
memset(fadt_aml + 36, 0, 4); /* sanitize FIRMWARE_CTRL ptr */
diff --git a/tests/vmgenid-test.c b/tests/vmgenid-test.c
index f400184268..85d8e6463e 100644
--- a/tests/vmgenid-test.c
+++ b/tests/vmgenid-test.c
@@ -42,12 +42,12 @@ static uint32_t acpi_find_vgia(QTestState *qts)
acpi_fetch_rsdp_table(qts, rsdp_offset, rsdp_table);
acpi_fetch_table(qts, &rsdt, &rsdt_len, &rsdp_table[16 /* RsdtAddress */],
- "RSDT", true);
+ 4, "RSDT", true);
ACPI_FOREACH_RSDT_ENTRY(rsdt, rsdt_len, ent, 4 /* Entry size */) {
uint8_t *table_aml;
- acpi_fetch_table(qts, &table_aml, &table_length, ent, NULL, true);
+ acpi_fetch_table(qts, &table_aml, &table_length, ent, 4, NULL, true);
if (!memcmp(table_aml + 16 /* OEM Table ID */, "VMGENID", 7)) {
uint32_t vgia_val;
uint8_t *aml = &table_aml[36 /* AML byte-code start */];
--
MST
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PULL 25/37] tests: acpi: make RSDT test routine handle XSDT
@ 2019-05-02 14:51 ` Igor Mammedov
0 siblings, 0 replies; 289+ messages in thread
From: Michael S. Tsirkin @ 2019-05-16 12:20 UTC (permalink / raw)
To: qemu-devel
Cc: Laurent Vivier, Peter Maydell, Thomas Huth, Wei Yang,
Igor Mammedov, Paolo Bonzini
From: Igor Mammedov <imammedo@redhat.com>
If RSDP revision is more than 0 fetch table pointed by XSDT
and fallback to legacy RSDT table otherwise.
While at it drop unused acpi_get_xsdt_address().
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Message-Id: <1556808723-226478-4-git-send-email-imammedo@redhat.com>
Reviewed-by: Wei Yang <richardw.yang@linux.intel.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
tests/acpi-utils.h | 1 -
tests/acpi-utils.c | 12 ------------
tests/bios-tables-test.c | 20 ++++++++++++++------
3 files changed, 14 insertions(+), 19 deletions(-)
diff --git a/tests/acpi-utils.h b/tests/acpi-utils.h
index 92285b75b3..f55ccf9ff7 100644
--- a/tests/acpi-utils.h
+++ b/tests/acpi-utils.h
@@ -46,7 +46,6 @@ typedef struct {
uint8_t acpi_calc_checksum(const uint8_t *data, int len);
uint32_t acpi_find_rsdp_address(QTestState *qts);
-uint64_t acpi_get_xsdt_address(uint8_t *rsdp_table);
void acpi_fetch_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table);
void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
const uint8_t *addr_ptr, int addr_size, const char *sig,
diff --git a/tests/acpi-utils.c b/tests/acpi-utils.c
index 644c87b5f9..a0d49c4371 100644
--- a/tests/acpi-utils.c
+++ b/tests/acpi-utils.c
@@ -51,18 +51,6 @@ uint32_t acpi_find_rsdp_address(QTestState *qts)
return off;
}
-uint64_t acpi_get_xsdt_address(uint8_t *rsdp_table)
-{
- uint64_t xsdt_physical_address;
- uint8_t revision = rsdp_table[15 /* Revision offset */];
-
- /* We must have revision 2 if we're looking for an XSDT pointer */
- g_assert(revision == 2);
-
- memcpy(&xsdt_physical_address, &rsdp_table[24 /* XsdtAddress offset */], 8);
- return le64_to_cpu(xsdt_physical_address);
-}
-
void acpi_fetch_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table)
{
uint8_t revision;
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index 86b592c67f..d6ab1218da 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -107,21 +107,29 @@ static void test_acpi_rsdp_table(test_data *data)
}
}
-static void test_acpi_rsdt_table(test_data *data)
+static void test_acpi_rxsdt_table(test_data *data)
{
+ const char *sig = "RSDT";
AcpiSdtTable rsdt = {};
+ int entry_size = 4;
+ int addr_off = 16 /* RsdtAddress */;
uint8_t *ent;
- /* read RSDT table */
+ if (data->rsdp_table[15 /* Revision offset */] != 0) {
+ addr_off = 24 /* XsdtAddress */;
+ entry_size = 8;
+ sig = "XSDT";
+ }
+ /* read [RX]SDT table */
acpi_fetch_table(data->qts, &rsdt.aml, &rsdt.aml_len,
- &data->rsdp_table[16 /* RsdtAddress */], 4, "RSDT", true);
+ &data->rsdp_table[addr_off], entry_size, sig, true);
/* Load all tables and add to test list directly RSDT referenced tables */
- ACPI_FOREACH_RSDT_ENTRY(rsdt.aml, rsdt.aml_len, ent, 4 /* Entry size */) {
+ ACPI_FOREACH_RSDT_ENTRY(rsdt.aml, rsdt.aml_len, ent, entry_size) {
AcpiSdtTable ssdt_table = {};
acpi_fetch_table(data->qts, &ssdt_table.aml, &ssdt_table.aml_len, ent,
- 4, NULL, true);
+ entry_size, NULL, true);
/* Add table to ASL test tables list */
g_array_append_val(data->tables, ssdt_table);
}
@@ -521,7 +529,7 @@ static void test_acpi_one(const char *params, test_data *data)
data->tables = g_array_new(false, true, sizeof(AcpiSdtTable));
test_acpi_rsdp_address(data);
test_acpi_rsdp_table(data);
- test_acpi_rsdt_table(data);
+ test_acpi_rxsdt_table(data);
test_acpi_fadt_table(data);
if (iasl) {
--
MST
^ permalink raw reply related [flat|nested] 289+ messages in thread
* [Qemu-devel] [PULL 26/37] tests: acpi: make pointer to RSDP 64bit
@ 2019-05-02 14:51 ` Igor Mammedov
0 siblings, 0 replies; 289+ messages in thread
From: Michael S. Tsirkin @ 2019-05-16 12:20 UTC (permalink / raw)
To: qemu-devel
Cc: Laurent Vivier, Peter Maydell, Thomas Huth, Wei Yang,
Paolo Bonzini, Igor Mammedov, Philippe Mathieu-Daudé
From: Igor Mammedov <imammedo@redhat.com>
In case of UEFI, RSDP doesn't have to be located in lowmem,
it could be placed at any address. Make sure that test won't
break if it is placed above the first 4Gb of address space.
PS:
While at it cleanup some local variables as we don't really
need them.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <1556808723-226478-5-git-send-email-imammedo@redhat.com>
Reviewed-by: Wei Yang <richardw.yang@linux.intel.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
tests/acpi-utils.h | 2 +-
tests/acpi-utils.c | 2 +-
tests/bios-tables-test.c | 10 ++++------
3 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/tests/acpi-utils.h b/tests/acpi-utils.h
index f55ccf9ff7..1da6c100a4 100644
--- a/tests/acpi-utils.h
+++ b/tests/acpi-utils.h
@@ -46,7 +46,7 @@ typedef struct {
uint8_t acpi_calc_checksum(const uint8_t *data, int len);
uint32_t acpi_find_rsdp_address(QTestState *qts);
-void acpi_fetch_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table);
+void acpi_fetch_rsdp_table(QTestState *qts, uint64_t addr, uint8_t *rsdp_table);
void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
const uint8_t *addr_ptr, int addr_size, const char *sig,
bool verify_checksum);
diff --git a/tests/acpi-utils.c b/tests/acpi-utils.c
index a0d49c4371..c216b9e0e9 100644
--- a/tests/acpi-utils.c
+++ b/tests/acpi-utils.c
@@ -51,7 +51,7 @@ uint32_t acpi_find_rsdp_address(QTestState *qts)
return off;
}
-void acpi_fetch_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table)
+void acpi_fetch_rsdp_table(QTestState *qts, uint64_t addr, uint8_t *rsdp_table)
{
uint8_t revision;
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index d6ab1218da..a164d274a2 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -26,7 +26,7 @@
typedef struct {
const char *machine;
const char *variant;
- uint32_t rsdp_addr;
+ uint64_t rsdp_addr;
uint8_t rsdp_table[36 /* ACPI 2.0+ RSD