The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH v3 0/5] mm, uio: huge PFN mappings for /dev/mem and UIO
@ 2026-11-24 13:15 Eliav Farber
  2026-11-24 13:15 ` [PATCH v3 1/5] mm: add MMAP_TRACK_PFN action and track_pfn_range() for lazy PFN maps Eliav Farber
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Eliav Farber @ 2026-11-24 13:15 UTC (permalink / raw)
  To: Andrew Morton, David Hildenbrand, Greg Kroah-Hartman, Zi Yan
  Cc: Lorenzo Stoakes, Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
	Suren Baghdasaryan, Michal Hocko, Jann Horn, Pedro Falcato,
	Baolin Wang, Nico Pache, Ryan Roberts, Dev Jain, Barry Song,
	Lance Yang, Usama Arif, Kiryl Shutsemau, linux-mm, linux-kernel,
	Eliav Farber

/dev/mem and UIO map large physical regions with 4KiB PTEs, even where a
2MiB or 1GiB entry would do. vfio-pci fixed that in commit f9e54c3a2f5b
("vfio/pci: implement huge_fault support") by populating on fault. This
series does the same for /dev/mem and UIO.

Patches 1 and 3 add the two things a driver needs outside vfio-pci: a way
to reserve a range's memory type without populating it, and the order
dispatch vfio-pci open-codes. Patch 2 fixes a window and pfn check in
huge_memory that the new callers reach. Patches 4 and 5 are the users.

Applies on top of Lorenzo Stoakes' fixes for races between huge and
non-huge faults in PFN mappings, queued in mm for 7.5:
https://lore.kernel.org/all/20261117-huge-pfnmap-fault-races-v2-0-276007e73bcb@kernel.org/

Changes in v3:

- Patch 2 is new: the window and pfn checks moved into mm, where every
  caller gets them.
- /dev/mem keeps the eager mapping under CONFIG_IO_STRICT_DEVMEM.
- Renamed pfn_range_track() to track_pfn_range(), and dropped its addr
  and size arguments.
- Shorter commit messages and comments.

Changes in v2:

- vmf_insert_pfn_order() maps a write fault writable at every
  order. (Sashiko)
- COW mappings get their own vm_operations_struct, instead of a COW test
  inside the fault handler. (Sashiko)
- Corrected the L1TF claim in the /dev/mem and UIO patches, and dropped
  the claim that uffd-wp can write-protect such a mapping.

An LLM helped me find corner cases and fix them in the code, write tests
and run them under QEMU. The runs on real hardware are mine.

v1: https://lore.kernel.org/all/20261111113045.35368-1-farbere@amazon.com/
v2: https://lore.kernel.org/all/20261112125638.12209-1-farbere@amazon.com/

Eliav Farber (5):
  mm: add MMAP_TRACK_PFN action and track_pfn_range() for lazy PFN maps
  mm/huge_memory: check the window and the pfn alignment before
    inserting
  mm: add vmf_insert_pfn_order()
  mm/char-mem: implement huge_fault support for /dev/mem
  uio: implement huge_fault support for physical mappings

 drivers/uio/uio.c               |  99 +++++++++++++++--
 include/linux/mm.h              |  18 ++++
 include/linux/mm_types.h        |   1 +
 mm/char-mem.c                   |  81 +++++++++++++-
 mm/huge_memory.c                |  18 +++-
 mm/internal.h                   |   3 +
 mm/memory.c                     | 182 +++++++++++++++++++++++++++-----
 mm/util.c                       |   7 ++
 tools/testing/vma/include/dup.h |   1 +
 9 files changed, 369 insertions(+), 41 deletions(-)


base-commit: b6a9fa34ce4187cb69d3c588a4bbffc31ce5db8f
-- 
2.47.3


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-11-24 13:28 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24 13:15 [PATCH v3 0/5] mm, uio: huge PFN mappings for /dev/mem and UIO Eliav Farber
2026-11-24 13:15 ` [PATCH v3 1/5] mm: add MMAP_TRACK_PFN action and track_pfn_range() for lazy PFN maps Eliav Farber
2026-11-24 13:15 ` [PATCH v3 2/5] mm/huge_memory: check the window and the pfn alignment before inserting Eliav Farber
2026-11-24 13:15 ` [PATCH v3 3/5] mm: add vmf_insert_pfn_order() Eliav Farber
2026-11-24 13:15 ` [PATCH v3 4/5] mm/char-mem: implement huge_fault support for /dev/mem Eliav Farber
2026-11-24 13:15 ` [PATCH v3 5/5] uio: implement huge_fault support for physical mappings Eliav Farber
2026-11-24 13:28 ` [PATCH v3 0/5] mm, uio: huge PFN mappings for /dev/mem and UIO Lorenzo Stoakes (ARM)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox