* [Qemu-devel] [PULL 01/36] xen: fix ram init regression
[not found] <1467650742-17580-1-git-send-email-mst@redhat.com>
@ 2016-07-04 16:46 ` Michael S. Tsirkin
2016-07-04 16:46 ` [Qemu-devel] [PULL 02/36] hw/ppc: realize the PCI root bus as part of mac99 init Michael S. Tsirkin
` (34 subsequent siblings)
35 siblings, 0 replies; 43+ messages in thread
From: Michael S. Tsirkin @ 2016-07-04 16:46 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Gerd Hoffmann, Anthony PERARD, Paolo Bonzini,
Richard Henderson, Eduardo Habkost, Stefano Stabellini, xen-devel
From: Gerd Hoffmann <kraxel@redhat.com>
Commit "8156d48 pc: allow raising low memory via max-ram-below-4g
option" causes a regression on xen, because it uses a different
memory split.
This patch initializes max-ram-below-4g to zero and leaves the
initialization to the memory initialization functions. That way
they can pick different default values (max-ram-below-4g is zero
still) or use the user supplied value (max-ram-below-4g is non-zero).
Also skip the whole ram split calculation on Xen. xen_ram_init()
does its own split calculation anyway so it is superfluous, also
this way xen_ram_init can actually see whenever max-ram-below-4g
is zero or not.
Reported-by: Anthony PERARD <anthony.perard@citrix.com>
Tested-by: Anthony PERARD <anthony.perard@citrix.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/i386/pc.c | 2 +-
hw/i386/pc_piix.c | 50 ++++++++++++++++++++++++++++----------------------
hw/i386/pc_q35.c | 3 +++
xen-hvm.c | 3 +++
4 files changed, 35 insertions(+), 23 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 44a8f3b..cd1745e 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1919,7 +1919,7 @@ static void pc_machine_initfn(Object *obj)
pc_machine_get_hotplug_memory_region_size,
NULL, NULL, NULL, &error_abort);
- pcms->max_ram_below_4g = 0xe0000000; /* 3.5G */
+ pcms->max_ram_below_4g = 0; /* use default */
object_property_add(obj, PC_MACHINE_MAX_RAM_BELOW_4G, "size",
pc_machine_get_max_ram_below_4g,
pc_machine_set_max_ram_below_4g,
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index c7d70af..a07dc81 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -108,37 +108,43 @@ static void pc_init1(MachineState *machine,
* so legacy non-PAE guests can get as much memory as possible in
* the 32bit address space below 4G.
*
+ * - Note that Xen has its own ram setp code in xen_ram_init(),
+ * called via xen_hvm_init().
+ *
* Examples:
* qemu -M pc-1.7 -m 4G (old default) -> 3584M low, 512M high
* qemu -M pc -m 4G (new default) -> 3072M low, 1024M high
* qemu -M pc,max-ram-below-4g=2G -m 4G -> 2048M low, 2048M high
* qemu -M pc,max-ram-below-4g=4G -m 3968M -> 3968M low (=4G-128M)
*/
- lowmem = pcms->max_ram_below_4g;
- if (machine->ram_size >= pcms->max_ram_below_4g) {
- if (pcmc->gigabyte_align) {
- if (lowmem > 0xc0000000) {
- lowmem = 0xc0000000;
- }
- if (lowmem & ((1ULL << 30) - 1)) {
- error_report("Warning: Large machine and max_ram_below_4g "
- "(%" PRIu64 ") not a multiple of 1G; "
- "possible bad performance.",
- pcms->max_ram_below_4g);
+ if (xen_enabled()) {
+ xen_hvm_init(pcms, &ram_memory);
+ } else {
+ if (!pcms->max_ram_below_4g) {
+ pcms->max_ram_below_4g = 0xe0000000; /* default: 3.5G */
+ }
+ lowmem = pcms->max_ram_below_4g;
+ if (machine->ram_size >= pcms->max_ram_below_4g) {
+ if (pcmc->gigabyte_align) {
+ if (lowmem > 0xc0000000) {
+ lowmem = 0xc0000000;
+ }
+ if (lowmem & ((1ULL << 30) - 1)) {
+ error_report("Warning: Large machine and max_ram_below_4g "
+ "(%" PRIu64 ") not a multiple of 1G; "
+ "possible bad performance.",
+ pcms->max_ram_below_4g);
+ }
}
}
- }
- if (machine->ram_size >= lowmem) {
- pcms->above_4g_mem_size = machine->ram_size - lowmem;
- pcms->below_4g_mem_size = lowmem;
- } else {
- pcms->above_4g_mem_size = 0;
- pcms->below_4g_mem_size = machine->ram_size;
- }
-
- if (xen_enabled()) {
- xen_hvm_init(pcms, &ram_memory);
+ if (machine->ram_size >= lowmem) {
+ pcms->above_4g_mem_size = machine->ram_size - lowmem;
+ pcms->below_4g_mem_size = lowmem;
+ } else {
+ pcms->above_4g_mem_size = 0;
+ pcms->below_4g_mem_size = machine->ram_size;
+ }
}
pc_cpus_init(pcms);
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 04b2684..cd57bce 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -94,6 +94,9 @@ static void pc_q35_init(MachineState *machine)
/* Handle the machine opt max-ram-below-4g. It is basically doing
* min(qemu limit, user limit).
*/
+ if (!pcms->max_ram_below_4g) {
+ pcms->max_ram_below_4g = 1ULL << 32; /* default: 4G */;
+ }
if (lowmem > pcms->max_ram_below_4g) {
lowmem = pcms->max_ram_below_4g;
if (machine->ram_size - lowmem > lowmem &&
diff --git a/xen-hvm.c b/xen-hvm.c
index 98ea44f..eb57792 100644
--- a/xen-hvm.c
+++ b/xen-hvm.c
@@ -190,6 +190,9 @@ static void xen_ram_init(PCMachineState *pcms,
/* Handle the machine opt max-ram-below-4g. It is basically doing
* min(xen limit, user limit).
*/
+ if (!user_lowmem) {
+ user_lowmem = HVM_BELOW_4G_RAM_END; /* default */
+ }
if (HVM_BELOW_4G_RAM_END <= user_lowmem) {
user_lowmem = HVM_BELOW_4G_RAM_END;
}
--
MST
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [Qemu-devel] [PULL 02/36] hw/ppc: realize the PCI root bus as part of mac99 init
[not found] <1467650742-17580-1-git-send-email-mst@redhat.com>
2016-07-04 16:46 ` [Qemu-devel] [PULL 01/36] xen: fix ram init regression Michael S. Tsirkin
@ 2016-07-04 16:46 ` Michael S. Tsirkin
2016-07-04 16:46 ` [Qemu-devel] [PULL 03/36] hw/pci: delay bus_master_enable_region initialization Michael S. Tsirkin
` (33 subsequent siblings)
35 siblings, 0 replies; 43+ messages in thread
From: Michael S. Tsirkin @ 2016-07-04 16:46 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Marcel Apfelbaum, Alexander Graf, David Gibson,
qemu-ppc
From: Marcel Apfelbaum <marcel@redhat.com>
Mac99's PCI root bus is not part of a host bridge,
realize it manually.
Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/ppc/mac_newworld.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c
index 32e88b3..7d25106 100644
--- a/hw/ppc/mac_newworld.c
+++ b/hw/ppc/mac_newworld.c
@@ -380,6 +380,7 @@ static void ppc_core99_init(MachineState *machine)
pci_bus = pci_pmac_init(pic, get_system_memory(), get_system_io());
machine_arch = ARCH_MAC99;
}
+ object_property_set_bool(OBJECT(pci_bus), true, "realized", &error_abort);
machine->usb |= defaults_enabled() && !machine->usb_disabled;
--
MST
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [Qemu-devel] [PULL 03/36] hw/pci: delay bus_master_enable_region initialization
[not found] <1467650742-17580-1-git-send-email-mst@redhat.com>
2016-07-04 16:46 ` [Qemu-devel] [PULL 01/36] xen: fix ram init regression Michael S. Tsirkin
2016-07-04 16:46 ` [Qemu-devel] [PULL 02/36] hw/ppc: realize the PCI root bus as part of mac99 init Michael S. Tsirkin
@ 2016-07-04 16:46 ` Michael S. Tsirkin
2016-07-09 1:34 ` Mark Cave-Ayland
2016-07-11 14:42 ` Leon Alrae
2016-07-04 16:46 ` [Qemu-devel] [PULL 04/36] q35: allow dynamic sysbus Michael S. Tsirkin
` (32 subsequent siblings)
35 siblings, 2 replies; 43+ messages in thread
From: Michael S. Tsirkin @ 2016-07-04 16:46 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Marcel Apfelbaum, Paolo Bonzini
From: Marcel Apfelbaum <marcel@redhat.com>
Skip bus_master_enable region creation on PCI device init
in order to be sure the IOMMU device (if present) would
be created in advance. Add this memory region at machine_done time.
Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
include/hw/pci/pci_bus.h | 2 ++
include/sysemu/sysemu.h | 1 +
hw/pci/pci.c | 41 ++++++++++++++++++++++++++++++++---------
vl.c | 5 +++++
4 files changed, 40 insertions(+), 9 deletions(-)
diff --git a/include/hw/pci/pci_bus.h b/include/hw/pci/pci_bus.h
index 403fec6..5484a9b 100644
--- a/include/hw/pci/pci_bus.h
+++ b/include/hw/pci/pci_bus.h
@@ -39,6 +39,8 @@ struct PCIBus {
Keep a count of the number of devices with raised IRQs. */
int nirq;
int *irq_count;
+
+ Notifier machine_done;
};
typedef struct PCIBridgeWindows PCIBridgeWindows;
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index 7313673..ee7c760 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -75,6 +75,7 @@ void qemu_add_exit_notifier(Notifier *notify);
void qemu_remove_exit_notifier(Notifier *notify);
void qemu_add_machine_init_done_notifier(Notifier *notify);
+void qemu_remove_machine_init_done_notifier(Notifier *notify);
void hmp_savevm(Monitor *mon, const QDict *qdict);
int load_vmstate(const char *name);
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 4b585f4..ee385eb 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -78,10 +78,37 @@ static const VMStateDescription vmstate_pcibus = {
}
};
+static void pci_init_bus_master(PCIDevice *pci_dev)
+{
+ AddressSpace *dma_as = pci_device_iommu_address_space(pci_dev);
+
+ memory_region_init_alias(&pci_dev->bus_master_enable_region,
+ OBJECT(pci_dev), "bus master",
+ dma_as->root, 0, memory_region_size(dma_as->root));
+ memory_region_set_enabled(&pci_dev->bus_master_enable_region, false);
+ address_space_init(&pci_dev->bus_master_as,
+ &pci_dev->bus_master_enable_region, pci_dev->name);
+}
+
+static void pcibus_machine_done(Notifier *notifier, void *data)
+{
+ PCIBus *bus = container_of(notifier, PCIBus, machine_done);
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(bus->devices); ++i) {
+ if (bus->devices[i]) {
+ pci_init_bus_master(bus->devices[i]);
+ }
+ }
+}
+
static void pci_bus_realize(BusState *qbus, Error **errp)
{
PCIBus *bus = PCI_BUS(qbus);
+ bus->machine_done.notify = pcibus_machine_done;
+ qemu_add_machine_init_done_notifier(&bus->machine_done);
+
vmstate_register(NULL, -1, &vmstate_pcibus, bus);
}
@@ -89,6 +116,8 @@ static void pci_bus_unrealize(BusState *qbus, Error **errp)
{
PCIBus *bus = PCI_BUS(qbus);
+ qemu_remove_machine_init_done_notifier(&bus->machine_done);
+
vmstate_unregister(NULL, &vmstate_pcibus, bus);
}
@@ -920,7 +949,6 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,
PCIConfigReadFunc *config_read = pc->config_read;
PCIConfigWriteFunc *config_write = pc->config_write;
Error *local_err = NULL;
- AddressSpace *dma_as;
DeviceState *dev = DEVICE(pci_dev);
pci_dev->bus = bus;
@@ -961,15 +989,10 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,
pci_dev->devfn = devfn;
pci_dev->requester_id_cache = pci_req_id_cache_get(pci_dev);
- dma_as = pci_device_iommu_address_space(pci_dev);
-
- memory_region_init_alias(&pci_dev->bus_master_enable_region,
- OBJECT(pci_dev), "bus master",
- dma_as->root, 0, memory_region_size(dma_as->root));
- memory_region_set_enabled(&pci_dev->bus_master_enable_region, false);
- address_space_init(&pci_dev->bus_master_as, &pci_dev->bus_master_enable_region,
- name);
+ if (qdev_hotplug) {
+ pci_init_bus_master(pci_dev);
+ }
pstrcpy(pci_dev->name, sizeof(pci_dev->name), name);
pci_dev->irq_state = 0;
pci_config_alloc(pci_dev);
diff --git a/vl.c b/vl.c
index 9bb7f4c..5cd0f2a 100644
--- a/vl.c
+++ b/vl.c
@@ -2675,6 +2675,11 @@ void qemu_add_machine_init_done_notifier(Notifier *notify)
}
}
+void qemu_remove_machine_init_done_notifier(Notifier *notify)
+{
+ notifier_remove(notify);
+}
+
static void qemu_run_machine_init_done_notifiers(void)
{
notifier_list_notify(&machine_init_done_notifiers, NULL);
--
MST
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [Qemu-devel] [PULL 04/36] q35: allow dynamic sysbus
[not found] <1467650742-17580-1-git-send-email-mst@redhat.com>
` (2 preceding siblings ...)
2016-07-04 16:46 ` [Qemu-devel] [PULL 03/36] hw/pci: delay bus_master_enable_region initialization Michael S. Tsirkin
@ 2016-07-04 16:46 ` Michael S. Tsirkin
2016-07-04 16:46 ` [Qemu-devel] [PULL 05/36] hw/iommu: enable iommu with -device Michael S. Tsirkin
` (31 subsequent siblings)
35 siblings, 0 replies; 43+ messages in thread
From: Michael S. Tsirkin @ 2016-07-04 16:46 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Marcel Apfelbaum, Paolo Bonzini, Richard Henderson,
Eduardo Habkost
From: Marcel Apfelbaum <marcel@redhat.com>
Allow adding sysbus devices with -device on Q35.
At first Q35 will support only intel-iommu to be added this way,
however the command line will support all sysbus devices.
Mark with 'cannot_instantiate_with_device_add_yet' the ones
causing immediate problems (e.g. crashes).
Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/i386/pc_q35.c | 1 +
hw/pci-bridge/pci_expander_bridge.c | 2 ++
hw/pci-host/piix.c | 2 ++
hw/pci-host/q35.c | 2 ++
4 files changed, 7 insertions(+)
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index cd57bce..fbaf2e6 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -290,6 +290,7 @@ static void pc_q35_machine_options(MachineClass *m)
m->default_machine_opts = "firmware=bios-256k.bin";
m->default_display = "std";
m->no_floppy = 1;
+ m->has_dynamic_sysbus = true;
}
static void pc_q35_2_7_machine_options(MachineClass *m)
diff --git a/hw/pci-bridge/pci_expander_bridge.c b/hw/pci-bridge/pci_expander_bridge.c
index ba320bd..ab86121 100644
--- a/hw/pci-bridge/pci_expander_bridge.c
+++ b/hw/pci-bridge/pci_expander_bridge.c
@@ -149,6 +149,8 @@ static void pxb_host_class_init(ObjectClass *class, void *data)
PCIHostBridgeClass *hc = PCI_HOST_BRIDGE_CLASS(class);
dc->fw_name = "pci";
+ /* Reason: Internal part of the pxb/pxb-pcie device, not usable by itself */
+ dc->cannot_instantiate_with_device_add_yet = true;
sbc->explicit_ofw_unit_address = pxb_host_ofw_unit_address;
hc->root_bus_path = pxb_host_root_bus_path;
}
diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c
index df2b0e2..7167e58 100644
--- a/hw/pci-host/piix.c
+++ b/hw/pci-host/piix.c
@@ -865,6 +865,8 @@ static void i440fx_pcihost_class_init(ObjectClass *klass, void *data)
dc->realize = i440fx_pcihost_realize;
dc->fw_name = "pci";
dc->props = i440fx_props;
+ /* Reason: needs to be wired up by pc_init1 */
+ dc->cannot_instantiate_with_device_add_yet = true;
}
static const TypeInfo i440fx_pcihost_info = {
diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c
index 03be05d..0150039 100644
--- a/hw/pci-host/q35.c
+++ b/hw/pci-host/q35.c
@@ -142,6 +142,8 @@ static void q35_host_class_init(ObjectClass *klass, void *data)
hc->root_bus_path = q35_host_root_bus_path;
dc->realize = q35_host_realize;
dc->props = mch_props;
+ /* Reason: needs to be wired up by pc_q35_init */
+ dc->cannot_instantiate_with_device_add_yet = true;
set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
dc->fw_name = "pci";
}
--
MST
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [Qemu-devel] [PULL 05/36] hw/iommu: enable iommu with -device
[not found] <1467650742-17580-1-git-send-email-mst@redhat.com>
` (3 preceding siblings ...)
2016-07-04 16:46 ` [Qemu-devel] [PULL 04/36] q35: allow dynamic sysbus Michael S. Tsirkin
@ 2016-07-04 16:46 ` Michael S. Tsirkin
2016-07-04 16:46 ` [Qemu-devel] [PULL 06/36] machine: remove iommu property Michael S. Tsirkin
` (30 subsequent siblings)
35 siblings, 0 replies; 43+ messages in thread
From: Michael S. Tsirkin @ 2016-07-04 16:46 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Marcel Apfelbaum, Paolo Bonzini, Richard Henderson,
Eduardo Habkost
From: Marcel Apfelbaum <marcel@redhat.com>
Use the standard '-device intel-iommu' to create the IOMMU device.
The legacy '-machine,iommu=on' can still be used.
Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/i386/intel_iommu.c | 16 ++++++++++++++++
hw/i386/pc_q35.c | 1 -
hw/pci-host/q35.c | 17 +----------------
3 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
index 5eba704..464f2a0 100644
--- a/hw/i386/intel_iommu.c
+++ b/hw/i386/intel_iommu.c
@@ -25,6 +25,7 @@
#include "intel_iommu_internal.h"
#include "hw/pci/pci.h"
#include "hw/pci/pci_bus.h"
+#include "hw/i386/pc.h"
/*#define DEBUG_INTEL_IOMMU*/
#ifdef DEBUG_INTEL_IOMMU
@@ -2026,8 +2027,20 @@ static void vtd_reset(DeviceState *dev)
vtd_init(s);
}
+static AddressSpace *vtd_host_dma_iommu(PCIBus *bus, void *opaque, int devfn)
+{
+ IntelIOMMUState *s = opaque;
+ VTDAddressSpace *vtd_as;
+
+ assert(0 <= devfn && devfn <= VTD_PCI_DEVFN_MAX);
+
+ vtd_as = vtd_find_add_as(s, bus, devfn);
+ return &vtd_as->as;
+}
+
static void vtd_realize(DeviceState *dev, Error **errp)
{
+ PCIBus *bus = PC_MACHINE(qdev_get_machine())->bus;
IntelIOMMUState *s = INTEL_IOMMU_DEVICE(dev);
VTD_DPRINTF(GENERAL, "");
@@ -2041,6 +2054,8 @@ static void vtd_realize(DeviceState *dev, Error **errp)
s->vtd_as_by_busptr = g_hash_table_new_full(vtd_uint64_hash, vtd_uint64_equal,
g_free, g_free);
vtd_init(s);
+ sysbus_mmio_map(SYS_BUS_DEVICE(s), 0, Q35_HOST_BRIDGE_IOMMU_ADDR);
+ pci_setup_iommu(bus, vtd_host_dma_iommu, dev);
}
static void vtd_class_init(ObjectClass *klass, void *data)
@@ -2051,6 +2066,7 @@ static void vtd_class_init(ObjectClass *klass, void *data)
dc->realize = vtd_realize;
dc->vmsd = &vtd_vmstate;
dc->props = vtd_properties;
+ dc->hotpluggable = false;
}
static const TypeInfo vtd_info = {
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index fbaf2e6..c0b9961 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -179,7 +179,6 @@ static void pc_q35_init(MachineState *machine)
qdev_init_nofail(DEVICE(q35_host));
phb = PCI_HOST_BRIDGE(q35_host);
host_bus = phb->bus;
- pcms->bus = phb->bus;
/* create ISA bus */
lpc = pci_create_simple_multifunction(host_bus, PCI_DEVFN(ICH9_LPC_DEV,
ICH9_LPC_FUNC), true,
diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c
index 0150039..8d060a5 100644
--- a/hw/pci-host/q35.c
+++ b/hw/pci-host/q35.c
@@ -52,6 +52,7 @@ static void q35_host_realize(DeviceState *dev, Error **errp)
pci->bus = pci_bus_new(DEVICE(s), "pcie.0",
s->mch.pci_address_space, s->mch.address_space_io,
0, TYPE_PCIE_BUS);
+ PC_MACHINE(qdev_get_machine())->bus = pci->bus;
qdev_set_parent_bus(DEVICE(&s->mch), BUS(pci->bus));
qdev_init_nofail(DEVICE(&s->mch));
}
@@ -446,28 +447,12 @@ static void mch_reset(DeviceState *qdev)
mch_update(mch);
}
-static AddressSpace *q35_host_dma_iommu(PCIBus *bus, void *opaque, int devfn)
-{
- IntelIOMMUState *s = opaque;
- VTDAddressSpace *vtd_as;
-
- assert(0 <= devfn && devfn <= VTD_PCI_DEVFN_MAX);
-
- vtd_as = vtd_find_add_as(s, bus, devfn);
- return &vtd_as->as;
-}
-
static void mch_init_dmar(MCHPCIState *mch)
{
- PCIBus *pci_bus = PCI_BUS(qdev_get_parent_bus(DEVICE(mch)));
-
mch->iommu = INTEL_IOMMU_DEVICE(qdev_create(NULL, TYPE_INTEL_IOMMU_DEVICE));
object_property_add_child(OBJECT(mch), "intel-iommu",
OBJECT(mch->iommu), NULL);
qdev_init_nofail(DEVICE(mch->iommu));
- sysbus_mmio_map(SYS_BUS_DEVICE(mch->iommu), 0, Q35_HOST_BRIDGE_IOMMU_ADDR);
-
- pci_setup_iommu(pci_bus, q35_host_dma_iommu, mch->iommu);
}
static void mch_realize(PCIDevice *d, Error **errp)
--
MST
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [Qemu-devel] [PULL 06/36] machine: remove iommu property
[not found] <1467650742-17580-1-git-send-email-mst@redhat.com>
` (4 preceding siblings ...)
2016-07-04 16:46 ` [Qemu-devel] [PULL 05/36] hw/iommu: enable iommu with -device Michael S. Tsirkin
@ 2016-07-04 16:46 ` Michael S. Tsirkin
2016-07-04 16:46 ` [Qemu-devel] [PULL 07/36] piix: Set I440FXState member pci_info.w32 in one place Michael S. Tsirkin
` (29 subsequent siblings)
35 siblings, 0 replies; 43+ messages in thread
From: Michael S. Tsirkin @ 2016-07-04 16:46 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Marcel Apfelbaum, Eduardo Habkost
From: Marcel Apfelbaum <marcel@redhat.com>
Since iommu devices can be created with '-device' there is
no need to keep iommu as machine and mch property.
Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
include/hw/pci-host/q35.h | 1 -
hw/core/machine.c | 20 --------------------
hw/pci-host/q35.c | 12 ------------
qemu-options.hx | 3 ---
4 files changed, 36 deletions(-)
diff --git a/include/hw/pci-host/q35.h b/include/hw/pci-host/q35.h
index 1075f3e..73992b4 100644
--- a/include/hw/pci-host/q35.h
+++ b/include/hw/pci-host/q35.h
@@ -60,7 +60,6 @@ typedef struct MCHPCIState {
uint64_t above_4g_mem_size;
uint64_t pci_hole64_size;
uint32_t short_root_bus;
- IntelIOMMUState *iommu;
} MCHPCIState;
typedef struct Q35PCIHost {
diff --git a/hw/core/machine.c b/hw/core/machine.c
index ccdd5fa..8f94301 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -300,20 +300,6 @@ static void machine_set_firmware(Object *obj, const char *value, Error **errp)
ms->firmware = g_strdup(value);
}
-static bool machine_get_iommu(Object *obj, Error **errp)
-{
- MachineState *ms = MACHINE(obj);
-
- return ms->iommu;
-}
-
-static void machine_set_iommu(Object *obj, bool value, Error **errp)
-{
- MachineState *ms = MACHINE(obj);
-
- ms->iommu = value;
-}
-
static void machine_set_suppress_vmdesc(Object *obj, bool value, Error **errp)
{
MachineState *ms = MACHINE(obj);
@@ -493,12 +479,6 @@ static void machine_initfn(Object *obj)
object_property_set_description(obj, "firmware",
"Firmware image",
NULL);
- object_property_add_bool(obj, "iommu",
- machine_get_iommu,
- machine_set_iommu, NULL);
- object_property_set_description(obj, "iommu",
- "Set on/off to enable/disable Intel IOMMU (VT-d)",
- NULL);
object_property_add_bool(obj, "suppress-vmdesc",
machine_get_suppress_vmdesc,
machine_set_suppress_vmdesc, NULL);
diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c
index 8d060a5..eb1b2f7 100644
--- a/hw/pci-host/q35.c
+++ b/hw/pci-host/q35.c
@@ -447,14 +447,6 @@ static void mch_reset(DeviceState *qdev)
mch_update(mch);
}
-static void mch_init_dmar(MCHPCIState *mch)
-{
- mch->iommu = INTEL_IOMMU_DEVICE(qdev_create(NULL, TYPE_INTEL_IOMMU_DEVICE));
- object_property_add_child(OBJECT(mch), "intel-iommu",
- OBJECT(mch->iommu), NULL);
- qdev_init_nofail(DEVICE(mch->iommu));
-}
-
static void mch_realize(PCIDevice *d, Error **errp)
{
int i;
@@ -513,10 +505,6 @@ static void mch_realize(PCIDevice *d, Error **errp)
mch->pci_address_space, &mch->pam_regions[i+1],
PAM_EXPAN_BASE + i * PAM_EXPAN_SIZE, PAM_EXPAN_SIZE);
}
- /* Intel IOMMU (VT-d) */
- if (object_property_get_bool(qdev_get_machine(), "iommu", NULL)) {
- mch_init_dmar(mch);
- }
}
uint64_t mch_mcfg_base(void)
diff --git a/qemu-options.hx b/qemu-options.hx
index a95a936..9692e53 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -38,7 +38,6 @@ DEF("machine", HAS_ARG, QEMU_OPTION_machine, \
" kvm_shadow_mem=size of KVM shadow MMU in bytes\n"
" dump-guest-core=on|off include guest memory in a core dump (default=on)\n"
" mem-merge=on|off controls memory merge support (default: on)\n"
- " iommu=on|off controls emulated Intel IOMMU (VT-d) support (default=off)\n"
" igd-passthru=on|off controls IGD GFX passthrough support (default=off)\n"
" aes-key-wrap=on|off controls support for AES key wrapping (default=on)\n"
" dea-key-wrap=on|off controls support for DEA key wrapping (default=on)\n"
@@ -73,8 +72,6 @@ Include guest memory in a core dump. The default is on.
Enables or disables memory merge support. This feature, when supported by
the host, de-duplicates identical memory pages among VMs instances
(enabled by default).
-@item iommu=on|off
-Enables or disables emulated Intel IOMMU (VT-d) support. The default is off.
@item aes-key-wrap=on|off
Enables or disables AES key wrapping support on s390-ccw hosts. This feature
controls whether AES wrapping keys will be created to allow
--
MST
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [Qemu-devel] [PULL 07/36] piix: Set I440FXState member pci_info.w32 in one place
[not found] <1467650742-17580-1-git-send-email-mst@redhat.com>
` (5 preceding siblings ...)
2016-07-04 16:46 ` [Qemu-devel] [PULL 06/36] machine: remove iommu property Michael S. Tsirkin
@ 2016-07-04 16:46 ` Michael S. Tsirkin
2016-07-04 16:46 ` [Qemu-devel] [PULL 08/36] pc: Eliminate PcPciInfo Michael S. Tsirkin
` (28 subsequent siblings)
35 siblings, 0 replies; 43+ messages in thread
From: Michael S. Tsirkin @ 2016-07-04 16:46 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Markus Armbruster, Eric Blake, Marcel Apfelbaum
From: Markus Armbruster <armbru@redhat.com>
Range pci_info.w32 records the location of the PCI hole.
It's initialized to empty when QOM zeroes I440FXState. That's a fine
value for a still unknown PCI hole.
i440fx_init() sets pci_info.w32.begin = below_4g_mem_size. Changes
the PCI hole from empty to [below_4g_mem_size, UINT64_MAX]. That's a
bogus value.
i440fx_pcihost_initfn() sets pci_info.end = IO_APIC_DEFAULT_ADDRESS.
Since i440fx_init() ran already, this changes the PCI hole to
[below_4g_mem_size, IO_APIC_DEFAULT_ADDRESS-1]. That's the correct
value.
Setting the bounds of the PCI hole in two separate places is
confusing, and begs the question whether the bogus intermediate value
could be used by something, or what would happen if we somehow managed
to realize an i440FX device without having run the board init function
i440fx_init() first.
Avoid the confusion by setting the (constant) upper bound along with
the lower bound in i440fx_init().
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
---
hw/pci-host/piix.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c
index 7167e58..d0b76c9 100644
--- a/hw/pci-host/piix.c
+++ b/hw/pci-host/piix.c
@@ -263,7 +263,6 @@ static void i440fx_pcihost_get_pci_hole64_end(Object *obj, Visitor *v,
static void i440fx_pcihost_initfn(Object *obj)
{
PCIHostState *s = PCI_HOST_BRIDGE(obj);
- I440FXState *d = I440FX_PCI_HOST_BRIDGE(obj);
memory_region_init_io(&s->conf_mem, obj, &pci_host_conf_le_ops, s,
"pci-conf-idx", 4);
@@ -285,8 +284,6 @@ static void i440fx_pcihost_initfn(Object *obj)
object_property_add(obj, PCI_HOST_PROP_PCI_HOLE64_END, "int",
i440fx_pcihost_get_pci_hole64_end,
NULL, NULL, NULL, NULL);
-
- d->pci_info.w32.end = IO_APIC_DEFAULT_ADDRESS;
}
static void i440fx_pcihost_realize(DeviceState *dev, Error **errp)
@@ -348,6 +345,7 @@ PCIBus *i440fx_init(const char *host_type, const char *pci_type,
i440fx = I440FX_PCI_HOST_BRIDGE(dev);
i440fx->pci_info.w32.begin = below_4g_mem_size;
+ i440fx->pci_info.w32.end = IO_APIC_DEFAULT_ADDRESS;
/* setup pci memory mapping */
pc_pci_as_mapping_init(OBJECT(f), f->system_memory,
--
MST
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [Qemu-devel] [PULL 08/36] pc: Eliminate PcPciInfo
[not found] <1467650742-17580-1-git-send-email-mst@redhat.com>
` (6 preceding siblings ...)
2016-07-04 16:46 ` [Qemu-devel] [PULL 07/36] piix: Set I440FXState member pci_info.w32 in one place Michael S. Tsirkin
@ 2016-07-04 16:46 ` Michael S. Tsirkin
2016-07-04 16:46 ` [Qemu-devel] [PULL 09/36] virtio: revert host notifiers to old semantics Michael S. Tsirkin
` (27 subsequent siblings)
35 siblings, 0 replies; 43+ messages in thread
From: Michael S. Tsirkin @ 2016-07-04 16:46 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Markus Armbruster, Eric Blake, Marcel Apfelbaum,
Igor Mammedov, Paolo Bonzini, Richard Henderson, Eduardo Habkost
From: Markus Armbruster <armbru@redhat.com>
PcPciInfo has two (ill-named) members: Range w32 is the PCI hole, and
w64 is the PCI64 hole.
Three users:
* I440FXState and MCHPCIState have a member PcPciInfo pci_info, but
only pci_info.w32 is actually used. This is confusing. Replace by
Range pci_hole.
* acpi_build() uses auto PcPciInfo pci_info to forward both PCI holes
from acpi_get_pci_info() to build_dsdt(). Replace by two variables
Range pci_hole, pci_hole64. Rename acpi_get_pci_info() to
acpi_get_pci_holes().
PcPciInfo is now unused; drop it.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
---
include/hw/i386/pc.h | 5 -----
include/hw/pci-host/q35.h | 2 +-
hw/i386/acpi-build.c | 43 ++++++++++++++++++++++---------------------
hw/pci-host/piix.c | 10 +++++-----
hw/pci-host/q35.c | 12 ++++++------
5 files changed, 34 insertions(+), 38 deletions(-)
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 7e43b20..d44e5e9 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -150,11 +150,6 @@ struct PCMachineClass {
/* PC-style peripherals (also used by other machines). */
-typedef struct PcPciInfo {
- Range w32;
- Range w64;
-} PcPciInfo;
-
#define ACPI_PM_PROP_S3_DISABLED "disable_s3"
#define ACPI_PM_PROP_S4_DISABLED "disable_s4"
#define ACPI_PM_PROP_S4_VAL "s4_val"
diff --git a/include/hw/pci-host/q35.h b/include/hw/pci-host/q35.h
index 73992b4..0d64032 100644
--- a/include/hw/pci-host/q35.h
+++ b/include/hw/pci-host/q35.h
@@ -55,7 +55,7 @@ typedef struct MCHPCIState {
MemoryRegion smram_region, open_high_smram;
MemoryRegion smram, low_smram, high_smram;
MemoryRegion tseg_blackhole, tseg_window;
- PcPciInfo pci_info;
+ Range pci_hole;
uint64_t below_4g_mem_size;
uint64_t above_4g_mem_size;
uint64_t pci_hole64_size;
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 5a594be..576c7af 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -229,26 +229,25 @@ static Object *acpi_get_i386_pci_host(void)
return OBJECT(host);
}
-static void acpi_get_pci_info(PcPciInfo *info)
+static void acpi_get_pci_holes(Range *hole, Range *hole64)
{
Object *pci_host;
-
pci_host = acpi_get_i386_pci_host();
g_assert(pci_host);
- info->w32.begin = object_property_get_int(pci_host,
- PCI_HOST_PROP_PCI_HOLE_START,
- NULL);
- info->w32.end = object_property_get_int(pci_host,
- PCI_HOST_PROP_PCI_HOLE_END,
- NULL);
- info->w64.begin = object_property_get_int(pci_host,
- PCI_HOST_PROP_PCI_HOLE64_START,
- NULL);
- info->w64.end = object_property_get_int(pci_host,
- PCI_HOST_PROP_PCI_HOLE64_END,
+ hole->begin = object_property_get_int(pci_host,
+ PCI_HOST_PROP_PCI_HOLE_START,
+ NULL);
+ hole->end = object_property_get_int(pci_host,
+ PCI_HOST_PROP_PCI_HOLE_END,
+ NULL);
+ hole64->begin = object_property_get_int(pci_host,
+ PCI_HOST_PROP_PCI_HOLE64_START,
NULL);
+ hole64->end = object_property_get_int(pci_host,
+ PCI_HOST_PROP_PCI_HOLE64_END,
+ NULL);
}
#define ACPI_PORT_SMI_CMD 0x00b2 /* TODO: this is APM_CNT_IOPORT */
@@ -1890,7 +1889,7 @@ static Aml *build_q35_osc_method(void)
static void
build_dsdt(GArray *table_data, BIOSLinker *linker,
AcpiPmInfo *pm, AcpiMiscInfo *misc,
- PcPciInfo *pci, MachineState *machine)
+ Range *pci_hole, Range *pci_hole64, MachineState *machine)
{
CrsRangeEntry *entry;
Aml *dsdt, *sb_scope, *scope, *dev, *method, *field, *pkg, *crs;
@@ -2047,7 +2046,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
AML_CACHEABLE, AML_READ_WRITE,
0, 0x000A0000, 0x000BFFFF, 0, 0x00020000));
- crs_replace_with_free_ranges(mem_ranges, pci->w32.begin, pci->w32.end - 1);
+ crs_replace_with_free_ranges(mem_ranges,
+ pci_hole->begin, pci_hole->end - 1);
for (i = 0; i < mem_ranges->len; i++) {
entry = g_ptr_array_index(mem_ranges, i);
aml_append(crs,
@@ -2057,12 +2057,12 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
0, entry->limit - entry->base + 1));
}
- if (pci->w64.begin) {
+ if (pci_hole64->begin) {
aml_append(crs,
aml_qword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED,
AML_CACHEABLE, AML_READ_WRITE,
- 0, pci->w64.begin, pci->w64.end - 1, 0,
- pci->w64.end - pci->w64.begin));
+ 0, pci_hole64->begin, pci_hole64->end - 1, 0,
+ pci_hole64->end - pci_hole64->begin));
}
if (misc->tpm_version != TPM_VERSION_UNSPEC) {
@@ -2554,7 +2554,7 @@ void acpi_build(AcpiBuildTables *tables, MachineState *machine)
AcpiPmInfo pm;
AcpiMiscInfo misc;
AcpiMcfgInfo mcfg;
- PcPciInfo pci;
+ Range pci_hole, pci_hole64;
uint8_t *u;
size_t aml_len = 0;
GArray *tables_blob = tables->table_data;
@@ -2562,7 +2562,7 @@ void acpi_build(AcpiBuildTables *tables, MachineState *machine)
acpi_get_pm_info(&pm);
acpi_get_misc_info(&misc);
- acpi_get_pci_info(&pci);
+ acpi_get_pci_holes(&pci_hole, &pci_hole64);
acpi_get_slic_oem(&slic_oem);
table_offsets = g_array_new(false, true /* clear */,
@@ -2584,7 +2584,8 @@ void acpi_build(AcpiBuildTables *tables, MachineState *machine)
/* DSDT is pointed to by FADT */
dsdt = tables_blob->len;
- build_dsdt(tables_blob, tables->linker, &pm, &misc, &pci, machine);
+ build_dsdt(tables_blob, tables->linker, &pm, &misc,
+ &pci_hole, &pci_hole64, machine);
/* Count the size of the DSDT and SSDT, we will need it for legacy
* sizing of ACPI tables.
diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c
index d0b76c9..b1bfc59 100644
--- a/hw/pci-host/piix.c
+++ b/hw/pci-host/piix.c
@@ -48,7 +48,7 @@
typedef struct I440FXState {
PCIHostState parent_obj;
- PcPciInfo pci_info;
+ Range pci_hole;
uint64_t pci_hole64_size;
uint32_t short_root_bus;
} I440FXState;
@@ -221,7 +221,7 @@ static void i440fx_pcihost_get_pci_hole_start(Object *obj, Visitor *v,
Error **errp)
{
I440FXState *s = I440FX_PCI_HOST_BRIDGE(obj);
- uint32_t value = s->pci_info.w32.begin;
+ uint32_t value = s->pci_hole.begin;
visit_type_uint32(v, name, &value, errp);
}
@@ -231,7 +231,7 @@ static void i440fx_pcihost_get_pci_hole_end(Object *obj, Visitor *v,
Error **errp)
{
I440FXState *s = I440FX_PCI_HOST_BRIDGE(obj);
- uint32_t value = s->pci_info.w32.end;
+ uint32_t value = s->pci_hole.end;
visit_type_uint32(v, name, &value, errp);
}
@@ -344,8 +344,8 @@ PCIBus *i440fx_init(const char *host_type, const char *pci_type,
f->ram_memory = ram_memory;
i440fx = I440FX_PCI_HOST_BRIDGE(dev);
- i440fx->pci_info.w32.begin = below_4g_mem_size;
- i440fx->pci_info.w32.end = IO_APIC_DEFAULT_ADDRESS;
+ i440fx->pci_hole.begin = below_4g_mem_size;
+ i440fx->pci_hole.end = IO_APIC_DEFAULT_ADDRESS;
/* setup pci memory mapping */
pc_pci_as_mapping_init(OBJECT(f), f->system_memory,
diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c
index eb1b2f7..f908ba3 100644
--- a/hw/pci-host/q35.c
+++ b/hw/pci-host/q35.c
@@ -74,7 +74,7 @@ static void q35_host_get_pci_hole_start(Object *obj, Visitor *v,
Error **errp)
{
Q35PCIHost *s = Q35_HOST_DEVICE(obj);
- uint32_t value = s->mch.pci_info.w32.begin;
+ uint32_t value = s->mch.pci_hole.begin;
visit_type_uint32(v, name, &value, errp);
}
@@ -84,7 +84,7 @@ static void q35_host_get_pci_hole_end(Object *obj, Visitor *v,
Error **errp)
{
Q35PCIHost *s = Q35_HOST_DEVICE(obj);
- uint32_t value = s->mch.pci_info.w32.end;
+ uint32_t value = s->mch.pci_hole.end;
visit_type_uint32(v, name, &value, errp);
}
@@ -205,9 +205,9 @@ static void q35_host_initfn(Object *obj)
* it's not a power of two, which means an MTRR
* can't cover it exactly.
*/
- s->mch.pci_info.w32.begin = MCH_HOST_BRIDGE_PCIEXBAR_DEFAULT +
+ s->mch.pci_hole.begin = MCH_HOST_BRIDGE_PCIEXBAR_DEFAULT +
MCH_HOST_BRIDGE_PCIEXBAR_MAX;
- s->mch.pci_info.w32.end = IO_APIC_DEFAULT_ADDRESS;
+ s->mch.pci_hole.end = IO_APIC_DEFAULT_ADDRESS;
}
static const TypeInfo q35_host_info = {
@@ -288,9 +288,9 @@ static void mch_update_pciexbar(MCHPCIState *mch)
* which means an MTRR can't cover it exactly.
*/
if (enable) {
- mch->pci_info.w32.begin = addr + length;
+ mch->pci_hole.begin = addr + length;
} else {
- mch->pci_info.w32.begin = MCH_HOST_BRIDGE_PCIEXBAR_DEFAULT;
+ mch->pci_hole.begin = MCH_HOST_BRIDGE_PCIEXBAR_DEFAULT;
}
}
--
MST
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [Qemu-devel] [PULL 09/36] virtio: revert host notifiers to old semantics
[not found] <1467650742-17580-1-git-send-email-mst@redhat.com>
` (7 preceding siblings ...)
2016-07-04 16:46 ` [Qemu-devel] [PULL 08/36] pc: Eliminate PcPciInfo Michael S. Tsirkin
@ 2016-07-04 16:46 ` Michael S. Tsirkin
2016-07-04 16:46 ` [Qemu-devel] [PULL 10/36] virtio: set low features early on load Michael S. Tsirkin
` (26 subsequent siblings)
35 siblings, 0 replies; 43+ messages in thread
From: Michael S. Tsirkin @ 2016-07-04 16:46 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Cornelia Huck, Peter Lieven, Jason Wang,
Marc-André Lureau, Marc-André Lureau
From: Cornelia Huck <cornelia.huck@de.ibm.com>
The host notifier rework tried both to unify host notifiers across
transports and plug a possible hole during host notifier
re-assignment. Unfortunately, this meant a change in semantics that
breaks vhost and iSCSI+dataplane.
As the minimal fix, keep the common host notifier code but revert
to the old semantics so that we have time to figure out the proper
fix.
Fixes: 6798e245a3 ("virtio-bus: common ioeventfd infrastructure")
Reported-by: Peter Lieven <pl@kamp.de>
Reported-by: Jason Wang <jasowang@redhat.com>
Reported-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Jason Wang <jasowang@redhat.com>
Tested-by: Jason Wang <jasowang@redhat.com>
Tested-by: Peter Lieven <pl@kamp.de>
---
hw/virtio/virtio-bus.c | 26 ++++++++++----------------
1 file changed, 10 insertions(+), 16 deletions(-)
diff --git a/hw/virtio/virtio-bus.c b/hw/virtio/virtio-bus.c
index 1313760..a85b7c8 100644
--- a/hw/virtio/virtio-bus.c
+++ b/hw/virtio/virtio-bus.c
@@ -176,8 +176,8 @@ static int set_host_notifier_internal(DeviceState *proxy, VirtioBusState *bus,
return r;
}
} else {
- virtio_queue_set_host_notifier_fd_handler(vq, false, false);
k->ioeventfd_assign(proxy, notifier, n, assign);
+ virtio_queue_set_host_notifier_fd_handler(vq, false, false);
event_notifier_cleanup(notifier);
}
return r;
@@ -251,31 +251,25 @@ int virtio_bus_set_host_notifier(VirtioBusState *bus, int n, bool assign)
{
VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(bus);
DeviceState *proxy = DEVICE(BUS(bus)->parent);
- VirtIODevice *vdev = virtio_bus_get_device(bus);
- VirtQueue *vq = virtio_get_queue(vdev, n);
if (!k->ioeventfd_started) {
return -ENOSYS;
}
+ k->ioeventfd_set_disabled(proxy, assign);
if (assign) {
/*
* Stop using the generic ioeventfd, we are doing eventfd handling
* ourselves below
+ *
+ * FIXME: We should just switch the handler and not deassign the
+ * ioeventfd.
+ * Otherwise, there's a window where we don't have an
+ * ioeventfd and we may end up with a notification where
+ * we don't expect one.
*/
- k->ioeventfd_set_disabled(proxy, true);
- }
- /*
- * Just switch the handler, don't deassign the ioeventfd.
- * Otherwise, there's a window where we don't have an
- * ioeventfd and we may end up with a notification where
- * we don't expect one.
- */
- virtio_queue_set_host_notifier_fd_handler(vq, assign, !assign);
- if (!assign) {
- /* Use generic ioeventfd handler again. */
- k->ioeventfd_set_disabled(proxy, false);
+ virtio_bus_stop_ioeventfd(bus);
}
- return 0;
+ return set_host_notifier_internal(proxy, bus, n, assign, false);
}
static char *virtio_bus_get_dev_path(DeviceState *dev)
--
MST
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [Qemu-devel] [PULL 10/36] virtio: set low features early on load
[not found] <1467650742-17580-1-git-send-email-mst@redhat.com>
` (8 preceding siblings ...)
2016-07-04 16:46 ` [Qemu-devel] [PULL 09/36] virtio: revert host notifiers to old semantics Michael S. Tsirkin
@ 2016-07-04 16:46 ` Michael S. Tsirkin
2016-07-04 16:46 ` [Qemu-devel] [PULL 11/36] Revert "virtio-net: unbreak self announcement and guest offloads after migration" Michael S. Tsirkin
` (25 subsequent siblings)
35 siblings, 0 replies; 43+ messages in thread
From: Michael S. Tsirkin @ 2016-07-04 16:46 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, qemu-stable, Robin Geuze
virtio migrates the low 32 feature bits twice, the first copy is there
for compatibility but ever since
019a3edbb25f1571e876f8af1ce4c55412939e5d: ("virtio: make features 64bit
wide") it's ignored on load. This is wrong since virtio_net_load tests
self announcement and guest offloads before the second copy including
high feature bits is loaded. This means that self announcement, control
vq and guest offloads are all broken after migration.
Fix it up by loading low feature bits: somewhat ugly since high and low
bits become out of sync temporarily, but seems unavoidable for
compatibility. The right thing to do for new features is probably to
test the host features, anyway.
Fixes: 019a3edbb25f1571e876f8af1ce4c55412939e5d
("virtio: make features 64bit wide")
Cc: qemu-stable@nongnu.org
Reported-by: Robin Geuze <robing@transip.nl>
Tested-by: Robin Geuze <robing@transip.nl>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/virtio/virtio.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 7ed06ea..18153d5 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -1499,6 +1499,16 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f, int version_id)
}
qemu_get_be32s(f, &features);
+ /*
+ * Temporarily set guest_features low bits - needed by
+ * virtio net load code testing for VIRTIO_NET_F_CTRL_GUEST_OFFLOADS
+ * VIRTIO_NET_F_GUEST_ANNOUNCE and VIRTIO_NET_F_CTRL_VQ.
+ *
+ * Note: devices should always test host features in future - don't create
+ * new dependencies like this.
+ */
+ vdev->guest_features = features;
+
config_len = qemu_get_be32(f);
/*
--
MST
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [Qemu-devel] [PULL 11/36] Revert "virtio-net: unbreak self announcement and guest offloads after migration"
[not found] <1467650742-17580-1-git-send-email-mst@redhat.com>
` (9 preceding siblings ...)
2016-07-04 16:46 ` [Qemu-devel] [PULL 10/36] virtio: set low features early on load Michael S. Tsirkin
@ 2016-07-04 16:46 ` Michael S. Tsirkin
2016-07-04 16:46 ` [Qemu-devel] [PULL 12/36] pci_register_bar: cleanup Michael S. Tsirkin
` (24 subsequent siblings)
35 siblings, 0 replies; 43+ messages in thread
From: Michael S. Tsirkin @ 2016-07-04 16:46 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, qemu-stable, Robin Geuze, Jason Wang
This reverts commit 1f8828ef573c83365b4a87a776daf8bcef1caa21.
Cc: qemu-stable@nongnu.org
Reported-by: Robin Geuze <robing@transip.nl>
Tested-by: Robin Geuze <robing@transip.nl>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/net/virtio-net.c | 40 +++++++++++++++++-----------------------
1 file changed, 17 insertions(+), 23 deletions(-)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 7e6a60a..9999899 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -1542,33 +1542,11 @@ static int virtio_net_load(QEMUFile *f, void *opaque, int version_id)
{
VirtIONet *n = opaque;
VirtIODevice *vdev = VIRTIO_DEVICE(n);
- int ret;
if (version_id < 2 || version_id > VIRTIO_NET_VM_VERSION)
return -EINVAL;
- ret = virtio_load(vdev, f, version_id);
- if (ret) {
- return ret;
- }
-
- if (virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS)) {
- n->curr_guest_offloads = qemu_get_be64(f);
- } else {
- n->curr_guest_offloads = virtio_net_supported_guest_offloads(n);
- }
-
- if (peer_has_vnet_hdr(n)) {
- virtio_net_apply_guest_offloads(n);
- }
-
- if (virtio_vdev_has_feature(vdev, VIRTIO_NET_F_GUEST_ANNOUNCE) &&
- virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ)) {
- n->announce_counter = SELF_ANNOUNCE_ROUNDS;
- timer_mod(n->announce_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL));
- }
-
- return 0;
+ return virtio_load(vdev, f, version_id);
}
static int virtio_net_load_device(VirtIODevice *vdev, QEMUFile *f,
@@ -1665,6 +1643,16 @@ static int virtio_net_load_device(VirtIODevice *vdev, QEMUFile *f,
}
}
+ if (virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS)) {
+ n->curr_guest_offloads = qemu_get_be64(f);
+ } else {
+ n->curr_guest_offloads = virtio_net_supported_guest_offloads(n);
+ }
+
+ if (peer_has_vnet_hdr(n)) {
+ virtio_net_apply_guest_offloads(n);
+ }
+
virtio_net_set_queues(n);
/* Find the first multicast entry in the saved MAC filter */
@@ -1682,6 +1670,12 @@ static int virtio_net_load_device(VirtIODevice *vdev, QEMUFile *f,
qemu_get_subqueue(n->nic, i)->link_down = link_down;
}
+ if (virtio_vdev_has_feature(vdev, VIRTIO_NET_F_GUEST_ANNOUNCE) &&
+ virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ)) {
+ n->announce_counter = SELF_ANNOUNCE_ROUNDS;
+ timer_mod(n->announce_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL));
+ }
+
return 0;
}
--
MST
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [Qemu-devel] [PULL 12/36] pci_register_bar: cleanup
[not found] <1467650742-17580-1-git-send-email-mst@redhat.com>
` (10 preceding siblings ...)
2016-07-04 16:46 ` [Qemu-devel] [PULL 11/36] Revert "virtio-net: unbreak self announcement and guest offloads after migration" Michael S. Tsirkin
@ 2016-07-04 16:46 ` Michael S. Tsirkin
2016-07-04 16:46 ` [Qemu-devel] [PULL 13/36] log: Clean up misuse of Range for -dfilter Michael S. Tsirkin
` (23 subsequent siblings)
35 siblings, 0 replies; 43+ messages in thread
From: Michael S. Tsirkin @ 2016-07-04 16:46 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Cao jin, Paolo Bonzini, Marcel Apfelbaum
From: Cao jin <caoj.fnst@cn.fujitsu.com>
place relevant code tegother, make the code easier to read
Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
---
hw/pci/pci.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index ee385eb..8c2f6ed 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -1074,7 +1074,7 @@ void pci_register_bar(PCIDevice *pci_dev, int region_num,
uint8_t type, MemoryRegion *memory)
{
PCIIORegion *r;
- uint32_t addr;
+ uint32_t addr; /* offset in pci config space */
uint64_t wmask;
pcibus_t size = memory_region_size(memory);
@@ -1090,15 +1090,20 @@ void pci_register_bar(PCIDevice *pci_dev, int region_num,
r->addr = PCI_BAR_UNMAPPED;
r->size = size;
r->type = type;
- r->memory = NULL;
+ r->memory = memory;
+ r->address_space = type & PCI_BASE_ADDRESS_SPACE_IO
+ ? pci_dev->bus->address_space_io
+ : pci_dev->bus->address_space_mem;
wmask = ~(size - 1);
- addr = pci_bar(pci_dev, region_num);
if (region_num == PCI_ROM_SLOT) {
/* ROM enable bit is writable */
wmask |= PCI_ROM_ADDRESS_ENABLE;
}
+
+ addr = pci_bar(pci_dev, region_num);
pci_set_long(pci_dev->config + addr, type);
+
if (!(r->type & PCI_BASE_ADDRESS_SPACE_IO) &&
r->type & PCI_BASE_ADDRESS_MEM_TYPE_64) {
pci_set_quad(pci_dev->wmask + addr, wmask);
@@ -1107,11 +1112,6 @@ void pci_register_bar(PCIDevice *pci_dev, int region_num,
pci_set_long(pci_dev->wmask + addr, wmask & 0xffffffff);
pci_set_long(pci_dev->cmask + addr, 0xffffffff);
}
- pci_dev->io_regions[region_num].memory = memory;
- pci_dev->io_regions[region_num].address_space
- = type & PCI_BASE_ADDRESS_SPACE_IO
- ? pci_dev->bus->address_space_io
- : pci_dev->bus->address_space_mem;
}
static void pci_update_vga(PCIDevice *pci_dev)
--
MST
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [Qemu-devel] [PULL 13/36] log: Clean up misuse of Range for -dfilter
[not found] <1467650742-17580-1-git-send-email-mst@redhat.com>
` (11 preceding siblings ...)
2016-07-04 16:46 ` [Qemu-devel] [PULL 12/36] pci_register_bar: cleanup Michael S. Tsirkin
@ 2016-07-04 16:46 ` Michael S. Tsirkin
2016-07-04 16:46 ` [Qemu-devel] [PULL 14/36] range: Eliminate direct Range member access Michael S. Tsirkin
` (22 subsequent siblings)
35 siblings, 0 replies; 43+ messages in thread
From: Michael S. Tsirkin @ 2016-07-04 16:46 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Markus Armbruster, Eric Blake, Paolo Bonzini,
Alex Bennée
From: Markus Armbruster <armbru@redhat.com>
Range encodes an integer interval [a,b] as { begin = a, end = b + 1 },
where a \in [0,2^64-1] and b \in [1,2^64]. Thus, zero end is to be
interpreted as 2^64.
The implementation of -dfilter (commit 3514552) uses Range
differently: it encodes [a,b] as { begin = a, end = b }. The code
works, but it contradicts the specification of Range in range.h.
Switch to the specified representation. Since it can't represent
[0,UINT64_MAX], we have to reject that now. Add a test for it.
While we're rejecting anyway: observe that we reject -dfilter LOB..UPB
where LOB > UPB when UPB is zero, but happily create an empty Range
when it isn't. Reject it then, too, and add a test for it.
While there, add a positive test for the problematic upper bound
UINT64_MAX.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
tests/test-logging.c | 10 ++++++++++
util/log.c | 28 +++++++++++++++-------------
2 files changed, 25 insertions(+), 13 deletions(-)
diff --git a/tests/test-logging.c b/tests/test-logging.c
index 440e75f..b6fa94e 100644
--- a/tests/test-logging.c
+++ b/tests/test-logging.c
@@ -68,6 +68,16 @@ static void test_parse_range(void)
g_assert(qemu_log_in_addr_range(0x2050));
g_assert(qemu_log_in_addr_range(0x3050));
+ qemu_set_dfilter_ranges("0xffffffffffffffff-1", &error_abort);
+ g_assert(qemu_log_in_addr_range(UINT64_MAX));
+ g_assert_false(qemu_log_in_addr_range(UINT64_MAX - 1));
+
+ qemu_set_dfilter_ranges("0..0xffffffffffffffff", &err);
+ error_free_or_abort(&err);
+
+ qemu_set_dfilter_ranges("2..1", &err);
+ error_free_or_abort(&err);
+
qemu_set_dfilter_ranges("0x1000+onehundred", &err);
error_free_or_abort(&err);
diff --git a/util/log.c b/util/log.c
index 32e4160..f811d61 100644
--- a/util/log.c
+++ b/util/log.c
@@ -131,8 +131,8 @@ bool qemu_log_in_addr_range(uint64_t addr)
if (debug_regions) {
int i = 0;
for (i = 0; i < debug_regions->len; i++) {
- struct Range *range = &g_array_index(debug_regions, Range, i);
- if (addr >= range->begin && addr <= range->end) {
+ Range *range = &g_array_index(debug_regions, Range, i);
+ if (addr >= range->begin && addr <= range->end - 1) {
return true;
}
}
@@ -158,7 +158,7 @@ void qemu_set_dfilter_ranges(const char *filter_spec, Error **errp)
for (i = 0; ranges[i]; i++) {
const char *r = ranges[i];
const char *range_op, *r2, *e;
- uint64_t r1val, r2val;
+ uint64_t r1val, r2val, lob, upb;
struct Range range;
range_op = strstr(r, "-");
@@ -187,27 +187,29 @@ void qemu_set_dfilter_ranges(const char *filter_spec, Error **errp)
(int)(r2 - range_op), range_op);
goto out;
}
- if (r2val == 0) {
- error_setg(errp, "Invalid range");
- goto out;
- }
switch (*range_op) {
case '+':
- range.begin = r1val;
- range.end = r1val + (r2val - 1);
+ lob = r1val;
+ upb = r1val + r2val - 1;
break;
case '-':
- range.end = r1val;
- range.begin = r1val - (r2val - 1);
+ upb = r1val;
+ lob = r1val - (r2val - 1);
break;
case '.':
- range.begin = r1val;
- range.end = r2val;
+ lob = r1val;
+ upb = r2val;
break;
default:
g_assert_not_reached();
}
+ if (lob > upb || (lob == 0 && upb == UINT64_MAX)) {
+ error_setg(errp, "Invalid range");
+ goto out;
+ }
+ range.begin = lob;
+ range.end = upb + 1;
g_array_append_val(debug_regions, range);
}
out:
--
MST
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [Qemu-devel] [PULL 14/36] range: Eliminate direct Range member access
[not found] <1467650742-17580-1-git-send-email-mst@redhat.com>
` (12 preceding siblings ...)
2016-07-04 16:46 ` [Qemu-devel] [PULL 13/36] log: Clean up misuse of Range for -dfilter Michael S. Tsirkin
@ 2016-07-04 16:46 ` Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 15/36] range: Replace internal representation of Range Michael S. Tsirkin
` (21 subsequent siblings)
35 siblings, 0 replies; 43+ messages in thread
From: Michael S. Tsirkin @ 2016-07-04 16:46 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Markus Armbruster, Eric Blake, Igor Mammedov,
Paolo Bonzini, Richard Henderson, Eduardo Habkost,
Marcel Apfelbaum, Michael Roth
From: Markus Armbruster <armbru@redhat.com>
Users of struct Range mess liberally with its members, which makes
refactoring hard. Create a set of methods, and convert all users to
call them instead of accessing members. The methods have carefully
worded contracts, and use assertions to check them.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
include/qemu/range.h | 85 ++++++++++++++++++++++++++++++++++++++++++--
hw/i386/acpi-build.c | 35 +++++++++---------
hw/pci-host/piix.c | 26 +++++++++-----
hw/pci-host/q35.c | 41 +++++++++++++--------
hw/pci/pci.c | 17 ++++-----
qapi/string-input-visitor.c | 20 +++++------
qapi/string-output-visitor.c | 18 +++++-----
util/log.c | 5 ++-
util/range.c | 3 +-
9 files changed, 176 insertions(+), 74 deletions(-)
diff --git a/include/qemu/range.h b/include/qemu/range.h
index 3970f00..c8c46a9 100644
--- a/include/qemu/range.h
+++ b/include/qemu/range.h
@@ -36,12 +36,91 @@ struct Range {
uint64_t end; /* 1 + the last byte. 0 if range empty or ends at ~0x0LL. */
};
+static inline void range_invariant(Range *range)
+{
+ assert((!range->begin && !range->end) /* empty */
+ || range->begin <= range->end - 1); /* non-empty */
+}
+
+/* Compound literal encoding the empty range */
+#define range_empty ((Range){ .begin = 0, .end = 0 })
+
+/* Is @range empty? */
+static inline bool range_is_empty(Range *range)
+{
+ range_invariant(range);
+ return !range->begin && !range->end;
+}
+
+/* Does @range contain @val? */
+static inline bool range_contains(Range *range, uint64_t val)
+{
+ return !range_is_empty(range)
+ && val >= range->begin && val <= range->end - 1;
+}
+
+/* Initialize @range to the empty range */
+static inline void range_make_empty(Range *range)
+{
+ *range = range_empty;
+ assert(range_is_empty(range));
+}
+
+/*
+ * Initialize @range to span the interval [@lob,@upb].
+ * Both bounds are inclusive.
+ * The interval must not be empty, i.e. @lob must be less than or
+ * equal @upb.
+ * The interval must not be [0,UINT64_MAX], because Range can't
+ * represent that.
+ */
+static inline void range_set_bounds(Range *range, uint64_t lob, uint64_t upb)
+{
+ assert(lob <= upb);
+ range->begin = lob;
+ range->end = upb + 1; /* may wrap to zero, that's okay */
+ assert(!range_is_empty(range));
+}
+
+/*
+ * Initialize @range to span the interval [@lob,@upb_plus1).
+ * The lower bound is inclusive, the upper bound is exclusive.
+ * Zero @upb_plus1 is special: if @lob is also zero, set @range to the
+ * empty range. Else, set @range to [@lob,UINT64_MAX].
+ */
+static inline void range_set_bounds1(Range *range,
+ uint64_t lob, uint64_t upb_plus1)
+{
+ range->begin = lob;
+ range->end = upb_plus1;
+ range_invariant(range);
+}
+
+/* Return @range's lower bound. @range must not be empty. */
+static inline uint64_t range_lob(Range *range)
+{
+ assert(!range_is_empty(range));
+ return range->begin;
+}
+
+/* Return @range's upper bound. @range must not be empty. */
+static inline uint64_t range_upb(Range *range)
+{
+ assert(!range_is_empty(range));
+ return range->end - 1;
+}
+
+/*
+ * Extend @range to the smallest interval that includes @extend_by, too.
+ * This must not extend @range to cover the interval [0,UINT64_MAX],
+ * because Range can't represent that.
+ */
static inline void range_extend(Range *range, Range *extend_by)
{
- if (!extend_by->begin && !extend_by->end) {
+ if (range_is_empty(extend_by)) {
return;
}
- if (!range->begin && !range->end) {
+ if (range_is_empty(range)) {
*range = *extend_by;
return;
}
@@ -52,6 +131,8 @@ static inline void range_extend(Range *range, Range *extend_by)
if (range->end - 1 < extend_by->end - 1) {
range->end = extend_by->end;
}
+ /* Must not extend to { .begin = 0, .end = 0 }: */
+ assert(!range_is_empty(range));
}
/* Get last byte of a range from offset + length.
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 576c7af..fbba461 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -236,18 +236,20 @@ static void acpi_get_pci_holes(Range *hole, Range *hole64)
pci_host = acpi_get_i386_pci_host();
g_assert(pci_host);
- hole->begin = object_property_get_int(pci_host,
- PCI_HOST_PROP_PCI_HOLE_START,
- NULL);
- hole->end = object_property_get_int(pci_host,
- PCI_HOST_PROP_PCI_HOLE_END,
- NULL);
- hole64->begin = object_property_get_int(pci_host,
- PCI_HOST_PROP_PCI_HOLE64_START,
- NULL);
- hole64->end = object_property_get_int(pci_host,
- PCI_HOST_PROP_PCI_HOLE64_END,
- NULL);
+ range_set_bounds1(hole,
+ object_property_get_int(pci_host,
+ PCI_HOST_PROP_PCI_HOLE_START,
+ NULL),
+ object_property_get_int(pci_host,
+ PCI_HOST_PROP_PCI_HOLE_END,
+ NULL));
+ range_set_bounds1(hole64,
+ object_property_get_int(pci_host,
+ PCI_HOST_PROP_PCI_HOLE64_START,
+ NULL),
+ object_property_get_int(pci_host,
+ PCI_HOST_PROP_PCI_HOLE64_END,
+ NULL));
}
#define ACPI_PORT_SMI_CMD 0x00b2 /* TODO: this is APM_CNT_IOPORT */
@@ -2047,7 +2049,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
0, 0x000A0000, 0x000BFFFF, 0, 0x00020000));
crs_replace_with_free_ranges(mem_ranges,
- pci_hole->begin, pci_hole->end - 1);
+ range_lob(pci_hole),
+ range_upb(pci_hole));
for (i = 0; i < mem_ranges->len; i++) {
entry = g_ptr_array_index(mem_ranges, i);
aml_append(crs,
@@ -2057,12 +2060,12 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
0, entry->limit - entry->base + 1));
}
- if (pci_hole64->begin) {
+ if (!range_is_empty(pci_hole64)) {
aml_append(crs,
aml_qword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED,
AML_CACHEABLE, AML_READ_WRITE,
- 0, pci_hole64->begin, pci_hole64->end - 1, 0,
- pci_hole64->end - pci_hole64->begin));
+ 0, range_lob(pci_hole64), range_upb(pci_hole64), 0,
+ range_upb(pci_hole64) + 1 - range_lob(pci_hole64)));
}
if (misc->tpm_version != TPM_VERSION_UNSPEC) {
diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c
index b1bfc59..f9218aa 100644
--- a/hw/pci-host/piix.c
+++ b/hw/pci-host/piix.c
@@ -221,8 +221,12 @@ static void i440fx_pcihost_get_pci_hole_start(Object *obj, Visitor *v,
Error **errp)
{
I440FXState *s = I440FX_PCI_HOST_BRIDGE(obj);
- uint32_t value = s->pci_hole.begin;
+ uint64_t val64;
+ uint32_t value;
+ val64 = range_is_empty(&s->pci_hole) ? 0 : range_lob(&s->pci_hole);
+ value = val64;
+ assert(value == val64);
visit_type_uint32(v, name, &value, errp);
}
@@ -231,8 +235,12 @@ static void i440fx_pcihost_get_pci_hole_end(Object *obj, Visitor *v,
Error **errp)
{
I440FXState *s = I440FX_PCI_HOST_BRIDGE(obj);
- uint32_t value = s->pci_hole.end;
+ uint64_t val64;
+ uint32_t value;
+ val64 = range_is_empty(&s->pci_hole) ? 0 : range_upb(&s->pci_hole) + 1;
+ value = val64;
+ assert(value == val64);
visit_type_uint32(v, name, &value, errp);
}
@@ -242,10 +250,11 @@ static void i440fx_pcihost_get_pci_hole64_start(Object *obj, Visitor *v,
{
PCIHostState *h = PCI_HOST_BRIDGE(obj);
Range w64;
+ uint64_t value;
pci_bus_get_w64_range(h->bus, &w64);
-
- visit_type_uint64(v, name, &w64.begin, errp);
+ value = range_is_empty(&w64) ? 0 : range_lob(&w64);
+ visit_type_uint64(v, name, &value, errp);
}
static void i440fx_pcihost_get_pci_hole64_end(Object *obj, Visitor *v,
@@ -254,10 +263,11 @@ static void i440fx_pcihost_get_pci_hole64_end(Object *obj, Visitor *v,
{
PCIHostState *h = PCI_HOST_BRIDGE(obj);
Range w64;
+ uint64_t value;
pci_bus_get_w64_range(h->bus, &w64);
-
- visit_type_uint64(v, name, &w64.end, errp);
+ value = range_is_empty(&w64) ? 0 : range_upb(&w64) + 1;
+ visit_type_uint64(v, name, &value, errp);
}
static void i440fx_pcihost_initfn(Object *obj)
@@ -344,8 +354,8 @@ PCIBus *i440fx_init(const char *host_type, const char *pci_type,
f->ram_memory = ram_memory;
i440fx = I440FX_PCI_HOST_BRIDGE(dev);
- i440fx->pci_hole.begin = below_4g_mem_size;
- i440fx->pci_hole.end = IO_APIC_DEFAULT_ADDRESS;
+ range_set_bounds(&i440fx->pci_hole, below_4g_mem_size,
+ IO_APIC_DEFAULT_ADDRESS - 1);
/* setup pci memory mapping */
pc_pci_as_mapping_init(OBJECT(f), f->system_memory,
diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c
index f908ba3..344f77b 100644
--- a/hw/pci-host/q35.c
+++ b/hw/pci-host/q35.c
@@ -74,8 +74,13 @@ static void q35_host_get_pci_hole_start(Object *obj, Visitor *v,
Error **errp)
{
Q35PCIHost *s = Q35_HOST_DEVICE(obj);
- uint32_t value = s->mch.pci_hole.begin;
+ uint64_t val64;
+ uint32_t value;
+ val64 = range_is_empty(&s->mch.pci_hole)
+ ? 0 : range_lob(&s->mch.pci_hole);
+ value = val64;
+ assert(value == val64);
visit_type_uint32(v, name, &value, errp);
}
@@ -84,8 +89,13 @@ static void q35_host_get_pci_hole_end(Object *obj, Visitor *v,
Error **errp)
{
Q35PCIHost *s = Q35_HOST_DEVICE(obj);
- uint32_t value = s->mch.pci_hole.end;
+ uint64_t val64;
+ uint32_t value;
+ val64 = range_is_empty(&s->mch.pci_hole)
+ ? 0 : range_upb(&s->mch.pci_hole) + 1;
+ value = val64;
+ assert(value == val64);
visit_type_uint32(v, name, &value, errp);
}
@@ -95,10 +105,11 @@ static void q35_host_get_pci_hole64_start(Object *obj, Visitor *v,
{
PCIHostState *h = PCI_HOST_BRIDGE(obj);
Range w64;
+ uint64_t value;
pci_bus_get_w64_range(h->bus, &w64);
-
- visit_type_uint64(v, name, &w64.begin, errp);
+ value = range_is_empty(&w64) ? 0 : range_lob(&w64);
+ visit_type_uint64(v, name, &value, errp);
}
static void q35_host_get_pci_hole64_end(Object *obj, Visitor *v,
@@ -107,10 +118,11 @@ static void q35_host_get_pci_hole64_end(Object *obj, Visitor *v,
{
PCIHostState *h = PCI_HOST_BRIDGE(obj);
Range w64;
+ uint64_t value;
pci_bus_get_w64_range(h->bus, &w64);
-
- visit_type_uint64(v, name, &w64.end, errp);
+ value = range_is_empty(&w64) ? 0 : range_upb(&w64) + 1;
+ visit_type_uint64(v, name, &value, errp);
}
static void q35_host_get_mmcfg_size(Object *obj, Visitor *v, const char *name,
@@ -205,9 +217,9 @@ static void q35_host_initfn(Object *obj)
* it's not a power of two, which means an MTRR
* can't cover it exactly.
*/
- s->mch.pci_hole.begin = MCH_HOST_BRIDGE_PCIEXBAR_DEFAULT +
- MCH_HOST_BRIDGE_PCIEXBAR_MAX;
- s->mch.pci_hole.end = IO_APIC_DEFAULT_ADDRESS;
+ range_set_bounds(&s->mch.pci_hole,
+ MCH_HOST_BRIDGE_PCIEXBAR_DEFAULT + MCH_HOST_BRIDGE_PCIEXBAR_MAX,
+ IO_APIC_DEFAULT_ADDRESS - 1);
}
static const TypeInfo q35_host_info = {
@@ -275,10 +287,7 @@ static void mch_update_pciexbar(MCHPCIState *mch)
break;
case MCH_HOST_BRIDGE_PCIEXBAR_LENGTH_RVD:
default:
- enable = 0;
- length = 0;
abort();
- break;
}
addr = pciexbar & addr_mask;
pcie_host_mmcfg_update(pehb, enable, addr, length);
@@ -288,9 +297,13 @@ static void mch_update_pciexbar(MCHPCIState *mch)
* which means an MTRR can't cover it exactly.
*/
if (enable) {
- mch->pci_hole.begin = addr + length;
+ range_set_bounds(&mch->pci_hole,
+ addr + length,
+ IO_APIC_DEFAULT_ADDRESS - 1);
} else {
- mch->pci_hole.begin = MCH_HOST_BRIDGE_PCIEXBAR_DEFAULT;
+ range_set_bounds(&mch->pci_hole,
+ MCH_HOST_BRIDGE_PCIEXBAR_DEFAULT,
+ IO_APIC_DEFAULT_ADDRESS - 1);
}
}
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 8c2f6ed..149994b 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -2533,13 +2533,13 @@ static void pci_dev_get_w64(PCIBus *b, PCIDevice *dev, void *opaque)
if (limit >= base) {
Range pref_range;
- pref_range.begin = base;
- pref_range.end = limit + 1;
+ range_set_bounds(&pref_range, base, limit);
range_extend(range, &pref_range);
}
}
for (i = 0; i < PCI_NUM_REGIONS; ++i) {
PCIIORegion *r = &dev->io_regions[i];
+ pcibus_t lob, upb;
Range region_range;
if (!r->size ||
@@ -2547,16 +2547,17 @@ static void pci_dev_get_w64(PCIBus *b, PCIDevice *dev, void *opaque)
!(r->type & PCI_BASE_ADDRESS_MEM_TYPE_64)) {
continue;
}
- region_range.begin = pci_bar_address(dev, i, r->type, r->size);
- region_range.end = region_range.begin + r->size;
- if (region_range.begin == PCI_BAR_UNMAPPED) {
+ lob = pci_bar_address(dev, i, r->type, r->size);
+ upb = lob + r->size - 1;
+ if (lob == PCI_BAR_UNMAPPED) {
continue;
}
- region_range.begin = MAX(region_range.begin, 0x1ULL << 32);
+ lob = MAX(lob, 0x1ULL << 32);
- if (region_range.end - 1 >= region_range.begin) {
+ if (upb >= lob) {
+ range_set_bounds(®ion_range, lob, upb);
range_extend(range, ®ion_range);
}
}
@@ -2564,7 +2565,7 @@ static void pci_dev_get_w64(PCIBus *b, PCIDevice *dev, void *opaque)
void pci_bus_get_w64_range(PCIBus *bus, Range *range)
{
- range->begin = range->end = 0;
+ range_make_empty(range);
pci_for_each_device_under_bus(bus, pci_dev_get_w64, range);
}
diff --git a/qapi/string-input-visitor.c b/qapi/string-input-visitor.c
index b546e5f..0690abb 100644
--- a/qapi/string-input-visitor.c
+++ b/qapi/string-input-visitor.c
@@ -59,8 +59,7 @@ static int parse_str(StringInputVisitor *siv, const char *name, Error **errp)
if (errno == 0 && endptr > str) {
if (*endptr == '\0') {
cur = g_malloc0(sizeof(*cur));
- cur->begin = start;
- cur->end = start + 1;
+ range_set_bounds(cur, start, start);
siv->ranges = range_list_insert(siv->ranges, cur);
cur = NULL;
str = NULL;
@@ -73,16 +72,14 @@ static int parse_str(StringInputVisitor *siv, const char *name, Error **errp)
end < start + 65536)) {
if (*endptr == '\0') {
cur = g_malloc0(sizeof(*cur));
- cur->begin = start;
- cur->end = end + 1;
+ range_set_bounds(cur, start, end);
siv->ranges = range_list_insert(siv->ranges, cur);
cur = NULL;
str = NULL;
} else if (*endptr == ',') {
str = endptr + 1;
cur = g_malloc0(sizeof(*cur));
- cur->begin = start;
- cur->end = end + 1;
+ range_set_bounds(cur, start, end);
siv->ranges = range_list_insert(siv->ranges, cur);
cur = NULL;
} else {
@@ -94,8 +91,7 @@ static int parse_str(StringInputVisitor *siv, const char *name, Error **errp)
} else if (*endptr == ',') {
str = endptr + 1;
cur = g_malloc0(sizeof(*cur));
- cur->begin = start;
- cur->end = start + 1;
+ range_set_bounds(cur, start, start);
siv->ranges = range_list_insert(siv->ranges, cur);
cur = NULL;
} else {
@@ -134,7 +130,7 @@ start_list(Visitor *v, const char *name, GenericList **list, size_t size,
if (siv->cur_range) {
Range *r = siv->cur_range->data;
if (r) {
- siv->cur = r->begin;
+ siv->cur = range_lob(r);
}
*list = g_malloc0(size);
} else {
@@ -156,7 +152,7 @@ static GenericList *next_list(Visitor *v, GenericList *tail, size_t size)
return NULL;
}
- if (siv->cur < r->begin || siv->cur >= r->end) {
+ if (!range_contains(r, siv->cur)) {
siv->cur_range = g_list_next(siv->cur_range);
if (!siv->cur_range) {
return NULL;
@@ -165,7 +161,7 @@ static GenericList *next_list(Visitor *v, GenericList *tail, size_t size)
if (!r) {
return NULL;
}
- siv->cur = r->begin;
+ siv->cur = range_lob(r);
}
tail->next = g_malloc0(size);
@@ -208,7 +204,7 @@ static void parse_type_int64(Visitor *v, const char *name, int64_t *obj,
goto error;
}
- siv->cur = r->begin;
+ siv->cur = range_lob(r);
}
*obj = siv->cur;
diff --git a/qapi/string-output-visitor.c b/qapi/string-output-visitor.c
index 5ea395a..c6f01f9 100644
--- a/qapi/string-output-visitor.c
+++ b/qapi/string-output-visitor.c
@@ -83,8 +83,8 @@ static void string_output_set(StringOutputVisitor *sov, char *string)
static void string_output_append(StringOutputVisitor *sov, int64_t a)
{
Range *r = g_malloc0(sizeof(*r));
- r->begin = a;
- r->end = a + 1;
+
+ range_set_bounds(r, a, a);
sov->ranges = range_list_insert(sov->ranges, r);
}
@@ -92,28 +92,28 @@ static void string_output_append_range(StringOutputVisitor *sov,
int64_t s, int64_t e)
{
Range *r = g_malloc0(sizeof(*r));
- r->begin = s;
- r->end = e + 1;
+
+ range_set_bounds(r, s, e);
sov->ranges = range_list_insert(sov->ranges, r);
}
static void format_string(StringOutputVisitor *sov, Range *r, bool next,
bool human)
{
- if (r->end - r->begin > 1) {
+ if (range_lob(r) != range_upb(r)) {
if (human) {
g_string_append_printf(sov->string, "0x%" PRIx64 "-0x%" PRIx64,
- r->begin, r->end - 1);
+ range_lob(r), range_upb(r));
} else {
g_string_append_printf(sov->string, "%" PRId64 "-%" PRId64,
- r->begin, r->end - 1);
+ range_lob(r), range_upb(r));
}
} else {
if (human) {
- g_string_append_printf(sov->string, "0x%" PRIx64, r->begin);
+ g_string_append_printf(sov->string, "0x%" PRIx64, range_lob(r));
} else {
- g_string_append_printf(sov->string, "%" PRId64, r->begin);
+ g_string_append_printf(sov->string, "%" PRId64, range_lob(r));
}
}
if (next) {
diff --git a/util/log.c b/util/log.c
index f811d61..4da635c 100644
--- a/util/log.c
+++ b/util/log.c
@@ -132,7 +132,7 @@ bool qemu_log_in_addr_range(uint64_t addr)
int i = 0;
for (i = 0; i < debug_regions->len; i++) {
Range *range = &g_array_index(debug_regions, Range, i);
- if (addr >= range->begin && addr <= range->end - 1) {
+ if (range_contains(range, addr)) {
return true;
}
}
@@ -208,8 +208,7 @@ void qemu_set_dfilter_ranges(const char *filter_spec, Error **errp)
error_setg(errp, "Invalid range");
goto out;
}
- range.begin = lob;
- range.end = upb + 1;
+ range_set_bounds(&range, lob, upb);
g_array_append_val(debug_regions, range);
}
out:
diff --git a/util/range.c b/util/range.c
index e90c988..e5f2e71 100644
--- a/util/range.c
+++ b/util/range.c
@@ -46,8 +46,7 @@ GList *range_list_insert(GList *list, Range *data)
{
GList *l;
- /* Range lists require no empty ranges */
- assert(data->begin < data->end || (data->begin && !data->end));
+ assert(!range_is_empty(data));
/* Skip all list elements strictly less than data */
for (l = list; l && range_compare(l->data, data) < 0; l = l->next) {
--
MST
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [Qemu-devel] [PULL 15/36] range: Replace internal representation of Range
[not found] <1467650742-17580-1-git-send-email-mst@redhat.com>
` (13 preceding siblings ...)
2016-07-04 16:46 ` [Qemu-devel] [PULL 14/36] range: Eliminate direct Range member access Michael S. Tsirkin
@ 2016-07-04 16:47 ` Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 16/36] log: Permit -dfilter 0..0xffffffffffffffff Michael S. Tsirkin
` (20 subsequent siblings)
35 siblings, 0 replies; 43+ messages in thread
From: Michael S. Tsirkin @ 2016-07-04 16:47 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Markus Armbruster, Eric Blake, Paolo Bonzini
From: Markus Armbruster <armbru@redhat.com>
Range represents a range as follows. Member @start is the inclusive
lower bound, member @end is the exclusive upper bound. Zero @end is
special: if @start is also zero, the range is empty, else @end is to
be interpreted as 2^64. No other empty ranges may occur.
The range [0,2^64-1] cannot be represented. If you try to create it
with range_set_bounds1(), you get the empty range instead. If you try
to create it with range_set_bounds() or range_extend(), assertions
fail. Before range_set_bounds() existed, the open-coded creation
usually got you the empty range instead. Open deathtrap.
Moreover, the code dealing with the janus-faced @end is too clever by
half.
Dumb this down to a more pedestrian representation: members @lob and
@upb are inclusive lower and upper bounds. The empty range is encoded
as @lob = 1, @upb = 0.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
include/qemu/range.h | 56 +++++++++++++++++++++++++---------------------------
util/range.c | 16 +++++++--------
2 files changed, 34 insertions(+), 38 deletions(-)
diff --git a/include/qemu/range.h b/include/qemu/range.h
index c8c46a9..f28f0c1 100644
--- a/include/qemu/range.h
+++ b/include/qemu/range.h
@@ -26,37 +26,38 @@
/*
* Operations on 64 bit address ranges.
* Notes:
- * - ranges must not wrap around 0, but can include the last byte ~0x0LL.
- * - this can not represent a full 0 to ~0x0LL range.
+ * - Ranges must not wrap around 0, but can include UINT64_MAX.
*/
-/* A structure representing a range of addresses. */
struct Range {
- uint64_t begin; /* First byte of the range, or 0 if empty. */
- uint64_t end; /* 1 + the last byte. 0 if range empty or ends at ~0x0LL. */
+ /*
+ * Do not access members directly, use the functions!
+ * A non-empty range has @lob <= @upb.
+ * An empty range has @lob == @upb + 1.
+ */
+ uint64_t lob; /* inclusive lower bound */
+ uint64_t upb; /* inclusive upper bound */
};
static inline void range_invariant(Range *range)
{
- assert((!range->begin && !range->end) /* empty */
- || range->begin <= range->end - 1); /* non-empty */
+ assert(range->lob <= range->upb || range->lob == range->upb + 1);
}
/* Compound literal encoding the empty range */
-#define range_empty ((Range){ .begin = 0, .end = 0 })
+#define range_empty ((Range){ .lob = 1, .upb = 0 })
/* Is @range empty? */
static inline bool range_is_empty(Range *range)
{
range_invariant(range);
- return !range->begin && !range->end;
+ return range->lob > range->upb;
}
/* Does @range contain @val? */
static inline bool range_contains(Range *range, uint64_t val)
{
- return !range_is_empty(range)
- && val >= range->begin && val <= range->end - 1;
+ return val >= range->lob && val <= range->upb;
}
/* Initialize @range to the empty range */
@@ -71,14 +72,11 @@ static inline void range_make_empty(Range *range)
* Both bounds are inclusive.
* The interval must not be empty, i.e. @lob must be less than or
* equal @upb.
- * The interval must not be [0,UINT64_MAX], because Range can't
- * represent that.
*/
static inline void range_set_bounds(Range *range, uint64_t lob, uint64_t upb)
{
- assert(lob <= upb);
- range->begin = lob;
- range->end = upb + 1; /* may wrap to zero, that's okay */
+ range->lob = lob;
+ range->upb = upb;
assert(!range_is_empty(range));
}
@@ -91,8 +89,12 @@ static inline void range_set_bounds(Range *range, uint64_t lob, uint64_t upb)
static inline void range_set_bounds1(Range *range,
uint64_t lob, uint64_t upb_plus1)
{
- range->begin = lob;
- range->end = upb_plus1;
+ if (!lob && !upb_plus1) {
+ *range = range_empty;
+ } else {
+ range->lob = lob;
+ range->upb = upb_plus1 - 1;
+ }
range_invariant(range);
}
@@ -100,20 +102,18 @@ static inline void range_set_bounds1(Range *range,
static inline uint64_t range_lob(Range *range)
{
assert(!range_is_empty(range));
- return range->begin;
+ return range->lob;
}
/* Return @range's upper bound. @range must not be empty. */
static inline uint64_t range_upb(Range *range)
{
assert(!range_is_empty(range));
- return range->end - 1;
+ return range->upb;
}
/*
* Extend @range to the smallest interval that includes @extend_by, too.
- * This must not extend @range to cover the interval [0,UINT64_MAX],
- * because Range can't represent that.
*/
static inline void range_extend(Range *range, Range *extend_by)
{
@@ -124,15 +124,13 @@ static inline void range_extend(Range *range, Range *extend_by)
*range = *extend_by;
return;
}
- if (range->begin > extend_by->begin) {
- range->begin = extend_by->begin;
+ if (range->lob > extend_by->lob) {
+ range->lob = extend_by->lob;
}
- /* Compare last byte in case region ends at ~0x0LL */
- if (range->end - 1 < extend_by->end - 1) {
- range->end = extend_by->end;
+ if (range->upb < extend_by->upb) {
+ range->upb = extend_by->upb;
}
- /* Must not extend to { .begin = 0, .end = 0 }: */
- assert(!range_is_empty(range));
+ range_invariant(range);
}
/* Get last byte of a range from offset + length.
diff --git a/util/range.c b/util/range.c
index e5f2e71..416df7c 100644
--- a/util/range.c
+++ b/util/range.c
@@ -22,20 +22,18 @@
#include "qemu/range.h"
/*
- * Operations on 64 bit address ranges.
- * Notes:
- * - ranges must not wrap around 0, but can include the last byte ~0x0LL.
- * - this can not represent a full 0 to ~0x0LL range.
+ * Return -1 if @a < @b, 1 @a > @b, and 0 if they touch or overlap.
+ * Both @a and @b must not be empty.
*/
-
-/* Return -1 if @a < @b, 1 if greater, and 0 if they touch or overlap. */
static inline int range_compare(Range *a, Range *b)
{
- /* Zero a->end is 2**64, and therefore not less than any b->begin */
- if (a->end && a->end < b->begin) {
+ assert(!range_is_empty(a) && !range_is_empty(b));
+
+ /* Careful, avoid wraparound */
+ if (b->lob && b->lob - 1 > a->upb) {
return -1;
}
- if (b->end && a->begin > b->end) {
+ if (a->lob && a->lob - 1 > b->upb) {
return 1;
}
return 0;
--
MST
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [Qemu-devel] [PULL 16/36] log: Permit -dfilter 0..0xffffffffffffffff
[not found] <1467650742-17580-1-git-send-email-mst@redhat.com>
` (14 preceding siblings ...)
2016-07-04 16:47 ` [Qemu-devel] [PULL 15/36] range: Replace internal representation of Range Michael S. Tsirkin
@ 2016-07-04 16:47 ` Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 17/36] tests: acpi: add CPU hotplug testcase Michael S. Tsirkin
` (19 subsequent siblings)
35 siblings, 0 replies; 43+ messages in thread
From: Michael S. Tsirkin @ 2016-07-04 16:47 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Markus Armbruster, Eric Blake, Paolo Bonzini,
Alex Bennée
From: Markus Armbruster <armbru@redhat.com>
Works fine since the previous commit fixed the underlying range data
type. Of course it filters out nothing, but so does
0..1,2..0xffffffffffffffff, and we don't bother rejecting that either.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
tests/test-logging.c | 5 +++--
util/log.c | 2 +-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/tests/test-logging.c b/tests/test-logging.c
index b6fa94e..cdf13c6 100644
--- a/tests/test-logging.c
+++ b/tests/test-logging.c
@@ -73,8 +73,9 @@ static void test_parse_range(void)
g_assert_false(qemu_log_in_addr_range(UINT64_MAX - 1));
qemu_set_dfilter_ranges("0..0xffffffffffffffff", &err);
- error_free_or_abort(&err);
-
+ g_assert(qemu_log_in_addr_range(0));
+ g_assert(qemu_log_in_addr_range(UINT64_MAX));
+
qemu_set_dfilter_ranges("2..1", &err);
error_free_or_abort(&err);
diff --git a/util/log.c b/util/log.c
index 4da635c..b6c75b1 100644
--- a/util/log.c
+++ b/util/log.c
@@ -204,7 +204,7 @@ void qemu_set_dfilter_ranges(const char *filter_spec, Error **errp)
default:
g_assert_not_reached();
}
- if (lob > upb || (lob == 0 && upb == UINT64_MAX)) {
+ if (lob > upb) {
error_setg(errp, "Invalid range");
goto out;
}
--
MST
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [Qemu-devel] [PULL 17/36] tests: acpi: add CPU hotplug testcase
[not found] <1467650742-17580-1-git-send-email-mst@redhat.com>
` (15 preceding siblings ...)
2016-07-04 16:47 ` [Qemu-devel] [PULL 16/36] log: Permit -dfilter 0..0xffffffffffffffff Michael S. Tsirkin
@ 2016-07-04 16:47 ` Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 18/36] tests: add APIC.cphp and DSDT.cphp blobs Michael S. Tsirkin
` (18 subsequent siblings)
35 siblings, 0 replies; 43+ messages in thread
From: Michael S. Tsirkin @ 2016-07-04 16:47 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Igor Mammedov, Marcel Apfelbaum, Eric Blake
From: Igor Mammedov <imammedo@redhat.com>
Test with:
-smp 2,cores=3,sockets=2,maxcpus=6
to capture sparse APIC ID values that default
AMD CPU has in above configuration.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
tests/bios-tables-test.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index 92c90dd..de4019e 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -801,6 +801,32 @@ static void test_acpi_q35_tcg_bridge(void)
free_test_data(&data);
}
+static void test_acpi_piix4_tcg_cphp(void)
+{
+ test_data data;
+
+ memset(&data, 0, sizeof(data));
+ data.machine = MACHINE_PC;
+ data.variant = ".cphp";
+ test_acpi_one("-machine accel=tcg"
+ " -smp 2,cores=3,sockets=2,maxcpus=6",
+ &data);
+ free_test_data(&data);
+}
+
+static void test_acpi_q35_tcg_cphp(void)
+{
+ test_data data;
+
+ memset(&data, 0, sizeof(data));
+ data.machine = MACHINE_Q35;
+ data.variant = ".cphp";
+ test_acpi_one("-machine q35,accel=tcg"
+ " -smp 2,cores=3,sockets=2,maxcpus=6",
+ &data);
+ free_test_data(&data);
+}
+
static uint8_t ipmi_required_struct_types[] = {
0, 1, 3, 4, 16, 17, 19, 32, 38, 127
};
@@ -856,6 +882,8 @@ int main(int argc, char *argv[])
qtest_add_func("acpi/q35/tcg/bridge", test_acpi_q35_tcg_bridge);
qtest_add_func("acpi/piix4/tcg/ipmi", test_acpi_piix4_tcg_ipmi);
qtest_add_func("acpi/q35/tcg/ipmi", test_acpi_q35_tcg_ipmi);
+ qtest_add_func("acpi/piix4/tcg/cpuhp", test_acpi_piix4_tcg_cphp);
+ qtest_add_func("acpi/q35/tcg/cpuhp", test_acpi_q35_tcg_cphp);
}
ret = g_test_run();
boot_sector_cleanup(disk);
--
MST
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [Qemu-devel] [PULL 18/36] tests: add APIC.cphp and DSDT.cphp blobs
[not found] <1467650742-17580-1-git-send-email-mst@redhat.com>
` (16 preceding siblings ...)
2016-07-04 16:47 ` [Qemu-devel] [PULL 17/36] tests: acpi: add CPU hotplug testcase Michael S. Tsirkin
@ 2016-07-04 16:47 ` Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 19/36] tests/acpi: add pxb/pxb-pcie tests Michael S. Tsirkin
` (17 subsequent siblings)
35 siblings, 0 replies; 43+ messages in thread
From: Michael S. Tsirkin @ 2016-07-04 16:47 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Igor Mammedov
From: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
tests/acpi-test-data/pc/APIC.cphp | Bin 0 -> 160 bytes
tests/acpi-test-data/pc/DSDT.cphp | Bin 0 -> 6435 bytes
tests/acpi-test-data/q35/APIC.cphp | Bin 0 -> 160 bytes
tests/acpi-test-data/q35/DSDT.cphp | Bin 0 -> 9197 bytes
4 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 tests/acpi-test-data/pc/APIC.cphp
create mode 100644 tests/acpi-test-data/pc/DSDT.cphp
create mode 100644 tests/acpi-test-data/q35/APIC.cphp
create mode 100644 tests/acpi-test-data/q35/DSDT.cphp
diff --git a/tests/acpi-test-data/pc/APIC.cphp b/tests/acpi-test-data/pc/APIC.cphp
new file mode 100644
index 0000000000000000000000000000000000000000..1bf8a0a63bc1c9b716d937b96eb34b05016b9366
GIT binary patch
literal 160
zcmXwx!3}^Q3`JW6f}%UP3UJYrBwpObWgNv(oJ8%n@zB24pP!~WmxG9S&r6xsF>kdb
z$yhQtNOavFgY<9)W~DJWDKu7Tozi)bd+hVZHk}Lv=1?18ZTnj%1<hjo%=$-Oyrt<4
A0RR91
literal 0
HcmV?d00001
diff --git a/tests/acpi-test-data/pc/DSDT.cphp b/tests/acpi-test-data/pc/DSDT.cphp
new file mode 100644
index 0000000000000000000000000000000000000000..e8b146208eb3877e1cde2cc361c5afd270d194c6
GIT binary patch
literal 6435
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
OTtYbOHt0~$nfQP4P$F9Z
literal 0
HcmV?d00001
diff --git a/tests/acpi-test-data/q35/APIC.cphp b/tests/acpi-test-data/q35/APIC.cphp
new file mode 100644
index 0000000000000000000000000000000000000000..1bf8a0a63bc1c9b716d937b96eb34b05016b9366
GIT binary patch
literal 160
zcmXwx!3}^Q3`JW6f}%UP3UJYrBwpObWgNv(oJ8%n@zB24pP!~WmxG9S&r6xsF>kdb
z$yhQtNOavFgY<9)W~DJWDKu7Tozi)bd+hVZHk}Lv=1?18ZTnj%1<hjo%=$-Oyrt<4
A0RR91
literal 0
HcmV?d00001
diff --git a/tests/acpi-test-data/q35/DSDT.cphp b/tests/acpi-test-data/q35/DSDT.cphp
new file mode 100644
index 0000000000000000000000000000000000000000..6cc28c6daec2b331030ab0600a4d79034c1dfc40
GIT binary patch
literal 9197
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
R7B$vXW1Sn>MzGZu{|B7Hnt1>K
literal 0
HcmV?d00001
--
MST
^ permalink raw reply [flat|nested] 43+ messages in thread
* [Qemu-devel] [PULL 19/36] tests/acpi: add pxb/pxb-pcie tests
[not found] <1467650742-17580-1-git-send-email-mst@redhat.com>
` (17 preceding siblings ...)
2016-07-04 16:47 ` [Qemu-devel] [PULL 18/36] tests: add APIC.cphp and DSDT.cphp blobs Michael S. Tsirkin
@ 2016-07-04 16:47 ` Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 20/36] hw/pxb: declare pxb devices as not hot-pluggable Michael S. Tsirkin
` (16 subsequent siblings)
35 siblings, 0 replies; 43+ messages in thread
From: Michael S. Tsirkin @ 2016-07-04 16:47 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Marcel Apfelbaum, Igor Mammedov, Laszlo Ersek,
Eric Blake
From: Marcel Apfelbaum <marcel@redhat.com>
Add an ivshmem device with 4G shared memory to
pxb in order to check the ACPI code of 64bit MMIO allocation.
Suggested-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
---
tests/bios-tables-test.c | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index de4019e..b1026d7 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -864,6 +864,41 @@ static void test_acpi_piix4_tcg_ipmi(void)
free_test_data(&data);
}
+static void test_acpi_piix4_tcg_pxb(void)
+{
+ test_data data;
+
+ memset(&data, 0, sizeof(data));
+ data.machine = MACHINE_PC;
+ data.variant = ".pxb";
+ data.required_struct_types = base_required_struct_types;
+ data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types);
+ test_acpi_one("-machine accel=tcg"
+ " -device pxb,id=pxb,bus_nr=0x80,bus=pci.0"
+ " -object memory-backend-file,size=4G,mem-path=/tmp/shmem,share,id=mb"
+ " -device ivshmem-plain,memdev=mb,bus=pxb",
+ &data);
+ free_test_data(&data);
+}
+
+static void test_acpi_q35_tcg_pxb_pcie(void)
+{
+ test_data data;
+
+ memset(&data, 0, sizeof(data));
+ data.machine = MACHINE_Q35;
+ data.variant = ".pxb_pcie";
+ data.required_struct_types = base_required_struct_types;
+ data.required_struct_types_len = ARRAY_SIZE(ipmi_required_struct_types);
+ test_acpi_one("-machine q35,accel=tcg"
+ " -device pxb-pcie,id=pxb,bus_nr=0x80,bus=pcie.0"
+ " -device ioh3420,id=rp,bus=pxb,slot=1"
+ " -object memory-backend-file,size=4G,mem-path=/tmp/shmem,share,id=mb"
+ " -device ivshmem-plain,memdev=mb,bus=rp",
+ &data);
+ free_test_data(&data);
+}
+
int main(int argc, char *argv[])
{
const char *arch = qtest_get_arch();
@@ -884,6 +919,8 @@ int main(int argc, char *argv[])
qtest_add_func("acpi/q35/tcg/ipmi", test_acpi_q35_tcg_ipmi);
qtest_add_func("acpi/piix4/tcg/cpuhp", test_acpi_piix4_tcg_cphp);
qtest_add_func("acpi/q35/tcg/cpuhp", test_acpi_q35_tcg_cphp);
+ qtest_add_func("acpi/piix4/tcg/pxb", test_acpi_piix4_tcg_pxb);
+ qtest_add_func("acpi/q35/tcg/pxb-pcie", test_acpi_q35_tcg_pxb_pcie);
}
ret = g_test_run();
boot_sector_cleanup(disk);
--
MST
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [Qemu-devel] [PULL 20/36] hw/pxb: declare pxb devices as not hot-pluggable
[not found] <1467650742-17580-1-git-send-email-mst@redhat.com>
` (18 preceding siblings ...)
2016-07-04 16:47 ` [Qemu-devel] [PULL 19/36] tests/acpi: add pxb/pxb-pcie tests Michael S. Tsirkin
@ 2016-07-04 16:47 ` Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 21/36] hw/acpi: fix a DSDT table issue when a pxb is present Michael S. Tsirkin
` (15 subsequent siblings)
35 siblings, 0 replies; 43+ messages in thread
From: Michael S. Tsirkin @ 2016-07-04 16:47 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Marcel Apfelbaum, Igor Mammedov, Laszlo Ersek
From: Marcel Apfelbaum <marcel@redhat.com>
Prevent future issues when hotplug will work for devices
attached to pxbs.
Suggested-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/pci-bridge/pci_expander_bridge.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/hw/pci-bridge/pci_expander_bridge.c b/hw/pci-bridge/pci_expander_bridge.c
index ab86121..b4f8ca2 100644
--- a/hw/pci-bridge/pci_expander_bridge.c
+++ b/hw/pci-bridge/pci_expander_bridge.c
@@ -310,6 +310,7 @@ static void pxb_dev_class_init(ObjectClass *klass, void *data)
dc->desc = "PCI Expander Bridge";
dc->props = pxb_dev_properties;
+ dc->hotpluggable = false;
set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
}
@@ -343,6 +344,7 @@ static void pxb_pcie_dev_class_init(ObjectClass *klass, void *data)
dc->desc = "PCI Express Expander Bridge";
dc->props = pxb_dev_properties;
+ dc->hotpluggable = false;
set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
}
--
MST
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [Qemu-devel] [PULL 21/36] hw/acpi: fix a DSDT table issue when a pxb is present.
[not found] <1467650742-17580-1-git-send-email-mst@redhat.com>
` (19 preceding siblings ...)
2016-07-04 16:47 ` [Qemu-devel] [PULL 20/36] hw/pxb: declare pxb devices as not hot-pluggable Michael S. Tsirkin
@ 2016-07-04 16:47 ` Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 22/36] acpi: refactor pxb crs computation Michael S. Tsirkin
` (14 subsequent siblings)
35 siblings, 0 replies; 43+ messages in thread
From: Michael S. Tsirkin @ 2016-07-04 16:47 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Marcel Apfelbaum, Igor Mammedov, Laszlo Ersek,
Paolo Bonzini, Richard Henderson, Eduardo Habkost
From: Marcel Apfelbaum <marcel@redhat.com>
PXBs do not support hotplug so they don't have a PCNT function.
Since the PXB's PCI root-bus is a child bus of bus 0, the
build_dsdt code will add a call to the corresponding PCNT function.
Fix this by skipping the PCNT call for the above case.
While at it skip also PCIe child buses.
Reported-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/i386/acpi-build.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index fbba461..5ed2bbd 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -597,6 +597,10 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
QLIST_FOREACH(sec, &bus->child, sibling) {
int32_t devfn = sec->parent_dev->devfn;
+ if (pci_bus_is_root(sec) || pci_bus_is_express(sec)) {
+ continue;
+ }
+
aml_append(method, aml_name("^S%.02X.PCNT", devfn));
}
}
--
MST
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [Qemu-devel] [PULL 22/36] acpi: refactor pxb crs computation
[not found] <1467650742-17580-1-git-send-email-mst@redhat.com>
` (20 preceding siblings ...)
2016-07-04 16:47 ` [Qemu-devel] [PULL 21/36] hw/acpi: fix a DSDT table issue when a pxb is present Michael S. Tsirkin
@ 2016-07-04 16:47 ` Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 23/36] hw/apci: handle 64-bit MMIO regions correctly Michael S. Tsirkin
` (13 subsequent siblings)
35 siblings, 0 replies; 43+ messages in thread
From: Michael S. Tsirkin @ 2016-07-04 16:47 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Marcel Apfelbaum, Igor Mammedov, Laszlo Ersek,
Paolo Bonzini, Richard Henderson, Eduardo Habkost
From: Marcel Apfelbaum <marcel@redhat.com>
Instead of always passing both IO and MEM ranges when
computing CRS ranges, define a new CrsRangeSet structure
that include them both.
This is done before introducing a third type of range,
64-bit MEM, so it will be easier to pass them all around.
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/i386/acpi-build.c | 81 ++++++++++++++++++++++++++++++++--------------------
1 file changed, 50 insertions(+), 31 deletions(-)
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 5ed2bbd..d8b3543 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -748,6 +748,23 @@ static void crs_range_free(gpointer data)
g_free(entry);
}
+typedef struct CrsRangeSet {
+ GPtrArray *io_ranges;
+ GPtrArray *mem_ranges;
+ } CrsRangeSet;
+
+static void crs_range_set_init(CrsRangeSet *range_set)
+{
+ range_set->io_ranges = g_ptr_array_new_with_free_func(crs_range_free);
+ range_set->mem_ranges = g_ptr_array_new_with_free_func(crs_range_free);
+}
+
+static void crs_range_set_free(CrsRangeSet *range_set)
+{
+ g_ptr_array_free(range_set->io_ranges, true);
+ g_ptr_array_free(range_set->mem_ranges, true);
+}
+
static gint crs_range_compare(gconstpointer a, gconstpointer b)
{
CrsRangeEntry *entry_a = *(CrsRangeEntry **)a;
@@ -832,18 +849,17 @@ static void crs_range_merge(GPtrArray *range)
g_ptr_array_free(tmp, true);
}
-static Aml *build_crs(PCIHostState *host,
- GPtrArray *io_ranges, GPtrArray *mem_ranges)
+static Aml *build_crs(PCIHostState *host, CrsRangeSet *range_set)
{
Aml *crs = aml_resource_template();
- GPtrArray *host_io_ranges = g_ptr_array_new_with_free_func(crs_range_free);
- GPtrArray *host_mem_ranges = g_ptr_array_new_with_free_func(crs_range_free);
+ CrsRangeSet temp_range_set;
CrsRangeEntry *entry;
uint8_t max_bus = pci_bus_num(host->bus);
uint8_t type;
int devfn;
int i;
+ crs_range_set_init(&temp_range_set);
for (devfn = 0; devfn < ARRAY_SIZE(host->bus->devices); devfn++) {
uint64_t range_base, range_limit;
PCIDevice *dev = host->bus->devices[devfn];
@@ -867,9 +883,11 @@ static Aml *build_crs(PCIHostState *host,
}
if (r->type & PCI_BASE_ADDRESS_SPACE_IO) {
- crs_range_insert(host_io_ranges, range_base, range_limit);
+ crs_range_insert(temp_range_set.io_ranges,
+ range_base, range_limit);
} else { /* "memory" */
- crs_range_insert(host_mem_ranges, range_base, range_limit);
+ crs_range_insert(temp_range_set.mem_ranges,
+ range_base, range_limit);
}
}
@@ -888,7 +906,8 @@ static Aml *build_crs(PCIHostState *host,
* that do not support multiple root buses
*/
if (range_base && range_base <= range_limit) {
- crs_range_insert(host_io_ranges, range_base, range_limit);
+ crs_range_insert(temp_range_set.io_ranges,
+ range_base, range_limit);
}
range_base =
@@ -901,7 +920,8 @@ static Aml *build_crs(PCIHostState *host,
* that do not support multiple root buses
*/
if (range_base && range_base <= range_limit) {
- crs_range_insert(host_mem_ranges, range_base, range_limit);
+ crs_range_insert(temp_range_set.mem_ranges,
+ range_base, range_limit);
}
range_base =
@@ -914,35 +934,36 @@ static Aml *build_crs(PCIHostState *host,
* that do not support multiple root buses
*/
if (range_base && range_base <= range_limit) {
- crs_range_insert(host_mem_ranges, range_base, range_limit);
+ crs_range_insert(temp_range_set.mem_ranges,
+ range_base, range_limit);
}
}
}
- crs_range_merge(host_io_ranges);
- for (i = 0; i < host_io_ranges->len; i++) {
- entry = g_ptr_array_index(host_io_ranges, i);
+ crs_range_merge(temp_range_set.io_ranges);
+ for (i = 0; i < temp_range_set.io_ranges->len; i++) {
+ entry = g_ptr_array_index(temp_range_set.io_ranges, i);
aml_append(crs,
aml_word_io(AML_MIN_FIXED, AML_MAX_FIXED,
AML_POS_DECODE, AML_ENTIRE_RANGE,
0, entry->base, entry->limit, 0,
entry->limit - entry->base + 1));
- crs_range_insert(io_ranges, entry->base, entry->limit);
+ crs_range_insert(range_set->io_ranges, entry->base, entry->limit);
}
- g_ptr_array_free(host_io_ranges, true);
- crs_range_merge(host_mem_ranges);
- for (i = 0; i < host_mem_ranges->len; i++) {
- entry = g_ptr_array_index(host_mem_ranges, i);
+ crs_range_merge(temp_range_set.mem_ranges);
+ for (i = 0; i < temp_range_set.mem_ranges->len; i++) {
+ entry = g_ptr_array_index(temp_range_set.mem_ranges, i);
aml_append(crs,
aml_dword_memory(AML_POS_DECODE, AML_MIN_FIXED,
AML_MAX_FIXED, AML_NON_CACHEABLE,
AML_READ_WRITE,
0, entry->base, entry->limit, 0,
entry->limit - entry->base + 1));
- crs_range_insert(mem_ranges, entry->base, entry->limit);
+ crs_range_insert(range_set->mem_ranges, entry->base, entry->limit);
}
- g_ptr_array_free(host_mem_ranges, true);
+
+ crs_range_set_free(&temp_range_set);
aml_append(crs,
aml_word_bus_number(AML_MIN_FIXED, AML_MAX_FIXED, AML_POS_DECODE,
@@ -1899,8 +1920,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
{
CrsRangeEntry *entry;
Aml *dsdt, *sb_scope, *scope, *dev, *method, *field, *pkg, *crs;
- GPtrArray *mem_ranges = g_ptr_array_new_with_free_func(crs_range_free);
- GPtrArray *io_ranges = g_ptr_array_new_with_free_func(crs_range_free);
+ CrsRangeSet crs_range_set;
PCMachineState *pcms = PC_MACHINE(machine);
PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(machine);
uint32_t nr_mem = machine->ram_slots;
@@ -1989,6 +2009,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
}
aml_append(dsdt, scope);
+ crs_range_set_init(&crs_range_set);
bus = PC_MACHINE(machine)->bus;
if (bus) {
QLIST_FOREACH(bus, &bus->child, sibling) {
@@ -2015,8 +2036,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
}
aml_append(dev, build_prt(false));
- crs = build_crs(PCI_HOST_BRIDGE(BUS(bus)->parent),
- io_ranges, mem_ranges);
+ crs = build_crs(PCI_HOST_BRIDGE(BUS(bus)->parent), &crs_range_set);
aml_append(dev, aml_name_decl("_CRS", crs));
aml_append(scope, dev);
aml_append(dsdt, scope);
@@ -2037,9 +2057,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
AML_POS_DECODE, AML_ENTIRE_RANGE,
0x0000, 0x0000, 0x0CF7, 0x0000, 0x0CF8));
- crs_replace_with_free_ranges(io_ranges, 0x0D00, 0xFFFF);
- for (i = 0; i < io_ranges->len; i++) {
- entry = g_ptr_array_index(io_ranges, i);
+ crs_replace_with_free_ranges(crs_range_set.io_ranges, 0x0D00, 0xFFFF);
+ for (i = 0; i < crs_range_set.io_ranges->len; i++) {
+ entry = g_ptr_array_index(crs_range_set.io_ranges, i);
aml_append(crs,
aml_word_io(AML_MIN_FIXED, AML_MAX_FIXED,
AML_POS_DECODE, AML_ENTIRE_RANGE,
@@ -2052,11 +2072,11 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
AML_CACHEABLE, AML_READ_WRITE,
0, 0x000A0000, 0x000BFFFF, 0, 0x00020000));
- crs_replace_with_free_ranges(mem_ranges,
+ crs_replace_with_free_ranges(crs_range_set.mem_ranges,
range_lob(pci_hole),
range_upb(pci_hole));
- for (i = 0; i < mem_ranges->len; i++) {
- entry = g_ptr_array_index(mem_ranges, i);
+ for (i = 0; i < crs_range_set.mem_ranges->len; i++) {
+ entry = g_ptr_array_index(crs_range_set.mem_ranges, i);
aml_append(crs,
aml_dword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED,
AML_NON_CACHEABLE, AML_READ_WRITE,
@@ -2091,8 +2111,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
aml_append(dev, aml_name_decl("_CRS", crs));
aml_append(scope, dev);
- g_ptr_array_free(io_ranges, true);
- g_ptr_array_free(mem_ranges, true);
+ crs_range_set_free(&crs_range_set);
/* reserve PCIHP resources */
if (pm->pcihp_io_len) {
--
MST
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [Qemu-devel] [PULL 23/36] hw/apci: handle 64-bit MMIO regions correctly
[not found] <1467650742-17580-1-git-send-email-mst@redhat.com>
` (21 preceding siblings ...)
2016-07-04 16:47 ` [Qemu-devel] [PULL 22/36] acpi: refactor pxb crs computation Michael S. Tsirkin
@ 2016-07-04 16:47 ` Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 24/36] tests/acpi: Add pxb/pxb-pcie tests blobs Michael S. Tsirkin
` (12 subsequent siblings)
35 siblings, 0 replies; 43+ messages in thread
From: Michael S. Tsirkin @ 2016-07-04 16:47 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Marcel Apfelbaum, Igor Mammedov, Laszlo Ersek,
Paolo Bonzini, Richard Henderson, Eduardo Habkost
From: Marcel Apfelbaum <marcel@redhat.com>
In build_crs(), the calculation and merging of the ranges already happens
in 64-bit, but the entry boundaries are silently truncated to 32-bit in the
call to aml_dword_memory(). Fix it by handling the 64-bit MMIO ranges separately.
This fixes 64-bit BARs behind PXBs.
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reported-by: Laszlo Ersek <lersek@redhat.com>
---
hw/i386/acpi-build.c | 54 +++++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 45 insertions(+), 9 deletions(-)
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index d8b3543..b1adf04 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -751,18 +751,22 @@ static void crs_range_free(gpointer data)
typedef struct CrsRangeSet {
GPtrArray *io_ranges;
GPtrArray *mem_ranges;
+ GPtrArray *mem_64bit_ranges;
} CrsRangeSet;
static void crs_range_set_init(CrsRangeSet *range_set)
{
range_set->io_ranges = g_ptr_array_new_with_free_func(crs_range_free);
range_set->mem_ranges = g_ptr_array_new_with_free_func(crs_range_free);
+ range_set->mem_64bit_ranges =
+ g_ptr_array_new_with_free_func(crs_range_free);
}
static void crs_range_set_free(CrsRangeSet *range_set)
{
g_ptr_array_free(range_set->io_ranges, true);
g_ptr_array_free(range_set->mem_ranges, true);
+ g_ptr_array_free(range_set->mem_64bit_ranges, true);
}
static gint crs_range_compare(gconstpointer a, gconstpointer b)
@@ -920,8 +924,14 @@ static Aml *build_crs(PCIHostState *host, CrsRangeSet *range_set)
* that do not support multiple root buses
*/
if (range_base && range_base <= range_limit) {
- crs_range_insert(temp_range_set.mem_ranges,
- range_base, range_limit);
+ uint64_t length = range_limit - range_base + 1;
+ if (range_limit <= UINT32_MAX && length <= UINT32_MAX) {
+ crs_range_insert(temp_range_set.mem_ranges,
+ range_base, range_limit);
+ } else {
+ crs_range_insert(temp_range_set.mem_64bit_ranges,
+ range_base, range_limit);
+ }
}
range_base =
@@ -934,8 +944,14 @@ static Aml *build_crs(PCIHostState *host, CrsRangeSet *range_set)
* that do not support multiple root buses
*/
if (range_base && range_base <= range_limit) {
- crs_range_insert(temp_range_set.mem_ranges,
- range_base, range_limit);
+ uint64_t length = range_limit - range_base + 1;
+ if (range_limit <= UINT32_MAX && length <= UINT32_MAX) {
+ crs_range_insert(temp_range_set.mem_ranges,
+ range_base, range_limit);
+ } else {
+ crs_range_insert(temp_range_set.mem_64bit_ranges,
+ range_base, range_limit);
+ }
}
}
}
@@ -963,6 +979,19 @@ static Aml *build_crs(PCIHostState *host, CrsRangeSet *range_set)
crs_range_insert(range_set->mem_ranges, entry->base, entry->limit);
}
+ crs_range_merge(temp_range_set.mem_64bit_ranges);
+ for (i = 0; i < temp_range_set.mem_64bit_ranges->len; i++) {
+ entry = g_ptr_array_index(temp_range_set.mem_64bit_ranges, i);
+ aml_append(crs,
+ aml_qword_memory(AML_POS_DECODE, AML_MIN_FIXED,
+ AML_MAX_FIXED, AML_NON_CACHEABLE,
+ AML_READ_WRITE,
+ 0, entry->base, entry->limit, 0,
+ entry->limit - entry->base + 1));
+ crs_range_insert(range_set->mem_64bit_ranges,
+ entry->base, entry->limit);
+ }
+
crs_range_set_free(&temp_range_set);
aml_append(crs,
@@ -2085,11 +2114,18 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
}
if (!range_is_empty(pci_hole64)) {
- aml_append(crs,
- aml_qword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED,
- AML_CACHEABLE, AML_READ_WRITE,
- 0, range_lob(pci_hole64), range_upb(pci_hole64), 0,
- range_upb(pci_hole64) + 1 - range_lob(pci_hole64)));
+ crs_replace_with_free_ranges(crs_range_set.mem_64bit_ranges,
+ range_lob(pci_hole64),
+ range_upb(pci_hole64));
+ for (i = 0; i < crs_range_set.mem_64bit_ranges->len; i++) {
+ entry = g_ptr_array_index(crs_range_set.mem_64bit_ranges, i);
+ aml_append(crs,
+ aml_qword_memory(AML_POS_DECODE, AML_MIN_FIXED,
+ AML_MAX_FIXED,
+ AML_CACHEABLE, AML_READ_WRITE,
+ 0, entry->base, entry->limit,
+ 0, entry->limit - entry->base + 1));
+ }
}
if (misc->tpm_version != TPM_VERSION_UNSPEC) {
--
MST
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [Qemu-devel] [PULL 24/36] tests/acpi: Add pxb/pxb-pcie tests blobs
[not found] <1467650742-17580-1-git-send-email-mst@redhat.com>
` (22 preceding siblings ...)
2016-07-04 16:47 ` [Qemu-devel] [PULL 23/36] hw/apci: handle 64-bit MMIO regions correctly Michael S. Tsirkin
@ 2016-07-04 16:47 ` Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 25/36] change pvscsi_init_msi() type to void Michael S. Tsirkin
` (11 subsequent siblings)
35 siblings, 0 replies; 43+ messages in thread
From: Michael S. Tsirkin @ 2016-07-04 16:47 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Marcel Apfelbaum, Laszlo Ersek
From: Marcel Apfelbaum <marcel@redhat.com>
Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
tests/acpi-test-data/pc/DSDT.pxb | Bin 0 -> 6280 bytes
tests/acpi-test-data/q35/DSDT.pxb_pcie | Bin 0 -> 9098 bytes
2 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 tests/acpi-test-data/pc/DSDT.pxb
create mode 100644 tests/acpi-test-data/q35/DSDT.pxb_pcie
diff --git a/tests/acpi-test-data/pc/DSDT.pxb b/tests/acpi-test-data/pc/DSDT.pxb
new file mode 100644
index 0000000000000000000000000000000000000000..1733aeceb843c449d7560d4728115b096e709da2
GIT binary patch
literal 6280
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
Pk#-Fau@%-EXgvHs$6*Lt
literal 0
HcmV?d00001
diff --git a/tests/acpi-test-data/q35/DSDT.pxb_pcie b/tests/acpi-test-data/q35/DSDT.pxb_pcie
new file mode 100644
index 0000000000000000000000000000000000000000..838ca876dece056934ed511197c2a8fa0d27fd11
GIT binary patch
literal 9098
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
D-{y{a
literal 0
HcmV?d00001
--
MST
^ permalink raw reply [flat|nested] 43+ messages in thread
* [Qemu-devel] [PULL 25/36] change pvscsi_init_msi() type to void
[not found] <1467650742-17580-1-git-send-email-mst@redhat.com>
` (23 preceding siblings ...)
2016-07-04 16:47 ` [Qemu-devel] [PULL 24/36] tests/acpi: Add pxb/pxb-pcie tests blobs Michael S. Tsirkin
@ 2016-07-04 16:47 ` Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 26/36] usb xhci: change msi/msix property type Michael S. Tsirkin
` (10 subsequent siblings)
35 siblings, 0 replies; 43+ messages in thread
From: Michael S. Tsirkin @ 2016-07-04 16:47 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Cao jin, Paolo Bonzini, Markus Armbruster,
Marcel Apfelbaum, Dmitry Fleytman
From: Cao jin <caoj.fnst@cn.fujitsu.com>
Nobody use its return value, so change the type to void.
cc: Michael S. Tsirkin <mst@redhat.com>
cc: Paolo Bonzini <pbonzini@redhat.com>
cc: Markus Armbruster <armbru@redhat.com>
cc: Marcel Apfelbaum <marcel@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Dmitry Fleytman <dmitry@daynix.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/scsi/vmw_pvscsi.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/hw/scsi/vmw_pvscsi.c b/hw/scsi/vmw_pvscsi.c
index 2d7528d..e035fce 100644
--- a/hw/scsi/vmw_pvscsi.c
+++ b/hw/scsi/vmw_pvscsi.c
@@ -1056,7 +1056,7 @@ pvscsi_io_read(void *opaque, hwaddr addr, unsigned size)
}
-static bool
+static void
pvscsi_init_msi(PVSCSIState *s)
{
int res;
@@ -1070,8 +1070,6 @@ pvscsi_init_msi(PVSCSIState *s)
} else {
s->msi_used = true;
}
-
- return s->msi_used;
}
static void
--
MST
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [Qemu-devel] [PULL 26/36] usb xhci: change msi/msix property type
[not found] <1467650742-17580-1-git-send-email-mst@redhat.com>
` (24 preceding siblings ...)
2016-07-04 16:47 ` [Qemu-devel] [PULL 25/36] change pvscsi_init_msi() type to void Michael S. Tsirkin
@ 2016-07-04 16:47 ` Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 27/36] intel-hda: change msi " Michael S. Tsirkin
` (9 subsequent siblings)
35 siblings, 0 replies; 43+ messages in thread
From: Michael S. Tsirkin @ 2016-07-04 16:47 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Cao jin, Gerd Hoffmann, Markus Armbruster,
Marcel Apfelbaum
From: Cao jin <caoj.fnst@cn.fujitsu.com>
>From bit to enum OnOffAuto
cc: Gerd Hoffmann <kraxel@redhat.com>
cc: Michael S. Tsirkin <mst@redhat.com>
cc: Markus Armbruster <armbru@redhat.com>
cc: Marcel Apfelbaum <marcel@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/usb/hcd-xhci.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
index 43ba615..0a5510f 100644
--- a/hw/usb/hcd-xhci.c
+++ b/hw/usb/hcd-xhci.c
@@ -461,6 +461,8 @@ struct XHCIState {
uint32_t numslots;
uint32_t flags;
uint32_t max_pstreams_mask;
+ OnOffAuto msi;
+ OnOffAuto msix;
/* Operational Registers */
uint32_t usbcmd;
@@ -498,9 +500,7 @@ typedef struct XHCIEvRingSeg {
} XHCIEvRingSeg;
enum xhci_flags {
- XHCI_FLAG_USE_MSI = 1,
- XHCI_FLAG_USE_MSI_X,
- XHCI_FLAG_SS_FIRST,
+ XHCI_FLAG_SS_FIRST = 1,
XHCI_FLAG_FORCE_PCIE_ENDCAP,
XHCI_FLAG_ENABLE_STREAMS,
};
@@ -3648,10 +3648,12 @@ static void usb_xhci_realize(struct PCIDevice *dev, Error **errp)
assert(ret >= 0);
}
- if (xhci_get_flag(xhci, XHCI_FLAG_USE_MSI)) {
+ if (xhci->msi != ON_OFF_AUTO_OFF) {
+ /* TODO check for errors */
msi_init(dev, 0x70, xhci->numintrs, true, false);
}
- if (xhci_get_flag(xhci, XHCI_FLAG_USE_MSI_X)) {
+ if (xhci->msix != ON_OFF_AUTO_OFF) {
+ /* TODO check for errors */
msix_init(dev, xhci->numintrs,
&xhci->mem, 0, OFF_MSIX_TABLE,
&xhci->mem, 0, OFF_MSIX_PBA,
@@ -3872,8 +3874,8 @@ static const VMStateDescription vmstate_xhci = {
};
static Property xhci_properties[] = {
- DEFINE_PROP_BIT("msi", XHCIState, flags, XHCI_FLAG_USE_MSI, true),
- DEFINE_PROP_BIT("msix", XHCIState, flags, XHCI_FLAG_USE_MSI_X, true),
+ DEFINE_PROP_ON_OFF_AUTO("msi", XHCIState, msi, ON_OFF_AUTO_AUTO),
+ DEFINE_PROP_ON_OFF_AUTO("msix", XHCIState, msix, ON_OFF_AUTO_AUTO),
DEFINE_PROP_BIT("superspeed-ports-first",
XHCIState, flags, XHCI_FLAG_SS_FIRST, true),
DEFINE_PROP_BIT("force-pcie-endcap", XHCIState, flags,
--
MST
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [Qemu-devel] [PULL 27/36] intel-hda: change msi property type
[not found] <1467650742-17580-1-git-send-email-mst@redhat.com>
` (25 preceding siblings ...)
2016-07-04 16:47 ` [Qemu-devel] [PULL 26/36] usb xhci: change msi/msix property type Michael S. Tsirkin
@ 2016-07-04 16:47 ` Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 28/36] mptsas: " Michael S. Tsirkin
` (8 subsequent siblings)
35 siblings, 0 replies; 43+ messages in thread
From: Michael S. Tsirkin @ 2016-07-04 16:47 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Cao jin, Gerd Hoffmann, Markus Armbruster,
Marcel Apfelbaum
From: Cao jin <caoj.fnst@cn.fujitsu.com>
>From uint32 to enum OnOffAuto.
cc: Gerd Hoffmann <kraxel@redhat.com>
cc: Michael S. Tsirkin <mst@redhat.com>
cc: Markus Armbruster <armbru@redhat.com>
cc: Marcel Apfelbaum <marcel@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/audio/intel-hda.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c
index 098b17d..4e19e8b 100644
--- a/hw/audio/intel-hda.c
+++ b/hw/audio/intel-hda.c
@@ -191,7 +191,7 @@ struct IntelHDAState {
/* properties */
uint32_t debug;
- uint32_t msi;
+ OnOffAuto msi;
bool old_msi_addr;
};
@@ -256,7 +256,7 @@ static void intel_hda_update_int_sts(IntelHDAState *d)
static void intel_hda_update_irq(IntelHDAState *d)
{
- int msi = d->msi && msi_enabled(&d->pci);
+ bool msi = msi_enabled(&d->pci);
int level;
intel_hda_update_int_sts(d);
@@ -1143,7 +1143,8 @@ static void intel_hda_realize(PCIDevice *pci, Error **errp)
memory_region_init_io(&d->mmio, OBJECT(d), &intel_hda_mmio_ops, d,
"intel-hda", 0x4000);
pci_register_bar(&d->pci, 0, 0, &d->mmio);
- if (d->msi) {
+ if (d->msi != ON_OFF_AUTO_OFF) {
+ /* TODO check for errors */
msi_init(&d->pci, d->old_msi_addr ? 0x50 : 0x60, 1, true, false);
}
@@ -1235,7 +1236,7 @@ static const VMStateDescription vmstate_intel_hda = {
static Property intel_hda_properties[] = {
DEFINE_PROP_UINT32("debug", IntelHDAState, debug, 0),
- DEFINE_PROP_UINT32("msi", IntelHDAState, msi, 1),
+ DEFINE_PROP_ON_OFF_AUTO("msi", IntelHDAState, msi, ON_OFF_AUTO_AUTO),
DEFINE_PROP_BOOL("old_msi_addr", IntelHDAState, old_msi_addr, false),
DEFINE_PROP_END_OF_LIST(),
};
--
MST
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [Qemu-devel] [PULL 28/36] mptsas: change msi property type
[not found] <1467650742-17580-1-git-send-email-mst@redhat.com>
` (26 preceding siblings ...)
2016-07-04 16:47 ` [Qemu-devel] [PULL 27/36] intel-hda: change msi " Michael S. Tsirkin
@ 2016-07-04 16:47 ` Michael S. Tsirkin
2016-07-04 16:48 ` [Qemu-devel] [PULL 29/36] megasas: change msi/msix " Michael S. Tsirkin
` (7 subsequent siblings)
35 siblings, 0 replies; 43+ messages in thread
From: Michael S. Tsirkin @ 2016-07-04 16:47 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Cao jin, Paolo Bonzini, Markus Armbruster,
Marcel Apfelbaum
From: Cao jin <caoj.fnst@cn.fujitsu.com>
>From uint32 to enum OnOffAuto, and give it a shorter name.
cc: Paolo Bonzini <pbonzini@redhat.com>
cc: Michael S. Tsirkin <mst@redhat.com>
cc: Markus Armbruster <armbru@redhat.com>
cc: Marcel Apfelbaum <marcel@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/scsi/mptsas.h | 3 ++-
hw/scsi/mptsas.c | 5 +++--
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/hw/scsi/mptsas.h b/hw/scsi/mptsas.h
index 595f81f..0436a33 100644
--- a/hw/scsi/mptsas.h
+++ b/hw/scsi/mptsas.h
@@ -27,7 +27,8 @@ struct MPTSASState {
MemoryRegion diag_io;
QEMUBH *request_bh;
- uint32_t msi_available;
+ /* properties */
+ OnOffAuto msi;
uint64_t sas_addr;
bool msi_in_use;
diff --git a/hw/scsi/mptsas.c b/hw/scsi/mptsas.c
index be88e16..40033c4 100644
--- a/hw/scsi/mptsas.c
+++ b/hw/scsi/mptsas.c
@@ -1284,8 +1284,9 @@ static void mptsas_scsi_init(PCIDevice *dev, Error **errp)
memory_region_init_io(&s->diag_io, OBJECT(s), &mptsas_diag_ops, s,
"mptsas-diag", 0x10000);
- if (s->msi_available &&
+ if (s->msi != ON_OFF_AUTO_OFF &&
msi_init(dev, 0, 1, true, false) >= 0) {
+ /* TODO check for errors */
s->msi_in_use = true;
}
@@ -1403,7 +1404,7 @@ static const VMStateDescription vmstate_mptsas = {
static Property mptsas_properties[] = {
DEFINE_PROP_UINT64("sas_address", MPTSASState, sas_addr, 0),
/* TODO: test MSI support under Windows */
- DEFINE_PROP_BIT("msi", MPTSASState, msi_available, 0, true),
+ DEFINE_PROP_ON_OFF_AUTO("msi", MPTSASState, msi, ON_OFF_AUTO_AUTO),
DEFINE_PROP_END_OF_LIST(),
};
--
MST
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [Qemu-devel] [PULL 29/36] megasas: change msi/msix property type
[not found] <1467650742-17580-1-git-send-email-mst@redhat.com>
` (27 preceding siblings ...)
2016-07-04 16:47 ` [Qemu-devel] [PULL 28/36] mptsas: " Michael S. Tsirkin
@ 2016-07-04 16:48 ` Michael S. Tsirkin
2016-07-04 16:48 ` [Qemu-devel] [PULL 30/36] pci bridge dev: change msi " Michael S. Tsirkin
` (6 subsequent siblings)
35 siblings, 0 replies; 43+ messages in thread
From: Michael S. Tsirkin @ 2016-07-04 16:48 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Cao jin, Hannes Reinecke, Paolo Bonzini,
Markus Armbruster, Marcel Apfelbaum, Hannes Reinecke, qemu-block
From: Cao jin <caoj.fnst@cn.fujitsu.com>
>From bit to enum OnOffAuto.
cc: Hannes Reinecke <hare@suse.de>
cc: Paolo Bonzini <pbonzini@redhat.com>
cc: Michael S. Tsirkin <mst@redhat.com>
cc: Markus Armbruster <armbru@redhat.com>
cc: Marcel Apfelbaum <marcel@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
---
hw/scsi/megasas.c | 28 +++++++++++-----------------
1 file changed, 11 insertions(+), 17 deletions(-)
diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c
index d177218..636ea73 100644
--- a/hw/scsi/megasas.c
+++ b/hw/scsi/megasas.c
@@ -48,11 +48,7 @@
#define MEGASAS_FLAG_USE_JBOD 0
#define MEGASAS_MASK_USE_JBOD (1 << MEGASAS_FLAG_USE_JBOD)
-#define MEGASAS_FLAG_USE_MSI 1
-#define MEGASAS_MASK_USE_MSI (1 << MEGASAS_FLAG_USE_MSI)
-#define MEGASAS_FLAG_USE_MSIX 2
-#define MEGASAS_MASK_USE_MSIX (1 << MEGASAS_FLAG_USE_MSIX)
-#define MEGASAS_FLAG_USE_QUEUE64 3
+#define MEGASAS_FLAG_USE_QUEUE64 1
#define MEGASAS_MASK_USE_QUEUE64 (1 << MEGASAS_FLAG_USE_QUEUE64)
static const char *mfi_frame_desc[] = {
@@ -96,6 +92,8 @@ typedef struct MegasasState {
int busy;
int diag;
int adp_reset;
+ OnOffAuto msi;
+ OnOffAuto msix;
MegasasCmd *event_cmd;
int event_locale;
@@ -159,12 +157,12 @@ static bool megasas_use_queue64(MegasasState *s)
static bool megasas_use_msi(MegasasState *s)
{
- return s->flags & MEGASAS_MASK_USE_MSI;
+ return s->msi != ON_OFF_AUTO_OFF;
}
static bool megasas_use_msix(MegasasState *s)
{
- return s->flags & MEGASAS_MASK_USE_MSIX;
+ return s->msix != ON_OFF_AUTO_OFF;
}
static bool megasas_is_jbod(MegasasState *s)
@@ -2349,12 +2347,12 @@ static void megasas_scsi_realize(PCIDevice *dev, Error **errp)
if (megasas_use_msi(s) &&
msi_init(dev, 0x50, 1, true, false)) {
- s->flags &= ~MEGASAS_MASK_USE_MSI;
+ s->msi = ON_OFF_AUTO_OFF;
}
if (megasas_use_msix(s) &&
msix_init(dev, 15, &s->mmio_io, b->mmio_bar, 0x2000,
&s->mmio_io, b->mmio_bar, 0x3800, 0x68)) {
- s->flags &= ~MEGASAS_MASK_USE_MSIX;
+ s->msix = ON_OFF_AUTO_OFF;
}
if (pci_is_express(dev)) {
pcie_endpoint_cap_init(dev, 0xa0);
@@ -2422,10 +2420,8 @@ static Property megasas_properties_gen1[] = {
MEGASAS_DEFAULT_FRAMES),
DEFINE_PROP_STRING("hba_serial", MegasasState, hba_serial),
DEFINE_PROP_UINT64("sas_address", MegasasState, sas_addr, 0),
- DEFINE_PROP_BIT("use_msi", MegasasState, flags,
- MEGASAS_FLAG_USE_MSI, false),
- DEFINE_PROP_BIT("use_msix", MegasasState, flags,
- MEGASAS_FLAG_USE_MSIX, false),
+ DEFINE_PROP_ON_OFF_AUTO("msi", MegasasState, msi, ON_OFF_AUTO_AUTO),
+ DEFINE_PROP_ON_OFF_AUTO("msix", MegasasState, msix, ON_OFF_AUTO_AUTO),
DEFINE_PROP_BIT("use_jbod", MegasasState, flags,
MEGASAS_FLAG_USE_JBOD, false),
DEFINE_PROP_END_OF_LIST(),
@@ -2438,10 +2434,8 @@ static Property megasas_properties_gen2[] = {
MEGASAS_GEN2_DEFAULT_FRAMES),
DEFINE_PROP_STRING("hba_serial", MegasasState, hba_serial),
DEFINE_PROP_UINT64("sas_address", MegasasState, sas_addr, 0),
- DEFINE_PROP_BIT("use_msi", MegasasState, flags,
- MEGASAS_FLAG_USE_MSI, true),
- DEFINE_PROP_BIT("use_msix", MegasasState, flags,
- MEGASAS_FLAG_USE_MSIX, true),
+ DEFINE_PROP_ON_OFF_AUTO("msi", MegasasState, msi, ON_OFF_AUTO_AUTO),
+ DEFINE_PROP_ON_OFF_AUTO("msix", MegasasState, msix, ON_OFF_AUTO_AUTO),
DEFINE_PROP_BIT("use_jbod", MegasasState, flags,
MEGASAS_FLAG_USE_JBOD, false),
DEFINE_PROP_END_OF_LIST(),
--
MST
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [Qemu-devel] [PULL 30/36] pci bridge dev: change msi property type
[not found] <1467650742-17580-1-git-send-email-mst@redhat.com>
` (28 preceding siblings ...)
2016-07-04 16:48 ` [Qemu-devel] [PULL 29/36] megasas: change msi/msix " Michael S. Tsirkin
@ 2016-07-04 16:48 ` Michael S. Tsirkin
2016-07-04 16:48 ` [Qemu-devel] [PULL 31/36] pci: Convert msi_init() to Error and fix callers to check it Michael S. Tsirkin
` (5 subsequent siblings)
35 siblings, 0 replies; 43+ messages in thread
From: Michael S. Tsirkin @ 2016-07-04 16:48 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Cao jin, Markus Armbruster, Marcel Apfelbaum
From: Cao jin <caoj.fnst@cn.fujitsu.com>
>From bit to enum OnOffAuto.
cc: Michael S. Tsirkin <mst@redhat.com>
cc: Markus Armbruster <armbru@redhat.com>
cc: Marcel Apfelbaum <marcel@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/pci-bridge/pci_bridge_dev.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/hw/pci-bridge/pci_bridge_dev.c b/hw/pci-bridge/pci_bridge_dev.c
index 41ca47b..0fbecc4 100644
--- a/hw/pci-bridge/pci_bridge_dev.c
+++ b/hw/pci-bridge/pci_bridge_dev.c
@@ -42,9 +42,10 @@ struct PCIBridgeDev {
MemoryRegion bar;
uint8_t chassis_nr;
-#define PCI_BRIDGE_DEV_F_MSI_REQ 0
-#define PCI_BRIDGE_DEV_F_SHPC_REQ 1
+#define PCI_BRIDGE_DEV_F_SHPC_REQ 0
uint32_t flags;
+
+ OnOffAuto msi;
};
typedef struct PCIBridgeDev PCIBridgeDev;
@@ -66,7 +67,7 @@ static int pci_bridge_dev_initfn(PCIDevice *dev)
}
} else {
/* MSI is not applicable without SHPC */
- bridge_dev->flags &= ~(1 << PCI_BRIDGE_DEV_F_MSI_REQ);
+ bridge_dev->msi = ON_OFF_AUTO_OFF;
}
err = slotid_cap_init(dev, 0, bridge_dev->chassis_nr, 0);
@@ -74,7 +75,7 @@ static int pci_bridge_dev_initfn(PCIDevice *dev)
goto slotid_error;
}
- if ((bridge_dev->flags & (1 << PCI_BRIDGE_DEV_F_MSI_REQ)) &&
+ if (bridge_dev->msi != ON_OFF_AUTO_OFF &&
msi_nonbroken) {
err = msi_init(dev, 0, 1, true, true);
if (err < 0) {
@@ -147,8 +148,8 @@ static Property pci_bridge_dev_properties[] = {
/* Note: 0 is not a legal chassis number. */
DEFINE_PROP_UINT8(PCI_BRIDGE_DEV_PROP_CHASSIS_NR, PCIBridgeDev, chassis_nr,
0),
- DEFINE_PROP_BIT(PCI_BRIDGE_DEV_PROP_MSI, PCIBridgeDev, flags,
- PCI_BRIDGE_DEV_F_MSI_REQ, true),
+ DEFINE_PROP_ON_OFF_AUTO(PCI_BRIDGE_DEV_PROP_MSI, PCIBridgeDev, msi,
+ ON_OFF_AUTO_AUTO),
DEFINE_PROP_BIT(PCI_BRIDGE_DEV_PROP_SHPC, PCIBridgeDev, flags,
PCI_BRIDGE_DEV_F_SHPC_REQ, true),
DEFINE_PROP_END_OF_LIST(),
--
MST
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [Qemu-devel] [PULL 31/36] pci: Convert msi_init() to Error and fix callers to check it
[not found] <1467650742-17580-1-git-send-email-mst@redhat.com>
` (29 preceding siblings ...)
2016-07-04 16:48 ` [Qemu-devel] [PULL 30/36] pci bridge dev: change msi " Michael S. Tsirkin
@ 2016-07-04 16:48 ` Michael S. Tsirkin
2016-07-04 16:48 ` [Qemu-devel] [PULL 32/36] megasas: remove unnecessary megasas_use_msi() Michael S. Tsirkin
` (4 subsequent siblings)
35 siblings, 0 replies; 43+ messages in thread
From: Michael S. Tsirkin @ 2016-07-04 16:48 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Cao jin, Gerd Hoffmann, John Snow, Dmitry Fleytman,
Jason Wang, Hannes Reinecke, Paolo Bonzini, Alex Williamson,
Markus Armbruster, Marcel Apfelbaum, Hannes Reinecke, qemu-block
From: Cao jin <caoj.fnst@cn.fujitsu.com>
msi_init() reports errors with error_report(), which is wrong
when it's used in realize().
Fix by converting it to Error.
Fix its callers to handle failure instead of ignoring it.
For those callers who don't handle the failure, it might happen:
when user want msi on, but he doesn't get what he want because of
msi_init fails silently.
cc: Gerd Hoffmann <kraxel@redhat.com>
cc: John Snow <jsnow@redhat.com>
cc: Dmitry Fleytman <dmitry@daynix.com>
cc: Jason Wang <jasowang@redhat.com>
cc: Michael S. Tsirkin <mst@redhat.com>
cc: Hannes Reinecke <hare@suse.de>
cc: Paolo Bonzini <pbonzini@redhat.com>
cc: Alex Williamson <alex.williamson@redhat.com>
cc: Markus Armbruster <armbru@redhat.com>
cc: Marcel Apfelbaum <marcel@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
---
include/hw/pci/msi.h | 3 ++-
hw/audio/intel-hda.c | 24 ++++++++++++++++++++----
hw/ide/ich.c | 7 +++++--
hw/net/e1000e.c | 8 ++------
hw/net/vmxnet3.c | 37 ++++++++++++-------------------------
hw/pci-bridge/ioh3420.c | 6 +++++-
hw/pci-bridge/pci_bridge_dev.c | 20 ++++++++++++++++----
hw/pci-bridge/xio3130_downstream.c | 6 +++++-
hw/pci-bridge/xio3130_upstream.c | 6 +++++-
hw/pci/msi.c | 11 ++++++++---
hw/scsi/megasas.c | 26 +++++++++++++++++++++-----
hw/scsi/mptsas.c | 31 ++++++++++++++++++++++++-------
hw/scsi/vmw_pvscsi.c | 2 +-
hw/usb/hcd-xhci.c | 23 +++++++++++++++++++----
hw/vfio/pci.c | 7 +++++--
15 files changed, 150 insertions(+), 67 deletions(-)
diff --git a/include/hw/pci/msi.h b/include/hw/pci/msi.h
index 8124908..4837bcf 100644
--- a/include/hw/pci/msi.h
+++ b/include/hw/pci/msi.h
@@ -35,7 +35,8 @@ void msi_set_message(PCIDevice *dev, MSIMessage msg);
MSIMessage msi_get_message(PCIDevice *dev, unsigned int vector);
bool msi_enabled(const PCIDevice *dev);
int msi_init(struct PCIDevice *dev, uint8_t offset,
- unsigned int nr_vectors, bool msi64bit, bool msi_per_vector_mask);
+ unsigned int nr_vectors, bool msi64bit,
+ bool msi_per_vector_mask, Error **errp);
void msi_uninit(struct PCIDevice *dev);
void msi_reset(PCIDevice *dev);
void msi_notify(PCIDevice *dev, unsigned int vector);
diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c
index 4e19e8b..cd95340 100644
--- a/hw/audio/intel-hda.c
+++ b/hw/audio/intel-hda.c
@@ -1132,6 +1132,8 @@ static void intel_hda_realize(PCIDevice *pci, Error **errp)
{
IntelHDAState *d = INTEL_HDA(pci);
uint8_t *conf = d->pci.config;
+ Error *err = NULL;
+ int ret;
d->name = object_get_typename(OBJECT(d));
@@ -1140,13 +1142,27 @@ static void intel_hda_realize(PCIDevice *pci, Error **errp)
/* HDCTL off 0x40 bit 0 selects signaling mode (1-HDA, 0 - Ac97) 18.1.19 */
conf[0x40] = 0x01;
+ if (d->msi != ON_OFF_AUTO_OFF) {
+ ret = msi_init(&d->pci, d->old_msi_addr ? 0x50 : 0x60,
+ 1, true, false, &err);
+ /* Any error other than -ENOTSUP(board's MSI support is broken)
+ * is a programming error */
+ assert(!ret || ret == -ENOTSUP);
+ if (ret && d->msi == ON_OFF_AUTO_ON) {
+ /* Can't satisfy user's explicit msi=on request, fail */
+ error_append_hint(&err, "You have to use msi=auto (default) or "
+ "msi=off with this machine type.\n");
+ error_propagate(errp, err);
+ return;
+ }
+ assert(!err || d->msi == ON_OFF_AUTO_AUTO);
+ /* With msi=auto, we fall back to MSI off silently */
+ error_free(err);
+ }
+
memory_region_init_io(&d->mmio, OBJECT(d), &intel_hda_mmio_ops, d,
"intel-hda", 0x4000);
pci_register_bar(&d->pci, 0, 0, &d->mmio);
- if (d->msi != ON_OFF_AUTO_OFF) {
- /* TODO check for errors */
- msi_init(&d->pci, d->old_msi_addr ? 0x50 : 0x60, 1, true, false);
- }
hda_codec_bus_init(DEVICE(pci), &d->codecs, sizeof(d->codecs),
intel_hda_response, intel_hda_xfer);
diff --git a/hw/ide/ich.c b/hw/ide/ich.c
index 0a13334..920ec27 100644
--- a/hw/ide/ich.c
+++ b/hw/ide/ich.c
@@ -68,7 +68,6 @@
#include <hw/isa/isa.h>
#include "sysemu/block-backend.h"
#include "sysemu/dma.h"
-
#include <hw/ide/pci.h>
#include <hw/ide/ahci.h>
@@ -111,6 +110,7 @@ static void pci_ich9_ahci_realize(PCIDevice *dev, Error **errp)
int sata_cap_offset;
uint8_t *sata_cap;
d = ICH_AHCI(dev);
+ int ret;
ahci_realize(&d->ahci, DEVICE(dev), pci_get_address_space(dev), 6);
@@ -146,7 +146,10 @@ static void pci_ich9_ahci_realize(PCIDevice *dev, Error **errp)
/* Although the AHCI 1.3 specification states that the first capability
* should be PMCAP, the Intel ICH9 data sheet specifies that the ICH9
* AHCI device puts the MSI capability first, pointing to 0x80. */
- msi_init(dev, ICH9_MSI_CAP_OFFSET, 1, true, false);
+ ret = msi_init(dev, ICH9_MSI_CAP_OFFSET, 1, true, false, NULL);
+ /* Any error other than -ENOTSUP(board's MSI support is broken)
+ * is a programming error. Fall back to INTx silently on -ENOTSUP */
+ assert(!ret || ret == -ENOTSUP);
}
static void pci_ich9_uninit(PCIDevice *dev)
diff --git a/hw/net/e1000e.c b/hw/net/e1000e.c
index 692283f..a06d184 100644
--- a/hw/net/e1000e.c
+++ b/hw/net/e1000e.c
@@ -268,13 +268,9 @@ e1000e_init_msi(E1000EState *s)
{
int res;
- res = msi_init(PCI_DEVICE(s),
- 0xD0, /* MSI capability offset */
- 1, /* MAC MSI interrupts */
- true, /* 64-bit message addresses supported */
- false); /* Per vector mask supported */
+ res = msi_init(PCI_DEVICE(s), 0xD0, 1, true, false, NULL);
- if (res > 0) {
+ if (!res) {
s->intr_state |= E1000E_USE_MSI;
} else {
trace_e1000e_msi_init_fail(res);
diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c
index 92236d3..f24298c 100644
--- a/hw/net/vmxnet3.c
+++ b/hw/net/vmxnet3.c
@@ -2216,27 +2216,6 @@ vmxnet3_cleanup_msix(VMXNET3State *s)
}
}
-#define VMXNET3_USE_64BIT (true)
-#define VMXNET3_PER_VECTOR_MASK (false)
-
-static bool
-vmxnet3_init_msi(VMXNET3State *s)
-{
- PCIDevice *d = PCI_DEVICE(s);
- int res;
-
- res = msi_init(d, VMXNET3_MSI_OFFSET(s), VMXNET3_MAX_NMSIX_INTRS,
- VMXNET3_USE_64BIT, VMXNET3_PER_VECTOR_MASK);
- if (0 > res) {
- VMW_WRPRN("Failed to initialize MSI, error %d", res);
- s->msi_used = false;
- } else {
- s->msi_used = true;
- }
-
- return s->msi_used;
-}
-
static void
vmxnet3_cleanup_msi(VMXNET3State *s)
{
@@ -2298,10 +2277,15 @@ static uint64_t vmxnet3_device_serial_num(VMXNET3State *s)
return dsn_payload;
}
+
+#define VMXNET3_USE_64BIT (true)
+#define VMXNET3_PER_VECTOR_MASK (false)
+
static void vmxnet3_pci_realize(PCIDevice *pci_dev, Error **errp)
{
DeviceState *dev = DEVICE(pci_dev);
VMXNET3State *s = VMXNET3(pci_dev);
+ int ret;
VMW_CBPRN("Starting init...");
@@ -2325,14 +2309,17 @@ static void vmxnet3_pci_realize(PCIDevice *pci_dev, Error **errp)
/* Interrupt pin A */
pci_dev->config[PCI_INTERRUPT_PIN] = 0x01;
+ ret = msi_init(pci_dev, VMXNET3_MSI_OFFSET(s), VMXNET3_MAX_NMSIX_INTRS,
+ VMXNET3_USE_64BIT, VMXNET3_PER_VECTOR_MASK, NULL);
+ /* Any error other than -ENOTSUP(board's MSI support is broken)
+ * is a programming error. Fall back to INTx silently on -ENOTSUP */
+ assert(!ret || ret == -ENOTSUP);
+ s->msi_used = !ret;
+
if (!vmxnet3_init_msix(s)) {
VMW_WRPRN("Failed to initialize MSI-X, configuration is inconsistent.");
}
- if (!vmxnet3_init_msi(s)) {
- VMW_WRPRN("Failed to initialize MSI, configuration is inconsistent.");
- }
-
vmxnet3_net_init(s);
if (pci_is_express(pci_dev)) {
diff --git a/hw/pci-bridge/ioh3420.c b/hw/pci-bridge/ioh3420.c
index b4a7806..93c6f0b 100644
--- a/hw/pci-bridge/ioh3420.c
+++ b/hw/pci-bridge/ioh3420.c
@@ -25,6 +25,7 @@
#include "hw/pci/msi.h"
#include "hw/pci/pcie.h"
#include "ioh3420.h"
+#include "qapi/error.h"
#define PCI_DEVICE_ID_IOH_EPORT 0x3420 /* D0:F0 express mode */
#define PCI_DEVICE_ID_IOH_REV 0x2
@@ -97,6 +98,7 @@ static int ioh3420_initfn(PCIDevice *d)
PCIEPort *p = PCIE_PORT(d);
PCIESlot *s = PCIE_SLOT(d);
int rc;
+ Error *err = NULL;
pci_bridge_initfn(d, TYPE_PCIE_BUS);
pcie_port_init_reg(d);
@@ -109,8 +111,10 @@ static int ioh3420_initfn(PCIDevice *d)
rc = msi_init(d, IOH_EP_MSI_OFFSET, IOH_EP_MSI_NR_VECTOR,
IOH_EP_MSI_SUPPORTED_FLAGS & PCI_MSI_FLAGS_64BIT,
- IOH_EP_MSI_SUPPORTED_FLAGS & PCI_MSI_FLAGS_MASKBIT);
+ IOH_EP_MSI_SUPPORTED_FLAGS & PCI_MSI_FLAGS_MASKBIT, &err);
if (rc < 0) {
+ assert(rc == -ENOTSUP);
+ error_report_err(err);
goto err_bridge;
}
diff --git a/hw/pci-bridge/pci_bridge_dev.c b/hw/pci-bridge/pci_bridge_dev.c
index 0fbecc4..5dbd933 100644
--- a/hw/pci-bridge/pci_bridge_dev.c
+++ b/hw/pci-bridge/pci_bridge_dev.c
@@ -54,6 +54,7 @@ static int pci_bridge_dev_initfn(PCIDevice *dev)
PCIBridge *br = PCI_BRIDGE(dev);
PCIBridgeDev *bridge_dev = PCI_BRIDGE_DEV(dev);
int err;
+ Error *local_err = NULL;
pci_bridge_initfn(dev, TYPE_PCI_BUS);
@@ -75,12 +76,23 @@ static int pci_bridge_dev_initfn(PCIDevice *dev)
goto slotid_error;
}
- if (bridge_dev->msi != ON_OFF_AUTO_OFF &&
- msi_nonbroken) {
- err = msi_init(dev, 0, 1, true, true);
- if (err < 0) {
+ if (bridge_dev->msi != ON_OFF_AUTO_OFF) {
+ /* it means SHPC exists, because MSI is needed by SHPC */
+
+ err = msi_init(dev, 0, 1, true, true, &local_err);
+ /* Any error other than -ENOTSUP(board's MSI support is broken)
+ * is a programming error */
+ assert(!err || err == -ENOTSUP);
+ if (err && bridge_dev->msi == ON_OFF_AUTO_ON) {
+ /* Can't satisfy user's explicit msi=on request, fail */
+ error_append_hint(&local_err, "You have to use msi=auto (default) "
+ "or msi=off with this machine type.\n");
+ error_report_err(local_err);
goto msi_error;
}
+ assert(!local_err || bridge_dev->msi == ON_OFF_AUTO_AUTO);
+ /* With msi=auto, we fall back to MSI off silently */
+ error_free(local_err);
}
if (shpc_present(dev)) {
diff --git a/hw/pci-bridge/xio3130_downstream.c b/hw/pci-bridge/xio3130_downstream.c
index e6d653d..f6149a3 100644
--- a/hw/pci-bridge/xio3130_downstream.c
+++ b/hw/pci-bridge/xio3130_downstream.c
@@ -24,6 +24,7 @@
#include "hw/pci/msi.h"
#include "hw/pci/pcie.h"
#include "xio3130_downstream.h"
+#include "qapi/error.h"
#define PCI_DEVICE_ID_TI_XIO3130D 0x8233 /* downstream port */
#define XIO3130_REVISION 0x1
@@ -60,14 +61,17 @@ static int xio3130_downstream_initfn(PCIDevice *d)
PCIEPort *p = PCIE_PORT(d);
PCIESlot *s = PCIE_SLOT(d);
int rc;
+ Error *err = NULL;
pci_bridge_initfn(d, TYPE_PCIE_BUS);
pcie_port_init_reg(d);
rc = msi_init(d, XIO3130_MSI_OFFSET, XIO3130_MSI_NR_VECTOR,
XIO3130_MSI_SUPPORTED_FLAGS & PCI_MSI_FLAGS_64BIT,
- XIO3130_MSI_SUPPORTED_FLAGS & PCI_MSI_FLAGS_MASKBIT);
+ XIO3130_MSI_SUPPORTED_FLAGS & PCI_MSI_FLAGS_MASKBIT, &err);
if (rc < 0) {
+ assert(rc == -ENOTSUP);
+ error_report_err(err);
goto err_bridge;
}
diff --git a/hw/pci-bridge/xio3130_upstream.c b/hw/pci-bridge/xio3130_upstream.c
index d976844..487edac 100644
--- a/hw/pci-bridge/xio3130_upstream.c
+++ b/hw/pci-bridge/xio3130_upstream.c
@@ -24,6 +24,7 @@
#include "hw/pci/msi.h"
#include "hw/pci/pcie.h"
#include "xio3130_upstream.h"
+#include "qapi/error.h"
#define PCI_DEVICE_ID_TI_XIO3130U 0x8232 /* upstream port */
#define XIO3130_REVISION 0x2
@@ -56,14 +57,17 @@ static int xio3130_upstream_initfn(PCIDevice *d)
{
PCIEPort *p = PCIE_PORT(d);
int rc;
+ Error *err = NULL;
pci_bridge_initfn(d, TYPE_PCIE_BUS);
pcie_port_init_reg(d);
rc = msi_init(d, XIO3130_MSI_OFFSET, XIO3130_MSI_NR_VECTOR,
XIO3130_MSI_SUPPORTED_FLAGS & PCI_MSI_FLAGS_64BIT,
- XIO3130_MSI_SUPPORTED_FLAGS & PCI_MSI_FLAGS_MASKBIT);
+ XIO3130_MSI_SUPPORTED_FLAGS & PCI_MSI_FLAGS_MASKBIT, &err);
if (rc < 0) {
+ assert(rc == -ENOTSUP);
+ error_report_err(err);
goto err_bridge;
}
diff --git a/hw/pci/msi.c b/hw/pci/msi.c
index ed79225..a87b227 100644
--- a/hw/pci/msi.c
+++ b/hw/pci/msi.c
@@ -22,6 +22,7 @@
#include "hw/pci/msi.h"
#include "hw/xen/xen.h"
#include "qemu/range.h"
+#include "qapi/error.h"
/* PCI_MSI_ADDRESS_LO */
#define PCI_MSI_ADDRESS_LO_MASK (~0x3)
@@ -173,7 +174,8 @@ bool msi_enabled(const PCIDevice *dev)
* If @msi64bit, make the device capable of sending a 64-bit message
* address.
* If @msi_per_vector_mask, make the device support per-vector masking.
- * Return 0 on success, return -errno on error.
+ * @errp is for returning errors.
+ * Return 0 on success; set @errp and return -errno on error.
*
* -ENOTSUP means lacking msi support for a msi-capable platform.
* -EINVAL means capability overlap, happens when @offset is non-zero,
@@ -181,7 +183,8 @@ bool msi_enabled(const PCIDevice *dev)
* if a real HW is broken.
*/
int msi_init(struct PCIDevice *dev, uint8_t offset,
- unsigned int nr_vectors, bool msi64bit, bool msi_per_vector_mask)
+ unsigned int nr_vectors, bool msi64bit,
+ bool msi_per_vector_mask, Error **errp)
{
unsigned int vectors_order;
uint16_t flags;
@@ -189,6 +192,7 @@ int msi_init(struct PCIDevice *dev, uint8_t offset,
int config_offset;
if (!msi_nonbroken) {
+ error_setg(errp, "MSI is not supported by interrupt controller");
return -ENOTSUP;
}
@@ -212,7 +216,8 @@ int msi_init(struct PCIDevice *dev, uint8_t offset,
}
cap_size = msi_cap_sizeof(flags);
- config_offset = pci_add_capability(dev, PCI_CAP_ID_MSI, offset, cap_size);
+ config_offset = pci_add_capability2(dev, PCI_CAP_ID_MSI, offset,
+ cap_size, errp);
if (config_offset < 0) {
return config_offset;
}
diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c
index 636ea73..6eb57ff 100644
--- a/hw/scsi/megasas.c
+++ b/hw/scsi/megasas.c
@@ -29,7 +29,7 @@
#include "hw/scsi/scsi.h"
#include "block/scsi.h"
#include "trace.h"
-
+#include "qapi/error.h"
#include "mfi.h"
#define MEGASAS_VERSION_GEN1 "1.70"
@@ -2330,6 +2330,8 @@ static void megasas_scsi_realize(PCIDevice *dev, Error **errp)
MegasasBaseClass *b = MEGASAS_DEVICE_GET_CLASS(s);
uint8_t *pci_conf;
int i, bar_type;
+ Error *err = NULL;
+ int ret;
pci_conf = dev->config;
@@ -2338,6 +2340,24 @@ static void megasas_scsi_realize(PCIDevice *dev, Error **errp)
/* Interrupt pin 1 */
pci_conf[PCI_INTERRUPT_PIN] = 0x01;
+ if (megasas_use_msi(s)) {
+ ret = msi_init(dev, 0x50, 1, true, false, &err);
+ /* Any error other than -ENOTSUP(board's MSI support is broken)
+ * is a programming error */
+ assert(!ret || ret == -ENOTSUP);
+ if (ret && s->msi == ON_OFF_AUTO_ON) {
+ /* Can't satisfy user's explicit msi=on request, fail */
+ error_append_hint(&err, "You have to use msi=auto (default) or "
+ "msi=off with this machine type.\n");
+ error_propagate(errp, err);
+ return;
+ } else if (ret) {
+ /* With msi=auto, we fall back to MSI off silently */
+ s->msi = ON_OFF_AUTO_OFF;
+ error_free(err);
+ }
+ }
+
memory_region_init_io(&s->mmio_io, OBJECT(s), &megasas_mmio_ops, s,
"megasas-mmio", 0x4000);
memory_region_init_io(&s->port_io, OBJECT(s), &megasas_port_ops, s,
@@ -2345,10 +2365,6 @@ static void megasas_scsi_realize(PCIDevice *dev, Error **errp)
memory_region_init_io(&s->queue_io, OBJECT(s), &megasas_queue_ops, s,
"megasas-queue", 0x40000);
- if (megasas_use_msi(s) &&
- msi_init(dev, 0x50, 1, true, false)) {
- s->msi = ON_OFF_AUTO_OFF;
- }
if (megasas_use_msix(s) &&
msix_init(dev, 15, &s->mmio_io, b->mmio_bar, 0x2000,
&s->mmio_io, b->mmio_bar, 0x3800, 0x68)) {
diff --git a/hw/scsi/mptsas.c b/hw/scsi/mptsas.c
index 40033c4..bb056c4 100644
--- a/hw/scsi/mptsas.c
+++ b/hw/scsi/mptsas.c
@@ -32,7 +32,7 @@
#include "hw/scsi/scsi.h"
#include "block/scsi.h"
#include "trace.h"
-
+#include "qapi/error.h"
#include "mptsas.h"
#include "mpi.h"
@@ -1273,10 +1273,33 @@ static void mptsas_scsi_init(PCIDevice *dev, Error **errp)
{
DeviceState *d = DEVICE(dev);
MPTSASState *s = MPT_SAS(dev);
+ Error *err = NULL;
+ int ret;
dev->config[PCI_LATENCY_TIMER] = 0;
dev->config[PCI_INTERRUPT_PIN] = 0x01;
+ if (s->msi != ON_OFF_AUTO_OFF) {
+ ret = msi_init(dev, 0, 1, true, false, &err);
+ /* Any error other than -ENOTSUP(board's MSI support is broken)
+ * is a programming error */
+ assert(!ret || ret == -ENOTSUP);
+ if (ret && s->msi == ON_OFF_AUTO_ON) {
+ /* Can't satisfy user's explicit msi=on request, fail */
+ error_append_hint(&err, "You have to use msi=auto (default) or "
+ "msi=off with this machine type.\n");
+ error_propagate(errp, err);
+ s->msi_in_use = false;
+ return;
+ } else if (ret) {
+ /* With msi=auto, we fall back to MSI off silently */
+ error_free(err);
+ s->msi_in_use = false;
+ } else {
+ s->msi_in_use = true;
+ }
+ }
+
memory_region_init_io(&s->mmio_io, OBJECT(s), &mptsas_mmio_ops, s,
"mptsas-mmio", 0x4000);
memory_region_init_io(&s->port_io, OBJECT(s), &mptsas_port_ops, s,
@@ -1284,12 +1307,6 @@ static void mptsas_scsi_init(PCIDevice *dev, Error **errp)
memory_region_init_io(&s->diag_io, OBJECT(s), &mptsas_diag_ops, s,
"mptsas-diag", 0x10000);
- if (s->msi != ON_OFF_AUTO_OFF &&
- msi_init(dev, 0, 1, true, false) >= 0) {
- /* TODO check for errors */
- s->msi_in_use = true;
- }
-
pci_register_bar(dev, 0, PCI_BASE_ADDRESS_SPACE_IO, &s->port_io);
pci_register_bar(dev, 1, PCI_BASE_ADDRESS_SPACE_MEMORY |
PCI_BASE_ADDRESS_MEM_TYPE_32, &s->mmio_io);
diff --git a/hw/scsi/vmw_pvscsi.c b/hw/scsi/vmw_pvscsi.c
index e035fce..ecd6077 100644
--- a/hw/scsi/vmw_pvscsi.c
+++ b/hw/scsi/vmw_pvscsi.c
@@ -1063,7 +1063,7 @@ pvscsi_init_msi(PVSCSIState *s)
PCIDevice *d = PCI_DEVICE(s);
res = msi_init(d, PVSCSI_MSI_OFFSET(s), PVSCSI_MSIX_NUM_VECTORS,
- PVSCSI_USE_64BIT, PVSCSI_PER_VECTOR_MASK);
+ PVSCSI_USE_64BIT, PVSCSI_PER_VECTOR_MASK, NULL);
if (res < 0) {
trace_pvscsi_init_msi_fail(res);
s->msi_used = false;
diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
index 0a5510f..1a3377f 100644
--- a/hw/usb/hcd-xhci.c
+++ b/hw/usb/hcd-xhci.c
@@ -26,6 +26,7 @@
#include "hw/pci/msi.h"
#include "hw/pci/msix.h"
#include "trace.h"
+#include "qapi/error.h"
//#define DEBUG_XHCI
//#define DEBUG_DATA
@@ -3581,6 +3582,7 @@ static void usb_xhci_init(XHCIState *xhci)
static void usb_xhci_realize(struct PCIDevice *dev, Error **errp)
{
int i, ret;
+ Error *err = NULL;
XHCIState *xhci = XHCI(dev);
@@ -3591,6 +3593,23 @@ static void usb_xhci_realize(struct PCIDevice *dev, Error **errp)
usb_xhci_init(xhci);
+ if (xhci->msi != ON_OFF_AUTO_OFF) {
+ ret = msi_init(dev, 0x70, xhci->numintrs, true, false, &err);
+ /* Any error other than -ENOTSUP(board's MSI support is broken)
+ * is a programming error */
+ assert(!ret || ret == -ENOTSUP);
+ if (ret && xhci->msi == ON_OFF_AUTO_ON) {
+ /* Can't satisfy user's explicit msi=on request, fail */
+ error_append_hint(&err, "You have to use msi=auto (default) or "
+ "msi=off with this machine type.\n");
+ error_propagate(errp, err);
+ return;
+ }
+ assert(!err || xhci->msi == ON_OFF_AUTO_AUTO);
+ /* With msi=auto, we fall back to MSI off silently */
+ error_free(err);
+ }
+
if (xhci->numintrs > MAXINTRS) {
xhci->numintrs = MAXINTRS;
}
@@ -3648,10 +3667,6 @@ static void usb_xhci_realize(struct PCIDevice *dev, Error **errp)
assert(ret >= 0);
}
- if (xhci->msi != ON_OFF_AUTO_OFF) {
- /* TODO check for errors */
- msi_init(dev, 0x70, xhci->numintrs, true, false);
- }
if (xhci->msix != ON_OFF_AUTO_OFF) {
/* TODO check for errors */
msix_init(dev, xhci->numintrs,
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index f2c679e..44783c5 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -31,6 +31,7 @@
#include "sysemu/sysemu.h"
#include "pci.h"
#include "trace.h"
+#include "qapi/error.h"
#define MSIX_CAP_LENGTH 12
@@ -1170,6 +1171,7 @@ static int vfio_msi_setup(VFIOPCIDevice *vdev, int pos)
uint16_t ctrl;
bool msi_64bit, msi_maskbit;
int ret, entries;
+ Error *err = NULL;
if (pread(vdev->vbasedev.fd, &ctrl, sizeof(ctrl),
vdev->config_offset + pos + PCI_CAP_FLAGS) != sizeof(ctrl)) {
@@ -1183,12 +1185,13 @@ static int vfio_msi_setup(VFIOPCIDevice *vdev, int pos)
trace_vfio_msi_setup(vdev->vbasedev.name, pos);
- ret = msi_init(&vdev->pdev, pos, entries, msi_64bit, msi_maskbit);
+ ret = msi_init(&vdev->pdev, pos, entries, msi_64bit, msi_maskbit, &err);
if (ret < 0) {
if (ret == -ENOTSUP) {
return 0;
}
- error_report("vfio: msi_init failed");
+ error_prepend(&err, "vfio: msi_init failed: ");
+ error_report_err(err);
return ret;
}
vdev->msi_cap_size = 0xa + (msi_maskbit ? 0xa : 0) + (msi_64bit ? 0x4 : 0);
--
MST
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [Qemu-devel] [PULL 32/36] megasas: remove unnecessary megasas_use_msi()
[not found] <1467650742-17580-1-git-send-email-mst@redhat.com>
` (30 preceding siblings ...)
2016-07-04 16:48 ` [Qemu-devel] [PULL 31/36] pci: Convert msi_init() to Error and fix callers to check it Michael S. Tsirkin
@ 2016-07-04 16:48 ` Michael S. Tsirkin
2016-07-04 16:48 ` [Qemu-devel] [PULL 33/36] mptsas: remove unnecessary internal msi state flag Michael S. Tsirkin
` (3 subsequent siblings)
35 siblings, 0 replies; 43+ messages in thread
From: Michael S. Tsirkin @ 2016-07-04 16:48 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Cao jin, Hannes Reinecke, Paolo Bonzini,
Markus Armbruster, Marcel Apfelbaum, Hannes Reinecke, qemu-block
From: Cao jin <caoj.fnst@cn.fujitsu.com>
megasas overwrites user configuration when msi_init fail to flag internal msi
state, which is unsuitable. megasa_use_msi() is unnecessary, we can call
msi_uninit() directly when unrealize, even no need to call msi_enabled() first.
cc: Hannes Reinecke <hare@suse.de>
cc: Paolo Bonzini <pbonzini@redhat.com>
cc: Markus Armbruster <armbru@redhat.com>
cc: Marcel Apfelbaum <marcel@redhat.com>
cc: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/scsi/megasas.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c
index 6eb57ff..52a4123 100644
--- a/hw/scsi/megasas.c
+++ b/hw/scsi/megasas.c
@@ -155,11 +155,6 @@ static bool megasas_use_queue64(MegasasState *s)
return s->flags & MEGASAS_MASK_USE_QUEUE64;
}
-static bool megasas_use_msi(MegasasState *s)
-{
- return s->msi != ON_OFF_AUTO_OFF;
-}
-
static bool megasas_use_msix(MegasasState *s)
{
return s->msix != ON_OFF_AUTO_OFF;
@@ -2307,9 +2302,7 @@ static void megasas_scsi_uninit(PCIDevice *d)
if (megasas_use_msix(s)) {
msix_uninit(d, &s->mmio_io, &s->mmio_io);
}
- if (megasas_use_msi(s)) {
- msi_uninit(d);
- }
+ msi_uninit(d);
}
static const struct SCSIBusInfo megasas_scsi_info = {
@@ -2340,7 +2333,7 @@ static void megasas_scsi_realize(PCIDevice *dev, Error **errp)
/* Interrupt pin 1 */
pci_conf[PCI_INTERRUPT_PIN] = 0x01;
- if (megasas_use_msi(s)) {
+ if (s->msi != ON_OFF_AUTO_OFF) {
ret = msi_init(dev, 0x50, 1, true, false, &err);
/* Any error other than -ENOTSUP(board's MSI support is broken)
* is a programming error */
--
MST
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [Qemu-devel] [PULL 33/36] mptsas: remove unnecessary internal msi state flag
[not found] <1467650742-17580-1-git-send-email-mst@redhat.com>
` (31 preceding siblings ...)
2016-07-04 16:48 ` [Qemu-devel] [PULL 32/36] megasas: remove unnecessary megasas_use_msi() Michael S. Tsirkin
@ 2016-07-04 16:48 ` Michael S. Tsirkin
2016-07-04 16:48 ` [Qemu-devel] [PULL 34/36] vmxnet3: " Michael S. Tsirkin
` (2 subsequent siblings)
35 siblings, 0 replies; 43+ messages in thread
From: Michael S. Tsirkin @ 2016-07-04 16:48 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Cao jin, Markus Armbruster, Marcel Apfelbaum,
Paolo Bonzini
From: Cao jin <caoj.fnst@cn.fujitsu.com>
internal flag msi_in_use in unnecessary, msi_uninit() could be called
directly, and msi_enabled() is enough to check device msi state.
cc: Markus Armbruster <armbru@redhat.com>
cc: Marcel Apfelbaum <marcel@redhat.com>
cc: Paolo Bonzini <pbonzini@redhat.com>
cc: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/scsi/mptsas.h | 2 --
hw/scsi/mptsas.c | 18 ++++++------------
2 files changed, 6 insertions(+), 14 deletions(-)
diff --git a/hw/scsi/mptsas.h b/hw/scsi/mptsas.h
index 0436a33..da014a3 100644
--- a/hw/scsi/mptsas.h
+++ b/hw/scsi/mptsas.h
@@ -31,8 +31,6 @@ struct MPTSASState {
OnOffAuto msi;
uint64_t sas_addr;
- bool msi_in_use;
-
/* Doorbell register */
uint32_t state;
uint8_t who_init;
diff --git a/hw/scsi/mptsas.c b/hw/scsi/mptsas.c
index bb056c4..1ae32fb 100644
--- a/hw/scsi/mptsas.c
+++ b/hw/scsi/mptsas.c
@@ -63,7 +63,7 @@ static void mptsas_update_interrupt(MPTSASState *s)
PCIDevice *pci = (PCIDevice *) s;
uint32_t state = s->intr_status & ~(s->intr_mask | MPI_HIS_IOP_DOORBELL_STATUS);
- if (s->msi_in_use && msi_enabled(pci)) {
+ if (msi_enabled(pci)) {
if (state) {
trace_mptsas_irq_msi(s);
msi_notify(pci, 0);
@@ -1289,15 +1289,12 @@ static void mptsas_scsi_init(PCIDevice *dev, Error **errp)
error_append_hint(&err, "You have to use msi=auto (default) or "
"msi=off with this machine type.\n");
error_propagate(errp, err);
- s->msi_in_use = false;
return;
- } else if (ret) {
- /* With msi=auto, we fall back to MSI off silently */
- error_free(err);
- s->msi_in_use = false;
- } else {
- s->msi_in_use = true;
}
+ assert(!err || s->msi == ON_OFF_AUTO_AUTO);
+ /* With msi=auto, we fall back to MSI off silently */
+ error_free(err);
+
}
memory_region_init_io(&s->mmio_io, OBJECT(s), &mptsas_mmio_ops, s,
@@ -1337,9 +1334,7 @@ static void mptsas_scsi_uninit(PCIDevice *dev)
MPTSASState *s = MPT_SAS(dev);
qemu_bh_delete(s->request_bh);
- if (s->msi_in_use) {
- msi_uninit(dev);
- }
+ msi_uninit(dev);
}
static void mptsas_reset(DeviceState *dev)
@@ -1375,7 +1370,6 @@ static const VMStateDescription vmstate_mptsas = {
.post_load = mptsas_post_load,
.fields = (VMStateField[]) {
VMSTATE_PCI_DEVICE(dev, MPTSASState),
- VMSTATE_BOOL(msi_in_use, MPTSASState),
VMSTATE_UINT32(state, MPTSASState),
VMSTATE_UINT8(who_init, MPTSASState),
--
MST
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [Qemu-devel] [PULL 34/36] vmxnet3: remove unnecessary internal msi state flag
[not found] <1467650742-17580-1-git-send-email-mst@redhat.com>
` (32 preceding siblings ...)
2016-07-04 16:48 ` [Qemu-devel] [PULL 33/36] mptsas: remove unnecessary internal msi state flag Michael S. Tsirkin
@ 2016-07-04 16:48 ` Michael S. Tsirkin
2016-07-04 16:48 ` [Qemu-devel] [PULL 35/36] e1000e: " Michael S. Tsirkin
2016-07-04 16:48 ` [Qemu-devel] [PULL 36/36] vmw_pvscsi: " Michael S. Tsirkin
35 siblings, 0 replies; 43+ messages in thread
From: Michael S. Tsirkin @ 2016-07-04 16:48 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Cao jin, Paolo Bonzini, Dmitry Fleytman,
Markus Armbruster, Marcel Apfelbaum, Jason Wang
From: Cao jin <caoj.fnst@cn.fujitsu.com>
Internal flag msi_used is unnecessary, it has the same effect as msi_enabled().
msi_uninit() could be called directly without risk.
cc: Paolo Bonzini <pbonzini@redhat.com>
cc: Dmitry Fleytman <dmitry@daynix.com>
cc: Markus Armbruster <armbru@redhat.com>
cc: Marcel Apfelbaum <marcel@redhat.com>
cc: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/net/vmxnet3.c | 17 ++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c
index f24298c..5994890 100644
--- a/hw/net/vmxnet3.c
+++ b/hw/net/vmxnet3.c
@@ -283,8 +283,6 @@ typedef struct {
/* Whether MSI-X support was installed successfully */
bool msix_used;
- /* Whether MSI support was installed successfully */
- bool msi_used;
hwaddr drv_shmem;
hwaddr temp_shared_guest_driver_memory;
@@ -366,7 +364,7 @@ static bool _vmxnet3_assert_interrupt_line(VMXNET3State *s, uint32_t int_idx)
msix_notify(d, int_idx);
return false;
}
- if (s->msi_used && msi_enabled(d)) {
+ if (msi_enabled(d)) {
VMW_IRPRN("Sending MSI notification for vector %u", int_idx);
msi_notify(d, int_idx);
return false;
@@ -390,7 +388,7 @@ static void _vmxnet3_deassert_interrupt_line(VMXNET3State *s, int lidx)
* This function should never be called for MSI(X) interrupts
* because deassertion never required for message interrupts
*/
- assert(!s->msi_used || !msi_enabled(d));
+ assert(!msi_enabled(d));
VMW_IRPRN("Deasserting line for interrupt %u", lidx);
pci_irq_deassert(d);
@@ -427,7 +425,7 @@ static void vmxnet3_trigger_interrupt(VMXNET3State *s, int lidx)
goto do_automask;
}
- if (s->msi_used && msi_enabled(d) && s->auto_int_masking) {
+ if (msi_enabled(d) && s->auto_int_masking) {
goto do_automask;
}
@@ -1425,8 +1423,8 @@ static void vmxnet3_update_features(VMXNET3State *s)
static bool vmxnet3_verify_intx(VMXNET3State *s, int intx)
{
- return s->msix_used || s->msi_used || (intx ==
- (pci_get_byte(s->parent_obj.config + PCI_INTERRUPT_PIN) - 1));
+ return s->msix_used || msi_enabled(PCI_DEVICE(s))
+ || intx == pci_get_byte(s->parent_obj.config + PCI_INTERRUPT_PIN) - 1;
}
static void vmxnet3_validate_interrupt_idx(bool is_msix, int idx)
@@ -2221,9 +2219,7 @@ vmxnet3_cleanup_msi(VMXNET3State *s)
{
PCIDevice *d = PCI_DEVICE(s);
- if (s->msi_used) {
- msi_uninit(d);
- }
+ msi_uninit(d);
}
static void
@@ -2314,7 +2310,6 @@ static void vmxnet3_pci_realize(PCIDevice *pci_dev, Error **errp)
/* Any error other than -ENOTSUP(board's MSI support is broken)
* is a programming error. Fall back to INTx silently on -ENOTSUP */
assert(!ret || ret == -ENOTSUP);
- s->msi_used = !ret;
if (!vmxnet3_init_msix(s)) {
VMW_WRPRN("Failed to initialize MSI-X, configuration is inconsistent.");
--
MST
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [Qemu-devel] [PULL 35/36] e1000e: remove unnecessary internal msi state flag
[not found] <1467650742-17580-1-git-send-email-mst@redhat.com>
` (33 preceding siblings ...)
2016-07-04 16:48 ` [Qemu-devel] [PULL 34/36] vmxnet3: " Michael S. Tsirkin
@ 2016-07-04 16:48 ` Michael S. Tsirkin
2016-07-04 16:48 ` [Qemu-devel] [PULL 36/36] vmw_pvscsi: " Michael S. Tsirkin
35 siblings, 0 replies; 43+ messages in thread
From: Michael S. Tsirkin @ 2016-07-04 16:48 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Cao jin, Dmitry Fleytman, Jason Wang,
Markus Armbruster, Marcel Apfelbaum
From: Cao jin <caoj.fnst@cn.fujitsu.com>
Internal big flag E1000E_USE_MSI is unnecessary, also is the helper
function: e1000e_init_msi(), e1000e_cleanup_msi(), so, remove them all.
cc: Dmitry Fleytman <dmitry@daynix.com>
cc: Jason Wang <jasowang@redhat.com>
cc: Markus Armbruster <armbru@redhat.com>
cc: Marcel Apfelbaum <marcel@redhat.com>
cc: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
---
hw/net/e1000e.c | 33 +++++++--------------------------
1 file changed, 7 insertions(+), 26 deletions(-)
diff --git a/hw/net/e1000e.c b/hw/net/e1000e.c
index a06d184..c7d33ee 100644
--- a/hw/net/e1000e.c
+++ b/hw/net/e1000e.c
@@ -89,8 +89,7 @@ typedef struct E1000EState {
#define E1000E_MSIX_TABLE (0x0000)
#define E1000E_MSIX_PBA (0x2000)
-#define E1000E_USE_MSI BIT(0)
-#define E1000E_USE_MSIX BIT(1)
+#define E1000E_USE_MSIX BIT(0)
static uint64_t
e1000e_mmio_read(void *opaque, hwaddr addr, unsigned size)
@@ -264,28 +263,6 @@ static void e1000e_core_realize(E1000EState *s)
}
static void
-e1000e_init_msi(E1000EState *s)
-{
- int res;
-
- res = msi_init(PCI_DEVICE(s), 0xD0, 1, true, false, NULL);
-
- if (!res) {
- s->intr_state |= E1000E_USE_MSI;
- } else {
- trace_e1000e_msi_init_fail(res);
- }
-}
-
-static void
-e1000e_cleanup_msi(E1000EState *s)
-{
- if (s->intr_state & E1000E_USE_MSI) {
- msi_uninit(PCI_DEVICE(s));
- }
-}
-
-static void
e1000e_unuse_msix_vectors(E1000EState *s, int num_vectors)
{
int i;
@@ -440,6 +417,7 @@ static void e1000e_pci_realize(PCIDevice *pci_dev, Error **errp)
static const uint16_t e1000e_dsn_offset = 0x140;
E1000EState *s = E1000E(pci_dev);
uint8_t *macaddr;
+ int ret;
trace_e1000e_cb_pci_realize();
@@ -489,7 +467,10 @@ static void e1000e_pci_realize(PCIDevice *pci_dev, Error **errp)
hw_error("Failed to initialize PCIe capability");
}
- e1000e_init_msi(s);
+ ret = msi_init(PCI_DEVICE(s), 0xD0, 1, true, false, NULL);
+ if (ret) {
+ trace_e1000e_msi_init_fail(ret);
+ }
if (e1000e_add_pm_capability(pci_dev, e1000e_pmrb_offset,
PCI_PM_CAP_DSI) < 0) {
@@ -528,7 +509,7 @@ static void e1000e_pci_uninit(PCIDevice *pci_dev)
qemu_del_nic(s->nic);
e1000e_cleanup_msix(s);
- e1000e_cleanup_msi(s);
+ msi_uninit(pci_dev);
}
static void e1000e_qdev_reset(DeviceState *dev)
--
MST
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [Qemu-devel] [PULL 36/36] vmw_pvscsi: remove unnecessary internal msi state flag
[not found] <1467650742-17580-1-git-send-email-mst@redhat.com>
` (34 preceding siblings ...)
2016-07-04 16:48 ` [Qemu-devel] [PULL 35/36] e1000e: " Michael S. Tsirkin
@ 2016-07-04 16:48 ` Michael S. Tsirkin
35 siblings, 0 replies; 43+ messages in thread
From: Michael S. Tsirkin @ 2016-07-04 16:48 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Cao jin, Paolo Bonzini, Dmitry Fleytman,
Markus Armbruster, Marcel Apfelbaum
From: Cao jin <caoj.fnst@cn.fujitsu.com>
Internal flag msi_used is uncesessary, msi_uninit() could be called
directly, msi_enabled() is enough to check device msi state.
But for migration compatibility, keep the field in structure.
cc: Paolo Bonzini <pbonzini@redhat.com>
cc: Dmitry Fleytman <dmitry@daynix.com>
cc: Markus Armbruster <armbru@redhat.com>
cc: Marcel Apfelbaum <marcel@redhat.com>
cc: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
---
hw/scsi/vmw_pvscsi.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/hw/scsi/vmw_pvscsi.c b/hw/scsi/vmw_pvscsi.c
index ecd6077..da71c8c 100644
--- a/hw/scsi/vmw_pvscsi.c
+++ b/hw/scsi/vmw_pvscsi.c
@@ -121,8 +121,7 @@ typedef struct {
uint8_t msg_ring_info_valid; /* Whether message ring initialized */
uint8_t use_msg; /* Whether to use message ring */
- uint8_t msi_used; /* Whether MSI support was installed successfully */
-
+ uint8_t msi_used; /* For migration compatibility */
PVSCSIRingInfo rings; /* Data transfer rings manager */
uint32_t resetting; /* Reset in progress */
@@ -362,7 +361,7 @@ pvscsi_update_irq_status(PVSCSIState *s)
trace_pvscsi_update_irq_level(should_raise, s->reg_interrupt_enabled,
s->reg_interrupt_status);
- if (s->msi_used && msi_enabled(d)) {
+ if (msi_enabled(d)) {
if (should_raise) {
trace_pvscsi_update_irq_msi();
msi_notify(d, PVSCSI_VECTOR_COMPLETION);
@@ -1077,9 +1076,7 @@ pvscsi_cleanup_msi(PVSCSIState *s)
{
PCIDevice *d = PCI_DEVICE(s);
- if (s->msi_used) {
- msi_uninit(d);
- }
+ msi_uninit(d);
}
static const MemoryRegionOps pvscsi_ops = {
--
MST
^ permalink raw reply related [flat|nested] 43+ messages in thread
* Re: [Qemu-devel] [PULL 03/36] hw/pci: delay bus_master_enable_region initialization
2016-07-04 16:46 ` [Qemu-devel] [PULL 03/36] hw/pci: delay bus_master_enable_region initialization Michael S. Tsirkin
@ 2016-07-09 1:34 ` Mark Cave-Ayland
2016-07-09 7:07 ` Marcel Apfelbaum
2016-07-11 14:42 ` Leon Alrae
1 sibling, 1 reply; 43+ messages in thread
From: Mark Cave-Ayland @ 2016-07-09 1:34 UTC (permalink / raw)
To: Michael S. Tsirkin, qemu-devel
Cc: Marcel Apfelbaum, Peter Maydell, Paolo Bonzini
On 04/07/16 17:46, Michael S. Tsirkin wrote:
> From: Marcel Apfelbaum <marcel@redhat.com>
>
> Skip bus_master_enable region creation on PCI device init
> in order to be sure the IOMMU device (if present) would
> be created in advance. Add this memory region at machine_done time.
>
> Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> include/hw/pci/pci_bus.h | 2 ++
> include/sysemu/sysemu.h | 1 +
> hw/pci/pci.c | 41 ++++++++++++++++++++++++++++++++---------
> vl.c | 5 +++++
> 4 files changed, 40 insertions(+), 9 deletions(-)
>
> diff --git a/include/hw/pci/pci_bus.h b/include/hw/pci/pci_bus.h
> index 403fec6..5484a9b 100644
> --- a/include/hw/pci/pci_bus.h
> +++ b/include/hw/pci/pci_bus.h
> @@ -39,6 +39,8 @@ struct PCIBus {
> Keep a count of the number of devices with raised IRQs. */
> int nirq;
> int *irq_count;
> +
> + Notifier machine_done;
> };
>
> typedef struct PCIBridgeWindows PCIBridgeWindows;
> diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
> index 7313673..ee7c760 100644
> --- a/include/sysemu/sysemu.h
> +++ b/include/sysemu/sysemu.h
> @@ -75,6 +75,7 @@ void qemu_add_exit_notifier(Notifier *notify);
> void qemu_remove_exit_notifier(Notifier *notify);
>
> void qemu_add_machine_init_done_notifier(Notifier *notify);
> +void qemu_remove_machine_init_done_notifier(Notifier *notify);
>
> void hmp_savevm(Monitor *mon, const QDict *qdict);
> int load_vmstate(const char *name);
> diff --git a/hw/pci/pci.c b/hw/pci/pci.c
> index 4b585f4..ee385eb 100644
> --- a/hw/pci/pci.c
> +++ b/hw/pci/pci.c
> @@ -78,10 +78,37 @@ static const VMStateDescription vmstate_pcibus = {
> }
> };
>
> +static void pci_init_bus_master(PCIDevice *pci_dev)
> +{
> + AddressSpace *dma_as = pci_device_iommu_address_space(pci_dev);
> +
> + memory_region_init_alias(&pci_dev->bus_master_enable_region,
> + OBJECT(pci_dev), "bus master",
> + dma_as->root, 0, memory_region_size(dma_as->root));
> + memory_region_set_enabled(&pci_dev->bus_master_enable_region, false);
> + address_space_init(&pci_dev->bus_master_as,
> + &pci_dev->bus_master_enable_region, pci_dev->name);
> +}
> +
> +static void pcibus_machine_done(Notifier *notifier, void *data)
> +{
> + PCIBus *bus = container_of(notifier, PCIBus, machine_done);
> + int i;
> +
> + for (i = 0; i < ARRAY_SIZE(bus->devices); ++i) {
> + if (bus->devices[i]) {
> + pci_init_bus_master(bus->devices[i]);
> + }
> + }
> +}
> +
> static void pci_bus_realize(BusState *qbus, Error **errp)
> {
> PCIBus *bus = PCI_BUS(qbus);
>
> + bus->machine_done.notify = pcibus_machine_done;
> + qemu_add_machine_init_done_notifier(&bus->machine_done);
> +
> vmstate_register(NULL, -1, &vmstate_pcibus, bus);
> }
>
> @@ -89,6 +116,8 @@ static void pci_bus_unrealize(BusState *qbus, Error **errp)
> {
> PCIBus *bus = PCI_BUS(qbus);
>
> + qemu_remove_machine_init_done_notifier(&bus->machine_done);
> +
> vmstate_unregister(NULL, &vmstate_pcibus, bus);
> }
>
> @@ -920,7 +949,6 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,
> PCIConfigReadFunc *config_read = pc->config_read;
> PCIConfigWriteFunc *config_write = pc->config_write;
> Error *local_err = NULL;
> - AddressSpace *dma_as;
> DeviceState *dev = DEVICE(pci_dev);
>
> pci_dev->bus = bus;
> @@ -961,15 +989,10 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,
>
> pci_dev->devfn = devfn;
> pci_dev->requester_id_cache = pci_req_id_cache_get(pci_dev);
> - dma_as = pci_device_iommu_address_space(pci_dev);
> -
> - memory_region_init_alias(&pci_dev->bus_master_enable_region,
> - OBJECT(pci_dev), "bus master",
> - dma_as->root, 0, memory_region_size(dma_as->root));
> - memory_region_set_enabled(&pci_dev->bus_master_enable_region, false);
> - address_space_init(&pci_dev->bus_master_as, &pci_dev->bus_master_enable_region,
> - name);
>
> + if (qdev_hotplug) {
> + pci_init_bus_master(pci_dev);
> + }
> pstrcpy(pci_dev->name, sizeof(pci_dev->name), name);
> pci_dev->irq_state = 0;
> pci_config_alloc(pci_dev);
> diff --git a/vl.c b/vl.c
> index 9bb7f4c..5cd0f2a 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -2675,6 +2675,11 @@ void qemu_add_machine_init_done_notifier(Notifier *notify)
> }
> }
>
> +void qemu_remove_machine_init_done_notifier(Notifier *notify)
> +{
> + notifier_remove(notify);
> +}
> +
> static void qemu_run_machine_init_done_notifiers(void)
> {
> notifier_list_notify(&machine_init_done_notifiers, NULL);
>
Unfortunately this patch causes a regression booting my Debian 7.8.0 and
NetBSD 7.0 test images under qemu-system-sparc64 when accessing the
CDROM device, and rather unusually causes the qemu-system-sparc64
executable itself to segfault:
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffe8453700 (LWP 21454)]
0x000000000041494a in address_space_lookup_region (d=0x0,
addr=3221225472, resolve_subpage=true) at
/home/build/src/qemu/git/qemu/exec.c:359
359 MemoryRegionSection *section = atomic_read(&d->mru_section);
(gdb) bt
#0 0x000000000041494a in address_space_lookup_region (d=0x0,
addr=3221225472, resolve_subpage=true) at
/home/build/src/qemu/git/qemu/exec.c:359
#1 0x0000000000414aa7 in address_space_translate_internal (d=0x0,
addr=3221225472, xlat=0x7fffe8451c40, plen=0x7fffe8451d10,
resolve_subpage=true) at /home/build/src/qemu/git/qemu/exec.c:390
#2 0x0000000000414c8f in address_space_translate (as=0x1961600,
addr=3221225472, xlat=0x7fffe8451d18, plen=0x7fffe8451d10,
is_write=false) at /home/build/src/qemu/git/qemu/exec.c:428
#3 0x000000000041a4be in address_space_read_full (as=0x1961600,
addr=3221225472, attrs=..., buf=0x7fffe8451f10 "\030(\226\001", len=8)
at /home/build/src/qemu/git/qemu/exec.c:2724
#4 0x000000000041a5b3 in address_space_read (len=8, buf=0x7fffe8451f10
"\030(\226\001", attrs=..., addr=3221225472, as=0x1961600) at
/home/build/src/qemu/git/qemu/include/exec/memory.h:1460
#5 address_space_rw (as=0x1961600, addr=3221225472, attrs=...,
buf=0x7fffe8451f10 "\030(\226\001", len=8, is_write=false) at
/home/build/src/qemu/git/qemu/exec.c:2739
#6 0x00000000005c71e0 in dma_memory_rw_relaxed (as=0x1961600,
addr=3221225472, buf=0x7fffe8451f10, len=8, dir=DMA_DIRECTION_TO_DEVICE)
at /home/build/src/qemu/git/qemu/include/sysemu/dma.h:87
#7 0x00000000005c7258 in dma_memory_rw (as=0x1961600, addr=3221225472,
buf=0x7fffe8451f10, len=8, dir=DMA_DIRECTION_TO_DEVICE) at
/home/build/src/qemu/git/qemu/include/sysemu/dma.h:110
#8 0x00000000005c72fa in pci_dma_rw (dev=0x19613f0, addr=3221225472,
buf=0x7fffe8451f10, len=8, dir=DMA_DIRECTION_TO_DEVICE) at
/home/build/src/qemu/git/qemu/include/hw/pci/pci.h:731
#9 0x00000000005c735a in pci_dma_read (dev=0x19613f0, addr=3221225472,
buf=0x7fffe8451f10, len=8) at
/home/build/src/qemu/git/qemu/include/hw/pci/pci.h:738
#10 0x00000000005c7980 in bmdma_rw_buf (dma=0x1962fa8, is_write=1) at
hw/ide/pci.c:139
#11 0x00000000005c4372 in ide_atapi_cmd_read_dma_cb (opaque=0x1962550,
ret=0) at hw/ide/atapi.c:413
#12 0x00000000005c7dfe in bmdma_cmd_writeb (bm=0x1962fa8, val=9) at
hw/ide/pci.c:245
#13 0x00000000005c91a9 in bmdma_write (opaque=0x1962fa8, addr=0, val=9,
size=1) at hw/ide/cmd646.c:219
#14 0x0000000000469fb8 in memory_region_write_accessor (mr=0x1963100,
addr=0, value=0x7fffe8452148, size=1, shift=0, mask=255, attrs=...) at
/home/build/src/qemu/git/qemu/memory.c:525
#15 0x000000000046a1e4 in access_with_adjusted_size (addr=0,
value=0x7fffe8452148, size=1, access_size_min=1, access_size_max=4,
access=0x469ec1 <memory_region_write_accessor>, mr=0x1963100, attrs=...)
at /home/build/src/qemu/git/qemu/memory.c:586
#16 0x000000000046d42b in memory_region_dispatch_write (mr=0x1963100,
addr=0, data=9, size=1, attrs=...) at
/home/build/src/qemu/git/qemu/memory.c:1262
#17 0x000000000041a051 in address_space_write_continue (as=0x12bb4b0,
addr=2190466908936, attrs=..., buf=0x7fffe8452323 "\t\376\001", len=1,
addr1=0, l=1, mr=0x1963100) at /home/build/src/qemu/git/qemu/exec.c:2590
#18 0x000000000041a1c3 in address_space_write (as=0x12bb4b0,
addr=2190466908936, attrs=..., buf=0x7fffe8452323 "\t\376\001", len=1)
at /home/build/src/qemu/git/qemu/exec.c:2635
#19 0x000000000041a569 in address_space_rw (as=0x12bb4b0,
addr=2190466908936, attrs=..., buf=0x7fffe8452323 "\t\376\001", len=1,
is_write=true) at /home/build/src/qemu/git/qemu/exec.c:2737
#20 0x000000000041c27d in address_space_stb (as=0x12bb4b0,
addr=2190466908936, val=9, attrs=..., result=0x0) at
/home/build/src/qemu/git/qemu/exec.c:3477
#21 0x000000000041c2f5 in stb_phys (as=0x12bb4b0, addr=2190466908936,
val=9) at /home/build/src/qemu/git/qemu/exec.c:3485
#22 0x0000000000504759 in helper_st_asi (env=0x12d57e8,
addr=2190466908936, val=9, asi=29, size=1) at
/home/build/src/qemu/git/qemu/target-sparc/ldst_helper.c:1801
#23 0x00000000405bf4b0 in code_gen_buffer ()
#24 0x0000000000420c97 in cpu_tb_exec (cpu=0x12cd570,
itb=0x7fffe8fc10c0) at /home/build/src/qemu/git/qemu/cpu-exec.c:166
#25 0x0000000000421882 in cpu_loop_exec_tb (cpu=0x12cd570,
tb=0x7fffe8fc10c0, last_tb=0x7fffe8452988, tb_exit=0x7fffe8452984,
sc=0x7fffe84529a0) at /home/build/src/qemu/git/qemu/cpu-exec.c:530
#26 0x0000000000421b40 in cpu_exec (cpu=0x12cd570) at
/home/build/src/qemu/git/qemu/cpu-exec.c:626
#27 0x0000000000451e6b in tcg_cpu_exec (cpu=0x12cd570) at
/home/build/src/qemu/git/qemu/cpus.c:1541
#28 0x0000000000451f6d in tcg_exec_all () at
/home/build/src/qemu/git/qemu/cpus.c:1574
#29 0x00000000004510b4 in qemu_tcg_cpu_thread_fn (arg=0x12cd570) at
/home/build/src/qemu/git/qemu/cpus.c:1171
#30 0x00007ffff264bb50 in start_thread (arg=<optimized out>) at
pthread_create.c:304
#31 0x00007ffff2395fbd in clone () at
../sysdeps/unix/sysv/linux/x86_64/clone.S:112
#32 0x0000000000000000 in ?? ()
(gdb)
ATB,
Mark.
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [Qemu-devel] [PULL 03/36] hw/pci: delay bus_master_enable_region initialization
2016-07-09 1:34 ` Mark Cave-Ayland
@ 2016-07-09 7:07 ` Marcel Apfelbaum
2016-07-09 9:09 ` Mark Cave-Ayland
0 siblings, 1 reply; 43+ messages in thread
From: Marcel Apfelbaum @ 2016-07-09 7:07 UTC (permalink / raw)
To: Mark Cave-Ayland, Michael S. Tsirkin, qemu-devel
Cc: Peter Maydell, Paolo Bonzini
On 07/09/2016 04:34 AM, Mark Cave-Ayland wrote:
> On 04/07/16 17:46, Michael S. Tsirkin wrote:
>
>> From: Marcel Apfelbaum <marcel@redhat.com>
>>
>> Skip bus_master_enable region creation on PCI device init
>> in order to be sure the IOMMU device (if present) would
>> be created in advance. Add this memory region at machine_done time.
>>
>> Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
>> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
>> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
>> ---
>> include/hw/pci/pci_bus.h | 2 ++
>> include/sysemu/sysemu.h | 1 +
>> hw/pci/pci.c | 41 ++++++++++++++++++++++++++++++++---------
>> vl.c | 5 +++++
>> 4 files changed, 40 insertions(+), 9 deletions(-)
>>
>> diff --git a/include/hw/pci/pci_bus.h b/include/hw/pci/pci_bus.h
>> index 403fec6..5484a9b 100644
>> --- a/include/hw/pci/pci_bus.h
>> +++ b/include/hw/pci/pci_bus.h
>> @@ -39,6 +39,8 @@ struct PCIBus {
>> Keep a count of the number of devices with raised IRQs. */
>> int nirq;
>> int *irq_count;
>> +
>> + Notifier machine_done;
>> };
>>
>> typedef struct PCIBridgeWindows PCIBridgeWindows;
>> diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
>> index 7313673..ee7c760 100644
>> --- a/include/sysemu/sysemu.h
>> +++ b/include/sysemu/sysemu.h
>> @@ -75,6 +75,7 @@ void qemu_add_exit_notifier(Notifier *notify);
>> void qemu_remove_exit_notifier(Notifier *notify);
>>
>> void qemu_add_machine_init_done_notifier(Notifier *notify);
>> +void qemu_remove_machine_init_done_notifier(Notifier *notify);
>>
>> void hmp_savevm(Monitor *mon, const QDict *qdict);
>> int load_vmstate(const char *name);
>> diff --git a/hw/pci/pci.c b/hw/pci/pci.c
>> index 4b585f4..ee385eb 100644
>> --- a/hw/pci/pci.c
>> +++ b/hw/pci/pci.c
>> @@ -78,10 +78,37 @@ static const VMStateDescription vmstate_pcibus = {
>> }
>> };
>>
>> +static void pci_init_bus_master(PCIDevice *pci_dev)
>> +{
>> + AddressSpace *dma_as = pci_device_iommu_address_space(pci_dev);
>> +
>> + memory_region_init_alias(&pci_dev->bus_master_enable_region,
>> + OBJECT(pci_dev), "bus master",
>> + dma_as->root, 0, memory_region_size(dma_as->root));
>> + memory_region_set_enabled(&pci_dev->bus_master_enable_region, false);
>> + address_space_init(&pci_dev->bus_master_as,
>> + &pci_dev->bus_master_enable_region, pci_dev->name);
>> +}
>> +
>> +static void pcibus_machine_done(Notifier *notifier, void *data)
>> +{
>> + PCIBus *bus = container_of(notifier, PCIBus, machine_done);
>> + int i;
>> +
>> + for (i = 0; i < ARRAY_SIZE(bus->devices); ++i) {
>> + if (bus->devices[i]) {
>> + pci_init_bus_master(bus->devices[i]);
>> + }
>> + }
>> +}
>> +
>> static void pci_bus_realize(BusState *qbus, Error **errp)
>> {
>> PCIBus *bus = PCI_BUS(qbus);
>>
>> + bus->machine_done.notify = pcibus_machine_done;
>> + qemu_add_machine_init_done_notifier(&bus->machine_done);
>> +
>> vmstate_register(NULL, -1, &vmstate_pcibus, bus);
>> }
>>
>> @@ -89,6 +116,8 @@ static void pci_bus_unrealize(BusState *qbus, Error **errp)
>> {
>> PCIBus *bus = PCI_BUS(qbus);
>>
>> + qemu_remove_machine_init_done_notifier(&bus->machine_done);
>> +
>> vmstate_unregister(NULL, &vmstate_pcibus, bus);
>> }
>>
>> @@ -920,7 +949,6 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,
>> PCIConfigReadFunc *config_read = pc->config_read;
>> PCIConfigWriteFunc *config_write = pc->config_write;
>> Error *local_err = NULL;
>> - AddressSpace *dma_as;
>> DeviceState *dev = DEVICE(pci_dev);
>>
>> pci_dev->bus = bus;
>> @@ -961,15 +989,10 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,
>>
>> pci_dev->devfn = devfn;
>> pci_dev->requester_id_cache = pci_req_id_cache_get(pci_dev);
>> - dma_as = pci_device_iommu_address_space(pci_dev);
>> -
>> - memory_region_init_alias(&pci_dev->bus_master_enable_region,
>> - OBJECT(pci_dev), "bus master",
>> - dma_as->root, 0, memory_region_size(dma_as->root));
>> - memory_region_set_enabled(&pci_dev->bus_master_enable_region, false);
>> - address_space_init(&pci_dev->bus_master_as, &pci_dev->bus_master_enable_region,
>> - name);
>>
>> + if (qdev_hotplug) {
>> + pci_init_bus_master(pci_dev);
>> + }
>> pstrcpy(pci_dev->name, sizeof(pci_dev->name), name);
>> pci_dev->irq_state = 0;
>> pci_config_alloc(pci_dev);
>> diff --git a/vl.c b/vl.c
>> index 9bb7f4c..5cd0f2a 100644
>> --- a/vl.c
>> +++ b/vl.c
>> @@ -2675,6 +2675,11 @@ void qemu_add_machine_init_done_notifier(Notifier *notify)
>> }
>> }
>>
>> +void qemu_remove_machine_init_done_notifier(Notifier *notify)
>> +{
>> + notifier_remove(notify);
>> +}
>> +
>> static void qemu_run_machine_init_done_notifiers(void)
>> {
>> notifier_list_notify(&machine_init_done_notifiers, NULL);
>>
>
> Unfortunately this patch causes a regression booting my Debian 7.8.0 and
> NetBSD 7.0 test images under qemu-system-sparc64 when accessing the
> CDROM device, and rather unusually causes the qemu-system-sparc64
> executable itself to segfault:
>
Hi Mark,
Thank you for finding it, can you please provide a command line and maybe one of your test images?
I'll be sure to address it.
Thanks,
Marcel
>
> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 0x7fffe8453700 (LWP 21454)]
> 0x000000000041494a in address_space_lookup_region (d=0x0,
> addr=3221225472, resolve_subpage=true) at
> /home/build/src/qemu/git/qemu/exec.c:359
> 359 MemoryRegionSection *section = atomic_read(&d->mru_section);
> (gdb) bt
> #0 0x000000000041494a in address_space_lookup_region (d=0x0,
> addr=3221225472, resolve_subpage=true) at
> /home/build/src/qemu/git/qemu/exec.c:359
> #1 0x0000000000414aa7 in address_space_translate_internal (d=0x0,
> addr=3221225472, xlat=0x7fffe8451c40, plen=0x7fffe8451d10,
> resolve_subpage=true) at /home/build/src/qemu/git/qemu/exec.c:390
> #2 0x0000000000414c8f in address_space_translate (as=0x1961600,
> addr=3221225472, xlat=0x7fffe8451d18, plen=0x7fffe8451d10,
> is_write=false) at /home/build/src/qemu/git/qemu/exec.c:428
> #3 0x000000000041a4be in address_space_read_full (as=0x1961600,
> addr=3221225472, attrs=..., buf=0x7fffe8451f10 "\030(\226\001", len=8)
> at /home/build/src/qemu/git/qemu/exec.c:2724
> #4 0x000000000041a5b3 in address_space_read (len=8, buf=0x7fffe8451f10
> "\030(\226\001", attrs=..., addr=3221225472, as=0x1961600) at
> /home/build/src/qemu/git/qemu/include/exec/memory.h:1460
> #5 address_space_rw (as=0x1961600, addr=3221225472, attrs=...,
> buf=0x7fffe8451f10 "\030(\226\001", len=8, is_write=false) at
> /home/build/src/qemu/git/qemu/exec.c:2739
> #6 0x00000000005c71e0 in dma_memory_rw_relaxed (as=0x1961600,
> addr=3221225472, buf=0x7fffe8451f10, len=8, dir=DMA_DIRECTION_TO_DEVICE)
> at /home/build/src/qemu/git/qemu/include/sysemu/dma.h:87
> #7 0x00000000005c7258 in dma_memory_rw (as=0x1961600, addr=3221225472,
> buf=0x7fffe8451f10, len=8, dir=DMA_DIRECTION_TO_DEVICE) at
> /home/build/src/qemu/git/qemu/include/sysemu/dma.h:110
> #8 0x00000000005c72fa in pci_dma_rw (dev=0x19613f0, addr=3221225472,
> buf=0x7fffe8451f10, len=8, dir=DMA_DIRECTION_TO_DEVICE) at
> /home/build/src/qemu/git/qemu/include/hw/pci/pci.h:731
> #9 0x00000000005c735a in pci_dma_read (dev=0x19613f0, addr=3221225472,
> buf=0x7fffe8451f10, len=8) at
> /home/build/src/qemu/git/qemu/include/hw/pci/pci.h:738
> #10 0x00000000005c7980 in bmdma_rw_buf (dma=0x1962fa8, is_write=1) at
> hw/ide/pci.c:139
> #11 0x00000000005c4372 in ide_atapi_cmd_read_dma_cb (opaque=0x1962550,
> ret=0) at hw/ide/atapi.c:413
> #12 0x00000000005c7dfe in bmdma_cmd_writeb (bm=0x1962fa8, val=9) at
> hw/ide/pci.c:245
> #13 0x00000000005c91a9 in bmdma_write (opaque=0x1962fa8, addr=0, val=9,
> size=1) at hw/ide/cmd646.c:219
> #14 0x0000000000469fb8 in memory_region_write_accessor (mr=0x1963100,
> addr=0, value=0x7fffe8452148, size=1, shift=0, mask=255, attrs=...) at
> /home/build/src/qemu/git/qemu/memory.c:525
> #15 0x000000000046a1e4 in access_with_adjusted_size (addr=0,
> value=0x7fffe8452148, size=1, access_size_min=1, access_size_max=4,
> access=0x469ec1 <memory_region_write_accessor>, mr=0x1963100, attrs=...)
> at /home/build/src/qemu/git/qemu/memory.c:586
> #16 0x000000000046d42b in memory_region_dispatch_write (mr=0x1963100,
> addr=0, data=9, size=1, attrs=...) at
> /home/build/src/qemu/git/qemu/memory.c:1262
> #17 0x000000000041a051 in address_space_write_continue (as=0x12bb4b0,
> addr=2190466908936, attrs=..., buf=0x7fffe8452323 "\t\376\001", len=1,
> addr1=0, l=1, mr=0x1963100) at /home/build/src/qemu/git/qemu/exec.c:2590
> #18 0x000000000041a1c3 in address_space_write (as=0x12bb4b0,
> addr=2190466908936, attrs=..., buf=0x7fffe8452323 "\t\376\001", len=1)
> at /home/build/src/qemu/git/qemu/exec.c:2635
> #19 0x000000000041a569 in address_space_rw (as=0x12bb4b0,
> addr=2190466908936, attrs=..., buf=0x7fffe8452323 "\t\376\001", len=1,
> is_write=true) at /home/build/src/qemu/git/qemu/exec.c:2737
> #20 0x000000000041c27d in address_space_stb (as=0x12bb4b0,
> addr=2190466908936, val=9, attrs=..., result=0x0) at
> /home/build/src/qemu/git/qemu/exec.c:3477
> #21 0x000000000041c2f5 in stb_phys (as=0x12bb4b0, addr=2190466908936,
> val=9) at /home/build/src/qemu/git/qemu/exec.c:3485
> #22 0x0000000000504759 in helper_st_asi (env=0x12d57e8,
> addr=2190466908936, val=9, asi=29, size=1) at
> /home/build/src/qemu/git/qemu/target-sparc/ldst_helper.c:1801
> #23 0x00000000405bf4b0 in code_gen_buffer ()
> #24 0x0000000000420c97 in cpu_tb_exec (cpu=0x12cd570,
> itb=0x7fffe8fc10c0) at /home/build/src/qemu/git/qemu/cpu-exec.c:166
> #25 0x0000000000421882 in cpu_loop_exec_tb (cpu=0x12cd570,
> tb=0x7fffe8fc10c0, last_tb=0x7fffe8452988, tb_exit=0x7fffe8452984,
> sc=0x7fffe84529a0) at /home/build/src/qemu/git/qemu/cpu-exec.c:530
> #26 0x0000000000421b40 in cpu_exec (cpu=0x12cd570) at
> /home/build/src/qemu/git/qemu/cpu-exec.c:626
> #27 0x0000000000451e6b in tcg_cpu_exec (cpu=0x12cd570) at
> /home/build/src/qemu/git/qemu/cpus.c:1541
> #28 0x0000000000451f6d in tcg_exec_all () at
> /home/build/src/qemu/git/qemu/cpus.c:1574
> #29 0x00000000004510b4 in qemu_tcg_cpu_thread_fn (arg=0x12cd570) at
> /home/build/src/qemu/git/qemu/cpus.c:1171
> #30 0x00007ffff264bb50 in start_thread (arg=<optimized out>) at
> pthread_create.c:304
> #31 0x00007ffff2395fbd in clone () at
> ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
> #32 0x0000000000000000 in ?? ()
> (gdb)
>
>
>
> ATB,
>
> Mark.
>
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [Qemu-devel] [PULL 03/36] hw/pci: delay bus_master_enable_region initialization
2016-07-09 7:07 ` Marcel Apfelbaum
@ 2016-07-09 9:09 ` Mark Cave-Ayland
0 siblings, 0 replies; 43+ messages in thread
From: Mark Cave-Ayland @ 2016-07-09 9:09 UTC (permalink / raw)
To: Marcel Apfelbaum, Michael S. Tsirkin, qemu-devel
Cc: Peter Maydell, Paolo Bonzini
On 09/07/16 08:07, Marcel Apfelbaum wrote:
> On 07/09/2016 04:34 AM, Mark Cave-Ayland wrote:
>> On 04/07/16 17:46, Michael S. Tsirkin wrote:
>>
>>> From: Marcel Apfelbaum <marcel@redhat.com>
>>>
>>> Skip bus_master_enable region creation on PCI device init
>>> in order to be sure the IOMMU device (if present) would
>>> be created in advance. Add this memory region at machine_done time.
>>>
>>> Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
>>> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
>>> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
>>> ---
>>> include/hw/pci/pci_bus.h | 2 ++
>>> include/sysemu/sysemu.h | 1 +
>>> hw/pci/pci.c | 41
>>> ++++++++++++++++++++++++++++++++---------
>>> vl.c | 5 +++++
>>> 4 files changed, 40 insertions(+), 9 deletions(-)
>>>
>>> diff --git a/include/hw/pci/pci_bus.h b/include/hw/pci/pci_bus.h
>>> index 403fec6..5484a9b 100644
>>> --- a/include/hw/pci/pci_bus.h
>>> +++ b/include/hw/pci/pci_bus.h
>>> @@ -39,6 +39,8 @@ struct PCIBus {
>>> Keep a count of the number of devices with raised IRQs. */
>>> int nirq;
>>> int *irq_count;
>>> +
>>> + Notifier machine_done;
>>> };
>>>
>>> typedef struct PCIBridgeWindows PCIBridgeWindows;
>>> diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
>>> index 7313673..ee7c760 100644
>>> --- a/include/sysemu/sysemu.h
>>> +++ b/include/sysemu/sysemu.h
>>> @@ -75,6 +75,7 @@ void qemu_add_exit_notifier(Notifier *notify);
>>> void qemu_remove_exit_notifier(Notifier *notify);
>>>
>>> void qemu_add_machine_init_done_notifier(Notifier *notify);
>>> +void qemu_remove_machine_init_done_notifier(Notifier *notify);
>>>
>>> void hmp_savevm(Monitor *mon, const QDict *qdict);
>>> int load_vmstate(const char *name);
>>> diff --git a/hw/pci/pci.c b/hw/pci/pci.c
>>> index 4b585f4..ee385eb 100644
>>> --- a/hw/pci/pci.c
>>> +++ b/hw/pci/pci.c
>>> @@ -78,10 +78,37 @@ static const VMStateDescription vmstate_pcibus = {
>>> }
>>> };
>>>
>>> +static void pci_init_bus_master(PCIDevice *pci_dev)
>>> +{
>>> + AddressSpace *dma_as = pci_device_iommu_address_space(pci_dev);
>>> +
>>> + memory_region_init_alias(&pci_dev->bus_master_enable_region,
>>> + OBJECT(pci_dev), "bus master",
>>> + dma_as->root, 0,
>>> memory_region_size(dma_as->root));
>>> + memory_region_set_enabled(&pci_dev->bus_master_enable_region,
>>> false);
>>> + address_space_init(&pci_dev->bus_master_as,
>>> + &pci_dev->bus_master_enable_region,
>>> pci_dev->name);
>>> +}
>>> +
>>> +static void pcibus_machine_done(Notifier *notifier, void *data)
>>> +{
>>> + PCIBus *bus = container_of(notifier, PCIBus, machine_done);
>>> + int i;
>>> +
>>> + for (i = 0; i < ARRAY_SIZE(bus->devices); ++i) {
>>> + if (bus->devices[i]) {
>>> + pci_init_bus_master(bus->devices[i]);
>>> + }
>>> + }
>>> +}
>>> +
>>> static void pci_bus_realize(BusState *qbus, Error **errp)
>>> {
>>> PCIBus *bus = PCI_BUS(qbus);
>>>
>>> + bus->machine_done.notify = pcibus_machine_done;
>>> + qemu_add_machine_init_done_notifier(&bus->machine_done);
>>> +
>>> vmstate_register(NULL, -1, &vmstate_pcibus, bus);
>>> }
>>>
>>> @@ -89,6 +116,8 @@ static void pci_bus_unrealize(BusState *qbus,
>>> Error **errp)
>>> {
>>> PCIBus *bus = PCI_BUS(qbus);
>>>
>>> + qemu_remove_machine_init_done_notifier(&bus->machine_done);
>>> +
>>> vmstate_unregister(NULL, &vmstate_pcibus, bus);
>>> }
>>>
>>> @@ -920,7 +949,6 @@ static PCIDevice
>>> *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,
>>> PCIConfigReadFunc *config_read = pc->config_read;
>>> PCIConfigWriteFunc *config_write = pc->config_write;
>>> Error *local_err = NULL;
>>> - AddressSpace *dma_as;
>>> DeviceState *dev = DEVICE(pci_dev);
>>>
>>> pci_dev->bus = bus;
>>> @@ -961,15 +989,10 @@ static PCIDevice
>>> *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,
>>>
>>> pci_dev->devfn = devfn;
>>> pci_dev->requester_id_cache = pci_req_id_cache_get(pci_dev);
>>> - dma_as = pci_device_iommu_address_space(pci_dev);
>>> -
>>> - memory_region_init_alias(&pci_dev->bus_master_enable_region,
>>> - OBJECT(pci_dev), "bus master",
>>> - dma_as->root, 0,
>>> memory_region_size(dma_as->root));
>>> - memory_region_set_enabled(&pci_dev->bus_master_enable_region,
>>> false);
>>> - address_space_init(&pci_dev->bus_master_as,
>>> &pci_dev->bus_master_enable_region,
>>> - name);
>>>
>>> + if (qdev_hotplug) {
>>> + pci_init_bus_master(pci_dev);
>>> + }
>>> pstrcpy(pci_dev->name, sizeof(pci_dev->name), name);
>>> pci_dev->irq_state = 0;
>>> pci_config_alloc(pci_dev);
>>> diff --git a/vl.c b/vl.c
>>> index 9bb7f4c..5cd0f2a 100644
>>> --- a/vl.c
>>> +++ b/vl.c
>>> @@ -2675,6 +2675,11 @@ void
>>> qemu_add_machine_init_done_notifier(Notifier *notify)
>>> }
>>> }
>>>
>>> +void qemu_remove_machine_init_done_notifier(Notifier *notify)
>>> +{
>>> + notifier_remove(notify);
>>> +}
>>> +
>>> static void qemu_run_machine_init_done_notifiers(void)
>>> {
>>> notifier_list_notify(&machine_init_done_notifiers, NULL);
>>>
>>
>> Unfortunately this patch causes a regression booting my Debian 7.8.0 and
>> NetBSD 7.0 test images under qemu-system-sparc64 when accessing the
>> CDROM device, and rather unusually causes the qemu-system-sparc64
>> executable itself to segfault:
>>
>
> Hi Mark,
> Thank you for finding it, can you please provide a command line and
> maybe one of your test images?
> I'll be sure to address it.
>
> Thanks,
> Marcel
Hi Marcel,
The failure was easy to reproduce with my NetBSD 7.0 image using the
following command line:
./qemu-system-sparc64 -cdrom NetBSD-7.0-sparc64.iso -boot d -nographic
The segfault occurs just after the CDROM is accessed.
Many thanks,
Mark.
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [Qemu-devel] [PULL 03/36] hw/pci: delay bus_master_enable_region initialization
2016-07-04 16:46 ` [Qemu-devel] [PULL 03/36] hw/pci: delay bus_master_enable_region initialization Michael S. Tsirkin
2016-07-09 1:34 ` Mark Cave-Ayland
@ 2016-07-11 14:42 ` Leon Alrae
2016-07-11 15:18 ` Marcel Apfelbaum
1 sibling, 1 reply; 43+ messages in thread
From: Leon Alrae @ 2016-07-11 14:42 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: qemu-devel, Marcel Apfelbaum, Peter Maydell, Paolo Bonzini
Hi,
This commit causes regressions in my MIPS tests. QEMU segfaults when
booting Linux on Malta board; this can be easily reproduced with
Aurelien's Debian images:
wget https://people.debian.org/~aurel32/qemu/mipsel/vmlinux-3.2.0-4-5kc-malta
wget https://people.debian.org/~aurel32/qemu/mipsel/debian_wheezy_mipsel_standard.qcow2
qemu-system-mips64el -M malta -kernel vmlinux-3.2.0-4-5kc-malta -hda debian_wheezy_mipsel_standard.qcow2 -append "root=/dev/sda1 console=ttyS0" -nographic
...
[ 1.468000] ata2.00: ATAPI: QEMU DVD-ROM, 2.5+, max UDMA/100
[ 1.476000] ata1.00: ATA-7: QEMU HARDDISK, 2.5+, max UDMA/100
[ 1.476000] ata1.00: 52428800 sectors, multi 16: LBA48
[ 1.480000] ata2.00: configured for UDMA/33
[ 1.484000] ata1.00: configured for UDMA/33
[ 1.536000] scsi 0:0:0:0: Direct-Access ATA QEMU HARDDISK 2.5+ PQ: 0 ANSI: 5
[ 1.552000] sd 0:0:0:0: [sda] 52428800 512-byte logical blocks: (26.8 GB/25.0 GiB)
[ 1.568000] scsi 1:0:0:0: CD-ROM QEMU QEMU DVD-ROM 2.5+ PQ: 0 ANSI: 5
[ 1.576000] sd 0:0:0:0: [sda] Write Protect is off
[ 1.580000] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffec79e700 (LWP 29679)]
0x00007ffff792f806 in address_space_lookup_region (d=0x0, addr=12582912, resolve_subpage=true) at /user/lea/dev/qemu/exec.c:359
359 MemoryRegionSection *section = atomic_read(&d->mru_section);
(gdb) bt
#0 0x00007ffff792f806 in address_space_lookup_region (d=0x0, addr=12582912, resolve_subpage=true) at /user/lea/dev/qemu/exec.c:359
#1 0x00007ffff792f95e in address_space_translate_internal (d=0x0, addr=12582912, xlat=0x7fffec79ca30, plen=0x7fffec79cb18, resolve_subpage=true) at /user/lea/dev/qemu/exec.c:390
#2 0x00007ffff792fb5a in address_space_translate (as=0x7ffff8bc1ef0, addr=12582912, xlat=0x7fffec79cb10, plen=0x7fffec79cb18, is_write=false) at /user/lea/dev/qemu/exec.c:428
#3 0x00007ffff7935720 in address_space_read_full (as=0x7ffff8bc1ef0, addr=12582912, attrs=..., buf=0x7fffec79cd60 "\260^\324\370", <incomplete sequence \330>, len=8) at /user/lea/dev/qemu/exec.c:2724
#4 0x00007ffff7935821 in address_space_read (as=0x7ffff8bc1ef0, addr=12582912, attrs=..., buf=0x7fffec79cd60 "\260^\324\370", <incomplete sequence \330>, len=8, is_write=false) at /user/lea/dev/qemu/include/exec/memory.h:1476
#5 address_space_rw (as=0x7ffff8bc1ef0, addr=12582912, attrs=..., buf=0x7fffec79cd60 "\260^\324\370", <incomplete sequence \330>, len=8, is_write=false) at /user/lea/dev/qemu/exec.c:2739
#6 0x00007ffff7baf9a7 in dma_memory_rw_relaxed (as=0x7ffff8bc1ef0, addr=12582912, buf=0x7fffec79cd60, len=8, dir=DMA_DIRECTION_TO_DEVICE) at /user/lea/dev/qemu/include/sysemu/dma.h:87
#7 0x00007ffff7bafa28 in dma_memory_rw (as=0x7ffff8bc1ef0, addr=12582912, buf=0x7fffec79cd60, len=8, dir=DMA_DIRECTION_TO_DEVICE) at /user/lea/dev/qemu/include/sysemu/dma.h:110
#8 0x00007ffff7bafad3 in pci_dma_rw (dev=0x7ffff8bc1ce0, addr=12582912, buf=0x7fffec79cd60, len=8, dir=DMA_DIRECTION_TO_DEVICE) at /user/lea/dev/qemu/include/hw/pci/pci.h:731
#9 0x00007ffff7bafb3c in pci_dma_read (dev=0x7ffff8bc1ce0, addr=12582912, buf=0x7fffec79cd60, len=8) at /user/lea/dev/qemu/include/hw/pci/pci.h:738
#10 0x00007ffff7baff6d in bmdma_prepare_buf (dma=0x7ffff8bc3620, limit=4096) at /user/lea/dev/qemu/hw/ide/pci.c:85
#11 0x00007ffff7ba66bc in ide_dma_cb (opaque=0x7ffff8bc25e8, ret=0) at /user/lea/dev/qemu/hw/ide/core.c:844
#12 0x00007ffff7bb0615 in bmdma_cmd_writeb (bm=0x7ffff8bc3620, val=9) at /user/lea/dev/qemu/hw/ide/pci.c:245
#13 0x00007ffff7bb1408 in bmdma_write (opaque=0x7ffff8bc3620, addr=0, val=9, size=1) at /user/lea/dev/qemu/hw/ide/piix.c:77
#14 0x00007ffff7988548 in memory_region_write_accessor (mr=0x7ffff8bc3778, addr=0, value=0x7fffec79cfd8, size=1, shift=0, mask=255, attrs=...) at /user/lea/dev/qemu/memory.c:525
#15 0x00007ffff79887dd in access_with_adjusted_size (addr=0, value=0x7fffec79cfd8, size=1, access_size_min=1, access_size_max=4, access=0x7ffff798843e <memory_region_write_accessor>, mr=0x7ffff8bc3778, attrs=...) at /user/lea/dev/qemu/memory.c:591
#16 0x00007ffff798bc6e in memory_region_dispatch_write (mr=0x7ffff8bc3778, addr=0, data=9, size=1, attrs=...) at /user/lea/dev/qemu/memory.c:1262
#17 0x00007ffff7935294 in address_space_write_continue (as=0x7ffff8921a90, addr=402657344, attrs=..., buf=0x7fffec79d170 "\t\345y\354\377\177", len=1, addr1=0, l=1, mr=0x7ffff8bc3778) at /user/lea/dev/qemu/exec.c:2590
#18 0x00007ffff793540d in address_space_write (as=0x7ffff8921a90, addr=402657344, attrs=..., buf=0x7fffec79d170 "\t\345y\354\377\177", len=1) at /user/lea/dev/qemu/exec.c:2635
#19 0x00007ffff79344c0 in subpage_write (opaque=0x7fffd4569730, addr=64, value=9, len=1, attrs=...) at /user/lea/dev/qemu/exec.c:2221
#20 0x00007ffff7988678 in memory_region_write_with_attrs_accessor (mr=0x7fffd4569730, addr=64, value=0x7fffec79d2b8, size=1, shift=0, mask=255, attrs=...) at /user/lea/dev/qemu/memory.c:551
#21 0x00007ffff79887dd in access_with_adjusted_size (addr=64, value=0x7fffec79d2b8, size=1, access_size_min=1, access_size_max=8, access=0x7ffff7988568 <memory_region_write_with_attrs_accessor>, mr=0x7fffd4569730, attrs=...) at /user/lea/dev/qemu/memory.c:591
#22 0x00007ffff798bcc9 in memory_region_dispatch_write (mr=0x7fffd4569730, addr=64, data=9, size=1, attrs=...) at /user/lea/dev/qemu/memory.c:1269
#23 0x00007ffff7993676 in io_writeb (env=0x7ffff8941978, iotlbentry=0x7ffff894a0e8, val=9 '\t', addr=10376293541864280128, retaddr=140737194805689) at /user/lea/dev/qemu/softmmu_template.h:349
#24 0x00007ffff7993ae0 in helper_ret_stb_mmu (env=0x7ffff8941978, addr=10376293541864280128, val=9 '\t', oi=0, retaddr=140737194805689) at /user/lea/dev/qemu/softmmu_template.h:390
#25 0x00007fffee80c9bb in code_gen_buffer ()
#26 0x00007ffff793c093 in cpu_tb_exec (cpu=0x7ffff8939700, itb=0x7fffedaf4ee0) at /user/lea/dev/qemu/cpu-exec.c:166
#27 0x00007ffff793ccd1 in cpu_loop_exec_tb (cpu=0x7ffff8939700, tb=0x7fffedaf4ee0, last_tb=0x7fffec79d9e0, tb_exit=0x7fffec79d9fc, sc=0x7fffec79d9c0) at /user/lea/dev/qemu/cpu-exec.c:530
#28 0x00007ffff793cf98 in cpu_exec (cpu=0x7ffff8939700) at /user/lea/dev/qemu/cpu-exec.c:626
#29 0x00007ffff796f949 in tcg_cpu_exec (cpu=0x7ffff8939700) at /user/lea/dev/qemu/cpus.c:1541
#30 0x00007ffff796fa52 in tcg_exec_all () at /user/lea/dev/qemu/cpus.c:1574
#31 0x00007ffff796eb15 in qemu_tcg_cpu_thread_fn (arg=0x7ffff8939700) at /user/lea/dev/qemu/cpus.c:1171
#32 0x00007ffff30ce9d1 in start_thread () from /lib64/libpthread.so.0
#33 0x00007ffff2e1b86d in clone () from /lib64/libc.so.6
Regards,
Leon
On Mon, Jul 04, 2016 at 07:46:15PM +0300, Michael S. Tsirkin wrote:
> From: Marcel Apfelbaum <marcel@redhat.com>
>
> Skip bus_master_enable region creation on PCI device init
> in order to be sure the IOMMU device (if present) would
> be created in advance. Add this memory region at machine_done time.
>
> Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> include/hw/pci/pci_bus.h | 2 ++
> include/sysemu/sysemu.h | 1 +
> hw/pci/pci.c | 41 ++++++++++++++++++++++++++++++++---------
> vl.c | 5 +++++
> 4 files changed, 40 insertions(+), 9 deletions(-)
>
> diff --git a/include/hw/pci/pci_bus.h b/include/hw/pci/pci_bus.h
> index 403fec6..5484a9b 100644
> --- a/include/hw/pci/pci_bus.h
> +++ b/include/hw/pci/pci_bus.h
> @@ -39,6 +39,8 @@ struct PCIBus {
> Keep a count of the number of devices with raised IRQs. */
> int nirq;
> int *irq_count;
> +
> + Notifier machine_done;
> };
>
> typedef struct PCIBridgeWindows PCIBridgeWindows;
> diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
> index 7313673..ee7c760 100644
> --- a/include/sysemu/sysemu.h
> +++ b/include/sysemu/sysemu.h
> @@ -75,6 +75,7 @@ void qemu_add_exit_notifier(Notifier *notify);
> void qemu_remove_exit_notifier(Notifier *notify);
>
> void qemu_add_machine_init_done_notifier(Notifier *notify);
> +void qemu_remove_machine_init_done_notifier(Notifier *notify);
>
> void hmp_savevm(Monitor *mon, const QDict *qdict);
> int load_vmstate(const char *name);
> diff --git a/hw/pci/pci.c b/hw/pci/pci.c
> index 4b585f4..ee385eb 100644
> --- a/hw/pci/pci.c
> +++ b/hw/pci/pci.c
> @@ -78,10 +78,37 @@ static const VMStateDescription vmstate_pcibus = {
> }
> };
>
> +static void pci_init_bus_master(PCIDevice *pci_dev)
> +{
> + AddressSpace *dma_as = pci_device_iommu_address_space(pci_dev);
> +
> + memory_region_init_alias(&pci_dev->bus_master_enable_region,
> + OBJECT(pci_dev), "bus master",
> + dma_as->root, 0, memory_region_size(dma_as->root));
> + memory_region_set_enabled(&pci_dev->bus_master_enable_region, false);
> + address_space_init(&pci_dev->bus_master_as,
> + &pci_dev->bus_master_enable_region, pci_dev->name);
> +}
> +
> +static void pcibus_machine_done(Notifier *notifier, void *data)
> +{
> + PCIBus *bus = container_of(notifier, PCIBus, machine_done);
> + int i;
> +
> + for (i = 0; i < ARRAY_SIZE(bus->devices); ++i) {
> + if (bus->devices[i]) {
> + pci_init_bus_master(bus->devices[i]);
> + }
> + }
> +}
> +
> static void pci_bus_realize(BusState *qbus, Error **errp)
> {
> PCIBus *bus = PCI_BUS(qbus);
>
> + bus->machine_done.notify = pcibus_machine_done;
> + qemu_add_machine_init_done_notifier(&bus->machine_done);
> +
> vmstate_register(NULL, -1, &vmstate_pcibus, bus);
> }
>
> @@ -89,6 +116,8 @@ static void pci_bus_unrealize(BusState *qbus, Error **errp)
> {
> PCIBus *bus = PCI_BUS(qbus);
>
> + qemu_remove_machine_init_done_notifier(&bus->machine_done);
> +
> vmstate_unregister(NULL, &vmstate_pcibus, bus);
> }
>
> @@ -920,7 +949,6 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,
> PCIConfigReadFunc *config_read = pc->config_read;
> PCIConfigWriteFunc *config_write = pc->config_write;
> Error *local_err = NULL;
> - AddressSpace *dma_as;
> DeviceState *dev = DEVICE(pci_dev);
>
> pci_dev->bus = bus;
> @@ -961,15 +989,10 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,
>
> pci_dev->devfn = devfn;
> pci_dev->requester_id_cache = pci_req_id_cache_get(pci_dev);
> - dma_as = pci_device_iommu_address_space(pci_dev);
> -
> - memory_region_init_alias(&pci_dev->bus_master_enable_region,
> - OBJECT(pci_dev), "bus master",
> - dma_as->root, 0, memory_region_size(dma_as->root));
> - memory_region_set_enabled(&pci_dev->bus_master_enable_region, false);
> - address_space_init(&pci_dev->bus_master_as, &pci_dev->bus_master_enable_region,
> - name);
>
> + if (qdev_hotplug) {
> + pci_init_bus_master(pci_dev);
> + }
> pstrcpy(pci_dev->name, sizeof(pci_dev->name), name);
> pci_dev->irq_state = 0;
> pci_config_alloc(pci_dev);
> diff --git a/vl.c b/vl.c
> index 9bb7f4c..5cd0f2a 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -2675,6 +2675,11 @@ void qemu_add_machine_init_done_notifier(Notifier *notify)
> }
> }
>
> +void qemu_remove_machine_init_done_notifier(Notifier *notify)
> +{
> + notifier_remove(notify);
> +}
> +
> static void qemu_run_machine_init_done_notifiers(void)
> {
> notifier_list_notify(&machine_init_done_notifiers, NULL);
> --
> MST
>
>
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [Qemu-devel] [PULL 03/36] hw/pci: delay bus_master_enable_region initialization
2016-07-11 14:42 ` Leon Alrae
@ 2016-07-11 15:18 ` Marcel Apfelbaum
2016-07-11 18:41 ` Mark Cave-Ayland
0 siblings, 1 reply; 43+ messages in thread
From: Marcel Apfelbaum @ 2016-07-11 15:18 UTC (permalink / raw)
To: Leon Alrae, Michael S. Tsirkin; +Cc: qemu-devel, Peter Maydell, Paolo Bonzini
On 07/11/2016 05:42 PM, Leon Alrae wrote:
> Hi,
>
> This commit causes regressions in my MIPS tests. QEMU segfaults when
> booting Linux on Malta board;
Hi Leon,
Is a good thing you caught it in the pull request, thanks!
Is a pity we don't have a way to run sanity tests on all archs (beyond make check)
this can be easily reproduced with
> Aurelien's Debian images:
>
> wget https://people.debian.org/~aurel32/qemu/mipsel/vmlinux-3.2.0-4-5kc-malta
> wget https://people.debian.org/~aurel32/qemu/mipsel/debian_wheezy_mipsel_standard.qcow2
> qemu-system-mips64el -M malta -kernel vmlinux-3.2.0-4-5kc-malta -hda debian_wheezy_mipsel_standard.qcow2 -append "root=/dev/sda1 console=ttyS0" -nographic
>
I'll reproduce and handle it, thanks!
Marcel
> ...
> [ 1.468000] ata2.00: ATAPI: QEMU DVD-ROM, 2.5+, max UDMA/100
> [ 1.476000] ata1.00: ATA-7: QEMU HARDDISK, 2.5+, max UDMA/100
> [ 1.476000] ata1.00: 52428800 sectors, multi 16: LBA48
> [ 1.480000] ata2.00: configured for UDMA/33
> [ 1.484000] ata1.00: configured for UDMA/33
> [ 1.536000] scsi 0:0:0:0: Direct-Access ATA QEMU HARDDISK 2.5+ PQ: 0 ANSI: 5
> [ 1.552000] sd 0:0:0:0: [sda] 52428800 512-byte logical blocks: (26.8 GB/25.0 GiB)
> [ 1.568000] scsi 1:0:0:0: CD-ROM QEMU QEMU DVD-ROM 2.5+ PQ: 0 ANSI: 5
> [ 1.576000] sd 0:0:0:0: [sda] Write Protect is off
> [ 1.580000] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
>
> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 0x7fffec79e700 (LWP 29679)]
> 0x00007ffff792f806 in address_space_lookup_region (d=0x0, addr=12582912, resolve_subpage=true) at /user/lea/dev/qemu/exec.c:359
> 359 MemoryRegionSection *section = atomic_read(&d->mru_section);
> (gdb) bt
> #0 0x00007ffff792f806 in address_space_lookup_region (d=0x0, addr=12582912, resolve_subpage=true) at /user/lea/dev/qemu/exec.c:359
> #1 0x00007ffff792f95e in address_space_translate_internal (d=0x0, addr=12582912, xlat=0x7fffec79ca30, plen=0x7fffec79cb18, resolve_subpage=true) at /user/lea/dev/qemu/exec.c:390
> #2 0x00007ffff792fb5a in address_space_translate (as=0x7ffff8bc1ef0, addr=12582912, xlat=0x7fffec79cb10, plen=0x7fffec79cb18, is_write=false) at /user/lea/dev/qemu/exec.c:428
> #3 0x00007ffff7935720 in address_space_read_full (as=0x7ffff8bc1ef0, addr=12582912, attrs=..., buf=0x7fffec79cd60 "\260^\324\370", <incomplete sequence \330>, len=8) at /user/lea/dev/qemu/exec.c:2724
> #4 0x00007ffff7935821 in address_space_read (as=0x7ffff8bc1ef0, addr=12582912, attrs=..., buf=0x7fffec79cd60 "\260^\324\370", <incomplete sequence \330>, len=8, is_write=false) at /user/lea/dev/qemu/include/exec/memory.h:1476
> #5 address_space_rw (as=0x7ffff8bc1ef0, addr=12582912, attrs=..., buf=0x7fffec79cd60 "\260^\324\370", <incomplete sequence \330>, len=8, is_write=false) at /user/lea/dev/qemu/exec.c:2739
> #6 0x00007ffff7baf9a7 in dma_memory_rw_relaxed (as=0x7ffff8bc1ef0, addr=12582912, buf=0x7fffec79cd60, len=8, dir=DMA_DIRECTION_TO_DEVICE) at /user/lea/dev/qemu/include/sysemu/dma.h:87
> #7 0x00007ffff7bafa28 in dma_memory_rw (as=0x7ffff8bc1ef0, addr=12582912, buf=0x7fffec79cd60, len=8, dir=DMA_DIRECTION_TO_DEVICE) at /user/lea/dev/qemu/include/sysemu/dma.h:110
> #8 0x00007ffff7bafad3 in pci_dma_rw (dev=0x7ffff8bc1ce0, addr=12582912, buf=0x7fffec79cd60, len=8, dir=DMA_DIRECTION_TO_DEVICE) at /user/lea/dev/qemu/include/hw/pci/pci.h:731
> #9 0x00007ffff7bafb3c in pci_dma_read (dev=0x7ffff8bc1ce0, addr=12582912, buf=0x7fffec79cd60, len=8) at /user/lea/dev/qemu/include/hw/pci/pci.h:738
> #10 0x00007ffff7baff6d in bmdma_prepare_buf (dma=0x7ffff8bc3620, limit=4096) at /user/lea/dev/qemu/hw/ide/pci.c:85
> #11 0x00007ffff7ba66bc in ide_dma_cb (opaque=0x7ffff8bc25e8, ret=0) at /user/lea/dev/qemu/hw/ide/core.c:844
> #12 0x00007ffff7bb0615 in bmdma_cmd_writeb (bm=0x7ffff8bc3620, val=9) at /user/lea/dev/qemu/hw/ide/pci.c:245
> #13 0x00007ffff7bb1408 in bmdma_write (opaque=0x7ffff8bc3620, addr=0, val=9, size=1) at /user/lea/dev/qemu/hw/ide/piix.c:77
> #14 0x00007ffff7988548 in memory_region_write_accessor (mr=0x7ffff8bc3778, addr=0, value=0x7fffec79cfd8, size=1, shift=0, mask=255, attrs=...) at /user/lea/dev/qemu/memory.c:525
> #15 0x00007ffff79887dd in access_with_adjusted_size (addr=0, value=0x7fffec79cfd8, size=1, access_size_min=1, access_size_max=4, access=0x7ffff798843e <memory_region_write_accessor>, mr=0x7ffff8bc3778, attrs=...) at /user/lea/dev/qemu/memory.c:591
> #16 0x00007ffff798bc6e in memory_region_dispatch_write (mr=0x7ffff8bc3778, addr=0, data=9, size=1, attrs=...) at /user/lea/dev/qemu/memory.c:1262
> #17 0x00007ffff7935294 in address_space_write_continue (as=0x7ffff8921a90, addr=402657344, attrs=..., buf=0x7fffec79d170 "\t\345y\354\377\177", len=1, addr1=0, l=1, mr=0x7ffff8bc3778) at /user/lea/dev/qemu/exec.c:2590
> #18 0x00007ffff793540d in address_space_write (as=0x7ffff8921a90, addr=402657344, attrs=..., buf=0x7fffec79d170 "\t\345y\354\377\177", len=1) at /user/lea/dev/qemu/exec.c:2635
> #19 0x00007ffff79344c0 in subpage_write (opaque=0x7fffd4569730, addr=64, value=9, len=1, attrs=...) at /user/lea/dev/qemu/exec.c:2221
> #20 0x00007ffff7988678 in memory_region_write_with_attrs_accessor (mr=0x7fffd4569730, addr=64, value=0x7fffec79d2b8, size=1, shift=0, mask=255, attrs=...) at /user/lea/dev/qemu/memory.c:551
> #21 0x00007ffff79887dd in access_with_adjusted_size (addr=64, value=0x7fffec79d2b8, size=1, access_size_min=1, access_size_max=8, access=0x7ffff7988568 <memory_region_write_with_attrs_accessor>, mr=0x7fffd4569730, attrs=...) at /user/lea/dev/qemu/memory.c:591
> #22 0x00007ffff798bcc9 in memory_region_dispatch_write (mr=0x7fffd4569730, addr=64, data=9, size=1, attrs=...) at /user/lea/dev/qemu/memory.c:1269
> #23 0x00007ffff7993676 in io_writeb (env=0x7ffff8941978, iotlbentry=0x7ffff894a0e8, val=9 '\t', addr=10376293541864280128, retaddr=140737194805689) at /user/lea/dev/qemu/softmmu_template.h:349
> #24 0x00007ffff7993ae0 in helper_ret_stb_mmu (env=0x7ffff8941978, addr=10376293541864280128, val=9 '\t', oi=0, retaddr=140737194805689) at /user/lea/dev/qemu/softmmu_template.h:390
> #25 0x00007fffee80c9bb in code_gen_buffer ()
> #26 0x00007ffff793c093 in cpu_tb_exec (cpu=0x7ffff8939700, itb=0x7fffedaf4ee0) at /user/lea/dev/qemu/cpu-exec.c:166
> #27 0x00007ffff793ccd1 in cpu_loop_exec_tb (cpu=0x7ffff8939700, tb=0x7fffedaf4ee0, last_tb=0x7fffec79d9e0, tb_exit=0x7fffec79d9fc, sc=0x7fffec79d9c0) at /user/lea/dev/qemu/cpu-exec.c:530
> #28 0x00007ffff793cf98 in cpu_exec (cpu=0x7ffff8939700) at /user/lea/dev/qemu/cpu-exec.c:626
> #29 0x00007ffff796f949 in tcg_cpu_exec (cpu=0x7ffff8939700) at /user/lea/dev/qemu/cpus.c:1541
> #30 0x00007ffff796fa52 in tcg_exec_all () at /user/lea/dev/qemu/cpus.c:1574
> #31 0x00007ffff796eb15 in qemu_tcg_cpu_thread_fn (arg=0x7ffff8939700) at /user/lea/dev/qemu/cpus.c:1171
> #32 0x00007ffff30ce9d1 in start_thread () from /lib64/libpthread.so.0
> #33 0x00007ffff2e1b86d in clone () from /lib64/libc.so.6
>
> Regards,
> Leon
>
> On Mon, Jul 04, 2016 at 07:46:15PM +0300, Michael S. Tsirkin wrote:
>> From: Marcel Apfelbaum <marcel@redhat.com>
>>
>> Skip bus_master_enable region creation on PCI device init
>> in order to be sure the IOMMU device (if present) would
>> be created in advance. Add this memory region at machine_done time.
>>
>> Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
>> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
>> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
>> ---
>> include/hw/pci/pci_bus.h | 2 ++
>> include/sysemu/sysemu.h | 1 +
>> hw/pci/pci.c | 41 ++++++++++++++++++++++++++++++++---------
>> vl.c | 5 +++++
>> 4 files changed, 40 insertions(+), 9 deletions(-)
>>
>> diff --git a/include/hw/pci/pci_bus.h b/include/hw/pci/pci_bus.h
>> index 403fec6..5484a9b 100644
>> --- a/include/hw/pci/pci_bus.h
>> +++ b/include/hw/pci/pci_bus.h
>> @@ -39,6 +39,8 @@ struct PCIBus {
>> Keep a count of the number of devices with raised IRQs. */
>> int nirq;
>> int *irq_count;
>> +
>> + Notifier machine_done;
>> };
>>
>> typedef struct PCIBridgeWindows PCIBridgeWindows;
>> diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
>> index 7313673..ee7c760 100644
>> --- a/include/sysemu/sysemu.h
>> +++ b/include/sysemu/sysemu.h
>> @@ -75,6 +75,7 @@ void qemu_add_exit_notifier(Notifier *notify);
>> void qemu_remove_exit_notifier(Notifier *notify);
>>
>> void qemu_add_machine_init_done_notifier(Notifier *notify);
>> +void qemu_remove_machine_init_done_notifier(Notifier *notify);
>>
>> void hmp_savevm(Monitor *mon, const QDict *qdict);
>> int load_vmstate(const char *name);
>> diff --git a/hw/pci/pci.c b/hw/pci/pci.c
>> index 4b585f4..ee385eb 100644
>> --- a/hw/pci/pci.c
>> +++ b/hw/pci/pci.c
>> @@ -78,10 +78,37 @@ static const VMStateDescription vmstate_pcibus = {
>> }
>> };
>>
>> +static void pci_init_bus_master(PCIDevice *pci_dev)
>> +{
>> + AddressSpace *dma_as = pci_device_iommu_address_space(pci_dev);
>> +
>> + memory_region_init_alias(&pci_dev->bus_master_enable_region,
>> + OBJECT(pci_dev), "bus master",
>> + dma_as->root, 0, memory_region_size(dma_as->root));
>> + memory_region_set_enabled(&pci_dev->bus_master_enable_region, false);
>> + address_space_init(&pci_dev->bus_master_as,
>> + &pci_dev->bus_master_enable_region, pci_dev->name);
>> +}
>> +
>> +static void pcibus_machine_done(Notifier *notifier, void *data)
>> +{
>> + PCIBus *bus = container_of(notifier, PCIBus, machine_done);
>> + int i;
>> +
>> + for (i = 0; i < ARRAY_SIZE(bus->devices); ++i) {
>> + if (bus->devices[i]) {
>> + pci_init_bus_master(bus->devices[i]);
>> + }
>> + }
>> +}
>> +
>> static void pci_bus_realize(BusState *qbus, Error **errp)
>> {
>> PCIBus *bus = PCI_BUS(qbus);
>>
>> + bus->machine_done.notify = pcibus_machine_done;
>> + qemu_add_machine_init_done_notifier(&bus->machine_done);
>> +
>> vmstate_register(NULL, -1, &vmstate_pcibus, bus);
>> }
>>
>> @@ -89,6 +116,8 @@ static void pci_bus_unrealize(BusState *qbus, Error **errp)
>> {
>> PCIBus *bus = PCI_BUS(qbus);
>>
>> + qemu_remove_machine_init_done_notifier(&bus->machine_done);
>> +
>> vmstate_unregister(NULL, &vmstate_pcibus, bus);
>> }
>>
>> @@ -920,7 +949,6 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,
>> PCIConfigReadFunc *config_read = pc->config_read;
>> PCIConfigWriteFunc *config_write = pc->config_write;
>> Error *local_err = NULL;
>> - AddressSpace *dma_as;
>> DeviceState *dev = DEVICE(pci_dev);
>>
>> pci_dev->bus = bus;
>> @@ -961,15 +989,10 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,
>>
>> pci_dev->devfn = devfn;
>> pci_dev->requester_id_cache = pci_req_id_cache_get(pci_dev);
>> - dma_as = pci_device_iommu_address_space(pci_dev);
>> -
>> - memory_region_init_alias(&pci_dev->bus_master_enable_region,
>> - OBJECT(pci_dev), "bus master",
>> - dma_as->root, 0, memory_region_size(dma_as->root));
>> - memory_region_set_enabled(&pci_dev->bus_master_enable_region, false);
>> - address_space_init(&pci_dev->bus_master_as, &pci_dev->bus_master_enable_region,
>> - name);
>>
>> + if (qdev_hotplug) {
>> + pci_init_bus_master(pci_dev);
>> + }
>> pstrcpy(pci_dev->name, sizeof(pci_dev->name), name);
>> pci_dev->irq_state = 0;
>> pci_config_alloc(pci_dev);
>> diff --git a/vl.c b/vl.c
>> index 9bb7f4c..5cd0f2a 100644
>> --- a/vl.c
>> +++ b/vl.c
>> @@ -2675,6 +2675,11 @@ void qemu_add_machine_init_done_notifier(Notifier *notify)
>> }
>> }
>>
>> +void qemu_remove_machine_init_done_notifier(Notifier *notify)
>> +{
>> + notifier_remove(notify);
>> +}
>> +
>> static void qemu_run_machine_init_done_notifiers(void)
>> {
>> notifier_list_notify(&machine_init_done_notifiers, NULL);
>> --
>> MST
>>
>>
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [Qemu-devel] [PULL 03/36] hw/pci: delay bus_master_enable_region initialization
2016-07-11 15:18 ` Marcel Apfelbaum
@ 2016-07-11 18:41 ` Mark Cave-Ayland
2016-07-14 12:40 ` Marcel Apfelbaum
0 siblings, 1 reply; 43+ messages in thread
From: Mark Cave-Ayland @ 2016-07-11 18:41 UTC (permalink / raw)
To: Marcel Apfelbaum, Leon Alrae, Michael S. Tsirkin
Cc: Peter Maydell, qemu-devel, Paolo Bonzini
On 11/07/16 16:18, Marcel Apfelbaum wrote:
> On 07/11/2016 05:42 PM, Leon Alrae wrote:
>> Hi,
>>
>> This commit causes regressions in my MIPS tests. QEMU segfaults when
>> booting Linux on Malta board;
>
> Hi Leon,
>
> Is a good thing you caught it in the pull request, thanks!
> Is a pity we don't have a way to run sanity tests on all archs (beyond
> make check)
>
> this can be easily reproduced with
>> Aurelien's Debian images:
>>
>> wget
>> https://people.debian.org/~aurel32/qemu/mipsel/vmlinux-3.2.0-4-5kc-malta
>> wget
>> https://people.debian.org/~aurel32/qemu/mipsel/debian_wheezy_mipsel_standard.qcow2
>>
>> qemu-system-mips64el -M malta -kernel vmlinux-3.2.0-4-5kc-malta -hda
>> debian_wheezy_mipsel_standard.qcow2 -append "root=/dev/sda1
>> console=ttyS0" -nographic
>>
>
> I'll reproduce and handle it, thanks!
> Marcel
FWIW this looks like the exact same backtrace I reported with
qemu-system-sparc64 so hopefully the solution should fix both problems :)
ATB,
Mark.
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [Qemu-devel] [PULL 03/36] hw/pci: delay bus_master_enable_region initialization
2016-07-11 18:41 ` Mark Cave-Ayland
@ 2016-07-14 12:40 ` Marcel Apfelbaum
0 siblings, 0 replies; 43+ messages in thread
From: Marcel Apfelbaum @ 2016-07-14 12:40 UTC (permalink / raw)
To: Mark Cave-Ayland, Leon Alrae, Michael S. Tsirkin
Cc: Peter Maydell, qemu-devel, Paolo Bonzini
On 07/11/2016 09:41 PM, Mark Cave-Ayland wrote:
> On 11/07/16 16:18, Marcel Apfelbaum wrote:
>
>> On 07/11/2016 05:42 PM, Leon Alrae wrote:
>>> Hi,
>>>
>>> This commit causes regressions in my MIPS tests. QEMU segfaults when
>>> booting Linux on Malta board;
>>
>> Hi Leon,
>>
>> Is a good thing you caught it in the pull request, thanks!
>> Is a pity we don't have a way to run sanity tests on all archs (beyond
>> make check)
>>
>> this can be easily reproduced with
>>> Aurelien's Debian images:
>>>
>>> wget
>>> https://people.debian.org/~aurel32/qemu/mipsel/vmlinux-3.2.0-4-5kc-malta
>>> wget
>>> https://people.debian.org/~aurel32/qemu/mipsel/debian_wheezy_mipsel_standard.qcow2
>>>
>>> qemu-system-mips64el -M malta -kernel vmlinux-3.2.0-4-5kc-malta -hda
>>> debian_wheezy_mipsel_standard.qcow2 -append "root=/dev/sda1
>>> console=ttyS0" -nographic
>>>
>>
>> I'll reproduce and handle it, thanks!
>> Marcel
>
> FWIW this looks like the exact same backtrace I reported with
> qemu-system-sparc64 so hopefully the solution should fix both problems :)
>
Hi Mark and Leon,
I've reproduced both failures and I've found the root cause.
The PCI root bus is not realized as part of the machine initialization.
Until now the only consequence was the machine couldn't be migrated
(because the vmstate is initialized as part of 'realize').
However, from now on the devices cannot do DMA requests if the bus is not 'realized'.
It took some time because I had to go over all the archs and check this issue.
I have the patches ready, I am running some more tests and post them soon.
Thanks for the patience,
Marcel
>
> ATB,
>
> Mark.
>
^ permalink raw reply [flat|nested] 43+ messages in thread
end of thread, other threads:[~2016-07-14 12:41 UTC | newest]
Thread overview: 43+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1467650742-17580-1-git-send-email-mst@redhat.com>
2016-07-04 16:46 ` [Qemu-devel] [PULL 01/36] xen: fix ram init regression Michael S. Tsirkin
2016-07-04 16:46 ` [Qemu-devel] [PULL 02/36] hw/ppc: realize the PCI root bus as part of mac99 init Michael S. Tsirkin
2016-07-04 16:46 ` [Qemu-devel] [PULL 03/36] hw/pci: delay bus_master_enable_region initialization Michael S. Tsirkin
2016-07-09 1:34 ` Mark Cave-Ayland
2016-07-09 7:07 ` Marcel Apfelbaum
2016-07-09 9:09 ` Mark Cave-Ayland
2016-07-11 14:42 ` Leon Alrae
2016-07-11 15:18 ` Marcel Apfelbaum
2016-07-11 18:41 ` Mark Cave-Ayland
2016-07-14 12:40 ` Marcel Apfelbaum
2016-07-04 16:46 ` [Qemu-devel] [PULL 04/36] q35: allow dynamic sysbus Michael S. Tsirkin
2016-07-04 16:46 ` [Qemu-devel] [PULL 05/36] hw/iommu: enable iommu with -device Michael S. Tsirkin
2016-07-04 16:46 ` [Qemu-devel] [PULL 06/36] machine: remove iommu property Michael S. Tsirkin
2016-07-04 16:46 ` [Qemu-devel] [PULL 07/36] piix: Set I440FXState member pci_info.w32 in one place Michael S. Tsirkin
2016-07-04 16:46 ` [Qemu-devel] [PULL 08/36] pc: Eliminate PcPciInfo Michael S. Tsirkin
2016-07-04 16:46 ` [Qemu-devel] [PULL 09/36] virtio: revert host notifiers to old semantics Michael S. Tsirkin
2016-07-04 16:46 ` [Qemu-devel] [PULL 10/36] virtio: set low features early on load Michael S. Tsirkin
2016-07-04 16:46 ` [Qemu-devel] [PULL 11/36] Revert "virtio-net: unbreak self announcement and guest offloads after migration" Michael S. Tsirkin
2016-07-04 16:46 ` [Qemu-devel] [PULL 12/36] pci_register_bar: cleanup Michael S. Tsirkin
2016-07-04 16:46 ` [Qemu-devel] [PULL 13/36] log: Clean up misuse of Range for -dfilter Michael S. Tsirkin
2016-07-04 16:46 ` [Qemu-devel] [PULL 14/36] range: Eliminate direct Range member access Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 15/36] range: Replace internal representation of Range Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 16/36] log: Permit -dfilter 0..0xffffffffffffffff Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 17/36] tests: acpi: add CPU hotplug testcase Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 18/36] tests: add APIC.cphp and DSDT.cphp blobs Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 19/36] tests/acpi: add pxb/pxb-pcie tests Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 20/36] hw/pxb: declare pxb devices as not hot-pluggable Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 21/36] hw/acpi: fix a DSDT table issue when a pxb is present Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 22/36] acpi: refactor pxb crs computation Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 23/36] hw/apci: handle 64-bit MMIO regions correctly Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 24/36] tests/acpi: Add pxb/pxb-pcie tests blobs Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 25/36] change pvscsi_init_msi() type to void Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 26/36] usb xhci: change msi/msix property type Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 27/36] intel-hda: change msi " Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 28/36] mptsas: " Michael S. Tsirkin
2016-07-04 16:48 ` [Qemu-devel] [PULL 29/36] megasas: change msi/msix " Michael S. Tsirkin
2016-07-04 16:48 ` [Qemu-devel] [PULL 30/36] pci bridge dev: change msi " Michael S. Tsirkin
2016-07-04 16:48 ` [Qemu-devel] [PULL 31/36] pci: Convert msi_init() to Error and fix callers to check it Michael S. Tsirkin
2016-07-04 16:48 ` [Qemu-devel] [PULL 32/36] megasas: remove unnecessary megasas_use_msi() Michael S. Tsirkin
2016-07-04 16:48 ` [Qemu-devel] [PULL 33/36] mptsas: remove unnecessary internal msi state flag Michael S. Tsirkin
2016-07-04 16:48 ` [Qemu-devel] [PULL 34/36] vmxnet3: " Michael S. Tsirkin
2016-07-04 16:48 ` [Qemu-devel] [PULL 35/36] e1000e: " Michael S. Tsirkin
2016-07-04 16:48 ` [Qemu-devel] [PULL 36/36] vmw_pvscsi: " Michael S. Tsirkin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).