On 02/05/2024 23:39, Jeff Xu wrote: > On Thu, May 2, 2024 at 4:24 AM Ryan Roberts <ryan.roberts@xxxxxxx> wrote: >> >> On 15/04/2024 17:35, jeffxu@xxxxxxxxxxxx wrote: >>> From: Jeff Xu <jeffxu@xxxxxxxxxxxx> >>> >>> selftest for memory sealing change in mmap() and mseal(). >>> >>> Signed-off-by: Jeff Xu <jeffxu@xxxxxxxxxxxx> >>> --- >>> tools/testing/selftests/mm/.gitignore | 1 + >>> tools/testing/selftests/mm/Makefile | 1 + >>> tools/testing/selftests/mm/mseal_test.c | 1836 +++++++++++++++++++++++ >>> 3 files changed, 1838 insertions(+) >>> create mode 100644 tools/testing/selftests/mm/mseal_test.c >>> >>> diff --git a/tools/testing/selftests/mm/.gitignore b/tools/testing/selftests/mm/.gitignore >>> index d26e962f2ac4..98eaa4590f11 100644 >>> --- a/tools/testing/selftests/mm/.gitignore >>> +++ b/tools/testing/selftests/mm/.gitignore >>> @@ -47,3 +47,4 @@ mkdirty >>> va_high_addr_switch >>> hugetlb_fault_after_madv >>> hugetlb_madv_vs_map >>> +mseal_test >>> diff --git a/tools/testing/selftests/mm/Makefile b/tools/testing/selftests/mm/Makefile >>> index eb5f39a2668b..95d10fe1b3c1 100644 >>> --- a/tools/testing/selftests/mm/Makefile >>> +++ b/tools/testing/selftests/mm/Makefile >>> @@ -59,6 +59,7 @@ TEST_GEN_FILES += mlock2-tests >>> TEST_GEN_FILES += mrelease_test >>> TEST_GEN_FILES += mremap_dontunmap >>> TEST_GEN_FILES += mremap_test >>> +TEST_GEN_FILES += mseal_test >>> TEST_GEN_FILES += on-fault-limit >>> TEST_GEN_FILES += pagemap_ioctl >>> TEST_GEN_FILES += thuge-gen >>> diff --git a/tools/testing/selftests/mm/mseal_test.c b/tools/testing/selftests/mm/mseal_test.c >>> new file mode 100644 >>> index 000000000000..06c780d1d8e5 >>> --- /dev/null >>> +++ b/tools/testing/selftests/mm/mseal_test.c >>> @@ -0,0 +1,1836 @@ >>> +// SPDX-License-Identifier: GPL-2.0 >>> +#define _GNU_SOURCE >>> +#include <sys/mman.h> >> >> I'm afraid this is causing a build error on our CI, and as a result we are not >> running any mm selftests currently. >> >> The error is here: >> >> CC mseal_test >> mseal_test.c: In function ‘test_seal_mremap_move_dontunmap’: >> mseal_test.c:1469:50: error: ‘MREMAP_DONTUNMAP’ undeclared (first use in this >> function) >> 1469 | ret2 = mremap(ptr, size, size, MREMAP_MAYMOVE | MREMAP_DONTUNMAP, 0); >> | ^~~~~~~~~~~~~~~~ >> mseal_test.c:1469:50: note: each undeclared identifier is reported only once for >> each function it appears in >> mseal_test.c: In function ‘test_seal_mremap_move_dontunmap_anyaddr’: >> mseal_test.c:1501:50: error: ‘MREMAP_DONTUNMAP’ undeclared (first use in this >> function) >> 1501 | ret2 = mremap(ptr, size, size, MREMAP_MAYMOVE | MREMAP_DONTUNMAP, >> | ^~~~~~~~~~~~~~~~ >> >> >> And I think the reason is due to our CI's toolchain's sys/mman.h not including >> linux/mman.h where MREMAP_DONTUNMAP is defined. >> >> I think the fix is to explicitly #include <linux/mman.h>, as a number of other >> mm selftests do. >> > When I tried to build with aarch64-linux-gnu-gcc, this passed. > > aarch64-linux-gnu-gcc -I ../../../../usr/include -DDEBUG -O3 > -DDEBUG -O3 mseal_test.c -o mseal_test -lm -Wall Its the same on my local system; I'm told our CI is using GCC 10, which I suspect makes the difference. > > I don't have the exact environment to repro the issue and verify the fix. > I will send a patch with the linux/mman.h. > > I will probably need some help to verify the fix on arm build, Ryan, > could you help with this ? I'll pass this on to our CI folks, and hopefully get confirmation shortly. > > Thanks > -Jeff