linux/drivers/vfio/pci
Abhishek Sahu 2b2c651baf vfio/pci: Invalidate mmaps and block the access in D3hot power state
According to [PCIe v5 5.3.1.4.1] for D3hot state

 "Configuration and Message requests are the only TLPs accepted by a
  Function in the D3Hot state. All other received Requests must be
  handled as Unsupported Requests, and all received Completions may
  optionally be handled as Unexpected Completions."

Currently, if the vfio PCI device has been put into D3hot state and if
user makes non-config related read/write request in D3hot state, these
requests will be forwarded to the host and this access may cause
issues on a few systems.

This patch leverages the memory-disable support added in commit
'abafbc551fdd ("vfio-pci: Invalidate mmaps and block MMIO access on
disabled memory")' to generate page fault on mmap access and
return error for the direct read/write. If the device is D3hot state,
then the error will be returned for MMIO access. The IO access generally
does not make the system unresponsive so the IO access can still happen
in D3hot state. The default value should be returned in this case
without bringing down the complete system.

Also, the power related structure fields need to be protected so
we can use the same 'memory_lock' to protect these fields also.
This protection is mainly needed when user changes the PCI
power state by writing into PCI_PM_CTRL register.
vfio_lock_and_set_power_state() wrapper function will take the
required locks and then it will invoke the vfio_pci_set_power_state().

Signed-off-by: Abhishek Sahu <abhsahu@nvidia.com>
Link: https://lore.kernel.org/r/20220518111612.16985-2-abhsahu@nvidia.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
2022-05-18 09:59:18 -06:00
..
hisilicon vfio/pci: Have all VFIO PCI drivers store the vfio_pci_core_device in drvdata 2022-05-11 13:32:56 -06:00
mlx5 vfio/pci: Have all VFIO PCI drivers store the vfio_pci_core_device in drvdata 2022-05-11 13:32:56 -06:00
Kconfig hisi_acc_vfio_pci: add new vfio_pci driver for HiSilicon ACC devices 2022-03-15 11:34:08 -06:00
Makefile hisi_acc_vfio_pci: add new vfio_pci driver for HiSilicon ACC devices 2022-03-15 11:34:08 -06:00
trace.h vfio/pci: Cleanup license mess 2019-01-22 11:06:05 -07:00
vfio_pci_config.c vfio/pci: Invalidate mmaps and block the access in D3hot power state 2022-05-18 09:59:18 -06:00
vfio_pci_core.c vfio/pci: Use the struct file as the handle not the vfio_group 2022-05-13 10:14:20 -06:00
vfio_pci_igd.c vfio/pci: Resolve sparse endian warnings in IGD support 2021-12-21 12:30:31 -07:00
vfio_pci_intrs.c vfio/pci: Introduce vfio_pci_core.ko 2021-08-26 10:36:51 -06:00
vfio_pci_rdwr.c vfio/pci: Stub vfio_pci_vga_rw when !CONFIG_VFIO_PCI_VGA 2022-02-22 13:45:02 -07:00
vfio_pci_zdev.c Merge branches 'v5.15/vfio/spdx-license-cleanups', 'v5.15/vfio/dma-valid-waited-v3', 'v5.15/vfio/vfio-pci-core-v5' and 'v5.15/vfio/vfio-ap' into v5.15/vfio/next 2021-08-26 11:08:50 -06:00
vfio_pci.c Merge remote-tracking branch 'iommu/vfio-notifier-fix' into v5.19/vfio/next 2022-05-13 10:04:22 -06:00