From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55654) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VoDY8-0002Xc-J4 for qemu-devel@nongnu.org; Wed, 04 Dec 2013 09:35:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VoDXi-0003ES-5Z for qemu-devel@nongnu.org; Wed, 04 Dec 2013 09:35:34 -0500 Received: from e39.co.us.ibm.com ([32.97.110.160]:39771) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VoDXh-0003Dj-Ug for qemu-devel@nongnu.org; Wed, 04 Dec 2013 09:35:10 -0500 Received: from /spool/local by e39.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 4 Dec 2013 07:35:09 -0700 From: Michael Roth Date: Wed, 4 Dec 2013 08:34:33 -0600 Message-Id: <1386167679-13021-27-git-send-email-mdroth@linux.vnet.ibm.com> In-Reply-To: <1386167679-13021-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1386167679-13021-1-git-send-email-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 26/32] vfio-pci: Fix multifunction=on List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org From: Alex Williamson When an assigned device is initialized it copies the device config space into the emulated config space. Unfortunately multifunction is setup prior to the device initfn and gets clobbered. We need to restore it just like pci-assign does. Cc: qemu-stable@nongnu.org Signed-off-by: Alex Williamson Signed-off-by: Paolo Bonzini (cherry picked from commit 8d07d6c46597a885eb38d99cc6fff399ce69cd21) Signed-off-by: Michael Roth --- hw/misc/vfio.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c index 017e693..d9e78e1 100644 --- a/hw/misc/vfio.c +++ b/hw/misc/vfio.c @@ -3142,6 +3142,13 @@ static int vfio_initfn(PCIDevice *pdev) vdev->emulated_config_bits[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_MULTI_FUNCTION; + /* Restore or clear multifunction, this is always controlled by QEMU */ + if (vdev->pdev.cap_present & QEMU_PCI_CAP_MULTIFUNCTION) { + vdev->pdev.config[PCI_HEADER_TYPE] |= PCI_HEADER_TYPE_MULTI_FUNCTION; + } else { + vdev->pdev.config[PCI_HEADER_TYPE] &= ~PCI_HEADER_TYPE_MULTI_FUNCTION; + } + /* * Clear host resource mapping info. If we choose not to register a * BAR, such as might be the case with the option ROM, we can get -- 1.7.9.5