* [PATCH] selftests/mm: fix uffd move-pmd test crash on 64K base page systems
@ 2026-10-11 16:35 Zenghui Yu
2026-10-12 6:13 ` Sarthak Sharma
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Zenghui Yu @ 2026-10-11 16:35 UTC (permalink / raw)
To: linux-mm, linux-kernel
Cc: akpm, rppt, peterx, david, ljs, liam, vbabka, surenb, mhocko,
Zenghui Yu (Huawei)
From: "Zenghui Yu (Huawei)" <zenghui.yu@linux.dev>
uffd_move_pmd_test()/uffd_move_test_common() splits the test area into
chunks of chunk_size and moves them one by one. On arm64 with 64K base
pages the chunk_size (read_pmd_pagesize()) is 512MB, which is larger than
the whole 32MB (UFFD_TEST_MEM_SIZE) test area:
step_count = nr_pages / (chunk_size / page_size) == 0
Because chunk_size > page_size, the test then aligns both areas up to
512MB, which points far outside of the 32MB mappings, and decrements
step_count, which underflows to ULONG_MAX. The verification loop then
runs away and the first dereference of area_src faults with a SIGSEGV.
Skip the test when a single chunk cannot fit into the test area.
Fixes: a2bf6a9ca805 ("selftests/mm: add UFFDIO_MOVE ioctl test")
Signed-off-by: Zenghui Yu (Huawei) <zenghui.yu@linux.dev>
---
tools/testing/selftests/mm/uffd-unit-tests.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/tools/testing/selftests/mm/uffd-unit-tests.c b/tools/testing/selftests/mm/uffd-unit-tests.c
index ef9b3956bdcf..2a97ba1d6feb 100644
--- a/tools/testing/selftests/mm/uffd-unit-tests.c
+++ b/tools/testing/selftests/mm/uffd-unit-tests.c
@@ -1937,6 +1937,11 @@ uffd_move_test_common(uffd_global_test_opts_t *gopts,
args.gopts = gopts;
+ if (chunk_size > gopts->nr_pages * gopts->page_size) {
+ uffd_test_skip("chunk size does not fit in the test area");
+ return;
+ }
+
/* Prevent source pages from being mapped more than once */
if (madvise(gopts->area_src, gopts->nr_pages * gopts->page_size, MADV_DONTFORK))
err("madvise(MADV_DONTFORK) failure");
--
2.53.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH] selftests/mm: fix uffd move-pmd test crash on 64K base page systems
2026-10-11 16:35 [PATCH] selftests/mm: fix uffd move-pmd test crash on 64K base page systems Zenghui Yu
@ 2026-10-12 6:13 ` Sarthak Sharma
2026-10-12 12:12 ` Jose A. Perez de Azpillaga
2026-10-13 7:39 ` David Hildenbrand (Arm)
2 siblings, 0 replies; 6+ messages in thread
From: Sarthak Sharma @ 2026-10-12 6:13 UTC (permalink / raw)
To: Zenghui Yu, linux-mm, linux-kernel
Cc: akpm, rppt, peterx, david, ljs, liam, vbabka, surenb, mhocko
Hi Zenghui!
On 10/11/26 10:05 PM, Zenghui Yu wrote:
> From: "Zenghui Yu (Huawei)" <zenghui.yu@linux.dev>
>
> uffd_move_pmd_test()/uffd_move_test_common() splits the test area into
> chunks of chunk_size and moves them one by one. On arm64 with 64K base
> pages the chunk_size (read_pmd_pagesize()) is 512MB, which is larger than
> the whole 32MB (UFFD_TEST_MEM_SIZE) test area:
>
> step_count = nr_pages / (chunk_size / page_size) == 0
>
> Because chunk_size > page_size, the test then aligns both areas up to
> 512MB, which points far outside of the 32MB mappings, and decrements
> step_count, which underflows to ULONG_MAX. The verification loop then
> runs away and the first dereference of area_src faults with a SIGSEGV.
>
> Skip the test when a single chunk cannot fit into the test area.
>
> Fixes: a2bf6a9ca805 ("selftests/mm: add UFFDIO_MOVE ioctl test")
> Signed-off-by: Zenghui Yu (Huawei) <zenghui.yu@linux.dev>
> ---
I run the test on a 64k kernel. Before the patch, a segmentation fault
occurred, which was fixed by the patch. So:
Tested-by: Sarthak Sharma <sarthak.sharma@arm.com>
Though Sashiko has a few nits [1] you might take a look at.
[1]
https://sashiko.dev/#/patchset/20261011163527.95988-1-zenghui.yu%40linux.dev
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] selftests/mm: fix uffd move-pmd test crash on 64K base page systems
2026-10-11 16:35 [PATCH] selftests/mm: fix uffd move-pmd test crash on 64K base page systems Zenghui Yu
2026-10-12 6:13 ` Sarthak Sharma
@ 2026-10-12 12:12 ` Jose A. Perez de Azpillaga
2026-10-13 7:39 ` David Hildenbrand (Arm)
2 siblings, 0 replies; 6+ messages in thread
From: Jose A. Perez de Azpillaga @ 2026-10-12 12:12 UTC (permalink / raw)
To: Zenghui Yu
Cc: linux-mm, linux-kernel, akpm, rppt, peterx, david, ljs, liam,
vbabka, surenb, mhocko
On Mon, Oct 12, 2026 at 12:35:27AM +0800, Zenghui Yu wrote:
> From: "Zenghui Yu (Huawei)" <zenghui.yu@linux.dev>
>
> uffd_move_pmd_test()/uffd_move_test_common() splits the test area into
> chunks of chunk_size and moves them one by one. On arm64 with 64K base
> pages the chunk_size (read_pmd_pagesize()) is 512MB, which is larger than
> the whole 32MB (UFFD_TEST_MEM_SIZE) test area:
>
> step_count = nr_pages / (chunk_size / page_size) == 0
>
> Because chunk_size > page_size, the test then aligns both areas up to
> 512MB, which points far outside of the 32MB mappings, and decrements
> step_count, which underflows to ULONG_MAX. The verification loop then
> runs away and the first dereference of area_src faults with a SIGSEGV.
>
> Skip the test when a single chunk cannot fit into the test area.
>
> Fixes: a2bf6a9ca805 ("selftests/mm: add UFFDIO_MOVE ioctl test")
> Signed-off-by: Zenghui Yu (Huawei) <zenghui.yu@linux.dev>
> ---
> tools/testing/selftests/mm/uffd-unit-tests.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/tools/testing/selftests/mm/uffd-unit-tests.c b/tools/testing/selftests/mm/uffd-unit-tests.c
> index ef9b3956bdcf..2a97ba1d6feb 100644
> --- a/tools/testing/selftests/mm/uffd-unit-tests.c
> +++ b/tools/testing/selftests/mm/uffd-unit-tests.c
> @@ -1937,6 +1937,11 @@ uffd_move_test_common(uffd_global_test_opts_t *gopts,
>
> args.gopts = gopts;
>
> + if (chunk_size > gopts->nr_pages * gopts->page_size) {
> + uffd_test_skip("chunk size does not fit in the test area");
> + return;
> + }
> +
> /* Prevent source pages from being mapped more than once */
> if (madvise(gopts->area_src, gopts->nr_pages * gopts->page_size, MADV_DONTFORK))
> err("madvise(MADV_DONTFORK) failure");
> --
> 2.53.0
>
>
LGTM.
Reviewed-by: Jose A. Perez de Azpillaga <azpijr@gmail.com>
--
cheers,
jose a. p-a
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] selftests/mm: fix uffd move-pmd test crash on 64K base page systems
2026-10-11 16:35 [PATCH] selftests/mm: fix uffd move-pmd test crash on 64K base page systems Zenghui Yu
2026-10-12 6:13 ` Sarthak Sharma
2026-10-12 12:12 ` Jose A. Perez de Azpillaga
@ 2026-10-13 7:39 ` David Hildenbrand (Arm)
2026-10-13 10:33 ` Mike Rapoport
2 siblings, 1 reply; 6+ messages in thread
From: David Hildenbrand (Arm) @ 2026-10-13 7:39 UTC (permalink / raw)
To: Zenghui Yu, linux-mm, linux-kernel
Cc: akpm, rppt, peterx, ljs, liam, vbabka, surenb, mhocko
On 10/11/26 18:35, Zenghui Yu wrote:
> From: "Zenghui Yu (Huawei)" <zenghui.yu@linux.dev>
>
> uffd_move_pmd_test()/uffd_move_test_common() splits the test area into
> chunks of chunk_size and moves them one by one. On arm64 with 64K base
> pages the chunk_size (read_pmd_pagesize()) is 512MB, which is larger than
> the whole 32MB (UFFD_TEST_MEM_SIZE) test area:
>
> step_count = nr_pages / (chunk_size / page_size) == 0
>
> Because chunk_size > page_size, the test then aligns both areas up to
> 512MB, which points far outside of the 32MB mappings, and decrements
> step_count, which underflows to ULONG_MAX. The verification loop then
> runs away and the first dereference of area_src faults with a SIGSEGV.
>
> Skip the test when a single chunk cannot fit into the test area.
That leaves 64k untested, though? Why not adjust the chunk size accordingly?
--
Cheers,
David
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] selftests/mm: fix uffd move-pmd test crash on 64K base page systems
2026-10-13 7:39 ` David Hildenbrand (Arm)
@ 2026-10-13 10:33 ` Mike Rapoport
2026-10-13 11:46 ` David Hildenbrand (Arm)
0 siblings, 1 reply; 6+ messages in thread
From: Mike Rapoport @ 2026-10-13 10:33 UTC (permalink / raw)
To: David Hildenbrand (Arm)
Cc: Zenghui Yu, linux-mm, linux-kernel, akpm, peterx, ljs, liam,
vbabka, surenb, mhocko
On Tue, Oct 13, 2026 at 09:39:54AM +0200, David Hildenbrand (Arm) wrote:
> On 10/11/26 18:35, Zenghui Yu wrote:
> > From: "Zenghui Yu (Huawei)" <zenghui.yu@linux.dev>
> >
> > uffd_move_pmd_test()/uffd_move_test_common() splits the test area into
> > chunks of chunk_size and moves them one by one. On arm64 with 64K base
> > pages the chunk_size (read_pmd_pagesize()) is 512MB, which is larger than
> > the whole 32MB (UFFD_TEST_MEM_SIZE) test area:
> >
> > step_count = nr_pages / (chunk_size / page_size) == 0
> >
> > Because chunk_size > page_size, the test then aligns both areas up to
> > 512MB, which points far outside of the 32MB mappings, and decrements
> > step_count, which underflows to ULONG_MAX. The verification loop then
> > runs away and the first dereference of area_src faults with a SIGSEGV.
> >
> > Skip the test when a single chunk cannot fit into the test area.
>
> That leaves 64k untested, though? Why not adjust the chunk size accordingly?
To test anything PMD on arm64 with 64k pages we need to adjust
UFFD_TEST_MEM_SIZE to have at least 4 pages, i.e 2G :)
Maybe we want UFFD_TEST_MEM_SIZE to scale with the page size?
> --
> Cheers,
>
> David
--
Sincerely yours,
Mike.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] selftests/mm: fix uffd move-pmd test crash on 64K base page systems
2026-10-13 10:33 ` Mike Rapoport
@ 2026-10-13 11:46 ` David Hildenbrand (Arm)
0 siblings, 0 replies; 6+ messages in thread
From: David Hildenbrand (Arm) @ 2026-10-13 11:46 UTC (permalink / raw)
To: Mike Rapoport
Cc: Zenghui Yu, linux-mm, linux-kernel, akpm, peterx, ljs, liam,
vbabka, surenb, mhocko
On 10/13/26 12:33, Mike Rapoport wrote:
> On Tue, Oct 13, 2026 at 09:39:54AM +0200, David Hildenbrand (Arm) wrote:
>> On 10/11/26 18:35, Zenghui Yu wrote:
>>> From: "Zenghui Yu (Huawei)" <zenghui.yu@linux.dev>
>>>
>>> uffd_move_pmd_test()/uffd_move_test_common() splits the test area into
>>> chunks of chunk_size and moves them one by one. On arm64 with 64K base
>>> pages the chunk_size (read_pmd_pagesize()) is 512MB, which is larger than
>>> the whole 32MB (UFFD_TEST_MEM_SIZE) test area:
>>>
>>> step_count = nr_pages / (chunk_size / page_size) == 0
>>>
>>> Because chunk_size > page_size, the test then aligns both areas up to
>>> 512MB, which points far outside of the 32MB mappings, and decrements
>>> step_count, which underflows to ULONG_MAX. The verification loop then
>>> runs away and the first dereference of area_src faults with a SIGSEGV.
>>>
>>> Skip the test when a single chunk cannot fit into the test area.
>>
>> That leaves 64k untested, though? Why not adjust the chunk size accordingly?
>
> To test anything PMD on arm64 with 64k pages we need to adjust
> UFFD_TEST_MEM_SIZE to have at least 4 pages, i.e 2G :)
>
> Maybe we want UFFD_TEST_MEM_SIZE to scale with the page size?
That was my thought. If you have 64k you better also have plenty of memory :)
--
Cheers,
David
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-10-13 11:46 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-11 16:35 [PATCH] selftests/mm: fix uffd move-pmd test crash on 64K base page systems Zenghui Yu
2026-10-12 6:13 ` Sarthak Sharma
2026-10-12 12:12 ` Jose A. Perez de Azpillaga
2026-10-13 7:39 ` David Hildenbrand (Arm)
2026-10-13 10:33 ` Mike Rapoport
2026-10-13 11:46 ` David Hildenbrand (Arm)
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.