vfio/pci: Per-BAR excluded ranges
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest5 patches 8 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/5 | vfio/pci: Move the excluded windows out of vfio_pci_core_do_io_rw()drivers/ drivers/ include/ | +76 | 2 replies | |
| 2/5 | vfio/virtio: Release vfio-pci-core state when legacy I/O setup failsdrivers/ | +4 | 2 replies | |
| 3/5 | vfio/pci: Add per-BAR excluded ranges and put the MSI-X table on themdrivers/ drivers/ drivers/ +1 more | +153 | 0 replies | |
| 4/5 | vfio/pci: Advertise the mmap areas around excluded rangesdrivers/ | +72 | 2 replies | |
| 5/5 | vfio/pci: Refuse ioeventfds and dma-buf exports over excluded rangesdrivers/ drivers/ drivers/ +1 more | +15 | 2 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH 0/5] vfio/pci: Per-BAR excluded ranges
From: Manish Honap <[email protected]>
vfio-pci keeps the user away from one range of a BAR, the MSI-X table:
reads through the device file return 0xff and writes are dropped. The vfio-cxl series needs the same for the HDM decoder registers of a CXL device, and Piotr's xe RFC [3] needs it for ranges of an xe BAR. Alex pointed both at one generic interface [4]. This series adds it, with the MSI-X table as its in-tree user.
Patch 1 moves the MSI-X and ROM windows out of the exported vfio_pci_core_do_io_rw() into vfio_pci_bar_rw(). The VGA and nvgrace-gpu callers lose two arguments. No functional change.
Patch 2 fixes an error path in virtio-vfio that skips vfio_pci_core_release_dev(). Patch 3 allocates in vfio_pci_core_init_dev() and would leak there.
Patch 3 adds a list of excluded ranges for each standard BAR, sorted by start. Each range has flags for mmap, read and write. The lists are built in .init and freed in .release, so readers take no lock. The MSI-X table is the first range, excluded from read and write. If its BIR or offset is outside a standard BAR, nothing is added and one warning is printed.
Patch 4 refuses an mmap that overlaps a range excluded from mmap, and reports the other areas of the BAR with a sparse mmap capability. The MSI-X table is not excluded from mmap, so the MSI-X BAR stays mappable as it has been since commit a32295c612c5 ("vfio-pci: Allow mapping MSIX BAR").
Patch 5 refuses an ioeventfd over a range excluded from write, and a dma-buf export over a range excluded from mmap. The generic test replaces the open-coded MSI-X ioeventfd test.
After this series no in-tree range is excluded from mmap, so patch 4 and the dma-buf check in patch 5 have no in-tree trigger yet. The vfio-cxl v7 series adds the first such range, the HDM decoder registers, and exports vfio_pci_core_add_excluded_range() with it. Piotr's xe ranges are the second. If you prefer, patch 4 can move into the vfio-cxl series, in front of its first user.
Changes from vfio-cxl v6 08 to 10/31 [1]:
- Patches 1 and 2 are new.
- Patch 3 (v6 08): lists built in vfio_pci_core_init_dev() and freed in vfio_pci_core_release_dev() (Alex, 08/31 [2]). Entries use struct range. The ROM BAR keeps its range past the ROM image outside the list. The MSI-X table is added by its own helper.
- Patch 4 (v6 09): count the sparse areas, allocate and fill them once (Alex, 09/31 [6]). VFIO_REGION_INFO_CAP_MSIX_MAPPABLE is not reported when a range excluded from mmap covers the MSI-X table pages (Sashiko on Piotr's RFC 2/4 [5]).
- Patch 5 (v6 10): the dma-buf check is in validate_dmabuf_input() (Alex, 10/31 [7]). The open-coded MSI-X ioeventfd test is removed.
- The export of vfio_pci_core_add_excluded_range() moves to the vfio-cxl series, with its first caller.
Testing:
- Series applies cleanly to v7.4-rc4 (b6a9fa34ce41)
- Tested with a passthrough guest on VR-NVL72 system with running CUDA/UVM workloads in guest.
- No vfio selftests, kmemleak or sparse were run.
[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
[3] https://lore.kernel.org/all/[email protected]/
[4] https://lore.kernel.org/all/[email protected]/
[5] https://lore.kernel.org/all/[email protected]/
[6] https://lore.kernel.org/all/[email protected]/
[7] https://lore.kernel.org/all/[email protected]/
base-commit: b6a9fa34ce4187cb69d3c588a4bbffc31ce5db8f
Manish Honap (5):
vfio/pci: Move the excluded windows out of vfio_pci_core_do_io_rw() vfio/virtio: Release vfio-pci-core state when legacy I/O setup fails vfio/pci: Add per-BAR excluded ranges and put the MSI-X table on them vfio/pci: Advertise the mmap areas around excluded ranges vfio/pci: Refuse ioeventfds and dma-buf exports over excluded ranges
drivers/vfio/pci/nvgrace-gpu/main.c | 4 +- drivers/vfio/pci/vfio_pci_core.c | 178 +++++++++++++++++++++++++++- drivers/vfio/pci/vfio_pci_dmabuf.c | 10 +- drivers/vfio/pci/vfio_pci_priv.h | 14 +++ drivers/vfio/pci/vfio_pci_rdwr.c | 152 ++++++++++++++++-------- drivers/vfio/pci/virtio/main.c | 5 +- include/linux/vfio_pci_core.h | 5 +- 7 files changed, 312 insertions(+), 56 deletions(-)
Signature · 1 line
2.53.0