From: Max Boone <mboone@akamai.com>
To: Andrew Morton <akpm@linux-foundation.org>,
David Hildenbrand <david@kernel.org>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
"Liam R . Howlett" <Liam.Howlett@oracle.com>,
Vlastimil Babka <vbabka@suse.cz>, Mike Rapoport <rppt@kernel.org>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>,
Alex Williamson <alex@shazbot.org>,
linux-mm@kvack.org, kvm@vger.kernel.org,
linux-kernel@vger.kernel.org, Max Tottenham <mtottenh@akamai.com>,
Josh Hunt <johunt@akamai.com>, Matt Pelland <mpelland@akamai.com>,
Max Boone <mboone@akamai.com>
Subject: [RFC 0/1] Avoid pagewalk hugepage-split race with VFIO DMA set
Date: Mon, 9 Mar 2026 18:49:48 +0100 [thread overview]
Message-ID: <20260309174949.2514565-1-mboone@akamai.com> (raw)
A kernel BUG can be triggered when /proc/$PID/numa_maps reads are
hammered by one process, while said $PID is setting up DMA for large
1G-aligned memory mapped BARs.
The 1G-aligned memory mapped BARs get set up as PUD-order PFNMAPs. When
the generic page walker (mm/pagewalk.c) gets to the PUD table entry of
the memory mapped BAR in the walk_pmd_range function, it tries to
split it by:
1. deleting the PUD entry by calling split_huge_pud
2. checking whether `pud_none` is true to go to `again`
if (walk->vma)
split_huge_pud(walk->vma, pud, addr);
...
if (pud_none(*pud))
goto again;
3. if has_install is set, it calls __pmd_alloc and further descends
into walk_pmd_range
again:
next = pud_addr_end(addr, end);
if (pud_none(*pud)) {
if (has_install)
err = __pmd_alloc(walk->mm, pud, addr);
When VFIO is setting up DMA, the PUD entry can get reinstalled between the
split_huge_pud call and the pud_none check to goto again. In such
case the walk continues to the PMD-level and an illegal read happens.
As a mitigation, I propose to skip splitting the PMD and PUD entries
that are marked as special in the walker, which are mappings that do not
wish to be associated with a "struct page". The only occurences of these
entries I found were the vfio pci and nvgrace pfnmap mappings, which do
not behave like regular memory.
For a reproduction, the `vfio-mmap-bar.py` script repeatedly DMA-maps a
1G-aligned BAR and can be used to reproduce this bug:
- https://github.com/akamaxb/repro-vfio-page-walk-race.git
Run the `vfio-mmap-bar.py` script with the device you want to passthrough,
and in the mean time, cat the `/proc/$PID/numa_maps` of that process repeatedly
in a while loop. This caused the `numa_maps` read to crash on an illegal read,
when testing it against a 128GB-sized 2nd BAR of a NVIDIA Blackwell 6000 GPU.
Signed-off-by: Max Boone <mboone@akamai.com>
Signed-off-by: Max Tottenham <mtottenh@akamai.com>
Max Boone (1):
mm/pagewalk: don't split device-backed huge pfnmaps
mm/pagewalk.c | 24 ++++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)
--
2.34.1
next reply other threads:[~2026-03-09 17:51 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-09 17:49 Max Boone [this message]
2026-03-09 17:49 ` [RFC 1/1] mm/pagewalk: don't split device-backed huge pfnmaps Max Boone
2026-03-09 20:19 ` David Hildenbrand (Arm)
2026-03-09 22:47 ` Boone, Max
2026-03-09 23:02 ` Boone, Max
2026-03-10 9:11 ` David Hildenbrand (Arm)
2026-03-10 11:38 ` Boone, Max
2026-03-10 15:19 ` David Hildenbrand (Arm)
2026-03-11 9:42 ` Boone, Max
2026-03-11 9:59 ` David Hildenbrand (Arm)
2026-03-11 10:34 ` Boone, Max
2026-03-11 10:45 ` David Hildenbrand (Arm)
2026-03-11 11:14 ` Boone, Max
2026-03-11 11:59 ` David Hildenbrand (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=20260309174949.2514565-1-mboone@akamai.com \
--to=mboone@akamai.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=alex@shazbot.org \
--cc=david@kernel.org \
--cc=johunt@akamai.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=mhocko@suse.com \
--cc=mpelland@akamai.com \
--cc=mtottenh@akamai.com \
--cc=rppt@kernel.org \
--cc=surenb@google.com \
--cc=vbabka@suse.cz \
/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