Skip to contentSkip to conversation

Simplify some not-really-necessary PCI bus callbacks

PATCH Superseded David Gibson 15 participants 108 messages Apr 24, 2019 – Jul 5, 2019

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover Simplify some not-really-necessary PCI bus callbacks

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(-)
Signature · 1 line
2.20.1
#1 lore raw

PATCH v2 1/3 pcie: Remove redundant test in pcie_mmcfg_data_{read, write}()

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.

---
 hw/pci/pcie_host.c | 10 ----------
 1 file changed, 10 deletions(-)
hw/pci/pcie_host.c +0 -10
index 553db56778..1ee4945a6d 100644
@@ -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);
 }
 
Signature · 1 line
2.20.1
Reviewed-by on v2 1/3
#2 lore raw

Re: [Qemu-devel] [PATCH v2 1/3] pcie: Remove redundant test in pcie_mmcfg_data_{read, write}()

Quoted 7 lines · On Wed, 24 Apr 2019 14:19:57 +1000 David Gibson <[email protected]>…

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.

---

Quoted 31 lines
 hw/pci/pcie_host.c | 10 ----------
 1 file changed, 10 deletions(-)
hw/pci/pcie_host.c +0 -10
index 553db56778..1ee4945a6d 100644
@@ -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);
 }
 
#3 lore raw

PATCH v2 2/3 pci: Simplify pci_bus_is_root()

In reply to 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.

---
 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(-)
hw/pci-bridge/pci_expander_bridge.c +0 -6
index e62de4218f..ca66bc721a 100644
@@ -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;
 }
 
hw/pci/pci.c +2 -12
index 6d13ef877b..ea5941fb22 100644
@@ -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);
hw/virtio/virtio-pci.c +1 -0
index cb44e19b67..942173d830 100644
@@ -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"
include/hw/pci/pci.h +0 -1
index 0abb06b357..33ccce320c 100644
@@ -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,
include/hw/pci/pci_bus.h +11 -1
index f6df834170..aea98d5040 100644
@@ -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 */
Signature · 1 line
2.20.1
#4 lore raw

Re: [Qemu-devel] [PULL v2 21/36] pci: Simplify pci_bus_is_root()

Quoted 11 lines · Michael S. Tsirkin

From: David Gibson <[email protected]>

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.

Quoted 5 lines

Message-Id: <[email protected]>

Michael, is there a particular reason this and the mmcfg patch went in, but not the later patches in my PCI-E cleanup series?

Signature · 4 lines
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
#5 lore raw

PATCH v2 3/3 pcie: Simplify pci_adjust_config_limit()

In reply to 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.

---
 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(-)
hw/pci/pci.c +23 -18
index ea5941fb22..59ee034331 100644
@@ -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,
hw/pci/pci_host.c +3 -10
index 9d64b2e12f..5f3497256c 100644
@@ -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;
     }
 }
 
hw/ppc/spapr_pci.c +10 -24
index f62e6833b8..65a86be29c 100644
@@ -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)
include/hw/pci/pci.h +0 -1
index 33ccce320c..0edfaabbb0 100644
@@ -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,
include/hw/pci/pci_bus.h +8 -1
index aea98d5040..2d5f74b7c1 100644
@@ -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 */
Signature · 1 line
2.20.1
Reviewed-by on v2 3/3
#6 lore raw

Re: [Qemu-devel] [PATCH v2 3/3] pcie: Simplify pci_adjust_config_limit()

Quoted 22 lines · On Wed, 24 Apr 2019 14:19:59 +1000 David Gibson <[email protected]>…

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.

Quoted 4 lines

This should cause no behavioural change.

---

Quoted 215 lines
 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(-)
hw/pci/pci.c +23 -18
index ea5941fb22..59ee034331 100644
@@ -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,
hw/pci/pci_host.c +3 -10
index 9d64b2e12f..5f3497256c 100644
@@ -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;
     }
 }
 
hw/ppc/spapr_pci.c +10 -24
index f62e6833b8..65a86be29c 100644
@@ -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)
include/hw/pci/pci.h +0 -1
index 33ccce320c..0edfaabbb0 100644
@@ -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,
include/hw/pci/pci_bus.h +8 -1
index aea98d5040..2d5f74b7c1 100644
@@ -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 */
Reviewed-by on v2 3/3
#7 lore raw

Re: [Qemu-devel] [Qemu-ppc] [PATCH v2 3/3] pcie: Simplify pci_adjust_config_limit()

In reply to David Gibson
Quoted 45 lines · 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.

---
 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(-)
hw/pci/pci.c +4 -0
index ea5941fb22..59ee034331 100644
@@ -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);
+

hw/pci/pci.c static void pci_bus_realize(BusState *qbus, Error **errp) · line 136

Quoted 10 lines
hw/pci/pci.c +10 -0
+    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).

Quoted 176 lines
hw/pci/pci.c +9 -18
+
+        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,
hw/pci/pci_host.c +3 -10
index 9d64b2e12f..5f3497256c 100644
@@ -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;
     }
 }
 
hw/ppc/spapr_pci.c +10 -24
index f62e6833b8..65a86be29c 100644
@@ -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)
include/hw/pci/pci.h +0 -1
index 33ccce320c..0edfaabbb0 100644
@@ -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,
include/hw/pci/pci_bus.h +2 -1
index aea98d5040..2d5f74b7c1 100644
@@ -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 {

include/hw/pci/pci_bus.h static inline bool pci_bus_is_root(PCIBus *bus) · line 66

Quoted 9 lines
include/hw/pci/pci_bus.h +6 -0
@@ -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

Quoted 2 lines
include/hw/pci/pci_bus.h +0 -0
 #endif /* QEMU_PCI_BUS_H */
Signature · 1 line
Alexey
#8 lore raw

Re: [Qemu-devel] [Qemu-ppc] [PATCH v2 3/3] pcie: Simplify pci_adjust_config_limit()

Quoted 62 lines · Alexey Kardashevskiy
Quoted 45 lines · 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.

---
 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(-)
hw/pci/pci.c +4 -0
index ea5941fb22..59ee034331 100644
@@ -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);
+

hw/pci/pci.c static void pci_bus_realize(BusState *qbus, Error **errp) · line 136

Quoted 10 lines
hw/pci/pci.c +10 -0
+    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) ?

Quoted 3 lines

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.

Quoted 19 lines

hw/pci/pci.c static void pci_bus_realize(BusState *qbus, Error **errp) · line 142

Quoted 6 lines
hw/pci/pci.c +6 -0
+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

Quoted 2 lines
hw/pci/pci.c +0 -0
 #endif /* QEMU_PCI_BUS_H */
 
Signature · 4 lines
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
#9 lore raw

Re: [Qemu-devel] [Qemu-ppc] [PATCH v2 3/3] pcie: Simplify pci_adjust_config_limit()

Quoted 72 lines · David Gibson
Quoted 62 lines · Alexey Kardashevskiy
Quoted 45 lines · 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.

---
 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(-)
hw/pci/pci.c +4 -0
index ea5941fb22..59ee034331 100644
@@ -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);
+

hw/pci/pci.c static void pci_bus_realize(BusState *qbus, Error **errp) · line 136

Quoted 10 lines
hw/pci/pci.c +10 -0
+    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) ?

Quoted 3 lines

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.

Quoted 25 lines

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.

Quoted 19 lines

hw/pci/pci.c static void pci_bus_realize(BusState *qbus, Error **errp) · line 142

Quoted 6 lines
hw/pci/pci.c +6 -0
+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

Quoted 2 lines
hw/pci/pci.c +0 -0
 #endif /* QEMU_PCI_BUS_H */
 

Pls address comments and repost ok?

Quoted 5 lines
Signature · 4 lines
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
#10 lore raw

Re: [Qemu-devel] [Qemu-ppc] [PATCH v2 3/3] pcie: Simplify pci_adjust_config_limit()

Quoted 95 lines · Michael S. Tsirkin
Quoted 94 lines · David Gibson
Quoted 62 lines · Alexey Kardashevskiy
Quoted 45 lines · 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.

---
 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(-)
hw/pci/pci.c +4 -0
index ea5941fb22..59ee034331 100644
@@ -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);
+

hw/pci/pci.c static void pci_bus_realize(BusState *qbus, Error **errp) · line 136

Quoted 10 lines
hw/pci/pci.c +10 -0
+    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) ?

Quoted 3 lines

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.

Quoted 16 lines

hw/pci/pci.c static void pci_bus_realize(BusState *qbus, Error **errp) · line 142

Quoted 6 lines
hw/pci/pci.c +6 -0
+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

Quoted 5 lines
Quoted 3 lines
Quoted 3 lines

hw/pci/pci.c static void pci_bus_realize(BusState *qbus, Error **errp) · line 144

Quoted 2 lines
hw/pci/pci.c +0 -0
 #endif /* QEMU_PCI_BUS_H */
 

Pls address comments and repost ok?

Done.

Signature · 4 lines
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
#11 lore raw

v4 cover tests: acpi: add UEFI (ARM) testing support

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/[email protected]/msg612679.html

CC Laszlo Ersek <[email protected]>
CC "Michael S. Tsirkin" <[email protected]>
CC Gonglei <[email protected]>
CC Philippe Mathieu-Daudé <[email protected]>
CC Shannon Zhao <[email protected]>
CC Wei Yang <[email protected]>
CC Andrew Jones <[email protected]>
CC Shameer Kolothum <[email protected]>
CC Ben Warren <[email protected]>

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
Signature · 1 line
2.7.4
#12 lore raw

PATCH v4 1/15 tests: acpi: rename acpi_parse_rsdp_table() into acpi_fetch_rsdp_table()

so name would reflect what the function does

---
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(-)
tests/acpi-utils.h +1 -1
index ef388bb..4cd5553 100644
@@ -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);
tests/acpi-utils.c +1 -1
index cc33b46..633d8f5 100644
@@ -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;
 
tests/bios-tables-test.c +1 -1
index a506dcb..6a678bf 100644
@@ -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) {
tests/vmgenid-test.c +1 -1
index ae38ee5..f400184 100644
@@ -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);
 
Signature · 1 line
2.7.4
#13 lore raw

Re: [Qemu-devel] [PULL 23/37] tests: acpi: rename acpi_parse_rsdp_table() into acpi_fetch_rsdp_table()

Quoted 10 lines · On Thu, 16 May 2019 08:20:15 -0400 "Michael S. Tsirkin" <[email protected]> wrote:

From: Igor Mammedov <[email protected]>

so name would reflect what the function does

Message-Id: <[email protected]>

Michael,
My mail client doesn't do proper threading since something wrong with Message-Ids in this pull req,

for example this patch in V4 I've posted has message id
Message-Id: <[email protected]>
and the same patch (modified with your SoB) here also has the same Message-Id
Message-ID: <[email protected]>
which to me look broken

Quoted 59 lines
---
 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(-)
tests/acpi-utils.h +1 -1
index ef388bbf12..4cd5553586 100644
@@ -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);
tests/acpi-utils.c +1 -1
index cc33b460ab..633d8f513d 100644
@@ -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;
 
tests/bios-tables-test.c +1 -1
index a506dcbb29..6a678bf761 100644
@@ -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) {
tests/vmgenid-test.c +1 -1
index ae38ee5ac0..f400184268 100644
@@ -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);
 
#14 lore raw

Re: [Qemu-devel] [PULL 23/37] tests: acpi: rename acpi_parse_rsdp_table() into acpi_fetch_rsdp_table()

Quoted 14 lines · Igor Mammedov
Quoted 10 lines · On Thu, 16 May 2019 08:20:15 -0400 "Michael S. Tsirkin" <[email protected]> wrote:

From: Igor Mammedov <[email protected]>

so name would reflect what the function does

Message-Id: <[email protected]>

Quoted 8 lines

Michael,
My mail client doesn't do proper threading since something wrong with Message-Ids in this pull req,

for example this patch in V4 I've posted has message id
Message-Id: <[email protected]>
and the same patch (modified with your SoB) here also has the same Message-Id
Message-ID: <[email protected]>
which to me look broken

Same happens to me (Thunderbird).

#15 lore raw

PATCH v4 2/15 tests: acpi: make acpi_fetch_table() take size of fetched table pointer

In reply to Igor Mammedov

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.

---
 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(-)
tests/acpi-utils.h +1 -1
index 4cd5553..92285b7 100644
@@ -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 */
tests/acpi-utils.c +6 -4
index 633d8f5..644c87b 100644
@@ -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);
tests/bios-tables-test.c +4 -4
index 6a678bf..86b592c 100644
@@ -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 */
tests/vmgenid-test.c +2 -2
index f400184..85d8e64 100644
@@ -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 */];
Signature · 1 line
2.7.4
Reviewed-by on v4 2/15
#16 lore raw

Re: [Qemu-devel] [PATCH v4 02/15] tests: acpi: make acpi_fetch_table() take size of fetched table pointer

Quoted 7 lines · Igor Mammedov

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.

Quoted 100 lines

---

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(-)
tests/acpi-utils.h +1 -1
index 4cd5553..92285b7 100644
@@ -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 */
tests/acpi-utils.c +6 -4
index 633d8f5..644c87b 100644
@@ -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);
tests/bios-tables-test.c +4 -4
index 6a678bf..86b592c 100644
@@ -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 */
tests/vmgenid-test.c +2 -2
index f400184..85d8e64 100644
@@ -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 */];
Signature · 1 line
2.7.4
Signature · 2 lines
Wei Yang
Help you, Help me
#17 lore raw

PATCH v4 3/15 tests: acpi: make RSDT test routine handle XSDT

In reply to Igor Mammedov

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().

---
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(-)
tests/acpi-utils.h +0 -1
index 92285b7..f55ccf9 100644
@@ -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,
tests/acpi-utils.c +0 -12
index 644c87b..a0d49c4 100644
@@ -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;
tests/bios-tables-test.c +14 -6
index 86b592c..d6ab121 100644
@@ -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) {
Signature · 1 line
2.7.4
Reviewed-by on v4 3/15
#18 lore raw

Re: [Qemu-devel] [PATCH v4 03/15] tests: acpi: make RSDT test routine handle XSDT

Quoted 6 lines · Igor Mammedov

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().

Quoted 101 lines

---
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(-)
tests/acpi-utils.h +0 -1
index 92285b7..f55ccf9 100644
@@ -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,
tests/acpi-utils.c +0 -12
index 644c87b..a0d49c4 100644
@@ -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;
tests/bios-tables-test.c +14 -6
index 86b592c..d6ab121 100644
@@ -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) {
Signature · 1 line
2.7.4
Signature · 2 lines
Wei Yang
Help you, Help me
#19 lore raw

PATCH v4 4/15 tests: acpi: make pointer to RSDP 64bit

In reply to Igor Mammedov

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.

---
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 <[email protected]>)
v2:
- s/In case of UEFI/In case of UEFI,/ (Laszlo Ersek <[email protected]>)

---
 tests/acpi-utils.h       |  2 +-
 tests/acpi-utils.c       |  2 +-
 tests/bios-tables-test.c | 10 ++++------
 3 files changed, 6 insertions(+), 8 deletions(-)
tests/acpi-utils.h +1 -1
index f55ccf9..1da6c10 100644
@@ -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);
tests/acpi-utils.c +1 -1
index a0d49c4..c216b9e 100644
@@ -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;
 
tests/bios-tables-test.c +4 -6
index d6ab121..a164d27 100644
@@ -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));
Signature · 1 line
2.7.4
Reviewed-by on v4 4/15
#20 lore raw

Re: [Qemu-devel] [PATCH v4 04/15] tests: acpi: make pointer to RSDP 64bit

Quoted 10 lines · Igor Mammedov

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.

Quoted 72 lines

---
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 <[email protected]>)
v2:
- s/In case of UEFI/In case of UEFI,/ (Laszlo Ersek <[email protected]>)
---

tests/acpi-utils.h       |  2 +-
tests/acpi-utils.c       |  2 +-
tests/bios-tables-test.c | 10 ++++------
3 files changed, 6 insertions(+), 8 deletions(-)
tests/acpi-utils.h +1 -1
index f55ccf9..1da6c10 100644
@@ -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);
tests/acpi-utils.c +1 -1
index a0d49c4..c216b9e 100644
@@ -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;
 
tests/bios-tables-test.c +4 -6
index d6ab121..a164d27 100644
@@ -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));
Signature · 1 line
2.7.4
Signature · 2 lines
Wei Yang
Help you, Help me
Tested-by on v4 4/15
#21 lore raw

Re: [Qemu-devel] [PATCH v4 04/15] tests: acpi: make pointer to RSDP 64bit

In reply to Igor Mammedov
Quoted 10 lines · Igor Mammedov

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.

Quoted 71 lines

---
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 <[email protected]>)
v2:
- s/In case of UEFI/In case of UEFI,/ (Laszlo Ersek <[email protected]>)

---
 tests/acpi-utils.h       |  2 +-
 tests/acpi-utils.c       |  2 +-
 tests/bios-tables-test.c | 10 ++++------
 3 files changed, 6 insertions(+), 8 deletions(-)
tests/acpi-utils.h +1 -1
index f55ccf9..1da6c10 100644
@@ -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);
tests/acpi-utils.c +1 -1
index a0d49c4..c216b9e 100644
@@ -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;
 
tests/bios-tables-test.c +4 -6
index d6ab121..a164d27 100644
@@ -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));
#22 lore raw

PATCH v4 5/15 tests: acpi: fetch X_DSDT if pointer to DSDT is 0

In reply to Igor Mammedov

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.

---
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é <[email protected]>)

---
 tests/bios-tables-test.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
tests/bios-tables-test.c +10 -1
index a164d27..d165a1b 100644
@@ -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 */
Signature · 1 line
2.7.4
#23 lore raw

Re: [Qemu-devel] [PATCH v4 05/15] tests: acpi: fetch X_DSDT if pointer to DSDT is 0

Quoted 36 lines · Igor Mammedov

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.

---
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é <[email protected]>)
---
tests/bios-tables-test.c | 11 ++++++++++-

1 file changed, 10 insertions(+), 1 deletion(-)
tests/bios-tables-test.c +3 -0
index a164d27..d165a1b 100644
@@ -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"));
 

tests/bios-tables-test.c static void test_acpi_fadt_table(test_data *data) · line 157

Quoted 7 lines
tests/bios-tables-test.c +4 -0
@@ -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?

Quoted 10 lines
tests/bios-tables-test.c +3 -1
+        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 */
Signature · 1 line
2.7.4
Signature · 2 lines
Wei Yang
Help you, Help me
#24 lore raw

Re: [Qemu-devel] [PATCH v4 05/15] tests: acpi: fetch X_DSDT if pointer to DSDT is 0

Quoted 40 lines · On Sun, 5 May 2019 09:27:45 +0800 Wei Yang <[email protected]>…
Quoted 39 lines · Igor Mammedov

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.

---
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é <[email protected]>)
---
tests/bios-tables-test.c | 11 ++++++++++-

1 file changed, 10 insertions(+), 1 deletion(-)
tests/bios-tables-test.c +3 -0
index a164d27..d165a1b 100644
@@ -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);
 
Quoted 8 lines

tests/bios-tables-test.c static void test_acpi_fadt_table(test_data *data) · line 157

Quoted 4 lines
tests/bios-tables-test.c +4 -0
+    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.

Quoted 14 lines

Do you think so?

Quoted 10 lines
tests/bios-tables-test.c +3 -1
+        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 */
Signature · 1 line
2.7.4
Reviewed-by
#25 lore raw

Re: [Qemu-devel] [PATCH v4 05/15] tests: acpi: fetch X_DSDT if pointer to DSDT is 0

Quoted 50 lines · Igor Mammedov
Quoted 47 lines · On Sun, 5 May 2019 09:27:45 +0800 Wei Yang <[email protected]>…
Quoted 36 lines · Igor Mammedov

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.

---
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é <[email protected]>)
---
tests/bios-tables-test.c | 11 ++++++++++-

1 file changed, 10 insertions(+), 1 deletion(-)
tests/bios-tables-test.c +3 -0
index a164d27..d165a1b 100644
@@ -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"));
 

tests/bios-tables-test.c static void test_acpi_fadt_table(test_data *data) · line 157

Quoted 7 lines
tests/bios-tables-test.c +4 -0
@@ -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.

Quoted 9 lines
Quoted 1 line

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.

Signature · 2 lines
Wei Yang
Help you, Help me
#26 lore raw

PATCH v4 6/15 tests: acpi: skip FACS table if board uses hw reduced ACPI profile

In reply to Igor Mammedov

If FADT has HW_REDUCED_ACPI flag set, do not attempt to fetch FACS as it's not provided by the board.

---
 tests/bios-tables-test.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
tests/bios-tables-test.c +7 -3
index d165a1b..e2fc341 100644
@@ -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);
Signature · 1 line
2.7.4
#27 lore raw

PATCH v4 7/15 tests: acpi: move boot_sector_init() into x86 tests branch

In reply to Igor Mammedov

boot_sector_init() won't be used by arm/virt board, so move it from global scope to x86 branch that uses it.

---
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(-)
tests/bios-tables-test.c +5 -4
index e2fc341..4d13a3c 100644
@@ -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);
Signature · 1 line
2.7.4
Tested-by on v4 7/15
#28 lore raw

Re: [Qemu-devel] [PATCH v4 07/15] tests: acpi: move boot_sector_init() into x86 tests branch

Quoted 5 lines · Igor Mammedov

boot_sector_init() won't be used by arm/virt board, so move it from global scope to x86 branch that uses it.

Quoted 31 lines

---
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(-)
tests/bios-tables-test.c +5 -4
index e2fc341..4d13a3c 100644
@@ -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);
#29 lore raw

PATCH v4 8/15 tests: acpi: add acpi_find_rsdp_address_uefi() helper

In reply to Igor Mammedov

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)

---
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 <[email protected]>
- 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(+)
tests/acpi-utils.h +2 -0
index 1da6c10..52c529e 100644
@@ -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,
tests/acpi-utils.c +44 -0

47 lines not on this page · raw message

Signature · 1 line
2.7.4
#30 lore raw

PATCH v4 9/15 tests: acpi: add a way to start tests with UEFI firmware

In reply to Igor Mammedov

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.

---
v4:
* fixup commit message (typo/spelling) (Wei Yang <[email protected]>)
* 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(-)
tests/bios-tables-test.c +35 -17
index 4d13a3c..84e1ce2 100644
@@ -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);
Signature · 1 line
2.7.4
#31 lore raw

PATCH v4 10/15 tests: acpi: ignore SMBIOS tests when UEFI firmware is used

In reply to Igor Mammedov

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.

---
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(-)
tests/bios-tables-test.c +9 -2
index 84e1ce2..8302ffc 100644
@@ -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);
Signature · 1 line
2.7.4
Tested-by on v4 10/15
#32 lore raw

Re: [Qemu-devel] [PATCH v4 10/15] tests: acpi: ignore SMBIOS tests when UEFI firmware is used

Quoted 5 lines · Igor Mammedov

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.

Quoted 30 lines

---
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(-)
tests/bios-tables-test.c +9 -2
index 84e1ce2..8302ffc 100644
@@ -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);
#33 lore raw

PATCH v4 11/15 tests: acpi: allow to override default accelerator

In reply to Igor Mammedov

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.

---
 tests/bios-tables-test.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
tests/bios-tables-test.c +5 -3
index 8302ffc..39c1e24 100644
@@ -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);
Signature · 1 line
2.7.4
Reviewed-by on v4 11/15
#34 lore raw

Re: [Qemu-devel] [PATCH v4 11/15] tests: acpi: allow to override default accelerator

Quoted 50 lines · Igor Mammedov

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.

---
 tests/bios-tables-test.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
tests/bios-tables-test.c +3 -2
index 8302ffc..39c1e24 100644
@@ -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. */

tests/bios-tables-test.c static void test_acpi_one(const char *params, test_data *data) · line 549

Quoted 9 lines
tests/bios-tables-test.c +2 -1
@@ -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);
#35 lore raw

PATCH v4 12/15 tests: add expected ACPI tables for arm/virt board

In reply to Igor Mammedov

---
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
tests/data/acpi/virt/APIC new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..797dfde2841c51b7e72065602e99ce1714347f0d
GIT binary patch
tests/data/acpi/virt/DSDT new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..20e85c7f89f645c69935c615c07084e221419960
GIT binary patch
tests/data/acpi/virt/FACP new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..27de99f51bfe846b1f8796ace49d83f5b33a1aed
GIT binary patch
tests/data/acpi/virt/GTDT new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..10107a65e958ff6495bb8c17d63d0539690f59f6
GIT binary patch
tests/data/acpi/virt/MCFG new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..e8987e1af0ec3829770bf4fe11fab02b06160dd2
GIT binary patch
tests/data/acpi/virt/SPCR new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..377271a0e7817cc21a28c02123a89facad63604f
GIT binary patch
Signature · 1 line
2.7.4
#36 lore raw

PATCH v4 13/15 tests: acpi: add simple arm/virt testcase

In reply to Igor Mammedov

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

---
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

---
 tests/Makefile.include   |  1 +
 tests/bios-tables-test.c | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+)
tests/Makefile.include +1 -0
index e2432d5..983c8b1 100644
@@ -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)
 
tests/bios-tables-test.c +18 -0
index 39c1e24..eaa1b0c 100644
@@ -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);
Signature · 1 line
2.7.4
#37 lore raw

Re: [Qemu-devel] [PATCH v4 13/15] tests: acpi: add simple arm/virt testcase

Quoted 73 lines · Igor Mammedov

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

---
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

---
 tests/Makefile.include   |  1 +
 tests/bios-tables-test.c | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+)
tests/Makefile.include +1 -0
index e2432d5..983c8b1 100644
@@ -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)
 
tests/bios-tables-test.c +16 -0
index 39c1e24..eaa1b0c 100644
@@ -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();

tests/bios-tables-test.c int main(int argc, char *argv[]) · line 861

Quoted 8 lines
tests/bios-tables-test.c +2 -0
@@ -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

#38 lore raw

PATCH v4 14/15 tests: acpi: refactor rebuild-expected-aml.sh to dump ACPI tables for a specified list of targets

In reply to Igor Mammedov

Make initial list contain aarch64 and x86_64 targets.

---
v4:
* fix typo (Wei Yang <[email protected]>)
v2:
* fix up error message (Philippe Mathieu-Daudé <[email protected]>)

---
 tests/data/acpi/rebuild-expected-aml.sh | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)
tests/data/acpi/rebuild-expected-aml.sh +11 -12
index abdff70..07f7e3f 100755
@@ -7,21 +7,12 @@
 #
 # Authors:
 #  Marcel Apfelbaum <[email protected]>
+#  Igor Mammedov <[email protected]>
 #
 # 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."
Signature · 1 line
2.7.4
Reviewed-by on v4 14/15
#39 lore raw

Re: [Qemu-devel] [PATCH v4 14/15] tests: acpi: refactor rebuild-expected-aml.sh to dump ACPI tables for a specified list of targets

Quoted 4 lines · Igor Mammedov

Make initial list contain aarch64 and x86_64 targets.

Quoted 55 lines

---
v4:
* fix typo (Wei Yang <[email protected]>)
v2:
* fix up error message (Philippe Mathieu-Daudé <[email protected]>)
---
tests/data/acpi/rebuild-expected-aml.sh | 23 +++++++++++------------

1 file changed, 11 insertions(+), 12 deletions(-)
tests/data/acpi/rebuild-expected-aml.sh +2 -11
index abdff70..07f7e3f 100755
@@ -7,21 +7,12 @@
 #
 # Authors:
 #  Marcel Apfelbaum <[email protected]>
+#  Igor Mammedov <[email protected]>
 #
 # 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."

tests/data/acpi/rebuild-expected-aml.sh +0 -0
@@ -29,6 +20,14 @@ if [ ! -e "tests/bios-tables-test" ]; then
    exit 1;

fi

tests/data/acpi/rebuild-expected-aml.sh +9 -1
-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."

Signature · 1 line
2.7.4
Signature · 2 lines
Wei Yang
Help you, Help me
#40 lore raw

PATCH v4 15/15 tests: acpi: print error unable to dump ACPI table during rebuild

In reply to Igor Mammedov

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).

---
v4:
* fix typo in commit message (Reviewed-by: Philippe Mathieu-Daudé <[email protected]>)

---
 tests/bios-tables-test.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
tests/bios-tables-test.c +4 -1
index eaa1b0c..6cb8b16 100644
@@ -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);
Signature · 1 line
2.7.4
#41 lore raw

Re: [Qemu-devel] [PATCH v4 01/15] tests: acpi: rename acpi_parse_rsdp_table() into acpi_fetch_rsdp_table()

Quoted 9 lines · Igor Mammedov

so name would reflect what the function does

---
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.

Quoted 60 lines
 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(-)
tests/acpi-utils.h +1 -1
index ef388bb..4cd5553 100644
@@ -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);
tests/acpi-utils.c +1 -1
index cc33b46..633d8f5 100644
@@ -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;
 
tests/bios-tables-test.c +1 -1
index a506dcb..6a678bf 100644
@@ -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) {
tests/vmgenid-test.c +1 -1
index ae38ee5..f400184 100644
@@ -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);
 
Signature · 1 line
2.7.4
Quoted 107 lines · Igor Mammedov

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.

---
 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(-)
tests/acpi-utils.h +1 -1
index 4cd5553..92285b7 100644
@@ -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 */
tests/acpi-utils.c +6 -4
index 633d8f5..644c87b 100644
@@ -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);
tests/bios-tables-test.c +4 -4
index 6a678bf..86b592c 100644
@@ -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 */
tests/vmgenid-test.c +2 -2
index f400184..85d8e64 100644
@@ -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 */];
Signature · 1 line
2.7.4
Quoted 107 lines · Igor Mammedov

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().

---
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(-)
tests/acpi-utils.h +0 -1
index 92285b7..f55ccf9 100644
@@ -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,
tests/acpi-utils.c +0 -12
index 644c87b..a0d49c4 100644
@@ -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;
tests/bios-tables-test.c +14 -6
index 86b592c..d6ab121 100644
@@ -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) {
Signature · 1 line
2.7.4
Quoted 82 lines · Igor Mammedov

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.

---
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 <[email protected]>)
v2:
- s/In case of UEFI/In case of UEFI,/ (Laszlo Ersek <[email protected]>)

---
 tests/acpi-utils.h       |  2 +-
 tests/acpi-utils.c       |  2 +-
 tests/bios-tables-test.c | 10 ++++------
 3 files changed, 6 insertions(+), 8 deletions(-)
tests/acpi-utils.h +1 -1
index f55ccf9..1da6c10 100644
@@ -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);
tests/acpi-utils.c +1 -1
index a0d49c4..c216b9e 100644
@@ -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;
 
tests/bios-tables-test.c +4 -6
index d6ab121..a164d27 100644
@@ -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));
Signature · 1 line
2.7.4
Quoted 53 lines · Igor Mammedov

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.

---
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é <[email protected]>)

---
 tests/bios-tables-test.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
tests/bios-tables-test.c +10 -1
index a164d27..d165a1b 100644
@@ -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 */
Signature · 1 line
2.7.4
Quoted 33 lines · Igor Mammedov

If FADT has HW_REDUCED_ACPI flag set, do not attempt to fetch FACS as it's not provided by the board.

---
 tests/bios-tables-test.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
tests/bios-tables-test.c +7 -3
index d165a1b..e2fc341 100644
@@ -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);
Signature · 1 line
2.7.4
Quoted 37 lines · Igor Mammedov

boot_sector_init() won't be used by arm/virt board, so move it from global scope to x86 branch that uses it.

---
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(-)
tests/bios-tables-test.c +5 -4
index e2fc341..4d13a3c 100644
@@ -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);
Signature · 1 line
2.7.4
Quoted 96 lines · Igor Mammedov

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)

---
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 <[email protected]>
- 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(+)
tests/acpi-utils.h +2 -0
index 1da6c10..52c529e 100644
@@ -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,
tests/acpi-utils.c +44 -0
index c216b9e..d2a202e 100644
@@ -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;
+}
Signature · 1 line
2.7.4
Quoted 109 lines · Igor Mammedov

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.

---
v4:
* fixup commit message (typo/spelling) (Wei Yang <[email protected]>)
* 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(-)
tests/bios-tables-test.c +35 -17
index 4d13a3c..84e1ce2 100644
@@ -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);
Signature · 1 line
2.7.4
Quoted 36 lines · Igor Mammedov

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.

---
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(-)
tests/bios-tables-test.c +9 -2
index 84e1ce2..8302ffc 100644
@@ -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);
Signature · 1 line
2.7.4
Quoted 60 lines · Igor Mammedov

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.

---
 tests/bios-tables-test.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
tests/bios-tables-test.c +5 -3
index 8302ffc..39c1e24 100644
@@ -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);
Signature · 1 line
2.7.4
Quoted 161 lines · Igor Mammedov

---
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
tests/data/acpi/virt/APIC new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..797dfde2841c51b7e72065602e99ce1714347f0d
GIT binary patch
tests/data/acpi/virt/DSDT new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..20e85c7f89f645c69935c615c07084e221419960
GIT binary patch
tests/data/acpi/virt/FACP new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..27de99f51bfe846b1f8796ace49d83f5b33a1aed
GIT binary patch
tests/data/acpi/virt/GTDT new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..10107a65e958ff6495bb8c17d63d0539690f59f6
GIT binary patch
tests/data/acpi/virt/MCFG new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..e8987e1af0ec3829770bf4fe11fab02b06160dd2
GIT binary patch
tests/data/acpi/virt/SPCR new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..377271a0e7817cc21a28c02123a89facad63604f
GIT binary patch
Signature · 2 lines
-- 
2.7.4
Quoted 82 lines · Igor Mammedov

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

---
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

---
 tests/Makefile.include   |  1 +
 tests/bios-tables-test.c | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+)
tests/Makefile.include +1 -0
index e2432d5..983c8b1 100644
@@ -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)
 
tests/bios-tables-test.c +18 -0
index 39c1e24..eaa1b0c 100644
@@ -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);
Signature · 1 line
2.7.4
Quoted 59 lines · Igor Mammedov

Make initial list contain aarch64 and x86_64 targets.

---
v4:
* fix typo (Wei Yang <[email protected]>)
v2:
* fix up error message (Philippe Mathieu-Daudé <[email protected]>)

---
 tests/data/acpi/rebuild-expected-aml.sh | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)
tests/data/acpi/rebuild-expected-aml.sh +11 -12
index abdff70..07f7e3f 100755
@@ -7,21 +7,12 @@
 #
 # Authors:
 #  Marcel Apfelbaum <[email protected]>
+#  Igor Mammedov <[email protected]>
 #
 # 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."
Signature · 1 line
2.7.4
Quoted 37 lines · Igor Mammedov

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).

---
v4:
* fix typo in commit message (Reviewed-by: Philippe Mathieu-Daudé <[email protected]>)

---
 tests/bios-tables-test.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
tests/bios-tables-test.c +4 -1
index eaa1b0c..6cb8b16 100644
@@ -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);
Signature · 1 line
2.7.4
#42 lore raw

Re: [Qemu-devel] [PATCH v4 01/15] tests: acpi: rename acpi_parse_rsdp_table() into acpi_fetch_rsdp_table()

Quoted 12 lines · On Sun, 12 May 2019 14:19:08 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 9 lines · Igor Mammedov

so name would reflect what the function does

---
v4:
* make it as the first patch in series
---

Quoted 3 lines

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)

Quoted 1 line

[...]

#43 lore raw

Re: [Qemu-devel] [PATCH v4 01/15] tests: acpi: rename acpi_parse_rsdp_table() into acpi_fetch_rsdp_table()

Quoted 25 lines · On Mon, 13 May 2019 11:04:40 +0200 Igor Mammedov <[email protected]> wrote:
Quoted 12 lines · On Sun, 12 May 2019 14:19:08 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 9 lines · Igor Mammedov

so name would reflect what the function does

---
v4:
* make it as the first patch in series
---

Quoted 3 lines

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?

[...]

Quoted 1 line

(it doesn't apply to master anymore)

never mind, it applies just fine (I've missed one patch when applying)

Quoted 5 lines
Quoted 2 lines

[...]

Tested-by on the v4 series
#44 lore raw

Re: [Qemu-devel] [PATCH v4 00/15] tests: acpi: add UEFI (ARM) testing support

In reply to Igor Mammedov

Hi Ignor,

Quoted 89 lines · Igor Mammedov

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/[email protected]/msg612679.html

CC Laszlo Ersek <[email protected]>
CC "Michael S. Tsirkin" <[email protected]>
CC Gonglei <[email protected]>
CC Philippe Mathieu-Daudé <[email protected]>
CC Shannon Zhao <[email protected]>
CC Wei Yang <[email protected]>
CC Andrew Jones <[email protected]>
CC Shameer Kolothum <[email protected]>
CC Ben Warren <[email protected]>

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
Quoted 9 lines
 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:

Thanks!

Best Regards,
Wei

#45 lore raw

[Qemu-devel] [PULL 00/37] pci, pc, virtio: features, fixes

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

----------------------------------------------------------------
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
#46 lore raw

[Qemu-devel] [PULL 06/37] vhost-user-blk: Use started flag in vhost_user_blk_set_status()

From: Xie Yongji <[email protected]>

Use started flag in vhost_user_blk_set_status() to decide if starting vhost-user backend or not.

Message-Id: <[email protected]>

---
 hw/block/vhost-user-blk.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/block/vhost-user-blk.c +2 -2
index 28b81368f7..700c1dd111 100644
@@ -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);
Signature · 1 line
MST
#47 lore raw

[Qemu-devel] [PULL 03/37] docs: reST-ify vhost-user documentation

In reply to Michael S. Tsirkin

From: Marc-André Lureau <[email protected]>

Message-Id: <[email protected]>

---
 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
docs/interop/vhost-user.txt deleted +0 -1219
deleted file mode 100644
index 4dbd530cb9..0000000000
@@ -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.
MAINTAINERS +1 -1
index 66ddbda9c9..562d0ee0c6 100644
@@ -1476,7 +1476,7 @@ M: Michael S. Tsirkin <[email protected]>
 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
docs/interop/index.rst +1 -1
index 2df977dd52..a037bd67ec 100644
@@ -15,4 +15,4 @@ Contents:
    bitmaps
    live-block-operations
    pr-helper
-
+   vhost-user
docs/interop/vhost-user.rst new file +1351 -0

1,351 lines not on this page · raw message

Signature · 1 line
MST
#48 lore raw

[Qemu-devel] [PULL 08/37] vhost-user-blk: Add return value for vhost_user_blk_start()

In reply to Michael S. Tsirkin

From: Xie Yongji <[email protected]>

Add a return value for vhost_user_blk_start() to check whether we start vhost-user backend successfully or not.

Message-Id: <[email protected]>

---
 hw/block/vhost-user-blk.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
hw/block/vhost-user-blk.c +5 -4
index 39e1adc60a..6802c19d65 100644
@@ -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)
Signature · 1 line
MST
#49 lore raw

[Qemu-devel] [PULL 05/37] virtio: Use started flag in virtio_vmstate_change()

In reply to Michael S. Tsirkin

From: Xie Yongji <[email protected]>

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.

Message-Id: <[email protected]>

---
 hw/virtio/virtio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/virtio/virtio.c +1 -1
index af7b59b4ae..b8d36cd4b7 100644
@@ -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) {
Signature · 1 line
MST
#50 lore raw

[Qemu-devel] [PULL 04/37] virtio: Introduce started flag to VirtioDevice

In reply to Michael S. Tsirkin

From: Xie Yongji <[email protected]>

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.

Message-Id: <[email protected]>

---
 include/hw/virtio/virtio.h |  2 ++
 hw/virtio/virtio.c         | 52 ++++++++++++++++++++++++++++++++++++--
 2 files changed, 52 insertions(+), 2 deletions(-)
include/hw/virtio/virtio.h +2 -0
index ce9516236a..fea08bcc44 100644
@@ -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;
hw/virtio/virtio.c +50 -2

116 lines not on this page · raw message

Signature · 1 line
MST
#51 lore raw

Re: [Qemu-devel] [PULL v2 04/36] virtio: Introduce started flag to VirtioDevice

Quoted 109 lines · On Mon, 20 May 2019 19:10:35 -0400 "Michael S. Tsirkin" <[email protected]> wrote:

From: Xie Yongji <[email protected]>

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.

Message-Id: <[email protected]>

---
 include/hw/virtio/virtio.h |  2 ++
 hw/virtio/virtio.c         | 52 ++++++++++++++++++++++++++++++++++++--
 2 files changed, 52 insertions(+), 2 deletions(-)
include/hw/virtio/virtio.h +2 -0
index 7140381e3a..27c0efc3d0 100644
@@ -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;
hw/virtio/virtio.c +28 -2
index 28056a7ef7..5d533ac74e 100644
@@ -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)

hw/virtio/virtio.c static bool virtio_broken_needed(void *opaque) · line 1803

Quoted 8 lines
hw/virtio/virtio.c +5 -0
@@ -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;

Existing machine types don't know about the "virtio/started" subsection. This breaks migration to older QEMUs if the driver has started the device, ie. most probably always when it comes to live migration.

My understanding is that we do try to support backward migration though. It is a regular practice in datacenters to migrate workloads without having to take care of the QEMU version. FWIW I had to fix similar issues downstream many times in the past because customers had filed bugs.

Cc'ing David for his opinion.

Quoted 41 lines
hw/virtio/virtio.c +17 -0
+}
+
 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);
#52 lore raw

Re: [Qemu-devel] [PULL v2 04/36] virtio: Introduce started flag to VirtioDevice

Quoted 126 lines · Greg Kurz
Quoted 109 lines · On Mon, 20 May 2019 19:10:35 -0400 "Michael S. Tsirkin" <[email protected]> wrote:

From: Xie Yongji <[email protected]>

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.

Message-Id: <[email protected]>

---
 include/hw/virtio/virtio.h |  2 ++
 hw/virtio/virtio.c         | 52 ++++++++++++++++++++++++++++++++++++--
 2 files changed, 52 insertions(+), 2 deletions(-)
include/hw/virtio/virtio.h +2 -0
index 7140381e3a..27c0efc3d0 100644
@@ -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;
hw/virtio/virtio.c +28 -2
index 28056a7ef7..5d533ac74e 100644
@@ -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)

hw/virtio/virtio.c static bool virtio_broken_needed(void *opaque) · line 1803

Quoted 8 lines
hw/virtio/virtio.c +5 -0
@@ -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;

Existing machine types don't know about the "virtio/started" subsection. This breaks migration to older QEMUs if the driver has started the device, ie. most probably always when it comes to live migration.

Quoted 5 lines

My understanding is that we do try to support backward migration though. It is a regular practice in datacenters to migrate workloads without having to take care of the QEMU version. FWIW I had to fix similar issues downstream many times in the past because customers had filed bugs.

If we do need to support backward migration, for this patch, what I can think of is to only migrate the flag in the case that guest kicks but not set DRIVER_OK. This could fix backward migration in most case. Not sure if there is a more general approach...

Thanks,
Yongji

#53 lore raw

Re: [Qemu-devel] [PULL v2 04/36] virtio: Introduce started flag to VirtioDevice

Quoted 133 lines · On Fri, 24 May 2019 19:56:06 +0800 Yongji Xie <[email protected]> wrote:
Quoted 126 lines · Greg Kurz
Quoted 109 lines · On Mon, 20 May 2019 19:10:35 -0400 "Michael S. Tsirkin" <[email protected]> wrote:

From: Xie Yongji <[email protected]>

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.

Message-Id: <[email protected]>

---
 include/hw/virtio/virtio.h |  2 ++
 hw/virtio/virtio.c         | 52 ++++++++++++++++++++++++++++++++++++--
 2 files changed, 52 insertions(+), 2 deletions(-)
include/hw/virtio/virtio.h +2 -0
index 7140381e3a..27c0efc3d0 100644
@@ -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;
hw/virtio/virtio.c +28 -2
index 28056a7ef7..5d533ac74e 100644
@@ -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)

hw/virtio/virtio.c static bool virtio_broken_needed(void *opaque) · line 1803

Quoted 8 lines
hw/virtio/virtio.c +5 -0
@@ -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;  

Existing machine types don't know about the "virtio/started" subsection. This breaks migration to older QEMUs if the driver has started the device, ie. most probably always when it comes to live migration.

Quoted 5 lines

My understanding is that we do try to support backward migration though. It is a regular practice in datacenters to migrate workloads without having to take care of the QEMU version. FWIW I had to fix similar issues downstream many times in the past because customers had filed bugs.

Quoted 3 lines

If we do need to support backward migration, for this patch, what I can think of is to only migrate the flag in the case that guest kicks but not set DRIVER_OK. This could fix backward migration in most case.

You mean something like that ?

static bool virtio_started_needed(void *opaque)

{
    VirtIODevice *vdev = opaque;

    return vdev->started && !(vdev->status & VIRTIO_CONFIG_S_DRIVER_OK);
}
Quoted 2 lines

Not sure if there is a more general approach...

Another approach would be to only implement the started flag for machine version > 4.0. This can be achieved by adding a "use-started" property to the base virtio device, true by default and set to false by hw_compat_4_0.

Quoted 2 lines

Thanks,
Yongji

#54 lore raw

Re: [Qemu-devel] [PULL v2 04/36] virtio: Introduce started flag to VirtioDevice

Quoted 141 lines · Greg Kurz
Quoted 133 lines · On Fri, 24 May 2019 19:56:06 +0800 Yongji Xie <[email protected]> wrote:
Quoted 126 lines · Greg Kurz
Quoted 109 lines · On Mon, 20 May 2019 19:10:35 -0400 "Michael S. Tsirkin" <[email protected]> wrote:

From: Xie Yongji <[email protected]>

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.

Message-Id: <[email protected]>

---
 include/hw/virtio/virtio.h |  2 ++
 hw/virtio/virtio.c         | 52 ++++++++++++++++++++++++++++++++++++--
 2 files changed, 52 insertions(+), 2 deletions(-)
include/hw/virtio/virtio.h +2 -0
index 7140381e3a..27c0efc3d0 100644
@@ -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;
hw/virtio/virtio.c +28 -2
index 28056a7ef7..5d533ac74e 100644
@@ -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)

hw/virtio/virtio.c static bool virtio_broken_needed(void *opaque) · line 1803

Quoted 8 lines
hw/virtio/virtio.c +5 -0
@@ -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;

Existing machine types don't know about the "virtio/started" subsection. This breaks migration to older QEMUs if the driver has started the device, ie. most probably always when it comes to live migration.

Quoted 5 lines

My understanding is that we do try to support backward migration though. It is a regular practice in datacenters to migrate workloads without having to take care of the QEMU version. FWIW I had to fix similar issues downstream many times in the past because customers had filed bugs.

Quoted 3 lines

If we do need to support backward migration, for this patch, what I can think of is to only migrate the flag in the case that guest kicks but not set DRIVER_OK. This could fix backward migration in most case.

Quoted 9 lines

You mean something like that ?

static bool virtio_started_needed(void *opaque)

{
    VirtIODevice *vdev = opaque;

    return vdev->started && !(vdev->status & VIRTIO_CONFIG_S_DRIVER_OK);
}

Yes.

Quoted 8 lines
Quoted 2 lines

Not sure if there is a more general approach...

Another approach would be to only implement the started flag for machine version > 4.0. This can be achieved by adding a "use-started" property to the base virtio device, true by default and set to false by hw_compat_4_0.

If so, the problem that I tried to fix in this patch would still be exist in old machine type, right?

Now I think the first approach may be more reasonable. Blocking a migration that will cause guest hang instead of allowing that.

Thanks,
Yongji

#55 lore raw

Re: [Qemu-devel] [PULL v2 04/36] virtio: Introduce started flag to VirtioDevice

Quoted 157 lines · On Mon, 27 May 2019 21:04:38 +0800 Yongji Xie <[email protected]> wrote:
Quoted 141 lines · Greg Kurz
Quoted 133 lines · On Fri, 24 May 2019 19:56:06 +0800 Yongji Xie <[email protected]> wrote:
Quoted 126 lines · Greg Kurz
Quoted 109 lines · On Mon, 20 May 2019 19:10:35 -0400 "Michael S. Tsirkin" <[email protected]> wrote:

From: Xie Yongji <[email protected]>

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.

Message-Id: <[email protected]>

---
 include/hw/virtio/virtio.h |  2 ++
 hw/virtio/virtio.c         | 52 ++++++++++++++++++++++++++++++++++++--
 2 files changed, 52 insertions(+), 2 deletions(-)
include/hw/virtio/virtio.h +2 -0
index 7140381e3a..27c0efc3d0 100644
@@ -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;
hw/virtio/virtio.c +28 -2
index 28056a7ef7..5d533ac74e 100644
@@ -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)

hw/virtio/virtio.c static bool virtio_broken_needed(void *opaque) · line 1803

Quoted 8 lines
hw/virtio/virtio.c +5 -0
@@ -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;  

Existing machine types don't know about the "virtio/started" subsection. This breaks migration to older QEMUs if the driver has started the device, ie. most probably always when it comes to live migration.

Quoted 5 lines

My understanding is that we do try to support backward migration though. It is a regular practice in datacenters to migrate workloads without having to take care of the QEMU version. FWIW I had to fix similar issues downstream many times in the past because customers had filed bugs.

Quoted 3 lines

If we do need to support backward migration, for this patch, what I can think of is to only migrate the flag in the case that guest kicks but not set DRIVER_OK. This could fix backward migration in most case.

Quoted 9 lines

You mean something like that ?

static bool virtio_started_needed(void *opaque)

{
    VirtIODevice *vdev = opaque;

    return vdev->started && !(vdev->status & VIRTIO_CONFIG_S_DRIVER_OK);
}

Yes.

Quoted 3 lines
Quoted 2 lines

Not sure if there is a more general approach...

Quoted 9 lines
Quoted 5 lines

Another approach would be to only implement the started flag for machine version > 4.0. This can be achieved by adding a "use-started" property to the base virtio device, true by default and set to false by hw_compat_4_0.

If so, the problem that I tried to fix in this patch would still be exist in old machine type, right?

Yes.

Quoted 3 lines

Now I think the first approach may be more reasonable. Blocking a migration that will cause guest hang instead of allowing that.

Fair enough but it may be difficult for the end user to understand why the migration failed in the first place... What about detecting the hang condition (kick before DRIVER_OK) in the source, add a migration blocker with an explicit message and remove the blocker once DRIVER_OK is set ?

Quoted 2 lines

Thanks,
Yongji

#56 lore raw

Re: [Qemu-devel] [PULL v2 04/36] virtio: Introduce started flag to VirtioDevice

In reply to Greg Kurz
Quoted 149 lines · Greg Kurz
Quoted 133 lines · On Fri, 24 May 2019 19:56:06 +0800 Yongji Xie <[email protected]> wrote:
Quoted 126 lines · Greg Kurz
Quoted 109 lines · On Mon, 20 May 2019 19:10:35 -0400 "Michael S. Tsirkin" <[email protected]> wrote:

From: Xie Yongji <[email protected]>

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.

Message-Id: <[email protected]>

---
 include/hw/virtio/virtio.h |  2 ++
 hw/virtio/virtio.c         | 52 ++++++++++++++++++++++++++++++++++++--
 2 files changed, 52 insertions(+), 2 deletions(-)
include/hw/virtio/virtio.h +2 -0
index 7140381e3a..27c0efc3d0 100644
@@ -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;
hw/virtio/virtio.c +28 -2
index 28056a7ef7..5d533ac74e 100644
@@ -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)

hw/virtio/virtio.c static bool virtio_broken_needed(void *opaque) · line 1803

Quoted 8 lines
hw/virtio/virtio.c +5 -0
@@ -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;  

Existing machine types don't know about the "virtio/started" subsection. This breaks migration to older QEMUs if the driver has started the device, ie. most probably always when it comes to live migration.

Quoted 5 lines

My understanding is that we do try to support backward migration though. It is a regular practice in datacenters to migrate workloads without having to take care of the QEMU version. FWIW I had to fix similar issues downstream many times in the past because customers had filed bugs.

Quoted 3 lines

If we do need to support backward migration, for this patch, what I can think of is to only migrate the flag in the case that guest kicks but not set DRIVER_OK. This could fix backward migration in most case.

You mean something like that ?

static bool virtio_started_needed(void *opaque)

{
    VirtIODevice *vdev = opaque;

    return vdev->started && !(vdev->status & VIRTIO_CONFIG_S_DRIVER_OK);
}
Quoted 7 lines
Quoted 2 lines

Not sure if there is a more general approach...

Another approach would be to only implement the started flag for machine version > 4.0. This can be achieved by adding a "use-started" property to the base virtio device, true by default and set to false by hw_compat_4_0.

I think this is best frankly.

Quoted 2 lines
Quoted 2 lines

Thanks,
Yongji

#57 lore raw

Re: [Qemu-devel] [PULL v2 04/36] virtio: Introduce started flag to VirtioDevice

Quoted 154 lines · Michael S. Tsirkin
Quoted 152 lines · Greg Kurz
Quoted 133 lines · On Fri, 24 May 2019 19:56:06 +0800 Yongji Xie <[email protected]> wrote:
Quoted 126 lines · Greg Kurz
Quoted 109 lines · On Mon, 20 May 2019 19:10:35 -0400 "Michael S. Tsirkin" <[email protected]> wrote:

From: Xie Yongji <[email protected]>

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.

Message-Id: <[email protected]>

---
 include/hw/virtio/virtio.h |  2 ++
 hw/virtio/virtio.c         | 52 ++++++++++++++++++++++++++++++++++++--
 2 files changed, 52 insertions(+), 2 deletions(-)
include/hw/virtio/virtio.h +2 -0
index 7140381e3a..27c0efc3d0 100644
@@ -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;
hw/virtio/virtio.c +28 -2
index 28056a7ef7..5d533ac74e 100644
@@ -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)

hw/virtio/virtio.c static bool virtio_broken_needed(void *opaque) · line 1803

Quoted 8 lines
hw/virtio/virtio.c +5 -0
@@ -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;

Existing machine types don't know about the "virtio/started" subsection. This breaks migration to older QEMUs if the driver has started the device, ie. most probably always when it comes to live migration.

Quoted 5 lines

My understanding is that we do try to support backward migration though. It is a regular practice in datacenters to migrate workloads without having to take care of the QEMU version. FWIW I had to fix similar issues downstream many times in the past because customers had filed bugs.

Quoted 3 lines

If we do need to support backward migration, for this patch, what I can think of is to only migrate the flag in the case that guest kicks but not set DRIVER_OK. This could fix backward migration in most case.

You mean something like that ?

static bool virtio_started_needed(void *opaque)

{
    VirtIODevice *vdev = opaque;

    return vdev->started && !(vdev->status & VIRTIO_CONFIG_S_DRIVER_OK);
}
Quoted 2 lines

Not sure if there is a more general approach...

Quoted 7 lines
Quoted 4 lines

Another approach would be to only implement the started flag for machine version > 4.0. This can be achieved by adding a "use-started" property to the base virtio device, true by default and set to false by hw_compat_4_0.

I think this is best frankly.

Only implement the started flag for machine version > 4.0 might not be good because vhost-user-blk now need to use this flag. How about only migrating this flag for machine version > 4.0 instead?

Thanks,
Yongji

#58 lore raw

Re: [Qemu-devel] [PULL v2 04/36] virtio: Introduce started flag to VirtioDevice

Quoted 12 lines · Yongji Xie
Quoted 11 lines · Michael S. Tsirkin
Quoted 9 lines · Greg Kurz
Quoted 6 lines · On Fri, 24 May 2019 19:56:06 +0800 Yongji Xie <[email protected]> wrote:
Quoted 5 lines · Greg Kurz
Quoted 1 line · On Mon, 20 May 2019 19:10:35 -0400 "Michael S. Tsirkin" <[email protected]> wrote:

From: Xie Yongji <[email protected]>

[...]

Quoted 41 lines
Quoted 41 lines
Quoted 40 lines
Quoted 20 lines
Quoted 14 lines

hw/virtio/virtio.c static bool virtio_broken_needed(void *opaque) · line 1803

Quoted 9 lines
hw/virtio/virtio.c +5 -0
@@ -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;

Existing machine types don't know about the "virtio/started" subsection. This breaks migration to older QEMUs if the driver has started the device, ie. most probably always when it comes to live migration.

Quoted 5 lines

My understanding is that we do try to support backward migration though. It is a regular practice in datacenters to migrate workloads without having to take care of the QEMU version. FWIW I had to fix similar issues downstream many times in the past because customers had filed bugs.

Quoted 3 lines

If we do need to support backward migration, for this patch, what I can think of is to only migrate the flag in the case that guest kicks but not set DRIVER_OK. This could fix backward migration in most case.

You mean something like that ?

static bool virtio_started_needed(void *opaque)

{
    VirtIODevice *vdev = opaque;

    return vdev->started && !(vdev->status & VIRTIO_CONFIG_S_DRIVER_OK);
}
Quoted 2 lines

Not sure if there is a more general approach...

Another approach would be to only implement the started flag for machine version > 4.0. This can be achieved by adding a "use-started" property to the base virtio device, true by default and set to false by hw_compat_4_0.

Quoted 6 lines
Quoted 2 lines

I think this is best frankly.

Only implement the started flag for machine version > 4.0 might not be good because vhost-user-blk now need to use this flag. How about only migrating this flag for machine version > 4.0 instead?

Was this implemented? Is migration from QEMU 4.1 to QEMU 4.0 currently broken?

Signature · 1 line
Eduardo
#59 lore raw

Re: [Qemu-devel] [PULL v2 04/36] virtio: Introduce started flag to VirtioDevice

Quoted 58 lines · On Fri, 31 May 2019 16:36:33 -0300 Eduardo Habkost <[email protected]> wrote:
Quoted 12 lines · Yongji Xie
Quoted 11 lines · Michael S. Tsirkin
Quoted 9 lines · Greg Kurz
Quoted 6 lines · On Fri, 24 May 2019 19:56:06 +0800 Yongji Xie <[email protected]> wrote:
Quoted 5 lines · Greg Kurz
Quoted 1 line · On Mon, 20 May 2019 19:10:35 -0400 "Michael S. Tsirkin" <[email protected]> wrote:

From: Xie Yongji <[email protected]>

[...]

Quoted 44 lines
Quoted 43 lines
Quoted 33 lines
Quoted 20 lines
Quoted 14 lines

Review static bool virtio_broken_needed(void *opaque) · line 1803

Quoted 9 lines
(quoted diff) +5 -0
@@ -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;  

Existing machine types don't know about the "virtio/started" subsection. This breaks migration to older QEMUs if the driver has started the device, ie. most probably always when it comes to live migration.

Quoted 5 lines

My understanding is that we do try to support backward migration though. It is a regular practice in datacenters to migrate workloads without having to take care of the QEMU version. FWIW I had to fix similar issues downstream many times in the past because customers had filed bugs.

Quoted 3 lines

If we do need to support backward migration, for this patch, what I can think of is to only migrate the flag in the case that guest kicks but not set DRIVER_OK. This could fix backward migration in most case.

You mean something like that ?

static bool virtio_started_needed(void *opaque)

{
    VirtIODevice *vdev = opaque;

    return vdev->started && !(vdev->status & VIRTIO_CONFIG_S_DRIVER_OK);
}
Quoted 7 lines
Quoted 2 lines

Not sure if there is a more general approach...

Another approach would be to only implement the started flag for machine version > 4.0. This can be achieved by adding a "use-started" property to the base virtio device, true by default and set to false by hw_compat_4_0.

I think this is best frankly.

Quoted 7 lines
Quoted 3 lines

Only implement the started flag for machine version > 4.0 might not be good because vhost-user-blk now need to use this flag. How about only migrating this flag for machine version > 4.0 instead?

Was this implemented? Is migration from QEMU 4.1 to QEMU 4.0 currently broken?

Answer is yes for both questions.

#60 lore raw

Re: [Qemu-devel] [PULL v2 04/36] virtio: Introduce started flag to VirtioDevice

Quoted 65 lines · Greg Kurz
Quoted 62 lines · On Fri, 31 May 2019 16:36:33 -0300 Eduardo Habkost <[email protected]> wrote:
Quoted 12 lines · Yongji Xie
Quoted 11 lines · Michael S. Tsirkin
Quoted 9 lines · Greg Kurz
Quoted 6 lines · On Fri, 24 May 2019 19:56:06 +0800 Yongji Xie <[email protected]> wrote:
Quoted 5 lines · Greg Kurz
Quoted 1 line · On Mon, 20 May 2019 19:10:35 -0400 "Michael S. Tsirkin" <[email protected]> wrote:

From: Xie Yongji <[email protected]>

[...]

Quoted 47 lines
Quoted 36 lines
Quoted 36 lines
Quoted 20 lines
Quoted 14 lines

Review static bool virtio_broken_needed(void *opaque) · line 1803

Quoted 9 lines
(quoted diff) +5 -0
@@ -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;  

Existing machine types don't know about the "virtio/started" subsection. This breaks migration to older QEMUs if the driver has started the device, ie. most probably always when it comes to live migration.

Quoted 5 lines

My understanding is that we do try to support backward migration though. It is a regular practice in datacenters to migrate workloads without having to take care of the QEMU version. FWIW I had to fix similar issues downstream many times in the past because customers had filed bugs.

Quoted 3 lines

If we do need to support backward migration, for this patch, what I can think of is to only migrate the flag in the case that guest kicks but not set DRIVER_OK. This could fix backward migration in most case.

You mean something like that ?

static bool virtio_started_needed(void *opaque)

{
    VirtIODevice *vdev = opaque;

    return vdev->started && !(vdev->status & VIRTIO_CONFIG_S_DRIVER_OK);
}
Quoted 2 lines

Not sure if there is a more general approach...

Quoted 7 lines
Quoted 4 lines

Another approach would be to only implement the started flag for machine version > 4.0. This can be achieved by adding a "use-started" property to the base virtio device, true by default and set to false by hw_compat_4_0.

I think this is best frankly.

Only implement the started flag for machine version > 4.0 might not be good because vhost-user-blk now need to use this flag. How about only migrating this flag for machine version > 4.0 instead?

Quoted 6 lines
Quoted 3 lines

Was this implemented? Is migration from QEMU 4.1 to QEMU 4.0 currently broken?

Answer is yes for both questions.

Is there a fix?

The problem is really easy to reproduce: start a guest with virtio-blk and migrate once the driver has started.

Thanks,
Laurent

#61 lore raw

Re: [Qemu-devel] [PULL v2 04/36] virtio: Introduce started flag to VirtioDevice

Quoted 66 lines · On Mon, 24 Jun 2019 19:54:27 +0200 Laurent Vivier <[email protected]> wrote:
Quoted 65 lines · Greg Kurz
Quoted 62 lines · On Fri, 31 May 2019 16:36:33 -0300 Eduardo Habkost <[email protected]> wrote:
Quoted 12 lines · Yongji Xie
Quoted 11 lines · Michael S. Tsirkin
Quoted 9 lines · Greg Kurz
Quoted 6 lines · On Fri, 24 May 2019 19:56:06 +0800 Yongji Xie <[email protected]> wrote:
Quoted 5 lines · Greg Kurz
Quoted 1 line · On Mon, 20 May 2019 19:10:35 -0400 "Michael S. Tsirkin" <[email protected]> wrote:

From: Xie Yongji <[email protected]>

[...]

Quoted 47 lines
Quoted 36 lines
Quoted 36 lines
Quoted 20 lines
Quoted 14 lines

Review static bool virtio_broken_needed(void *opaque) · line 1803

Quoted 9 lines
(quoted diff) +5 -0
@@ -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;  

Existing machine types don't know about the "virtio/started" subsection. This breaks migration to older QEMUs if the driver has started the device, ie. most probably always when it comes to live migration.

Quoted 5 lines

My understanding is that we do try to support backward migration though. It is a regular practice in datacenters to migrate workloads without having to take care of the QEMU version. FWIW I had to fix similar issues downstream many times in the past because customers had filed bugs.

Quoted 3 lines

If we do need to support backward migration, for this patch, what I can think of is to only migrate the flag in the case that guest kicks but not set DRIVER_OK. This could fix backward migration in most case.

You mean something like that ?

static bool virtio_started_needed(void *opaque)

{
    VirtIODevice *vdev = opaque;

    return vdev->started && !(vdev->status & VIRTIO_CONFIG_S_DRIVER_OK);
}
Quoted 2 lines

Not sure if there is a more general approach...

Quoted 7 lines
Quoted 4 lines

Another approach would be to only implement the started flag for machine version > 4.0. This can be achieved by adding a "use-started" property to the base virtio device, true by default and set to false by hw_compat_4_0.

I think this is best frankly.

Only implement the started flag for machine version > 4.0 might not be good because vhost-user-blk now need to use this flag. How about only migrating this flag for machine version > 4.0 instead?

Quoted 9 lines
Quoted 6 lines
Quoted 3 lines

Was this implemented? Is migration from QEMU 4.1 to QEMU 4.0 currently broken?

Answer is yes for both questions.

Is there a fix?

The fix was merged with this PR:

https://lists.gnu.org/archive/html/qemu-devel/2019-07/msg01565.html

Cheers,

--
Greg

Quoted 5 lines

The problem is really easy to reproduce: start a guest with virtio-blk and migrate once the driver has started.

Thanks,
Laurent

#62 lore raw

Re: [Qemu-devel] [PULL v2 04/36] virtio: Introduce started flag to VirtioDevice

In reply to Greg Kurz
Quoted 125 lines · Greg Kurz
Quoted 109 lines · On Mon, 20 May 2019 19:10:35 -0400 "Michael S. Tsirkin" <[email protected]> wrote:

From: Xie Yongji <[email protected]>

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.

Message-Id: <[email protected]>

---
 include/hw/virtio/virtio.h |  2 ++
 hw/virtio/virtio.c         | 52 ++++++++++++++++++++++++++++++++++++--
 2 files changed, 52 insertions(+), 2 deletions(-)
include/hw/virtio/virtio.h +2 -0
index 7140381e3a..27c0efc3d0 100644
@@ -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;
hw/virtio/virtio.c +28 -2
index 28056a7ef7..5d533ac74e 100644
@@ -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)

hw/virtio/virtio.c static bool virtio_broken_needed(void *opaque) · line 1803

Quoted 8 lines
hw/virtio/virtio.c +5 -0
@@ -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;

Existing machine types don't know about the "virtio/started" subsection. This breaks migration to older QEMUs if the driver has started the device, ie. most probably always when it comes to live migration.

Quoted 6 lines

My understanding is that we do try to support backward migration though. It is a regular practice in datacenters to migrate workloads without having to take care of the QEMU version. FWIW I had to fix similar issues downstream many times in the past because customers had filed bugs.

Cc'ing David for his opinion.

Uh.. did you mean to CC me, or Dave Gilbert?

I mean, I think you're right that we should try to maintain backwards migration, but this isn't really my area of authority.

Signature · 4 lines
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
#63 lore raw

Re: [Qemu-devel] [PULL v2 04/36] virtio: Introduce started flag to VirtioDevice

Quoted 126 lines · On Tue, 28 May 2019 10:08:54 +1000 David Gibson <[email protected]>…
Quoted 125 lines · Greg Kurz
Quoted 109 lines · On Mon, 20 May 2019 19:10:35 -0400 "Michael S. Tsirkin" <[email protected]> wrote:

From: Xie Yongji <[email protected]>

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.

Message-Id: <[email protected]>

---
 include/hw/virtio/virtio.h |  2 ++
 hw/virtio/virtio.c         | 52 ++++++++++++++++++++++++++++++++++++--
 2 files changed, 52 insertions(+), 2 deletions(-)
include/hw/virtio/virtio.h +2 -0
index 7140381e3a..27c0efc3d0 100644
@@ -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;
hw/virtio/virtio.c +28 -2
index 28056a7ef7..5d533ac74e 100644
@@ -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)

hw/virtio/virtio.c static bool virtio_broken_needed(void *opaque) · line 1803

Quoted 8 lines
hw/virtio/virtio.c +5 -0
@@ -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;  

Existing machine types don't know about the "virtio/started" subsection. This breaks migration to older QEMUs if the driver has started the device, ie. most probably always when it comes to live migration.

Quoted 9 lines
Quoted 6 lines

My understanding is that we do try to support backward migration though. It is a regular practice in datacenters to migrate workloads without having to take care of the QEMU version. FWIW I had to fix similar issues downstream many times in the past because customers had filed bugs.

Cc'ing David for his opinion.

Uh.. did you mean to CC me, or Dave Gilbert?

Oops... Dave Gilbert indeed, but you're thoughts on that matter are valuable as well. I remember being involved in backward migration fixes for spapr several times.

Quoted 3 lines

I mean, I think you're right that we should try to maintain backwards migration, but this isn't really my area of authority.

Cc'ing Dave Gilbert :)

Cheers,

--
Greg

#64 lore raw

Re: [Qemu-devel] [PULL v2 04/36] virtio: Introduce started flag to VirtioDevice

Quoted 143 lines · * Greg Kurz ([email protected]) wrote:
Quoted 126 lines · On Tue, 28 May 2019 10:08:54 +1000 David Gibson <[email protected]>…
Quoted 125 lines · Greg Kurz
Quoted 109 lines · On Mon, 20 May 2019 19:10:35 -0400 "Michael S. Tsirkin" <[email protected]> wrote:

From: Xie Yongji <[email protected]>

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.

Message-Id: <[email protected]>

---
 include/hw/virtio/virtio.h |  2 ++
 hw/virtio/virtio.c         | 52 ++++++++++++++++++++++++++++++++++++--
 2 files changed, 52 insertions(+), 2 deletions(-)
include/hw/virtio/virtio.h +2 -0
index 7140381e3a..27c0efc3d0 100644
@@ -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;
hw/virtio/virtio.c +28 -2
index 28056a7ef7..5d533ac74e 100644
@@ -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)

hw/virtio/virtio.c static bool virtio_broken_needed(void *opaque) · line 1803

Quoted 8 lines
hw/virtio/virtio.c +5 -0
@@ -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;  

Existing machine types don't know about the "virtio/started" subsection. This breaks migration to older QEMUs if the driver has started the device, ie. most probably always when it comes to live migration.

Quoted 9 lines
Quoted 6 lines

My understanding is that we do try to support backward migration though. It is a regular practice in datacenters to migrate workloads without having to take care of the QEMU version. FWIW I had to fix similar issues downstream many times in the past because customers had filed bugs.

Cc'ing David for his opinion.

Uh.. did you mean to CC me, or Dave Gilbert?

Oops... Dave Gilbert indeed, but you're thoughts on that matter are valuable as well. I remember being involved in backward migration fixes for spapr several times.

Quoted 5 lines
Quoted 3 lines

I mean, I think you're right that we should try to maintain backwards migration, but this isn't really my area of authority.

Cc'ing Dave Gilbert :)

Right, I need to maintain backwards migration compatibility; tie the feature to a machine type so it's only used on newer machine types and then we'll be safe.

Having said that, what's the symptom when this goes wrong?

Dave

Quoted 4 lines

Cheers,

--
Greg

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#65 lore raw

Re: [Qemu-devel] [PULL v2 04/36] virtio: Introduce started flag to VirtioDevice

Quoted 148 lines · On Wed, 29 May 2019 12:18:50 +0100 "Dr. David Alan Gilbert"…
Quoted 147 lines · * Greg Kurz ([email protected]) wrote:
Quoted 126 lines · On Tue, 28 May 2019 10:08:54 +1000 David Gibson <[email protected]>…
Quoted 125 lines · Greg Kurz
Quoted 109 lines · On Mon, 20 May 2019 19:10:35 -0400 "Michael S. Tsirkin" <[email protected]> wrote:

From: Xie Yongji <[email protected]>

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.

Message-Id: <[email protected]>

---
 include/hw/virtio/virtio.h |  2 ++
 hw/virtio/virtio.c         | 52 ++++++++++++++++++++++++++++++++++++--
 2 files changed, 52 insertions(+), 2 deletions(-)
include/hw/virtio/virtio.h +2 -0
index 7140381e3a..27c0efc3d0 100644
@@ -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;
hw/virtio/virtio.c +28 -2
index 28056a7ef7..5d533ac74e 100644
@@ -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)

hw/virtio/virtio.c static bool virtio_broken_needed(void *opaque) · line 1803

Quoted 8 lines
hw/virtio/virtio.c +5 -0
@@ -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;    

Existing machine types don't know about the "virtio/started" subsection. This breaks migration to older QEMUs if the driver has started the device, ie. most probably always when it comes to live migration.

Quoted 9 lines
Quoted 6 lines

My understanding is that we do try to support backward migration though. It is a regular practice in datacenters to migrate workloads without having to take care of the QEMU version. FWIW I had to fix similar issues downstream many times in the past because customers had filed bugs.

Cc'ing David for his opinion.

Uh.. did you mean to CC me, or Dave Gilbert?

Oops... Dave Gilbert indeed, but you're thoughts on that matter are valuable as well. I remember being involved in backward migration fixes for spapr several times.

Quoted 3 lines

I mean, I think you're right that we should try to maintain backwards migration, but this isn't really my area of authority.

Quoted 8 lines
Quoted 1 line

Cc'ing Dave Gilbert :)

Right, I need to maintain backwards migration compatibility; tie the feature to a machine type so it's only used on newer machine types and then we'll be safe.

Having said that, what's the symptom when this goes wrong?

Since the started flag is set as soon as the guest driver begins to use the device and remains so until next reset, the associated subsection is basically always emitted when migrating a booted guest. This causes migration to always fail on the target in this case:

qemu-system-ppc64: Failed to load virtio-net:virtio
qemu-system-ppc64: error while loading state for instance 0x0 of device 'pci@800000020000000:00.0/virtio-net'
qemu-system-ppc64: load of migration failed: No such file or directory

Xie Yongji has just sent a series to fix that, with you in Cc:

Cheers,

--
Greg

Quoted 10 lines

Dave

Quoted 4 lines

Cheers,

--
Greg

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#66 lore raw

Re: [Qemu-devel] [PULL v2 04/36] virtio: Introduce started flag to VirtioDevice

Quoted 157 lines · * Greg Kurz ([email protected]) wrote:
Quoted 154 lines · On Wed, 29 May 2019 12:18:50 +0100 "Dr. David Alan Gilbert"…
Quoted 143 lines · * Greg Kurz ([email protected]) wrote:
Quoted 126 lines · On Tue, 28 May 2019 10:08:54 +1000 David Gibson <[email protected]>…
Quoted 125 lines · Greg Kurz
Quoted 109 lines · On Mon, 20 May 2019 19:10:35 -0400 "Michael S. Tsirkin" <[email protected]> wrote:

From: Xie Yongji <[email protected]>

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.

Message-Id: <[email protected]>

---
 include/hw/virtio/virtio.h |  2 ++
 hw/virtio/virtio.c         | 52 ++++++++++++++++++++++++++++++++++++--
 2 files changed, 52 insertions(+), 2 deletions(-)
include/hw/virtio/virtio.h +2 -0
index 7140381e3a..27c0efc3d0 100644
@@ -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;
hw/virtio/virtio.c +28 -2
index 28056a7ef7..5d533ac74e 100644
@@ -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)

hw/virtio/virtio.c static bool virtio_broken_needed(void *opaque) · line 1803

Quoted 8 lines
hw/virtio/virtio.c +5 -0
@@ -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;    

Existing machine types don't know about the "virtio/started" subsection. This breaks migration to older QEMUs if the driver has started the device, ie. most probably always when it comes to live migration.

Quoted 9 lines
Quoted 6 lines

My understanding is that we do try to support backward migration though. It is a regular practice in datacenters to migrate workloads without having to take care of the QEMU version. FWIW I had to fix similar issues downstream many times in the past because customers had filed bugs.

Cc'ing David for his opinion.

Uh.. did you mean to CC me, or Dave Gilbert?

Oops... Dave Gilbert indeed, but you're thoughts on that matter are valuable as well. I remember being involved in backward migration fixes for spapr several times.

Quoted 5 lines
Quoted 3 lines

I mean, I think you're right that we should try to maintain backwards migration, but this isn't really my area of authority.

Cc'ing Dave Gilbert :)

Right, I need to maintain backwards migration compatibility; tie the feature to a machine type so it's only used on newer machine types and then we'll be safe.

Quoted 7 lines
Quoted 2 lines

Having said that, what's the symptom when this goes wrong?

Since the started flag is set as soon as the guest driver begins to use the device and remains so until next reset, the associated subsection is basically always emitted when migrating a booted guest. This causes migration to always fail on the target in this case:

I meant what's the symptom without this patch series at all?

Dave

Quoted 4 lines

qemu-system-ppc64: Failed to load virtio-net:virtio
qemu-system-ppc64: error while loading state for instance 0x0 of device 'pci@800000020000000:00.0/virtio-net'
qemu-system-ppc64: load of migration failed: No such file or directory

Quoted 18 lines

Xie Yongji has just sent a series to fix that, with you in Cc:

Cheers,

--
Greg

Quoted 10 lines

Dave

Quoted 4 lines

Cheers,

--
Greg

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#67 lore raw

Re: [Qemu-devel] [PULL v2 04/36] virtio: Introduce started flag to VirtioDevice

Quoted 161 lines · On Wed, 29 May 2019 13:38:19 +0100 "Dr. David Alan Gilbert"…
Quoted 160 lines · * Greg Kurz ([email protected]) wrote:
Quoted 156 lines · On Wed, 29 May 2019 12:18:50 +0100 "Dr. David Alan Gilbert"…
Quoted 143 lines · * Greg Kurz ([email protected]) wrote:
Quoted 126 lines · On Tue, 28 May 2019 10:08:54 +1000 David Gibson <[email protected]>…
Quoted 125 lines · Greg Kurz
Quoted 109 lines · On Mon, 20 May 2019 19:10:35 -0400 "Michael S. Tsirkin" <[email protected]> wrote:

From: Xie Yongji <[email protected]>

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.

Message-Id: <[email protected]>

---
 include/hw/virtio/virtio.h |  2 ++
 hw/virtio/virtio.c         | 52 ++++++++++++++++++++++++++++++++++++--
 2 files changed, 52 insertions(+), 2 deletions(-)
include/hw/virtio/virtio.h +2 -0
index 7140381e3a..27c0efc3d0 100644
@@ -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;
hw/virtio/virtio.c +28 -2
index 28056a7ef7..5d533ac74e 100644
@@ -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)

hw/virtio/virtio.c static bool virtio_broken_needed(void *opaque) · line 1803

Quoted 8 lines
hw/virtio/virtio.c +5 -0
@@ -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;      

Existing machine types don't know about the "virtio/started" subsection. This breaks migration to older QEMUs if the driver has started the device, ie. most probably always when it comes to live migration.

Quoted 9 lines
Quoted 6 lines

My understanding is that we do try to support backward migration though. It is a regular practice in datacenters to migrate workloads without having to take care of the QEMU version. FWIW I had to fix similar issues downstream many times in the past because customers had filed bugs.

Cc'ing David for his opinion.

Uh.. did you mean to CC me, or Dave Gilbert?

Oops... Dave Gilbert indeed, but you're thoughts on that matter are valuable as well. I remember being involved in backward migration fixes for spapr several times.

Quoted 5 lines
Quoted 3 lines

I mean, I think you're right that we should try to maintain backwards migration, but this isn't really my area of authority.

Cc'ing Dave Gilbert :)

Right, I need to maintain backwards migration compatibility; tie the feature to a machine type so it's only used on newer machine types and then we'll be safe.

Having said that, what's the symptom when this goes wrong?

Quoted 7 lines
Quoted 4 lines

Since the started flag is set as soon as the guest driver begins to use the device and remains so until next reset, the associated subsection is basically always emitted when migrating a booted guest. This causes migration to always fail on the target in this case:

I meant what's the symptom without this patch series at all?

Oh sorry... if I got it right, migrating when the guest first kicked the device but not set the DRIVE_OK bit yet would result in a guest hang on the destination. Yongji might elaborate a bit more on that.

Quoted 26 lines

Dave

Quoted 4 lines

qemu-system-ppc64: Failed to load virtio-net:virtio
qemu-system-ppc64: error while loading state for instance 0x0 of device 'pci@800000020000000:00.0/virtio-net'
qemu-system-ppc64: load of migration failed: No such file or directory

Quoted 18 lines

Xie Yongji has just sent a series to fix that, with you in Cc:

Cheers,

--
Greg

Quoted 10 lines

Dave

Quoted 4 lines

Cheers,

--
Greg

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#68 lore raw

Re: [Qemu-devel] [PULL v2 04/36] virtio: Introduce started flag to VirtioDevice

Quoted 169 lines · * Greg Kurz ([email protected]) wrote:
Quoted 166 lines · On Wed, 29 May 2019 13:38:19 +0100 "Dr. David Alan Gilbert"…
Quoted 164 lines · * Greg Kurz ([email protected]) wrote:
Quoted 148 lines · On Wed, 29 May 2019 12:18:50 +0100 "Dr. David Alan Gilbert"…
Quoted 147 lines · * Greg Kurz ([email protected]) wrote:
Quoted 126 lines · On Tue, 28 May 2019 10:08:54 +1000 David Gibson <[email protected]>…
Quoted 125 lines · Greg Kurz
Quoted 109 lines · On Mon, 20 May 2019 19:10:35 -0400 "Michael S. Tsirkin" <[email protected]> wrote:

From: Xie Yongji <[email protected]>

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.

Message-Id: <[email protected]>

---
 include/hw/virtio/virtio.h |  2 ++
 hw/virtio/virtio.c         | 52 ++++++++++++++++++++++++++++++++++++--
 2 files changed, 52 insertions(+), 2 deletions(-)
include/hw/virtio/virtio.h +2 -0
index 7140381e3a..27c0efc3d0 100644
@@ -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;
hw/virtio/virtio.c +28 -2
index 28056a7ef7..5d533ac74e 100644
@@ -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)

hw/virtio/virtio.c static bool virtio_broken_needed(void *opaque) · line 1803

Quoted 8 lines
hw/virtio/virtio.c +5 -0
@@ -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;      

Existing machine types don't know about the "virtio/started" subsection. This breaks migration to older QEMUs if the driver has started the device, ie. most probably always when it comes to live migration.

Quoted 9 lines
Quoted 6 lines

My understanding is that we do try to support backward migration though. It is a regular practice in datacenters to migrate workloads without having to take care of the QEMU version. FWIW I had to fix similar issues downstream many times in the past because customers had filed bugs.

Cc'ing David for his opinion.

Uh.. did you mean to CC me, or Dave Gilbert?

Oops... Dave Gilbert indeed, but you're thoughts on that matter are valuable as well. I remember being involved in backward migration fixes for spapr several times.

Quoted 3 lines

I mean, I think you're right that we should try to maintain backwards migration, but this isn't really my area of authority.

Quoted 8 lines
Quoted 1 line

Cc'ing Dave Gilbert :)

Right, I need to maintain backwards migration compatibility; tie the feature to a machine type so it's only used on newer machine types and then we'll be safe.

Having said that, what's the symptom when this goes wrong?

Since the started flag is set as soon as the guest driver begins to use the device and remains so until next reset, the associated subsection is basically always emitted when migrating a booted guest. This causes migration to always fail on the target in this case:

Quoted 6 lines
Quoted 2 lines

I meant what's the symptom without this patch series at all?

Oh sorry... if I got it right, migrating when the guest first kicked the device but not set the DRIVE_OK bit yet would result in a guest hang on the destination. Yongji might elaborate a bit more on that.

Hmm - the only thing worse than a migration failing with an error is a migration that fails with a hung guest.

If you were sending a new subsection in *only* the case where the guest would definitely hang, then I think it would be worth sending the subsection and allowing the backwards migration to fail with the error because it's a bit better than a hung VM.

What we cant have though is most backwards migrations failing.

Dave

Quoted 21 lines
Quoted 21 lines

Dave

Quoted 19 lines

qemu-system-ppc64: Failed to load virtio-net:virtio
qemu-system-ppc64: error while loading state for instance 0x0 of device 'pci@800000020000000:00.0/virtio-net'
qemu-system-ppc64: load of migration failed: No such file or directory

Xie Yongji has just sent a series to fix that, with you in Cc:

Cheers,

--
Greg

Quoted 8 lines

Dave

Quoted 4 lines

Cheers,

--
Greg

Quoted 6 lines
Quoted 5 lines
Quoted 3 lines
Quoted 2 lines

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#69 lore raw

Re: [Qemu-devel] [PULL v2 04/36] virtio: Introduce started flag to VirtioDevice

Quoted 178 lines · Dr. David Alan Gilbert
Quoted 169 lines · * Greg Kurz ([email protected]) wrote:
Quoted 166 lines · On Wed, 29 May 2019 13:38:19 +0100 "Dr. David Alan Gilbert"…
Quoted 164 lines · * Greg Kurz ([email protected]) wrote:
Quoted 148 lines · On Wed, 29 May 2019 12:18:50 +0100 "Dr. David Alan Gilbert"…
Quoted 147 lines · * Greg Kurz ([email protected]) wrote:
Quoted 126 lines · On Tue, 28 May 2019 10:08:54 +1000 David Gibson <[email protected]>…
Quoted 125 lines · Greg Kurz
Quoted 109 lines · On Mon, 20 May 2019 19:10:35 -0400 "Michael S. Tsirkin" <[email protected]> wrote:

From: Xie Yongji <[email protected]>

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.

Message-Id: <[email protected]>

---
 include/hw/virtio/virtio.h |  2 ++
 hw/virtio/virtio.c         | 52 ++++++++++++++++++++++++++++++++++++--
 2 files changed, 52 insertions(+), 2 deletions(-)
include/hw/virtio/virtio.h +2 -0
index 7140381e3a..27c0efc3d0 100644
@@ -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;
hw/virtio/virtio.c +28 -2
index 28056a7ef7..5d533ac74e 100644
@@ -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)

hw/virtio/virtio.c static bool virtio_broken_needed(void *opaque) · line 1803

Quoted 8 lines
hw/virtio/virtio.c +5 -0
@@ -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;

Existing machine types don't know about the "virtio/started" subsection. This breaks migration to older QEMUs if the driver has started the device, ie. most probably always when it comes to live migration.

Quoted 9 lines
Quoted 6 lines

My understanding is that we do try to support backward migration though. It is a regular practice in datacenters to migrate workloads without having to take care of the QEMU version. FWIW I had to fix similar issues downstream many times in the past because customers had filed bugs.

Cc'ing David for his opinion.

Uh.. did you mean to CC me, or Dave Gilbert?

Oops... Dave Gilbert indeed, but you're thoughts on that matter are valuable as well. I remember being involved in backward migration fixes for spapr several times.

Quoted 3 lines

I mean, I think you're right that we should try to maintain backwards migration, but this isn't really my area of authority.

Quoted 8 lines
Quoted 1 line

Cc'ing Dave Gilbert :)

Right, I need to maintain backwards migration compatibility; tie the feature to a machine type so it's only used on newer machine types and then we'll be safe.

Having said that, what's the symptom when this goes wrong?

Since the started flag is set as soon as the guest driver begins to use the device and remains so until next reset, the associated subsection is basically always emitted when migrating a booted guest. This causes migration to always fail on the target in this case:

Quoted 6 lines
Quoted 2 lines

I meant what's the symptom without this patch series at all?

Oh sorry... if I got it right, migrating when the guest first kicked the device but not set the DRIVE_OK bit yet would result in a guest hang on the destination. Yongji might elaborate a bit more on that.

Quoted 8 lines

Hmm - the only thing worse than a migration failing with an error is a migration that fails with a hung guest.

If you were sending a new subsection in *only* the case where the guest would definitely hang, then I think it would be worth sending the subsection and allowing the backwards migration to fail with the error because it's a bit better than a hung VM.

I considered this approach before. But it needs to add some complex logic in virtio code to make sure migration works well between different qemu versions. Since it's hardly to trigger the hung VM bug. So I still try to use the general way (tie the feature to a machine type) to fix this migration issue. It's easily to ensure the compatibility

Thanks,
Yongji

#70 lore raw

Re: [Qemu-devel] [PULL v2 04/36] virtio: Introduce started flag to VirtioDevice

Quoted 189 lines · * Yongji Xie ([email protected]) wrote:
Quoted 178 lines · Dr. David Alan Gilbert
Quoted 169 lines · * Greg Kurz ([email protected]) wrote:
Quoted 166 lines · On Wed, 29 May 2019 13:38:19 +0100 "Dr. David Alan Gilbert"…
Quoted 164 lines · * Greg Kurz ([email protected]) wrote:
Quoted 148 lines · On Wed, 29 May 2019 12:18:50 +0100 "Dr. David Alan Gilbert"…
Quoted 147 lines · * Greg Kurz ([email protected]) wrote:
Quoted 126 lines · On Tue, 28 May 2019 10:08:54 +1000 David Gibson <[email protected]>…
Quoted 125 lines · Greg Kurz
Quoted 109 lines · On Mon, 20 May 2019 19:10:35 -0400 "Michael S. Tsirkin" <[email protected]> wrote:

From: Xie Yongji <[email protected]>

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.

Message-Id: <[email protected]>

---
 include/hw/virtio/virtio.h |  2 ++
 hw/virtio/virtio.c         | 52 ++++++++++++++++++++++++++++++++++++--
 2 files changed, 52 insertions(+), 2 deletions(-)
include/hw/virtio/virtio.h +2 -0
index 7140381e3a..27c0efc3d0 100644
@@ -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;
hw/virtio/virtio.c +28 -2
index 28056a7ef7..5d533ac74e 100644
@@ -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)

hw/virtio/virtio.c static bool virtio_broken_needed(void *opaque) · line 1803

Quoted 8 lines
hw/virtio/virtio.c +5 -0
@@ -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;

Existing machine types don't know about the "virtio/started" subsection. This breaks migration to older QEMUs if the driver has started the device, ie. most probably always when it comes to live migration.

Quoted 9 lines
Quoted 6 lines

My understanding is that we do try to support backward migration though. It is a regular practice in datacenters to migrate workloads without having to take care of the QEMU version. FWIW I had to fix similar issues downstream many times in the past because customers had filed bugs.

Cc'ing David for his opinion.

Uh.. did you mean to CC me, or Dave Gilbert?

Oops... Dave Gilbert indeed, but you're thoughts on that matter are valuable as well. I remember being involved in backward migration fixes for spapr several times.

Quoted 3 lines

I mean, I think you're right that we should try to maintain backwards migration, but this isn't really my area of authority.

Quoted 8 lines
Quoted 1 line

Cc'ing Dave Gilbert :)

Right, I need to maintain backwards migration compatibility; tie the feature to a machine type so it's only used on newer machine types and then we'll be safe.

Having said that, what's the symptom when this goes wrong?

Since the started flag is set as soon as the guest driver begins to use the device and remains so until next reset, the associated subsection is basically always emitted when migrating a booted guest. This causes migration to always fail on the target in this case:

Quoted 6 lines
Quoted 2 lines

I meant what's the symptom without this patch series at all?

Oh sorry... if I got it right, migrating when the guest first kicked the device but not set the DRIVE_OK bit yet would result in a guest hang on the destination. Yongji might elaborate a bit more on that.

Quoted 8 lines

Hmm - the only thing worse than a migration failing with an error is a migration that fails with a hung guest.

If you were sending a new subsection in *only* the case where the guest would definitely hang, then I think it would be worth sending the subsection and allowing the backwards migration to fail with the error because it's a bit better than a hung VM.

Quoted 6 lines

I considered this approach before. But it needs to add some complex logic in virtio code to make sure migration works well between different qemu versions. Since it's hardly to trigger the hung VM bug. So I still try to use the general way (tie the feature to a machine type) to fix this migration issue. It's easily to ensure the compatibility

OK, great. For reference could you give me a bit more info on how exactly the failure happens, how you spot it and what the symptoms are; so that when someone comes to me with a hung VM I know what to look for?

Dave

Quoted 2 lines

Thanks,
Yongji

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#71 lore raw

Re: [Qemu-devel] [PULL v2 04/36] virtio: Introduce started flag to VirtioDevice

Quoted 198 lines · Dr. David Alan Gilbert
Quoted 189 lines · * Yongji Xie ([email protected]) wrote:
Quoted 178 lines · Dr. David Alan Gilbert
Quoted 169 lines · * Greg Kurz ([email protected]) wrote:
Quoted 166 lines · On Wed, 29 May 2019 13:38:19 +0100 "Dr. David Alan Gilbert"…
Quoted 164 lines · * Greg Kurz ([email protected]) wrote:
Quoted 148 lines · On Wed, 29 May 2019 12:18:50 +0100 "Dr. David Alan Gilbert"…
Quoted 147 lines · * Greg Kurz ([email protected]) wrote:
Quoted 126 lines · On Tue, 28 May 2019 10:08:54 +1000 David Gibson <[email protected]>…
Quoted 125 lines · Greg Kurz
Quoted 109 lines · On Mon, 20 May 2019 19:10:35 -0400 "Michael S. Tsirkin" <[email protected]> wrote:

From: Xie Yongji <[email protected]>

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.

Message-Id: <[email protected]>

---
 include/hw/virtio/virtio.h |  2 ++
 hw/virtio/virtio.c         | 52 ++++++++++++++++++++++++++++++++++++--
 2 files changed, 52 insertions(+), 2 deletions(-)
include/hw/virtio/virtio.h +2 -0
index 7140381e3a..27c0efc3d0 100644
@@ -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;
hw/virtio/virtio.c +28 -2
index 28056a7ef7..5d533ac74e 100644
@@ -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)

hw/virtio/virtio.c static bool virtio_broken_needed(void *opaque) · line 1803

Quoted 8 lines
hw/virtio/virtio.c +5 -0
@@ -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;

Existing machine types don't know about the "virtio/started" subsection. This breaks migration to older QEMUs if the driver has started the device, ie. most probably always when it comes to live migration.

Quoted 9 lines
Quoted 6 lines

My understanding is that we do try to support backward migration though. It is a regular practice in datacenters to migrate workloads without having to take care of the QEMU version. FWIW I had to fix similar issues downstream many times in the past because customers had filed bugs.

Cc'ing David for his opinion.

Uh.. did you mean to CC me, or Dave Gilbert?

Oops... Dave Gilbert indeed, but you're thoughts on that matter are valuable as well. I remember being involved in backward migration fixes for spapr several times.

Quoted 3 lines

I mean, I think you're right that we should try to maintain backwards migration, but this isn't really my area of authority.

Quoted 8 lines
Quoted 1 line

Cc'ing Dave Gilbert :)

Right, I need to maintain backwards migration compatibility; tie the feature to a machine type so it's only used on newer machine types and then we'll be safe.

Having said that, what's the symptom when this goes wrong?

Since the started flag is set as soon as the guest driver begins to use the device and remains so until next reset, the associated subsection is basically always emitted when migrating a booted guest. This causes migration to always fail on the target in this case:

Quoted 6 lines
Quoted 2 lines

I meant what's the symptom without this patch series at all?

Oh sorry... if I got it right, migrating when the guest first kicked the device but not set the DRIVE_OK bit yet would result in a guest hang on the destination. Yongji might elaborate a bit more on that.

Quoted 8 lines

Hmm - the only thing worse than a migration failing with an error is a migration that fails with a hung guest.

If you were sending a new subsection in *only* the case where the guest would definitely hang, then I think it would be worth sending the subsection and allowing the backwards migration to fail with the error because it's a bit better than a hung VM.

Quoted 6 lines

I considered this approach before. But it needs to add some complex logic in virtio code to make sure migration works well between different qemu versions. Since it's hardly to trigger the hung VM bug. So I still try to use the general way (tie the feature to a machine type) to fix this migration issue. It's easily to ensure the compatibility

Quoted 4 lines

OK, great. For reference could you give me a bit more info on how exactly the failure happens, how you spot it and what the symptoms are; so that when someone comes to me with a hung VM I know what to look for?

Oh, sure. This failure would only happen on an old guest (e.g. centos 6u5, centos 6u3) with virtio-blk/vhost-user-blk device. This kind of guest might be hung when migration completes at the point that guest is booting (loading virtio-blk driver) because its first I/O would be hung.

Thanks,
Yongji

#72 lore raw

Re: [Qemu-devel] [PULL v2 04/36] virtio: Introduce started flag to VirtioDevice

Quoted 205 lines · * Yongji Xie ([email protected]) wrote:
Quoted 198 lines · Dr. David Alan Gilbert
Quoted 189 lines · * Yongji Xie ([email protected]) wrote:
Quoted 178 lines · Dr. David Alan Gilbert
Quoted 169 lines · * Greg Kurz ([email protected]) wrote:
Quoted 166 lines · On Wed, 29 May 2019 13:38:19 +0100 "Dr. David Alan Gilbert"…
Quoted 164 lines · * Greg Kurz ([email protected]) wrote:
Quoted 148 lines · On Wed, 29 May 2019 12:18:50 +0100 "Dr. David Alan Gilbert"…
Quoted 147 lines · * Greg Kurz ([email protected]) wrote:
Quoted 126 lines · On Tue, 28 May 2019 10:08:54 +1000 David Gibson <[email protected]>…
Quoted 125 lines · Greg Kurz
Quoted 109 lines · On Mon, 20 May 2019 19:10:35 -0400 "Michael S. Tsirkin" <[email protected]> wrote:

From: Xie Yongji <[email protected]>

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.

Message-Id: <[email protected]>

---
 include/hw/virtio/virtio.h |  2 ++
 hw/virtio/virtio.c         | 52 ++++++++++++++++++++++++++++++++++++--
 2 files changed, 52 insertions(+), 2 deletions(-)
include/hw/virtio/virtio.h +2 -0
index 7140381e3a..27c0efc3d0 100644
@@ -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;
hw/virtio/virtio.c +28 -2
index 28056a7ef7..5d533ac74e 100644
@@ -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)

hw/virtio/virtio.c static bool virtio_broken_needed(void *opaque) · line 1803

Quoted 8 lines
hw/virtio/virtio.c +5 -0
@@ -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;

Existing machine types don't know about the "virtio/started" subsection. This breaks migration to older QEMUs if the driver has started the device, ie. most probably always when it comes to live migration.

Quoted 9 lines
Quoted 6 lines

My understanding is that we do try to support backward migration though. It is a regular practice in datacenters to migrate workloads without having to take care of the QEMU version. FWIW I had to fix similar issues downstream many times in the past because customers had filed bugs.

Cc'ing David for his opinion.

Uh.. did you mean to CC me, or Dave Gilbert?

Oops... Dave Gilbert indeed, but you're thoughts on that matter are valuable as well. I remember being involved in backward migration fixes for spapr several times.

Quoted 3 lines

I mean, I think you're right that we should try to maintain backwards migration, but this isn't really my area of authority.

Quoted 8 lines
Quoted 1 line

Cc'ing Dave Gilbert :)

Right, I need to maintain backwards migration compatibility; tie the feature to a machine type so it's only used on newer machine types and then we'll be safe.

Having said that, what's the symptom when this goes wrong?

Since the started flag is set as soon as the guest driver begins to use the device and remains so until next reset, the associated subsection is basically always emitted when migrating a booted guest. This causes migration to always fail on the target in this case:

Quoted 6 lines
Quoted 2 lines

I meant what's the symptom without this patch series at all?

Oh sorry... if I got it right, migrating when the guest first kicked the device but not set the DRIVE_OK bit yet would result in a guest hang on the destination. Yongji might elaborate a bit more on that.

Quoted 8 lines

Hmm - the only thing worse than a migration failing with an error is a migration that fails with a hung guest.

If you were sending a new subsection in *only* the case where the guest would definitely hang, then I think it would be worth sending the subsection and allowing the backwards migration to fail with the error because it's a bit better than a hung VM.

Quoted 6 lines

I considered this approach before. But it needs to add some complex logic in virtio code to make sure migration works well between different qemu versions. Since it's hardly to trigger the hung VM bug. So I still try to use the general way (tie the feature to a machine type) to fix this migration issue. It's easily to ensure the compatibility

Quoted 4 lines

OK, great. For reference could you give me a bit more info on how exactly the failure happens, how you spot it and what the symptoms are; so that when someone comes to me with a hung VM I know what to look for?

Quoted 5 lines

Oh, sure. This failure would only happen on an old guest (e.g. centos 6u5, centos 6u3) with virtio-blk/vhost-user-blk device. This kind of guest might be hung when migration completes at the point that guest is booting (loading virtio-blk driver) because its first I/O would be hung.

OK, thanks.
But a migration when the VM is running is fine? - it's only a problem if it happens during bootup, before the driver starts?

Dave

Quoted 2 lines

Thanks,
Yongji

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#73 lore raw

Re: [Qemu-devel] [PULL v2 04/36] virtio: Introduce started flag to VirtioDevice

Quoted 213 lines · Dr. David Alan Gilbert
Quoted 205 lines · * Yongji Xie ([email protected]) wrote:
Quoted 198 lines · Dr. David Alan Gilbert
Quoted 189 lines · * Yongji Xie ([email protected]) wrote:
Quoted 178 lines · Dr. David Alan Gilbert
Quoted 169 lines · * Greg Kurz ([email protected]) wrote:
Quoted 166 lines · On Wed, 29 May 2019 13:38:19 +0100 "Dr. David Alan Gilbert"…
Quoted 164 lines · * Greg Kurz ([email protected]) wrote:
Quoted 148 lines · On Wed, 29 May 2019 12:18:50 +0100 "Dr. David Alan Gilbert"…
Quoted 147 lines · * Greg Kurz ([email protected]) wrote:
Quoted 126 lines · On Tue, 28 May 2019 10:08:54 +1000 David Gibson <[email protected]>…
Quoted 125 lines · Greg Kurz
Quoted 117 lines · On Mon, 20 May 2019 19:10:35 -0400 "Michael S. Tsirkin" <[email protected]> wrote:

From: Xie Yongji <[email protected]>

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 <[email protected]>
Signed-off-by: Zhang Yu <[email protected]>
Message-Id: <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
---
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 7140381e3a..27c0efc3d0 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 28056a7ef7..5d533ac74e 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;

Existing machine types don't know about the "virtio/started" subsection. This breaks migration to older QEMUs if the driver has started the device, ie. most probably always when it comes to live migration.

Quoted 9 lines
Quoted 6 lines

My understanding is that we do try to support backward migration though. It is a regular practice in datacenters to migrate workloads without having to take care of the QEMU version. FWIW I had to fix similar issues downstream many times in the past because customers had filed bugs.

Cc'ing David for his opinion.

Uh.. did you mean to CC me, or Dave Gilbert?

Oops... Dave Gilbert indeed, but you're thoughts on that matter are valuable as well. I remember being involved in backward migration fixes for spapr several times.

Quoted 3 lines

I mean, I think you're right that we should try to maintain backwards migration, but this isn't really my area of authority.

Quoted 8 lines
Quoted 1 line

Cc'ing Dave Gilbert :)

Right, I need to maintain backwards migration compatibility; tie the feature to a machine type so it's only used on newer machine types and then we'll be safe.

Having said that, what's the symptom when this goes wrong?

Since the started flag is set as soon as the guest driver begins to use the device and remains so until next reset, the associated subsection is basically always emitted when migrating a booted guest. This causes migration to always fail on the target in this case:

Quoted 6 lines
Quoted 2 lines

I meant what's the symptom without this patch series at all?

Oh sorry... if I got it right, migrating when the guest first kicked the device but not set the DRIVE_OK bit yet would result in a guest hang on the destination. Yongji might elaborate a bit more on that.

Quoted 8 lines

Hmm - the only thing worse than a migration failing with an error is a migration that fails with a hung guest.

If you were sending a new subsection in *only* the case where the guest would definitely hang, then I think it would be worth sending the subsection and allowing the backwards migration to fail with the error because it's a bit better than a hung VM.

Quoted 6 lines

I considered this approach before. But it needs to add some complex logic in virtio code to make sure migration works well between different qemu versions. Since it's hardly to trigger the hung VM bug. So I still try to use the general way (tie the feature to a machine type) to fix this migration issue. It's easily to ensure the compatibility

Quoted 4 lines

OK, great. For reference could you give me a bit more info on how exactly the failure happens, how you spot it and what the symptoms are; so that when someone comes to me with a hung VM I know what to look for?

Quoted 5 lines

Oh, sure. This failure would only happen on an old guest (e.g. centos 6u5, centos 6u3) with virtio-blk/vhost-user-blk device. This kind of guest might be hung when migration completes at the point that guest is booting (loading virtio-blk driver) because its first I/O would be hung.

Quoted 4 lines

OK, thanks.
But a migration when the VM is running is fine? - it's only a problem if it happens during bootup, before the driver starts?

Yes. Running VM would be fine unless we reload the driver manually at that point...

Thanks,
Yongji

#74 lore raw

Re: [Qemu-devel] [PULL v2 04/36] virtio: Introduce started flag to VirtioDevice

Quoted 215 lines · * Yongji Xie ([email protected]) wrote:
Quoted 213 lines · Dr. David Alan Gilbert
Quoted 210 lines · * Yongji Xie ([email protected]) wrote:
Quoted 198 lines · Dr. David Alan Gilbert
Quoted 189 lines · * Yongji Xie ([email protected]) wrote:
Quoted 178 lines · Dr. David Alan Gilbert
Quoted 169 lines · * Greg Kurz ([email protected]) wrote:
Quoted 166 lines · On Wed, 29 May 2019 13:38:19 +0100 "Dr. David Alan Gilbert"…
Quoted 164 lines · * Greg Kurz ([email protected]) wrote:
Quoted 148 lines · On Wed, 29 May 2019 12:18:50 +0100 "Dr. David Alan Gilbert"…
Quoted 147 lines · * Greg Kurz ([email protected]) wrote:
Quoted 126 lines · On Tue, 28 May 2019 10:08:54 +1000 David Gibson <[email protected]>…
Quoted 125 lines · Greg Kurz

On Mon, 20 May 2019 19:10:35 -0400
"Michael S. Tsirkin" <[email protected]> wrote:

From: Xie Yongji <[email protected]>

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 <[email protected]>
Signed-off-by: Zhang Yu <[email protected]>
Message-Id: <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
---
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 7140381e3a..27c0efc3d0 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 28056a7ef7..5d533ac74e 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;

Existing machine types don't know about the "virtio/started" subsection. This
breaks migration to older QEMUs if the driver has started the device, ie. most
probably always when it comes to live migration.

Quoted 9 lines
Quoted 6 lines

My understanding is that we do try to support backward migration though. It
is a regular practice in datacenters to migrate workloads without having to
take care of the QEMU version. FWIW I had to fix similar issues downstream
many times in the past because customers had filed bugs.

Cc'ing David for his opinion.

Uh.. did you mean to CC me, or Dave Gilbert?

Oops... Dave Gilbert indeed, but you're thoughts on that matter are valuable as well. I remember being involved in backward migration fixes for spapr several times.

Quoted 3 lines

I mean, I think you're right that we should try to maintain backwards migration, but this isn't really my area of authority.

Quoted 8 lines
Quoted 1 line

Cc'ing Dave Gilbert :)

Right, I need to maintain backwards migration compatibility; tie the feature to a machine type so it's only used on newer machine types and then we'll be safe.

Having said that, what's the symptom when this goes wrong?

Since the started flag is set as soon as the guest driver begins to use the device and remains so until next reset, the associated subsection is basically always emitted when migrating a booted guest. This causes migration to always fail on the target in this case:

Quoted 6 lines
Quoted 2 lines

I meant what's the symptom without this patch series at all?

Oh sorry... if I got it right, migrating when the guest first kicked the device but not set the DRIVE_OK bit yet would result in a guest hang on the destination. Yongji might elaborate a bit more on that.

Quoted 8 lines

Hmm - the only thing worse than a migration failing with an error is a migration that fails with a hung guest.

If you were sending a new subsection in *only* the case where the guest would definitely hang, then I think it would be worth sending the subsection and allowing the backwards migration to fail with the error because it's a bit better than a hung VM.

Quoted 6 lines

I considered this approach before. But it needs to add some complex logic in virtio code to make sure migration works well between different qemu versions. Since it's hardly to trigger the hung VM bug. So I still try to use the general way (tie the feature to a machine type) to fix this migration issue. It's easily to ensure the compatibility

Quoted 4 lines

OK, great. For reference could you give me a bit more info on how exactly the failure happens, how you spot it and what the symptoms are; so that when someone comes to me with a hung VM I know what to look for?

Oh, sure. This failure would only happen on an old guest (e.g. centos 6u5, centos 6u3) with virtio-blk/vhost-user-blk device. This kind of guest might be hung when migration completes at the point that guest is booting (loading virtio-blk driver) because its first I/O would be hung.

Quoted 7 lines
Quoted 4 lines

OK, thanks.
But a migration when the VM is running is fine? - it's only a problem if it happens during bootup, before the driver starts?

Yes. Running VM would be fine unless we reload the driver manually at that point...

OK, thanks.

Dave

Quoted 2 lines

Thanks,
Yongji

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#75 lore raw

Re: [Qemu-devel] [PULL v2 04/36] virtio: Introduce started flag to VirtioDevice

In reply to Greg Kurz
Quoted 170 lines · Greg Kurz
Quoted 166 lines · On Wed, 29 May 2019 13:38:19 +0100 "Dr. David Alan Gilbert"…
Quoted 164 lines · * Greg Kurz ([email protected]) wrote:
Quoted 148 lines · On Wed, 29 May 2019 12:18:50 +0100 "Dr. David Alan Gilbert"…
Quoted 147 lines · * Greg Kurz ([email protected]) wrote:
Quoted 126 lines · On Tue, 28 May 2019 10:08:54 +1000 David Gibson <[email protected]>…
Quoted 125 lines · Greg Kurz
Quoted 109 lines · On Mon, 20 May 2019 19:10:35 -0400 "Michael S. Tsirkin" <[email protected]> wrote:

From: Xie Yongji <[email protected]>

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.

Message-Id: <[email protected]>

---
 include/hw/virtio/virtio.h |  2 ++
 hw/virtio/virtio.c         | 52 ++++++++++++++++++++++++++++++++++++--
 2 files changed, 52 insertions(+), 2 deletions(-)
include/hw/virtio/virtio.h +2 -0
index 7140381e3a..27c0efc3d0 100644
@@ -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;
hw/virtio/virtio.c +28 -2
index 28056a7ef7..5d533ac74e 100644
@@ -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)

hw/virtio/virtio.c static bool virtio_broken_needed(void *opaque) · line 1803

Quoted 8 lines
hw/virtio/virtio.c +5 -0
@@ -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;

Existing machine types don't know about the "virtio/started" subsection. This breaks migration to older QEMUs if the driver has started the device, ie. most probably always when it comes to live migration.

Quoted 9 lines
Quoted 6 lines

My understanding is that we do try to support backward migration though. It is a regular practice in datacenters to migrate workloads without having to take care of the QEMU version. FWIW I had to fix similar issues downstream many times in the past because customers had filed bugs.

Cc'ing David for his opinion.

Uh.. did you mean to CC me, or Dave Gilbert?

Oops... Dave Gilbert indeed, but you're thoughts on that matter are valuable as well. I remember being involved in backward migration fixes for spapr several times.

Quoted 3 lines

I mean, I think you're right that we should try to maintain backwards migration, but this isn't really my area of authority.

Quoted 8 lines
Quoted 1 line

Cc'ing Dave Gilbert :)

Right, I need to maintain backwards migration compatibility; tie the feature to a machine type so it's only used on newer machine types and then we'll be safe.

Having said that, what's the symptom when this goes wrong?

Since the started flag is set as soon as the guest driver begins to use the device and remains so until next reset, the associated subsection is basically always emitted when migrating a booted guest. This causes migration to always fail on the target in this case:

Quoted 7 lines
Quoted 2 lines

I meant what's the symptom without this patch series at all?

Oh sorry... if I got it right, migrating when the guest first kicked the device but not set the DRIVE_OK bit yet would result in a guest hang on the destination. Yongji might elaborate a bit more on that.

Yes, that's the issue that my patch tries to fix. It only happens in a short window for virtio 1.0 transitional devices.

Thanks,
Yongji

#76 lore raw

[Qemu-devel] [PULL 09/37] vhost-user-blk: Add support to reconnect backend

In reply to Michael S. Tsirkin

From: Xie Yongji <[email protected]>

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.

Message-Id: <[email protected]>

---
 include/hw/virtio/vhost-user-blk.h |   3 +
 hw/block/vhost-user-blk.c          | 159 ++++++++++++++++++++++++-----
 2 files changed, 139 insertions(+), 23 deletions(-)
include/hw/virtio/vhost-user-blk.h +3 -0
index 68634bee61..51457fb857 100644
@@ -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
hw/block/vhost-user-blk.c +136 -23

232 lines not on this page · raw message

Signature · 1 line
MST
#77 lore raw

[Qemu-devel] [PULL 10/37] contrib/vhost-user-blk: enable inflight I/O tracking

In reply to Michael S. Tsirkin

From: Xie Yongji <[email protected]>

This patch enables inflight I/O tracking for vhost-user-blk backend so that we could restart it safely.

Message-Id: <[email protected]>

---
 contrib/vhost-user-blk/vhost-user-blk.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
contrib/vhost-user-blk/vhost-user-blk.c +2 -1
index 43583f2659..86a3987744 100644
@@ -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
Signature · 1 line
MST
#78 lore raw

[Qemu-devel] [PULL 07/37] vhost-user-blk: Only start vhost-user backend with the first kick

In reply to Michael S. Tsirkin

From: Xie Yongji <[email protected]>

We should only start vhost-user backend at the first kick for virtio 1.0 transitional devices.

Message-Id: <[email protected]>

---
 hw/block/vhost-user-blk.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
hw/block/vhost-user-blk.c +1 -2
index 700c1dd111..39e1adc60a 100644
@@ -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;
     }
 
Signature · 1 line
MST
#79 lore raw

Re: [Qemu-devel] [PULL 00/37] pci, pc, virtio: features, fixes

In reply to Michael S. Tsirkin
Quoted 16 lines · Michael S. Tsirkin

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

Quoted 7 lines

reconnect for vhost blk
tests for UEFI
misc other stuff

----------------------------------------------------------------

Hi -- this pullreq has a conflict in default-configs/arm-softmmu.mak because the conversion of arm to Kconfig has landed in master. Could you rebase and fix up to use whatever the Kconfig equivalent of these changes is, please?

thanks
-- PMM

#80 lore raw

Re: [Qemu-devel] [PULL 00/37] pci, pc, virtio: features, fixes

Quoted 21 lines · Peter Maydell
Quoted 20 lines · Michael S. Tsirkin

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

Quoted 8 lines
Quoted 3 lines

----------------------------------------------------------------

Hi -- this pullreq has a conflict in default-configs/arm-softmmu.mak because the conversion of arm to Kconfig has landed in master. Could you rebase and fix up to use whatever the Kconfig equivalent of these changes is, please?

Culprit is "hw/acpi: Consolidate build_mcfg to pci.c"

The conflict doesn't look trivial to resolve (to me) so I'd rather see it reviewed (by Thomas). I suggest to drop the patch(es) from your PR :(

Regards,

Phil.

#81 lore raw

Re: [Qemu-devel] [PULL 00/37] pci, pc, virtio: features, fixes

Quoted 31 lines · Philippe Mathieu-Daudé
Quoted 21 lines · Peter Maydell
Quoted 20 lines · Michael S. Tsirkin

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

Quoted 8 lines
Quoted 3 lines

----------------------------------------------------------------

Hi -- this pullreq has a conflict in default-configs/arm-softmmu.mak because the conversion of arm to Kconfig has landed in master. Could you rebase and fix up to use whatever the Kconfig equivalent of these changes is, please?

Quoted 4 lines

Culprit is "hw/acpi: Consolidate build_mcfg to pci.c"

The conflict doesn't look trivial to resolve (to me) so I'd rather see it reviewed (by Thomas). I suggest to drop the patch(es) from your PR :(

Thomas, FYI I did this to resolve the conflict:

- keep default-configs/arm-softmmu.mak from master:

git checkout origin/master default-configs/arm-softmmu.mak

- applied the following !fixup snippet:

-- >8 --

hw/acpi/Kconfig +1 -2
@@ -25,7 +25,7 @@ config ACPI_NVDIMM
 
 config ACPI_PCI
     bool
-    depends on ACPI
+    depends on ACPI && PCI
 
---
 

I felt it easier to review on top of "hw/acpi: Improve build modularity"
https://lists.gnu.org/archive/html/qemu-devel/2019-04/msg04718.html

Sadly both series clash :(

Regards,

Phil.

#82 lore raw

Re: [Qemu-devel] [PULL 00/37] pci, pc, virtio: features, fixes

Quoted 53 lines · Philippe Mathieu-Daudé
Quoted 31 lines · Philippe Mathieu-Daudé
Quoted 21 lines · Peter Maydell
Quoted 20 lines · Michael S. Tsirkin

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

Quoted 8 lines
Quoted 3 lines

----------------------------------------------------------------

Hi -- this pullreq has a conflict in default-configs/arm-softmmu.mak because the conversion of arm to Kconfig has landed in master. Could you rebase and fix up to use whatever the Kconfig equivalent of these changes is, please?

Quoted 4 lines

Culprit is "hw/acpi: Consolidate build_mcfg to pci.c"

The conflict doesn't look trivial to resolve (to me) so I'd rather see it reviewed (by Thomas). I suggest to drop the patch(es) from your PR :(

Thomas, FYI I did this to resolve the conflict:

- keep default-configs/arm-softmmu.mak from master:

git checkout origin/master default-configs/arm-softmmu.mak

- applied the following !fixup snippet:

-- >8 --

hw/acpi/Kconfig +0 -0
@@ -25,7 +25,7 @@ config ACPI_NVDIMM
 

config ACPI_PCI
bool

hw/acpi/Kconfig config ACPI_NVDIMM · line 28

Quoted 2 lines
hw/acpi/Kconfig +1 -1
-    depends on ACPI
+    depends on ACPI && PCI

Take a look into hw/arm/Kconfig. Only ARM_VIRT selects ACPI, but this one doesn't select PCI.

Which option on arm select both?

Quoted 11 lines

---

I felt it easier to review on top of "hw/acpi: Improve build modularity"
https://lists.gnu.org/archive/html/qemu-devel/2019-04/msg04718.html

Sadly both series clash :(

Regards,

Phil.

Signature · 2 lines
Wei Yang
Help you, Help me
#83 lore raw

Re: [Qemu-devel] [PULL 00/37] pci, pc, virtio: features, fixes

Quoted 60 lines · Wei Yang
Quoted 53 lines · Philippe Mathieu-Daudé
Quoted 31 lines · Philippe Mathieu-Daudé
Quoted 21 lines · Peter Maydell
Quoted 20 lines · Michael S. Tsirkin

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

Quoted 8 lines
Quoted 3 lines

----------------------------------------------------------------

Hi -- this pullreq has a conflict in default-configs/arm-softmmu.mak because the conversion of arm to Kconfig has landed in master. Could you rebase and fix up to use whatever the Kconfig equivalent of these changes is, please?

Quoted 4 lines

Culprit is "hw/acpi: Consolidate build_mcfg to pci.c"

The conflict doesn't look trivial to resolve (to me) so I'd rather see it reviewed (by Thomas). I suggest to drop the patch(es) from your PR :(

Thomas, FYI I did this to resolve the conflict:

- keep default-configs/arm-softmmu.mak from master:

git checkout origin/master default-configs/arm-softmmu.mak

- applied the following !fixup snippet:

-- >8 --

hw/acpi/Kconfig +0 -0
@@ -25,7 +25,7 @@ config ACPI_NVDIMM
 

config ACPI_PCI
bool

hw/acpi/Kconfig config ACPI_NVDIMM · line 28

Quoted 2 lines
hw/acpi/Kconfig +1 -1
-    depends on ACPI
+    depends on ACPI && PCI

Take a look into hw/arm/Kconfig. Only ARM_VIRT selects ACPI, but this one doesn't select PCI.

Quoted 1 line

Which option on arm select both?

ARM_VIRT -> ACPI
ARM_VIRT -> PCI_EXPRESS -> PCI

Maybe the correct Kconfig is:

config ACPI_PCI

    bool
    default y if ACPI && PCI

Paolo/Thomas?

#84 lore raw

Re: [Qemu-devel] [PULL 00/37] pci, pc, virtio: features, fixes

Quoted 66 lines · Philippe Mathieu-Daudé
Quoted 60 lines · Wei Yang
Quoted 53 lines · Philippe Mathieu-Daudé
Quoted 31 lines · Philippe Mathieu-Daudé
Quoted 21 lines · Peter Maydell
Quoted 20 lines · Michael S. Tsirkin

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

Quoted 8 lines
Quoted 3 lines

----------------------------------------------------------------

Hi -- this pullreq has a conflict in default-configs/arm-softmmu.mak because the conversion of arm to Kconfig has landed in master. Could you rebase and fix up to use whatever the Kconfig equivalent of these changes is, please?

Quoted 4 lines

Culprit is "hw/acpi: Consolidate build_mcfg to pci.c"

The conflict doesn't look trivial to resolve (to me) so I'd rather see it reviewed (by Thomas). I suggest to drop the patch(es) from your PR :(

Thomas, FYI I did this to resolve the conflict:

- keep default-configs/arm-softmmu.mak from master:

git checkout origin/master default-configs/arm-softmmu.mak

- applied the following !fixup snippet:

-- >8 --

hw/acpi/Kconfig +0 -0
@@ -25,7 +25,7 @@ config ACPI_NVDIMM
 

config ACPI_PCI
bool

hw/acpi/Kconfig config ACPI_NVDIMM · line 28

Quoted 2 lines
hw/acpi/Kconfig +1 -1
-    depends on ACPI
+    depends on ACPI && PCI

Take a look into hw/arm/Kconfig. Only ARM_VIRT selects ACPI, but this one doesn't select PCI.

Quoted 1 line

Which option on arm select both?

ARM_VIRT -> ACPI
ARM_VIRT -> PCI_EXPRESS -> PCI

Quoted 7 lines

Maybe the correct Kconfig is:

config ACPI_PCI

    bool
    default y if ACPI && PCI

Paolo/Thomas?

Is it optional for the virt machine? If yes, "default y if ACPI && PCI" is fine. If not, the virt machine should "select ACPI_PCI" explicitly.

Thomas

#85 lore raw

Re: [Qemu-devel] [PULL 00/37] pci, pc, virtio: features, fixes

Quoted 69 lines · Thomas Huth
Quoted 68 lines · Philippe Mathieu-Daudé
Quoted 60 lines · Wei Yang
Quoted 53 lines · Philippe Mathieu-Daudé
Quoted 31 lines · Philippe Mathieu-Daudé
Quoted 21 lines · Peter Maydell
Quoted 20 lines · Michael S. Tsirkin

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

Quoted 8 lines
Quoted 3 lines

----------------------------------------------------------------

Hi -- this pullreq has a conflict in default-configs/arm-softmmu.mak because the conversion of arm to Kconfig has landed in master. Could you rebase and fix up to use whatever the Kconfig equivalent of these changes is, please?

Quoted 4 lines

Culprit is "hw/acpi: Consolidate build_mcfg to pci.c"

The conflict doesn't look trivial to resolve (to me) so I'd rather see it reviewed (by Thomas). I suggest to drop the patch(es) from your PR :(

Thomas, FYI I did this to resolve the conflict:

- keep default-configs/arm-softmmu.mak from master:

git checkout origin/master default-configs/arm-softmmu.mak

- applied the following !fixup snippet:

-- >8 --

hw/acpi/Kconfig +0 -0
@@ -25,7 +25,7 @@ config ACPI_NVDIMM
 

config ACPI_PCI
bool

hw/acpi/Kconfig config ACPI_NVDIMM · line 28

Quoted 2 lines
hw/acpi/Kconfig +1 -1
-    depends on ACPI
+    depends on ACPI && PCI

Take a look into hw/arm/Kconfig. Only ARM_VIRT selects ACPI, but this one doesn't select PCI.

Quoted 1 line

Which option on arm select both?

ARM_VIRT -> ACPI
ARM_VIRT -> PCI_EXPRESS -> PCI

Maybe the correct Kconfig is:

Quoted 8 lines
Quoted 5 lines

config ACPI_PCI

    bool
    default y if ACPI && PCI

Paolo/Thomas?

Is it optional for the virt machine? If yes, "default y if ACPI && PCI" is fine. If not, the virt machine should "select ACPI_PCI" explicitly.

Yes, you are correct, we need 2 changes:

config ARM_VIRT

    ...
    select ACPI_PCI

config ACPI_PCI

    bool
    depends on ACPI && PCI
#86 lore raw

Re: [Qemu-devel] [PULL 00/37] pci, pc, virtio: features, fixes

In reply to Philippe Mathieu-Daudé
Quoted 58 lines · Philippe Mathieu-Daudé
Quoted 31 lines · Philippe Mathieu-Daudé
Quoted 21 lines · Peter Maydell
Quoted 20 lines · Michael S. Tsirkin

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

Quoted 8 lines
Quoted 3 lines

----------------------------------------------------------------

Hi -- this pullreq has a conflict in default-configs/arm-softmmu.mak because the conversion of arm to Kconfig has landed in master. Could you rebase and fix up to use whatever the Kconfig equivalent of these changes is, please?

Quoted 4 lines

Culprit is "hw/acpi: Consolidate build_mcfg to pci.c"

The conflict doesn't look trivial to resolve (to me) so I'd rather see it reviewed (by Thomas). I suggest to drop the patch(es) from your PR :(

Thomas, FYI I did this to resolve the conflict:

- keep default-configs/arm-softmmu.mak from master:

git checkout origin/master default-configs/arm-softmmu.mak

- applied the following !fixup snippet:

-- >8 --

hw/acpi/Kconfig +0 -0
@@ -25,7 +25,7 @@ config ACPI_NVDIMM
 

config ACPI_PCI
bool

hw/acpi/Kconfig +1 -2
-    depends on ACPI
+    depends on ACPI && PCI
 
---
Quoted 3 lines

I felt it easier to review on top of "hw/acpi: Improve build modularity"
https://lists.gnu.org/archive/html/qemu-devel/2019-04/msg04718.html

Well, I hope this will not block the merge.

I took a look in the change of default-configs/arm-softmmu.mak. The general idea from Thomas is put those hard-coded config to Kconfig.

This is fine and what I need to change in my patch is to select ACPI_PCI in the proper place, if my understanding is correct.

Two things I need to fix:

* add select ACPI_PCI in proper place of hw/arm/Kconfig
* add a dummy build_mcfg() for link when ACPI_PCI is not configured.

Then I have two questions:

* In hw/arm/Kconfig, I don't see one option contains both PCI and ACPI. I am confused where to put the select.
* put dummy build_mcfg() in aml-build.c works. Igor, do you like this? Or you haver other preference?

Quoted 5 lines

Sadly both series clash :(

Regards,

Phil.

Signature · 2 lines
Wei Yang
Help you, Help me
#87 lore raw

Re: [Qemu-devel] [PULL 00/37] pci, pc, virtio: features, fixes

Quoted 76 lines · Wei Yang
Quoted 58 lines · Philippe Mathieu-Daudé
Quoted 31 lines · Philippe Mathieu-Daudé
Quoted 21 lines · Peter Maydell
Quoted 20 lines · Michael S. Tsirkin

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

Quoted 8 lines
Quoted 3 lines

----------------------------------------------------------------

Hi -- this pullreq has a conflict in default-configs/arm-softmmu.mak because the conversion of arm to Kconfig has landed in master. Could you rebase and fix up to use whatever the Kconfig equivalent of these changes is, please?

Quoted 4 lines

Culprit is "hw/acpi: Consolidate build_mcfg to pci.c"

The conflict doesn't look trivial to resolve (to me) so I'd rather see it reviewed (by Thomas). I suggest to drop the patch(es) from your PR :(

Thomas, FYI I did this to resolve the conflict:

- keep default-configs/arm-softmmu.mak from master:

git checkout origin/master default-configs/arm-softmmu.mak

- applied the following !fixup snippet:

-- >8 --

hw/acpi/Kconfig +0 -0
@@ -25,7 +25,7 @@ config ACPI_NVDIMM
 

config ACPI_PCI
bool

hw/acpi/Kconfig +1 -2
-    depends on ACPI
+    depends on ACPI && PCI
 
---
Quoted 3 lines

I felt it easier to review on top of "hw/acpi: Improve build modularity"
https://lists.gnu.org/archive/html/qemu-devel/2019-04/msg04718.html

Well, I hope this will not block the merge.

I took a look in the change of default-configs/arm-softmmu.mak. The general idea from Thomas is put those hard-coded config to Kconfig.

This is fine and what I need to change in my patch is to select ACPI_PCI in the proper place, if my understanding is correct.

Two things I need to fix:

* add select ACPI_PCI in proper place of hw/arm/Kconfig
* add a dummy build_mcfg() for link when ACPI_PCI is not configured.

Quoted 6 lines

Then I have two questions:

* In hw/arm/Kconfig, I don't see one option contains both PCI and ACPI. I am confused where to put the select.
* put dummy build_mcfg() in aml-build.c works. Igor, do you like this? Or you haver other preference?

Hmm... put build_mcfg() in aml-build.c seems not work when we config both x86 and arm. e.g. --target-list=x86_64-softmmu,arm-softmmu. Because we only have one aml-build.o object file.

What comes into my mind is wrap build_mcfg() with #ifdef CONFIG_ACPI_PCI.

Any better idea?

Quoted 10 lines
Quoted 6 lines

Sadly both series clash :(

Regards,

Phil.

Signature · 2 lines
Wei Yang
Help you, Help me
Signature · 2 lines
Wei Yang
Help you, Help me
#88 lore raw

Re: [Qemu-devel] [PULL 00/37] pci, pc, virtio: features, fixes

Quoted 79 lines · Wei Yang
Quoted 78 lines · Wei Yang
Quoted 58 lines · Philippe Mathieu-Daudé
Quoted 31 lines · Philippe Mathieu-Daudé
Quoted 21 lines · Peter Maydell
Quoted 20 lines · Michael S. Tsirkin

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

Quoted 8 lines
Quoted 3 lines

----------------------------------------------------------------

Hi -- this pullreq has a conflict in default-configs/arm-softmmu.mak because the conversion of arm to Kconfig has landed in master. Could you rebase and fix up to use whatever the Kconfig equivalent of these changes is, please?

Quoted 4 lines

Culprit is "hw/acpi: Consolidate build_mcfg to pci.c"

The conflict doesn't look trivial to resolve (to me) so I'd rather see it reviewed (by Thomas). I suggest to drop the patch(es) from your PR :(

Thomas, FYI I did this to resolve the conflict:

- keep default-configs/arm-softmmu.mak from master:

git checkout origin/master default-configs/arm-softmmu.mak

- applied the following !fixup snippet:

-- >8 --

hw/acpi/Kconfig +0 -0
@@ -25,7 +25,7 @@ config ACPI_NVDIMM
 

config ACPI_PCI
bool

hw/acpi/Kconfig +1 -2
-    depends on ACPI
+    depends on ACPI && PCI
 
---
Quoted 3 lines

I felt it easier to review on top of "hw/acpi: Improve build modularity"
https://lists.gnu.org/archive/html/qemu-devel/2019-04/msg04718.html

Well, I hope this will not block the merge.

I took a look in the change of default-configs/arm-softmmu.mak. The general idea from Thomas is put those hard-coded config to Kconfig.

This is fine and what I need to change in my patch is to select ACPI_PCI in the proper place, if my understanding is correct.

Two things I need to fix:

* add select ACPI_PCI in proper place of hw/arm/Kconfig
* add a dummy build_mcfg() for link when ACPI_PCI is not configured.

Then I have two questions:

Quoted 8 lines
Quoted 4 lines

* In hw/arm/Kconfig, I don't see one option contains both PCI and ACPI. I am confused where to put the select.
* put dummy build_mcfg() in aml-build.c works. Igor, do you like this? Or you haver other preference?

Hmm... put build_mcfg() in aml-build.c seems not work when we config both x86 and arm. e.g. --target-list=x86_64-softmmu,arm-softmmu. Because we only have one aml-build.o object file.

I think this is what I tried to fix in "hw/acpi: Improve build modularity"
https://lists.gnu.org/archive/html/qemu-devel/2019-04/msg04718.html

Quoted 16 lines

What comes into my mind is wrap build_mcfg() with #ifdef CONFIG_ACPI_PCI.

Any better idea?

Quoted 10 lines
Quoted 6 lines

Sadly both series clash :(

Regards,

Phil.

Signature · 2 lines
Wei Yang
Help you, Help me
#89 lore raw

Re: [Qemu-devel] [PULL 00/37] pci, pc, virtio: features, fixes

Quoted 85 lines · Philippe Mathieu-Daudé
Quoted 84 lines · Wei Yang
Quoted 82 lines · Wei Yang
Quoted 58 lines · Philippe Mathieu-Daudé
Quoted 31 lines · Philippe Mathieu-Daudé
Quoted 21 lines · Peter Maydell
Quoted 20 lines · Michael S. Tsirkin

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

Quoted 8 lines
Quoted 3 lines

----------------------------------------------------------------

Hi -- this pullreq has a conflict in default-configs/arm-softmmu.mak because the conversion of arm to Kconfig has landed in master. Could you rebase and fix up to use whatever the Kconfig equivalent of these changes is, please?

Quoted 4 lines

Culprit is "hw/acpi: Consolidate build_mcfg to pci.c"

The conflict doesn't look trivial to resolve (to me) so I'd rather see it reviewed (by Thomas). I suggest to drop the patch(es) from your PR :(

Thomas, FYI I did this to resolve the conflict:

- keep default-configs/arm-softmmu.mak from master:

git checkout origin/master default-configs/arm-softmmu.mak

- applied the following !fixup snippet:

-- >8 --

hw/acpi/Kconfig +0 -0
@@ -25,7 +25,7 @@ config ACPI_NVDIMM
 

config ACPI_PCI
bool

hw/acpi/Kconfig +1 -2
-    depends on ACPI
+    depends on ACPI && PCI
 
---
Quoted 3 lines

I felt it easier to review on top of "hw/acpi: Improve build modularity"
https://lists.gnu.org/archive/html/qemu-devel/2019-04/msg04718.html

Well, I hope this will not block the merge.

I took a look in the change of default-configs/arm-softmmu.mak. The general idea from Thomas is put those hard-coded config to Kconfig.

This is fine and what I need to change in my patch is to select ACPI_PCI in the proper place, if my understanding is correct.

Two things I need to fix:

* add select ACPI_PCI in proper place of hw/arm/Kconfig
* add a dummy build_mcfg() for link when ACPI_PCI is not configured.

Then I have two questions:

* In hw/arm/Kconfig, I don't see one option contains both PCI and ACPI. I am confused where to put the select.
* put dummy build_mcfg() in aml-build.c works. Igor, do you like this? Or you haver other preference?

Quoted 7 lines
Quoted 3 lines

Hmm... put build_mcfg() in aml-build.c seems not work when we config both x86 and arm. e.g. --target-list=x86_64-softmmu,arm-softmmu. Because we only have one aml-build.o object file.

I think this is what I tried to fix in "hw/acpi: Improve build modularity"
https://lists.gnu.org/archive/html/qemu-devel/2019-04/msg04718.html

If I am correct, you are trying to add something in stub to fix the "undefined reference" right?

Quoted 16 lines
Quoted 16 lines

What comes into my mind is wrap build_mcfg() with #ifdef CONFIG_ACPI_PCI.

Any better idea?

Quoted 10 lines
Quoted 6 lines

Sadly both series clash :(

Regards,

Phil.

Signature · 2 lines
Wei Yang
Help you, Help me
Signature · 2 lines
Wei Yang
Help you, Help me
#90 lore raw

Re: [Qemu-devel] [PULL 00/37] pci, pc, virtio: features, fixes

In reply to Wei Yang
Quoted 76 lines · On Fri, 17 May 2019 10:59:03 +0800 Wei Yang <[email protected]>…
Quoted 58 lines · Philippe Mathieu-Daudé
Quoted 31 lines · Philippe Mathieu-Daudé
Quoted 21 lines · Peter Maydell
Quoted 20 lines · Michael S. Tsirkin

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

Quoted 8 lines
Quoted 3 lines

----------------------------------------------------------------

Hi -- this pullreq has a conflict in default-configs/arm-softmmu.mak because the conversion of arm to Kconfig has landed in master. Could you rebase and fix up to use whatever the Kconfig equivalent of these changes is, please?

Quoted 4 lines

Culprit is "hw/acpi: Consolidate build_mcfg to pci.c"

The conflict doesn't look trivial to resolve (to me) so I'd rather see it reviewed (by Thomas). I suggest to drop the patch(es) from your PR :(

Thomas, FYI I did this to resolve the conflict:

- keep default-configs/arm-softmmu.mak from master:

git checkout origin/master default-configs/arm-softmmu.mak

- applied the following !fixup snippet:

-- >8 --

hw/acpi/Kconfig +0 -0
@@ -25,7 +25,7 @@ config ACPI_NVDIMM
 

config ACPI_PCI
bool

hw/acpi/Kconfig +1 -2
-    depends on ACPI
+    depends on ACPI && PCI
 
---
Quoted 3 lines

I felt it easier to review on top of "hw/acpi: Improve build modularity"
https://lists.gnu.org/archive/html/qemu-devel/2019-04/msg04718.html

Well, I hope this will not block the merge.

I took a look in the change of default-configs/arm-softmmu.mak. The general idea from Thomas is put those hard-coded config to Kconfig.

This is fine and what I need to change in my patch is to select ACPI_PCI in the proper place, if my understanding is correct.

Two things I need to fix:

* add select ACPI_PCI in proper place of hw/arm/Kconfig
* add a dummy build_mcfg() for link when ACPI_PCI is not configured.

Quoted 6 lines

Then I have two questions:

* In hw/arm/Kconfig, I don't see one option contains both PCI and ACPI. I am confused where to put the select.
* put dummy build_mcfg() in aml-build.c works. Igor, do you like this? Or you haver other preference?

could you point out why we need dummy build_mcfg(), in the first place?

Quoted 7 lines
Quoted 6 lines

Sadly both series clash :(

Regards,

Phil.

#91 lore raw

Re: [Qemu-devel] [PULL 00/37] pci, pc, virtio: features, fixes

Quoted 3 lines · Igor Mammedov

On Fri, 17 May 2019 10:59:03 +0800
Wei Yang <[email protected]> wrote:

[..]

Quoted 14 lines
Quoted 14 lines

Well, I hope this will not block the merge.

I took a look in the change of default-configs/arm-softmmu.mak. The general idea from Thomas is put those hard-coded config to Kconfig.

This is fine and what I need to change in my patch is to select ACPI_PCI in the proper place, if my understanding is correct.

Two things I need to fix:

* add select ACPI_PCI in proper place of hw/arm/Kconfig
* add a dummy build_mcfg() for link when ACPI_PCI is not configured.

Quoted 9 lines
Quoted 6 lines

Then I have two questions:

* In hw/arm/Kconfig, I don't see one option contains both PCI and ACPI. I am confused where to put the select.
* put dummy build_mcfg() in aml-build.c works. Igor, do you like this? Or you haver other preference?

could you point out why we need dummy build_mcfg(), in the first place?

I may made a misunderstanding about hw/arm/Kconfig in recent upstream change.

I thought there would be no configuration to choose both ACPI and PCI at the same time, which leads to build_mcfg() will not be compiled.

While seems Philip decides to select ACPI_PCI for ARM_VIRT.

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

Sadly both series clash :(

Regards,

Phil.

Signature · 2 lines
Wei Yang
Help you, Help me
#92 lore raw

Re: [Qemu-devel] [PULL 00/37] pci, pc, virtio: features, fixes

In reply to Philippe Mathieu-Daudé
Quoted 31 lines · Philippe Mathieu-Daudé
Quoted 21 lines · Peter Maydell
Quoted 20 lines · Michael S. Tsirkin

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

Quoted 8 lines
Quoted 3 lines

----------------------------------------------------------------

Hi -- this pullreq has a conflict in default-configs/arm-softmmu.mak because the conversion of arm to Kconfig has landed in master. Could you rebase and fix up to use whatever the Kconfig equivalent of these changes is, please?

Quoted 8 lines

Culprit is "hw/acpi: Consolidate build_mcfg to pci.c"

The conflict doesn't look trivial to resolve (to me) so I'd rather see it reviewed (by Thomas). I suggest to drop the patch(es) from your PR :(

Regards,

Phil.

Yea, that's what I did.

Signature · 1 line
MST
#93 lore raw

Re: [Qemu-devel] [PULL 00/37] pci, pc, virtio: features, fixes

In reply to Peter Maydell
Quoted 25 lines · Peter Maydell
Quoted 16 lines · Michael S. Tsirkin

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

Quoted 7 lines

reconnect for vhost blk
tests for UEFI
misc other stuff

----------------------------------------------------------------

Quoted 7 lines

Hi -- this pullreq has a conflict in default-configs/arm-softmmu.mak because the conversion of arm to Kconfig has landed in master. Could you rebase and fix up to use whatever the Kconfig equivalent of these changes is, please?

thanks
-- PMM

Rebased and dropped the conflicting patch.
Pls re-pull.

Signature · 1 line
MST
#94 lore raw

[Qemu-devel] [PULL v2 00/36] pci, pc, virtio: features, fixes

The following changes since commit 2259637b95bef3116cc262459271de08e038cc66:

Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging (2019-05-20 17:22:05 +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 0c05ec64c388aea59facbef740651afa78e04f50:

tests: acpi: print error unable to dump ACPI table during rebuild (2019-05-20 18:40:02 -0400)

----------------------------------------------------------------
pci, pc, virtio: features, fixes

reconnect for vhost blk
tests for UEFI
misc other stuff

----------------------------------------------------------------
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 (3):
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()

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 ----------------------------
 hw/virtio/virtio-pci.h                  |   31 +-
 include/hw/acpi/pci.h                   |   33 +
 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/pcihp.c                         |   32 +-
 hw/acpi/piix4.c                         |   14 +-
 hw/arm/virt-acpi-build.c                |   22 +-
 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                    |   32 +-
 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/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
 43 files changed, 1908 insertions(+), 1452 deletions(-)
 delete mode 100644 docs/interop/vhost-user.txt
 create mode 100644 include/hw/acpi/pci.h
 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
#95 lore raw

Re: [Qemu-devel] [PULL v2 00/36] pci, pc, virtio: features, fixes

Quoted 16 lines · Michael S. Tsirkin

The following changes since commit 2259637b95bef3116cc262459271de08e038cc66:

Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging (2019-05-20 17:22:05 +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 0c05ec64c388aea59facbef740651afa78e04f50:

tests: acpi: print error unable to dump ACPI table during rebuild (2019-05-20 18:40:02 -0400)

----------------------------------------------------------------
pci, pc, virtio: features, fixes

Quoted 7 lines

reconnect for vhost blk
tests for UEFI
misc other stuff

----------------------------------------------------------------

Hi -- this failed 'make check' for 32-bit Arm hosts:

ERROR:/home/peter.maydell/qemu/tests/acpi-utils.c:145:acpi_find_rsdp_address_uefi:
code should not be reached
Aborted
ERROR - too few tests run (expected 1, got 0) /home/peter.maydell/qemu/tests/Makefile.include:885: recipe for target 'check-qtest-aarch64' failed

thanks
-- PMM

#96 lore raw

Re: [Qemu-devel] [PULL v2 00/36] pci, pc, virtio: features, fixes

Quoted 34 lines · Peter Maydell
Quoted 16 lines · Michael S. Tsirkin

The following changes since commit 2259637b95bef3116cc262459271de08e038cc66:

Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging (2019-05-20 17:22:05 +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 0c05ec64c388aea59facbef740651afa78e04f50:

tests: acpi: print error unable to dump ACPI table during rebuild (2019-05-20 18:40:02 -0400)

----------------------------------------------------------------
pci, pc, virtio: features, fixes

Quoted 7 lines

reconnect for vhost blk
tests for UEFI
misc other stuff

----------------------------------------------------------------

Hi -- this failed 'make check' for 32-bit Arm hosts:

ERROR:/home/peter.maydell/qemu/tests/acpi-utils.c:145:acpi_find_rsdp_address_uefi:
code should not be reached
Aborted
ERROR - too few tests run (expected 1, got 0) /home/peter.maydell/qemu/tests/Makefile.include:885: recipe for target 'check-qtest-aarch64' failed

Quoted 2 lines

thanks
-- PMM

Nothing jumps out ... Igor?

Signature · 1 line
MST
#97 lore raw

Re: [Qemu-devel] [PULL v2 00/36] pci, pc, virtio: features, fixes

Quoted 35 lines · On Tue, 21 May 2019 09:26:16 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 34 lines · Peter Maydell
Quoted 16 lines · Michael S. Tsirkin

The following changes since commit 2259637b95bef3116cc262459271de08e038cc66:

Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging (2019-05-20 17:22:05 +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 0c05ec64c388aea59facbef740651afa78e04f50:

tests: acpi: print error unable to dump ACPI table during rebuild (2019-05-20 18:40:02 -0400)

----------------------------------------------------------------
pci, pc, virtio: features, fixes

Quoted 7 lines

reconnect for vhost blk
tests for UEFI
misc other stuff

----------------------------------------------------------------

Hi -- this failed 'make check' for 32-bit Arm hosts:

ERROR:/home/peter.maydell/qemu/tests/acpi-utils.c:145:acpi_find_rsdp_address_uefi:
code should not be reached
Aborted
ERROR - too few tests run (expected 1, got 0) /home/peter.maydell/qemu/tests/Makefile.include:885: recipe for target 'check-qtest-aarch64' failed

Quoted 4 lines
Quoted 2 lines

thanks
-- PMM

Nothing jumps out ... Igor?

On 32-bit ARM host and it looks like UEFI crashes (CCing Laszlo) with:

InstallProtocolInterface: 5B1B31A1-9562-11D2-8E3F-00A0C969723B 469E52C0
ASSERT [DxeCore] /home/lacos/src/upstream/qemu/roms/edk2/MdePkg/Library/BaseLib/String.c(1090): Length < _gPcd_FixedAtBuild_PcdMaximumAsciiStringLength

CLI to reproduce:

qemu-system-aarch64 -display none -machine virt,accel=tcg -nodefaults -nographic -drive if=pflash,format=raw,file=pc-bios/edk2-aarch64-code.fd,readonly -drive if=pflash,format=raw,file=pc-bios/edk2-arm-vars.fd,snapshot=on -cdrom tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2 -cpu cortex-a57 -serial stdio

#98 lore raw

Re: [Qemu-devel] [PULL v2 00/36] pci, pc, virtio: features, fixes

Quoted 42 lines · Igor Mammedov
Quoted 35 lines · On Tue, 21 May 2019 09:26:16 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 34 lines · Peter Maydell
Quoted 16 lines · Michael S. Tsirkin

The following changes since commit 2259637b95bef3116cc262459271de08e038cc66:

Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging (2019-05-20 17:22:05 +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 0c05ec64c388aea59facbef740651afa78e04f50:

tests: acpi: print error unable to dump ACPI table during rebuild (2019-05-20 18:40:02 -0400)

----------------------------------------------------------------
pci, pc, virtio: features, fixes

Quoted 7 lines

reconnect for vhost blk
tests for UEFI
misc other stuff

----------------------------------------------------------------

Hi -- this failed 'make check' for 32-bit Arm hosts:

ERROR:/home/peter.maydell/qemu/tests/acpi-utils.c:145:acpi_find_rsdp_address_uefi:
code should not be reached
Aborted
ERROR - too few tests run (expected 1, got 0) /home/peter.maydell/qemu/tests/Makefile.include:885: recipe for target 'check-qtest-aarch64' failed

Quoted 4 lines
Quoted 2 lines

thanks
-- PMM

Nothing jumps out ... Igor?

Quoted 8 lines

On 32-bit ARM host and it looks like UEFI crashes (CCing Laszlo) with:

InstallProtocolInterface: 5B1B31A1-9562-11D2-8E3F-00A0C969723B 469E52C0
ASSERT [DxeCore] /home/lacos/src/upstream/qemu/roms/edk2/MdePkg/Library/BaseLib/String.c(1090): Length < _gPcd_FixedAtBuild_PcdMaximumAsciiStringLength

CLI to reproduce:

qemu-system-aarch64 -display none -machine virt,accel=tcg -nodefaults -nographic -drive if=pflash,format=raw,file=pc-bios/edk2-aarch64-code.fd,readonly -drive if=pflash,format=raw,file=pc-bios/edk2-arm-vars.fd,snapshot=on -cdrom tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2 -cpu cortex-a57 -serial stdio

This is very interesting. I had obviously tested booting "bios-tables-test.aarch64.iso.qcow2" against "edk2-aarch64-code.fd", using TCG, on my x86_64 laptop. (And, I've run the above exact command just now, at commit a4f667b67149 -- it works 100% fine.)

However, I've never been *near* a 32-bit ARM host. Therefore my suspicion is that the AARCH64 UEFI guest code tickles something in the 32-bit ARM code generator. It could be a bug in 32-bit ARM TCG, or it could be a bug in edk2 that is exposed by 32-bit ARM TCG.

The direct assertion failure is mostly useless. The AsciiStrLen() function does what you'd expect it to, except it has a kind of "safety check" where it trips an assertion if the string length (under measurement) exceeds a pre-set platform constant. It helps with catching memory corruption errors.

$ git show edk2-stable201903:MdePkg/Library/BaseLib/String.c | less
1090g

UINTN
EFIAPI
AsciiStrLen (
IN CONST CHAR8 *String
)
{
UINTN Length;

  ASSERT (String != NULL);
  for (Length = 0; *String != '\0'; String++, Length++) {
    //
    // If PcdMaximumUnicodeStringLength is not zero,
    // length should not more than PcdMaximumUnicodeStringLength
    //
    if (PcdGet32 (PcdMaximumAsciiStringLength) != 0) {
      ASSERT (Length < PcdGet32 (PcdMaximumAsciiStringLength)); <-- HERE
    }

}
return Length;
}

(Never mind that the comment has a typo -- it incorrectly references "PcdMaximumUnicodeStringLength", but the PCD that's actually checked is (correctly) "PcdMaximumAsciiStringLength".)

The constant is set to decimal 1,000,000 in ArmVirtQemu builds (inherited from MdePkg.dec), and that's indeed a quite unlikely length for real-word strings seen by firmware.

I'll take a closer look once I have access to a 32-bit ARM host, but I'll definitely need help. Basically we should compare the original AARCH64 (dis)assembly with the QEMU-generated 32-bit ARM assembly. Hopefully I can at least get a backtrace myself.

Thanks,
Laszlo

#99 lore raw

Re: [Qemu-devel] [PULL v2 00/36] pci, pc, virtio: features, fixes

Quoted 9 lines · Laszlo Ersek

This is very interesting. I had obviously tested booting "bios-tables-test.aarch64.iso.qcow2" against "edk2-aarch64-code.fd", using TCG, on my x86_64 laptop. (And, I've run the above exact command just now, at commit a4f667b67149 -- it works 100% fine.)

However, I've never been *near* a 32-bit ARM host. Therefore my suspicion is that the AARCH64 UEFI guest code tickles something in the 32-bit ARM code generator. It could be a bug in 32-bit ARM TCG, or it could be a bug in edk2 that is exposed by 32-bit ARM TCG.

Does it repro in a 32-bit-chroot in an aarch64 host ? I don't know if that might be easier for you to set up than getting access to real 32-bit hardware.

thanks
-- PMM

#100 lore raw

Re: [Qemu-devel] [PULL v2 00/36] pci, pc, virtio: features, fixes

Hi Peter,

Quoted 6 lines · Peter Maydell
Quoted 5 lines · Laszlo Ersek

This is very interesting. I had obviously tested booting "bios-tables-test.aarch64.iso.qcow2" against "edk2-aarch64-code.fd", using TCG, on my x86_64 laptop. (And, I've run the above exact command just now, at commit a4f667b67149 -- it works 100% fine.)

Quoted 8 lines
Quoted 4 lines

However, I've never been *near* a 32-bit ARM host. Therefore my suspicion is that the AARCH64 UEFI guest code tickles something in the 32-bit ARM code generator. It could be a bug in 32-bit ARM TCG, or it could be a bug in edk2 that is exposed by 32-bit ARM TCG.

Does it repro in a 32-bit-chroot in an aarch64 host ? I don't know if that might be easier for you to set up than getting access to real 32-bit hardware.

If this test is still necessary (e.g. for repeated testing), I might be able to run qemu-system-aarch64/TCG in a 32-bit QEMU/KVM guest on my Mustang. I was preparing to set up this kind of nesting, when Igor gave me access to a real aarch32 host.

Thanks
Laszlo

#101 lore raw

Re: [Qemu-devel] [PULL v2 00/36] pci, pc, virtio: features, fixes

In reply to Laszlo Ersek

(+Ard)

Quoted 109 lines · Laszlo Ersek
Quoted 59 lines · Igor Mammedov
Quoted 41 lines · On Tue, 21 May 2019 09:26:16 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 40 lines · Peter Maydell
Quoted 21 lines · Michael S. Tsirkin

The following changes since commit
2259637b95bef3116cc262459271de08e038cc66:

Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging (2019-05-20 17:22:05 +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
0c05ec64c388aea59facbef740651afa78e04f50:

tests: acpi: print error unable to dump ACPI table during rebuild (2019-05-20 18:40:02 -0400)

----------------------------------------------------------------
pci, pc, virtio: features, fixes

Quoted 7 lines

reconnect for vhost blk
tests for UEFI
misc other stuff

----------------------------------------------------------------

Hi -- this failed 'make check' for 32-bit Arm hosts:

ERROR:/home/peter.maydell/qemu/tests/acpi-utils.c:145:acpi_find_rsdp_address_uefi:
code should not be reached
Aborted
ERROR - too few tests run (expected 1, got 0) /home/peter.maydell/qemu/tests/Makefile.include:885: recipe for /target check-qtest-aarch64' failed

Quoted 4 lines
Quoted 2 lines

thanks
-- PMM

Nothing jumps out ... Igor?

On 32-bit ARM host and it looks like UEFI crashes (CCing Laszlo) with:

InstallProtocolInterface: 5B1B31A1-9562-11D2-8E3F-00A0C969723B 469E52C0
ASSERT [DxeCore] /home/lacos/src/upstream/qemu/roms/edk2/MdePkg/Library/BaseLib/String.c(1090): Length < _gPcd_FixedAtBuild_PcdMaximumAsciiStringLength

CLI to reproduce:

qemu-system-aarch64 -display none -machine virt,accel=tcg -nodefaults -nographic -drive if=pflash,format=raw,file=pc-bios/edk2-aarch64-code.fd,readonly

Review

Quoted 3 lines
(quoted diff) +0 -3
-drive if=pflash,format=raw,file=pc-bios/edk2-arm-vars.fd,snapshot=on
-cdrom tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2
-cpu cortex-a57 -serial stdio

This is very interesting. I had obviously tested booting "bios-tables-test.aarch64.iso.qcow2" against "edk2-aarch64-code.fd", using TCG, on my x86_64 laptop. (And, I've run the above exact command just now, at commit a4f667b67149 -- it works 100% fine.)

However, I've never been *near* a 32-bit ARM host. Therefore my suspicion is that the AARCH64 UEFI guest code tickles something in the 32-bit ARM code generator. It could be a bug in 32-bit ARM TCG, or it could be a bug in edk2 that is exposed by 32-bit ARM TCG.

The direct assertion failure is mostly useless. The AsciiStrLen() function does what you'd expect it to, except it has a kind of "safety check" where it trips an assertion if the string length (under measurement) exceeds a pre-set platform constant. It helps with catching memory corruption errors.

$ git show edk2-stable201903:MdePkg/Library/BaseLib/String.c | less
1090g

UINTN
EFIAPI
AsciiStrLen (
IN CONST CHAR8 *String
)
{
UINTN Length;

  ASSERT (String != NULL);
  for (Length = 0; *String != '\0'; String++, Length++) {
    //
    // If PcdMaximumUnicodeStringLength is not zero,
    // length should not more than PcdMaximumUnicodeStringLength
    //
    if (PcdGet32 (PcdMaximumAsciiStringLength) != 0) {
      ASSERT (Length < PcdGet32 (PcdMaximumAsciiStringLength)); <-- HERE
    }

}
return Length;
}

(Never mind that the comment has a typo -- it incorrectly references "PcdMaximumUnicodeStringLength", but the PCD that's actually checked is (correctly) "PcdMaximumAsciiStringLength".)

Quoted 8 lines

The constant is set to decimal 1,000,000 in ArmVirtQemu builds (inherited from MdePkg.dec), and that's indeed a quite unlikely length for real-word strings seen by firmware.

I'll take a closer look once I have access to a 32-bit ARM host, but I'll definitely need help. Basically we should compare the original AARCH64 (dis)assembly with the QEMU-generated 32-bit ARM assembly. Hopefully I can at least get a backtrace myself.

I have narrowed down the issue sufficiently that I think I can hand it over to Peter and Ard now -- because they know AARCH32 and AARCH64 assembly, and "target/arm/translate-a64.c" and "tcg/arm/*" too.

The summarize the issue for Ard, the symptom is that AARCH64 ArmVirtQemu runs perfectly fine with TCG on an x86-64 system, but it crashes on an AARCH32 host system.

Below is my analysis.

(1) First, I determined a backtrace for the crash. For this, I flipped the ASSERT() failure disposition from CpuDeadLoop() to CpuBreakpoint(), via "PcdDebugPropertyMask". This printed a very nice (numeric) stack trace, which wasn't hard to turn into symbols with "objdump -S", using edk2's Build directory.

(2) The actual crash is completely irrelevant, as it occurs on a cleanup path after the DXE Core fails to load the very first DXE driver that it attempts to load. The cleanup path should never be entered (i.e. the attempt to load the DXE driver in question should never fail). BTW the DXE driver in question is "MdeModulePkg/Universal/DevicePathDxe", but it's mostly irrelevant.

(3) The function that first encounters a failure -- i.e. where the guest firmware behavior diverges, dependent on whether qemu-system-aarch64/TCG executes on an AARCH32 host, or an x86-64 host -- is PeCoffLoaderRelocateImage(), in "MdePkg/Library/BasePeCoffLib/BasePeCoff.c". It is invoked when the DXE Core loads DevicePathDxe. The following check fails in the function (on the AARCH32 host), when it attempts to process the very first relocation block in DevicePathDxe:

Quoted 7 lines
      //
      // Add check for RelocBase->SizeOfBlock field.
      //
      if (RelocBase->SizeOfBlock == 0) {
        ImageContext->ImageError = IMAGE_ERROR_FAILED_RELOCATION;
        return RETURN_LOAD_ERROR;
      }

I logged the address and the contents of (*RelocBase). The address is the same in both working and failing cases, the contents differ.

(4) I tracked back a little bit to CoreLoadImageCommon() in "MdeModulePkg/Core/Dxe/Image/Image.c", to the spot where the image file is fetched (for later relocation). The following function call succeeds in both cases, however it returns *different data* as the DevicePathDxe.efi image file:

Quoted 6 lines
    FHand.Source = GetFileBufferByFilePath (
                      BootPolicy,
                      FilePath,
                      &FHand.SourceSize,
                      &AuthenticationStatus
                      );

Base address and size are identical, the CRC32s differ. After hexdumping the image variants (functional vs. broken with garbled relocations), and diffing the logs, an interesting pattern emerged. In every 4096 byte block, the 8-byte word at offset 4032 (0xFC0) is zeroed out in the broken variant. There are no other differences, as far as I can tell. 4096 = 64*64, and the qword in question is the start of the last 64-byte block (63*64=4032). I'm attaching the two log sections ("good.txt" (from the x86-64 host) vs "bad.txt" (from the aarch64 host)).

(5) Because the DevicePathDxe.efi image originates from the FvMain firmware volume, which is embedded as an LZMA-compressed file into the FVMAIN_COMPACT firmware volume, I hooked another CRC32 calculation into LzmaUefiDecompress(), in "MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaDecompress.c". The decompression is performed by the PEI Core with the help of the DXE IPL PEIM; in other words it happens in the PEI phase. The log confirmed that the firmware ran identically on both hosts (x86-64 and aarch32).

Thus, the data corruption was introduced somewhere between the decompression near the end of PEI, and GetFileBufferByFilePath() in the DXE Core.

(6) Here I got a bit frustrated by the many possible paths in the reading of firmware volumes, in the files "MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c" and "MdeModulePkg/Core/Dxe/SectionExtraction/CoreSectionExtraction.c". However, all those paths seemed to end in CopyMem(), one way or another -- ultimately, CopyMem() would transfer the data from the decompressed firmware volume (which was fine) to the caller of GetFileBufferByFilePath() (which was not fine).

(7) CopyMem() comes from the BaseMemoryLib class. "ArmVirtPkg/ArmVirt.dsc.inc" resolves it to the following lib instances:

Quoted 4 lines

[LibraryClasses.common]

  # use the accelerated BaseMemoryLibOptDxe by default, overrides for SEC/PEI below
  BaseMemoryLib|MdePkg/Library/BaseMemoryLibOptDxe/BaseMemoryLibOptDxe.inf
Quoted 8 lines

[LibraryClasses.common.SEC]
BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf

[LibraryClasses.common.PEI_CORE]
BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf

[LibraryClasses.common.PEIM]
BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf

The optimized aarch64 assembly code can be seen here:

https://github.com/tianocore/edk2/blob/master/MdePkg/Library/BaseMemoryLibOptDxe/AArch64/CopyMem.S

It has great comments, and the 64-byte chunk size mentioned in the comments made me realize that 0xFC0 equals 63 decimal * 64 decimal.

(8) I applied the following (proof of concept) patch:

Quoted 31 lines
ArmVirtPkg/ArmVirt.dsc.inc +1 -4
index a5d63751a343..c643a5a76718 100644
@@ -67,8 +67,7 @@ [LibraryClasses.common]
   #
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
 
-  # use the accelerated BaseMemoryLibOptDxe by default, overrides for SEC/PEI below
-  BaseMemoryLib|MdePkg/Library/BaseMemoryLibOptDxe/BaseMemoryLibOptDxe.inf
+  BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
 
   # Networking Requirements
 !include NetworkPkg/NetworkLibs.dsc.inc
@@ -160,7 +159,6 @@ [LibraryClasses.common]
 
 [LibraryClasses.common.SEC]
   PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
-  BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
 
   DebugAgentLib|ArmPkg/Library/DebugAgentSymbolsBaseLib/DebugAgentSymbolsBaseLib.inf
   SerialPortLib|ArmVirtPkg/Library/FdtPL011SerialPortLib/EarlyFdtPL011SerialPortLib.inf
@@ -171,7 +169,6 @@ [LibraryClasses.common.SEC]
 
 [LibraryClasses.common.PEI_CORE]
   PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf
-  BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
   HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
   PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
   MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf

ArmVirtPkg/ArmVirt.dsc.inc [LibraryClasses.common.PEI_CORE] · line 188

Quoted 7 lines
ArmVirtPkg/ArmVirt.dsc.inc +0 -1
@@ -186,7 +183,6 @@ [LibraryClasses.common.PEI_CORE]
 
 [LibraryClasses.common.PEIM]
   PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf
-  BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
   HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
   PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
   MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf

which replaces the assembly implementation of CopyMem() -- and of some other functions -- with C implementations (which are also optimized; see commit 01f688be90f5, "MdePkg/BaseMemoryLib: widen aligned accesses to 32 or 64 bits", 2016-09-13), in all module types.

(9) With this patch, the boot finished successfully (although it took very long):

Quoted 3 lines

BiosTablesTest: BiosTablesTest=41200000 Rsdp10=0 Rsdp20=40370000
BiosTablesTest: Smbios21=0 Smbios30=43EF0000
BiosTablesTest: press any key to exit

(10) Given that "translate-a64.c" is common between both x86-64 and aarch32 hosts, I think it must be "tcg/arm/*" that doesn't interoperate with the guest's "MdePkg/Library/BaseMemoryLibOptDxe/AArch64/CopyMem.S", for some reason. IOW, the aarch64 binary code is likely parsed correctly into the internal representation, but the 32-bit ARM code generated from the IR could hit some corner case.

Thanks,
Laszlo

#102 lore raw

Re: [Qemu-devel] [PULL v2 00/36] pci, pc, virtio: features, fixes

Quoted 2 lines · Laszlo Ersek

I'm attaching the two log sections ("good.txt" (from the x86-64 host) vs "bad.txt" (from the aarch64 host)).

Typo correction: "bad.txt" comes from an aarch32 host. (That's quite the point.)

Thanks & sorry
Laszlo

#103 lore raw

Re: [Qemu-devel] [PULL v2 00/36] pci, pc, virtio: features, fixes

In reply to Laszlo Ersek
Quoted 7 lines · Laszlo Ersek

I have narrowed down the issue sufficiently that I think I can hand it over to Peter and Ard now -- because they know AARCH32 and AARCH64 assembly, and "target/arm/translate-a64.c" and "tcg/arm/*" too.

The summarize the issue for Ard, the symptom is that AARCH64 ArmVirtQemu runs perfectly fine with TCG on an x86-64 system, but it crashes on an AARCH32 host system.

Thanks for the investigation; this is probably more one for Richard than me.

-- PMM

#104 lore raw

Re: [Qemu-devel] [PULL v2 00/36] pci, pc, virtio: features, fixes

Quoted 11 lines · Peter Maydell
Quoted 7 lines · Laszlo Ersek

I have narrowed down the issue sufficiently that I think I can hand it over to Peter and Ard now -- because they know AARCH32 and AARCH64 assembly, and "target/arm/translate-a64.c" and "tcg/arm/*" too.

The summarize the issue for Ard, the symptom is that AARCH64 ArmVirtQemu runs perfectly fine with TCG on an x86-64 system, but it crashes on an AARCH32 host system.

Thanks for the investigation; this is probably more one for Richard than me.

I figured I'd provide some logs.

(1) To recap, the aarch64 assembly source code file that seems to be mis-translated (from the aarch64 binary) lives at

https://github.com/tianocore/edk2/blob/3604174718e2afc950c3cc64c64ba5165c8692bd/MdePkg/Library/BaseMemoryLibOptDxe/AArch64/CopyMem.S

The relevant functions are InternalMemCopyMem() and __memcpy().

(2) I disassembled the aarch64 binary with "objdump", and uploaded the listing to:

http://people.redhat.com/lersek/aarch64-to-arm-mistranslation/DxeCore.objdump.xz

The InternalMemCopyMem() function starts at hex offset 2b2ec. The __memcpy() function starts at hex offset 2b180.

(3) I ran the guest with "-d in_asm,op,op_opt,op_ind,out_asm" and uploaded the log file to:

http://people.redhat.com/lersek/aarch64-to-arm-mistranslation/tcg.in_asm.op.op_opt.op_ind.out_asm.log.xz

The TBs that correspond to (parts of) the InternalMemCopyMem() and __memcpy() functions are scattered over the file, but the offset between the "nice" disassembly from (2), and the in-RAM TBs in (3), can be determined from the fact that there is a single prfm instruction in the entire binary. The instruction's offset is 0x2b180 in (2) -- at the beginning of the __memcpy() function --, and its RAM address is 0x472d2180 in (3). Thus the difference (= the load address of DxeCore.efi) is 0x472a7000.

(This is logged by the guest as well:

Quoted 1 line

Loading DXE CORE at 0x000472A7000 EntryPoint=0x000472A8000

)

Thanks
Laszlo

#105 lore raw

Re: [Qemu-devel] [PULL v2 00/36] pci, pc, virtio: features, fixes

In reply to Peter Maydell
Quoted 34 lines · Peter Maydell
Quoted 16 lines · Michael S. Tsirkin

The following changes since commit 2259637b95bef3116cc262459271de08e038cc66:

Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging (2019-05-20 17:22:05 +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 0c05ec64c388aea59facbef740651afa78e04f50:

tests: acpi: print error unable to dump ACPI table during rebuild (2019-05-20 18:40:02 -0400)

----------------------------------------------------------------
pci, pc, virtio: features, fixes

Quoted 7 lines

reconnect for vhost blk
tests for UEFI
misc other stuff

----------------------------------------------------------------

Hi -- this failed 'make check' for 32-bit Arm hosts:

ERROR:/home/peter.maydell/qemu/tests/acpi-utils.c:145:acpi_find_rsdp_address_uefi:
code should not be reached
Aborted
ERROR - too few tests run (expected 1, got 0) /home/peter.maydell/qemu/tests/Makefile.include:885: recipe for target 'check-qtest-aarch64' failed

Quoted 2 lines

thanks
-- PMM

OK for now I will just drop UEFI tests from ARM.
Igor will debug and re-add later on.

Igor, as you do this maybe start by adding the infrastructure with the blacklist so we can formalize the current "these tables need to be updated".

Signature · 1 line
MST
#106 lore raw

Re: [Qemu-devel] [PULL v2 00/36] pci, pc, virtio: features, fixes

In reply to Peter Maydell
Quoted 34 lines · Peter Maydell
Quoted 16 lines · Michael S. Tsirkin

The following changes since commit 2259637b95bef3116cc262459271de08e038cc66:

Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging (2019-05-20 17:22:05 +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 0c05ec64c388aea59facbef740651afa78e04f50:

tests: acpi: print error unable to dump ACPI table during rebuild (2019-05-20 18:40:02 -0400)

----------------------------------------------------------------
pci, pc, virtio: features, fixes

Quoted 7 lines

reconnect for vhost blk
tests for UEFI
misc other stuff

----------------------------------------------------------------

Hi -- this failed 'make check' for 32-bit Arm hosts:

ERROR:/home/peter.maydell/qemu/tests/acpi-utils.c:145:acpi_find_rsdp_address_uefi:
code should not be reached
Aborted
ERROR - too few tests run (expected 1, got 0) /home/peter.maydell/qemu/tests/Makefile.include:885: recipe for target 'check-qtest-aarch64' failed

Quoted 2 lines

thanks
-- PMM

Dropped ARM and re-pushed.

Signature · 1 line
MST
#107 lore raw

Re: [Qemu-devel] [PULL v2 00/36] pci, pc, virtio: features, fixes

Quoted 36 lines · Michael S. Tsirkin
Quoted 34 lines · Peter Maydell
Quoted 16 lines · Michael S. Tsirkin

The following changes since commit 2259637b95bef3116cc262459271de08e038cc66:

Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging (2019-05-20 17:22:05 +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 0c05ec64c388aea59facbef740651afa78e04f50:

tests: acpi: print error unable to dump ACPI table during rebuild (2019-05-20 18:40:02 -0400)

----------------------------------------------------------------
pci, pc, virtio: features, fixes

Quoted 7 lines

reconnect for vhost blk
tests for UEFI
misc other stuff

----------------------------------------------------------------

Hi -- this failed 'make check' for 32-bit Arm hosts:

ERROR:/home/peter.maydell/qemu/tests/acpi-utils.c:145:acpi_find_rsdp_address_uefi:
code should not be reached
Aborted
ERROR - too few tests run (expected 1, got 0) /home/peter.maydell/qemu/tests/Makefile.include:885: recipe for target 'check-qtest-aarch64' failed

Quoted 4 lines
Quoted 2 lines

thanks
-- PMM

Dropped ARM and re-pushed.

Fixed up version applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/4.1
for any user-visible changes.

-- PMM