1 /* $Id: process.c,v 1.131 2002/02/09 19:49:30 davem Exp $
2 * arch/sparc64/kernel/process.c
4 * Copyright (C) 1995, 1996 David S. Miller (davem@caip.rutgers.edu)
5 * Copyright (C) 1996 Eddie C. Dost (ecd@skynet.be)
6 * Copyright (C) 1997, 1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
10 * This file handles the architecture-dependent parts of process handling..
15 #include <linux/config.h>
16 #include <linux/errno.h>
17 #include <linux/module.h>
18 #include <linux/sched.h>
19 #include <linux/kernel.h>
20 #include <linux/kallsyms.h>
22 #include <linux/smp.h>
23 #include <linux/smp_lock.h>
24 #include <linux/stddef.h>
25 #include <linux/ptrace.h>
26 #include <linux/slab.h>
27 #include <linux/user.h>
28 #include <linux/a.out.h>
29 #include <linux/config.h>
30 #include <linux/reboot.h>
31 #include <linux/delay.h>
32 #include <linux/compat.h>
33 #include <linux/init.h>
35 #include <asm/oplib.h>
36 #include <asm/uaccess.h>
37 #include <asm/system.h>
39 #include <asm/pgalloc.h>
40 #include <asm/pgtable.h>
41 #include <asm/processor.h>
42 #include <asm/pstate.h>
44 #include <asm/fpumacro.h>
46 #include <asm/cpudata.h>
47 #include <asm/unistd.h>
49 /* #define VERBOSE_SHOWREGS */
52 * Nothing special yet...
54 void default_idle(void)
61 * the idle loop on a Sparc... ;)
65 /* endless idle loop with no priority at all */
67 /* If current->work.need_resched is zero we should really
68 * setup for a system wakup event and execute a shutdown
71 * But this requires writing back the contents of the
72 * L2 cache etc. so implement this later. -DaveM
74 while (!need_resched())
77 preempt_enable_no_resched();
87 * the idle loop on a UltraMultiPenguin...
89 * TIF_POLLING_NRFLAG is set because we do not sleep the cpu
90 * inside of the idler task, so an interrupt is not needed
91 * to get a clean fast response.
93 * XXX Reverify this assumption... -DaveM
95 * Addendum: We do want it to do something for the signal
96 * delivery case, we detect that by just seeing
97 * if we are trying to send this to an idler or not.
101 cpuinfo_sparc *cpuinfo = &local_cpu_data();
102 set_thread_flag(TIF_POLLING_NRFLAG);
105 if (need_resched()) {
106 cpuinfo->idle_volume = 0;
107 preempt_enable_no_resched();
112 cpuinfo->idle_volume++;
114 /* The store ordering is so that IRQ handlers on
115 * other cpus see our increasing idleness for the buddy
116 * redistribution algorithm. -DaveM
118 membar_storeload_storestore();
124 extern char reboot_command [];
126 extern void (*prom_palette)(int);
127 extern void (*prom_keyboard)(void);
129 void machine_halt(void)
131 if (!serial_console && prom_palette)
136 panic("Halt failed!");
139 void machine_alt_power_off(void)
141 if (!serial_console && prom_palette)
145 prom_halt_power_off();
146 panic("Power-off failed!");
149 void machine_restart(char * cmd)
153 p = strchr (reboot_command, '\n');
155 if (!serial_console && prom_palette)
162 prom_reboot(reboot_command);
164 panic("Reboot failed!");
168 static void show_regwindow32(struct pt_regs *regs)
170 struct reg_window32 __user *rw;
171 struct reg_window32 r_w;
174 __asm__ __volatile__ ("flushw");
175 rw = compat_ptr((unsigned)regs->u_regs[14]);
178 if (copy_from_user (&r_w, rw, sizeof(r_w))) {
184 printk("l0: %08x l1: %08x l2: %08x l3: %08x "
185 "l4: %08x l5: %08x l6: %08x l7: %08x\n",
186 r_w.locals[0], r_w.locals[1], r_w.locals[2], r_w.locals[3],
187 r_w.locals[4], r_w.locals[5], r_w.locals[6], r_w.locals[7]);
188 printk("i0: %08x i1: %08x i2: %08x i3: %08x "
189 "i4: %08x i5: %08x i6: %08x i7: %08x\n",
190 r_w.ins[0], r_w.ins[1], r_w.ins[2], r_w.ins[3],
191 r_w.ins[4], r_w.ins[5], r_w.ins[6], r_w.ins[7]);
194 #define show_regwindow32(regs) do { } while (0)
197 static void show_regwindow(struct pt_regs *regs)
199 struct reg_window __user *rw;
200 struct reg_window *rwk;
201 struct reg_window r_w;
204 if ((regs->tstate & TSTATE_PRIV) || !(test_thread_flag(TIF_32BIT))) {
205 __asm__ __volatile__ ("flushw");
206 rw = (struct reg_window __user *)
207 (regs->u_regs[14] + STACK_BIAS);
208 rwk = (struct reg_window *)
209 (regs->u_regs[14] + STACK_BIAS);
210 if (!(regs->tstate & TSTATE_PRIV)) {
213 if (copy_from_user (&r_w, rw, sizeof(r_w))) {
221 show_regwindow32(regs);
224 printk("l0: %016lx l1: %016lx l2: %016lx l3: %016lx\n",
225 rwk->locals[0], rwk->locals[1], rwk->locals[2], rwk->locals[3]);
226 printk("l4: %016lx l5: %016lx l6: %016lx l7: %016lx\n",
227 rwk->locals[4], rwk->locals[5], rwk->locals[6], rwk->locals[7]);
228 printk("i0: %016lx i1: %016lx i2: %016lx i3: %016lx\n",
229 rwk->ins[0], rwk->ins[1], rwk->ins[2], rwk->ins[3]);
230 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
231 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
232 if (regs->tstate & TSTATE_PRIV)
233 print_symbol("I7: <%s>\n", rwk->ins[7]);
236 void show_stackframe(struct sparc_stackf *sf)
242 printk("l0: %016lx l1: %016lx l2: %016lx l3: %016lx\n"
243 "l4: %016lx l5: %016lx l6: %016lx l7: %016lx\n",
244 sf->locals[0], sf->locals[1], sf->locals[2], sf->locals[3],
245 sf->locals[4], sf->locals[5], sf->locals[6], sf->locals[7]);
246 printk("i0: %016lx i1: %016lx i2: %016lx i3: %016lx\n"
247 "i4: %016lx i5: %016lx fp: %016lx ret_pc: %016lx\n",
248 sf->ins[0], sf->ins[1], sf->ins[2], sf->ins[3],
249 sf->ins[4], sf->ins[5], (unsigned long)sf->fp, sf->callers_pc);
250 printk("sp: %016lx x0: %016lx x1: %016lx x2: %016lx\n"
251 "x3: %016lx x4: %016lx x5: %016lx xx: %016lx\n",
252 (unsigned long)sf->structptr, sf->xargs[0], sf->xargs[1],
253 sf->xargs[2], sf->xargs[3], sf->xargs[4], sf->xargs[5],
255 size = ((unsigned long)sf->fp) - ((unsigned long)sf);
256 size -= STACKFRAME_SZ;
257 stk = (unsigned long *)((unsigned long)sf + STACKFRAME_SZ);
260 printk("s%d: %016lx\n", i++, *stk++);
261 } while ((size -= sizeof(unsigned long)));
264 void show_stackframe32(struct sparc_stackf32 *sf)
270 printk("l0: %08x l1: %08x l2: %08x l3: %08x\n",
271 sf->locals[0], sf->locals[1], sf->locals[2], sf->locals[3]);
272 printk("l4: %08x l5: %08x l6: %08x l7: %08x\n",
273 sf->locals[4], sf->locals[5], sf->locals[6], sf->locals[7]);
274 printk("i0: %08x i1: %08x i2: %08x i3: %08x\n",
275 sf->ins[0], sf->ins[1], sf->ins[2], sf->ins[3]);
276 printk("i4: %08x i5: %08x fp: %08x ret_pc: %08x\n",
277 sf->ins[4], sf->ins[5], sf->fp, sf->callers_pc);
278 printk("sp: %08x x0: %08x x1: %08x x2: %08x\n"
279 "x3: %08x x4: %08x x5: %08x xx: %08x\n",
280 sf->structptr, sf->xargs[0], sf->xargs[1],
281 sf->xargs[2], sf->xargs[3], sf->xargs[4], sf->xargs[5],
283 size = ((unsigned long)sf->fp) - ((unsigned long)sf);
284 size -= STACKFRAME32_SZ;
285 stk = (unsigned *)((unsigned long)sf + STACKFRAME32_SZ);
288 printk("s%d: %08x\n", i++, *stk++);
289 } while ((size -= sizeof(unsigned)));
293 static DEFINE_SPINLOCK(regdump_lock);
296 void __show_regs(struct pt_regs * regs)
301 /* Protect against xcall ipis which might lead to livelock on the lock */
302 __asm__ __volatile__("rdpr %%pstate, %0\n\t"
303 "wrpr %0, %1, %%pstate"
306 spin_lock(®dump_lock);
308 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
309 regs->tpc, regs->tnpc, regs->y, print_tainted());
310 print_symbol("TPC: <%s>\n", regs->tpc);
311 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
312 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
314 printk("g4: %016lx g5: %016lx g6: %016lx g7: %016lx\n",
315 regs->u_regs[4], regs->u_regs[5], regs->u_regs[6],
317 printk("o0: %016lx o1: %016lx o2: %016lx o3: %016lx\n",
318 regs->u_regs[8], regs->u_regs[9], regs->u_regs[10],
320 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
321 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
323 print_symbol("RPC: <%s>\n", regs->u_regs[15]);
324 show_regwindow(regs);
326 spin_unlock(®dump_lock);
327 __asm__ __volatile__("wrpr %0, 0, %%pstate"
332 #ifdef VERBOSE_SHOWREGS
333 static void idump_from_user (unsigned int *pc)
338 if((((unsigned long) pc) & 3))
342 for(i = -3; i < 6; i++) {
344 printk("%c%08x%c",i?' ':'<',code,i?' ':'>');
351 void show_regs(struct pt_regs *regs)
353 #ifdef VERBOSE_SHOWREGS
354 extern long etrap, etraptl1;
359 extern void smp_report_regs(void);
365 #ifdef VERBOSE_SHOWREGS
366 if (regs->tpc >= &etrap && regs->tpc < &etraptl1 &&
367 regs->u_regs[14] >= (long)current - PAGE_SIZE &&
368 regs->u_regs[14] < (long)current + 6 * PAGE_SIZE) {
369 printk ("*********parent**********\n");
370 __show_regs((struct pt_regs *)(regs->u_regs[14] + PTREGS_OFF));
371 idump_from_user(((struct pt_regs *)(regs->u_regs[14] + PTREGS_OFF))->tpc);
372 printk ("*********endpar**********\n");
377 void show_regs32(struct pt_regs32 *regs)
379 printk("PSR: %08x PC: %08x NPC: %08x Y: %08x %s\n", regs->psr,
380 regs->pc, regs->npc, regs->y, print_tainted());
381 printk("g0: %08x g1: %08x g2: %08x g3: %08x ",
382 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
384 printk("g4: %08x g5: %08x g6: %08x g7: %08x\n",
385 regs->u_regs[4], regs->u_regs[5], regs->u_regs[6],
387 printk("o0: %08x o1: %08x o2: %08x o3: %08x ",
388 regs->u_regs[8], regs->u_regs[9], regs->u_regs[10],
390 printk("o4: %08x o5: %08x sp: %08x ret_pc: %08x\n",
391 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
395 unsigned long thread_saved_pc(struct task_struct *tsk)
397 struct thread_info *ti = task_thread_info(tsk);
398 unsigned long ret = 0xdeadbeefUL;
402 sp = (unsigned long *)(ti->ksp + STACK_BIAS);
403 if (((unsigned long)sp & (sizeof(long) - 1)) == 0UL &&
406 fp = (unsigned long *)(sp[14] + STACK_BIAS);
407 if (((unsigned long)fp & (sizeof(long) - 1)) == 0UL)
414 /* Free current thread data structures etc.. */
415 void exit_thread(void)
417 struct thread_info *t = current_thread_info();
420 if (t->utraps[0] < 2)
426 if (test_and_clear_thread_flag(TIF_PERFCTR)) {
427 t->user_cntd0 = t->user_cntd1 = NULL;
433 void flush_thread(void)
435 struct thread_info *t = current_thread_info();
437 if (t->flags & _TIF_ABI_PENDING)
438 t->flags ^= (_TIF_ABI_PENDING | _TIF_32BIT);
441 unsigned long pgd_cache = 0UL;
442 if (test_thread_flag(TIF_32BIT)) {
443 struct mm_struct *mm = t->task->mm;
444 pgd_t *pgd0 = &mm->pgd[0];
445 pud_t *pud0 = pud_offset(pgd0, 0);
447 if (pud_none(*pud0)) {
448 pmd_t *page = pmd_alloc_one(mm, 0);
451 pgd_cache = get_pgd_cache(pgd0);
453 __asm__ __volatile__("stxa %0, [%1] %2\n\t"
460 set_thread_wsaved(0);
462 /* Turn off performance counters if on. */
463 if (test_and_clear_thread_flag(TIF_PERFCTR)) {
464 t->user_cntd0 = t->user_cntd1 = NULL;
469 /* Clear FPU register state. */
472 if (get_thread_current_ds() != ASI_AIUS)
475 /* Init new signal delivery disposition. */
476 clear_thread_flag(TIF_NEWSIGNALS);
479 /* It's a bit more tricky when 64-bit tasks are involved... */
480 static unsigned long clone_stackframe(unsigned long csp, unsigned long psp)
482 unsigned long fp, distance, rval;
484 if (!(test_thread_flag(TIF_32BIT))) {
487 __get_user(fp, &(((struct reg_window __user *)psp)->ins[6]));
490 __get_user(fp, &(((struct reg_window32 __user *)psp)->ins[6]));
492 /* Now 8-byte align the stack as this is mandatory in the
493 * Sparc ABI due to how register windows work. This hides
494 * the restriction from thread libraries etc. -DaveM
499 rval = (csp - distance);
500 if (copy_in_user((void __user *) rval, (void __user *) psp, distance))
502 else if (test_thread_flag(TIF_32BIT)) {
503 if (put_user(((u32)csp),
504 &(((struct reg_window32 __user *)rval)->ins[6])))
507 if (put_user(((u64)csp - STACK_BIAS),
508 &(((struct reg_window __user *)rval)->ins[6])))
511 rval = rval - STACK_BIAS;
517 /* Standard stuff. */
518 static inline void shift_window_buffer(int first_win, int last_win,
519 struct thread_info *t)
523 for (i = first_win; i < last_win; i++) {
524 t->rwbuf_stkptrs[i] = t->rwbuf_stkptrs[i+1];
525 memcpy(&t->reg_window[i], &t->reg_window[i+1],
526 sizeof(struct reg_window));
530 void synchronize_user_stack(void)
532 struct thread_info *t = current_thread_info();
533 unsigned long window;
535 flush_user_windows();
536 if ((window = get_thread_wsaved()) != 0) {
537 int winsize = sizeof(struct reg_window);
540 if (test_thread_flag(TIF_32BIT))
541 winsize = sizeof(struct reg_window32);
547 unsigned long sp = (t->rwbuf_stkptrs[window] + bias);
548 struct reg_window *rwin = &t->reg_window[window];
550 if (!copy_to_user((char __user *)sp, rwin, winsize)) {
551 shift_window_buffer(window, get_thread_wsaved() - 1, t);
552 set_thread_wsaved(get_thread_wsaved() - 1);
558 void fault_in_user_windows(void)
560 struct thread_info *t = current_thread_info();
561 unsigned long window;
562 int winsize = sizeof(struct reg_window);
565 if (test_thread_flag(TIF_32BIT))
566 winsize = sizeof(struct reg_window32);
570 flush_user_windows();
571 window = get_thread_wsaved();
576 unsigned long sp = (t->rwbuf_stkptrs[window] + bias);
577 struct reg_window *rwin = &t->reg_window[window];
579 if (copy_to_user((char __user *)sp, rwin, winsize))
583 set_thread_wsaved(0);
587 set_thread_wsaved(window + 1);
591 asmlinkage long sparc_do_fork(unsigned long clone_flags,
592 unsigned long stack_start,
593 struct pt_regs *regs,
594 unsigned long stack_size)
596 int __user *parent_tid_ptr, *child_tid_ptr;
599 if (test_thread_flag(TIF_32BIT)) {
600 parent_tid_ptr = compat_ptr(regs->u_regs[UREG_I2]);
601 child_tid_ptr = compat_ptr(regs->u_regs[UREG_I4]);
605 parent_tid_ptr = (int __user *) regs->u_regs[UREG_I2];
606 child_tid_ptr = (int __user *) regs->u_regs[UREG_I4];
609 return do_fork(clone_flags, stack_start,
611 parent_tid_ptr, child_tid_ptr);
614 /* Copy a Sparc thread. The fork() return value conventions
615 * under SunOS are nothing short of bletcherous:
616 * Parent --> %o0 == childs pid, %o1 == 0
617 * Child --> %o0 == parents pid, %o1 == 1
619 int copy_thread(int nr, unsigned long clone_flags, unsigned long sp,
620 unsigned long unused,
621 struct task_struct *p, struct pt_regs *regs)
623 struct thread_info *t = task_thread_info(p);
624 char *child_trap_frame;
626 /* Calculate offset to stack_frame & pt_regs */
627 child_trap_frame = task_stack_page(p) + (THREAD_SIZE - (TRACEREG_SZ+STACKFRAME_SZ));
628 memcpy(child_trap_frame, (((struct sparc_stackf *)regs)-1), (TRACEREG_SZ+STACKFRAME_SZ));
630 t->flags = (t->flags & ~((0xffUL << TI_FLAG_CWP_SHIFT) | (0xffUL << TI_FLAG_CURRENT_DS_SHIFT))) |
631 (((regs->tstate + 1) & TSTATE_CWP) << TI_FLAG_CWP_SHIFT);
633 t->ksp = ((unsigned long) child_trap_frame) - STACK_BIAS;
634 t->kregs = (struct pt_regs *)(child_trap_frame+sizeof(struct sparc_stackf));
637 if (regs->tstate & TSTATE_PRIV) {
638 /* Special case, if we are spawning a kernel thread from
639 * a userspace task (via KMOD, NFS, or similar) we must
640 * disable performance counters in the child because the
641 * address space and protection realm are changing.
643 if (t->flags & _TIF_PERFCTR) {
644 t->user_cntd0 = t->user_cntd1 = NULL;
646 t->flags &= ~_TIF_PERFCTR;
648 t->kregs->u_regs[UREG_FP] = t->ksp;
649 t->flags |= ((long)ASI_P << TI_FLAG_CURRENT_DS_SHIFT);
650 flush_register_windows();
651 memcpy((void *)(t->ksp + STACK_BIAS),
652 (void *)(regs->u_regs[UREG_FP] + STACK_BIAS),
653 sizeof(struct sparc_stackf));
654 t->kregs->u_regs[UREG_G6] = (unsigned long) t;
655 t->kregs->u_regs[UREG_G4] = (unsigned long) t->task;
657 if (t->flags & _TIF_32BIT) {
658 sp &= 0x00000000ffffffffUL;
659 regs->u_regs[UREG_FP] &= 0x00000000ffffffffUL;
661 t->kregs->u_regs[UREG_FP] = sp;
662 t->flags |= ((long)ASI_AIUS << TI_FLAG_CURRENT_DS_SHIFT);
663 if (sp != regs->u_regs[UREG_FP]) {
666 csp = clone_stackframe(sp, regs->u_regs[UREG_FP]);
669 t->kregs->u_regs[UREG_FP] = csp;
675 /* Set the return value for the child. */
676 t->kregs->u_regs[UREG_I0] = current->pid;
677 t->kregs->u_regs[UREG_I1] = 1;
679 /* Set the second return value for the parent. */
680 regs->u_regs[UREG_I1] = 0;
682 if (clone_flags & CLONE_SETTLS)
683 t->kregs->u_regs[UREG_G7] = regs->u_regs[UREG_I3];
689 * This is the mechanism for creating a new kernel thread.
691 * NOTE! Only a kernel-only process(ie the swapper or direct descendants
692 * who haven't done an "execve()") should use this: it will work within
693 * a system call from a "real" process, but the process memory space will
694 * not be free'd until both the parent and the child have exited.
696 pid_t kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
700 /* If the parent runs before fn(arg) is called by the child,
701 * the input registers of this function can be clobbered.
702 * So we stash 'fn' and 'arg' into global registers which
703 * will not be modified by the parent.
705 __asm__ __volatile__("mov %4, %%g2\n\t" /* Save FN into global */
706 "mov %5, %%g3\n\t" /* Save ARG into global */
707 "mov %1, %%g1\n\t" /* Clone syscall nr. */
708 "mov %2, %%o0\n\t" /* Clone flags. */
709 "mov 0, %%o1\n\t" /* usp arg == 0 */
710 "t 0x6d\n\t" /* Linux/Sparc clone(). */
711 "brz,a,pn %%o1, 1f\n\t" /* Parent, just return. */
713 "jmpl %%g2, %%o7\n\t" /* Call the function. */
714 " mov %%g3, %%o0\n\t" /* Set arg in delay. */
716 "t 0x6d\n\t" /* Linux/Sparc exit(). */
717 /* Notreached by child. */
720 "i" (__NR_clone), "r" (flags | CLONE_VM | CLONE_UNTRACED),
721 "i" (__NR_exit), "r" (fn), "r" (arg) :
722 "g1", "g2", "g3", "o0", "o1", "memory", "cc");
727 * fill in the user structure for a core dump..
729 void dump_thread(struct pt_regs * regs, struct user * dump)
731 /* Only should be used for SunOS and ancient a.out
732 * SparcLinux binaries... Not worth implementing.
734 memset(dump, 0, sizeof(struct user));
739 unsigned int pr_regs[32];
740 unsigned long pr_dregs[16];
742 unsigned int __unused;
744 unsigned char pr_qcnt;
745 unsigned char pr_q_entrysize;
747 unsigned int pr_q[64];
751 * fill in the fpu structure for a core dump.
753 int dump_fpu (struct pt_regs * regs, elf_fpregset_t * fpregs)
755 unsigned long *kfpregs = current_thread_info()->fpregs;
756 unsigned long fprs = current_thread_info()->fpsaved[0];
758 if (test_thread_flag(TIF_32BIT)) {
759 elf_fpregset_t32 *fpregs32 = (elf_fpregset_t32 *)fpregs;
762 memcpy(&fpregs32->pr_fr.pr_regs[0], kfpregs,
763 sizeof(unsigned int) * 32);
765 memset(&fpregs32->pr_fr.pr_regs[0], 0,
766 sizeof(unsigned int) * 32);
767 fpregs32->pr_qcnt = 0;
768 fpregs32->pr_q_entrysize = 8;
769 memset(&fpregs32->pr_q[0], 0,
770 (sizeof(unsigned int) * 64));
771 if (fprs & FPRS_FEF) {
772 fpregs32->pr_fsr = (unsigned int) current_thread_info()->xfsr[0];
775 fpregs32->pr_fsr = 0;
780 memcpy(&fpregs->pr_regs[0], kfpregs,
781 sizeof(unsigned int) * 32);
783 memset(&fpregs->pr_regs[0], 0,
784 sizeof(unsigned int) * 32);
786 memcpy(&fpregs->pr_regs[16], kfpregs+16,
787 sizeof(unsigned int) * 32);
789 memset(&fpregs->pr_regs[16], 0,
790 sizeof(unsigned int) * 32);
791 if(fprs & FPRS_FEF) {
792 fpregs->pr_fsr = current_thread_info()->xfsr[0];
793 fpregs->pr_gsr = current_thread_info()->gsr[0];
795 fpregs->pr_fsr = fpregs->pr_gsr = 0;
797 fpregs->pr_fprs = fprs;
803 * sparc_execve() executes a new program after the asm stub has set
804 * things up for us. This should basically do what I want it to.
806 asmlinkage int sparc_execve(struct pt_regs *regs)
811 /* User register window flush is done by entry.S */
813 /* Check for indirect call. */
814 if (regs->u_regs[UREG_G1] == 0)
817 filename = getname((char __user *)regs->u_regs[base + UREG_I0]);
818 error = PTR_ERR(filename);
819 if (IS_ERR(filename))
821 error = do_execve(filename,
822 (char __user * __user *)
823 regs->u_regs[base + UREG_I1],
824 (char __user * __user *)
825 regs->u_regs[base + UREG_I2], regs);
829 current_thread_info()->xfsr[0] = 0;
830 current_thread_info()->fpsaved[0] = 0;
831 regs->tstate &= ~TSTATE_PEF;
833 current->ptrace &= ~PT_DTRACE;
834 task_unlock(current);
840 unsigned long get_wchan(struct task_struct *task)
842 unsigned long pc, fp, bias = 0;
843 unsigned long thread_info_base;
844 struct reg_window *rw;
845 unsigned long ret = 0;
848 if (!task || task == current ||
849 task->state == TASK_RUNNING)
852 thread_info_base = (unsigned long) task_stack_page(task);
854 fp = task_thread_info(task)->ksp + bias;
857 /* Bogus frame pointer? */
858 if (fp < (thread_info_base + sizeof(struct thread_info)) ||
859 fp >= (thread_info_base + THREAD_SIZE))
861 rw = (struct reg_window *) fp;
863 if (!in_sched_functions(pc)) {
867 fp = rw->ins[6] + bias;
868 } while (++count < 16);