Module Name: src Committed By: matt Date: Fri Jan 7 02:03:51 UTC 2011
Modified Files: src/sys/arch/powerpc/powerpc [matt-nb5-pq3]: fpu.c ipkdb_glue.c kgdb_machdep.c powerpc_machdep.c process_machdep.c syscall.c vm_machdep.c Log Message: Deal with trapframe changes and booke changes. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.21.26.1 src/sys/arch/powerpc/powerpc/fpu.c cvs rdiff -u -r1.9 -r1.9.70.1 src/sys/arch/powerpc/powerpc/ipkdb_glue.c cvs rdiff -u -r1.20 -r1.20.30.1 src/sys/arch/powerpc/powerpc/kgdb_machdep.c cvs rdiff -u -r1.39 -r1.39.16.1 \ src/sys/arch/powerpc/powerpc/powerpc_machdep.c cvs rdiff -u -r1.26 -r1.26.42.1 \ src/sys/arch/powerpc/powerpc/process_machdep.c cvs rdiff -u -r1.43 -r1.43.16.1 src/sys/arch/powerpc/powerpc/syscall.c cvs rdiff -u -r1.74.4.1 -r1.74.4.1.4.1 \ src/sys/arch/powerpc/powerpc/vm_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/powerpc/powerpc/fpu.c diff -u src/sys/arch/powerpc/powerpc/fpu.c:1.21 src/sys/arch/powerpc/powerpc/fpu.c:1.21.26.1 --- src/sys/arch/powerpc/powerpc/fpu.c:1.21 Tue Apr 8 02:33:03 2008 +++ src/sys/arch/powerpc/powerpc/fpu.c Fri Jan 7 02:03:51 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu.c,v 1.21 2008/04/08 02:33:03 garbled Exp $ */ +/* $NetBSD: fpu.c,v 1.21.26.1 2011/01/07 02:03:51 matt Exp $ */ /* * Copyright (C) 1996 Wolfgang Solfrank. @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.21 2008/04/08 02:33:03 garbled Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.21.26.1 2011/01/07 02:03:51 matt Exp $"); #include "opt_multiprocessor.h" @@ -69,7 +69,7 @@ * If we own the CPU but FP is disabled, simply enable it and return. */ if (ci->ci_fpulwp == l) { - tf->srr1 |= PSL_FP | (pcb->pcb_flags & (PCB_FE0|PCB_FE1)); + tf->tf_srr1 |= PSL_FP | (pcb->pcb_flags & (PCB_FE0|PCB_FE1)); return; } msr = mfmsr(); @@ -118,7 +118,7 @@ "lfd 31,248(%0)\n" :: "b"(&pcb->pcb_fpu.fpreg[0])); __asm volatile ("isync"); - tf->srr1 |= PSL_FP | (pcb->pcb_flags & (PCB_FE0|PCB_FE1)); + tf->tf_srr1 |= PSL_FP | (pcb->pcb_flags & (PCB_FE0|PCB_FE1)); ci->ci_fpulwp = l; pcb->pcb_fpcpu = ci; pcb->pcb_flags |= PCB_OWNFPU; Index: src/sys/arch/powerpc/powerpc/ipkdb_glue.c diff -u src/sys/arch/powerpc/powerpc/ipkdb_glue.c:1.9 src/sys/arch/powerpc/powerpc/ipkdb_glue.c:1.9.70.1 --- src/sys/arch/powerpc/powerpc/ipkdb_glue.c:1.9 Wed Jan 24 13:08:14 2007 +++ src/sys/arch/powerpc/powerpc/ipkdb_glue.c Fri Jan 7 02:03:51 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: ipkdb_glue.c,v 1.9 2007/01/24 13:08:14 hubertf Exp $ */ +/* $NetBSD: ipkdb_glue.c,v 1.9.70.1 2011/01/07 02:03:51 matt Exp $ */ /* * Copyright (C) 1995, 1996 Wolfgang Solfrank. @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ipkdb_glue.c,v 1.9 2007/01/24 13:08:14 hubertf Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ipkdb_glue.c,v 1.9.70.1 2011/01/07 02:03:51 matt Exp $"); #include <sys/param.h> @@ -67,25 +67,25 @@ } int -ipkdb_trap_glue(struct trapframe *frame) +ipkdb_trap_glue(struct trapframe *tf) { - if (!(frame->srr1 & PSL_PR) - && (frame->exc == EXC_TRC - || (frame->exc == EXC_PGM - && (frame->srr1 & 0x20000)) - || frame->exc == EXC_BPT)) { + if (!(tf->tf_srr1 & PSL_PR) + && (tf->tf_exc == EXC_TRC + || (tf->tf_exc == EXC_PGM + && (tf->tf_srr1 & 0x20000)) + || tf->tf_exc == EXC_BPT)) { #ifdef IPKDBUSERHACK /* XXX see above */ __asm ("mfsr %0,%1" : "=r"(savesr) : "n"(USER_SR)); #endif ipkdbzero(ipkdbregs, sizeof ipkdbregs); - ipkdbcopy(frame->fixreg, &ipkdbregs[FIX], NFIX * sizeof(int)); - ipkdbregs[PC] = frame->srr0; - ipkdbregs[PS] = frame->srr1 & ~PSL_BE; - ipkdbregs[CR] = frame->cr; - ipkdbregs[LR] = frame->lr; - ipkdbregs[CTR] = frame->ctr; - ipkdbregs[XER] = frame->xer; + ipkdbcopy(tf->tf_fixreg, &ipkdbregs[FIX], NFIX * sizeof(int)); + ipkdbregs[PC] = tf->tf_srr0; + ipkdbregs[PS] = tf->tf_srr1 & ~PSL_BE; + ipkdbregs[CR] = tf->tf_cr; + ipkdbregs[LR] = tf->tf_lr; + ipkdbregs[CTR] = tf->tf_ctr; + ipkdbregs[XER] = tf->tf_xer; switch (ipkdbcmds()) { case 2: @@ -96,13 +96,13 @@ ipkdbregs[PS] |= PSL_SE; break; } - ipkdbcopy(&ipkdbregs[FIX], frame->fixreg, NFIX * sizeof(int)); - frame->srr0 = ipkdbregs[PC]; - frame->srr1 = ipkdbregs[PS]; - frame->cr = ipkdbregs[CR]; - frame->lr = ipkdbregs[LR]; - frame->ctr = ipkdbregs[CTR]; - frame->xer = ipkdbregs[XER]; + ipkdbcopy(&ipkdbregs[FIX], tf->tf_fixreg, NFIX * sizeof(int)); + tf->tf_srr0 = ipkdbregs[PC]; + tf->tf_srr1 = ipkdbregs[PS]; + tf->tf_cr = ipkdbregs[CR]; + tf->tf_lr = ipkdbregs[LR]; + tf->tf_ctr = ipkdbregs[CTR]; + tf->tf_xer = ipkdbregs[XER]; #ifdef IPKDBUSERHACK __asm ("mtsr %0,%1; isync" :: "n"(USER_SR), "r"(savesr)); #endif Index: src/sys/arch/powerpc/powerpc/kgdb_machdep.c diff -u src/sys/arch/powerpc/powerpc/kgdb_machdep.c:1.20 src/sys/arch/powerpc/powerpc/kgdb_machdep.c:1.20.30.1 --- src/sys/arch/powerpc/powerpc/kgdb_machdep.c:1.20 Tue Feb 5 22:31:50 2008 +++ src/sys/arch/powerpc/powerpc/kgdb_machdep.c Fri Jan 7 02:03:51 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: kgdb_machdep.c,v 1.20 2008/02/05 22:31:50 garbled Exp $ */ +/* $NetBSD: kgdb_machdep.c,v 1.20.30.1 2011/01/07 02:03:51 matt Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -36,7 +36,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: kgdb_machdep.c,v 1.20 2008/02/05 22:31:50 garbled Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kgdb_machdep.c,v 1.20.30.1 2011/01/07 02:03:51 matt Exp $"); #include "opt_ddb.h" @@ -56,6 +56,18 @@ #include <powerpc/oea/bat.h> #include <powerpc/spr.h> +#if defined (PPC_OEA) || defined (PPC_OEA601) || defined (PPC_OEA64_BRIDGE) +#include <powerpc/oea/spr.h> +#include <powerpc/oea/bat.h> +#elif defined (PPC_OEA64) +#include <powerpc/oea/spr.h> +#elif defined (PPC_IBM4XX) +#include <powerpc/booke/spr.h> +#elif defined (PPC_BOOKE) +#include <powerpc/booke/spr.h> +#else +#error unknown architecture +#endif /* * Determine if the memory at va..(va+len) is valid. Index: src/sys/arch/powerpc/powerpc/powerpc_machdep.c diff -u src/sys/arch/powerpc/powerpc/powerpc_machdep.c:1.39 src/sys/arch/powerpc/powerpc/powerpc_machdep.c:1.39.16.1 --- src/sys/arch/powerpc/powerpc/powerpc_machdep.c:1.39 Wed Oct 15 06:51:18 2008 +++ src/sys/arch/powerpc/powerpc/powerpc_machdep.c Fri Jan 7 02:03:51 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: powerpc_machdep.c,v 1.39 2008/10/15 06:51:18 wrstuden Exp $ */ +/* $NetBSD: powerpc_machdep.c,v 1.39.16.1 2011/01/07 02:03:51 matt Exp $ */ /* * Copyright (C) 1995, 1996 Wolfgang Solfrank. @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: powerpc_machdep.c,v 1.39 2008/10/15 06:51:18 wrstuden Exp $"); +__KERNEL_RCSID(0, "$NetBSD: powerpc_machdep.c,v 1.39.16.1 2011/01/07 02:03:51 matt Exp $"); #include "opt_altivec.h" @@ -51,7 +51,7 @@ #include <sys/cpu.h> int cpu_timebase; -int cpu_printfataltraps; +int cpu_printfataltraps = 1; #if !defined(PPC_IBM4XX) extern int powersave; #endif @@ -70,7 +70,7 @@ struct ps_strings arginfo; memset(tf, 0, sizeof *tf); - tf->fixreg[1] = -roundup(-stack + 8, 16); + tf->tf_fixreg[1] = -roundup(-stack + 8, 16); /* * XXX Machine-independent code has already copied arguments and @@ -92,17 +92,17 @@ * XXX We have to set both regs and retval here due to different * XXX calling convention in trap.c and init_main.c. */ - tf->fixreg[3] = arginfo.ps_nargvstr; - tf->fixreg[4] = (register_t)arginfo.ps_argvstr; - tf->fixreg[5] = (register_t)arginfo.ps_envstr; - tf->fixreg[6] = 0; /* auxillary vector */ - tf->fixreg[7] = 0; /* termination vector */ - tf->fixreg[8] = (register_t)p->p_psstr; /* NetBSD extension */ + tf->tf_fixreg[3] = arginfo.ps_nargvstr; + tf->tf_fixreg[4] = (register_t)arginfo.ps_argvstr; + tf->tf_fixreg[5] = (register_t)arginfo.ps_envstr; + tf->tf_fixreg[6] = 0; /* auxillary vector */ + tf->tf_fixreg[7] = 0; /* termination vector */ + tf->tf_fixreg[8] = (register_t)p->p_psstr; /* NetBSD extension */ - tf->srr0 = pack->ep_entry; - tf->srr1 = PSL_MBO | PSL_USERSET; + tf->tf_srr0 = pack->ep_entry; + tf->tf_srr1 = PSL_MBO | PSL_USERSET; #ifdef ALTIVEC - tf->tf_xtra[TF_VRSAVE] = 0; + tf->tf_vrsave = 0; #endif l->l_addr->u_pcb.pcb_flags = PSL_FE_DFLT; } @@ -197,16 +197,18 @@ CTLTYPE_INT, "powersave", NULL, sysctl_machdep_powersave, 0, &powersave, 0, CTL_MACHDEP, CPU_POWERSAVE, CTL_EOL); +#endif +#if defined(PPC_IBM4XX) || defined(PPC_BOOKE) sysctl_createv(clog, 0, NULL, NULL, CTLFLAG_PERMANENT|CTLFLAG_IMMEDIATE, CTLTYPE_INT, "altivec", NULL, - NULL, cpu_altivec, NULL, 0, + NULL, 0, NULL, 0, CTL_MACHDEP, CPU_ALTIVEC, CTL_EOL); #else sysctl_createv(clog, 0, NULL, NULL, CTLFLAG_PERMANENT|CTLFLAG_IMMEDIATE, CTLTYPE_INT, "altivec", NULL, - NULL, 0, NULL, 0, + NULL, cpu_altivec, NULL, 0, CTL_MACHDEP, CPU_ALTIVEC, CTL_EOL); #endif sysctl_createv(clog, 0, NULL, NULL, @@ -283,21 +285,28 @@ /* * Build context to run handler in. */ - tf->fixreg[1] = (register_t)((struct saframe *)sp - 1); - tf->lr = 0; - tf->fixreg[3] = (register_t)type; - tf->fixreg[4] = (register_t)sas; - tf->fixreg[5] = (register_t)nevents; - tf->fixreg[6] = (register_t)ninterrupted; - tf->fixreg[7] = (register_t)ap; - tf->srr0 = (register_t)upcall; - tf->srr1 &= ~PSL_SE; + tf->tf_fixreg[1] = (register_t)((struct saframe *)sp - 1); + tf->tf_lr = 0; + tf->tf_fixreg[3] = (register_t)type; + tf->tf_fixreg[4] = (register_t)sas; + tf->tf_fixreg[5] = (register_t)nevents; + tf->tf_fixreg[6] = (register_t)ninterrupted; + tf->tf_fixreg[7] = (register_t)ap; + tf->tf_srr0 = (register_t)upcall; + tf->tf_srr1 &= ~PSL_SE; } bool cpu_intr_p(void) { - return curcpu()->ci_idepth != 0; + return curcpu()->ci_idepth >= 0; } +void +cpu_idle(void) +{ + KASSERT(mfmsr() & PSL_EE); + KASSERT(curcpu()->ci_cpl == IPL_NONE); + (*curcpu()->ci_idlespin)(); +} Index: src/sys/arch/powerpc/powerpc/process_machdep.c diff -u src/sys/arch/powerpc/powerpc/process_machdep.c:1.26 src/sys/arch/powerpc/powerpc/process_machdep.c:1.26.42.1 --- src/sys/arch/powerpc/powerpc/process_machdep.c:1.26 Wed Oct 17 19:56:48 2007 +++ src/sys/arch/powerpc/powerpc/process_machdep.c Fri Jan 7 02:03:51 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: process_machdep.c,v 1.26 2007/10/17 19:56:48 garbled Exp $ */ +/* $NetBSD: process_machdep.c,v 1.26.42.1 2011/01/07 02:03:51 matt Exp $ */ /* * Copyright (C) 1995, 1996 Wolfgang Solfrank. @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.26 2007/10/17 19:56:48 garbled Exp $"); +__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.26.42.1 2011/01/07 02:03:51 matt Exp $"); #include "opt_altivec.h" @@ -57,12 +57,12 @@ { struct trapframe * const tf = trapframe(l); - memcpy(regs->fixreg, tf->fixreg, sizeof(regs->fixreg)); - regs->lr = tf->lr; - regs->cr = tf->cr; - regs->xer = tf->xer; - regs->ctr = tf->ctr; - regs->pc = tf->srr0; + memcpy(regs->fixreg, tf->tf_fixreg, sizeof(regs->fixreg)); + regs->lr = tf->tf_lr; + regs->cr = tf->tf_cr; + regs->xer = tf->tf_xer; + regs->ctr = tf->tf_ctr; + regs->pc = tf->tf_srr0; return 0; } @@ -72,12 +72,12 @@ { struct trapframe * const tf = trapframe(l); - memcpy(tf->fixreg, regs->fixreg, sizeof(regs->fixreg)); - tf->lr = regs->lr; - tf->cr = regs->cr; - tf->xer = regs->xer; - tf->ctr = regs->ctr; - tf->srr0 = regs->pc; + memcpy(tf->tf_fixreg, regs->fixreg, sizeof(regs->fixreg)); + tf->tf_lr = regs->lr; + tf->tf_cr = regs->cr; + tf->tf_xer = regs->xer; + tf->tf_ctr = regs->ctr; + tf->tf_srr0 = regs->pc; return 0; } @@ -126,7 +126,8 @@ { struct trapframe * const tf = trapframe(l); - tf->srr0 = (register_t)addr; + tf->tf_srr0 = (register_t)addr; + return 0; } @@ -136,9 +137,9 @@ struct trapframe *tf = trapframe(l); if (sstep) - tf->srr1 |= PSL_SE; + tf->tf_srr1 |= PSL_SE; else - tf->srr1 &= ~PSL_SE; + tf->tf_srr1 &= ~PSL_SE; return 0; } Index: src/sys/arch/powerpc/powerpc/syscall.c diff -u src/sys/arch/powerpc/powerpc/syscall.c:1.43 src/sys/arch/powerpc/powerpc/syscall.c:1.43.16.1 --- src/sys/arch/powerpc/powerpc/syscall.c:1.43 Tue Oct 21 12:16:59 2008 +++ src/sys/arch/powerpc/powerpc/syscall.c Fri Jan 7 02:03:51 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: syscall.c,v 1.43 2008/10/21 12:16:59 ad Exp $ */ +/* $NetBSD: syscall.c,v 1.43.16.1 2011/01/07 02:03:51 matt Exp $ */ /* * Copyright (C) 2002 Matt Thomas @@ -64,7 +64,7 @@ #define EMULNAME(x) (x) #define EMULNAMEU(x) (x) -__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.43 2008/10/21 12:16:59 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.43.16.1 2011/01/07 02:03:51 matt Exp $"); void child_return(void *arg) @@ -72,10 +72,10 @@ struct lwp * const l = arg; struct trapframe * const tf = trapframe(l); - tf->fixreg[FIRSTARG] = 0; - tf->fixreg[FIRSTARG + 1] = 1; - tf->cr &= ~0x10000000; - tf->srr1 &= ~(PSL_FP|PSL_VEC); /* Disable FP & AltiVec, as we can't + tf->tf_fixreg[FIRSTARG] = 0; + tf->tf_fixreg[FIRSTARG + 1] = 1; + tf->tf_cr &= ~0x10000000; + tf->tf_srr1 &= ~(PSL_FP|PSL_VEC); /* Disable FP & AltiVec, as we can't be them. */ l->l_addr->u_pcb.pcb_fpcpu = NULL; ktrsysret(SYS_fork, 0, 0); @@ -85,8 +85,10 @@ static void EMULNAME(syscall_plain)(struct trapframe *); +#include <powerpc/spr.h> + void -EMULNAME(syscall_plain)(struct trapframe *frame) +EMULNAME(syscall_plain)(struct trapframe *tf) { struct lwp *l = curlwp; struct proc *p = l->l_proc; @@ -100,9 +102,10 @@ LWP_CACHE_CREDS(l, p); curcpu()->ci_ev_scalls.ev_count++; + curcpu()->ci_data.cpu_nsyscall++; - code = frame->fixreg[0]; - params = frame->fixreg + FIRSTARG; + code = tf->tf_fixreg[0]; + params = tf->tf_fixreg + FIRSTARG; n = NARGREG; #ifdef KERN_SA @@ -143,9 +146,9 @@ if (argsize > n * sizeof(register_t)) { memcpy(args, params, n * sizeof(register_t)); - error = copyin(MOREARGS(frame->fixreg[1]), - args + n, - argsize - n * sizeof(register_t)); + error = copyin(MOREARGS(tf->tf_fixreg[1]), + args + n, + argsize - n * sizeof(register_t)); if (error) goto bad; params = args; @@ -158,24 +161,24 @@ switch (error) { case 0: - frame->fixreg[FIRSTARG] = rval[0]; - frame->fixreg[FIRSTARG + 1] = rval[1]; - frame->cr &= ~0x10000000; + tf->tf_fixreg[FIRSTARG] = rval[0]; + tf->tf_fixreg[FIRSTARG + 1] = rval[1]; + tf->tf_cr &= ~0x10000000; #ifdef COMPAT_MACH /* * For regular system calls, on success, * the next instruction is skipped */ - if ((frame->fixreg[0] < p->p_emul->e_nsysent) - && (frame->fixreg[0] >= 0)) - frame->srr0 += 4; + if ((tf->tf_fixreg[0] < p->p_emul->e_nsysent) + && (tf->tf_fixreg[0] >= 0)) + tf->tf_srr0 += 4; #endif /* COMPAT_MACH */ break; case ERESTART: /* * Set user's pc back to redo the system call. */ - frame->srr0 -= 4; + tf->tf_srr0 -= 4; break; case EJUSTRETURN: /* nothing to do */ @@ -184,17 +187,18 @@ bad: if (p->p_emul->e_errno) error = p->p_emul->e_errno[error]; - frame->fixreg[FIRSTARG] = error; - frame->cr |= 0x10000000; + tf->tf_fixreg[FIRSTARG] = error; + tf->tf_cr |= 0x10000000; break; } - userret(l, frame); + + userret(l, tf); } static void EMULNAME(syscall_fancy)(struct trapframe *); void -EMULNAME(syscall_fancy)(struct trapframe *frame) +EMULNAME(syscall_fancy)(struct trapframe *tf) { struct lwp *l = curlwp; struct proc *p = l->l_proc; @@ -211,8 +215,8 @@ curcpu()->ci_ev_scalls.ev_count++; - code = frame->fixreg[0]; - params = frame->fixreg + FIRSTARG; + code = tf->tf_fixreg[0]; + params = tf->tf_fixreg + FIRSTARG; n = NARGREG; #ifdef KERN_SA @@ -255,7 +259,7 @@ if (argsize > n * sizeof(register_t)) { memcpy(args, params, n * sizeof(register_t)); - error = copyin(MOREARGS(frame->fixreg[1]), + error = copyin(MOREARGS(tf->tf_fixreg[1]), args + n, argsize - n * sizeof(register_t)); if (error) @@ -273,24 +277,24 @@ out: switch (error) { case 0: - frame->fixreg[FIRSTARG] = rval[0]; - frame->fixreg[FIRSTARG + 1] = rval[1]; - frame->cr &= ~0x10000000; + tf->tf_fixreg[FIRSTARG] = rval[0]; + tf->tf_fixreg[FIRSTARG + 1] = rval[1]; + tf->tf_cr &= ~0x10000000; #ifdef COMPAT_MACH /* * For regular system calls, on success, * the next instruction is skipped */ - if ((frame->fixreg[0] < p->p_emul->e_nsysent) - && (frame->fixreg[0] >= 0)) - frame->srr0 += 4; + if ((tf->tf_fixreg[0] < p->p_emul->e_nsysent) + && (tf->tf_fixreg[0] >= 0)) + tf->tf_srr0 += 4; #endif /* COMPAT_MACH */ break; case ERESTART: /* * Set user's pc back to redo the system call. */ - frame->srr0 -= 4; + tf->tf_srr0 -= 4; break; case EJUSTRETURN: /* nothing to do */ @@ -299,12 +303,12 @@ bad: if (p->p_emul->e_errno) error = p->p_emul->e_errno[error]; - frame->fixreg[FIRSTARG] = error; - frame->cr |= 0x10000000; + tf->tf_fixreg[FIRSTARG] = error; + tf->tf_cr |= 0x10000000; break; } trace_exit(realcode, rval, error); - userret(l, frame); + userret(l, tf); } void EMULNAME(syscall_intern)(struct proc *); Index: src/sys/arch/powerpc/powerpc/vm_machdep.c diff -u src/sys/arch/powerpc/powerpc/vm_machdep.c:1.74.4.1 src/sys/arch/powerpc/powerpc/vm_machdep.c:1.74.4.1.4.1 --- src/sys/arch/powerpc/powerpc/vm_machdep.c:1.74.4.1 Tue Jun 9 17:52:58 2009 +++ src/sys/arch/powerpc/powerpc/vm_machdep.c Fri Jan 7 02:03:51 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.74.4.1 2009/06/09 17:52:58 snj Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.74.4.1.4.1 2011/01/07 02:03:51 matt Exp $ */ /* * Copyright (C) 1995, 1996 Wolfgang Solfrank. @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.74.4.1 2009/06/09 17:52:58 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.74.4.1.4.1 2011/01/07 02:03:51 matt Exp $"); #include "opt_altivec.h" #include "opt_multiprocessor.h" @@ -88,15 +88,17 @@ struct callframe *cf; struct switchframe *sf; char *stktop1, *stktop2; - struct pcb *pcb = &l2->l_addr->u_pcb; + struct pcb *pcb1, *pcb2; -#ifdef DIAGNOSTIC +//printf("%s: l1 %p, l2 %p, stack %p, stacksize %#x, func %p, arg %p\n", +//__func__, l1, l2, stack, stacksize, func, arg); /* * if p1 != curlwp && p1 == &proc0, we're creating a kernel thread. */ - if (l1 != curlwp && l1 != &lwp0) - panic("cpu_lwp_fork: curlwp"); -#endif + KASSERT(l1 == curlwp || l1 == &lwp0); + + pcb1 = &l1->l_addr->u_pcb; + pcb2 = &l2->l_addr->u_pcb; #ifdef PPC_HAVE_FPU if (l1->l_addr->u_pcb.pcb_fpcpu) @@ -106,9 +108,11 @@ if (l1->l_addr->u_pcb.pcb_veccpu) save_vec_lwp(l1, ALTIVEC_SAVE); #endif - *pcb = l1->l_addr->u_pcb; - pcb->pcb_pm = l2->l_proc->p_vmspace->vm_map.pmap; + /* Copy PCB. */ + *pcb2 = *pcb1; + + pcb2->pcb_pm = l2->l_proc->p_vmspace->vm_map.pmap; l2->l_md.md_flags = 0; @@ -124,33 +128,34 @@ */ if (stack != NULL) { tf = trapframe(l2); - tf->fixreg[1] = (register_t)stack + stacksize; + tf->tf_fixreg[1] = (register_t)stack + stacksize; } /* * Align stack pointer - * Since sizeof(struct trapframe) is 41 words, this will - * give us 12 bytes on the stack, which pad us somewhat - * for an extra call frame (or at least space for callee - * to store LR). + * struct ktrapframe has a partial callframe (sp & lr) + * followed by a real trapframe. The partial callframe + * is for the callee to store LR. The SP isn't really used + * since trap/syscall will use the SP in the trapframe. */ - stktop2 = (void *)((uintptr_t)stktop2 & ~(CALLFRAMELEN-1)); + stktop2 = (void *)ktrapframe(l2); /* - * There happens to be a callframe, too. + * There happens to be a partial callframe in front of the + * trapframe, too. */ - cf = (struct callframe *)stktop2; - cf->sp = (register_t)(stktop2 + CALLFRAMELEN); - cf->lr = (register_t)cpu_lwp_bootstrap; + struct ktrapframe *ktf = (struct ktrapframe *)stktop2; + ktf->ktf_sp = (register_t)(stktop2 + FRAMELEN); /* not used */ + ktf->ktf_lr = (register_t)cpu_lwp_bootstrap; /* * Below the trap frame, there is another call frame: */ stktop2 -= CALLFRAMELEN; cf = (struct callframe *)stktop2; - cf->sp = (register_t)(stktop2 + CALLFRAMELEN); - cf->r31 = (register_t)func; - cf->r30 = (register_t)arg; + cf->cf_sp = (register_t)(stktop2 + CALLFRAMELEN); + cf->cf_r31 = (register_t)func; + cf->cf_r30 = (register_t)arg; /* * Below that, we allocate the switch frame: @@ -158,13 +163,15 @@ stktop2 -= SFRAMELEN; /* must match SFRAMELEN in genassym */ sf = (struct switchframe *)stktop2; memset((void *)sf, 0, sizeof *sf); /* just in case */ - sf->sp = (register_t)cf; -#ifndef PPC_IBM4XX - sf->user_sr = pmap_kernel()->pm_sr[USER_SR]; /* again, just in case */ + sf->sf_sp = (register_t)cf; +#if defined (PPC_OEA) || defined (PPC_OEA64_BRIDGE) + sf->sf_user_sr = pmap_kernel()->pm_sr[USER_SR]; /* again, just in case */ #endif - pcb->pcb_sp = (register_t)stktop2; - pcb->pcb_kmapsr = 0; - pcb->pcb_umapsr = 0; + pcb2->pcb_sp = (register_t)stktop2; + pcb2->pcb_kmapsr = 0; + pcb2->pcb_umapsr = 0; + + KASSERT(memcmp(trapframe(l1), trapframe(l2), sizeof(struct trapframe)) == 0); } void @@ -353,22 +360,22 @@ { extern void setfunc_trampoline(void); struct pcb *pcb = &l->l_addr->u_pcb; - struct trapframe *tf; + struct ktrapframe *ktf; struct callframe *cf; struct switchframe *sf; - tf = trapframe(l); - cf = (struct callframe *) ((uintptr_t)tf & ~(CALLFRAMELEN-1)); - cf->lr = (register_t)setfunc_trampoline; - cf--; - cf->sp = (register_t) (cf+1); - cf->r31 = (register_t) func; - cf->r30 = (register_t) arg; + ktf = ktrapframe(l); + KASSERT((ktf->ktf_tf.tf_srr1 & PSL_USERSET) == PSL_USERSET); + ktf->ktf_lr = (register_t)setfunc_trampoline; + cf = ((struct callframe *) ktf) - 1; + cf->cf_sp = (register_t) (cf+1); + cf->cf_r31 = (register_t) func; + cf->cf_r30 = (register_t) arg; sf = (struct switchframe *) ((uintptr_t) cf - SFRAMELEN); memset((void *)sf, 0, sizeof *sf); /* just in case */ - sf->sp = (register_t) cf; + sf->sf_sp = (register_t) cf; #if defined (PPC_OEA) || defined (PPC_OEA64_BRIDGE) - sf->user_sr = pmap_kernel()->pm_sr[USER_SR]; /* again, just in case */ + sf->sf_user_sr = pmap_kernel()->pm_sr[USER_SR]; /* again, just in case */ #endif pcb->pcb_sp = (register_t)sf; pcb->pcb_kmapsr = 0;