[PATCH] selftests/powerpc: Skip the subpage_prot tests if the syscall is disabled

Subsystems: kernel selftest framework, the rest

STALE3084d

2 messages, 2 authors, 2018-02-26 · open the first message on its own page

[PATCH] selftests/powerpc: Skip the subpage_prot tests if the syscall is disabled

From: Michael Ellerman <mpe@ellerman.id.au>
Date: 2018-02-26 04:25:16

The subpage_prot syscall is only functional when the system is using
the Hash MMU. Since commit 5b2b80714796 ("powerpc/mm: Invalidate
subpage_prot() system call on radix platforms") it returns ENOENT when
the Radix MMU is active. Currently this just makes the test fail.

Instead check explicitly for ENOENT and skip if we see that.

Fixes: 5b2b80714796 ("powerpc/mm: Invalidate subpage_prot() system call on radix platforms")
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 tools/testing/selftests/powerpc/mm/subpage_prot.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
diff --git a/tools/testing/selftests/powerpc/mm/subpage_prot.c b/tools/testing/selftests/powerpc/mm/subpage_prot.c
index 35ade7406dcd..81570680e7ea 100644
--- a/tools/testing/selftests/powerpc/mm/subpage_prot.c
+++ b/tools/testing/selftests/powerpc/mm/subpage_prot.c
@@ -135,6 +135,15 @@ static int run_test(void *addr, unsigned long size)
 	return 0;
 }
 
+static int syscall_available(void)
+{
+	int rc;
+
+	errno = 0;
+	rc = syscall(__NR_subpage_prot, 0, 0, 0);
+	return rc == 0 || errno != ENOENT;
+}
+
 int test_anon(void)
 {
 	unsigned long align;
@@ -145,6 +154,8 @@ int test_anon(void)
 	void *mallocblock;
 	unsigned long mallocsize;
 
+	SKIP_IF(!syscall_available());
+
 	if (getpagesize() != 0x10000) {
 		fprintf(stderr, "Kernel page size must be 64K!\n");
 		return 1;
@@ -180,6 +191,8 @@ int test_file(void)
 	off_t filesize;
 	int fd;
 
+	SKIP_IF(!syscall_available());
+
 	fd = open(file_name, O_RDWR);
 	if (fd == -1) {
 		perror("failed to open file");
-- 
2.14.1

Re: [PATCH] selftests/powerpc: Skip the subpage_prot tests if the syscall is disabled

From: Aneesh Kumar K.V <hidden>
Date: 2018-02-26 04:34:42

Michael Ellerman [off-list ref] writes:
The subpage_prot syscall is only functional when the system is using
the Hash MMU. Since commit 5b2b80714796 ("powerpc/mm: Invalidate
subpage_prot() system call on radix platforms") it returns ENOENT when
the Radix MMU is active. Currently this just makes the test fail.

Instead check explicitly for ENOENT and skip if we see that.
Reviewed-by: Aneesh Kumar K.V <redacted>
quoted hunk
Fixes: 5b2b80714796 ("powerpc/mm: Invalidate subpage_prot() system call on radix platforms")
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 tools/testing/selftests/powerpc/mm/subpage_prot.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
diff --git a/tools/testing/selftests/powerpc/mm/subpage_prot.c b/tools/testing/selftests/powerpc/mm/subpage_prot.c
index 35ade7406dcd..81570680e7ea 100644
--- a/tools/testing/selftests/powerpc/mm/subpage_prot.c
+++ b/tools/testing/selftests/powerpc/mm/subpage_prot.c
@@ -135,6 +135,15 @@ static int run_test(void *addr, unsigned long size)
 	return 0;
 }

+static int syscall_available(void)
+{
+	int rc;
+
+	errno = 0;
+	rc = syscall(__NR_subpage_prot, 0, 0, 0);
+	return rc == 0 || errno != ENOENT;
+}
+
 int test_anon(void)
 {
 	unsigned long align;
@@ -145,6 +154,8 @@ int test_anon(void)
 	void *mallocblock;
 	unsigned long mallocsize;

+	SKIP_IF(!syscall_available());
+
 	if (getpagesize() != 0x10000) {
 		fprintf(stderr, "Kernel page size must be 64K!\n");
 		return 1;
@@ -180,6 +191,8 @@ int test_file(void)
 	off_t filesize;
 	int fd;

+	SKIP_IF(!syscall_available());
+
 	fd = open(file_name, O_RDWR);
 	if (fd == -1) {
 		perror("failed to open file");
-- 
2.14.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help