cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
05bba0
From d8cc073c06a4c79e24a86a958b8c1ac7a26fa039 Mon Sep 17 00:00:00 2001
05bba0
From: Alex Williamson <alex.williamson@redhat.com>
05bba0
Date: Fri, 10 Apr 2015 16:33:45 +0200
05bba0
Subject: [PATCH 02/14] vfio: Do not reattempt a failed rom read
05bba0
05bba0
Message-id: <20150410163345.15324.23733.stgit@gimli.home>
05bba0
Patchwork-id: 64790
05bba0
O-Subject: [RHEL7.2 qemu-kvm PATCH 2/8] vfio: Do not reattempt a failed rom read
05bba0
Bugzilla: 1210503
05bba0
RH-Acked-by: Thomas Huth <thuth@redhat.com>
05bba0
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
05bba0
RH-Acked-by: Bandan Das <bsd@redhat.com>
05bba0
05bba0
From: Bandan Das <bsd@redhat.com>
05bba0
05bba0
Upstream: e638073c569e801ce9def2016a84f955cbbca779
05bba0
05bba0
During lazy rom loading, if rom read fails, and the
05bba0
guest attempts a read again, vfio will again attempt it.
05bba0
Add a boolean to prevent this. There could be a case where
05bba0
a failed rom read might succeed the next time because of
05bba0
a device reset or such, but it's best to exclude unpredictable
05bba0
behavior
05bba0
05bba0
Signed-off-by: Bandan Das <bsd@redhat.com>
05bba0
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
05bba0
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
05bba0
---
05bba0
 hw/misc/vfio.c | 6 ++++++
05bba0
 1 file changed, 6 insertions(+)
05bba0
05bba0
diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c
05bba0
index c9dbc28..f3bf491 100644
05bba0
--- a/hw/misc/vfio.c
05bba0
+++ b/hw/misc/vfio.c
05bba0
@@ -206,6 +206,7 @@ typedef struct VFIODevice {
05bba0
     bool has_flr;
05bba0
     bool has_pm_reset;
05bba0
     bool needs_reset;
05bba0
+    bool rom_read_failed;
05bba0
 } VFIODevice;
05bba0
 
05bba0
 typedef struct VFIOGroup {
05bba0
@@ -1197,6 +1198,7 @@ static void vfio_pci_load_rom(VFIODevice *vdev)
05bba0
     vdev->rom_offset = reg_info.offset;
05bba0
 
05bba0
     if (!vdev->rom_size) {
05bba0
+        vdev->rom_read_failed = true;
05bba0
         error_report("vfio-pci: Cannot read device rom at "
05bba0
                     "%04x:%02x:%02x.%x\n",
05bba0
                     vdev->host.domain, vdev->host.bus, vdev->host.slot,
05bba0
@@ -1235,6 +1237,9 @@ static uint64_t vfio_rom_read(void *opaque, hwaddr addr, unsigned size)
05bba0
     /* Load the ROM lazily when the guest tries to read it */
05bba0
     if (unlikely(!vdev->rom)) {
05bba0
         vfio_pci_load_rom(vdev);
05bba0
+        if (unlikely(!vdev->rom && !vdev->rom_read_failed)) {
05bba0
+            vfio_pci_load_rom(vdev);
05bba0
+        }
05bba0
     }
05bba0
 
05bba0
     memcpy(&val, vdev->rom + addr,
05bba0
@@ -1352,6 +1357,7 @@ static void vfio_pci_size_rom(VFIODevice *vdev)
05bba0
                      PCI_BASE_ADDRESS_SPACE_MEMORY, &vdev->pdev.rom);
05bba0
 
05bba0
     vdev->pdev.has_rom = true;
05bba0
+    vdev->rom_read_failed = false;
05bba0
 }
05bba0
 
05bba0
 static void vfio_vga_write(void *opaque, hwaddr addr,
05bba0
-- 
05bba0
1.8.3.1
05bba0