powerpc: Enable compile-time check for syscall handlers
PATCH v2 7/14 powerpc: Enable compile-time check for syscall handlers
The table of syscall handlers and registered compatibility syscall handlers has in past been produced using assembly, with function references resolved at link time. This moves link-time errors to compile-time, by rewriting systbl.S in C, and including the linux/syscalls.h, linux/compat.h and asm/syscalls.h headers for prototypes.
---
V1 -> V2: New patch.
---
arch/powerpc/kernel/{systbl.S => systbl.c} | 27 ++++++++++----------
1 file changed, 14 insertions(+), 13 deletions(-)arch/powerpc/kernel/systbl.c renamed from arch/powerpc/kernel/systbl.S +14 -13
@@ -10,31 +10,32 @@* PPC64 updates by Dave Engebretsen ([email protected]) */ -#include <asm/ppc_asm.h> +#include <linux/syscalls.h> +#include <linux/compat.h> +#include <asm/unistd.h> +#include <asm/syscalls.h> -.section .rodata,"a" +#define __SYSCALL_WITH_COMPAT (nr, entry, compat) __SYSCALL(nr, entry) -#ifdef CONFIG_PPC64 - .p2align 3 -#define __SYSCALL (nr, entry) .8byte entry +#ifdef CONFIG_ARCH_HAS_SYSCALL_WRAPPER +#define __SYSCALL (nr, entry) [nr] = __powerpc_##entry, +#define __powerpc_sys_ni_syscall sys_ni_syscall#else -#define __SYSCALL (nr, entry) .long entry +#define __SYSCALL (nr, entry) [nr] = entry,#endif -#define __SYSCALL_WITH_COMPAT (nr, native, compat) __SYSCALL(nr, native) -.globl sys_call_table -sys_call_table: +void *sys_call_table[] = {#ifdef CONFIG_PPC64 #include <asm/syscall_table_64.h> #else #include <asm/syscall_table_32.h> #endif +};#ifdef CONFIG_COMPAT #undef __SYSCALL_WITH_COMPAT#define __SYSCALL_WITH_COMPAT (nr, native, compat) __SYSCALL(nr, compat) -.globl compat_sys_call_table -compat_sys_call_table: -#define compat_sys_sigsuspend sys_sigsuspend +void *compat_sys_call_table[] = {#include <asm/syscall_table_32.h> -#endif +}; +#endif /* CONFIG_COMPAT */
Signature · 1 line
2.34.1
Quoted 37 lines · Rohan McLure
The table of syscall handlers and registered compatibility syscall handlers has in past been produced using assembly, with function references resolved at link time. This moves link-time errors to compile-time, by rewriting
systbl.Sin C, and including thelinux/syscalls.h,linux/compat.handasm/syscalls.hheaders for prototypes.Reported-by Arnd Bergmann <[email protected]>Signed-off-by Rohan McLure <[email protected]>---
V1 -> V2: New patch.
---
arch/powerpc/kernel/{systbl.S =>systbl.c} | 27 ++++++++++----------1 file changed, 14 insertions(+), 13 deletions(-)arch/powerpc/kernel/systbl.c renamed from arch/powerpc/kernel/systbl.S +0
-0@@ -10,31 +10,32 @@* PPC64 updates by Dave Engebretsen ([email protected]) */ arch/powerpc/kernel/systbl.c renamed from arch/powerpc/kernel/systbl.S +4
-1-#include <asm/ppc_asm.h> +#include <linux/syscalls.h> +#include <linux/compat.h> +#include <asm/unistd.h> +#include <asm/syscalls.h>
-.section .rodata,"a"
+#define__SYSCALL_WITH_COMPAT(nr, entry, compat)__SYSCALL(nr, entry)
arch/powerpc/kernel/systbl.c line 22
Quoted 6 lines
arch/powerpc/kernel/systbl.c renamed from arch/powerpc/kernel/systbl.S +3
-3-#ifdef CONFIG_PPC64 - .p2align 3 -#define __SYSCALL (nr, entry) .8byte entry +#ifdef CONFIG_ARCH_HAS_SYSCALL_WRAPPER +#define __SYSCALL (nr, entry) [nr] = __powerpc_##entry, +#define __powerpc_sys_ni_syscall sys_ni_syscall
Keep this until patch 10.
Otherwise looks alright to me.
Quoted 29 lines
#else
arch/powerpc/kernel/systbl.c renamed from arch/powerpc/kernel/systbl.S +1
-1-#define __SYSCALL (nr, entry) .long entry +#define __SYSCALL (nr, entry) [nr] = entry,#endif
-#define__SYSCALL_WITH_COMPAT(nr, native, compat)__SYSCALL(nr, native)
-.globlsys_call_tablearch/powerpc/kernel/systbl.c renamed from arch/powerpc/kernel/systbl.S +1
-1-sys_call_table: +void *sys_call_table[] = {#ifdef
CONFIG_PPC64
#include <asm/syscall_table_64.h>
#else
#include <asm/syscall_table_32.h>
#endif
+};
#ifdefCONFIG_COMPAT
#undef__SYSCALL_WITH_COMPAT
#define__SYSCALL_WITH_COMPAT(nr, native, compat)__SYSCALL(nr, compat)
-.globlcompat_sys_call_tablearch/powerpc/kernel/systbl.c renamed from arch/powerpc/kernel/systbl.S +1
-2-compat_sys_call_table: -#define compat_sys_sigsuspend sys_sigsuspend +void *compat_sys_call_table[] = {#include <
asm/syscall_table_32.h>arch/powerpc/kernel/systbl.c renamed from arch/powerpc/kernel/systbl.S +2
-1-#endif +}; +#endif /* CONFIG_COMPAT */
Signature · 2 lines
Andrew Donnellan OzLabs, ADL Canberra [email protected] IBM Australia Limited