Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Eliav Farber <farbere@amazon.com>
To: Andrew Morton <akpm@linux-foundation.org>,
	David Hildenbrand <david@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Zi Yan <ziy@nvidia.com>
Cc: Lorenzo Stoakes <ljs@kernel.org>,
	"Liam R. Howlett" <liam@infradead.org>,
	Vlastimil Babka <vbabka@kernel.org>,
	Mike Rapoport <rppt@kernel.org>,
	"Suren Baghdasaryan" <surenb@google.com>,
	Michal Hocko <mhocko@suse.com>, Jann Horn <jannh@google.com>,
	Pedro Falcato <pfalcato@suse.de>,
	Baolin Wang <baolin.wang@linux.alibaba.com>,
	Nico Pache <nico.pache@linux.dev>,
	"Ryan Roberts" <ryan.roberts@arm.com>,
	Dev Jain <dev.jain@arm.com>, Barry Song <baohua@kernel.org>,
	Lance Yang <lance.yang@linux.dev>,
	Usama Arif <usama.arif@linux.dev>,
	Kiryl Shutsemau <kas@kernel.org>, <linux-mm@kvack.org>,
	<linux-kernel@vger.kernel.org>, Eliav Farber <farbere@amazon.com>
Subject: [PATCH v3 0/5] mm, uio: huge PFN mappings for /dev/mem and UIO
Date: Tue, 24 Nov 2026 13:15:05 +0000	[thread overview]
Message-ID: <20261124131510.38745-1-farbere@amazon.com> (raw)

/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



             reply	other threads:[~2026-11-24 13:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 13:15 Eliav Farber [this message]
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)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261124131510.38745-1-farbere@amazon.com \
    --to=farbere@amazon.com \
    --cc=akpm@linux-foundation.org \
    --cc=baohua@kernel.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=david@kernel.org \
    --cc=dev.jain@arm.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jannh@google.com \
    --cc=kas@kernel.org \
    --cc=lance.yang@linux.dev \
    --cc=liam@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=mhocko@suse.com \
    --cc=nico.pache@linux.dev \
    --cc=pfalcato@suse.de \
    --cc=rppt@kernel.org \
    --cc=ryan.roberts@arm.com \
    --cc=surenb@google.com \
    --cc=usama.arif@linux.dev \
    --cc=vbabka@kernel.org \
    --cc=ziy@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox