From fbbbab2c57e373bad5d30eb28798f9e7e6c68b28 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Oct 06 2014 16:32:22 +0000 Subject: Fix PPC virtio regression (bz #1144490) --- diff --git a/0008-Revert-virtio-pci-fix-migration-for-pci-bus-master.patch b/0008-Revert-virtio-pci-fix-migration-for-pci-bus-master.patch new file mode 100644 index 0000000..c1b0103 --- /dev/null +++ b/0008-Revert-virtio-pci-fix-migration-for-pci-bus-master.patch @@ -0,0 +1,98 @@ +From 9d8b817bfe327873c009fa4621c0308e7f3bc5de Mon Sep 17 00:00:00 2001 +From: "Michael S. Tsirkin" +Date: Mon, 29 Sep 2014 11:27:32 +0300 +Subject: [PATCH] Revert "virtio-pci: fix migration for pci bus master" + +This reverts commit 4d43d3f3c8147ade184df9a1e9e82826edd39e19. + +Reported to break PPC guests. + +Signed-off-by: Michael S. Tsirkin +(cherry picked from commit 45363e46aeebfc99753389649eac7c7fc22bfe52) +--- + hw/virtio/virtio-pci.c | 39 +++++++++++++++++++-------------------- + 1 file changed, 19 insertions(+), 20 deletions(-) + +diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c +index c19c4d6..58ebbcf 100644 +--- a/hw/virtio/virtio-pci.c ++++ b/hw/virtio/virtio-pci.c +@@ -86,6 +86,9 @@ + * 12 is historical, and due to x86 page size. */ + #define VIRTIO_PCI_QUEUE_ADDR_SHIFT 12 + ++/* Flags track per-device state like workarounds for quirks in older guests. */ ++#define VIRTIO_PCI_FLAG_BUS_MASTER_BUG (1 << 0) ++ + static void virtio_pci_bus_new(VirtioBusState *bus, size_t bus_size, + VirtIOPCIProxy *dev); + +@@ -320,6 +323,14 @@ static void virtio_ioport_write(void *opaque, uint32_t addr, uint32_t val) + proxy->pci_dev.config[PCI_COMMAND] | + PCI_COMMAND_MASTER, 1); + } ++ ++ /* Linux before 2.6.34 sets the device as OK without enabling ++ the PCI device bus master bit. In this case we need to disable ++ some safety checks. */ ++ if ((val & VIRTIO_CONFIG_S_DRIVER_OK) && ++ !(proxy->pci_dev.config[PCI_COMMAND] & PCI_COMMAND_MASTER)) { ++ proxy->flags |= VIRTIO_PCI_FLAG_BUS_MASTER_BUG; ++ } + break; + case VIRTIO_MSI_CONFIG_VECTOR: + msix_vector_unuse(&proxy->pci_dev, vdev->config_vector); +@@ -469,18 +480,13 @@ static void virtio_write_config(PCIDevice *pci_dev, uint32_t address, + VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev); + VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus); + +- uint8_t cmd = proxy->pci_dev.config[PCI_COMMAND]; +- + pci_default_write_config(pci_dev, address, val, len); + + if (range_covers_byte(address, len, PCI_COMMAND) && + !(pci_dev->config[PCI_COMMAND] & PCI_COMMAND_MASTER) && +- (cmd & PCI_COMMAND_MASTER)) { +- /* Bus driver disables bus mastering - make it act +- * as a kind of reset to render the device quiescent. */ ++ !(proxy->flags & VIRTIO_PCI_FLAG_BUS_MASTER_BUG)) { + virtio_pci_stop_ioeventfd(proxy); +- virtio_reset(vdev); +- msix_unuse_all_vectors(&proxy->pci_dev); ++ virtio_set_status(vdev, vdev->status & ~VIRTIO_CONFIG_S_DRIVER_OK); + } + } + +@@ -889,19 +895,11 @@ static void virtio_pci_vmstate_change(DeviceState *d, bool running) + VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus); + + if (running) { +- /* Linux before 2.6.34 drives the device without enabling +- the PCI device bus master bit. Enable it automatically +- for the guest. This is a PCI spec violation but so is +- initiating DMA with bus master bit clear. +- Note: this only makes a difference when migrating +- across QEMU versions from an old QEMU, as for new QEMU +- bus master and driver bits are always in sync. +- TODO: consider enabling conditionally for compat machine types. */ +- if (vdev->status & (VIRTIO_CONFIG_S_ACKNOWLEDGE | +- VIRTIO_CONFIG_S_DRIVER)) { +- pci_default_write_config(&proxy->pci_dev, PCI_COMMAND, +- proxy->pci_dev.config[PCI_COMMAND] | +- PCI_COMMAND_MASTER, 1); ++ /* Try to find out if the guest has bus master disabled, but is ++ in ready state. Then we have a buggy guest OS. */ ++ if ((vdev->status & VIRTIO_CONFIG_S_DRIVER_OK) && ++ !(proxy->pci_dev.config[PCI_COMMAND] & PCI_COMMAND_MASTER)) { ++ proxy->flags |= VIRTIO_PCI_FLAG_BUS_MASTER_BUG; + } + virtio_pci_start_ioeventfd(proxy); + } else { +@@ -1045,6 +1043,7 @@ static void virtio_pci_reset(DeviceState *qdev) + virtio_pci_stop_ioeventfd(proxy); + virtio_bus_reset(bus); + msix_unuse_all_vectors(&proxy->pci_dev); ++ proxy->flags &= ~VIRTIO_PCI_FLAG_BUS_MASTER_BUG; + } + + static Property virtio_pci_properties[] = { diff --git a/qemu.spec b/qemu.spec index e9748ea..5a9a7d1 100644 --- a/qemu.spec +++ b/qemu.spec @@ -152,7 +152,7 @@ Summary: QEMU is a FAST! processor emulator Name: qemu Version: 2.1.2 -Release: 3%{?dist} +Release: 4%{?dist} Epoch: 2 License: GPLv2+ and LGPLv2+ and BSD Group: Development/Tools @@ -202,6 +202,8 @@ Patch0005: 0005-curl-Don-t-deref-NULL-pointer-in-call-to-aio_poll.patch # Fix crash on migration/snapshot (bz #1144490) Patch0006: 0006-virtio-pci-enable-bus-master-for-old-guests.patch Patch0007: 0007-virtio-pci-fix-migration-for-pci-bus-master.patch +# Fix PPC virtio regression (bz #1144490) +Patch0008: 0008-Revert-virtio-pci-fix-migration-for-pci-bus-master.patch BuildRequires: SDL2-devel BuildRequires: zlib-devel @@ -738,6 +740,8 @@ CAC emulation development files. # Fix crash on migration/snapshot (bz #1144490) %patch0006 -p1 %patch0007 -p1 +# Fix PPC virtio regression (bz #1144490) +%patch0008 -p1 %build @@ -1517,6 +1521,9 @@ getent passwd qemu >/dev/null || \ %endif %changelog +* Mon Oct 06 2014 Cole Robinson - 2:2.1.2-4 +- Fix PPC virtio regression (bz #1144490) + * Tue Sep 30 2014 Dan HorĂ¡k - 2:2.1.2-3 - Enable KVM on ppc64le