* + selftests-mm-add-tests-for-uffdio_move-of-a-uffd-protected-swap-entry.patch added to mm-hotfixes-unstable branch
@ 2026-09-27 21:01 Andrew Morton
0 siblings, 0 replies; 3+ messages in thread
From: Andrew Morton @ 2026-09-27 21:01 UTC (permalink / raw)
To: mm-commits, vbabka, surenb, shuah, rppt, peterx, mhocko, ljs,
liam, kas, david, aarcange, donggeunyoo.kernel, akpm
The patch titled
Subject: selftests/mm: add tests for UFFDIO_MOVE of a uffd-protected swap entry
has been added to the -mm mm-hotfixes-unstable branch. Its filename is
selftests-mm-add-tests-for-uffdio_move-of-a-uffd-protected-swap-entry.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/selftests-mm-add-tests-for-uffdio_move-of-a-uffd-protected-swap-entry.patch
This patch will later appear in the mm-hotfixes-unstable branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days
------------------------------------------------------
From: Donggeun Yoo <donggeunyoo.kernel@gmail.com>
Subject: selftests/mm: add tests for UFFDIO_MOVE of a uffd-protected swap entry
Date: Sat, 26 Sep 2026 21:41:45 +0900
Move a swapped-out page out of a write-protected or RWP-protected area
into a destination registered for missing faults only, and read pagemap
bit 57 at the destination. The destination was never protected, so the
bit must be clear.
Link: https://lore.kernel.org/20260926124145.2878520-3-donggeunyoo.kernel@gmail.com
Signed-off-by: Donggeun Yoo <donggeunyoo.kernel@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Assisted-by: LLM
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Peter Xu <peterx@redhat.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: David Hildenbrand <david@kernel.org>
Cc: Lorenzo Stoakes <ljs@kernel.org>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Kiryl Shutsemau <kas@kernel.org>
---
tools/testing/selftests/mm/uffd-unit-tests.c | 84 +++++++++++++++++
1 file changed, 84 insertions(+)
--- a/tools/testing/selftests/mm/uffd-unit-tests.c~selftests-mm-add-tests-for-uffdio_move-of-a-uffd-protected-swap-entry
+++ a/tools/testing/selftests/mm/uffd-unit-tests.c
@@ -2037,6 +2037,75 @@ static void uffd_move_pmd_split_test(uff
uffd_move_pmd_handle_fault);
}
+/*
+ * Moving a swapped-out page out of a write-protected or RWP-protected area
+ * must not carry the uffd bit into a destination registered for missing
+ * faults only: such a bit is never cleared afterwards, so pagemap keeps
+ * reporting the page as uffd-tracked.
+ *
+ * Needs a swap device; skipped if MADV_PAGEOUT cannot evict the page.
+ */
+static void uffd_move_swap_test_common(uffd_global_test_opts_t *gopts,
+ bool rwp)
+{
+ unsigned long page_size = gopts->page_size;
+ struct uffdio_move move = { };
+ int pagemap_fd;
+
+ if (rwp) {
+ if (uffd_register_rwp(gopts->uffd, gopts->area_src, page_size))
+ err("register src failure");
+ } else if (uffd_register(gopts->uffd, gopts->area_src, page_size,
+ false, true, false)) {
+ err("register src failure");
+ }
+ if (uffd_register(gopts->uffd, gopts->area_dst, page_size,
+ true, false, false))
+ err("register dst failure");
+
+ if (rwp)
+ rwprotect_range(gopts->uffd, (unsigned long)gopts->area_src,
+ page_size, true);
+ else
+ wp_range(gopts->uffd, (unsigned long)gopts->area_src,
+ page_size, true);
+
+ pagemap_fd = pagemap_open();
+ if (madvise(gopts->area_src, page_size, MADV_PAGEOUT))
+ err("MADV_PAGEOUT");
+ if (!pagemap_is_swapped(pagemap_fd, gopts->area_src)) {
+ uffd_test_skip("MADV_PAGEOUT did not swap the page; is swap enabled?");
+ goto out;
+ }
+
+ move.dst = (unsigned long)gopts->area_dst;
+ move.src = (unsigned long)gopts->area_src;
+ move.len = page_size;
+ if (ioctl(gopts->uffd, UFFDIO_MOVE, &move))
+ err("UFFDIO_MOVE");
+
+ if (pagemap_get_entry(pagemap_fd, gopts->area_dst) & PM_UFFD_WP)
+ uffd_test_fail("uffd bit moved into an area registered for missing faults only");
+ else
+ uffd_test_pass();
+out:
+ close(pagemap_fd);
+ uffd_unregister(gopts->uffd, gopts->area_src, page_size);
+ uffd_unregister(gopts->uffd, gopts->area_dst, page_size);
+}
+
+static void uffd_move_swap_wp_test(uffd_global_test_opts_t *gopts,
+ uffd_test_args_t *targs)
+{
+ uffd_move_swap_test_common(gopts, false);
+}
+
+static void uffd_move_swap_rwp_test(uffd_global_test_opts_t *gopts,
+ uffd_test_args_t *targs)
+{
+ uffd_move_swap_test_common(gopts, true);
+}
+
static bool
uffdio_verify_results(const char *name, int ret, int error, long result)
{
@@ -2360,6 +2429,21 @@ uffd_test_case_t uffd_tests[] = {
.test_case_ops = &uffd_move_test_pmd_case_ops,
},
{
+ .name = "move-swap-wp",
+ .uffd_fn = uffd_move_swap_wp_test,
+ .mem_targets = MEM_ANON,
+ .uffd_feature_required = UFFD_FEATURE_MOVE |
+ UFFD_FEATURE_PAGEFAULT_FLAG_WP,
+ .test_case_ops = &uffd_move_test_case_ops,
+ },
+ {
+ .name = "move-swap-rwp",
+ .uffd_fn = uffd_move_swap_rwp_test,
+ .mem_targets = MEM_ANON,
+ .uffd_feature_required = UFFD_FEATURE_MOVE | UFFD_FEATURE_RWP,
+ .test_case_ops = &uffd_move_test_case_ops,
+ },
+ {
.name = "wp-fork",
.uffd_fn = uffd_wp_fork_test,
.mem_targets = MEM_ALL,
_
Patches currently in -mm which might be from donggeunyoo.kernel@gmail.com are
userfaultfd-clear-the-inherited-uffd-bit-in-move_swap_pte.patch
selftests-mm-add-tests-for-uffdio_move-of-a-uffd-protected-swap-entry.patch
mm-damon-core-charge-only-the-part-of-a-region-the-filter-left.patch
mm-damon-tests-core-kunit-test-the-size-charged-for-a-filter-trimmed-region.patch
^ permalink raw reply [flat|nested] 3+ messages in thread
* + selftests-mm-add-tests-for-uffdio_move-of-a-uffd-protected-swap-entry.patch added to mm-hotfixes-unstable branch
@ 2026-09-27 21:39 Andrew Morton
0 siblings, 0 replies; 3+ messages in thread
From: Andrew Morton @ 2026-09-27 21:39 UTC (permalink / raw)
To: mm-commits, vbabka, surenb, shuah, rppt, peterx, mhocko, ljs,
liam, kas, david, aarcange, donggeunyoo.kernel, akpm
The patch titled
Subject: selftests/mm: add tests for UFFDIO_MOVE of a uffd-protected swap entry
has been added to the -mm mm-hotfixes-unstable branch. Its filename is
selftests-mm-add-tests-for-uffdio_move-of-a-uffd-protected-swap-entry.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/selftests-mm-add-tests-for-uffdio_move-of-a-uffd-protected-swap-entry.patch
This patch will later appear in the mm-hotfixes-unstable branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days
------------------------------------------------------
From: Donggeun Yoo <donggeunyoo.kernel@gmail.com>
Subject: selftests/mm: add tests for UFFDIO_MOVE of a uffd-protected swap entry
Date: Sat, 26 Sep 2026 21:41:45 +0900
Move a swapped-out page out of a write-protected or RWP-protected area
into a destination registered for missing faults only, and read pagemap
bit 57 at the destination. The destination was never protected, so the
bit must be clear.
Link: https://lore.kernel.org/20260926124145.2878520-3-donggeunyoo.kernel@gmail.com
Signed-off-by: Donggeun Yoo <donggeunyoo.kernel@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Assisted-by: LLM
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Peter Xu <peterx@redhat.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: David Hildenbrand <david@kernel.org>
Cc: Lorenzo Stoakes <ljs@kernel.org>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Kiryl Shutsemau <kas@kernel.org>
---
tools/testing/selftests/mm/uffd-unit-tests.c | 84 +++++++++++++++++
1 file changed, 84 insertions(+)
--- a/tools/testing/selftests/mm/uffd-unit-tests.c~selftests-mm-add-tests-for-uffdio_move-of-a-uffd-protected-swap-entry
+++ a/tools/testing/selftests/mm/uffd-unit-tests.c
@@ -2037,6 +2037,75 @@ static void uffd_move_pmd_split_test(uff
uffd_move_pmd_handle_fault);
}
+/*
+ * Moving a swapped-out page out of a write-protected or RWP-protected area
+ * must not carry the uffd bit into a destination registered for missing
+ * faults only: such a bit is never cleared afterwards, so pagemap keeps
+ * reporting the page as uffd-tracked.
+ *
+ * Needs a swap device; skipped if MADV_PAGEOUT cannot evict the page.
+ */
+static void uffd_move_swap_test_common(uffd_global_test_opts_t *gopts,
+ bool rwp)
+{
+ unsigned long page_size = gopts->page_size;
+ struct uffdio_move move = { };
+ int pagemap_fd;
+
+ if (rwp) {
+ if (uffd_register_rwp(gopts->uffd, gopts->area_src, page_size))
+ err("register src failure");
+ } else if (uffd_register(gopts->uffd, gopts->area_src, page_size,
+ false, true, false)) {
+ err("register src failure");
+ }
+ if (uffd_register(gopts->uffd, gopts->area_dst, page_size,
+ true, false, false))
+ err("register dst failure");
+
+ if (rwp)
+ rwprotect_range(gopts->uffd, (unsigned long)gopts->area_src,
+ page_size, true);
+ else
+ wp_range(gopts->uffd, (unsigned long)gopts->area_src,
+ page_size, true);
+
+ pagemap_fd = pagemap_open();
+ if (madvise(gopts->area_src, page_size, MADV_PAGEOUT))
+ err("MADV_PAGEOUT");
+ if (!pagemap_is_swapped(pagemap_fd, gopts->area_src)) {
+ uffd_test_skip("MADV_PAGEOUT did not swap the page; is swap enabled?");
+ goto out;
+ }
+
+ move.dst = (unsigned long)gopts->area_dst;
+ move.src = (unsigned long)gopts->area_src;
+ move.len = page_size;
+ if (ioctl(gopts->uffd, UFFDIO_MOVE, &move))
+ err("UFFDIO_MOVE");
+
+ if (pagemap_get_entry(pagemap_fd, gopts->area_dst) & PM_UFFD_WP)
+ uffd_test_fail("uffd bit moved into an area registered for missing faults only");
+ else
+ uffd_test_pass();
+out:
+ close(pagemap_fd);
+ uffd_unregister(gopts->uffd, gopts->area_src, page_size);
+ uffd_unregister(gopts->uffd, gopts->area_dst, page_size);
+}
+
+static void uffd_move_swap_wp_test(uffd_global_test_opts_t *gopts,
+ uffd_test_args_t *targs)
+{
+ uffd_move_swap_test_common(gopts, false);
+}
+
+static void uffd_move_swap_rwp_test(uffd_global_test_opts_t *gopts,
+ uffd_test_args_t *targs)
+{
+ uffd_move_swap_test_common(gopts, true);
+}
+
static bool
uffdio_verify_results(const char *name, int ret, int error, long result)
{
@@ -2360,6 +2429,21 @@ uffd_test_case_t uffd_tests[] = {
.test_case_ops = &uffd_move_test_pmd_case_ops,
},
{
+ .name = "move-swap-wp",
+ .uffd_fn = uffd_move_swap_wp_test,
+ .mem_targets = MEM_ANON,
+ .uffd_feature_required = UFFD_FEATURE_MOVE |
+ UFFD_FEATURE_PAGEFAULT_FLAG_WP,
+ .test_case_ops = &uffd_move_test_case_ops,
+ },
+ {
+ .name = "move-swap-rwp",
+ .uffd_fn = uffd_move_swap_rwp_test,
+ .mem_targets = MEM_ANON,
+ .uffd_feature_required = UFFD_FEATURE_MOVE | UFFD_FEATURE_RWP,
+ .test_case_ops = &uffd_move_test_case_ops,
+ },
+ {
.name = "wp-fork",
.uffd_fn = uffd_wp_fork_test,
.mem_targets = MEM_ALL,
_
Patches currently in -mm which might be from donggeunyoo.kernel@gmail.com are
userfaultfd-clear-the-inherited-uffd-bit-in-move_swap_pte.patch
selftests-mm-add-tests-for-uffdio_move-of-a-uffd-protected-swap-entry.patch
mm-damon-core-charge-only-the-part-of-a-region-the-filter-left.patch
mm-damon-tests-core-kunit-test-the-size-charged-for-a-filter-trimmed-region.patch
^ permalink raw reply [flat|nested] 3+ messages in thread
* + selftests-mm-add-tests-for-uffdio_move-of-a-uffd-protected-swap-entry.patch added to mm-hotfixes-unstable branch
@ 2026-10-04 20:08 Andrew Morton
0 siblings, 0 replies; 3+ messages in thread
From: Andrew Morton @ 2026-10-04 20:08 UTC (permalink / raw)
To: mm-commits, vbabka, surenb, shuah, rppt, peterx, mhocko, ljs,
liam, kas, david, aarcange, donggeunyoo.kernel, akpm
The patch titled
Subject: selftests/mm: add tests for UFFDIO_MOVE of a uffd-protected swap entry
has been added to the -mm mm-hotfixes-unstable branch. Its filename is
selftests-mm-add-tests-for-uffdio_move-of-a-uffd-protected-swap-entry.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/selftests-mm-add-tests-for-uffdio_move-of-a-uffd-protected-swap-entry.patch
This patch will later appear in the mm-hotfixes-unstable branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days
------------------------------------------------------
From: Donggeun Yoo <donggeunyoo.kernel@gmail.com>
Subject: selftests/mm: add tests for UFFDIO_MOVE of a uffd-protected swap entry
Date: Sat, 3 Oct 2026 19:30:30 +0900
Move a swapped-out page out of a write-protected or RWP-protected area into
a destination registered for missing faults only, and read pagemap bit 57
at the destination. The destination was never protected, so the bit must
be clear.
Link: https://lore.kernel.org/20261003103030.63380-3-donggeunyoo.kernel@gmail.com
Signed-off-by: Donggeun Yoo <donggeunyoo.kernel@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Assisted-by: LLM
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Peter Xu <peterx@redhat.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: David Hildenbrand <david@kernel.org>
Cc: Lorenzo Stoakes <ljs@kernel.org>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Kiryl Shutsemau <kas@kernel.org>
---
tools/testing/selftests/mm/uffd-unit-tests.c | 84 +++++++++++++++++
1 file changed, 84 insertions(+)
--- a/tools/testing/selftests/mm/uffd-unit-tests.c~selftests-mm-add-tests-for-uffdio_move-of-a-uffd-protected-swap-entry
+++ a/tools/testing/selftests/mm/uffd-unit-tests.c
@@ -2037,6 +2037,75 @@ static void uffd_move_pmd_split_test(uff
uffd_move_pmd_handle_fault);
}
+/*
+ * Moving a swapped-out page out of a write-protected or RWP-protected area
+ * must not carry the uffd bit into a destination registered for missing
+ * faults only: such a bit is never cleared afterwards, so pagemap keeps
+ * reporting the page as uffd-tracked.
+ *
+ * Needs a swap device; skipped if MADV_PAGEOUT cannot evict the page.
+ */
+static void uffd_move_swap_test_common(uffd_global_test_opts_t *gopts,
+ bool rwp)
+{
+ unsigned long page_size = gopts->page_size;
+ struct uffdio_move move = {
+ .dst = (unsigned long)gopts->area_dst,
+ .src = (unsigned long)gopts->area_src,
+ .len = page_size,
+ };
+ int pagemap_fd = pagemap_open();
+
+ if (rwp) {
+ if (uffd_register_rwp(gopts->uffd, gopts->area_src, page_size))
+ err("register src failure");
+ rwprotect_range(gopts->uffd, (unsigned long)gopts->area_src,
+ page_size, true);
+ } else {
+ if (uffd_register(gopts->uffd, gopts->area_src, page_size,
+ false, true, false))
+ err("register src failure");
+ wp_range(gopts->uffd, (unsigned long)gopts->area_src,
+ page_size, true);
+ }
+ if (uffd_register(gopts->uffd, gopts->area_dst, page_size,
+ true, false, false))
+ err("register dst failure");
+
+ if (madvise(gopts->area_src, page_size, MADV_PAGEOUT))
+ err("MADV_PAGEOUT");
+ if (!pagemap_is_swapped(pagemap_fd, gopts->area_src)) {
+ uffd_test_skip("MADV_PAGEOUT did not swap the page; is swap enabled?");
+ goto out;
+ }
+
+ if (ioctl(gopts->uffd, UFFDIO_MOVE, &move)) {
+ uffd_test_fail("UFFDIO_MOVE failed: %s", strerror(errno));
+ goto out;
+ }
+
+ if (pagemap_get_entry(pagemap_fd, gopts->area_dst) & PM_UFFD_WP)
+ uffd_test_fail("uffd bit moved into an area registered for missing faults only");
+ else
+ uffd_test_pass();
+out:
+ close(pagemap_fd);
+ uffd_unregister(gopts->uffd, gopts->area_src, page_size);
+ uffd_unregister(gopts->uffd, gopts->area_dst, page_size);
+}
+
+static void uffd_move_swap_wp_test(uffd_global_test_opts_t *gopts,
+ uffd_test_args_t *targs)
+{
+ uffd_move_swap_test_common(gopts, false);
+}
+
+static void uffd_move_swap_rwp_test(uffd_global_test_opts_t *gopts,
+ uffd_test_args_t *targs)
+{
+ uffd_move_swap_test_common(gopts, true);
+}
+
static bool
uffdio_verify_results(const char *name, int ret, int error, long result)
{
@@ -2360,6 +2429,21 @@ uffd_test_case_t uffd_tests[] = {
.test_case_ops = &uffd_move_test_pmd_case_ops,
},
{
+ .name = "move-swap-wp",
+ .uffd_fn = uffd_move_swap_wp_test,
+ .mem_targets = MEM_ANON,
+ .uffd_feature_required = UFFD_FEATURE_MOVE |
+ UFFD_FEATURE_PAGEFAULT_FLAG_WP,
+ .test_case_ops = &uffd_move_test_case_ops,
+ },
+ {
+ .name = "move-swap-rwp",
+ .uffd_fn = uffd_move_swap_rwp_test,
+ .mem_targets = MEM_ANON,
+ .uffd_feature_required = UFFD_FEATURE_MOVE | UFFD_FEATURE_RWP,
+ .test_case_ops = &uffd_move_test_case_ops,
+ },
+ {
.name = "wp-fork",
.uffd_fn = uffd_wp_fork_test,
.mem_targets = MEM_ALL,
_
Patches currently in -mm which might be from donggeunyoo.kernel@gmail.com are
userfaultfd-clear-the-inherited-uffd-bit-in-move_swap_pte.patch
selftests-mm-add-tests-for-uffdio_move-of-a-uffd-protected-swap-entry.patch
mm-damon-core-charge-only-the-part-of-a-region-the-filter-left.patch
mm-damon-tests-core-kunit-test-the-size-charged-for-a-filter-trimmed-region.patch
mm-damon-core-prevent-size-quota-overflow-in-the-temporal-goal-tuner.patch
mm-damon-tests-core-kunit-test-the-temporal-tuners-size-quota-conversion.patch
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-04 20:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-27 21:01 + selftests-mm-add-tests-for-uffdio_move-of-a-uffd-protected-swap-entry.patch added to mm-hotfixes-unstable branch Andrew Morton
-- strict thread matches above, loose matches on Subject: below --
2026-09-27 21:39 Andrew Morton
2026-10-04 20:08 Andrew Morton
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.