Commit 0a7565ee authored by John Hubbard's avatar John Hubbard Committed by Andrew Morton
Browse files

Revert "selftests/mm: remove local __NR_* definitions"

This reverts commit a5c6bc59.

The general approach described in commit e076eaca ("selftests: break
the dependency upon local header files") was taken one step too far here:
it should not have been extended to include the syscall numbers.  This is
because doing so would require per-arch support in tools/include/uapi, and
no such support exists.

This revert fixes two separate reports of test failures, from Dave
Hansen[1], and Li Wang[2].  An excerpt of Dave's report:

Before this commit (a5c6bc59) things are
fine.  But after, I get:

	running PKEY tests for unsupported CPU/OS

An excerpt of Li's report:

    I just found that mlock2_() return a wrong value in mlock2-test

[1] https://lore.kernel.org/dc585017-6740-4cab-a536-b12b37a7582d@intel.com
[2] https://lore.kernel.org/CAEemH2eW=UMu9+turT2jRie7+6ewUazXmA6kL+VBo3cGDGU6RA@mail.gmail.com

Link: https://lkml.kernel.org/r/20250214033850.235171-1-jhubbard@nvidia.com


Fixes: a5c6bc59 ("selftests/mm: remove local __NR_* definitions")
Signed-off-by: default avatarJohn Hubbard <jhubbard@nvidia.com>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: Li Wang <liwang@redhat.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Jeff Xu <jeffxu@chromium.org>
Cc: Andrei Vagin <avagin@google.com>
Cc: Axel Rasmussen <axelrasmussen@google.com>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Kees Cook <kees@kernel.org>
Cc: Kent Overstreet <kent.overstreet@linux.dev>
Cc: Liam R. Howlett <Liam.Howlett@oracle.com>
Cc: Muhammad Usama Anjum <usama.anjum@collabora.com>
Cc: Peter Xu <peterx@redhat.com>
Cc: Rich Felker <dalias@libc.org>
Cc: Shuah Khan <shuah@kernel.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 8344017a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@
#define _GNU_SOURCE
#include <stdlib.h>
#include <stdio.h>
#include <asm-generic/unistd.h>
#include <unistd.h>
#include <sys/mman.h>
#include <errno.h>
#include <fcntl.h> /* Definition of O_* constants */
+7 −1
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <asm-generic/unistd.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/mman.h>
@@ -369,6 +369,7 @@ static void test_unmerge_discarded(void)
	munmap(map, size);
}

#ifdef __NR_userfaultfd
static void test_unmerge_uffd_wp(void)
{
	struct uffdio_writeprotect uffd_writeprotect;
@@ -429,6 +430,7 @@ static void test_unmerge_uffd_wp(void)
unmap:
	munmap(map, size);
}
#endif

/* Verify that KSM can be enabled / queried with prctl. */
static void test_prctl(void)
@@ -684,7 +686,9 @@ int main(int argc, char **argv)
		exit(test_child_ksm());
	}

#ifdef __NR_userfaultfd
	tests++;
#endif

	ksft_print_header();
	ksft_set_plan(tests);
@@ -696,7 +700,9 @@ int main(int argc, char **argv)
	test_unmerge();
	test_unmerge_zero_pages();
	test_unmerge_discarded();
#ifdef __NR_userfaultfd
	test_unmerge_uffd_wp();
#endif

	test_prot_none();

+13 −1
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@

#include <stdlib.h>
#include <string.h>
#include <asm-generic/unistd.h>
#include <unistd.h>
#include <errno.h>
#include <stdio.h>
#include <fcntl.h>
@@ -28,6 +28,8 @@
#define pass(fmt, ...) ksft_test_result_pass(fmt, ##__VA_ARGS__)
#define skip(fmt, ...) ksft_test_result_skip(fmt, ##__VA_ARGS__)

#ifdef __NR_memfd_secret

#define PATTERN	0x55

static const int prot = PROT_READ | PROT_WRITE;
@@ -332,3 +334,13 @@ int main(int argc, char *argv[])

	ksft_finished();
}

#else /* __NR_memfd_secret */

int main(int argc, char *argv[])
{
	printf("skip: skipping memfd_secret test (missing __NR_memfd_secret)\n");
	return KSFT_SKIP;
}

#endif /* __NR_memfd_secret */
+7 −1
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@
 */
#include <fcntl.h>
#include <signal.h>
#include <asm-generic/unistd.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
@@ -265,6 +265,7 @@ static void test_pte_mapped_thp(void)
	munmap(mmap_mem, mmap_size);
}

#ifdef __NR_userfaultfd
static void test_uffdio_copy(void)
{
	struct uffdio_register uffdio_register;
@@ -322,6 +323,7 @@ static void test_uffdio_copy(void)
	munmap(dst, pagesize);
	free(src);
}
#endif /* __NR_userfaultfd */

int main(void)
{
@@ -334,7 +336,9 @@ int main(void)
			       thpsize / 1024);
		tests += 3;
	}
#ifdef __NR_userfaultfd
	tests += 1;
#endif /* __NR_userfaultfd */

	ksft_print_header();
	ksft_set_plan(tests);
@@ -364,7 +368,9 @@ int main(void)
	if (thpsize)
		test_pte_mapped_thp();
	/* Placing a fresh page via userfaultfd may set the PTE dirty. */
#ifdef __NR_userfaultfd
	test_uffdio_copy();
#endif /* __NR_userfaultfd */

	err = ksft_get_fail_cnt();
	if (err)
+0 −1
Original line number Diff line number Diff line
@@ -3,7 +3,6 @@
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <asm-generic/unistd.h>

static int mlock2_(void *start, size_t len, int flags)
{
Loading