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

arch/tile: Use <asm-generic/syscalls.h>

With this change we now include <asm-generic/syscalls.h> into the "tile"
version of the header. To take full advantage of the prototypes there,
we also change our naming convention for "struct pt_regs *" syscalls so
that, e.g., _sys_execve() is the "true" syscall entry, which sets the
appropriate register to point to the pt_regs before calling sys_execve().

While doing this I realized I no longer needed the fork and vfork
entry point stubs, since those functions aren't in the generic
syscall ABI, so I removed them as well.

Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>

+76 -103
+12 -3
arch/tile/include/asm/compat.h
··· 216 216 struct compat_sigaltstack; 217 217 long compat_sys_execve(const char __user *path, 218 218 const compat_uptr_t __user *argv, 219 - const compat_uptr_t __user *envp); 219 + const compat_uptr_t __user *envp, struct pt_regs *); 220 220 long compat_sys_rt_sigaction(int sig, struct compat_sigaction __user *act, 221 221 struct compat_sigaction __user *oact, 222 222 size_t sigsetsize); 223 223 long compat_sys_rt_sigqueueinfo(int pid, int sig, 224 224 struct compat_siginfo __user *uinfo); 225 - long compat_sys_rt_sigreturn(void); 225 + long compat_sys_rt_sigreturn(struct pt_regs *); 226 226 long compat_sys_sigaltstack(const struct compat_sigaltstack __user *uss_ptr, 227 - struct compat_sigaltstack __user *uoss_ptr); 227 + struct compat_sigaltstack __user *uoss_ptr, 228 + struct pt_regs *); 228 229 long compat_sys_truncate64(char __user *filename, u32 dummy, u32 low, u32 high); 229 230 long compat_sys_ftruncate64(unsigned int fd, u32 dummy, u32 low, u32 high); 230 231 long compat_sys_pread64(unsigned int fd, char __user *ubuf, size_t count, ··· 255 254 256 255 /* Tilera Linux syscalls that don't have "compat" versions. */ 257 256 #define compat_sys_flush_cache sys_flush_cache 257 + 258 + /* These are the intvec_64.S trampolines. */ 259 + long _compat_sys_execve(const char __user *path, 260 + const compat_uptr_t __user *argv, 261 + const compat_uptr_t __user *envp); 262 + long _compat_sys_sigaltstack(const struct compat_sigaltstack __user *uss_ptr, 263 + struct compat_sigaltstack __user *uoss_ptr); 264 + long _compat_sys_rt_sigreturn(void); 258 265 259 266 #endif /* _ASM_TILE_COMPAT_H */
+18 -55
arch/tile/include/asm/syscalls.h
··· 32 32 33 33 /* 34 34 * Note that by convention, any syscall which requires the current 35 - * register set takes an additional "struct pt_regs *" pointer; the 36 - * sys_xxx() function just adds the pointer and tail-calls to _sys_xxx(). 35 + * register set takes an additional "struct pt_regs *" pointer; a 36 + * _sys_xxx() trampoline in intvec*.S just sets up the pointer and 37 + * jumps to sys_xxx(). 37 38 */ 38 39 39 40 /* kernel/sys.c */ ··· 44 43 int sys32_fadvise64_64(int fd, u32 offset_lo, u32 offset_hi, 45 44 u32 len_lo, u32 len_hi, int advice); 46 45 long sys_flush_cache(void); 47 - long sys_mmap2(unsigned long addr, unsigned long len, 48 - unsigned long prot, unsigned long flags, 49 - unsigned long fd, unsigned long pgoff); 50 - #ifdef __tilegx__ 51 - long sys_mmap(unsigned long addr, unsigned long len, 52 - unsigned long prot, unsigned long flags, 53 - unsigned long fd, off_t pgoff); 46 + #ifndef __tilegx__ /* No mmap() in the 32-bit kernel. */ 47 + #define sys_mmap sys_mmap 54 48 #endif 55 - 56 - /* kernel/process.c */ 57 - long sys_clone(unsigned long clone_flags, unsigned long newsp, 58 - void __user *parent_tid, void __user *child_tid); 59 - long _sys_clone(unsigned long clone_flags, unsigned long newsp, 60 - void __user *parent_tid, void __user *child_tid, 61 - struct pt_regs *regs); 62 - long sys_fork(void); 63 - long _sys_fork(struct pt_regs *regs); 64 - long sys_vfork(void); 65 - long _sys_vfork(struct pt_regs *regs); 66 - long sys_execve(const char __user *filename, 67 - const char __user *const __user *argv, 68 - const char __user *const __user *envp); 69 - long _sys_execve(const char __user *filename, 70 - const char __user *const __user *argv, 71 - const char __user *const __user *envp, struct pt_regs *regs); 72 - 73 - /* kernel/signal.c */ 74 - long sys_sigaltstack(const stack_t __user *, stack_t __user *); 75 - long _sys_sigaltstack(const stack_t __user *, stack_t __user *, 76 - struct pt_regs *); 77 - long sys_rt_sigreturn(void); 78 - long _sys_rt_sigreturn(struct pt_regs *regs); 79 - 80 - /* platform-independent functions */ 81 - long sys_rt_sigsuspend(sigset_t __user *unewset, size_t sigsetsize); 82 - long sys_rt_sigaction(int sig, const struct sigaction __user *act, 83 - struct sigaction __user *oact, size_t sigsetsize); 84 49 85 50 #ifndef __tilegx__ 86 51 /* mm/fault.c */ 87 - int sys_cmpxchg_badaddr(unsigned long address); 88 - int _sys_cmpxchg_badaddr(unsigned long address, struct pt_regs *); 52 + long sys_cmpxchg_badaddr(unsigned long address, struct pt_regs *); 53 + long _sys_cmpxchg_badaddr(unsigned long address); 89 54 #endif 90 55 91 56 #ifdef CONFIG_COMPAT 92 - long compat_sys_execve(const char __user *path, 93 - const compat_uptr_t __user *argv, 94 - const compat_uptr_t __user *envp); 95 - long _compat_sys_execve(const char __user *path, 96 - const compat_uptr_t __user *argv, 97 - const compat_uptr_t __user *envp, 98 - struct pt_regs *regs); 99 - long compat_sys_sigaltstack(const struct compat_sigaltstack __user *uss_ptr, 100 - struct compat_sigaltstack __user *uoss_ptr); 101 - long _compat_sys_sigaltstack(const struct compat_sigaltstack __user *uss_ptr, 102 - struct compat_sigaltstack __user *uoss_ptr, 103 - struct pt_regs *regs); 104 - long compat_sys_rt_sigreturn(void); 105 - long _compat_sys_rt_sigreturn(struct pt_regs *regs); 106 - 107 57 /* These four are not defined for 64-bit, but serve as "compat" syscalls. */ 108 58 long sys_fcntl64(unsigned int fd, unsigned int cmd, unsigned long arg); 109 59 long sys_fstat64(unsigned long fd, struct stat64 __user *statbuf); 110 60 long sys_truncate64(const char __user *path, loff_t length); 111 61 long sys_ftruncate64(unsigned int fd, loff_t length); 112 62 #endif 63 + 64 + /* These are the intvec*.S trampolines. */ 65 + long _sys_sigaltstack(const stack_t __user *, stack_t __user *); 66 + long _sys_rt_sigreturn(void); 67 + long _sys_clone(unsigned long clone_flags, unsigned long newsp, 68 + void __user *parent_tid, void __user *child_tid); 69 + long _sys_execve(const char __user *filename, 70 + const char __user *const __user *argv, 71 + const char __user *const __user *envp); 72 + 73 + #include <asm-generic/syscalls.h> 113 74 114 75 #endif /* _ASM_TILE_SYSCALLS_H */
+6
arch/tile/kernel/compat.c
··· 157 157 /* Pass full 64-bit values through ptrace. */ 158 158 #define compat_sys_ptrace tile_compat_sys_ptrace 159 159 160 + /* Call the trampolines to manage pt_regs where necessary. */ 161 + #define compat_sys_execve _compat_sys_execve 162 + #define compat_sys_sigaltstack _compat_sys_sigaltstack 163 + #define compat_sys_rt_sigreturn _compat_sys_rt_sigreturn 164 + #define sys_clone _sys_clone 165 + 160 166 /* 161 167 * Note that we can't include <linux/unistd.h> here since the header 162 168 * guard will defeat us; <asm/unistd.h> checks for __SYSCALL as well.
+5 -5
arch/tile/kernel/compat_signal.c
··· 256 256 return err; 257 257 } 258 258 259 - long _compat_sys_sigaltstack(const struct compat_sigaltstack __user *uss_ptr, 260 - struct compat_sigaltstack __user *uoss_ptr, 261 - struct pt_regs *regs) 259 + long compat_sys_sigaltstack(const struct compat_sigaltstack __user *uss_ptr, 260 + struct compat_sigaltstack __user *uoss_ptr, 261 + struct pt_regs *regs) 262 262 { 263 263 stack_t uss, uoss; 264 264 int ret; ··· 291 291 return ret; 292 292 } 293 293 294 - long _compat_sys_rt_sigreturn(struct pt_regs *regs) 294 + long compat_sys_rt_sigreturn(struct pt_regs *regs) 295 295 { 296 296 struct compat_rt_sigframe __user *frame = 297 297 (struct compat_rt_sigframe __user *) compat_ptr(regs->sp); ··· 312 312 if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &r0)) 313 313 goto badframe; 314 314 315 - if (_compat_sys_sigaltstack(&frame->uc.uc_stack, NULL, regs) != 0) 315 + if (compat_sys_sigaltstack(&frame->uc.uc_stack, NULL, regs) != 0) 316 316 goto badframe; 317 317 318 318 return r0;
+9 -14
arch/tile/kernel/intvec_32.S
··· 1524 1524 1525 1525 /* Put address of pt_regs in reg and jump. */ 1526 1526 #define PTREGS_SYSCALL(x, reg) \ 1527 - STD_ENTRY(x); \ 1527 + STD_ENTRY(_##x); \ 1528 1528 { \ 1529 1529 PTREGS_PTR(reg, PTREGS_OFFSET_BASE); \ 1530 - j _##x \ 1530 + j x \ 1531 1531 }; \ 1532 - STD_ENDPROC(x) 1532 + STD_ENDPROC(_##x) 1533 1533 1534 1534 PTREGS_SYSCALL(sys_execve, r3) 1535 1535 PTREGS_SYSCALL(sys_sigaltstack, r2) 1536 1536 PTREGS_SYSCALL(sys_rt_sigreturn, r0) 1537 + PTREGS_SYSCALL(sys_cmpxchg_badaddr, r1) 1537 1538 1538 - /* Save additional callee-saves to pt_regs, put address in reg and jump. */ 1539 - #define PTREGS_SYSCALL_ALL_REGS(x, reg) \ 1540 - STD_ENTRY(x); \ 1541 - push_extra_callee_saves reg; \ 1542 - j _##x; \ 1543 - STD_ENDPROC(x) 1544 - 1545 - PTREGS_SYSCALL_ALL_REGS(sys_fork, r0) 1546 - PTREGS_SYSCALL_ALL_REGS(sys_vfork, r0) 1547 - PTREGS_SYSCALL_ALL_REGS(sys_clone, r4) 1548 - PTREGS_SYSCALL_ALL_REGS(sys_cmpxchg_badaddr, r1) 1539 + /* Save additional callee-saves to pt_regs, put address in r4 and jump. */ 1540 + STD_ENTRY(_sys_clone) 1541 + push_extra_callee_saves r4 1542 + j sys_clone 1543 + STD_ENDPROC(_sys_clone) 1549 1544 1550 1545 /* 1551 1546 * This entrypoint is taken for the cmpxchg and atomic_update fast
+11 -20
arch/tile/kernel/process.c
··· 528 528 return __switch_to(prev, next, next_current_ksp0(next)); 529 529 } 530 530 531 - long _sys_fork(struct pt_regs *regs) 532 - { 533 - return do_fork(SIGCHLD, regs->sp, regs, 0, NULL, NULL); 534 - } 535 - 536 - long _sys_clone(unsigned long clone_flags, unsigned long newsp, 537 - void __user *parent_tidptr, void __user *child_tidptr, 538 - struct pt_regs *regs) 531 + SYSCALL_DEFINE5(clone, unsigned long, clone_flags, unsigned long, newsp, 532 + void __user *, parent_tidptr, void __user *, child_tidptr, 533 + struct pt_regs *, regs) 539 534 { 540 535 if (!newsp) 541 536 newsp = regs->sp; ··· 538 543 parent_tidptr, child_tidptr); 539 544 } 540 545 541 - long _sys_vfork(struct pt_regs *regs) 542 - { 543 - return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, regs->sp, 544 - regs, 0, NULL, NULL); 545 - } 546 - 547 546 /* 548 547 * sys_execve() executes a new program. 549 548 */ 550 - long _sys_execve(const char __user *path, 551 - const char __user *const __user *argv, 552 - const char __user *const __user *envp, struct pt_regs *regs) 549 + SYSCALL_DEFINE4(execve, const char __user *, path, 550 + const char __user *const __user *, argv, 551 + const char __user *const __user *, envp, 552 + struct pt_regs *, regs) 553 553 { 554 554 long error; 555 555 char *filename; ··· 560 570 } 561 571 562 572 #ifdef CONFIG_COMPAT 563 - long _compat_sys_execve(const char __user *path, 564 - const compat_uptr_t __user *argv, 565 - const compat_uptr_t __user *envp, struct pt_regs *regs) 573 + long compat_sys_execve(const char __user *path, 574 + const compat_uptr_t __user *argv, 575 + const compat_uptr_t __user *envp, 576 + struct pt_regs *regs) 566 577 { 567 578 long error; 568 579 char *filename;
+3 -3
arch/tile/kernel/signal.c
··· 41 41 #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) 42 42 43 43 44 - long _sys_sigaltstack(const stack_t __user *uss, 45 - stack_t __user *uoss, struct pt_regs *regs) 44 + SYSCALL_DEFINE3(sigaltstack, const stack_t __user *, uss, 45 + stack_t __user *, uoss, struct pt_regs *, regs) 46 46 { 47 47 return do_sigaltstack(uss, uoss, regs->sp); 48 48 } ··· 78 78 } 79 79 80 80 /* sigreturn() returns long since it restores r0 in the interrupted code. */ 81 - long _sys_rt_sigreturn(struct pt_regs *regs) 81 + SYSCALL_DEFINE1(rt_sigreturn, struct pt_regs *, regs) 82 82 { 83 83 struct rt_sigframe __user *frame = 84 84 (struct rt_sigframe __user *)(regs->sp);
+9
arch/tile/kernel/sys.c
··· 110 110 #define sys_sync_file_range sys_sync_file_range2 111 111 #endif 112 112 113 + /* Call the trampolines to manage pt_regs where necessary. */ 114 + #define sys_execve _sys_execve 115 + #define sys_sigaltstack _sys_sigaltstack 116 + #define sys_rt_sigreturn _sys_rt_sigreturn 117 + #define sys_clone _sys_clone 118 + #ifndef __tilegx__ 119 + #define sys_cmpxchg_badaddr _sys_cmpxchg_badaddr 120 + #endif 121 + 113 122 /* 114 123 * Note that we can't include <linux/unistd.h> here since the header 115 124 * guard will defeat us; <asm/unistd.h> checks for __SYSCALL as well.
+3 -3
arch/tile/mm/fault.c
··· 66 66 #ifndef __tilegx__ 67 67 /* 68 68 * Synthesize the fault a PL0 process would get by doing a word-load of 69 - * an unaligned address or a high kernel address. Called indirectly 70 - * from sys_cmpxchg() in kernel/intvec.S. 69 + * an unaligned address or a high kernel address. 71 70 */ 72 - int _sys_cmpxchg_badaddr(unsigned long address, struct pt_regs *regs) 71 + SYSCALL_DEFINE2(cmpxchg_badaddr, unsigned long, address, 72 + struct pt_regs *, regs) 73 73 { 74 74 if (address >= PAGE_OFFSET) 75 75 force_sig_info_fault(SIGSEGV, SEGV_MAPERR, address,