qemu/hw/vfio
Alex Williamson 00b519c0bc vfio/helpers: Align mmaps
Thanks to work by Peter Xu, support is introduced in Linux v6.12 to
allow pfnmap insertions at PMD and PUD levels of the page table.  This
means that provided a properly aligned mmap, the vfio driver is able
to map MMIO at significantly larger intervals than PAGE_SIZE.  For
example on x86_64 (the only architecture currently supporting huge
pfnmaps for PUD), rather than 4KiB mappings, we can map device MMIO
using 2MiB and even 1GiB page table entries.

Typically mmap will already provide PMD aligned mappings, so devices
with moderately sized MMIO ranges, even GPUs with standard 256MiB BARs,
will already take advantage of this support.  However in order to better
support devices exposing multi-GiB MMIO, such as 3D accelerators or GPUs
with resizable BARs enabled, we need to manually align the mmap.

There doesn't seem to be a way for userspace to easily learn about PMD
and PUD mapping level sizes, therefore this takes the simple approach
to align the mapping to the power-of-two size of the region, up to 1GiB,
which is currently the maximum alignment we care about.

Cc: Peter Xu <peterx@redhat.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
2024-10-23 14:46:24 +02:00
..
amd-xgbe.c
ap.c hw: Use device_class_set_legacy_reset() instead of opencoding 2024-09-13 15:31:44 +01:00
calxeda-xgmac.c
ccw.c hw: Use device_class_set_legacy_reset() instead of opencoding 2024-09-13 15:31:44 +01:00
common.c vfio queue: 2024-07-24 12:58:46 +10:00
container-base.c vfio-container-base: Introduce vfio_container_get_iova_ranges() helper 2024-07-09 11:50:37 +02:00
container.c vfio/{iommufd, container}: Invoke HostIOMMUDevice::realize() during attach_device() 2024-07-23 17:14:52 +02:00
cpr.c vfio/cpr: Make vfio_cpr_register_container() return bool 2024-05-16 16:59:20 +02:00
display.c vfio/display: Fix vfio_display_edid_init() error path 2024-07-09 11:50:37 +02:00
helpers.c vfio/helpers: Align mmaps 2024-10-23 14:46:24 +02:00
igd.c vfio/igd: correctly calculate stolen memory size for gen 9 and later 2024-09-17 10:37:55 +02:00
iommufd.c vfio/iommufd: Implement VFIOIOMMUClass::query_dirty_bitmap support 2024-07-23 17:14:52 +02:00
Kconfig hw/vfio: Move the IGD quirk code to a separate file 2020-02-06 11:55:42 -07:00
meson.build vfio: register container for cpr 2024-03-08 22:10:13 +01:00
migration.c vfio/migration: Report only stop-copy size in vfio_state_pending_exact() 2024-10-23 14:46:24 +02:00
pci-quirks.c vfio/igd: add new bar0 quirk to emulate BDSM mirror 2024-09-17 10:37:55 +02:00
pci.c hw: Use device_class_set_legacy_reset() instead of opencoding 2024-09-13 15:31:44 +01:00
pci.h vfio/igd: add new bar0 quirk to emulate BDSM mirror 2024-09-17 10:37:55 +02:00
platform.c vfio/platform: Make vfio_populate_device() and vfio_base_device_init() return bool 2024-05-22 10:04:21 +02:00
spapr.c vfio/container: Change VFIOContainerBase to use QOM 2024-06-24 23:15:31 +02:00
trace-events vfio/migration: Change trace formats from hex to decimal 2024-10-23 14:46:24 +02:00
trace.h trace: switch position of headers to what Meson requires 2020-08-21 06:18:24 -04:00