From: Jan-Benedict G. <jb...@us...> - 2005-04-25 14:35:31
|
Update of /cvsroot/linux-vax/kernel-2.5/arch/vax/kernel In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27961/kernel Modified Files: clock.c interrupt.c signal.c Log Message: - Numerous touchups. - verify_area() -> access_ok() - Deprecate verify_area() Index: clock.c =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.5/arch/vax/kernel/clock.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- clock.c 25 Apr 2005 09:18:48 -0000 1.7 +++ clock.c 25 Apr 2005 14:35:02 -0000 1.8 @@ -33,7 +33,7 @@ /* this does nothing, and is a placeholder */ void generic_clock_init(void) { - printk (KERN_WARN "No RTC used\n"); + printk (KERN_WARNING "No RTC used\n"); return; } Index: signal.c =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.5/arch/vax/kernel/signal.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- signal.c 18 Nov 2004 09:29:32 -0000 1.14 +++ signal.c 25 Apr 2005 14:35:02 -0000 1.15 @@ -2,7 +2,7 @@ * linux/arch/vax/kernel/signal.c * * From arch/cris/kernel/signal.c - * + * * Based on arch/i386/kernel/signal.c by * Copyright (C) 1991, 1992 Linus Torvalds * 1997-11-28 Modified for POSIX.1b signals by Richard Henderson * @@ -14,7 +14,7 @@ * Authors: Bjorn Wesen (bj...@ax...) * VAX port at...@pe.... * + David Airlie Copyright (C) 2003 - * See syscall.c for details of the call stack layout etc... + * See syscall.c for details of the call stack layout etc... */ #include <linux/sched.h> @@ -38,7 +38,7 @@ #undef DEBUG_SIG /* FIXME: Check this & fixup other regs, like r0 */ -#define RESTART_VAX_SYSCALL(regs) { (regs)->pc -= 4; } +#define RESTART_VAX_SYSCALL(regs) { (regs)->pc -= 4; } #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) @@ -70,8 +70,8 @@ } /* - * atp - it is a little confusing, looking at other ports, as to what the arguments to - * this function are. I'm assuming two args, plus our pushed pt_regs set up by syscall + * atp - it is a little confusing, looking at other ports, as to what the arguments to + * this function are. I'm assuming two args, plus our pushed pt_regs set up by syscall */ int sys_rt_sigsuspend(struct pt_regs *regs,sigset_t *unewset, size_t sigsetsize) @@ -101,18 +101,18 @@ } } -int +int sys_sigaction(int sig, const struct old_sigaction *act, - struct old_sigaction *oact) + struct old_sigaction *oact) { struct k_sigaction new_ka, old_ka; int ret; if (act) { old_sigset_t mask; - if (verify_area(VERIFY_READ, act, sizeof(*act)) || - __get_user(new_ka.sa.sa_handler, &act->sa_handler) || - __get_user(new_ka.sa.sa_restorer, &act->sa_restorer)) + if (!access_ok(VERIFY_READ, act, sizeof(*act)) || + __get_user(new_ka.sa.sa_handler, &act->sa_handler) || + __get_user(new_ka.sa.sa_restorer, &act->sa_restorer)) return -EFAULT; __get_user(new_ka.sa.sa_flags, &act->sa_flags); __get_user(mask, &act->sa_mask); @@ -122,9 +122,9 @@ ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL); if (!ret && oact) { - if (verify_area(VERIFY_WRITE, oact, sizeof(*oact)) || - __put_user(old_ka.sa.sa_handler, &oact->sa_handler) || - __put_user(old_ka.sa.sa_restorer, &oact->sa_restorer)) + if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) || + __put_user(old_ka.sa.sa_handler, &oact->sa_handler) || + __put_user(old_ka.sa.sa_restorer, &oact->sa_restorer)) return -EFAULT; __put_user(old_ka.sa.sa_flags, &oact->sa_flags); __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask); @@ -137,24 +137,23 @@ sys_sigaltstack(const stack_t *uss, stack_t *uoss) { struct pt_regs *regs = (struct pt_regs *) &uss; - return do_sigaltstack(uss, uoss, regs->sp ); + + return do_sigaltstack(uss, uoss, regs->sp); } /* * Do a signal return; undo the signal stack. */ - struct sigframe { - int sig; + int sig; struct sigcontext sc; unsigned long extramask[_NSIG_WORDS-1]; unsigned char retcode[20]; /* trampoline code */ }; - struct rt_sigframe { - int sig; + int sig; struct siginfo *pinfo; void *puc; struct siginfo info; @@ -162,32 +161,34 @@ unsigned char retcode[20]; /* trampoline code */ }; - static int restore_sigcontext(struct pt_regs *regs, struct sigcontext *sc) { unsigned int err = 0; - /* restore the regs from &sc->regs (same as sc, since regs is first) + /* + * Restore the regs from &sc->regs (same as sc, since regs is first) * (sc is already checked for VERIFY_READ since the sigframe was - * checked in sys_sigreturn previously) + * checked in sys_sigreturn previously). */ if (__copy_from_user(regs, sc, sizeof(struct pt_regs))) - goto badframe; + goto badframe; /* FIXME: check user mode flag in restored regs PSW */ - - /* restore the old USP as it was before we stacked the sc etc. + + /* + * Restore the old USP as it was before we stacked the sc etc. * (we cannot just pop the sigcontext since we aligned the sp and - * stuff after pushing it) + * stuff after pushing it). */ - - /* FIXME: check process stack */ - - /* TODO: the other ports use regs->orig_XX to disable syscall checks + + /* FIXME: check process stack */ + + /* + * TODO: the other ports use regs->orig_XX to disable syscall checks * after this completes, but we don't use that mechanism. maybe we can - * use it now ? + * use it now ? */ return err; @@ -199,23 +200,23 @@ asmlinkage int sys_sigreturn(struct pt_regs *regs) { - struct sigframe *frame = (struct sigframe *)(regs->sp); + struct sigframe *frame = (struct sigframe *) (regs->sp); sigset_t set; /* * Since we stacked the signal on a dword boundary, - * then frame should be dword aligned here. If it's + * then frame should be dword aligned here. If it's * not, then the user is trying to mess with us. */ - if (((long)frame) & 3) + if (((long) frame) & 3) goto badframe; - if (verify_area(VERIFY_READ, frame, sizeof(*frame))) + if (!access_ok(VERIFY_READ, frame, sizeof(*frame))) goto badframe; if (__get_user(set.sig[0], &frame->sc.oldmask) - || (_NSIG_WORDS > 1 - && __copy_from_user(&set.sig[1], &frame->extramask, - sizeof(frame->extramask)))) + || (_NSIG_WORDS > 1 + && __copy_from_user(&set.sig[1], &frame->extramask, + sizeof(frame->extramask)))) goto badframe; sigdelsetmask(&set, ~_BLOCKABLE); @@ -223,7 +224,7 @@ current->blocked = set; recalc_sigpending(); spin_unlock_irq(¤t->sighand->siglock); - + if (restore_sigcontext(regs, &frame->sc)) goto badframe; @@ -234,24 +235,24 @@ badframe: force_sig(SIGSEGV, current); return 0; -} +} asmlinkage int sys_rt_sigreturn(struct pt_regs *regs) { - struct rt_sigframe *frame = (struct rt_sigframe *)(regs->sp-8); + struct rt_sigframe *frame = (struct rt_sigframe *) (regs->sp-8); sigset_t set; stack_t st; /* * Since we stacked the signal on a dword boundary, - * then frame should be dword aligned here. If it's + * then frame should be dword aligned here. If it's * not, then the user is trying to mess with us. */ - if (((long)frame) & 3) + if (((long) frame) & 3) goto badframe; - if (verify_area(VERIFY_READ, frame, sizeof(*frame))) + if (!access_ok(VERIFY_READ, frame, sizeof(*frame))) goto badframe; if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set))) goto badframe; @@ -261,14 +262,16 @@ current->blocked = set; recalc_sigpending(); spin_unlock_irq(¤t->sighand->siglock); - + if (restore_sigcontext(regs, &frame->uc.uc_mcontext)) goto badframe; if (__copy_from_user(&st, &frame->uc.uc_stack, sizeof(st))) goto badframe; - /* It is more difficult to avoid calling this function than to - call it and ignore errors. */ + /* + * It is more difficult to avoid calling this function than to + * call it and ignore errors. + */ do_sigaltstack(&st, NULL, (regs->sp)); return regs->r0; @@ -276,12 +279,11 @@ badframe: force_sig(SIGSEGV, current); return 0; -} +} /* * Set up a signal frame. */ - static int setup_sigcontext(struct sigcontext *sc, struct pt_regs *regs, unsigned long mask) { @@ -301,7 +303,7 @@ /* figure out where we want to put the new signal frame - usually on the stack */ static inline void * -get_sigframe(struct k_sigaction *ka, struct pt_regs * regs, size_t frame_size) +get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size) { unsigned long sp = regs->sp; @@ -312,38 +314,36 @@ } /* make sure the frame is dword-aligned */ - + sp &= ~3; return (void *)(sp - frame_size); } -/* grab and setup a signal frame. - * - * basically we stack a lot of state info, and arrange for the +/* Grab and setup a signal frame. + * + * Basically we stack a lot of state info, and arrange for the * user-mode program to return to the kernel using either a * trampoline which performs the syscall sigreturn, or a provided * user-mode trampoline. */ - static void setup_frame(int sig, struct k_sigaction *ka, - sigset_t *set, struct pt_regs * regs) + sigset_t *set, struct pt_regs *regs) { struct sigframe *frame; int err = 0; frame = get_sigframe(ka, regs, sizeof(*frame)); - - -#ifdef DEBUG_SIG + +#ifdef DEBUG_SIG printk("setup_frame: pid %d, sig %d, regs %p, regs->sp %p, frame %p, sigaction %p\n",current->pid,sig,regs,regs->sp,frame,ka); show_regs(regs); -#endif +#endif if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) goto give_sigsegv; /* write the signal onto the stack */ - err |= __put_user(sig, (unsigned int *)&frame->sig); + err |= __put_user(sig, (unsigned int *) &frame->sig); err |= setup_sigcontext(&frame->sc, regs, set->sig[0]); if (err) goto give_sigsegv; @@ -355,49 +355,56 @@ if (err) goto give_sigsegv; - /* Set up to return from userspace. If provided, use a stub - already in userspace. */ - - /* We do this differently to other ports. Each function has a two byte RSM. - * (due to the calling convention). Each sighandler will expect to be - * CALLS'd and will RET from that. So we cant just muck about with PC's on the - * stack like the i386. So we use the trampoline code on the stack a bit more. - * The easiest way to skip around all this is to calls the signal - * handler, and then either calls the restorer, or chmk to sys_sigreturn */ - - /* CALLS $1, */ - err |= __put_user(0xfb, (char *)(frame->retcode+0)); - err |= __put_user(0x01, (char *)(frame->retcode+1)); - /* (absolute address)*/ - err |= __put_user(0x9f, (char *)(frame->retcode+2)); - /* sighandler */ - err |= __put_user(((unsigned long) ka->sa.sa_handler), (unsigned long *)(frame->retcode + 3)); - + /* + * Set up to return from userspace. If provided, use a stub + * already in userspace. + * + * We do this differently to other ports. Each function has a two + * byte RSM (due to the calling convention). Each sighandler will + * expect to be CALLS'd and will RET from that. So we cant just muck + * about with PC's on the stack like the i386. So we use the + * trampoline code on the stack a bit more. The easiest way to skip + * around all this is to calls the signal handler, and then either + * calls the restorer, or chmk to sys_sigreturn. + */ + + /* CALLS $1, */ + err |= __put_user(0xfb, (char *) (frame->retcode + 0)); + err |= __put_user(0x01, (char *) (frame->retcode + 1)); + /* (absolute address)*/ + err |= __put_user(0x9f, (char *) (frame->retcode + 2)); + /* sighandler */ + err |= __put_user(((unsigned long) ka->sa.sa_handler), + (unsigned long *) (frame->retcode + 3)); + if (ka->sa.sa_flags & SA_RESTORER) { - /* CALLS $0,*/ - err |= __put_user(0xfb, (char *)(frame->retcode+7)); - err |= __put_user(0x00, (char *)(frame->retcode+8)); - /* (absolute address)*/ - err |= __put_user(0x9f, (char *)(frame->retcode+9)); - /* restorer */ - err |= __put_user(((unsigned long) ka->sa.sa_restorer), (unsigned long *)(frame->retcode + 10)); + /* CALLS $0,*/ + err |= __put_user(0xfb, (char *) (frame->retcode + 7)); + err |= __put_user(0x00, (char *) (frame->retcode + 8)); + /* (absolute address)*/ + err |= __put_user(0x9f, (char *) (frame->retcode + 9)); + /* restorer */ + err |= __put_user(((unsigned long) ka->sa.sa_restorer), + (unsigned long *) (frame->retcode + 10)); /* plus a halt */ - err |= __put_user(0x00, (char *)(frame->retcode+14)); + err |= __put_user(0x00, (char *) (frame->retcode + 14)); } else { - /* perform a syscall to sys_sigreturn. First set up the - * argument list to avoid confusing it */ - - /* pushl $0x0 */ - err |= __put_user(0xdd, (char *)(frame->retcode+7)); - err |= __put_user(0x00, (char *)(frame->retcode+8)); + /* + * Perform a syscall to sys_sigreturn. First set up the + * argument list to avoid confusing it. + */ + + /* pushl $0x0 */ + err |= __put_user(0xdd, (char *) (frame->retcode + 7)); + err |= __put_user(0x00, (char *) (frame->retcode + 8)); /* movl sp, ap */ - err |= __put_user(0xd0, (char *)(frame->retcode+9)); - err |= __put_user(0x5e, (char *)(frame->retcode+10)); - err |= __put_user(0x5c, (char *)(frame->retcode+11)); + err |= __put_user(0xd0, (char *) (frame->retcode + 9)); + err |= __put_user(0x5e, (char *) (frame->retcode + 10)); + err |= __put_user(0x5c, (char *) (frame->retcode + 11)); /* chmk __NR_sigreturn; */ - err |= __put_user(0xbc, (char *)(frame->retcode+12)); - err |= __put_user(0x8f, (char *)(frame->retcode+13)); - err |= __put_user(__NR_sigreturn, (short *)(frame->retcode+14)); + err |= __put_user(0xbc, (char *) (frame->retcode + 12)); + err |= __put_user(0x8f, (char *) (frame->retcode + 13)); + err |= __put_user(__NR_sigreturn, (short *) (frame->retcode + 14)); /* plus a halt */ err |= __put_user(0x00, (char *)(frame->retcode+16)); } @@ -405,79 +412,85 @@ if (err) goto give_sigsegv; -#ifdef DEBUG_SIG - printk("setup_frame: pid %d, frame->retcode %p, sa_handler %p\n",current->pid,frame->retcode,ka->sa.sa_handler); +#ifdef DEBUG_SIG + printk("setup_frame: pid %d, frame->retcode %p, sa_handler %p\n", + current->pid, + frame->retcode, + ka->sa.sa_handler); #endif - /* Set up registers for signal handler */ - - regs->pc = (unsigned long) frame->retcode; /* what we enter NOW */ - regs->fp = regs->sp; - regs->sp = (unsigned int)frame; - __mtpr(frame,PR_USP); /* and into to the register, ready for REI */ + /* Set up registers for signal handler. */ + regs->pc = (unsigned long) frame->retcode; /* What we enter NOW. */ + regs->fp = regs->sp; + regs->sp = (unsigned int) frame; + __mtpr(frame,PR_USP); /* and into to the register, ready for REI */ -#ifdef DEBUG_SIG - printk("setup_frame: pid %d, regs->pc %8lx, regs->sp %8lx, regs->ap %8lx\n",current->pid,regs->pc,regs->sp,regs->ap); - { - unsigned char c[4]; - __get_user(c[0], (char *)&frame->sig); - __get_user(c[1], (char *)&frame->sig+1); - __get_user(c[2], (char *)&frame->sig+2); - __get_user(c[3], (char *)&frame->sig+3); - printk("setup_frame: %p %1x %p %1x %p %1x %p %1x\n", - &frame->sig, c[0], - &frame->sig+1, c[1], - &frame->sig+2, c[2], - &frame->sig+3, c[3]); - } - { - unsigned char c[4]; - __get_user(c[0], (char *)frame->retcode); - __get_user(c[1], (char *)frame->retcode+1); - __get_user(c[2], (char *)frame->retcode+2); - __get_user(c[3], (char *)frame->retcode+3); - printk("setup_frame: %p %1x %p %1x %p %1x %p %1x\n", - frame->retcode, c[0], - frame->retcode+1, c[1], - frame->retcode+2, c[2], - frame->retcode+3, c[3]); - } - { - unsigned char c[4]; - __get_user(c[0], (char *)frame->retcode+4); - __get_user(c[1], (char *)frame->retcode+5); - __get_user(c[2], (char *)frame->retcode+6); - __get_user(c[3], (char *)frame->retcode+7); - printk("setup_frame: %p %1x %p %1x %p %1x %p %1x\n", - frame->retcode+4, c[0], - frame->retcode+5, c[1], - frame->retcode+6, c[2], - frame->retcode+7, c[3]); - } - { - unsigned char c[4]; - __get_user(c[0], (char *)frame->retcode+8); - __get_user(c[1], (char *)frame->retcode+9); - __get_user(c[2], (char *)frame->retcode+10); - __get_user(c[3], (char *)frame->retcode+11); - printk("setup_frame: %p %1x %p %1x %p %1x %p %1x\n", - frame->retcode+8, c[0], - frame->retcode+9, c[1], - frame->retcode+10, c[2], - frame->retcode+11, c[3]); - } - { - unsigned char c[4]; - __get_user(c[0], (char *)frame->retcode+12); - __get_user(c[1], (char *)frame->retcode+13); - __get_user(c[2], (char *)frame->retcode+14); - __get_user(c[3], (char *)frame->retcode+15); - printk("setup_frame: %p %1x %p %1x %p %1x %p %1x\n", - frame->retcode+12, c[0], - frame->retcode+13, c[1], - frame->retcode+14, c[2], - frame->retcode+15, c[3]); - } -#endif +#ifdef DEBUG_SIG + printk("setup_frame: pid %d, regs->pc %8lx, regs->sp %8lx, regs->ap %8lx\n", + current->pid, + regs->pc, + regs->sp, + regs->ap); + { + unsigned char c[4]; + __get_user(c[0], (char *) &frame->sig + 0); + __get_user(c[1], (char *) &frame->sig + 1); + __get_user(c[2], (char *) &frame->sig + 2); + __get_user(c[3], (char *) &frame->sig + 3); + printk("setup_frame: %p %1x %p %1x %p %1x %p %1x\n", + &frame->sig + 0, c[0], + &frame->sig + 1, c[1], + &frame->sig + 2, c[2], + &frame->sig + 3, c[3]); + } + { + unsigned char c[4]; + __get_user(c[0], (char *) frame->retcode + 0); + __get_user(c[1], (char *) frame->retcode + 1); + __get_user(c[2], (char *) frame->retcode + 2); + __get_user(c[3], (char *) frame->retcode + 3); + printk("setup_frame: %p %1x %p %1x %p %1x %p %1x\n", + frame->retcode + 0, c[0], + frame->retcode + 1, c[1], + frame->retcode + 2, c[2], + frame->retcode + 3, c[3]); + } + { + unsigned char c[4]; + __get_user(c[0], (char *) frame->retcode + 4); + __get_user(c[1], (char *) frame->retcode + 5); + __get_user(c[2], (char *) frame->retcode + 6); + __get_user(c[3], (char *) frame->retcode + 7); + printk("setup_frame: %p %1x %p %1x %p %1x %p %1x\n", + frame->retcode + 4, c[0], + frame->retcode + 5, c[1], + frame->retcode + 6, c[2], + frame->retcode + 7, c[3]); + } + { + unsigned char c[4]; + __get_user(c[0], (char *) frame->retcode + 8); + __get_user(c[1], (char *) frame->retcode + 9); + __get_user(c[2], (char *) frame->retcode + 10); + __get_user(c[3], (char *) frame->retcode + 11); + printk("setup_frame: %p %1x %p %1x %p %1x %p %1x\n", + frame->retcode + 8, c[0], + frame->retcode + 9, c[1], + frame->retcode + 10, c[2], + frame->retcode + 11, c[3]); + } + { + unsigned char c[4]; + __get_user(c[0], (char *) frame->retcode + 12); + __get_user(c[1], (char *) frame->retcode + 13); + __get_user(c[2], (char *) frame->retcode + 14); + __get_user(c[3], (char *) frame->retcode + 15); + printk("setup_frame: %p %1x %p %1x %p %1x %p %1x\n", + frame->retcode + 12, c[0], + frame->retcode + 13, c[1], + frame->retcode + 14, c[2], + frame->retcode + 15, c[3]); + } +#endif return; give_sigsegv: @@ -487,17 +500,17 @@ } static void setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, - sigset_t *set, struct pt_regs * regs) + sigset_t *set, struct pt_regs * regs) { struct rt_sigframe *frame; int err = 0; frame = get_sigframe(ka, regs, sizeof(*frame)); -#ifdef DEBUG_SIG +#ifdef DEBUG_SIG printk("setup_rt_frame: pid %d, sig %d, regs %p, regs->sp %p, frame %p, sigaction %p\n",current->pid,sig,regs,regs->sp,frame,ka); show_regs(regs); -#endif +#endif if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) goto give_sigsegv; @@ -511,59 +524,64 @@ /* Clear all the bits of the ucontext we don't use. */ err |= __clear_user(&frame->uc, offsetof(struct ucontext, uc_mcontext)); - err |= setup_sigcontext(&frame->uc.uc_mcontext, regs, set->sig[0]); - err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set)); - if (err) goto give_sigsegv; - /* Set up to return from userspace. If provided, use a stub - already in userspace. */ + /* + * Set up to return from userspace. If provided, use a stub + * already in userspace. + */ - /* We do this differently to other ports. Each function has a two byte RSM. - * (due to the calling convention). Each sighandler will expect to be + /* + * We do this differently to other ports. Each function has a two byte RSM. + * (due to the calling convention). Each sighandler will expect to be * CALLS'd and will RET from that. So we cant just muck about with PC's on the * stack like the i386. So we use the trampoline code on the stack a bit more. * The easiest way to skip around all this is to calls the signal - * handler, and then either calls the restorer, or chmk to sys_sigreturn */ - - /* CALLS $3, */ - err |= __put_user(0xfb, (char *)(frame->retcode+0)); - err |= __put_user(0x03, (char *)(frame->retcode+1)); - /* (absolute address)*/ - err |= __put_user(0x9f, (char *)(frame->retcode+2)); - /* sighandler */ - err |= __put_user(((unsigned long) ka->sa.sa_handler), (unsigned long *)(frame->retcode + 3)); - + * handler, and then either calls the restorer, or chmk to sys_sigreturn. + */ + + /* CALLS $3, */ + err |= __put_user(0xfb, (char *) (frame->retcode + 0)); + err |= __put_user(0x03, (char *) (frame->retcode + 1)); + /* (absolute address)*/ + err |= __put_user(0x9f, (char *) (frame->retcode + 2)); + /* sighandler */ + err |= __put_user(((unsigned long) ka->sa.sa_handler), + (unsigned long *) (frame->retcode + 3)); + if (ka->sa.sa_flags & SA_RESTORER) { - /* CALLS $0,*/ - err |= __put_user(0xfb, (char *)(frame->retcode+7)); - err |= __put_user(0x00, (char *)(frame->retcode+8)); - /* (absolute address)*/ - err |= __put_user(0x9f, (char *)(frame->retcode+9)); - /* restorer */ - err |= __put_user(((unsigned long) ka->sa.sa_restorer), (unsigned long *)(frame->retcode + 10)); + /* CALLS $0,*/ + err |= __put_user(0xfb, (char *) (frame->retcode + 7)); + err |= __put_user(0x00, (char *) (frame->retcode + 8)); + /* (absolute address)*/ + err |= __put_user(0x9f, (char *) (frame->retcode + 9)); + /* restorer */ + err |= __put_user(((unsigned long) ka->sa.sa_restorer), + (unsigned long *) (frame->retcode + 10)); /* plus a halt */ - err |= __put_user(0x00, (char *)(frame->retcode+14)); + err |= __put_user(0x00, (char *) (frame->retcode + 14)); } else { - /* perform a syscall to sys_sigreturn. First set up the - * argument list to avoid confusing it */ - - /* pushl $0x0 */ - err |= __put_user(0xdd, (char *)(frame->retcode+7)); - err |= __put_user(0x00, (char *)(frame->retcode+8)); + /* + * Perform a syscall to sys_sigreturn. First set up the + * argument list to avoid confusing it. + */ + + /* pushl $0x0 */ + err |= __put_user(0xdd, (char *) (frame->retcode + 7)); + err |= __put_user(0x00, (char *) (frame->retcode + 8)); /* movl sp, ap */ - err |= __put_user(0xd0, (char *)(frame->retcode+9)); - err |= __put_user(0x5e, (char *)(frame->retcode+10)); - err |= __put_user(0x5c, (char *)(frame->retcode+11)); + err |= __put_user(0xd0, (char *) (frame->retcode + 9)); + err |= __put_user(0x5e, (char *) (frame->retcode + 10)); + err |= __put_user(0x5c, (char *) (frame->retcode + 11)); /* chmk __NR_sigreturn; */ - err |= __put_user(0xbc, (char *)(frame->retcode+12)); - err |= __put_user(0x8f, (char *)(frame->retcode+13)); - err |= __put_user(__NR_rt_sigreturn, (short *)(frame->retcode+14)); + err |= __put_user(0xbc, (char *) (frame->retcode + 12)); + err |= __put_user(0x8f, (char *) (frame->retcode + 13)); + err |= __put_user(__NR_rt_sigreturn, (short *) (frame->retcode + 14)); /* plus a halt */ - err |= __put_user(0x00, (char *)(frame->retcode+16)); + err |= __put_user(0x00, (char *) (frame->retcode + 16)); } if (err) @@ -571,8 +589,12 @@ /* TODO what is the current->exec_domain stuff and invmap ? */ -#ifdef DEBUG_SIG - printk("setup_rt_frame: pid %d, frame->retcode %p, sa_handler %p usp %8lX\n",current->pid,frame->retcode,ka->sa.sa_handler,__mfpr(PR_USP)); +#ifdef DEBUG_SIG + printk("setup_rt_frame: pid %d, frame->retcode %p, sa_handler %p usp %8lX\n", + current->pid, + frame->retcode, + ka->sa.sa_handler, + __mfpr(PR_USP)); #endif /* Set up registers for signal handler */ regs->pc = (unsigned long) frame->retcode; /* what we enter NOW */ @@ -589,12 +611,11 @@ } /* - * OK, we're invoking a handler - */ - + * OK, we're invoking a handler. + */ static inline void handle_signal(int canrestart, unsigned long sig, struct k_sigaction *ka, - siginfo_t *info, sigset_t *oldset, struct pt_regs * regs) + siginfo_t *info, sigset_t *oldset, struct pt_regs * regs) { /* Are we from a system call? */ if (canrestart) { @@ -622,14 +643,14 @@ case -ERESTARTNOINTR: /* ERESTARTNOINTR means that the syscall should be called again after the signal handler returns. */ - RESTART_VAX_SYSCALL(regs); + RESTART_VAX_SYSCALL(regs); } } /* Set up the stack frame */ -#ifdef DEBUG_SIG +#ifdef DEBUG_SIG printk("handle_signal: setup_frame(sig=%d,flags=%d,ka=%p,oldset=%d,regs=%p)\n",sig,ka->sa.sa_flags,ka,oldset,regs); -#endif +#endif if (ka->sa.sa_flags & SA_SIGINFO) setup_rt_frame(sig, ka, info, oldset, regs); else @@ -669,14 +690,14 @@ return 1; /* FIXME: */ - canrestart=regs->r0; -#ifdef DEBUG_SIG + canrestart=regs->r0; +#ifdef DEBUG_SIG printk("do_signal: pid %d,canrestart %d, current->sigpending %d,current->blocked %d ", current->pid,canrestart,current->sigpending,current->blocked); -#endif +#endif if (!oldset) oldset = ¤t->blocked; - + signr = get_signal_to_deliver(&info, &ka, regs, NULL); if (signr > 0) { /* Whee! Actually deliver the signal. */ @@ -687,11 +708,13 @@ /* Did we come from a system call? */ if (canrestart) { /* Restart the system call - no handlers present */ - if (regs->r0 == -ERESTARTNOHAND || - regs->r0 == -ERESTARTSYS || - regs->r0 == -ERESTARTNOINTR) { + if (regs->r0 == -ERESTARTNOHAND + || regs->r0 == -ERESTARTSYS + || regs->r0 == -ERESTARTNOINTR) { RESTART_VAX_SYSCALL(regs); } } + return 0; } + Index: interrupt.c =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.5/arch/vax/kernel/interrupt.c,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- interrupt.c 28 Mar 2005 16:26:14 -0000 1.28 +++ interrupt.c 25 Apr 2005 14:35:02 -0000 1.29 @@ -32,17 +32,19 @@ union scb_and_device_vectors __attribute__((__aligned__(PAGE_SIZE))) scb; -/* Statically-defined pool of irqvector structures. This will go once - we have a working kmalloc()/kfree(). - - Actually, it's not that simple... trap_init() is called before the - slab caches are initialized so we can't call kmalloc() this early - in initialization. What we could do is statically allocate a small - number of irqvectors here (enough for trap_init() and friends) and - then kmalloc() vectors on demand later. - - An entry in the list is free if the dest_addr field is zero, and - is in use if non-zero */ +/* + * Statically-defined pool of irqvector structures. This will go once + * we have a working kmalloc()/kfree(). + * + * Actually, it's not that simple... trap_init() is called before the + * slab caches are initialized so we can't call kmalloc() this early + * in initialization. What we could do is statically allocate a small + * number of irqvectors here (enough for trap_init() and friends) and + * then kmalloc() vectors on demand later. + * + * An entry in the list is free if the dest_addr field is zero, and + * is in use if non-zero. + */ struct irqvector irqvectors[NR_IRQVECTORS]; /* Default handlers for each SCB vector */ @@ -58,8 +60,10 @@ unsigned long base_pfn; pte_t *base_pte_addr; - /* Do we need more than a page for the int stack? - Yes, if we want a guard page. */ + /* + * Do we need more than a page for the int stack? + * Yes, if we want a guard page. + */ if (INT_STACK_SIZE <= PAGE_SIZE) { printk("Interrupt stack too small, must be > PAGE_SIZE\n"); machine_halt(); @@ -69,11 +73,12 @@ base_pfn = MAP_NR(stack_base); base_pte_addr = GET_SPTE_VIRT(stack_base); - - /* Set first page of interrupt stack area to kernel read, thus - trapping any writes to this page. This will catch attempts - to overflow the interrupt stack before they can do any damage. */ + /* + * Set first page of interrupt stack area to kernel read, thus + * trapping any writes to this page. This will catch attempts + * to overflow the interrupt stack before they can do any damage. + */ set_pte(base_pte_addr, pfn_pte(base_pfn, __pgprot(_PAGE_KR|_PAGE_VALID))); __flush_tlb_one(stack_base); @@ -96,7 +101,7 @@ flush_icache(); } -/* Register the machine check handler. */ +/* Register the machine check handler. */ void register_mcheck_handler(void) { extern void machine_check_handler(struct pt_regs *regs, void *unused); @@ -141,7 +146,7 @@ { SCB_MEMCORR, "Memory corrected read (SCB_MEMCORR: corrected_read_handler)", corrected_read_handler, 0, 0, }, { SCB_RESINSTR, "Reserved instruction (SCB_RESINSTR: reserved_instr_handler)", reserved_instr_handler, 0, 0, }, { SCB_TRANS_INVAL, "Translation not valid (SCB_TRANS_INVAL: page_fault_handler)", page_fault_handler, 2, 0, }, - }; + }; int i; /* @@ -183,32 +188,34 @@ /* Nothing to do... Already done by trap_init */ } -/* This is the handler for reserved operand faults and aborts. - Eventually this will have to check if the fault was from user - mode or kernel mode and either throw a SIGILL or panic. */ - +/* + * This is the handler for reserved operand faults and aborts. + * Eventually this will have to check if the fault was from user + * mode or kernel mode and either throw a SIGILL or panic. + */ void reserved_operand_handler(struct pt_regs *regs, void *unused) { printk("\nReserved operand fault at PC=%08lx\n", regs->pc); - - printk("\nStack dump\n"); + + printk("\nStack dump\n"); hex_dump((void *)(regs->sp), 256); - show_regs(regs); - show_cpu_regs(); + show_regs(regs); + show_cpu_regs(); - if (user_mode(regs)) { - force_sig(SIGILL,current); - return; + if (user_mode(regs)) { + force_sig(SIGILL,current); + return; } machine_halt(); } -/* This is the handler for reserved instruction exceptions. - Eventually this will have to check if the fault was from user - mode or kernel mode and either throw a SIGILL or panic. */ - +/* + * This is the handler for reserved instruction exceptions. + * Eventually this will have to check if the fault was from user + * mode or kernel mode and either throw a SIGILL or panic. + */ void reserved_instr_handler(struct pt_regs *regs, void *unused) { unsigned short instr = *(unsigned short *)(regs->pc); @@ -218,17 +225,18 @@ } else { printk("\nReserved instruction at PC=%08lx\n", regs->pc); } - - printk("\nStack dump\n"); + + printk("\nStack dump\n"); hex_dump((void *)(regs->sp), 256); dump_stack(); - show_regs(regs); - show_cpu_regs(); + show_regs(regs); + show_cpu_regs(); - if (user_mode(regs)) { - force_sig(SIGILL,current); - return; + if (user_mode(regs)) { + force_sig(SIGILL,current); + return; } + machine_halt(); } @@ -241,21 +249,21 @@ printk("\nBreakpoint at PC=%08lx at %08lX\n", regs->pc, ®s->pc); - printk("\nStack dump\n"); + printk("\nStack dump\n"); hex_dump((void *)(regs->sp), 256); - show_regs(regs); - show_cpu_regs(); + show_regs(regs); + show_cpu_regs(); #endif if (user_mode(regs)) { info.si_signo = SIGTRAP; info.si_errno = 0; info.si_code = TRAP_BRKPT; - info.si_addr = (void *)(regs->pc); + info.si_addr = (void *) (regs->pc); force_sig_info(SIGTRAP, &info,current); - return; + return; } - machine_halt(); + machine_halt(); force_sig(SIGTRAP, current); } @@ -264,57 +272,60 @@ { siginfo_t info; - regs->psl.t=0; + regs->psl.t = 0; #if 0 printk("\ntpend sending SIGTRAP\n"); printk("\nTrace Pending at PC=%08lx at %08lX\n", regs->pc, ®s->pc); printk("\nStack dump\n"); hex_dump((void *)(regs->sp), 256); - show_regs(regs); - show_cpu_regs(); + show_regs(regs); + show_cpu_regs(); #endif if (user_mode(regs)) { info.si_signo = SIGTRAP; info.si_errno = 0; info.si_code = TRAP_BRKPT; - info.si_addr = (void *)(regs->pc); - force_sig_info(SIGTRAP,&info,current); + info.si_addr = (void *) (regs->pc); + force_sig_info(SIGTRAP, &info, current); return; } + machine_halt(); force_sig(SIGTRAP, current); } -/* This is the handler for reserved addressing mode exceptions. - Eventually this will have to check if the fault was from user - mode or kernel mode and either throw a SIGILL or panic. */ +/* + * This is the handler for reserved addressing mode exceptions. + * Eventually this will have to check if the fault was from user + * mode or kernel mode and either throw a SIGILL or panic. + */ void resam_handler(struct pt_regs *regs, void *unused) { - unsigned short instr = *(unsigned short *)(regs->pc); + unsigned short instr = * (unsigned short *) (regs->pc); if ((instr == 0xfeff) || (instr == 0xfdff)) { printk("\nKernel bugcheck at PC=%08lx\n", regs->pc); } else { printk("\nReserved addressing mode fault at PC=%08lx\n", regs->pc); } - - printk("\nStack dump\n"); + + printk("\nStack dump\n"); hex_dump((void *)(regs->sp), 256); dump_stack(); - show_regs(regs); - show_cpu_regs(); + show_regs(regs); + show_cpu_regs(); if (user_mode(regs)) { force_sig(SIGILL,current); - return; + return; } + machine_halt(); } /* This is the handler for corrected memory read errors */ - void corrected_read_handler(struct pt_regs *regs, void *unused) { printk("Corrected memory read error. " @@ -349,24 +360,25 @@ } } -/* This function gets called from irqvec_stray when we get an exception or - interrupt that doesn't have a handler in the SCB. The argument is the - saved PC value from the JSB instruction in the stray_handler structure. - From this value, we can find the address of the struct stray_handler, - and thus the vector number. - - This will also be used to auto-probe interrupt vectors. probe_irq_on() - will clear the STRAY_EXCEPTION_FIRED flag on each stray handler above 64 - (adapter and device vectors). Then probe_irq_off() will look for a - vector with this bit set. */ - +/* + * This function gets called from irqvec_stray when we get an exception or + * interrupt that doesn't have a handler in the SCB. The argument is the + * saved PC value from the JSB instruction in the stray_handler structure. + * From this value, we can find the address of the struct stray_handler, + * and thus the vector number. + * + * This will also be used to auto-probe interrupt vectors. probe_irq_on() + * will clear the STRAY_EXCEPTION_FIRED flag on each stray handler above 64 + * (adapter and device vectors). Then probe_irq_off() will look for a + * vector with this bit set. + */ int unhandled_exception(unsigned char *retaddr) { struct stray_handler *handler; unsigned int vec_num; - handler = (struct stray_handler *)(retaddr - - offsetof(struct stray_handler, flags)); + handler = (struct stray_handler *) (retaddr + - offsetof(struct stray_handler, flags)); vec_num = handler - stray_handlers; @@ -375,8 +387,8 @@ return 0; } - printk("\nUnhandled interrupt or exception number 0x%04x (SCB offset 0x%04x)\n", - vec_num, vec_num*4); + printk("\nUnhandled interrupt or exception number 0x%04x (SCB offset 0x%04x)\n", + vec_num, vec_num * 4); printk("\nStack dump:\n"); vax_dump_stack(DUMP_STACK_CALLER); @@ -388,10 +400,11 @@ } -/* This is the equivalent of handle_IRQ_event() on x86. There is no - need to walk the list of irqactions as in x86 because we don't have - shared interrupts on the VAX */ - +/* + * This is the equivalent of handle_IRQ_event() on x86. There is no + * need to walk the list of irqactions as in x86 because we don't have + * shared interrupts on the VAX. + */ static inline void dispatch_irq(struct pt_regs *regs, struct irqvector *vec) { struct irqaction *action; @@ -407,9 +420,10 @@ add_interrupt_randomness(vec_num); } -/* This is called once we know that an interrupt or exception is actually - an interrupt. */ - +/* + * This is called once we know that an interrupt or exception is actually + * an interrupt. + */ static inline void do_irq(struct pt_regs *regs, struct irqvector *vec) { int flags; @@ -419,16 +433,16 @@ hardware capabilities... */ irq_enter(); - + local_irq_save(flags); dispatch_irq(regs, vec); irq_exit(); local_irq_restore(flags); - if (local_softirq_pending()) { + + if (local_softirq_pending()) do_softirq(); - } } static inline void do_exception(struct pt_regs *regs, struct irqvector *vec, void *excep_info) @@ -451,12 +465,14 @@ { struct irqvector *vec; - vec = (struct irqvector *)(inside_vec - - offsetof(struct irqvector, excep_info_size)); + vec = (struct irqvector *) (inside_vec + - offsetof(struct irqvector, excep_info_size)); - /* If the excep_handler field of the irqvector is NULL, - then this is an interrupt vector. Dispatch it via the - irqaction struct */ + /* + * If the excep_handler field of the irqvector is NULL, + * then this is an interrupt vector. Dispatch it via the + * irqaction struct. + */ if (vec->excep_handler != NULL) { // printk("exception: vec=%p handler %p excep_info=%p(%d)\n",vec,vec->excep_handler,excep_info,*(int *)excep_info); do_exception(regs, vec, excep_info); @@ -478,9 +494,8 @@ goto ret_with_reschedule; ret_from_exception: - if (local_softirq_pending()) { + if (local_softirq_pending()) do_softirq(); - } ret_from_intr: if (__psl.prevmode == 0) { @@ -523,7 +538,7 @@ for (i=0, vec=irqvectors; i<NR_IRQVECTORS; i++, vec++) { if (vec->dest_addr == NULL) { - vec->dest_addr = (void *)0xffffffff; + vec->dest_addr = (void *) 0xffffffff; local_irq_restore(flags); return vec; } @@ -565,7 +580,7 @@ if (!scb_vec_free(vec_num)) { local_irq_restore(flags); - printk("hook_scb_vector: SCB vector %04x (%p) already in use\n", + printk("hook_scb_vector: SCB vector %04x (%p) already in use\n", vec_num, SCB_VECTOR(vec_num)); return -EBUSY; } @@ -581,8 +596,10 @@ new_vector = &vec->inst_jsb; if (use_interrupt_stack) { - /* LSB set in SCB vector tells CPU to service event - on interrupt stack regardless of current stack */ + /* + * LSB set in SCB vector tells CPU to service event + * on interrupt stack regardless of current stack. + */ new_vector++; } @@ -647,10 +664,10 @@ /* We must mask off the bottom two bits. They have meaning to to the hardware, and are not part of the actual target address */ - inside_vec = (unsigned char *) ((unsigned long)(inside_vec) & ~0x3); + inside_vec = (unsigned char *) ((unsigned long) (inside_vec) & ~0x3); - vector = (struct irqvector *)(inside_vec - - offsetof(struct irqvector, inst_jsb)); + vector = (struct irqvector *) (inside_vec + - offsetof(struct irqvector, inst_jsb)); if (dev_id != vector->action.dev_id) { local_irq_restore(flags); @@ -679,13 +696,13 @@ int i; int flags; - local_irq_save(flags); + local_irq_save(flags); for (i = FIRST_ADAPTER_VECTOR; i < NR_IRQS; i++) stray_handlers[i].flags &= ~STRAY_EXCEPTION_FIRED; - autoprobing=1; - local_irq_restore(flags); + autoprobing = 1; + local_irq_restore(flags); return 1; } @@ -700,7 +717,7 @@ nr_vecs = 0; vec_found = 0; - local_irq_save(flags); + local_irq_save(flags); for (i = FIRST_ADAPTER_VECTOR; i < NR_IRQS; i++) { if (stray_handlers[i].flags & STRAY_EXCEPTION_FIRED) { @@ -709,7 +726,7 @@ } } autoprobing=0; - local_irq_restore(flags); + local_irq_restore(flags); if (nr_vecs > 1) { vec_found = -vec_found; @@ -738,7 +755,7 @@ vector->excep_info_size = exception_info_size; vector->excep_handler = handler; vector->action.name = exception_name; /* Needed to stop get_irq_list dying */ - /* FIXME: This doesn't set dev_id or other members of the irqaction structure... */ + /* FIXME: This doesn't set dev_id or other members of the irqaction structure... */ retval = hook_scb_vector(vec_num, vector, use_interrupt_stack); @@ -750,11 +767,11 @@ int show_interrupts(struct seq_file *p, void *v) { - int i = *(loff_t *) v; + int i = * (loff_t *) v; struct irqvector *vector; unsigned char *inside_vec; - - if ((i < NR_IRQS) && !scb_vec_free (i)) { + + if (i < NR_IRQS && !scb_vec_free (i)) { inside_vec = SCB_VECTOR (i); /* @@ -762,9 +779,9 @@ * meaning to the hardware, and are not part of * the actual target address */ - inside_vec = (unsigned char *) ((unsigned long)(inside_vec) & ~0x3); - vector = (struct irqvector *)(inside_vec - - offsetof (struct irqvector, inst_jsb)); + inside_vec = (unsigned char *) ((unsigned long) (inside_vec) & ~0x3); + vector = (struct irqvector *) (inside_vec + - offsetof (struct irqvector, inst_jsb)); if (vector->action.name == NULL) seq_printf (p, "%4d: %8d no interrupt vector name\n", vector->vec_num, 0); else |