]> git.ipfire.org Git - thirdparty/linux.git/commit
mm/huge_memory: preserve pmd_swp_uffd_wp on device-private PMD downgrade
authorKiryl Shutsemau (Meta) <kas@kernel.org>
Fri, 29 May 2026 17:23:28 +0000 (18:23 +0100)
committerAndrew Morton <akpm@linux-foundation.org>
Tue, 9 Jun 2026 01:21:29 +0000 (18:21 -0700)
commitf7e2c21bd1f57cd5350eecdfdb5d6025ca6afbab
tree900856bd4ded997e59bd7e296999d638f1ced308
parente92d92bbafb264dc0518d52b846a3c07ed8d523f
mm/huge_memory: preserve pmd_swp_uffd_wp on device-private PMD downgrade

change_non_present_huge_pmd() rewrites a writable device-private PMD swap
entry into a readable one without carrying pmd_swp_uffd_wp() across.  The
PTE-level change_softleaf_pte() does this correctly; mirror that here,
matching what copy_huge_pmd() does for the fork path.  Without the carry,
a plain mprotect() over a UFFD_WP-marked device-private THP strips the bit
and the trap is bypassed on swap-in.

Link: https://lore.kernel.org/20260529172331.356655-5-kas@kernel.org
Fixes: 368076f52ebe ("mm/huge_memory: add device-private THP support to PMD operations")
Signed-off-by: Kiryl Shutsemau <kas@kernel.org>
Reported-by: Sashiko AI review <sashiko-bot@kernel.org>
Reviewed-by: Balbir Singh <balbirs@nvidia.com>
Cc: David Hildenbrand <david@kernel.org>
Cc: Lorenzo Stoakes <ljs@kernel.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Peter Xu <peterx@redhat.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/huge_memory.c