When executing the uffd-unit-test, the "move-pmd on anon" test will fail on aarch64+64k with a segmentation fault because the initial allocated memory region is too small. This only happens with the move-pmd* tests because the architecture base page size is still utilized even though the memory region is specific to the size indicated by the pmd. Patch 9f5c2aec3388 ("selftests/mm: fix uffd move-pmd test crash on 64K base page systems") implements an initial fix to the segmentation fault by skipping the test if the allocated memory region is not large enough for the number of pages x page size requested. But as this will skip over the aarch64+64k pmd tests, this patch is intended to resolve the problem with 64k pages by scaling up the initial allocated memory region subject to base page size of the architecture. Fixes: a2bf6a9ca805 ("selftests/mm: add UFFDIO_MOVE ioctl test") Signed-off-by: John J. Coleman --- I made some basic revisions, but as I am looking to gauge opinions on this email chain I am replying to the chain, I apologize if this is an inconvenience. Changes in v2: * Since psize() is included from vm_util.h through uffd-common.h, PAGE_SIZE macro removed. * Added UL suffix to ensure integer is treated as unsigned long. tools/testing/selftests/mm/uffd-unit-tests.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/mm/uffd-unit-tests.c b/tools/testing/selftests/mm/uffd-unit-tests.c index 2a97ba1d6feb1b35d6281449fd1917793a64fab1..3be227ed8d413f6e67e475862aba10ce13221446 100644 --- a/tools/testing/selftests/mm/uffd-unit-tests.c +++ b/tools/testing/selftests/mm/uffd-unit-tests.c @@ -13,8 +13,13 @@ #ifdef __NR_userfaultfd -/* The unit test doesn't need a large or random size, make it 32MB for now */ -#define UFFD_TEST_MEM_SIZE (32UL << 20) +/* + * The unit test does not need a large or random size, but the allocation size + * needs to scale with base page size per architecture otherwise pmd alignment + * tests will fail for architectures like aarch64+64k. For standard 4k pages, + * this will allocate 64MiB, while allocating 1GiB for 64k page sizes. + */ +#define UFFD_TEST_MEM_SIZE (psize() * (16UL << 10)) #define MEM_ANON BIT_ULL(0) #define MEM_SHMEM BIT_ULL(1) -- 2.56.0