1From d07260db8b803841a739fbe85d4617398e3e5c6a Mon Sep 17 00:00:00 2001 2From: Steve Muckle <smuckle@google.com> 3Date: Tue, 24 Oct 2017 14:41:07 -0700 4Subject: [PATCH 09/24] 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 <smuckle@google.com> 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 9691fdd5ab790..65b81fa4aaca8 100644 18--- a/tools/testing/selftests/seccomp/seccomp_bpf.c 19+++ b/tools/testing/selftests/seccomp/seccomp_bpf.c 20@@ -3020,6 +3020,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@@ -3135,12 +3136,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.36.0.550.gb090851708-goog 45 46