cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
0a122b
From 7197c8b9234f26922ce7c6f3d7784b2604bdaafd Mon Sep 17 00:00:00 2001
0a122b
From: Alex Williamson <alex.williamson@redhat.com>
0a122b
Date: Thu, 21 Nov 2013 21:08:58 +0100
0a122b
Subject: [PATCH 10/14] vfio-pci: Fix multifunction=on
0a122b
0a122b
RH-Author: Alex Williamson <alex.williamson@redhat.com>
0a122b
Message-id: <20131121210817.12705.22782.stgit@bling.home>
0a122b
Patchwork-id: 55844
0a122b
O-Subject: [RHEL7 qemu-kvm PATCH] vfio-pci: Fix multifunction=on
0a122b
Bugzilla: 1029275
0a122b
RH-Acked-by: Amos Kong <akong@redhat.com>
0a122b
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
0a122b
RH-Acked-by: Bandan Das <bsd@redhat.com>
0a122b
0a122b
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1029275
0a122b
Brew: https://brewweb.devel.redhat.com/taskinfo?taskID=6627360
0a122b
Upstream: 187d62327aca39afbb038d13d7cd6bf2d11640d3
0a122b
0a122b
When an assigned device is initialized it copies the device config
0a122b
space into the emulated config space.  Unfortunately multifunction is
0a122b
setup prior to the device initfn and gets clobbered.  We need to
0a122b
restore it just like pci-assign does.
0a122b
0a122b
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
0a122b
Reviewed-by: Bandan Das <bsd@redhat.com>
0a122b
Message-id: 20131112185059.7262.33780.stgit@bling.home
0a122b
Cc: qemu-stable@nongnu.org
0a122b
Signed-off-by: Anthony Liguori <aliguori@amazon.com>
0a122b
---
0a122b
 hw/misc/vfio.c |    7 +++++++
0a122b
 1 file changed, 7 insertions(+)
0a122b
0a122b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
0a122b
---
0a122b
 hw/misc/vfio.c |    7 +++++++
0a122b
 1 files changed, 7 insertions(+), 0 deletions(-)
0a122b
0a122b
diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c
0a122b
index b7f213b..5a6925c 100644
0a122b
--- a/hw/misc/vfio.c
0a122b
+++ b/hw/misc/vfio.c
0a122b
@@ -3625,6 +3625,13 @@ static int vfio_initfn(PCIDevice *pdev)
0a122b
     vdev->emulated_config_bits[PCI_HEADER_TYPE] =
0a122b
                                               PCI_HEADER_TYPE_MULTI_FUNCTION;
0a122b
 
0a122b
+    /* Restore or clear multifunction, this is always controlled by QEMU */
0a122b
+    if (vdev->pdev.cap_present & QEMU_PCI_CAP_MULTIFUNCTION) {
0a122b
+        vdev->pdev.config[PCI_HEADER_TYPE] |= PCI_HEADER_TYPE_MULTI_FUNCTION;
0a122b
+    } else {
0a122b
+        vdev->pdev.config[PCI_HEADER_TYPE] &= ~PCI_HEADER_TYPE_MULTI_FUNCTION;
0a122b
+    }
0a122b
+
0a122b
     /*
0a122b
      * Clear host resource mapping info.  If we choose not to register a
0a122b
      * BAR, such as might be the case with the option ROM, we can get
0a122b
-- 
0a122b
1.7.1
0a122b