public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] device-assignment: register a reset function
@ 2010-09-14 15:04 Bernhard Kohl
  2010-09-16 15:48 ` Alex Williamson
  0 siblings, 1 reply; 10+ messages in thread
From: Bernhard Kohl @ 2010-09-14 15:04 UTC (permalink / raw)
  To: kvm; +Cc: Bernhard Kohl, Thomas Ostler

This is necessary because during reboot of a VM the assigned devices
continue DMA transfers which causes memory corruption.

Signed-off-by: Thomas Ostler <thomas.ostler@nsn.com>
Signed-off-by: Bernhard Kohl <bernhard.kohl@nsn.com>
---
 hw/device-assignment.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/hw/device-assignment.c b/hw/device-assignment.c
index 87f7418..001aee8 100644
--- a/hw/device-assignment.c
+++ b/hw/device-assignment.c
@@ -1450,6 +1450,17 @@ static void assigned_dev_unregister_msix_mmio(AssignedDevice *dev)
     dev->msix_table_page = NULL;
 }
 
+static void reset_assigned_device(void *opaque)
+{
+    PCIDevice *d = (PCIDevice *)opaque;
+    uint32_t conf;
+
+    /* reset the bus master bit to avoid further DMA transfers */
+    conf = assigned_dev_pci_read_config(d, 0x04, 0x02);
+    conf &= ~0x04;
+    assigned_dev_pci_write_config(d, 0x04, conf, 0x02);
+}
+
 static int assigned_initfn(struct PCIDevice *pci_dev)
 {
     AssignedDevice *dev = DO_UPCAST(AssignedDevice, dev, pci_dev);
@@ -1499,6 +1510,9 @@ static int assigned_initfn(struct PCIDevice *pci_dev)
     if (r < 0)
         goto assigned_out;
 
+    /* register reset function for the device */
+    qemu_register_reset(reset_assigned_device, pci_dev);
+
     /* intercept MSI-X entry page in the MMIO */
     if (dev->cap.available & ASSIGNED_DEVICE_CAP_MSIX)
         if (assigned_dev_register_msix_mmio(dev))
-- 
1.7.2.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2010-11-16 11:40 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-14 15:04 [PATCH] device-assignment: register a reset function Bernhard Kohl
2010-09-16 15:48 ` Alex Williamson
2010-09-17 14:14   ` Bernhard Kohl
2010-09-17 15:27     ` Bernhard Kohl
2010-09-17 16:16       ` Alex Williamson
2010-09-21 14:01         ` Bernhard Kohl
     [not found]         ` <1289820837-24254-1-git-send-email-bernhard.kohl@nsn.com>
2010-11-15 12:08           ` Jan Kiszka
2010-11-15 20:38             ` Alex Williamson
2010-11-15 21:58               ` Jan Kiszka
2010-11-16 11:39                 ` Bernhard Kohl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox