[PATCH 1/2] aarch64: add missing system call defines

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH 1/2] aarch64: add missing system call defines

Victor Kamensky
A set of system call defines like __NR_alarm, __NR_ioperm,
__NR_modify_ldt, __NR_time, __NR_utime is missing in aarch64
kernel as of 4.18 kernel version.

Add corresponding definitions so system call related probes
would compile. Tested with nd_syscalls-all-probes.stp.

Signed-off-by: Victor Kamensky <[hidden email]>
---
Here is output from original error:


Running /home/root/systemtap/20181025/systemtap/testsuite/buildok/nd_syscalls-all-probes.stp
Sending "run" to stapi
run
Pass 1: parsed user script and 457 library scripts using 83972virt/69064res/2504shr/66536data kb, in 0usr/0sys/0real ms.
Pass 2: analyzed script: 993 probes, 191 functions, 102 embeds, 52 globals using 1037004virt/361076res/154868shr/1019468data kb, in 111900usr/1180sys/113049real ms.
Pass 3: translated to C into "/tmp/stap4s8PED/stap_c999d6ef96352213299084133959be00_870057_src.c" using 1037188virt/361236res/154932shr/1019652data kb, in 12260usr/20sys/12267re
al ms.
In file included from /tmp/stap4s8PED/stap_c999d6ef96352213299084133959be00_870057_src.c:35:
/tmp/stap4s8PED/stap_c999d6ef96352213299084133959be00_870057_src.c: In function 'probe_6202':
/home/root/systemtap/20181025/systemtap/runtime/linux/compat_unistd.h:1658:28: error: '__NR_alarm' undeclared (first use in this function)
 #define __NR_compat_alarm  __NR_alarm
                            ^~~~~~~~~~
/tmp/stap4s8PED/stap_c999d6ef96352213299084133959be00_870057_src.c:38449:85: note: in expansion of macro '__NR_compat_alarm'
       if ((((l->l___nr) != ((((int64_t) (/* pure */ /* unprivileged */ /* stable */ __NR_compat_alarm))))))) {
                                                                                     ^~~~~~~~~~~~~~~~~
/home/root/systemtap/20181025/systemtap/runtime/linux/compat_unistd.h:1658:28: note: each undeclared identifier is reported only once for each function it appears in
 #define __NR_compat_alarm  __NR_alarm
                            ^~~~~~~~~~
/tmp/stap4s8PED/stap_c999d6ef96352213299084133959be00_870057_src.c:38449:85: note: in expansion of macro '__NR_compat_alarm'
       if ((((l->l___nr) != ((((int64_t) (/* pure */ /* unprivileged */ /* stable */ __NR_compat_alarm))))))) {
                                                                                     ^~~~~~~~~~~~~~~~~
/tmp/stap4s8PED/stap_c999d6ef96352213299084133959be00_870057_src.c: In function 'probe_6705':
/home/root/systemtap/20181025/systemtap/runtime/linux/compat_unistd.h:1766:29: error: '__NR_ioperm' undeclared (first use in this function); did you mean '__lt_insert'?
 #define __NR_compat_ioperm  __NR_ioperm
                             ^~~~~~~~~~~
/tmp/stap4s8PED/stap_c999d6ef96352213299084133959be00_870057_src.c:59066:85: note: in expansion of macro '__NR_compat_ioperm'
       if ((((l->l___nr) != ((((int64_t) (/* pure */ /* unprivileged */ /* stable */ __NR_compat_ioperm))))))) {
                                                                                     ^~~~~~~~~~~~~~~~~~
/tmp/stap4s8PED/stap_c999d6ef96352213299084133959be00_870057_src.c: In function 'probe_6837':
/home/root/systemtap/20181025/systemtap/runtime/linux/compat_unistd.h:1801:33: error: '__NR_modify_ldt' undeclared (first use in this function)
 #define __NR_compat_modify_ldt  __NR_modify_ldt
                                 ^~~~~~~~~~~~~~~
/tmp/stap4s8PED/stap_c999d6ef96352213299084133959be00_870057_src.c:65796:85: note: in expansion of macro '__NR_compat_modify_ldt'
       if ((((l->l___nr) != ((((int64_t) (/* pure */ /* unprivileged */ /* stable */ __NR_compat_modify_ldt))))))) {
                                                                                     ^~~~~~~~~~~~~~~~~~~~~~
/tmp/stap4s8PED/stap_c999d6ef96352213299084133959be00_870057_src.c: In function 'probe_7488':
/home/root/systemtap/20181025/systemtap/runtime/linux/compat_unistd.h:1953:27: error: '__NR_time' undeclared (first use in this function); did you mean 'stp_time'?
 #define __NR_compat_time  __NR_time
                           ^~~~~~~~~
/tmp/stap4s8PED/stap_c999d6ef96352213299084133959be00_870057_src.c:93826:85: note: in expansion of macro '__NR_compat_time'
       if ((((l->l___nr) != ((((int64_t) (/* pure */ /* unprivileged */ /* stable */ __NR_compat_time))))))) {
                                                                                     ^~~~~~~~~~~~~~~~
/tmp/stap4s8PED/stap_c999d6ef96352213299084133959be00_870057_src.c: In function 'probe_7583':
/tmp/stap4s8PED/stap_c999d6ef96352213299084133959be00_870057_src.c:97104:75: error: '__NR_utime' undeclared (first use in this function); did you mean 'si_utime'?
           })) != ((((int64_t) (/* pure */ /* unprivileged */ /* stable */ __NR_utime))))))) {
                                                                           ^~~~~~~~~~
                                                                           si_utime
In file included from /tmp/stap4s8PED/stap_c999d6ef96352213299084133959be00_870057_src.c:35:
/tmp/stap4s8PED/stap_c999d6ef96352213299084133959be00_870057_src.c: In function 'probe_7660':
/home/root/systemtap/20181025/systemtap/runtime/linux/compat_unistd.h:1658:28: error: '__NR_alarm' undeclared (first use in this function)
 #define __NR_compat_alarm  __NR_alarm
                            ^~~~~~~~~~
/tmp/stap4s8PED/stap_c999d6ef96352213299084133959be00_870057_src.c:99983:85: note: in expansion of macro '__NR_compat_alarm'
       if ((((l->l___nr) != ((((int64_t) (/* pure */ /* unprivileged */ /* stable */ __NR_compat_alarm))))))) {
                                                                                     ^~~~~~~~~~~~~~~~~
/tmp/stap4s8PED/stap_c999d6ef96352213299084133959be00_870057_src.c: In function 'probe_8160':
/home/root/systemtap/20181025/systemtap/runtime/linux/compat_unistd.h:1766:29: error: '__NR_ioperm' undeclared (first use in this function); did you mean '__lt_insert'?
 #define __NR_compat_ioperm  __NR_ioperm
                             ^~~~~~~~~~~
/tmp/stap4s8PED/stap_c999d6ef96352213299084133959be00_870057_src.c:104860:85: note: in expansion of macro '__NR_compat_ioperm'
       if ((((l->l___nr) != ((((int64_t) (/* pure */ /* unprivileged */ /* stable */ __NR_compat_ioperm))))))) {
                                                                                     ^~~~~~~~~~~~~~~~~~
/tmp/stap4s8PED/stap_c999d6ef96352213299084133959be00_870057_src.c: In function 'probe_8292':
/home/root/systemtap/20181025/systemtap/runtime/linux/compat_unistd.h:1801:33: error: '__NR_modify_ldt' undeclared (first use in this function)
 #define __NR_compat_modify_ldt  __NR_modify_ldt
                                 ^~~~~~~~~~~~~~~
/tmp/stap4s8PED/stap_c999d6ef96352213299084133959be00_870057_src.c:106118:85: note: in expansion of macro '__NR_compat_modify_ldt'
       if ((((l->l___nr) != ((((int64_t) (/* pure */ /* unprivileged */ /* stable */ __NR_compat_modify_ldt))))))) {
                                                                                     ^~~~~~~~~~~~~~~~~~~~~~
/tmp/stap4s8PED/stap_c999d6ef96352213299084133959be00_870057_src.c: In function 'probe_8932':
/home/root/systemtap/20181025/systemtap/runtime/linux/compat_unistd.h:1953:27: error: '__NR_time' undeclared (first use in this function); did you mean 'stp_time'?
 #define __NR_compat_time  __NR_time
                           ^~~~~~~~~
/tmp/stap4s8PED/stap_c999d6ef96352213299084133959be00_870057_src.c:112682:85: note: in expansion of macro '__NR_compat_time'
       if ((((l->l___nr) != ((((int64_t) (/* pure */ /* unprivileged */ /* stable */ __NR_compat_time))))))) {
                                                                                     ^~~~~~~~~~~~~~~~
/tmp/stap4s8PED/stap_c999d6ef96352213299084133959be00_870057_src.c: In function 'probe_9018':
/tmp/stap4s8PED/stap_c999d6ef96352213299084133959be00_870057_src.c:113286:75: error: '__NR_utime' undeclared (first use in this function); did you mean 'si_utime'?
           })) != ((((int64_t) (/* pure */ /* unprivileged */ /* stable */ __NR_utime))))))) {
                                                                           ^~~~~~~~~~
                                                                           si_utime
make[7]: *** [scripts/Makefile.build:317: /tmp/stap4s8PED/stap_c999d6ef96352213299084133959be00_870057_src.o] Error 1
make[6]: *** [Makefile:1505: _module_/tmp/stap4s8PED] Error 2

 runtime/linux/compat_unistd.h | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/runtime/linux/compat_unistd.h b/runtime/linux/compat_unistd.h
index 07b3c5ffa..6f7e8adec 100644
--- a/runtime/linux/compat_unistd.h
+++ b/runtime/linux/compat_unistd.h
@@ -349,6 +349,21 @@
 #ifndef __NR_waitpid
 #define __NR_waitpid (__NR_syscall_max + 1)
 #endif
+#ifndef __NR_alarm
+#define __NR_alarm (__NR_syscall_max + 1)
+#endif
+#ifndef __NR_ioperm
+#define __NR_ioperm (__NR_syscall_max + 1)
+#endif
+#ifndef __NR_modify_ldt
+#define __NR_modify_ldt (__NR_syscall_max + 1)
+#endif
+#ifndef __NR_time
+#define __NR_time (__NR_syscall_max + 1)
+#endif
+#ifndef __NR_utime
+#define __NR_utime (__NR_syscall_max + 1)
+#endif
 
 #if defined(__x86_64__)
 
--
2.18.0

Reply | Threaded
Open this post in threaded view
|

[PATCH 2/2] powerpc64: add missing system call defines

Victor Kamensky
A set of system call defines like __NR_pkey_alloc, __NR_pkey_free
__NR_pkey_mprotect are missing in powerpc64 kernel as of 4.14 kernel
version.

Add corresponding definitions so system call related probes
would compile. Tested with nd_syscalls-all-probes.stp.

Signed-off-by: Victor Kamensky <[hidden email]>
---
Here is error that I get with latest systemtap on nxp p5020
powerpc64 machine. But I think the error is common for all
older kernels that would not have those system calls yet:

root@p5020ds-64b:~# stap -v nd_syscalls-all-probes.stp
Pass 1: parsed user script and 495 library scripts using 89036virt/73708res/9256shr/64004data kb, in 710usr/70sys/783real ms.
WARNING: never-assigned local variable 'retstr' (similar: argstr, buf, flags_str, count, name): identifier 'retstr' at nd_syscalls-all-probes.stp:10:17
 source: printf("%s\n", retstr)
                        ^
Pass 2: analyzed script: 1075 probes, 199 functions, 102 embeds, 104 globals using 221080virt/207548res/11068shr/196048data kb, in 498110usr/19270sys/463469real ms.
Pass 3: translated to C into "/tmp/stapSrqSJF/stap_5d936e2fa4c3279e32799d9e5510d43d_974050_src.c" using 221080virt/207548res/11068shr/196048data kb, in 42980usr/70sys/43071real ms.
In file included from /tmp/stapSrqSJF/stap_5d936e2fa4c3279e32799d9e5510d43d_974050_src.c:35:
/tmp/stapSrqSJF/stap_5d936e2fa4c3279e32799d9e5510d43d_974050_src.c: In function 'probe_7220':
/home/root/systemtap/20181030/packages/share/systemtap/runtime/linux/compat_unistd.h:1921:33: error: '__NR_pkey_alloc' undeclared (first use in this function); did you mean '__pte_alloc'?
 #define __NR_compat_pkey_alloc  __NR_pkey_alloc
                                 ^~~~~~~~~~~~~~~
/tmp/stapSrqSJF/stap_5d936e2fa4c3279e32799d9e5510d43d_974050_src.c:79572:85: note: in expansion of macro '__NR_compat_pkey_alloc'
       if ((((l->l___nr) != ((((int64_t) (/* pure */ /* unprivileged */ /* stable */ __NR_compat_pkey_alloc))))))) {
                                                                                     ^~~~~~~~~~~~~~~~~~~~~~
/home/root/systemtap/20181030/packages/share/systemtap/runtime/linux/compat_unistd.h:1921:33: note: each undeclared identifier is reported only once for each function it appears in
 #define __NR_compat_pkey_alloc  __NR_pkey_alloc
                                 ^~~~~~~~~~~~~~~
/tmp/stapSrqSJF/stap_5d936e2fa4c3279e32799d9e5510d43d_974050_src.c:79572:85: note: in expansion of macro '__NR_compat_pkey_alloc'
       if ((((l->l___nr) != ((((int64_t) (/* pure */ /* unprivileged */ /* stable */ __NR_compat_pkey_alloc))))))) {
                                                                                     ^~~~~~~~~~~~~~~~~~~~~~
/tmp/stapSrqSJF/stap_5d936e2fa4c3279e32799d9e5510d43d_974050_src.c: In function 'probe_7225':
/home/root/systemtap/20181030/packages/share/systemtap/runtime/linux/compat_unistd.h:1922:32: error: '__NR_pkey_free' undeclared (first use in this function); did you mean '__stp_get_freq'?
 #define __NR_compat_pkey_free  __NR_pkey_free
                                ^~~~~~~~~~~~~~
/tmp/stapSrqSJF/stap_5d936e2fa4c3279e32799d9e5510d43d_974050_src.c:79731:85: note: in expansion of macro '__NR_compat_pkey_free'
       if ((((l->l___nr) != ((((int64_t) (/* pure */ /* unprivileged */ /* stable */ __NR_compat_pkey_free))))))) {
                                                                                     ^~~~~~~~~~~~~~~~~~~~~
/tmp/stapSrqSJF/stap_5d936e2fa4c3279e32799d9e5510d43d_974050_src.c: In function 'probe_7230':
/home/root/systemtap/20181030/packages/share/systemtap/runtime/linux/compat_unistd.h:1923:35: error: '__NR_pkey_mprotect' undeclared (first use in this function); did you mean 'pudp_set_wrprotect'?
 #define __NR_compat_pkey_mprotect __NR_pkey_mprotect
                                   ^~~~~~~~~~~~~~~~~~
/tmp/stapSrqSJF/stap_5d936e2fa4c3279e32799d9e5510d43d_974050_src.c:79864:85: note: in expansion of macro '__NR_compat_pkey_mprotect'
       if ((((l->l___nr) != ((((int64_t) (/* pure */ /* unprivileged */ /* stable */ __NR_compat_pkey_mprotect))))))) {
                                                                                     ^~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/stapSrqSJF/stap_5d936e2fa4c3279e32799d9e5510d43d_974050_src.c: In function 'probe_8761':
/home/root/systemtap/20181030/packages/share/systemtap/runtime/linux/compat_unistd.h:1921:33: error: '__NR_pkey_alloc' undeclared (first use in this function); did you mean '__pte_alloc'?
 #define __NR_compat_pkey_alloc  __NR_pkey_alloc
                                 ^~~~~~~~~~~~~~~
/tmp/stapSrqSJF/stap_5d936e2fa4c3279e32799d9e5510d43d_974050_src.c:122651:85: note: in expansion of macro '__NR_compat_pkey_alloc'
       if ((((l->l___nr) != ((((int64_t) (/* pure */ /* unprivileged */ /* stable */ __NR_compat_pkey_alloc))))))) {
                                                                                     ^~~~~~~~~~~~~~~~~~~~~~
/tmp/stapSrqSJF/stap_5d936e2fa4c3279e32799d9e5510d43d_974050_src.c: In function 'probe_8766':
/home/root/systemtap/20181030/packages/share/systemtap/runtime/linux/compat_unistd.h:1922:32: error: '__NR_pkey_free' undeclared (first use in this function); did you mean '__stp_get_freq'?
 #define __NR_compat_pkey_free  __NR_pkey_free
                                ^~~~~~~~~~~~~~
/tmp/stapSrqSJF/stap_5d936e2fa4c3279e32799d9e5510d43d_974050_src.c:122752:85: note: in expansion of macro '__NR_compat_pkey_free'
       if ((((l->l___nr) != ((((int64_t) (/* pure */ /* unprivileged */ /* stable */ __NR_compat_pkey_free))))))) {
                                                                                     ^~~~~~~~~~~~~~~~~~~~~
/tmp/stapSrqSJF/stap_5d936e2fa4c3279e32799d9e5510d43d_974050_src.c: In function 'probe_8771':
/home/root/systemtap/20181030/packages/share/systemtap/runtime/linux/compat_unistd.h:1923:35: error: '__NR_pkey_mprotect' undeclared (first use in this function); did you mean 'pudp_set_wrprotect'?
 #define __NR_compat_pkey_mprotect __NR_pkey_mprotect
                                   ^~~~~~~~~~~~~~~~~~
/tmp/stapSrqSJF/stap_5d936e2fa4c3279e32799d9e5510d43d_974050_src.c:122853:85: note: in expansion of macro '__NR_compat_pkey_mprotect'
       if ((((l->l___nr) != ((((int64_t) (/* pure */ /* unprivileged */ /* stable */ __NR_compat_pkey_mprotect))))))) {
                                                                                     ^~~~~~~~~~~~~~~~~~~~~~~~~
make[1]: *** [scripts/Makefile.build:328: /tmp/stapSrqSJF/stap_5d936e2fa4c3279e32799d9e5510d43d_974050_src.o] Error 1
make: *** [Makefile:1525: _module_/tmp/stapSrqSJF] Error 2
WARNING: kbuild exited with status: 2
Pass 4: compiled C into "stap_5d936e2fa4c3279e32799d9e5510d43d_974050.ko" in 112140usr/4170sys/114904real ms.
Pass 4: compilation failed.  [man error::pass4]

 runtime/linux/compat_unistd.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/runtime/linux/compat_unistd.h b/runtime/linux/compat_unistd.h
index 6f7e8adec..13f98a424 100644
--- a/runtime/linux/compat_unistd.h
+++ b/runtime/linux/compat_unistd.h
@@ -364,6 +364,15 @@
 #ifndef __NR_utime
 #define __NR_utime (__NR_syscall_max + 1)
 #endif
+#ifndef __NR_pkey_alloc
+#define __NR_pkey_alloc (__NR_syscall_max + 1)
+#endif
+#ifndef __NR_pkey_free
+#define __NR_pkey_free (__NR_syscall_max + 1)
+#endif
+#ifndef __NR_pkey_mprotect
+#define __NR_pkey_mprotect (__NR_syscall_max + 1)
+#endif
 
 #if defined(__x86_64__)
 
--
2.18.0