This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
[PATCH 2nd try] aarch64: kernel defines __NR_compat_[exit|read|write] since 3.19
- From: Victor Kamensky <kamensky at cisco dot com>
- To: systemtap at sourceware dot org, David Smith <dsmith at redhat dot com>
- Cc: Jafeer Uddin <juddin at redhat dot com>
- Date: Fri, 26 Oct 2018 10:31:29 -0700
- Subject: [PATCH 2nd try] aarch64: kernel defines __NR_compat_[exit|read|write] since 3.19
On aarch64 Linux system calls related SystemTap scripts
compilation fail with "__NR_compat_[exit|read|write] redefined"
errors after following two commits:
7abf0aee9 PR23160,PR14690: remove references to ia32 and x86 to make sysc_* files as arch-independent as possible
cd84aedca PR23160,PR14690: adapt 13 more syscalls for 4.17 __ARCH_sys_FOO and sys_enter/exit
aarch64 kernel defines __NR_compat_[exit|read|write] after
a1ae65b21941 arm64: add seccomp support
aarch64 kernel define __NR_compat_restart_syscall after
f3e5c847ec3d arm64: Add __NR_* definitions for compat syscalls
Fix by adding proper conditional compilation based on current
architecture and kernel version.
Signed-off-by: Victor Kamensky <kamensky@cisco.com>
---
Hi SystemTap Team,
Please consider applying this patch. On aarch64 several scripts
involving __NR_xxx numbers fails as described below.
I've posted fist version back in July, but it was not accepted by
some reason, but I've not seen any feedback on it:
https://sourceware.org/ml/systemtap/2018-q3/msg00042.html
Since then further NR restructuring also redefined __NR_compat_restart_syscall
on aarch64.
Note 'probe nd_syscall.*' still failing on aarch64: there are more
issues I am looking into those. I'll try to fix it with separate
patch.
More details on __NR_compat_exit, __NR_compat_read, __NR_compat_write,
__NR_compat_restart_syscall redefinition failures.
The following two commits broke aarch64 compilation on quite a
few system call related SystemTap scripts on aarch64 CPU
architecture:
commit 7abf0aee98042c585e055635eebacde5b31bab69
Author: Jafeer Uddin <juddin@redhat.com>
Date: Fri Jul 13 10:21:51 2018 -0400
PR23160,PR14690: remove references to ia32 and x86 to make sysc_* files as arch-independent as possible
commit cd84aedcaffbda31041da6226a13918af7e132f7
Author: Jafeer Uddin <juddin@redhat.com>
Date: Tue Jul 17 10:30:28 2018 -0400
PR23160,PR14690: adapt 13 more syscalls for 4.17 __ARCH_sys_FOO and sys_enter/exit
and further __NR restructuring in SystemTap-4.0
root@apm-mustang-aarch64:~# stap -v nfs-detailed.stp
Pass 1: parsed user script and 457 library scripts using 80628virt/69624res/6492shr/63192data kb, in 460usr/70sys/536real ms.
Pass 2: analyzed script: 87 probes, 106 functions, 106 embeds, 28 globals using 242708virt/232376res/7684shr/225272data kb, in 4010usr/360sys/4370real ms.
Pass 3: translated to C into "/tmp/stapHSwIiw/stap_a781e9eaf77e4633bc0fa5061394bb00_163131_src.c" using 242708virt/232504res/7812shr/225272data kb, in 60usr/20sys/72real ms.
In file included from /tmp/stapHSwIiw/stap_a781e9eaf77e4633bc0fa5061394bb00_163131_src.c:55:
/home/root/systemtap/20181025/packages/share/systemtap/runtime/linux/compat_unistd.h:1690: error: "__NR_compat_exit" redefined [-Werror]
#define __NR_compat_exit __NR_exit
In file included from /tmp/stapHSwIiw/stap_a781e9eaf77e4633bc0fa5061394bb00_163131_src.c:54:
./arch/arm64/include/asm/unistd.h:33: note: this is the location of the previous definition
#define __NR_compat_exit 1
In file included from /tmp/stapHSwIiw/stap_a781e9eaf77e4633bc0fa5061394bb00_163131_src.c:55:
/home/root/systemtap/20181025/packages/share/systemtap/runtime/linux/compat_unistd.h:1848: error: "__NR_compat_read" redefined [-Werror]
#define __NR_compat_read __NR_read
In file included from /tmp/stapHSwIiw/stap_a781e9eaf77e4633bc0fa5061394bb00_163131_src.c:54:
./arch/arm64/include/asm/unistd.h:34: note: this is the location of the previous definition
#define __NR_compat_read 3
In file included from /tmp/stapHSwIiw/stap_a781e9eaf77e4633bc0fa5061394bb00_163131_src.c:55:
/home/root/systemtap/20181025/packages/share/systemtap/runtime/linux/compat_unistd.h:1861: error: "__NR_compat_restart_syscall" redefined [-Werror]
#define __NR_compat_restart_syscall __NR_restart_syscall
In file included from /tmp/stapHSwIiw/stap_a781e9eaf77e4633bc0fa5061394bb00_163131_src.c:54:
./arch/arm64/include/asm/unistd.h:32: note: this is the location of the previous definition
#define __NR_compat_restart_syscall 0
In file included from /tmp/stapHSwIiw/stap_a781e9eaf77e4633bc0fa5061394bb00_163131_src.c:55:
/home/root/systemtap/20181025/packages/share/systemtap/runtime/linux/compat_unistd.h:1979: error: "__NR_compat_write" redefined [-Werror]
#define __NR_compat_write __NR_write
In file included from /tmp/stapHSwIiw/stap_a781e9eaf77e4633bc0fa5061394bb00_163131_src.c:54:
./arch/arm64/include/asm/unistd.h:35: note: this is the location of the previous definition
#define __NR_compat_write 4
cc1: all warnings being treated as errors
make[1]: *** [scripts/Makefile.build:317: /tmp/stapHSwIiw/stap_a781e9eaf77e4633bc0fa5061394bb00_163131_src.o] Error 1
make: *** [Makefile:1505: _module_/tmp/stapHSwIiw] Error 2
WARNING: kbuild exited with status: 2
Pass 4: compiled C into "stap_a781e9eaf77e4633bc0fa5061394bb00_163131.ko" in 17210usr/920sys/18072real ms.
Pass 4: compilation failed. [man error::pass4]
on aarch64 __NR_compat_exit, __NR_compat_read, __NR_compat_write were added
by:
commit a1ae65b219416a72c15577bd4c8c11174fffbb8b
Author: AKASHI Takahiro <takahiro.akashi@linaro.org>
Date: Fri Nov 28 05:26:39 2014 +0000
arm64: add seccomp support
secure_computing() is called first in syscall_trace_enter() so that
a system call will be aborted quickly without doing succeeding syscall
tracing if seccomp rules want to deny that system call.
On compat task, syscall numbers for system calls allowed in seccomp mode 1
are different from those on normal tasks, and so _NR_seccomp_xxx_32's need
to be redefined.
Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
on aarch64 __NR_compat_restart_syscall added by
commit f3e5c847ec3d12b4de7898662024ee25622b25d7
Author: Catalin Marinas <catalin.marinas@arm.com>
Date: Thu Jan 30 17:56:56 2014 +0000
arm64: Add __NR_* definitions for compat syscalls
This patch adds __NR_* definitions to asm/unistd32.h, moves the
__NR_compat_* definitions to asm/unistd.h and removes all the explicit
unistd32.h includes apart from the one building the compat syscall
table. The aim is to have the compat __NR_* definitions available but
without colliding with the native syscall definitions (required by
lib/compat_audit.c to avoid duplicating the audit header files between
native and compat).
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
runtime/linux/compat_unistd.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/runtime/linux/compat_unistd.h b/runtime/linux/compat_unistd.h
index c97ad37c4..388beca99 100644
--- a/runtime/linux/compat_unistd.h
+++ b/runtime/linux/compat_unistd.h
@@ -1687,7 +1687,9 @@
#define __NR_compat_eventfd2 __NR_eventfd2
#define __NR_compat_execve __NR_execve
#define __NR_compat_execveat __NR_execveat
+#if !(defined(__aarch64__) && LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0))
#define __NR_compat_exit __NR_exit
+#endif
#define __NR_compat_exit_group __NR_exit_group
#define __NR_compat_faccessat __NR_faccessat
#define __NR_compat_fanotify_init __NR_fanotify_init
@@ -1845,7 +1847,9 @@
#define __NR_compat_pwritev __NR_pwritev
#define __NR_compat_pwritev2 __NR_pwritev2
#define __NR_compat_quotactl __NR_quoactl
+#if !(defined(__aarch64__) && LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0))
#define __NR_compat_read __NR_read
+#endif
#define __NR_compat_readdir __NR_readdir
#define __NR_compat_readlink __NR_readlink
#define __NR_compat_readlinkat __NR_readlinkat
@@ -1858,7 +1862,9 @@
#define __NR_compat_renameat __NR_renameat
#define __NR_compat_renameat2 __NR_renameat2
#define __NR_compat_request_key __NR_request_key
+#if !(defined(__aarch64__) && LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
#define __NR_compat_restart_syscall __NR_restart_syscall
+#endif
#define __NR_compat_rmdir __NR_rmdir
#define __NR_compat_rt_sigaction __NR_rt_sigaction
#define __NR_compat_rt_sigpending __NR_rt_sigpending
@@ -1976,7 +1982,9 @@
#define __NR_compat_wait4 __NR_wait4
#define __NR_compat_waitid __NR_waitid
#define __NR_compat_waitpid __NR_waitpid
+#if !(defined(__aarch64__) && LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0))
#define __NR_compat_write __NR_write
+#endif
#define __NR_compat_writev __NR_writev
#endif /* __powerpc64__ || __s390x__ || __aarch64__ */
--
2.17.2