vfio/pci: Decouple PCI_COMMAND_MEMORY bit checks from is_virtfn
authorMatthew Rosato <mjrosato@linux.ibm.com>
Thu, 10 Sep 2020 14:59:57 +0000 (10:59 -0400)
committerAlex Williamson <alex.williamson@redhat.com>
Tue, 22 Sep 2020 16:52:24 +0000 (10:52 -0600)
commit515ecd5368f1510152fa4f9b9ce55b66ac56c334
tree6b4a5e3c00c739db0f82c3e55faf1ac1a244167f
parent08b6e22b850c28b6032da1e4d767a33116e23dfb
vfio/pci: Decouple PCI_COMMAND_MEMORY bit checks from is_virtfn

While it is true that devices with is_virtfn=1 will have a Memory Space
Enable bit that is hard-wired to 0, this is not the only case where we
see this behavior -- For example some bare-metal hypervisors lack
Memory Space Enable bit emulation for devices not setting is_virtfn
(s390). Fix this by instead checking for the newly-added
no_command_memory bit which directly denotes the need for
PCI_COMMAND_MEMORY emulation in vfio.

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>
drivers/vfio/pci/vfio_pci_config.c