提交 5ac9efa3 编写于 作者: D Dominik Brodowski 提交者: Ingo Molnar

syscalls/core, syscalls/x86: Clean up compat syscall stub naming convention

Tidy the naming convention for compat syscall subs. Hints which describe
the purpose of the stub go in front and receive a double underscore to
denote that they are generated on-the-fly by the COMPAT_SYSCALL_DEFINEx()
macro.

For the generic case, this means:

t            kernel_waitid	# common C function (see kernel/exit.c)

    __do_compat_sys_waitid	# inlined helper doing the actual work
				# (takes original parameters as declared)

T   __se_compat_sys_waitid	# sign-extending C function calling inlined
				# helper (takes parameters of type long,
				# casts them to unsigned long and then to
				# the declared type)

T        compat_sys_waitid      # alias to __se_compat_sys_waitid()
				# (taking parameters as declared), to
				# be included in syscall table

For x86, the naming is as follows:

t            kernel_waitid	# common C function (see kernel/exit.c)

    __do_compat_sys_waitid	# inlined helper doing the actual work
				# (takes original parameters as declared)

t   __se_compat_sys_waitid      # sign-extending C function calling inlined
				# helper (takes parameters of type long,
				# casts them to unsigned long and then to
				# the declared type)

T __ia32_compat_sys_waitid	# IA32_EMULATION 32-bit-ptregs -> C stub,
				# calls __se_compat_sys_waitid(); to be
				# included in syscall table

T  __x32_compat_sys_waitid	# x32 64-bit-ptregs -> C stub, calls
				# __se_compat_sys_waitid(); to be included
				# in syscall table

If only one of IA32_EMULATION and x32 is enabled, __se_compat_sys_waitid()
may be inlined into the stub __{ia32,x32}_compat_sys_waitid().
Suggested-by: NIngo Molnar <mingo@kernel.org>
Signed-off-by: NDominik Brodowski <linux@dominikbrodowski.net>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.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/20180409105145.5364-3-linux@dominikbrodowski.netSigned-off-by: NIngo Molnar <mingo@kernel.org>
上级 e145242e
......@@ -360,7 +360,7 @@ First, the entry in ``arch/x86/entry/syscalls/syscall_32.tbl`` gets an extra
column to indicate that a 32-bit userspace program running on a 64-bit kernel
should hit the compat entry point::
380 i386 xyzzy sys_xyzzy compat_sys_xyzzy
380 i386 xyzzy sys_xyzzy __ia32_compat_sys_xyzzy
Second, you need to figure out what should happen for the x32 ABI version of
the new system call. There's a choice here: the layout of the arguments
......@@ -373,7 +373,7 @@ the compatibility wrapper::
333 64 xyzzy sys_xyzzy
...
555 x32 xyzzy compat_sys_xyzzy
555 x32 xyzzy __x32_compat_sys_xyzzy
If no pointers are involved, then it is preferable to re-use the 64-bit system
call for the x32 ABI (and consequently the entry in
......
......@@ -342,43 +342,43 @@
#
# x32-specific system call numbers start at 512 to avoid cache impact
# for native 64-bit operation. The __compat_sys_x32 stubs are created
# for native 64-bit operation. The __x32_compat_sys stubs are created
# on-the-fly for compat_sys_*() compatibility system calls if X86_X32
# is defined.
#
512 x32 rt_sigaction __compat_sys_x32_rt_sigaction
512 x32 rt_sigaction __x32_compat_sys_rt_sigaction
513 x32 rt_sigreturn sys32_x32_rt_sigreturn
514 x32 ioctl __compat_sys_x32_ioctl
515 x32 readv __compat_sys_x32_readv
516 x32 writev __compat_sys_x32_writev
517 x32 recvfrom __compat_sys_x32_recvfrom
518 x32 sendmsg __compat_sys_x32_sendmsg
519 x32 recvmsg __compat_sys_x32_recvmsg
520 x32 execve __compat_sys_x32_execve/ptregs
521 x32 ptrace __compat_sys_x32_ptrace
522 x32 rt_sigpending __compat_sys_x32_rt_sigpending
523 x32 rt_sigtimedwait __compat_sys_x32_rt_sigtimedwait
524 x32 rt_sigqueueinfo __compat_sys_x32_rt_sigqueueinfo
525 x32 sigaltstack __compat_sys_x32_sigaltstack
526 x32 timer_create __compat_sys_x32_timer_create
527 x32 mq_notify __compat_sys_x32_mq_notify
528 x32 kexec_load __compat_sys_x32_kexec_load
529 x32 waitid __compat_sys_x32_waitid
530 x32 set_robust_list __compat_sys_x32_set_robust_list
531 x32 get_robust_list __compat_sys_x32_get_robust_list
532 x32 vmsplice __compat_sys_x32_vmsplice
533 x32 move_pages __compat_sys_x32_move_pages
534 x32 preadv __compat_sys_x32_preadv64
535 x32 pwritev __compat_sys_x32_pwritev64
536 x32 rt_tgsigqueueinfo __compat_sys_x32_rt_tgsigqueueinfo
537 x32 recvmmsg __compat_sys_x32_recvmmsg
538 x32 sendmmsg __compat_sys_x32_sendmmsg
539 x32 process_vm_readv __compat_sys_x32_process_vm_readv
540 x32 process_vm_writev __compat_sys_x32_process_vm_writev
541 x32 setsockopt __compat_sys_x32_setsockopt
542 x32 getsockopt __compat_sys_x32_getsockopt
543 x32 io_setup __compat_sys_x32_io_setup
544 x32 io_submit __compat_sys_x32_io_submit
545 x32 execveat __compat_sys_x32_execveat/ptregs
546 x32 preadv2 __compat_sys_x32_preadv64v2
547 x32 pwritev2 __compat_sys_x32_pwritev64v2
514 x32 ioctl __x32_compat_sys_ioctl
515 x32 readv __x32_compat_sys_readv
516 x32 writev __x32_compat_sys_writev
517 x32 recvfrom __x32_compat_sys_recvfrom
518 x32 sendmsg __x32_compat_sys_sendmsg
519 x32 recvmsg __x32_compat_sys_recvmsg
520 x32 execve __x32_compat_sys_execve/ptregs
521 x32 ptrace __x32_compat_sys_ptrace
522 x32 rt_sigpending __x32_compat_sys_rt_sigpending
523 x32 rt_sigtimedwait __x32_compat_sys_rt_sigtimedwait
524 x32 rt_sigqueueinfo __x32_compat_sys_rt_sigqueueinfo
525 x32 sigaltstack __x32_compat_sys_sigaltstack
526 x32 timer_create __x32_compat_sys_timer_create
527 x32 mq_notify __x32_compat_sys_mq_notify
528 x32 kexec_load __x32_compat_sys_kexec_load
529 x32 waitid __x32_compat_sys_waitid
530 x32 set_robust_list __x32_compat_sys_set_robust_list
531 x32 get_robust_list __x32_compat_sys_get_robust_list
532 x32 vmsplice __x32_compat_sys_vmsplice
533 x32 move_pages __x32_compat_sys_move_pages
534 x32 preadv __x32_compat_sys_preadv64
535 x32 pwritev __x32_compat_sys_pwritev64
536 x32 rt_tgsigqueueinfo __x32_compat_sys_rt_tgsigqueueinfo
537 x32 recvmmsg __x32_compat_sys_recvmmsg
538 x32 sendmmsg __x32_compat_sys_sendmmsg
539 x32 process_vm_readv __x32_compat_sys_process_vm_readv
540 x32 process_vm_writev __x32_compat_sys_process_vm_writev
541 x32 setsockopt __x32_compat_sys_setsockopt
542 x32 getsockopt __x32_compat_sys_getsockopt
543 x32 io_setup __x32_compat_sys_io_setup
544 x32 io_submit __x32_compat_sys_io_submit
545 x32 execveat __x32_compat_sys_execveat/ptregs
546 x32 preadv2 __x32_compat_sys_preadv64v2
547 x32 pwritev2 __x32_compat_sys_pwritev64v2
......@@ -29,11 +29,11 @@
* case as well.
*/
#define COMPAT_SC_IA32_STUBx(x, name, ...) \
asmlinkage long __compat_sys_ia32##name(const struct pt_regs *regs);\
ALLOW_ERROR_INJECTION(__compat_sys_ia32##name, ERRNO); \
asmlinkage long __compat_sys_ia32##name(const struct pt_regs *regs)\
asmlinkage long __ia32_compat_sys##name(const struct pt_regs *regs);\
ALLOW_ERROR_INJECTION(__ia32_compat_sys##name, ERRNO); \
asmlinkage long __ia32_compat_sys##name(const struct pt_regs *regs)\
{ \
return c_SyS##name(SC_IA32_REGS_TO_ARGS(x,__VA_ARGS__));\
return __se_compat_sys##name(SC_IA32_REGS_TO_ARGS(x,__VA_ARGS__));\
} \
#define SC_IA32_WRAPPERx(x, name, ...) \
......@@ -65,11 +65,11 @@
* with x86_64 obviously do not need such care.
*/
#define COMPAT_SC_X32_STUBx(x, name, ...) \
asmlinkage long __compat_sys_x32##name(const struct pt_regs *regs);\
ALLOW_ERROR_INJECTION(__compat_sys_x32##name, ERRNO); \
asmlinkage long __compat_sys_x32##name(const struct pt_regs *regs)\
asmlinkage long __x32_compat_sys##name(const struct pt_regs *regs);\
ALLOW_ERROR_INJECTION(__x32_compat_sys##name, ERRNO); \
asmlinkage long __x32_compat_sys##name(const struct pt_regs *regs)\
{ \
return c_SyS##name(SC_X86_64_REGS_TO_ARGS(x,__VA_ARGS__));\
return __se_compat_sys##name(SC_X86_64_REGS_TO_ARGS(x,__VA_ARGS__));\
} \
#else /* CONFIG_X86_X32 */
......@@ -84,16 +84,16 @@
* of them. There is no need to implement COMPAT_SYSCALL_DEFINE0, as it is
* unused on x86.
*/
#define COMPAT_SYSCALL_DEFINEx(x, name, ...) \
static long c_SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \
static inline long C_SYSC##name(__MAP(x,__SC_DECL,__VA_ARGS__));\
COMPAT_SC_IA32_STUBx(x, name, __VA_ARGS__) \
COMPAT_SC_X32_STUBx(x, name, __VA_ARGS__) \
static long c_SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \
{ \
return C_SYSC##name(__MAP(x,__SC_DELOUSE,__VA_ARGS__)); \
} \
static inline long C_SYSC##name(__MAP(x,__SC_DECL,__VA_ARGS__))
#define COMPAT_SYSCALL_DEFINEx(x, name, ...) \
static long __se_compat_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \
static inline long __do_compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__));\
COMPAT_SC_IA32_STUBx(x, name, __VA_ARGS__) \
COMPAT_SC_X32_STUBx(x, name, __VA_ARGS__) \
static long __se_compat_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \
{ \
return __do_compat_sys##name(__MAP(x,__SC_DELOUSE,__VA_ARGS__));\
} \
static inline long __do_compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))
/*
* As some compat syscalls may not be implemented, we need to expand
......@@ -101,12 +101,12 @@
* kernel/time/posix-stubs.c to cover this case as well.
*/
#define COND_SYSCALL_COMPAT(name) \
cond_syscall(__compat_sys_ia32_##name); \
cond_syscall(__compat_sys_x32_##name)
cond_syscall(__ia32_compat_sys_##name); \
cond_syscall(__x32_compat_sys_##name)
#define COMPAT_SYS_NI(name) \
SYSCALL_ALIAS(__compat_sys_ia32_##name, sys_ni_posix_timers); \
SYSCALL_ALIAS(__compat_sys_x32_##name, sys_ni_posix_timers)
SYSCALL_ALIAS(__ia32_compat_sys_##name, sys_ni_posix_timers); \
SYSCALL_ALIAS(__x32_compat_sys_##name, sys_ni_posix_timers)
#endif /* CONFIG_COMPAT */
......
......@@ -20,7 +20,7 @@
long ksys_ioperm(unsigned long from, unsigned long num, int turn_on);
#ifdef CONFIG_X86_32
/*
/*
* These definitions are only valid on pure 32-bit systems; x86-64 uses a
* different syscall calling convention
*/
......
......@@ -63,19 +63,24 @@
#define COMPAT_SYSCALL_DEFINE6(name, ...) \
COMPAT_SYSCALL_DEFINEx(6, _##name, __VA_ARGS__)
/*
* The asmlinkage stub is aliased to a function named __se_compat_sys_*() which
* sign-extends 32-bit ints to longs whenever needed. The actual work is
* done within __do_compat_sys_*().
*/
#ifndef COMPAT_SYSCALL_DEFINEx
#define COMPAT_SYSCALL_DEFINEx(x, name, ...) \
asmlinkage long compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__));\
asmlinkage long compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))\
__attribute__((alias(__stringify(compat_SyS##name)))); \
ALLOW_ERROR_INJECTION(compat_sys##name, ERRNO); \
static inline long C_SYSC##name(__MAP(x,__SC_DECL,__VA_ARGS__));\
asmlinkage long compat_SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__));\
asmlinkage long compat_SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__))\
{ \
return C_SYSC##name(__MAP(x,__SC_DELOUSE,__VA_ARGS__)); \
} \
static inline long C_SYSC##name(__MAP(x,__SC_DECL,__VA_ARGS__))
#define COMPAT_SYSCALL_DEFINEx(x, name, ...) \
asmlinkage long compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)); \
asmlinkage long compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \
__attribute__((alias(__stringify(__se_compat_sys##name)))); \
ALLOW_ERROR_INJECTION(compat_sys##name, ERRNO); \
static inline long __do_compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__));\
asmlinkage long __se_compat_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \
asmlinkage long __se_compat_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \
{ \
return __do_compat_sys##name(__MAP(x,__SC_DELOUSE,__VA_ARGS__));\
} \
static inline long __do_compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))
#endif /* COMPAT_SYSCALL_DEFINEx */
#ifndef compat_user_stack_pointer
......
......@@ -31,7 +31,7 @@ def getsizes(file, format):
# strip generated symbols
if name.startswith("__mod_"): continue
if name.startswith("__se_sys"): continue
if name.startswith("compat_SyS_"): continue
if name.startswith("__se_compat_sys"): continue
if name == "linux_banner": continue
# statics and some other optimizations adds random .NUMBER
name = re_NUMBER.sub('', name)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册