1From ad6fc2f796d9610356a052d2967d1794e2b52933 Mon Sep 17 00:00:00 2001
2From: Steve Muckle <[email protected]>
3Date: Tue, 24 Oct 2017 14:41:07 -0700
4Subject: [PATCH 09/20] seccomp: detect compat mode in ARM64
5
6Compat mode on ARM64 reports syscall numbering differently.
7
8(cherry picked from commit ce845e0a25d77c8cf0fae539d4596b83e65e3e70)
9Test: run vts-kernel -m VtsKernelLinuxKselftestStaging
10Bug: 33027081
11Signed-off-by: Steve Muckle <[email protected]>
12---
13 tools/testing/selftests/seccomp/seccomp_bpf.c | 5 +++--
14 1 file changed, 3 insertions(+), 2 deletions(-)
15
16diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c
17index 325725ca082f..110ca8bf8e2b 100644
18--- a/tools/testing/selftests/seccomp/seccomp_bpf.c
19+++ b/tools/testing/selftests/seccomp/seccomp_bpf.c
20@@ -3054,6 +3054,7 @@ TEST(syscall_restart)
21 	};
22 #if defined(__arm__)
23 	struct utsname utsbuf;
24+	int arm_version;
25 #endif
26
27 	ASSERT_EQ(0, pipe(pipefd));
28@@ -3169,12 +3170,12 @@ TEST(syscall_restart)
29 	ret = get_syscall(_metadata, child_pid);
30 #if defined(__arm__)
31 	/*
32-	 * FIXME:
33 	 * - native ARM registers do NOT expose true syscall.
34 	 * - compat ARM registers on ARM64 DO expose true syscall.
35 	 */
36 	ASSERT_EQ(0, uname(&utsbuf));
37-	if (strncmp(utsbuf.machine, "arm", 3) == 0) {
38+	if (sscanf(utsbuf.machine, "armv%d", &arm_version) == 1 &&
39+	    arm_version < 8) {
40 		EXPECT_EQ(__NR_nanosleep, ret);
41 	} else
42 #endif
43--
442.42.0.609.gbb76f46606-goog
45
46