Please fix following for this and fifth patch as well: --> checkpatch.pl --codespell tools/testing/selftests/mm/mseal_test.c
WARNING: Macros with flow control statements should be avoided #42: FILE: tools/testing/selftests/mm/mseal_test.c:42: +#define FAIL_TEST_IF_FALSE(c) do {\ + if (!(c)) {\ + ksft_test_result_fail("%s, line:%d\n", __func__, __LINE__);\ + goto test_end;\ + } \ + } \ + while (0) WARNING: Macros with flow control statements should be avoided #50: FILE: tools/testing/selftests/mm/mseal_test.c:50: +#define SKIP_TEST_IF_FALSE(c) do {\ + if (!(c)) {\ + ksft_test_result_skip("%s, line:%d\n", __func__, __LINE__);\ + goto test_end;\ + } \ + } \ + while (0) WARNING: Macros with flow control statements should be avoided #59: FILE: tools/testing/selftests/mm/mseal_test.c:59: +#define TEST_END_CHECK() {\ + ksft_test_result_pass("%s\n", __func__);\ + return;\ +test_end:\ + return;\ +} On 4/15/24 9:35 PM, jef...@chromium.org wrote: > From: Jeff Xu <jef...@chromium.org> > > selftest for memory sealing change in mmap() and mseal(). > > Signed-off-by: Jeff Xu <jef...@chromium.org> > --- > 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. > +static void __write_pkey_reg(u64 pkey_reg) > +{ > +#if defined(__i386__) || defined(__x86_64__) /* arch */ > + unsigned int eax = pkey_reg; > + unsigned int ecx = 0; > + unsigned int edx = 0; > + > + asm volatile(".byte 0x0f,0x01,0xef\n\t" > + : : "a" (eax), "c" (ecx), "d" (edx)); > + assert(pkey_reg == __read_pkey_reg()); Use ksft_exit_fail_msg instead of assert to stay inside TAP format if condition is false and error is generated. > +int main(int argc, char **argv) > +{ > + bool test_seal = seal_support(); > + > + ksft_print_header(); > + > + if (!test_seal) > + ksft_exit_skip("sealing not supported, check CONFIG_64BIT\n"); > + > + if (!pkey_supported()) > + ksft_print_msg("PKEY not supported\n"); > + > + ksft_set_plan(80); > + > + test_seal_addseal(); > + test_seal_unmapped_start(); > + test_seal_unmapped_middle(); > + test_seal_unmapped_end(); > + test_seal_multiple_vmas(); > + test_seal_split_start(); > + test_seal_split_end(); > + test_seal_invalid_input(); > + test_seal_zero_length(); > + test_seal_twice(); > + > + test_seal_mprotect(false); > + test_seal_mprotect(true); > + > + test_seal_start_mprotect(false); > + test_seal_start_mprotect(true); > + > + test_seal_end_mprotect(false); > + test_seal_end_mprotect(true); > + > + test_seal_mprotect_unalign_len(false); > + test_seal_mprotect_unalign_len(true); > + > + test_seal_mprotect_unalign_len_variant_2(false); > + test_seal_mprotect_unalign_len_variant_2(true); > + > + test_seal_mprotect_two_vma(false); > + test_seal_mprotect_two_vma(true); > + > + test_seal_mprotect_two_vma_with_split(false); > + test_seal_mprotect_two_vma_with_split(true); > + > + test_seal_mprotect_partial_mprotect(false); > + test_seal_mprotect_partial_mprotect(true); > + > + test_seal_mprotect_two_vma_with_gap(false); > + test_seal_mprotect_two_vma_with_gap(true); > + > + test_seal_mprotect_merge(false); > + test_seal_mprotect_merge(true); > + > + test_seal_mprotect_split(false); > + test_seal_mprotect_split(true); > + > + test_seal_munmap(false); > + test_seal_munmap(true); > + test_seal_munmap_two_vma(false); > + test_seal_munmap_two_vma(true); > + test_seal_munmap_vma_with_gap(false); > + test_seal_munmap_vma_with_gap(true); > + > + test_munmap_start_freed(false); > + test_munmap_start_freed(true); > + test_munmap_middle_freed(false); > + test_munmap_middle_freed(true); > + test_munmap_end_freed(false); > + test_munmap_end_freed(true); > + > + test_seal_mremap_shrink(false); > + test_seal_mremap_shrink(true); > + test_seal_mremap_expand(false); > + test_seal_mremap_expand(true); > + test_seal_mremap_move(false); > + test_seal_mremap_move(true); > + > + test_seal_mremap_shrink_fixed(false); > + test_seal_mremap_shrink_fixed(true); > + test_seal_mremap_expand_fixed(false); > + test_seal_mremap_expand_fixed(true); > + test_seal_mremap_move_fixed(false); > + test_seal_mremap_move_fixed(true); > + test_seal_mremap_move_dontunmap(false); > + test_seal_mremap_move_dontunmap(true); > + test_seal_mremap_move_fixed_zero(false); > + test_seal_mremap_move_fixed_zero(true); > + test_seal_mremap_move_dontunmap_anyaddr(false); > + test_seal_mremap_move_dontunmap_anyaddr(true); > + test_seal_discard_ro_anon(false); > + test_seal_discard_ro_anon(true); > + test_seal_discard_ro_anon_on_rw(false); > + test_seal_discard_ro_anon_on_rw(true); > + test_seal_discard_ro_anon_on_shared(false); > + test_seal_discard_ro_anon_on_shared(true); > + test_seal_discard_ro_anon_on_filebacked(false); > + test_seal_discard_ro_anon_on_filebacked(true); > + test_seal_mmap_overwrite_prot(false); > + test_seal_mmap_overwrite_prot(true); > + test_seal_mmap_expand(false); > + test_seal_mmap_expand(true); > + test_seal_mmap_shrink(false); > + test_seal_mmap_shrink(true); > + > + test_seal_merge_and_split(); > + test_seal_zero_address(); > + > + test_seal_discard_ro_anon_on_pkey(false); > + test_seal_discard_ro_anon_on_pkey(true); > + > + ksft_finished(); > + return 0; The return isn't needed as ksft_finished() calls exit() with right exit code. > +} -- BR, Muhammad Usama Anjum