Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86/syscalls: Move compat syscall entry handling into syscalltbl.sh

Rather than duplicating the compat entry handling in all
consumers of syscalls_BITS.h, handle it directly in
syscalltbl.sh. Now we generate entries in syscalls_32.h like:

__SYSCALL_I386(5, sys_open)
__SYSCALL_I386(5, compat_sys_open)

and all of its consumers implicitly get the right entry point.

Signed-off-by: Andy Lutomirski <luto@kernel.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/b7c2b501dc0e6e43050e916b95807c3e2e16e9bb.1454022279.git.luto@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Andy Lutomirski and committed by
Ingo Molnar
3e65654e 32324ce1

+31 -23
+2 -8
arch/x86/entry/syscall_32.c
··· 6 6 #include <asm/asm-offsets.h> 7 7 #include <asm/syscall.h> 8 8 9 - #ifdef CONFIG_IA32_EMULATION 10 - #define SYM(sym, compat) compat 11 - #else 12 - #define SYM(sym, compat) sym 13 - #endif 14 - 15 - #define __SYSCALL_I386(nr, sym, compat) extern asmlinkage long SYM(sym, compat)(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long) ; 9 + #define __SYSCALL_I386(nr, sym) extern asmlinkage long sym(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long) ; 16 10 #include <asm/syscalls_32.h> 17 11 #undef __SYSCALL_I386 18 12 19 - #define __SYSCALL_I386(nr, sym, compat) [nr] = SYM(sym, compat), 13 + #define __SYSCALL_I386(nr, sym) [nr] = sym, 20 14 21 15 extern asmlinkage long sys_ni_syscall(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long); 22 16
+2 -2
arch/x86/entry/syscall_64.c
··· 6 6 #include <asm/asm-offsets.h> 7 7 #include <asm/syscall.h> 8 8 9 - #define __SYSCALL_64(nr, sym, compat) extern asmlinkage long sym(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long) ; 9 + #define __SYSCALL_64(nr, sym) extern asmlinkage long sym(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long) ; 10 10 #include <asm/syscalls_64.h> 11 11 #undef __SYSCALL_64 12 12 13 - #define __SYSCALL_64(nr, sym, compat) [nr] = sym, 13 + #define __SYSCALL_64(nr, sym) [nr] = sym, 14 14 15 15 extern long sys_ni_syscall(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long); 16 16
+18 -4
arch/x86/entry/syscalls/syscalltbl.sh
··· 8 8 nr="$2" 9 9 entry="$3" 10 10 compat="$4" 11 - if [ -n "$compat" ]; then 12 - echo "__SYSCALL_${abi}($nr, $entry, $compat)" 13 - elif [ -n "$entry" ]; then 14 - echo "__SYSCALL_${abi}($nr, $entry, $entry)" 11 + 12 + if [ "$abi" == "64" -a -n "$compat" ]; then 13 + echo "a compat entry for a 64-bit syscall makes no sense" >&2 14 + exit 1 15 + fi 16 + 17 + if [ -z "$compat" ]; then 18 + if [ -n "$entry" ]; then 19 + echo "__SYSCALL_${abi}($nr, $entry)" 20 + fi 21 + else 22 + echo "#ifdef CONFIG_X86_32" 23 + if [ -n "$entry" ]; then 24 + echo "__SYSCALL_${abi}($nr, $entry)" 25 + fi 26 + echo "#else" 27 + echo "__SYSCALL_${abi}($nr, $compat)" 28 + echo "#endif" 15 29 fi 16 30 } 17 31
+1 -1
arch/x86/kernel/asm-offsets_32.c
··· 7 7 #include <linux/lguest.h> 8 8 #include "../../../drivers/lguest/lg.h" 9 9 10 - #define __SYSCALL_I386(nr, sym, compat) [nr] = 1, 10 + #define __SYSCALL_I386(nr, sym) [nr] = 1, 11 11 static char syscalls[] = { 12 12 #include <asm/syscalls_32.h> 13 13 };
+2 -2
arch/x86/kernel/asm-offsets_64.c
··· 4 4 5 5 #include <asm/ia32.h> 6 6 7 - #define __SYSCALL_64(nr, sym, compat) [nr] = 1, 7 + #define __SYSCALL_64(nr, sym) [nr] = 1, 8 8 static char syscalls_64[] = { 9 9 #include <asm/syscalls_64.h> 10 10 }; 11 - #define __SYSCALL_I386(nr, sym, compat) [nr] = 1, 11 + #define __SYSCALL_I386(nr, sym) [nr] = 1, 12 12 static char syscalls_ia32[] = { 13 13 #include <asm/syscalls_32.h> 14 14 };
+2 -2
arch/x86/um/sys_call_table_32.c
··· 25 25 26 26 #define old_mmap sys_old_mmap 27 27 28 - #define __SYSCALL_I386(nr, sym, compat) extern asmlinkage long sym(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long) ; 28 + #define __SYSCALL_I386(nr, sym) extern asmlinkage long sym(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long) ; 29 29 #include <asm/syscalls_32.h> 30 30 31 31 #undef __SYSCALL_I386 32 - #define __SYSCALL_I386(nr, sym, compat) [ nr ] = sym, 32 + #define __SYSCALL_I386(nr, sym) [ nr ] = sym, 33 33 34 34 extern asmlinkage long sys_ni_syscall(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long); 35 35
+2 -2
arch/x86/um/sys_call_table_64.c
··· 35 35 #define stub_execveat sys_execveat 36 36 #define stub_rt_sigreturn sys_rt_sigreturn 37 37 38 - #define __SYSCALL_64(nr, sym, compat) extern asmlinkage long sym(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long) ; 38 + #define __SYSCALL_64(nr, sym) extern asmlinkage long sym(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long) ; 39 39 #include <asm/syscalls_64.h> 40 40 41 41 #undef __SYSCALL_64 42 - #define __SYSCALL_64(nr, sym, compat) [ nr ] = sym, 42 + #define __SYSCALL_64(nr, sym) [ nr ] = sym, 43 43 44 44 extern asmlinkage long sys_ni_syscall(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long); 45 45
+2 -2
arch/x86/um/user-offsets.c
··· 9 9 #include <asm/types.h> 10 10 11 11 #ifdef __i386__ 12 - #define __SYSCALL_I386(nr, sym, compat) [nr] = 1, 12 + #define __SYSCALL_I386(nr, sym) [nr] = 1, 13 13 static char syscalls[] = { 14 14 #include <asm/syscalls_32.h> 15 15 }; 16 16 #else 17 - #define __SYSCALL_64(nr, sym, compat) [nr] = 1, 17 + #define __SYSCALL_64(nr, sym) [nr] = 1, 18 18 static char syscalls[] = { 19 19 #include <asm/syscalls_64.h> 20 20 };