aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Metcalf <cmetcalf@tilera.com>2010-10-14 14:34:33 -0400
committerChris Metcalf <cmetcalf@tilera.com>2010-10-14 14:34:33 -0400
commitd929b6aeaacbe78cbfef4a80e3eed1bf0464d984 (patch)
tree5f121a845d616a3926768c2fa1b25c4ae417d9c2
parentce0ecc8abfa9904e27a5f3ac4dd83398b134278d (diff)
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>
-rw-r--r--arch/tile/include/asm/compat.h15
-rw-r--r--arch/tile/include/asm/syscalls.h73
-rw-r--r--arch/tile/kernel/compat.c6
-rw-r--r--arch/tile/kernel/compat_signal.c10
-rw-r--r--arch/tile/kernel/intvec_32.S23
-rw-r--r--arch/tile/kernel/process.c31
-rw-r--r--arch/tile/kernel/signal.c6
-rw-r--r--arch/tile/kernel/sys.c9
-rw-r--r--arch/tile/mm/fault.c6
9 files changed, 76 insertions, 103 deletions
diff --git a/arch/tile/include/asm/compat.h b/arch/tile/include/asm/compat.h
index 8b60ec8b2d19..c3ae570c0a5d 100644
--- a/arch/tile/include/asm/compat.h
+++ b/arch/tile/include/asm/compat.h
@@ -216,15 +216,16 @@ struct compat_siginfo;
216struct compat_sigaltstack; 216struct compat_sigaltstack;
217long compat_sys_execve(const char __user *path, 217long compat_sys_execve(const char __user *path,
218 const compat_uptr_t __user *argv, 218 const compat_uptr_t __user *argv,
219 const compat_uptr_t __user *envp); 219 const compat_uptr_t __user *envp, struct pt_regs *);
220long compat_sys_rt_sigaction(int sig, struct compat_sigaction __user *act, 220long compat_sys_rt_sigaction(int sig, struct compat_sigaction __user *act,
221 struct compat_sigaction __user *oact, 221 struct compat_sigaction __user *oact,
222 size_t sigsetsize); 222 size_t sigsetsize);
223long compat_sys_rt_sigqueueinfo(int pid, int sig, 223long compat_sys_rt_sigqueueinfo(int pid, int sig,
224 struct compat_siginfo __user *uinfo); 224 struct compat_siginfo __user *uinfo);
225long compat_sys_rt_sigreturn(void); 225long compat_sys_rt_sigreturn(struct pt_regs *);
226long compat_sys_sigaltstack(const struct compat_sigaltstack __user *uss_ptr, 226long 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 *);
228long compat_sys_truncate64(char __user *filename, u32 dummy, u32 low, u32 high); 229long compat_sys_truncate64(char __user *filename, u32 dummy, u32 low, u32 high);
229long compat_sys_ftruncate64(unsigned int fd, u32 dummy, u32 low, u32 high); 230long compat_sys_ftruncate64(unsigned int fd, u32 dummy, u32 low, u32 high);
230long compat_sys_pread64(unsigned int fd, char __user *ubuf, size_t count, 231long compat_sys_pread64(unsigned int fd, char __user *ubuf, size_t count,
@@ -255,4 +256,12 @@ long tile_compat_sys_ptrace(compat_long_t request, compat_long_t pid,
255/* Tilera Linux syscalls that don't have "compat" versions. */ 256/* Tilera Linux syscalls that don't have "compat" versions. */
256#define compat_sys_flush_cache sys_flush_cache 257#define compat_sys_flush_cache sys_flush_cache
257 258
259/* These are the intvec_64.S trampolines. */
260long _compat_sys_execve(const char __user *path,
261 const compat_uptr_t __user *argv,
262 const compat_uptr_t __user *envp);
263long _compat_sys_sigaltstack(const struct compat_sigaltstack __user *uss_ptr,
264 struct compat_sigaltstack __user *uoss_ptr);
265long _compat_sys_rt_sigreturn(void);
266
258#endif /* _ASM_TILE_COMPAT_H */ 267#endif /* _ASM_TILE_COMPAT_H */
diff --git a/arch/tile/include/asm/syscalls.h b/arch/tile/include/asm/syscalls.h
index ce99ffefeacf..3b5507c31eae 100644
--- a/arch/tile/include/asm/syscalls.h
+++ b/arch/tile/include/asm/syscalls.h
@@ -32,8 +32,9 @@ extern void *compat_sys_call_table[];
32 32
33/* 33/*
34 * Note that by convention, any syscall which requires the current 34 * Note that by convention, any syscall which requires the current
35 * register set takes an additional "struct pt_regs *" pointer; the 35 * register set takes an additional "struct pt_regs *" pointer; a
36 * sys_xxx() function just adds the pointer and tail-calls to _sys_xxx(). 36 * _sys_xxx() trampoline in intvec*.S just sets up the pointer and
37 * jumps to sys_xxx().
37 */ 38 */
38 39
39/* kernel/sys.c */ 40/* kernel/sys.c */
@@ -43,66 +44,17 @@ long sys32_fadvise64(int fd, u32 offset_lo, u32 offset_hi,
43int sys32_fadvise64_64(int fd, u32 offset_lo, u32 offset_hi, 44int sys32_fadvise64_64(int fd, u32 offset_lo, u32 offset_hi,
44 u32 len_lo, u32 len_hi, int advice); 45 u32 len_lo, u32 len_hi, int advice);
45long sys_flush_cache(void); 46long sys_flush_cache(void);
46long sys_mmap2(unsigned long addr, unsigned long len, 47#ifndef __tilegx__ /* No mmap() in the 32-bit kernel. */
47 unsigned long prot, unsigned long flags, 48#define sys_mmap sys_mmap
48 unsigned long fd, unsigned long pgoff);
49#ifdef __tilegx__
50long sys_mmap(unsigned long addr, unsigned long len,
51 unsigned long prot, unsigned long flags,
52 unsigned long fd, off_t pgoff);
53#endif 49#endif
54 50
55/* kernel/process.c */
56long sys_clone(unsigned long clone_flags, unsigned long newsp,
57 void __user *parent_tid, void __user *child_tid);
58long _sys_clone(unsigned long clone_flags, unsigned long newsp,
59 void __user *parent_tid, void __user *child_tid,
60 struct pt_regs *regs);
61long sys_fork(void);
62long _sys_fork(struct pt_regs *regs);
63long sys_vfork(void);
64long _sys_vfork(struct pt_regs *regs);
65long sys_execve(const char __user *filename,
66 const char __user *const __user *argv,
67 const char __user *const __user *envp);
68long _sys_execve(const char __user *filename,
69 const char __user *const __user *argv,
70 const char __user *const __user *envp, struct pt_regs *regs);
71
72/* kernel/signal.c */
73long sys_sigaltstack(const stack_t __user *, stack_t __user *);
74long _sys_sigaltstack(const stack_t __user *, stack_t __user *,
75 struct pt_regs *);
76long sys_rt_sigreturn(void);
77long _sys_rt_sigreturn(struct pt_regs *regs);
78
79/* platform-independent functions */
80long sys_rt_sigsuspend(sigset_t __user *unewset, size_t sigsetsize);
81long sys_rt_sigaction(int sig, const struct sigaction __user *act,
82 struct sigaction __user *oact, size_t sigsetsize);
83
84#ifndef __tilegx__ 51#ifndef __tilegx__
85/* mm/fault.c */ 52/* mm/fault.c */
86int sys_cmpxchg_badaddr(unsigned long address); 53long sys_cmpxchg_badaddr(unsigned long address, struct pt_regs *);
87int _sys_cmpxchg_badaddr(unsigned long address, struct pt_regs *); 54long _sys_cmpxchg_badaddr(unsigned long address);
88#endif 55#endif
89 56
90#ifdef CONFIG_COMPAT 57#ifdef CONFIG_COMPAT
91long compat_sys_execve(const char __user *path,
92 const compat_uptr_t __user *argv,
93 const compat_uptr_t __user *envp);
94long _compat_sys_execve(const char __user *path,
95 const compat_uptr_t __user *argv,
96 const compat_uptr_t __user *envp,
97 struct pt_regs *regs);
98long compat_sys_sigaltstack(const struct compat_sigaltstack __user *uss_ptr,
99 struct compat_sigaltstack __user *uoss_ptr);
100long _compat_sys_sigaltstack(const struct compat_sigaltstack __user *uss_ptr,
101 struct compat_sigaltstack __user *uoss_ptr,
102 struct pt_regs *regs);
103long compat_sys_rt_sigreturn(void);
104long _compat_sys_rt_sigreturn(struct pt_regs *regs);
105
106/* These four are not defined for 64-bit, but serve as "compat" syscalls. */ 58/* These four are not defined for 64-bit, but serve as "compat" syscalls. */
107long sys_fcntl64(unsigned int fd, unsigned int cmd, unsigned long arg); 59long sys_fcntl64(unsigned int fd, unsigned int cmd, unsigned long arg);
108long sys_fstat64(unsigned long fd, struct stat64 __user *statbuf); 60long sys_fstat64(unsigned long fd, struct stat64 __user *statbuf);
@@ -110,4 +62,15 @@ long sys_truncate64(const char __user *path, loff_t length);
110long sys_ftruncate64(unsigned int fd, loff_t length); 62long sys_ftruncate64(unsigned int fd, loff_t length);
111#endif 63#endif
112 64
65/* These are the intvec*.S trampolines. */
66long _sys_sigaltstack(const stack_t __user *, stack_t __user *);
67long _sys_rt_sigreturn(void);
68long _sys_clone(unsigned long clone_flags, unsigned long newsp,
69 void __user *parent_tid, void __user *child_tid);
70long _sys_execve(const char __user *filename,
71 const char __user *const __user *argv,
72 const char __user *const __user *envp);
73
74#include <asm-generic/syscalls.h>
75
113#endif /* _ASM_TILE_SYSCALLS_H */ 76#endif /* _ASM_TILE_SYSCALLS_H */
diff --git a/arch/tile/kernel/compat.c b/arch/tile/kernel/compat.c
index b1e06d041555..5f24e54bf3c5 100644
--- a/arch/tile/kernel/compat.c
+++ b/arch/tile/kernel/compat.c
@@ -157,6 +157,12 @@ long tile_compat_sys_msgrcv(int msqid,
157/* Pass full 64-bit values through ptrace. */ 157/* Pass full 64-bit values through ptrace. */
158#define compat_sys_ptrace tile_compat_sys_ptrace 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 * Note that we can't include <linux/unistd.h> here since the header 167 * Note that we can't include <linux/unistd.h> here since the header
162 * guard will defeat us; <asm/unistd.h> checks for __SYSCALL as well. 168 * guard will defeat us; <asm/unistd.h> checks for __SYSCALL as well.
diff --git a/arch/tile/kernel/compat_signal.c b/arch/tile/kernel/compat_signal.c
index 9c710db43f13..fb64b99959d4 100644
--- a/arch/tile/kernel/compat_signal.c
+++ b/arch/tile/kernel/compat_signal.c
@@ -256,9 +256,9 @@ int copy_siginfo_from_user32(siginfo_t *to, struct compat_siginfo __user *from)
256 return err; 256 return err;
257} 257}
258 258
259long _compat_sys_sigaltstack(const struct compat_sigaltstack __user *uss_ptr, 259long compat_sys_sigaltstack(const struct compat_sigaltstack __user *uss_ptr,
260 struct compat_sigaltstack __user *uoss_ptr, 260 struct compat_sigaltstack __user *uoss_ptr,
261 struct pt_regs *regs) 261 struct pt_regs *regs)
262{ 262{
263 stack_t uss, uoss; 263 stack_t uss, uoss;
264 int ret; 264 int ret;
@@ -291,7 +291,7 @@ long _compat_sys_sigaltstack(const struct compat_sigaltstack __user *uss_ptr,
291 return ret; 291 return ret;
292} 292}
293 293
294long _compat_sys_rt_sigreturn(struct pt_regs *regs) 294long compat_sys_rt_sigreturn(struct pt_regs *regs)
295{ 295{
296 struct compat_rt_sigframe __user *frame = 296 struct compat_rt_sigframe __user *frame =
297 (struct compat_rt_sigframe __user *) compat_ptr(regs->sp); 297 (struct compat_rt_sigframe __user *) compat_ptr(regs->sp);
@@ -312,7 +312,7 @@ long _compat_sys_rt_sigreturn(struct pt_regs *regs)
312 if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &r0)) 312 if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &r0))
313 goto badframe; 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 goto badframe; 316 goto badframe;
317 317
318 return r0; 318 return r0;
diff --git a/arch/tile/kernel/intvec_32.S b/arch/tile/kernel/intvec_32.S
index 8f58bdff20d7..7c7e9ac2580d 100644
--- a/arch/tile/kernel/intvec_32.S
+++ b/arch/tile/kernel/intvec_32.S
@@ -1524,28 +1524,23 @@ STD_ENTRY_LOCAL(bad_intr)
1524 1524
1525/* Put address of pt_regs in reg and jump. */ 1525/* Put address of pt_regs in reg and jump. */
1526#define PTREGS_SYSCALL(x, reg) \ 1526#define PTREGS_SYSCALL(x, reg) \
1527 STD_ENTRY(x); \ 1527 STD_ENTRY(_##x); \
1528 { \ 1528 { \
1529 PTREGS_PTR(reg, PTREGS_OFFSET_BASE); \ 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
1534PTREGS_SYSCALL(sys_execve, r3) 1534PTREGS_SYSCALL(sys_execve, r3)
1535PTREGS_SYSCALL(sys_sigaltstack, r2) 1535PTREGS_SYSCALL(sys_sigaltstack, r2)
1536PTREGS_SYSCALL(sys_rt_sigreturn, r0) 1536PTREGS_SYSCALL(sys_rt_sigreturn, r0)
1537PTREGS_SYSCALL(sys_cmpxchg_badaddr, r1)
1537 1538
1538/* Save additional callee-saves to pt_regs, put address in reg and jump. */ 1539/* Save additional callee-saves to pt_regs, put address in r4 and jump. */
1539#define PTREGS_SYSCALL_ALL_REGS(x, reg) \ 1540STD_ENTRY(_sys_clone)
1540 STD_ENTRY(x); \ 1541 push_extra_callee_saves r4
1541 push_extra_callee_saves reg; \ 1542 j sys_clone
1542 j _##x; \ 1543 STD_ENDPROC(_sys_clone)
1543 STD_ENDPROC(x)
1544
1545PTREGS_SYSCALL_ALL_REGS(sys_fork, r0)
1546PTREGS_SYSCALL_ALL_REGS(sys_vfork, r0)
1547PTREGS_SYSCALL_ALL_REGS(sys_clone, r4)
1548PTREGS_SYSCALL_ALL_REGS(sys_cmpxchg_badaddr, r1)
1549 1544
1550/* 1545/*
1551 * This entrypoint is taken for the cmpxchg and atomic_update fast 1546 * This entrypoint is taken for the cmpxchg and atomic_update fast
diff --git a/arch/tile/kernel/process.c b/arch/tile/kernel/process.c
index 84c29111756c..42ff73d5f637 100644
--- a/arch/tile/kernel/process.c
+++ b/arch/tile/kernel/process.c
@@ -528,14 +528,9 @@ struct task_struct *__sched _switch_to(struct task_struct *prev,
528 return __switch_to(prev, next, next_current_ksp0(next)); 528 return __switch_to(prev, next, next_current_ksp0(next));
529} 529}
530 530
531long _sys_fork(struct pt_regs *regs) 531SYSCALL_DEFINE5(clone, unsigned long, clone_flags, unsigned long, newsp,
532{ 532 void __user *, parent_tidptr, void __user *, child_tidptr,
533 return do_fork(SIGCHLD, regs->sp, regs, 0, NULL, NULL); 533 struct pt_regs *, regs)
534}
535
536long _sys_clone(unsigned long clone_flags, unsigned long newsp,
537 void __user *parent_tidptr, void __user *child_tidptr,
538 struct pt_regs *regs)
539{ 534{
540 if (!newsp) 535 if (!newsp)
541 newsp = regs->sp; 536 newsp = regs->sp;
@@ -543,18 +538,13 @@ long _sys_clone(unsigned long clone_flags, unsigned long newsp,
543 parent_tidptr, child_tidptr); 538 parent_tidptr, child_tidptr);
544} 539}
545 540
546long _sys_vfork(struct pt_regs *regs)
547{
548 return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, regs->sp,
549 regs, 0, NULL, NULL);
550}
551
552/* 541/*
553 * sys_execve() executes a new program. 542 * sys_execve() executes a new program.
554 */ 543 */
555long _sys_execve(const char __user *path, 544SYSCALL_DEFINE4(execve, const char __user *, path,
556 const char __user *const __user *argv, 545 const char __user *const __user *, argv,
557 const char __user *const __user *envp, struct pt_regs *regs) 546 const char __user *const __user *, envp,
547 struct pt_regs *, regs)
558{ 548{
559 long error; 549 long error;
560 char *filename; 550 char *filename;
@@ -570,9 +560,10 @@ out:
570} 560}
571 561
572#ifdef CONFIG_COMPAT 562#ifdef CONFIG_COMPAT
573long _compat_sys_execve(const char __user *path, 563long compat_sys_execve(const char __user *path,
574 const compat_uptr_t __user *argv, 564 const compat_uptr_t __user *argv,
575 const compat_uptr_t __user *envp, struct pt_regs *regs) 565 const compat_uptr_t __user *envp,
566 struct pt_regs *regs)
576{ 567{
577 long error; 568 long error;
578 char *filename; 569 char *filename;
diff --git a/arch/tile/kernel/signal.c b/arch/tile/kernel/signal.c
index ce183aa1492c..fb28e85ae3ae 100644
--- a/arch/tile/kernel/signal.c
+++ b/arch/tile/kernel/signal.c
@@ -41,8 +41,8 @@
41#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) 41#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
42 42
43 43
44long _sys_sigaltstack(const stack_t __user *uss, 44SYSCALL_DEFINE3(sigaltstack, const stack_t __user *, uss,
45 stack_t __user *uoss, struct pt_regs *regs) 45 stack_t __user *, uoss, struct pt_regs *, regs)
46{ 46{
47 return do_sigaltstack(uss, uoss, regs->sp); 47 return do_sigaltstack(uss, uoss, regs->sp);
48} 48}
@@ -78,7 +78,7 @@ int restore_sigcontext(struct pt_regs *regs,
78} 78}
79 79
80/* sigreturn() returns long since it restores r0 in the interrupted code. */ 80/* sigreturn() returns long since it restores r0 in the interrupted code. */
81long _sys_rt_sigreturn(struct pt_regs *regs) 81SYSCALL_DEFINE1(rt_sigreturn, struct pt_regs *, regs)
82{ 82{
83 struct rt_sigframe __user *frame = 83 struct rt_sigframe __user *frame =
84 (struct rt_sigframe __user *)(regs->sp); 84 (struct rt_sigframe __user *)(regs->sp);
diff --git a/arch/tile/kernel/sys.c b/arch/tile/kernel/sys.c
index f0f87eab8c39..7e764669a022 100644
--- a/arch/tile/kernel/sys.c
+++ b/arch/tile/kernel/sys.c
@@ -110,6 +110,15 @@ SYSCALL_DEFINE6(mmap, unsigned long, addr, unsigned long, len,
110#define sys_sync_file_range sys_sync_file_range2 110#define sys_sync_file_range sys_sync_file_range2
111#endif 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 * Note that we can't include <linux/unistd.h> here since the header 123 * Note that we can't include <linux/unistd.h> here since the header
115 * guard will defeat us; <asm/unistd.h> checks for __SYSCALL as well. 124 * guard will defeat us; <asm/unistd.h> checks for __SYSCALL as well.
diff --git a/arch/tile/mm/fault.c b/arch/tile/mm/fault.c
index 704f3e8a4385..94f579d0a494 100644
--- a/arch/tile/mm/fault.c
+++ b/arch/tile/mm/fault.c
@@ -66,10 +66,10 @@ static noinline void force_sig_info_fault(int si_signo, int si_code,
66#ifndef __tilegx__ 66#ifndef __tilegx__
67/* 67/*
68 * Synthesize the fault a PL0 process would get by doing a word-load of 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 69 * an unaligned address or a high kernel address.
70 * from sys_cmpxchg() in kernel/intvec.S.
71 */ 70 */
72int _sys_cmpxchg_badaddr(unsigned long address, struct pt_regs *regs) 71SYSCALL_DEFINE2(cmpxchg_badaddr, unsigned long, address,
72 struct pt_regs *, regs)
73{ 73{
74 if (address >= PAGE_OFFSET) 74 if (address >= PAGE_OFFSET)
75 force_sig_info_fault(SIGSEGV, SEGV_MAPERR, address, 75 force_sig_info_fault(SIGSEGV, SEGV_MAPERR, address,