blob: b0a6cf4f2cad47a26f6c96a51c9a8e2da5241000 [file] [log] [blame]
Mikael Starvik51533b62005-07-27 11:44:44 -07001/*
2 * Copyright (C) 2003, Axis Communications AB.
3 */
4
5#include <linux/sched.h>
6#include <linux/mm.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +09007#include <linux/slab.h>
Mikael Starvik51533b62005-07-27 11:44:44 -07008#include <linux/kernel.h>
9#include <linux/signal.h>
10#include <linux/errno.h>
11#include <linux/wait.h>
12#include <linux/ptrace.h>
13#include <linux/unistd.h>
14#include <linux/stddef.h>
15#include <linux/syscalls.h>
16#include <linux/vmalloc.h>
17
18#include <asm/io.h>
19#include <asm/processor.h>
20#include <asm/ucontext.h>
21#include <asm/uaccess.h>
Jesper Nilsson556dcee2008-10-21 17:45:58 +020022#include <arch/ptrace.h>
23#include <arch/hwregs/cpu_vect.h>
Mikael Starvik51533b62005-07-27 11:44:44 -070024
25extern unsigned long cris_signal_return_page;
26
27/* Flag to check if a signal is blockable. */
28#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
29
30/*
31 * A syscall in CRIS is really a "break 13" instruction, which is 2
32 * bytes. The registers is manipulated so upon return the instruction
33 * will be executed again.
34 *
35 * This relies on that PC points to the instruction after the break call.
36 */
37#define RESTART_CRIS_SYS(regs) regs->r10 = regs->orig_r10; regs->erp -= 2;
38
39/* Signal frames. */
40struct signal_frame {
41 struct sigcontext sc;
42 unsigned long extramask[_NSIG_WORDS - 1];
43 unsigned char retcode[8]; /* Trampoline code. */
44};
45
46struct rt_signal_frame {
47 struct siginfo *pinfo;
48 void *puc;
49 struct siginfo info;
50 struct ucontext uc;
51 unsigned char retcode[8]; /* Trampoline code. */
52};
53
Jesper Nilsson574852a2008-01-25 16:10:02 +010054void do_signal(int restart, struct pt_regs *regs);
Mikael Starvik51533b62005-07-27 11:44:44 -070055void keep_debug_flags(unsigned long oldccs, unsigned long oldspc,
56 struct pt_regs *regs);
57/*
58 * Swap in the new signal mask, and wait for a signal. Define some
59 * dummy arguments to be able to reach the regs argument.
60 */
61int
Al Viro68f3f162012-05-21 21:42:32 -040062sys_sigsuspend(old_sigset_t mask)
Mikael Starvik51533b62005-07-27 11:44:44 -070063{
Al Viro68f3f162012-05-21 21:42:32 -040064 sigset_t blocked;
65 siginitset(&blocked, mask);
66 return sigsuspend(&blocked);
Mikael Starvik51533b62005-07-27 11:44:44 -070067}
68
69int
70sys_sigaction(int signal, const struct old_sigaction *act,
71 struct old_sigaction *oact)
72{
73 int retval;
74 struct k_sigaction newk;
75 struct k_sigaction oldk;
76
77 if (act) {
78 old_sigset_t mask;
79
80 if (!access_ok(VERIFY_READ, act, sizeof(*act)) ||
81 __get_user(newk.sa.sa_handler, &act->sa_handler) ||
82 __get_user(newk.sa.sa_restorer, &act->sa_restorer))
83 return -EFAULT;
84
85 __get_user(newk.sa.sa_flags, &act->sa_flags);
86 __get_user(mask, &act->sa_mask);
87 siginitset(&newk.sa.sa_mask, mask);
88 }
89
90 retval = do_sigaction(signal, act ? &newk : NULL, oact ? &oldk : NULL);
91
92 if (!retval && oact) {
93 if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) ||
94 __put_user(oldk.sa.sa_handler, &oact->sa_handler) ||
95 __put_user(oldk.sa.sa_restorer, &oact->sa_restorer))
96 return -EFAULT;
97
98 __put_user(oldk.sa.sa_flags, &oact->sa_flags);
99 __put_user(oldk.sa.sa_mask.sig[0], &oact->sa_mask);
100 }
101
102 return retval;
103}
104
105int
106sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss)
107{
108 return do_sigaltstack(uss, uoss, rdusp());
109}
110
111static int
112restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc)
113{
114 unsigned int err = 0;
115 unsigned long old_usp;
116
117 /* Always make any pending restarted system calls return -EINTR */
118 current_thread_info()->restart_block.fn = do_no_restart_syscall;
119
120 /*
121 * Restore the registers from &sc->regs. sc is already checked
122 * for VERIFY_READ since the signal_frame was previously
123 * checked in sys_sigreturn().
124 */
125 if (__copy_from_user(regs, sc, sizeof(struct pt_regs)))
126 goto badframe;
127
128 /* Make that the user-mode flag is set. */
129 regs->ccs |= (1 << (U_CCS_BITNR + CCS_SHIFT));
130
131 /* Restore the old USP. */
132 err |= __get_user(old_usp, &sc->usp);
133 wrusp(old_usp);
134
135 return err;
136
137badframe:
138 return 1;
139}
140
141/* Define some dummy arguments to be able to reach the regs argument. */
142asmlinkage int
143sys_sigreturn(long r10, long r11, long r12, long r13, long mof, long srp,
144 struct pt_regs *regs)
145{
146 sigset_t set;
147 struct signal_frame __user *frame;
148 unsigned long oldspc = regs->spc;
149 unsigned long oldccs = regs->ccs;
150
151 frame = (struct signal_frame *) rdusp();
152
153 /*
154 * Since the signal is stacked on a dword boundary, the frame
155 * should be dword aligned here as well. It it's not, then the
156 * user is trying some funny business.
157 */
158 if (((long)frame) & 3)
159 goto badframe;
160
161 if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
162 goto badframe;
163
164 if (__get_user(set.sig[0], &frame->sc.oldmask) ||
165 (_NSIG_WORDS > 1 && __copy_from_user(&set.sig[1],
166 frame->extramask,
167 sizeof(frame->extramask))))
168 goto badframe;
169
170 sigdelsetmask(&set, ~_BLOCKABLE);
Matt Flemingf3b5e822012-05-11 10:58:00 +1000171 set_current_blocked(&set);
Mikael Starvik51533b62005-07-27 11:44:44 -0700172
173 if (restore_sigcontext(regs, &frame->sc))
174 goto badframe;
175
176 keep_debug_flags(oldccs, oldspc, regs);
177
178 return regs->r10;
179
180badframe:
181 force_sig(SIGSEGV, current);
182 return 0;
183}
184
185/* Define some dummy variables to be able to reach the regs argument. */
186asmlinkage int
187sys_rt_sigreturn(long r10, long r11, long r12, long r13, long mof, long srp,
188 struct pt_regs *regs)
189{
190 sigset_t set;
191 struct rt_signal_frame __user *frame;
192 unsigned long oldspc = regs->spc;
193 unsigned long oldccs = regs->ccs;
194
195 frame = (struct rt_signal_frame *) rdusp();
196
197 /*
198 * Since the signal is stacked on a dword boundary, the frame
199 * should be dword aligned here as well. It it's not, then the
200 * user is trying some funny business.
201 */
202 if (((long)frame) & 3)
203 goto badframe;
204
205 if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
206 goto badframe;
207
208 if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
209 goto badframe;
210
211 sigdelsetmask(&set, ~_BLOCKABLE);
Matt Flemingf3b5e822012-05-11 10:58:00 +1000212 set_current_blocked(&set);
Mikael Starvik51533b62005-07-27 11:44:44 -0700213
214 if (restore_sigcontext(regs, &frame->uc.uc_mcontext))
215 goto badframe;
216
217 if (do_sigaltstack(&frame->uc.uc_stack, NULL, rdusp()) == -EFAULT)
Jesper Nilsson574852a2008-01-25 16:10:02 +0100218 goto badframe;
Mikael Starvik51533b62005-07-27 11:44:44 -0700219
220 keep_debug_flags(oldccs, oldspc, regs);
221
222 return regs->r10;
223
224badframe:
225 force_sig(SIGSEGV, current);
226 return 0;
227}
228
229/* Setup a signal frame. */
230static int
231setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs,
232 unsigned long mask)
233{
234 int err;
235 unsigned long usp;
236
237 err = 0;
238 usp = rdusp();
239
240 /*
241 * Copy the registers. They are located first in sc, so it's
242 * possible to use sc directly.
243 */
244 err |= __copy_to_user(sc, regs, sizeof(struct pt_regs));
245
246 err |= __put_user(mask, &sc->oldmask);
247 err |= __put_user(usp, &sc->usp);
248
249 return err;
250}
251
252/* Figure out where to put the new signal frame - usually on the stack. */
253static inline void __user *
254get_sigframe(struct k_sigaction *ka, struct pt_regs * regs, size_t frame_size)
255{
256 unsigned long sp;
257
258 sp = rdusp();
259
260 /* This is the X/Open sanctioned signal stack switching. */
261 if (ka->sa.sa_flags & SA_ONSTACK) {
262 if (!on_sig_stack(sp))
263 sp = current->sas_ss_sp + current->sas_ss_size;
264 }
265
266 /* Make sure the frame is dword-aligned. */
267 sp &= ~3;
268
269 return (void __user *)(sp - frame_size);
270}
271
272/* Grab and setup a signal frame.
273 *
274 * Basically a lot of state-info is stacked, and arranged for the
Jesper Nilsson574852a2008-01-25 16:10:02 +0100275 * user-mode program to return to the kernel using either a trampiline
Mikael Starvik51533b62005-07-27 11:44:44 -0700276 * which performs the syscall sigreturn(), or a provided user-mode
277 * trampoline.
278 */
Jesper Nilsson574852a2008-01-25 16:10:02 +0100279static int
Mikael Starvik51533b62005-07-27 11:44:44 -0700280setup_frame(int sig, struct k_sigaction *ka, sigset_t *set,
281 struct pt_regs * regs)
282{
283 int err;
284 unsigned long return_ip;
285 struct signal_frame __user *frame;
286
287 err = 0;
288 frame = get_sigframe(ka, regs, sizeof(*frame));
289
290 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
291 goto give_sigsegv;
292
293 err |= setup_sigcontext(&frame->sc, regs, set->sig[0]);
294
295 if (err)
296 goto give_sigsegv;
297
298 if (_NSIG_WORDS > 1) {
299 err |= __copy_to_user(frame->extramask, &set->sig[1],
300 sizeof(frame->extramask));
301 }
302
303 if (err)
304 goto give_sigsegv;
305
306 /*
307 * Set up to return from user-space. If provided, use a stub
308 * already located in user-space.
309 */
310 if (ka->sa.sa_flags & SA_RESTORER) {
311 return_ip = (unsigned long)ka->sa.sa_restorer;
312 } else {
313 /* Trampoline - the desired return ip is in the signal return page. */
314 return_ip = cris_signal_return_page;
315
316 /*
317 * This is movu.w __NR_sigreturn, r9; break 13;
318 *
319 * WE DO NOT USE IT ANY MORE! It's only left here for historical
320 * reasons and because gdb uses it as a signature to notice
321 * signal handler stack frames.
322 */
323 err |= __put_user(0x9c5f, (short __user*)(frame->retcode+0));
324 err |= __put_user(__NR_sigreturn, (short __user*)(frame->retcode+2));
325 err |= __put_user(0xe93d, (short __user*)(frame->retcode+4));
326 }
327
328 if (err)
329 goto give_sigsegv;
330
331 /*
332 * Set up registers for signal handler.
333 *
334 * Where the code enters now.
335 * Where the code enter later.
336 * First argument, signo.
337 */
338 regs->erp = (unsigned long) ka->sa.sa_handler;
339 regs->srp = return_ip;
340 regs->r10 = sig;
341
342 /* Actually move the USP to reflect the stacked frame. */
343 wrusp((unsigned long)frame);
344
Jesper Nilsson574852a2008-01-25 16:10:02 +0100345 return 0;
Mikael Starvik51533b62005-07-27 11:44:44 -0700346
347give_sigsegv:
348 if (sig == SIGSEGV)
349 ka->sa.sa_handler = SIG_DFL;
350
351 force_sig(SIGSEGV, current);
Jesper Nilsson574852a2008-01-25 16:10:02 +0100352 return -EFAULT;
Mikael Starvik51533b62005-07-27 11:44:44 -0700353}
354
Jesper Nilsson574852a2008-01-25 16:10:02 +0100355static int
Mikael Starvik51533b62005-07-27 11:44:44 -0700356setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
357 sigset_t *set, struct pt_regs * regs)
358{
359 int err;
360 unsigned long return_ip;
361 struct rt_signal_frame __user *frame;
362
363 err = 0;
364 frame = get_sigframe(ka, regs, sizeof(*frame));
365
366 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
367 goto give_sigsegv;
368
369 /* TODO: what is the current->exec_domain stuff and invmap ? */
370
371 err |= __put_user(&frame->info, &frame->pinfo);
372 err |= __put_user(&frame->uc, &frame->puc);
373 err |= copy_siginfo_to_user(&frame->info, info);
374
375 if (err)
376 goto give_sigsegv;
377
378 /* Clear all the bits of the ucontext we don't use. */
379 err |= __clear_user(&frame->uc, offsetof(struct ucontext, uc_mcontext));
380 err |= setup_sigcontext(&frame->uc.uc_mcontext, regs, set->sig[0]);
381 err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
382
383 if (err)
384 goto give_sigsegv;
385
386 /*
387 * Set up to return from user-space. If provided, use a stub
388 * already located in user-space.
389 */
390 if (ka->sa.sa_flags & SA_RESTORER) {
391 return_ip = (unsigned long) ka->sa.sa_restorer;
392 } else {
393 /* Trampoline - the desired return ip is in the signal return page. */
394 return_ip = cris_signal_return_page + 6;
395
396 /*
397 * This is movu.w __NR_rt_sigreturn, r9; break 13;
398 *
399 * WE DO NOT USE IT ANY MORE! It's only left here for historical
400 * reasons and because gdb uses it as a signature to notice
401 * signal handler stack frames.
402 */
403 err |= __put_user(0x9c5f, (short __user*)(frame->retcode+0));
404
405 err |= __put_user(__NR_rt_sigreturn,
406 (short __user*)(frame->retcode+2));
407
408 err |= __put_user(0xe93d, (short __user*)(frame->retcode+4));
409 }
410
411 if (err)
412 goto give_sigsegv;
413
414 /*
415 * Set up registers for signal handler.
416 *
417 * Where the code enters now.
418 * Where the code enters later.
419 * First argument is signo.
420 * Second argument is (siginfo_t *).
421 * Third argument is unused.
422 */
423 regs->erp = (unsigned long) ka->sa.sa_handler;
424 regs->srp = return_ip;
425 regs->r10 = sig;
426 regs->r11 = (unsigned long) &frame->info;
427 regs->r12 = 0;
428
429 /* Actually move the usp to reflect the stacked frame. */
430 wrusp((unsigned long)frame);
431
Jesper Nilsson574852a2008-01-25 16:10:02 +0100432 return 0;
Mikael Starvik51533b62005-07-27 11:44:44 -0700433
434give_sigsegv:
435 if (sig == SIGSEGV)
436 ka->sa.sa_handler = SIG_DFL;
437
438 force_sig(SIGSEGV, current);
Jesper Nilsson574852a2008-01-25 16:10:02 +0100439 return -EFAULT;
Mikael Starvik51533b62005-07-27 11:44:44 -0700440}
441
Frederik Schwarzerc03264a2008-12-23 00:54:00 +0100442/* Invoke a signal handler to, well, handle the signal. */
Jesper Nilsson574852a2008-01-25 16:10:02 +0100443static inline int
Mikael Starvik51533b62005-07-27 11:44:44 -0700444handle_signal(int canrestart, unsigned long sig,
445 siginfo_t *info, struct k_sigaction *ka,
446 sigset_t *oldset, struct pt_regs * regs)
447{
Jesper Nilsson574852a2008-01-25 16:10:02 +0100448 int ret;
449
Mikael Starvik51533b62005-07-27 11:44:44 -0700450 /* Check if this got called from a system call. */
451 if (canrestart) {
452 /* If so, check system call restarting. */
453 switch (regs->r10) {
454 case -ERESTART_RESTARTBLOCK:
455 case -ERESTARTNOHAND:
456 /*
457 * This means that the syscall should
458 * only be restarted if there was no
459 * handler for the signal, and since
460 * this point isn't reached unless
461 * there is a handler, there's no need
462 * to restart.
463 */
464 regs->r10 = -EINTR;
465 break;
466
467 case -ERESTARTSYS:
468 /*
469 * This means restart the syscall if
470 * there is no handler, or the handler
471 * was registered with SA_RESTART.
472 */
473 if (!(ka->sa.sa_flags & SA_RESTART)) {
474 regs->r10 = -EINTR;
475 break;
476 }
477
478 /* Fall through. */
479
480 case -ERESTARTNOINTR:
481 /*
482 * This means that the syscall should
483 * be called again after the signal
484 * handler returns.
485 */
486 RESTART_CRIS_SYS(regs);
487 break;
488 }
489 }
490
491 /* Set up the stack frame. */
492 if (ka->sa.sa_flags & SA_SIGINFO)
Jesper Nilsson574852a2008-01-25 16:10:02 +0100493 ret = setup_rt_frame(sig, ka, info, oldset, regs);
Mikael Starvik51533b62005-07-27 11:44:44 -0700494 else
Jesper Nilsson574852a2008-01-25 16:10:02 +0100495 ret = setup_frame(sig, ka, oldset, regs);
Mikael Starvik51533b62005-07-27 11:44:44 -0700496
497 if (ka->sa.sa_flags & SA_ONESHOT)
498 ka->sa.sa_handler = SIG_DFL;
499
Matt Flemingf3b5e822012-05-11 10:58:00 +1000500 if (ret == 0)
501 block_sigmask(ka, sig);
Jesper Nilsson574852a2008-01-25 16:10:02 +0100502
503 return ret;
Mikael Starvik51533b62005-07-27 11:44:44 -0700504}
505
506/*
507 * Note that 'init' is a special process: it doesn't get signals it doesn't
508 * want to handle. Thus you cannot kill init even with a SIGKILL even by
509 * mistake.
510 *
511 * Also note that the regs structure given here as an argument, is the latest
512 * pushed pt_regs. It may or may not be the same as the first pushed registers
513 * when the initial usermode->kernelmode transition took place. Therefore
514 * we can use user_mode(regs) to see if we came directly from kernel or user
515 * mode below.
516 */
Jesper Nilsson574852a2008-01-25 16:10:02 +0100517void
518do_signal(int canrestart, struct pt_regs *regs)
Mikael Starvik51533b62005-07-27 11:44:44 -0700519{
520 int signr;
521 siginfo_t info;
522 struct k_sigaction ka;
Jesper Nilsson574852a2008-01-25 16:10:02 +0100523 sigset_t *oldset;
Mikael Starvik51533b62005-07-27 11:44:44 -0700524
525 /*
526 * The common case should go fast, which is why this point is
527 * reached from kernel-mode. If that's the case, just return
528 * without doing anything.
529 */
530 if (!user_mode(regs))
Jesper Nilsson574852a2008-01-25 16:10:02 +0100531 return;
Mikael Starvik51533b62005-07-27 11:44:44 -0700532
Jesper Nilsson574852a2008-01-25 16:10:02 +0100533 if (test_thread_flag(TIF_RESTORE_SIGMASK))
534 oldset = &current->saved_sigmask;
535 else
Mikael Starvik51533b62005-07-27 11:44:44 -0700536 oldset = &current->blocked;
537
538 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
539
540 if (signr > 0) {
Jesper Nilsson574852a2008-01-25 16:10:02 +0100541 /* Whee! Actually deliver the signal. */
542 if (handle_signal(canrestart, signr, &info, &ka,
543 oldset, regs)) {
544 /* a signal was successfully delivered; the saved
545 * sigmask will have been stored in the signal frame,
546 * and will be restored by sigreturn, so we can simply
547 * clear the TIF_RESTORE_SIGMASK flag */
548 if (test_thread_flag(TIF_RESTORE_SIGMASK))
549 clear_thread_flag(TIF_RESTORE_SIGMASK);
550 }
551
552 return;
Mikael Starvik51533b62005-07-27 11:44:44 -0700553 }
554
555 /* Got here from a system call? */
556 if (canrestart) {
557 /* Restart the system call - no handlers present. */
558 if (regs->r10 == -ERESTARTNOHAND ||
559 regs->r10 == -ERESTARTSYS ||
560 regs->r10 == -ERESTARTNOINTR) {
561 RESTART_CRIS_SYS(regs);
562 }
563
564 if (regs->r10 == -ERESTART_RESTARTBLOCK){
Jesper Nilsson39923322010-08-03 15:55:48 +0200565 regs->r9 = __NR_restart_syscall;
Mikael Starvik51533b62005-07-27 11:44:44 -0700566 regs->erp -= 2;
567 }
568 }
569
Jesper Nilsson574852a2008-01-25 16:10:02 +0100570 /* if there's no signal to deliver, we just put the saved sigmask
571 * back */
572 if (test_thread_flag(TIF_RESTORE_SIGMASK)) {
573 clear_thread_flag(TIF_RESTORE_SIGMASK);
574 sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
575 }
Mikael Starvik51533b62005-07-27 11:44:44 -0700576}
577
578asmlinkage void
579ugdb_trap_user(struct thread_info *ti, int sig)
580{
581 if (((user_regs(ti)->exs & 0xff00) >> 8) != SINGLE_STEP_INTR_VECT) {
582 /* Zero single-step PC if the reason we stopped wasn't a single
583 step exception. This is to avoid relying on it when it isn't
584 reliable. */
585 user_regs(ti)->spc = 0;
586 }
587 /* FIXME: Filter out false h/w breakpoint hits (i.e. EDA
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300588 not within any configured h/w breakpoint range). Synchronize with
Mikael Starvik51533b62005-07-27 11:44:44 -0700589 what already exists for kernel debugging. */
590 if (((user_regs(ti)->exs & 0xff00) >> 8) == BREAK_8_INTR_VECT) {
591 /* Break 8: subtract 2 from ERP unless in a delay slot. */
592 if (!(user_regs(ti)->erp & 0x1))
593 user_regs(ti)->erp -= 2;
594 }
595 sys_kill(ti->task->pid, sig);
596}
597
598void
599keep_debug_flags(unsigned long oldccs, unsigned long oldspc,
600 struct pt_regs *regs)
601{
602 if (oldccs & (1 << Q_CCS_BITNR)) {
603 /* Pending single step due to single-stepping the break 13
604 in the signal trampoline: keep the Q flag. */
605 regs->ccs |= (1 << Q_CCS_BITNR);
606 /* S flag should be set - complain if it's not. */
607 if (!(oldccs & (1 << (S_CCS_BITNR + CCS_SHIFT)))) {
608 printk("Q flag but no S flag?");
609 }
610 regs->ccs |= (1 << (S_CCS_BITNR + CCS_SHIFT));
611 /* Assume the SPC is valid and interesting. */
612 regs->spc = oldspc;
613
614 } else if (oldccs & (1 << (S_CCS_BITNR + CCS_SHIFT))) {
615 /* If a h/w bp was set in the signal handler we need
616 to keep the S flag. */
617 regs->ccs |= (1 << (S_CCS_BITNR + CCS_SHIFT));
618 /* Don't keep the old SPC though; if we got here due to
619 a single-step, the Q flag should have been set. */
620 } else if (regs->spc) {
621 /* If we were single-stepping *before* the signal was taken,
622 we don't want to restore that state now, because GDB will
623 have forgotten all about it. */
624 regs->spc = 0;
625 regs->ccs &= ~(1 << (S_CCS_BITNR + CCS_SHIFT));
626 }
627}
628
629/* Set up the trampolines on the signal return page. */
630int __init
631cris_init_signal(void)
632{
Robert P. J. Day5cbded52006-12-13 00:35:56 -0800633 u16* data = kmalloc(PAGE_SIZE, GFP_KERNEL);
Mikael Starvik51533b62005-07-27 11:44:44 -0700634
635 /* This is movu.w __NR_sigreturn, r9; break 13; */
636 data[0] = 0x9c5f;
637 data[1] = __NR_sigreturn;
638 data[2] = 0xe93d;
639 /* This is movu.w __NR_rt_sigreturn, r9; break 13; */
640 data[3] = 0x9c5f;
641 data[4] = __NR_rt_sigreturn;
642 data[5] = 0xe93d;
643
644 /* Map to userspace with appropriate permissions (no write access...) */
645 cris_signal_return_page = (unsigned long)
646 __ioremap_prot(virt_to_phys(data), PAGE_SIZE, PAGE_SIGNAL_TRAMPOLINE);
647
648 return 0;
649}
650
651__initcall(cris_init_signal);