diff options
author | Chris Metcalf <cmetcalf@tilera.com> | 2012-10-23 13:30:54 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-10-23 16:23:58 -0400 |
commit | 6b14e4198c729b748a7f6d22059e6a101d2b241a (patch) | |
tree | 77668782763f74aec995899e919231e81a71d56a /arch | |
parent | 530550651fdfd548d25b6bd5ff4607803540508b (diff) |
arch/tile: eliminate pt_regs trampolines for syscalls
Using the new current_pt_regs() model, we can remove some trampolines
from assembly code and call directly to the C syscall implementations.
rt_sigreturn() and clone() still need some assembly wrapping, but no
longer are passed a pt_regs pointer. sigaltstack() and the
tilepro-specific cmpxchg_badaddr() syscalls are now just straight C.
Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/tile/include/asm/compat.h | 9 | ||||
-rw-r--r-- | arch/tile/include/asm/syscalls.h | 19 | ||||
-rw-r--r-- | arch/tile/kernel/compat.c | 4 | ||||
-rw-r--r-- | arch/tile/kernel/compat_signal.c | 10 | ||||
-rw-r--r-- | arch/tile/kernel/intvec_32.S | 13 | ||||
-rw-r--r-- | arch/tile/kernel/intvec_64.S | 13 | ||||
-rw-r--r-- | arch/tile/kernel/process.c | 6 | ||||
-rw-r--r-- | arch/tile/kernel/signal.c | 9 | ||||
-rw-r--r-- | arch/tile/kernel/sys.c | 8 | ||||
-rw-r--r-- | arch/tile/mm/fault.c | 5 |
10 files changed, 39 insertions, 57 deletions
diff --git a/arch/tile/include/asm/compat.h b/arch/tile/include/asm/compat.h index 3bcf1b94b563..ca61fb4296b3 100644 --- a/arch/tile/include/asm/compat.h +++ b/arch/tile/include/asm/compat.h | |||
@@ -280,10 +280,9 @@ long compat_sys_rt_sigaction(int sig, struct compat_sigaction __user *act, | |||
280 | size_t sigsetsize); | 280 | size_t sigsetsize); |
281 | long compat_sys_rt_sigqueueinfo(int pid, int sig, | 281 | long compat_sys_rt_sigqueueinfo(int pid, int sig, |
282 | struct compat_siginfo __user *uinfo); | 282 | struct compat_siginfo __user *uinfo); |
283 | long compat_sys_rt_sigreturn(struct pt_regs *); | 283 | long compat_sys_rt_sigreturn(void); |
284 | long compat_sys_sigaltstack(const struct compat_sigaltstack __user *uss_ptr, | 284 | long compat_sys_sigaltstack(const struct compat_sigaltstack __user *uss_ptr, |
285 | struct compat_sigaltstack __user *uoss_ptr, | 285 | struct compat_sigaltstack __user *uoss_ptr); |
286 | struct pt_regs *); | ||
287 | long compat_sys_truncate64(char __user *filename, u32 dummy, u32 low, u32 high); | 286 | long compat_sys_truncate64(char __user *filename, u32 dummy, u32 low, u32 high); |
288 | long compat_sys_ftruncate64(unsigned int fd, u32 dummy, u32 low, u32 high); | 287 | long compat_sys_ftruncate64(unsigned int fd, u32 dummy, u32 low, u32 high); |
289 | long compat_sys_pread64(unsigned int fd, char __user *ubuf, size_t count, | 288 | long compat_sys_pread64(unsigned int fd, char __user *ubuf, size_t count, |
@@ -300,9 +299,7 @@ long compat_sys_fallocate(int fd, int mode, | |||
300 | long compat_sys_sched_rr_get_interval(compat_pid_t pid, | 299 | long compat_sys_sched_rr_get_interval(compat_pid_t pid, |
301 | struct compat_timespec __user *interval); | 300 | struct compat_timespec __user *interval); |
302 | 301 | ||
303 | /* These are the intvec_64.S trampolines. */ | 302 | /* Assembly trampoline to avoid clobbering r0. */ |
304 | long _compat_sys_sigaltstack(const struct compat_sigaltstack __user *uss_ptr, | ||
305 | struct compat_sigaltstack __user *uoss_ptr); | ||
306 | long _compat_sys_rt_sigreturn(void); | 303 | long _compat_sys_rt_sigreturn(void); |
307 | 304 | ||
308 | #endif /* _ASM_TILE_COMPAT_H */ | 305 | #endif /* _ASM_TILE_COMPAT_H */ |
diff --git a/arch/tile/include/asm/syscalls.h b/arch/tile/include/asm/syscalls.h index 0d52992f8e05..369696d63e7b 100644 --- a/arch/tile/include/asm/syscalls.h +++ b/arch/tile/include/asm/syscalls.h | |||
@@ -51,8 +51,7 @@ long sys_cacheflush(unsigned long addr, unsigned long len, | |||
51 | 51 | ||
52 | #ifndef __tilegx__ | 52 | #ifndef __tilegx__ |
53 | /* mm/fault.c */ | 53 | /* mm/fault.c */ |
54 | long sys_cmpxchg_badaddr(unsigned long address, struct pt_regs *); | 54 | long sys_cmpxchg_badaddr(unsigned long address); |
55 | long _sys_cmpxchg_badaddr(unsigned long address); | ||
56 | #endif | 55 | #endif |
57 | 56 | ||
58 | #ifdef CONFIG_COMPAT | 57 | #ifdef CONFIG_COMPAT |
@@ -63,15 +62,23 @@ long sys_truncate64(const char __user *path, loff_t length); | |||
63 | long sys_ftruncate64(unsigned int fd, loff_t length); | 62 | long sys_ftruncate64(unsigned int fd, loff_t length); |
64 | #endif | 63 | #endif |
65 | 64 | ||
66 | /* These are the intvec*.S trampolines. */ | 65 | /* Provide versions of standard syscalls that use current_pt_regs(). */ |
67 | long _sys_sigaltstack(const stack_t __user *, stack_t __user *); | 66 | long sys_clone(unsigned long clone_flags, unsigned long newsp, |
68 | long _sys_rt_sigreturn(void); | ||
69 | long _sys_clone(unsigned long clone_flags, unsigned long newsp, | ||
70 | void __user *parent_tid, void __user *child_tid); | 67 | void __user *parent_tid, void __user *child_tid); |
71 | long sys_execve(const char __user *filename, | 68 | long sys_execve(const char __user *filename, |
72 | const char __user *const __user *argv, | 69 | const char __user *const __user *argv, |
73 | const char __user *const __user *envp); | 70 | const char __user *const __user *envp); |
71 | long sys_rt_sigreturn(void); | ||
72 | long sys_sigaltstack(const stack_t __user *, stack_t __user *); | ||
73 | #define sys_clone sys_clone | ||
74 | #define sys_execve sys_execve | 74 | #define sys_execve sys_execve |
75 | #define sys_rt_sigreturn sys_rt_sigreturn | ||
76 | #define sys_sigaltstack sys_sigaltstack | ||
77 | |||
78 | /* These are the intvec*.S trampolines. */ | ||
79 | long _sys_rt_sigreturn(void); | ||
80 | long _sys_clone(unsigned long clone_flags, unsigned long newsp, | ||
81 | void __user *parent_tid, void __user *child_tid); | ||
75 | 82 | ||
76 | #include <asm-generic/syscalls.h> | 83 | #include <asm-generic/syscalls.h> |
77 | 84 | ||
diff --git a/arch/tile/kernel/compat.c b/arch/tile/kernel/compat.c index a8e5a847037c..a2e805569d5d 100644 --- a/arch/tile/kernel/compat.c +++ b/arch/tile/kernel/compat.c | |||
@@ -102,9 +102,9 @@ long compat_sys_sched_rr_get_interval(compat_pid_t pid, | |||
102 | #define compat_sys_fadvise64_64 sys32_fadvise64_64 | 102 | #define compat_sys_fadvise64_64 sys32_fadvise64_64 |
103 | #define compat_sys_readahead sys32_readahead | 103 | #define compat_sys_readahead sys32_readahead |
104 | 104 | ||
105 | /* Call the trampolines to manage pt_regs where necessary. */ | 105 | /* Call the assembly trampolines where necessary. */ |
106 | #define compat_sys_sigaltstack _compat_sys_sigaltstack | ||
107 | #define compat_sys_rt_sigreturn _compat_sys_rt_sigreturn | 106 | #define compat_sys_rt_sigreturn _compat_sys_rt_sigreturn |
107 | #undef sys_clone | ||
108 | #define sys_clone _sys_clone | 108 | #define sys_clone _sys_clone |
109 | 109 | ||
110 | /* | 110 | /* |
diff --git a/arch/tile/kernel/compat_signal.c b/arch/tile/kernel/compat_signal.c index 08b4fe1717bb..210a9bbae963 100644 --- a/arch/tile/kernel/compat_signal.c +++ b/arch/tile/kernel/compat_signal.c | |||
@@ -197,8 +197,7 @@ int copy_siginfo_from_user32(siginfo_t *to, struct compat_siginfo __user *from) | |||
197 | } | 197 | } |
198 | 198 | ||
199 | long compat_sys_sigaltstack(const struct compat_sigaltstack __user *uss_ptr, | 199 | long compat_sys_sigaltstack(const struct compat_sigaltstack __user *uss_ptr, |
200 | struct compat_sigaltstack __user *uoss_ptr, | 200 | struct compat_sigaltstack __user *uoss_ptr) |
201 | struct pt_regs *regs) | ||
202 | { | 201 | { |
203 | stack_t uss, uoss; | 202 | stack_t uss, uoss; |
204 | int ret; | 203 | int ret; |
@@ -219,7 +218,7 @@ long compat_sys_sigaltstack(const struct compat_sigaltstack __user *uss_ptr, | |||
219 | set_fs(KERNEL_DS); | 218 | set_fs(KERNEL_DS); |
220 | ret = do_sigaltstack(uss_ptr ? (stack_t __user __force *)&uss : NULL, | 219 | ret = do_sigaltstack(uss_ptr ? (stack_t __user __force *)&uss : NULL, |
221 | (stack_t __user __force *)&uoss, | 220 | (stack_t __user __force *)&uoss, |
222 | (unsigned long)compat_ptr(regs->sp)); | 221 | (unsigned long)compat_ptr(current_pt_regs()->sp)); |
223 | set_fs(seg); | 222 | set_fs(seg); |
224 | if (ret >= 0 && uoss_ptr) { | 223 | if (ret >= 0 && uoss_ptr) { |
225 | if (!access_ok(VERIFY_WRITE, uoss_ptr, sizeof(*uoss_ptr)) || | 224 | if (!access_ok(VERIFY_WRITE, uoss_ptr, sizeof(*uoss_ptr)) || |
@@ -232,8 +231,9 @@ long compat_sys_sigaltstack(const struct compat_sigaltstack __user *uss_ptr, | |||
232 | } | 231 | } |
233 | 232 | ||
234 | /* The assembly shim for this function arranges to ignore the return value. */ | 233 | /* The assembly shim for this function arranges to ignore the return value. */ |
235 | long compat_sys_rt_sigreturn(struct pt_regs *regs) | 234 | long compat_sys_rt_sigreturn(void) |
236 | { | 235 | { |
236 | struct pt_regs *regs = current_pt_regs(); | ||
237 | struct compat_rt_sigframe __user *frame = | 237 | struct compat_rt_sigframe __user *frame = |
238 | (struct compat_rt_sigframe __user *) compat_ptr(regs->sp); | 238 | (struct compat_rt_sigframe __user *) compat_ptr(regs->sp); |
239 | sigset_t set; | 239 | sigset_t set; |
@@ -248,7 +248,7 @@ long compat_sys_rt_sigreturn(struct pt_regs *regs) | |||
248 | if (restore_sigcontext(regs, &frame->uc.uc_mcontext)) | 248 | if (restore_sigcontext(regs, &frame->uc.uc_mcontext)) |
249 | goto badframe; | 249 | goto badframe; |
250 | 250 | ||
251 | if (compat_sys_sigaltstack(&frame->uc.uc_stack, NULL, regs) != 0) | 251 | if (compat_sys_sigaltstack(&frame->uc.uc_stack, NULL) != 0) |
252 | goto badframe; | 252 | goto badframe; |
253 | 253 | ||
254 | return 0; | 254 | return 0; |
diff --git a/arch/tile/kernel/intvec_32.S b/arch/tile/kernel/intvec_32.S index 174b837ef926..f212bf7cea86 100644 --- a/arch/tile/kernel/intvec_32.S +++ b/arch/tile/kernel/intvec_32.S | |||
@@ -1452,15 +1452,6 @@ STD_ENTRY_LOCAL(bad_intr) | |||
1452 | panic "Unhandled interrupt %#x: PC %#lx" | 1452 | panic "Unhandled interrupt %#x: PC %#lx" |
1453 | STD_ENDPROC(bad_intr) | 1453 | STD_ENDPROC(bad_intr) |
1454 | 1454 | ||
1455 | /* Put address of pt_regs in reg and jump. */ | ||
1456 | #define PTREGS_SYSCALL(x, reg) \ | ||
1457 | STD_ENTRY(_##x); \ | ||
1458 | { \ | ||
1459 | PTREGS_PTR(reg, PTREGS_OFFSET_BASE); \ | ||
1460 | j x \ | ||
1461 | }; \ | ||
1462 | STD_ENDPROC(_##x) | ||
1463 | |||
1464 | /* | 1455 | /* |
1465 | * Special-case sigreturn to not write r0 to the stack on return. | 1456 | * Special-case sigreturn to not write r0 to the stack on return. |
1466 | * This is technically more efficient, but it also avoids difficulties | 1457 | * This is technically more efficient, but it also avoids difficulties |
@@ -1476,11 +1467,9 @@ STD_ENTRY_LOCAL(bad_intr) | |||
1476 | }; \ | 1467 | }; \ |
1477 | STD_ENDPROC(_##x) | 1468 | STD_ENDPROC(_##x) |
1478 | 1469 | ||
1479 | PTREGS_SYSCALL(sys_sigaltstack, r2) | ||
1480 | PTREGS_SYSCALL_SIGRETURN(sys_rt_sigreturn, r0) | 1470 | PTREGS_SYSCALL_SIGRETURN(sys_rt_sigreturn, r0) |
1481 | PTREGS_SYSCALL(sys_cmpxchg_badaddr, r1) | ||
1482 | 1471 | ||
1483 | /* Save additional callee-saves to pt_regs, put address in r4 and jump. */ | 1472 | /* Save additional callee-saves to pt_regs and jump to standard function. */ |
1484 | STD_ENTRY(_sys_clone) | 1473 | STD_ENTRY(_sys_clone) |
1485 | push_extra_callee_saves r4 | 1474 | push_extra_callee_saves r4 |
1486 | j sys_clone | 1475 | j sys_clone |
diff --git a/arch/tile/kernel/intvec_64.S b/arch/tile/kernel/intvec_64.S index 283efedf67d6..54bc9a6678e8 100644 --- a/arch/tile/kernel/intvec_64.S +++ b/arch/tile/kernel/intvec_64.S | |||
@@ -1181,15 +1181,6 @@ STD_ENTRY_LOCAL(bad_intr) | |||
1181 | panic "Unhandled interrupt %#x: PC %#lx" | 1181 | panic "Unhandled interrupt %#x: PC %#lx" |
1182 | STD_ENDPROC(bad_intr) | 1182 | STD_ENDPROC(bad_intr) |
1183 | 1183 | ||
1184 | /* Put address of pt_regs in reg and jump. */ | ||
1185 | #define PTREGS_SYSCALL(x, reg) \ | ||
1186 | STD_ENTRY(_##x); \ | ||
1187 | { \ | ||
1188 | PTREGS_PTR(reg, PTREGS_OFFSET_BASE); \ | ||
1189 | j x \ | ||
1190 | }; \ | ||
1191 | STD_ENDPROC(_##x) | ||
1192 | |||
1193 | /* | 1184 | /* |
1194 | * Special-case sigreturn to not write r0 to the stack on return. | 1185 | * Special-case sigreturn to not write r0 to the stack on return. |
1195 | * This is technically more efficient, but it also avoids difficulties | 1186 | * This is technically more efficient, but it also avoids difficulties |
@@ -1205,14 +1196,12 @@ STD_ENTRY_LOCAL(bad_intr) | |||
1205 | }; \ | 1196 | }; \ |
1206 | STD_ENDPROC(_##x) | 1197 | STD_ENDPROC(_##x) |
1207 | 1198 | ||
1208 | PTREGS_SYSCALL(sys_sigaltstack, r2) | ||
1209 | PTREGS_SYSCALL_SIGRETURN(sys_rt_sigreturn, r0) | 1199 | PTREGS_SYSCALL_SIGRETURN(sys_rt_sigreturn, r0) |
1210 | #ifdef CONFIG_COMPAT | 1200 | #ifdef CONFIG_COMPAT |
1211 | PTREGS_SYSCALL(compat_sys_sigaltstack, r2) | ||
1212 | PTREGS_SYSCALL_SIGRETURN(compat_sys_rt_sigreturn, r0) | 1201 | PTREGS_SYSCALL_SIGRETURN(compat_sys_rt_sigreturn, r0) |
1213 | #endif | 1202 | #endif |
1214 | 1203 | ||
1215 | /* Save additional callee-saves to pt_regs, put address in r4 and jump. */ | 1204 | /* Save additional callee-saves to pt_regs and jump to standard function. */ |
1216 | STD_ENTRY(_sys_clone) | 1205 | STD_ENTRY(_sys_clone) |
1217 | push_extra_callee_saves r4 | 1206 | push_extra_callee_saves r4 |
1218 | j sys_clone | 1207 | j sys_clone |
diff --git a/arch/tile/kernel/process.c b/arch/tile/kernel/process.c index 58f8fd1f0bc2..6e7fb4e41f1c 100644 --- a/arch/tile/kernel/process.c +++ b/arch/tile/kernel/process.c | |||
@@ -584,10 +584,10 @@ int do_work_pending(struct pt_regs *regs, u32 thread_info_flags) | |||
584 | } | 584 | } |
585 | 585 | ||
586 | /* Note there is an implicit fifth argument if (clone_flags & CLONE_SETTLS). */ | 586 | /* Note there is an implicit fifth argument if (clone_flags & CLONE_SETTLS). */ |
587 | SYSCALL_DEFINE5(clone, unsigned long, clone_flags, unsigned long, newsp, | 587 | SYSCALL_DEFINE4(clone, unsigned long, clone_flags, unsigned long, newsp, |
588 | void __user *, parent_tidptr, void __user *, child_tidptr, | 588 | void __user *, parent_tidptr, void __user *, child_tidptr) |
589 | struct pt_regs *, regs) | ||
590 | { | 589 | { |
590 | struct pt_regs *regs = current_pt_regs(); | ||
591 | if (!newsp) | 591 | if (!newsp) |
592 | newsp = regs->sp; | 592 | newsp = regs->sp; |
593 | return do_fork(clone_flags, newsp, regs, 0, | 593 | return do_fork(clone_flags, newsp, regs, 0, |
diff --git a/arch/tile/kernel/signal.c b/arch/tile/kernel/signal.c index 67efb656d104..657a7ace4ab4 100644 --- a/arch/tile/kernel/signal.c +++ b/arch/tile/kernel/signal.c | |||
@@ -37,10 +37,10 @@ | |||
37 | 37 | ||
38 | #define DEBUG_SIG 0 | 38 | #define DEBUG_SIG 0 |
39 | 39 | ||
40 | SYSCALL_DEFINE3(sigaltstack, const stack_t __user *, uss, | 40 | SYSCALL_DEFINE2(sigaltstack, const stack_t __user *, uss, |
41 | stack_t __user *, uoss, struct pt_regs *, regs) | 41 | stack_t __user *, uoss) |
42 | { | 42 | { |
43 | return do_sigaltstack(uss, uoss, regs->sp); | 43 | return do_sigaltstack(uss, uoss, current_pt_regs()->sp); |
44 | } | 44 | } |
45 | 45 | ||
46 | 46 | ||
@@ -83,8 +83,9 @@ void signal_fault(const char *type, struct pt_regs *regs, | |||
83 | } | 83 | } |
84 | 84 | ||
85 | /* The assembly shim for this function arranges to ignore the return value. */ | 85 | /* The assembly shim for this function arranges to ignore the return value. */ |
86 | SYSCALL_DEFINE1(rt_sigreturn, struct pt_regs *, regs) | 86 | SYSCALL_DEFINE0(rt_sigreturn) |
87 | { | 87 | { |
88 | struct pt_regs *regs = current_pt_regs(); | ||
88 | struct rt_sigframe __user *frame = | 89 | struct rt_sigframe __user *frame = |
89 | (struct rt_sigframe __user *)(regs->sp); | 90 | (struct rt_sigframe __user *)(regs->sp); |
90 | sigset_t set; | 91 | sigset_t set; |
diff --git a/arch/tile/kernel/sys.c b/arch/tile/kernel/sys.c index 359e76f68838..02ff5c0ef775 100644 --- a/arch/tile/kernel/sys.c +++ b/arch/tile/kernel/sys.c | |||
@@ -106,13 +106,11 @@ SYSCALL_DEFINE6(mmap, unsigned long, addr, unsigned long, len, | |||
106 | #define sys_readahead sys32_readahead | 106 | #define sys_readahead sys32_readahead |
107 | #endif | 107 | #endif |
108 | 108 | ||
109 | /* Call the trampolines to manage pt_regs where necessary. */ | 109 | /* Call the assembly trampolines where necessary. */ |
110 | #define sys_sigaltstack _sys_sigaltstack | 110 | #undef sys_rt_sigreturn |
111 | #define sys_rt_sigreturn _sys_rt_sigreturn | 111 | #define sys_rt_sigreturn _sys_rt_sigreturn |
112 | #undef sys_clone | ||
112 | #define sys_clone _sys_clone | 113 | #define sys_clone _sys_clone |
113 | #ifndef __tilegx__ | ||
114 | #define sys_cmpxchg_badaddr _sys_cmpxchg_badaddr | ||
115 | #endif | ||
116 | 114 | ||
117 | /* | 115 | /* |
118 | * Note that we can't include <linux/unistd.h> here since the header | 116 | * Note that we can't include <linux/unistd.h> here since the header |
diff --git a/arch/tile/mm/fault.c b/arch/tile/mm/fault.c index fe811fa5f1b9..3d2b81c163a6 100644 --- a/arch/tile/mm/fault.c +++ b/arch/tile/mm/fault.c | |||
@@ -70,9 +70,10 @@ static noinline void force_sig_info_fault(const char *type, int si_signo, | |||
70 | * Synthesize the fault a PL0 process would get by doing a word-load of | 70 | * Synthesize the fault a PL0 process would get by doing a word-load of |
71 | * an unaligned address or a high kernel address. | 71 | * an unaligned address or a high kernel address. |
72 | */ | 72 | */ |
73 | SYSCALL_DEFINE2(cmpxchg_badaddr, unsigned long, address, | 73 | SYSCALL_DEFINE1(cmpxchg_badaddr, unsigned long, address) |
74 | struct pt_regs *, regs) | ||
75 | { | 74 | { |
75 | struct pt_regs *regs = current_pt_regs(); | ||
76 | |||
76 | if (address >= PAGE_OFFSET) | 77 | if (address >= PAGE_OFFSET) |
77 | force_sig_info_fault("atomic segfault", SIGSEGV, SEGV_MAPERR, | 78 | force_sig_info_fault("atomic segfault", SIGSEGV, SEGV_MAPERR, |
78 | address, INT_DTLB_MISS, current, regs); | 79 | address, INT_DTLB_MISS, current, regs); |