The way in which the tracing framework defines its syscall metadata is tightly coupled with the syscall wrappers and those might be subject to architecture specific fine-tuning. For most cases this is not an issue, as SYSCALL_METADATA is simply piggy-backing on the arguments provided to those wrappers, though for arm64/Morello this proves to be problematic. To overcome this, split the SYSCALL_METADATA into a double-phased setup, allow amending the arguments themselves, so that whatever changes the arch code decides to do there, get sanitised prior to expanding the actual metadata wrapper. Additionally, the order of the arguments here gets align with the rest of the syscall framework.
Signed-off-by: Beata Michalska beata.michalska@arm.com --- arch/arm64/include/asm/syscall_wrapper.h | 4 ++-- arch/s390/include/asm/syscall_wrapper.h | 6 +++--- arch/x86/include/asm/syscall_wrapper.h | 2 +- include/linux/syscalls.h | 13 +++++++++---- 4 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/arch/arm64/include/asm/syscall_wrapper.h b/arch/arm64/include/asm/syscall_wrapper.h index b823aee59b6c..97e08c4a6520 100644 --- a/arch/arm64/include/asm/syscall_wrapper.h +++ b/arch/arm64/include/asm/syscall_wrapper.h @@ -68,7 +68,7 @@ struct pt_regs; }
#define __SYSCALL_DEFINE0(sname, ret_type) \ - SYSCALL_METADATA(sname, 0); \ + SYSCALL_METADATA(0, sname,); \ asmlinkage ret_type __arm64_sys##sname(const struct pt_regs *__unused); \ ALLOW_ERROR_INJECTION(__arm64_sys##sname, ERRNO); \ asmlinkage ret_type __arm64_compatentry_sys##sname(const struct pt_regs *__unused)\ @@ -94,7 +94,7 @@ struct pt_regs; #define __ARM64_SYS_STUBx(x, name, ...)
#define __SYSCALL_DEFINE0(sname, ret_type) \ - SYSCALL_METADATA(sname, 0); \ + SYSCALL_METADATA(0, sname,); \ asmlinkage ret_type __arm64_sys##sname(const struct pt_regs *__unused); \ ALLOW_ERROR_INJECTION(__arm64_sys##sname, ERRNO); \ asmlinkage ret_type __arm64_sys##sname(const struct pt_regs *__unused) diff --git a/arch/s390/include/asm/syscall_wrapper.h b/arch/s390/include/asm/syscall_wrapper.h index fde7e6b1df48..dee9c319734d 100644 --- a/arch/s390/include/asm/syscall_wrapper.h +++ b/arch/s390/include/asm/syscall_wrapper.h @@ -72,13 +72,13 @@ * named __s390x_sys_*() */ #define COMPAT_SYSCALL_DEFINE0(sname) \ - SYSCALL_METADATA(_##sname, 0); \ + SYSCALL_METADATA(0, _##sname); \ long __s390_compat_sys_##sname(void); \ ALLOW_ERROR_INJECTION(__s390_compat_sys_##sname, ERRNO); \ long __s390_compat_sys_##sname(void)
#define SYSCALL_DEFINE0(sname) \ - SYSCALL_METADATA(_##sname, 0); \ + SYSCALL_METADATA(0, _##sname); \ long __s390x_sys_##sname(void); \ ALLOW_ERROR_INJECTION(__s390x_sys_##sname, ERRNO); \ long __s390_sys_##sname(void) \ @@ -129,7 +129,7 @@ #define __S390_SYS_STUBx(x, fullname, name, ...)
#define SYSCALL_DEFINE0(sname) \ - SYSCALL_METADATA(_##sname, 0); \ + SYSCALL_METADATA(0, _##sname); \ long __s390x_sys_##sname(void); \ ALLOW_ERROR_INJECTION(__s390x_sys_##sname, ERRNO); \ long __s390x_sys_##sname(void) diff --git a/arch/x86/include/asm/syscall_wrapper.h b/arch/x86/include/asm/syscall_wrapper.h index 59358d1bf880..c39adc4810f0 100644 --- a/arch/x86/include/asm/syscall_wrapper.h +++ b/arch/x86/include/asm/syscall_wrapper.h @@ -247,7 +247,7 @@ extern long __ia32_sys_ni_syscall(const struct pt_regs *regs); * macros to work correctly. */ #define SYSCALL_DEFINE0(sname) \ - SYSCALL_METADATA(_##sname, 0); \ + SYSCALL_METADATA(0, _##sname); \ static long __do_sys_##sname(const struct pt_regs *__unused); \ __X64_SYS_STUB0(sname) \ __IA32_SYS_STUB0(sname) \ diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index 8a6f561ce1de..4bd6d9a4c6ea 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h @@ -193,7 +193,7 @@ extern struct trace_event_functions exit_syscall_print_funcs; __section("_ftrace_events") \ *__event_exit_##sname = &event_exit_##sname;
-#define SYSCALL_METADATA(sname, nb, ...) \ +#define __SYSCALL_METADATA(nb, sname, ...) \ static const char *types_##sname[] = { \ __MAP(nb,__SC_STR_TDECL,__VA_ARGS__) \ }; \ @@ -224,7 +224,7 @@ static inline int is_syscall_trace_event(struct trace_event_call *tp_event) }
#else -#define SYSCALL_METADATA(sname, nb, ...) +#define __SYSCALL_METADATA(nb, sname, ...)
static inline int is_syscall_trace_event(struct trace_event_call *tp_event) { @@ -232,6 +232,11 @@ static inline int is_syscall_trace_event(struct trace_event_call *tp_event) } #endif
+#ifndef SYSCALL_METADATA +#define SYSCALL_METADATA(nb, sname, ...) \ + __SYSCALL_METADATA(nb, sname, __VA_ARGS__) +#endif + #ifndef __retptr__ #define __retptr__(name) name #undef SYSCALL_PREP @@ -240,7 +245,7 @@ static inline int is_syscall_trace_event(struct trace_event_call *tp_event)
#ifndef SYSCALL_DEFINE0 #define SYSCALL_DEFINE0(sname) \ - SYSCALL_METADATA(_##sname, 0); \ + SYSCALL_METADATA(0, _##sname); \ asmlinkage long sys_##sname(void); \ ALLOW_ERROR_INJECTION(sys_##sname, ERRNO); \ asmlinkage long sys_##sname(void) @@ -256,7 +261,7 @@ static inline int is_syscall_trace_event(struct trace_event_call *tp_event) #define SYSCALL_DEFINE_MAXARGS 6
#define SYSCALL_DEFINEx(x, sname, ...) \ - SYSCALL_METADATA(sname, x, __VA_ARGS__) \ + SYSCALL_METADATA(x, sname, __VA_ARGS__) \ __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
#define __PROTECT(...) asmlinkage_protect(__VA_ARGS__)