Blob Blame History Raw
From: Matthew Rosato <mjrosato@linux.ibm.com>
Date: Thu, 10 Sep 2020 10:59:56 -0400
Subject: s390/pci: Mark all VFs as not implementing PCI_COMMAND_MEMORY
Git-commit: 08b6e22b850c28b6032da1e4d767a33116e23dfb
Patch-mainline: v5.10-rc1
References: bsc#1179612

For s390 we can have VFs that are passed-through without the associated
PF. Firmware provides an emulation layer to allow these devices to
operate independently, but is missing emulation of the Memory Space
Enable bit.  For these as well as linked VFs, set no_command_memory
which specifies these devices do not implement PCI_COMMAND_MEMORY.

Fixes: abafbc551fdd ("vfio-pci: Invalidate mmaps and block MMIO access on disabled memory")
Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
Reviewed-by: Niklas Schnelle <schnelle@linux.ibm.com>
Reviewed-by: Pierre Morel <pmorel@linux.ibm.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Acked-by: Joerg Roedel <jroedel@suse.de>
---
 arch/s390/pci/pci.c |    9 +++++++++
 1 file changed, 9 insertions(+)

--- a/arch/s390/pci/pci.c
+++ b/arch/s390/pci/pci.c
@@ -609,6 +609,15 @@ void pcibios_disable_device(struct pci_d
 	zpci_fmb_disable_device(zdev);
 	zpci_debug_exit_device(zdev);
 }
+void pcibios_bus_add_device(struct pci_dev *pdev)
+{
+	struct zpci_dev *zdev = to_zpci(pdev);
+
+	if (zdev->vfn) {
+		/* Set no_command_memory on all VFs */
+		pdev->no_command_memory = 1;
+	}
+}
 
 #ifdef CONFIG_HIBERNATE_CALLBACKS
 static int zpci_restore(struct device *dev)