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

x86/syscalls: Add syscall entry qualifiers

This will let us specify something like 'sys_xyz/foo' instead of
'sys_xyz' in the syscall table, where the 'foo' qualifier conveys
some extra information to the C code.

The intent is to allow things like sys_execve/ptregs to indicate
that sys_execve() touches pt_regs.

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/2de06e33dce62556b3ec662006fcb295504e296e.1454022279.git.luto@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Andy Lutomirski and committed by
Ingo Molnar
cfcbadb4 3e65654e

+29 -16
+2 -2
arch/x86/entry/syscall_32.c
··· 6 6 #include <asm/asm-offsets.h> 7 7 #include <asm/syscall.h> 8 8 9 - #define __SYSCALL_I386(nr, sym) extern asmlinkage long sym(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long) ; 9 + #define __SYSCALL_I386(nr, sym, qual) extern asmlinkage long sym(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long) ; 10 10 #include <asm/syscalls_32.h> 11 11 #undef __SYSCALL_I386 12 12 13 - #define __SYSCALL_I386(nr, sym) [nr] = sym, 13 + #define __SYSCALL_I386(nr, sym, qual) [nr] = sym, 14 14 15 15 extern asmlinkage long sys_ni_syscall(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long); 16 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) extern asmlinkage long sym(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long) ; 9 + #define __SYSCALL_64(nr, sym, qual) 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) [nr] = sym, 13 + #define __SYSCALL_64(nr, sym, qual) [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
+16 -3
arch/x86/entry/syscalls/syscalltbl.sh
··· 3 3 in="$1" 4 4 out="$2" 5 5 6 + syscall_macro() { 7 + abi="$1" 8 + nr="$2" 9 + entry="$3" 10 + 11 + # Entry can be either just a function name or "function/qualifier" 12 + real_entry="${entry%%/*}" 13 + qualifier="${entry:${#real_entry}}" # Strip the function name 14 + qualifier="${qualifier:1}" # Strip the slash, if any 15 + 16 + echo "__SYSCALL_${abi}($nr, $real_entry, $qualifier)" 17 + } 18 + 6 19 emit() { 7 20 abi="$1" 8 21 nr="$2" ··· 29 16 30 17 if [ -z "$compat" ]; then 31 18 if [ -n "$entry" ]; then 32 - echo "__SYSCALL_${abi}($nr, $entry)" 19 + syscall_macro "$abi" "$nr" "$entry" 33 20 fi 34 21 else 35 22 echo "#ifdef CONFIG_X86_32" 36 23 if [ -n "$entry" ]; then 37 - echo "__SYSCALL_${abi}($nr, $entry)" 24 + syscall_macro "$abi" "$nr" "$entry" 38 25 fi 39 26 echo "#else" 40 - echo "__SYSCALL_${abi}($nr, $compat)" 27 + syscall_macro "$abi" "$nr" "$compat" 41 28 echo "#endif" 42 29 fi 43 30 }
+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) [nr] = 1, 10 + #define __SYSCALL_I386(nr, sym, qual) [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) [nr] = 1, 7 + #define __SYSCALL_64(nr, sym, qual) [nr] = 1, 8 8 static char syscalls_64[] = { 9 9 #include <asm/syscalls_64.h> 10 10 }; 11 - #define __SYSCALL_I386(nr, sym) [nr] = 1, 11 + #define __SYSCALL_I386(nr, sym, qual) [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) extern asmlinkage long sym(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long) ; 28 + #define __SYSCALL_I386(nr, sym, qual) 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) [ nr ] = sym, 32 + #define __SYSCALL_I386(nr, sym, qual) [ 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) extern asmlinkage long sym(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long) ; 38 + #define __SYSCALL_64(nr, sym, qual) 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) [ nr ] = sym, 42 + #define __SYSCALL_64(nr, sym, qual) [ 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) [nr] = 1, 12 + #define __SYSCALL_I386(nr, sym, qual) [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) [nr] = 1, 17 + #define __SYSCALL_64(nr, sym, qual) [nr] = 1, 18 18 static char syscalls[] = { 19 19 #include <asm/syscalls_64.h> 20 20 };