]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
vfio/pci: Set up BAR resources and maps in vfio_pci_core_enable()
authorMatt Evans <mattev@meta.com>
Mon, 11 May 2026 14:58:23 +0000 (07:58 -0700)
committerAlex Williamson <alex@shazbot.org>
Thu, 14 May 2026 17:38:04 +0000 (11:38 -0600)
commit05f2a68b407a6817fe141dd64972c6ab8725312d
treeb871dad49283bcdb17cc3bfa7f7df1ae75680c90
parentdf733ddc263dbe5f471e7c80c8b669532f56bf76
vfio/pci: Set up BAR resources and maps in vfio_pci_core_enable()

Previously BAR resource requests and the corresponding pci_iomap()
were performed on-demand and without synchronisation, which was racy.
Rather than add synchronisation, it's simplest to address this by
doing both activities from vfio_pci_core_enable().

The resource allocation and/or pci_iomap() can still fail; their
status is tracked and existing calls to vfio_pci_core_setup_barmap()
will fail in a similar way to before.  This keeps the point of failure
as observed by userspace the same, i.e. failures to request/map unused
BARs are benign.

Fixes: 89e1f7d4c66d ("vfio: Add PCI device driver")
Signed-off-by: Matt Evans <mattev@meta.com>
Link: https://lore.kernel.org/r/20260511145829.2993601-2-mattev@meta.com
[ERR_PTR -> IOMEM_ERR_PTR per lkp report]
Signed-off-by: Alex Williamson <alex@shazbot.org>
drivers/vfio/pci/vfio_pci_core.c
drivers/vfio/pci/vfio_pci_rdwr.c