aboutsummaryrefslogtreecommitdiffstats
path: root/arch/microblaze/kernel
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-08-09 12:58:12 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-08-09 12:58:12 -0400
commit63b12bdb0d21aca527996fb2c547387bfd3e14b8 (patch)
tree6ab83b2a1c289f30fea18b88f04138ee69c37c6f /arch/microblaze/kernel
parentad1f5caf34390bb20fdbb4eaf71b0494e89936f0 (diff)
parent059ade650ae57cfd371af690fdba887af04aded8 (diff)
Merge branch 'signal-cleanup' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/misc
Pull arch signal handling cleanup from Richard Weinberger: "This patch series moves all remaining archs to the get_signal(), signal_setup_done() and sigsp() functions. Currently these archs use open coded variants of the said functions. Further, unused parameters get removed from get_signal_to_deliver(), tracehook_signal_handler() and signal_delivered(). At the end of the day we save around 500 lines of code." * 'signal-cleanup' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/misc: (43 commits) powerpc: Use sigsp() openrisc: Use sigsp() mn10300: Use sigsp() mips: Use sigsp() microblaze: Use sigsp() metag: Use sigsp() m68k: Use sigsp() m32r: Use sigsp() hexagon: Use sigsp() frv: Use sigsp() cris: Use sigsp() c6x: Use sigsp() blackfin: Use sigsp() avr32: Use sigsp() arm64: Use sigsp() arc: Use sigsp() sas_ss_flags: Remove nested ternary if Rip out get_signal_to_deliver() Clean up signal_delivered() tracehook_signal_handler: Remove sig, info, ka and regs ...
Diffstat (limited to 'arch/microblaze/kernel')
-rw-r--r--arch/microblaze/kernel/signal.c55
1 files changed, 19 insertions, 36 deletions
diff --git a/arch/microblaze/kernel/signal.c b/arch/microblaze/kernel/signal.c
index 49a07a4d76d0..8955a3829cf0 100644
--- a/arch/microblaze/kernel/signal.c
+++ b/arch/microblaze/kernel/signal.c
@@ -145,22 +145,19 @@ setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs,
145 * Determine which stack to use.. 145 * Determine which stack to use..
146 */ 146 */
147static inline void __user * 147static inline void __user *
148get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size) 148get_sigframe(struct ksignal *ksig, struct pt_regs *regs, size_t frame_size)
149{ 149{
150 /* Default to using normal stack */ 150 /* Default to using normal stack */
151 unsigned long sp = regs->r1; 151 unsigned long sp = sigsp(regs->r1, ksig);
152
153 if ((ka->sa.sa_flags & SA_ONSTACK) != 0 && !on_sig_stack(sp))
154 sp = current->sas_ss_sp + current->sas_ss_size;
155 152
156 return (void __user *)((sp - frame_size) & -8UL); 153 return (void __user *)((sp - frame_size) & -8UL);
157} 154}
158 155
159static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, 156static int setup_rt_frame(struct ksignal *ksig, sigset_t *set,
160 sigset_t *set, struct pt_regs *regs) 157 struct pt_regs *regs)
161{ 158{
162 struct rt_sigframe __user *frame; 159 struct rt_sigframe __user *frame;
163 int err = 0; 160 int err = 0, sig = ksig->sig;
164 int signal; 161 int signal;
165 unsigned long address = 0; 162 unsigned long address = 0;
166#ifdef CONFIG_MMU 163#ifdef CONFIG_MMU
@@ -168,10 +165,10 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
168 pte_t *ptep; 165 pte_t *ptep;
169#endif 166#endif
170 167
171 frame = get_sigframe(ka, regs, sizeof(*frame)); 168 frame = get_sigframe(ksig, regs, sizeof(*frame));
172 169
173 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) 170 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
174 goto give_sigsegv; 171 return -EFAULT;
175 172
176 signal = current_thread_info()->exec_domain 173 signal = current_thread_info()->exec_domain
177 && current_thread_info()->exec_domain->signal_invmap 174 && current_thread_info()->exec_domain->signal_invmap
@@ -179,8 +176,8 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
179 ? current_thread_info()->exec_domain->signal_invmap[sig] 176 ? current_thread_info()->exec_domain->signal_invmap[sig]
180 : sig; 177 : sig;
181 178
182 if (info) 179 if (ksig->ka.sa.sa_flags & SA_SIGINFO)
183 err |= copy_siginfo_to_user(&frame->info, info); 180 err |= copy_siginfo_to_user(&frame->info, &ksig->info);
184 181
185 /* Create the ucontext. */ 182 /* Create the ucontext. */
186 err |= __put_user(0, &frame->uc.uc_flags); 183 err |= __put_user(0, &frame->uc.uc_flags);
@@ -227,7 +224,7 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
227 flush_dcache_range(address, address + 8); 224 flush_dcache_range(address, address + 8);
228#endif 225#endif
229 if (err) 226 if (err)
230 goto give_sigsegv; 227 return -EFAULT;
231 228
232 /* Set up registers for signal handler */ 229 /* Set up registers for signal handler */
233 regs->r1 = (unsigned long) frame; 230 regs->r1 = (unsigned long) frame;
@@ -237,7 +234,7 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
237 regs->r6 = (unsigned long) &frame->info; /* arg 1: siginfo */ 234 regs->r6 = (unsigned long) &frame->info; /* arg 1: siginfo */
238 regs->r7 = (unsigned long) &frame->uc; /* arg2: ucontext */ 235 regs->r7 = (unsigned long) &frame->uc; /* arg2: ucontext */
239 /* Offset to handle microblaze rtid r14, 0 */ 236 /* Offset to handle microblaze rtid r14, 0 */
240 regs->pc = (unsigned long)ka->sa.sa_handler; 237 regs->pc = (unsigned long)ksig->ka.sa.sa_handler;
241 238
242 set_fs(USER_DS); 239 set_fs(USER_DS);
243 240
@@ -247,10 +244,6 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
247#endif 244#endif
248 245
249 return 0; 246 return 0;
250
251give_sigsegv:
252 force_sigsegv(sig, current);
253 return -EFAULT;
254} 247}
255 248
256/* Handle restarting system calls */ 249/* Handle restarting system calls */
@@ -283,23 +276,15 @@ do_restart:
283 */ 276 */
284 277
285static void 278static void
286handle_signal(unsigned long sig, struct k_sigaction *ka, 279handle_signal(struct ksignal *ksig, struct pt_regs *regs)
287 siginfo_t *info, struct pt_regs *regs)
288{ 280{
289 sigset_t *oldset = sigmask_to_save(); 281 sigset_t *oldset = sigmask_to_save();
290 int ret; 282 int ret;
291 283
292 /* Set up the stack frame */ 284 /* Set up the stack frame */
293 if (ka->sa.sa_flags & SA_SIGINFO) 285 ret = setup_rt_frame(ksig, oldset, regs);
294 ret = setup_rt_frame(sig, ka, info, oldset, regs);
295 else
296 ret = setup_rt_frame(sig, ka, NULL, oldset, regs);
297 286
298 if (ret) 287 signal_setup_done(ret, ksig, test_thread_flag(TIF_SINGLESTEP));
299 return;
300
301 signal_delivered(sig, info, ka, regs,
302 test_thread_flag(TIF_SINGLESTEP));
303} 288}
304 289
305/* 290/*
@@ -313,21 +298,19 @@ handle_signal(unsigned long sig, struct k_sigaction *ka,
313 */ 298 */
314static void do_signal(struct pt_regs *regs, int in_syscall) 299static void do_signal(struct pt_regs *regs, int in_syscall)
315{ 300{
316 siginfo_t info; 301 struct ksignal ksig;
317 int signr; 302
318 struct k_sigaction ka;
319#ifdef DEBUG_SIG 303#ifdef DEBUG_SIG
320 pr_info("do signal: %p %d\n", regs, in_syscall); 304 pr_info("do signal: %p %d\n", regs, in_syscall);
321 pr_info("do signal2: %lx %lx %ld [%lx]\n", regs->pc, regs->r1, 305 pr_info("do signal2: %lx %lx %ld [%lx]\n", regs->pc, regs->r1,
322 regs->r12, current_thread_info()->flags); 306 regs->r12, current_thread_info()->flags);
323#endif 307#endif
324 308
325 signr = get_signal_to_deliver(&info, &ka, regs, NULL); 309 if (get_signal(&ksig)) {
326 if (signr > 0) {
327 /* Whee! Actually deliver the signal. */ 310 /* Whee! Actually deliver the signal. */
328 if (in_syscall) 311 if (in_syscall)
329 handle_restart(regs, &ka, 1); 312 handle_restart(regs, &ksig.ka, 1);
330 handle_signal(signr, &ka, &info, regs); 313 handle_signal(&ksig, regs);
331 return; 314 return;
332 } 315 }
333 316