From: Kalesh Singh uffd-wp-mremap checks only for UFFD_FEATURE_PAGEFAULT_FLAG_WP before it runs. With CONFIG_PTE_MARKER_UFFD_WP=n the kernel keeps that feature but supports write protection on anonymous memory only, so the shmem and hugetlb cases fail with EINVAL from UFFDIO_REGISTER instead of skipping. Skip them when UFFD_FEATURE_WP_HUGETLBFS_SHMEM is missing. Fixes: b2466bb3b495 ("selftests/mm: introduce uffd-wp-mremap regression test") Cc: Andrew Morton Cc: Lokesh Gidra Signed-off-by: Kalesh Singh --- tools/testing/selftests/mm/uffd-wp-mremap.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/mm/uffd-wp-mremap.c b/tools/testing/selftests/mm/uffd-wp-mremap.c index c48eaab8e75c..f7b272baa6f5 100644 --- a/tools/testing/selftests/mm/uffd-wp-mremap.c +++ b/tools/testing/selftests/mm/uffd-wp-mremap.c @@ -18,15 +18,14 @@ static int nr_thpsizes; static size_t thpsizes[20]; static int nr_hugetlbsizes; static unsigned long hugetlbsizes[10]; +static uint64_t uffd_features; static void check_uffd_wp_feature_supported(void) { - uint64_t features = 0; - - if (uffd_get_features(&features)) + if (uffd_get_features(&uffd_features)) ksft_exit_skip("failed to get available features (%d)\n", errno); - if (!(features & UFFD_FEATURE_PAGEFAULT_FLAG_WP)) + if (!(uffd_features & UFFD_FEATURE_PAGEFAULT_FLAG_WP)) ksft_exit_skip("uffd-wp feature not supported\n"); } @@ -180,6 +179,12 @@ static void test_one_folio(uffd_global_test_opts_t *gopts, size_t size, bool pri swapout ? "true" : "false", hugetlb ? "true" : "false"); + if ((!private || hugetlb) && + !(uffd_features & UFFD_FEATURE_WP_HUGETLBFS_SHMEM)) { + ksft_test_result_skip("uffd-wp on shmem and hugetlbfs is not supported\n"); + return; + } + /* Allocate a folio of required size and type. */ mem = alloc_one_folio(size, private, hugetlb); if (!mem) { -- 2.56.1.750.gf70dc682cf-goog