]> www.infradead.org Git - users/jedix/linux-maple.git/commit
mm/userfaultfd: fix uffd-wp handling for THP migration entries
authorDavid Hildenbrand <david@redhat.com>
Wed, 5 Apr 2023 16:02:35 +0000 (18:02 +0200)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 5 Apr 2023 23:01:37 +0000 (16:01 -0700)
commit0cd6f96e7e9b4f4f41c280ca46c413485f227d39
tree4bd443b905f4eba0aa4081594ae8f8ea53a8e453
parentde914896b6dfb0fde250767a6f43126d827a6ee9
mm/userfaultfd: fix uffd-wp handling for THP migration entries

Looks like what we fixed for hugetlb in commit 44f86392bdd1 ("mm/hugetlb:
fix uffd-wp handling for migration entries in
hugetlb_change_protection()") similarly applies to THP.

Setting/clearing uffd-wp on THP migration entries is not implemented
properly.  Further, while removing migration PMDs considers the uffd-wp
bit, inserting migration PMDs does not consider the uffd-wp bit.

We have to set/clear independently of the migration entry type in
change_huge_pmd() and properly copy the uffd-wp bit in
set_pmd_migration_entry().

Verified using a simple reproducer that triggers migration of a THP, that
the set_pmd_migration_entry() no longer loses the uffd-wp bit.

Link: https://lkml.kernel.org/r/20230405160236.587705-2-david@redhat.com
Fixes: f45ec5ff16a7 ("userfaultfd: wp: support swap and page migration")
Signed-off-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Cc: <stable@vger.kernel.org>
Cc: Muhammad Usama Anjum <usama.anjum@collabora.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/huge_memory.c