After kernel commit abafbc55 'vfio-pci: Invalidate mmaps and
block MMIO access on disabled memory', I'm seeing qemu errors
on s390x as vfio-pci devices attempt to read bar 0 because
PCI_COMMAND_MEMORY is not reliably set. Ensure the value
stays ON while the device is in-use.
Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
---
hw/s390x/s390-pci-inst.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c
index 2f7a7d7..74b8796 100644
--- a/hw/s390x/s390-pci-inst.c
+++ b/hw/s390x/s390-pci-inst.c
@@ -555,6 +555,16 @@ int pcistg_service_call(S390CPU *cpu, uint8_t r1, uint8_t r2, uintptr_t ra)
}
/* len = 1,2,4 so we do not need to test */
zpci_endian_swap(&data, len);
+
+ /*
+ * vfio-pci requires PCI_COMMAND_MEMORY. Ensure that it
+ * stays on for an active device.
+ */
+ if ((pbdev->fh & FH_SHM_VFIO) && (offset == PCI_COMMAND) &&
+ (len == 2) && (data != 0)) {
+ data |= PCI_COMMAND_MEMORY;
+ }
+
pci_host_config_write_common(pbdev->pdev, offset,
pci_config_size(pbdev->pdev),
data, len);
--
1.8.3.1