Module Name: src Committed By: matt Date: Thu Aug 16 17:35:01 UTC 2012
Modified Files: src/sys/arch/acorn26/acorn26: cpuswitch.c except.c machdep.c vm_machdep.c src/sys/arch/arm/arm: arm_machdep.c ast.c compat_13_machdep.c compat_16_machdep.c syscall.c undefined.c src/sys/arch/arm/arm32: arm32_machdep.c cpuswitch.S fault.c genassym.cf vm_machdep.c src/sys/arch/arm/include: cpu.h frame.h pcb.h proc.h src/sys/arch/arm/include/arm32: frame.h Log Message: small rototill. pcb_flags is dead. PCB_NOALIGNFLT is now in stored l_md.md_flags as MDLWP_NOALIGNFLT. This avoids a few loads of the PCB in exception handling. pcb_tf has been moved to l_md.md_tf. Again this avoids a lot of pcb references just to access or set this. It also means that pcb doesn't need to accessed by MI code. Move pcb_onfault to after the pcb union. Add pcb_sp macro to make code prettier. Add lwp_settrapframe(l, tf) to set the l_md.md_tf field. Use lwp_trapframe to access it (was process_frame but that name was changed in a previous commit). Kill off curpcb in acorn26. Kill the checks for curlwp being NULL. Move TRAP_USERMODE from arm32/fault.c to frame.h and a __PROG26 version. Replace tests for usermode with that macro. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sys/arch/acorn26/acorn26/cpuswitch.c cvs rdiff -u -r1.28 -r1.29 src/sys/arch/acorn26/acorn26/except.c \ src/sys/arch/acorn26/acorn26/vm_machdep.c cvs rdiff -u -r1.36 -r1.37 src/sys/arch/acorn26/acorn26/machdep.c cvs rdiff -u -r1.32 -r1.33 src/sys/arch/arm/arm/arm_machdep.c cvs rdiff -u -r1.20 -r1.21 src/sys/arch/arm/arm/ast.c cvs rdiff -u -r1.16 -r1.17 src/sys/arch/arm/arm/compat_13_machdep.c cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/arm/compat_16_machdep.c cvs rdiff -u -r1.55 -r1.56 src/sys/arch/arm/arm/syscall.c cvs rdiff -u -r1.46 -r1.47 src/sys/arch/arm/arm/undefined.c cvs rdiff -u -r1.80 -r1.81 src/sys/arch/arm/arm32/arm32_machdep.c cvs rdiff -u -r1.65 -r1.66 src/sys/arch/arm/arm32/cpuswitch.S cvs rdiff -u -r1.82 -r1.83 src/sys/arch/arm/arm32/fault.c cvs rdiff -u -r1.48 -r1.49 src/sys/arch/arm/arm32/genassym.cf cvs rdiff -u -r1.58 -r1.59 src/sys/arch/arm/arm32/vm_machdep.c cvs rdiff -u -r1.67 -r1.68 src/sys/arch/arm/include/cpu.h cvs rdiff -u -r1.16 -r1.17 src/sys/arch/arm/include/frame.h cvs rdiff -u -r1.23 -r1.24 src/sys/arch/arm/include/pcb.h cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/include/proc.h cvs rdiff -u -r1.30 -r1.31 src/sys/arch/arm/include/arm32/frame.h 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/acorn26/acorn26/cpuswitch.c diff -u src/sys/arch/acorn26/acorn26/cpuswitch.c:1.17 src/sys/arch/acorn26/acorn26/cpuswitch.c:1.18 --- src/sys/arch/acorn26/acorn26/cpuswitch.c:1.17 Sat Nov 21 20:32:17 2009 +++ src/sys/arch/acorn26/acorn26/cpuswitch.c Thu Aug 16 17:35:01 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: cpuswitch.c,v 1.17 2009/11/21 20:32:17 rmind Exp $ */ +/* $NetBSD: cpuswitch.c,v 1.18 2012/08/16 17:35:01 matt Exp $ */ /* * Copyright (c) 2000 Ben Harris. @@ -38,7 +38,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: cpuswitch.c,v 1.17 2009/11/21 20:32:17 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpuswitch.c,v 1.18 2012/08/16 17:35:01 matt Exp $"); #include "opt_lockdebug.h" @@ -60,8 +60,6 @@ __KERNEL_RCSID(0, "$NetBSD: cpuswitch.c, lwp_t * cpu_switchto(lwp_t *old, lwp_t *new, bool returning) { - struct cpu_info * const ci = curcpu(); - struct pcb *pcb; struct proc *p2; /* @@ -73,14 +71,12 @@ cpu_switchto(lwp_t *old, lwp_t *new, boo #endif curlwp = new; - pcb = lwp_getpcb(curlwp); - ci->ci_curpcb = pcb; if ((new->l_flag & LW_SYSTEM) == 0) { /* Check for Restartable Atomic Sequences. */ p2 = new->l_proc; if (p2->p_raslist != NULL) { - struct trapframe *tf = pcb->pcb_tf; + struct trapframe * const tf = lwp_trapframe(curlwp); void *pc; pc = ras_lookup(p2, (void *)(tf->tf_r15 & R15_PC)); Index: src/sys/arch/acorn26/acorn26/except.c diff -u src/sys/arch/acorn26/acorn26/except.c:1.28 src/sys/arch/acorn26/acorn26/except.c:1.29 --- src/sys/arch/acorn26/acorn26/except.c:1.28 Fri May 11 15:39:17 2012 +++ src/sys/arch/acorn26/acorn26/except.c Thu Aug 16 17:35:01 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: except.c,v 1.28 2012/05/11 15:39:17 skrll Exp $ */ +/* $NetBSD: except.c,v 1.29 2012/08/16 17:35:01 matt Exp $ */ /*- * Copyright (c) 1998, 1999, 2000 Ben Harris * All rights reserved. @@ -31,7 +31,7 @@ #include <sys/param.h> -__KERNEL_RCSID(0, "$NetBSD: except.c,v 1.28 2012/05/11 15:39:17 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: except.c,v 1.29 2012/08/16 17:35:01 matt Exp $"); #include "opt_ddb.h" @@ -93,9 +93,8 @@ checkvectors(void) void prefetch_abort_handler(struct trapframe *tf) { - vaddr_t pc; - struct proc *p; - struct lwp *l; + struct lwp * const l = curlwp; + struct proc * const p = l->l_proc; /* Enable interrupts if they were enabled before the trap. */ if ((tf->tf_r15 & R15_IRQ_DISABLE) == 0) @@ -109,18 +108,11 @@ prefetch_abort_handler(struct trapframe */ curcpu()->ci_data.cpu_ntrap++; - l = curlwp; - if (l == NULL) - l = &lwp0; - p = l->l_proc; - if ((tf->tf_r15 & R15_MODE) == R15_MODE_USR) { - struct pcb *pcb = lwp_getpcb(l); - pcb->pcb_tf = tf; + if (TRAP_USERMODE(tf)) { + lwp_settrapframe(l, tf); LWP_CACHE_CREDS(l, p); - } - - if ((tf->tf_r15 & R15_MODE) != R15_MODE_USR) { + } else { #ifdef DDB db_printf("Prefetch abort in kernel mode\n"); kdb_trap(T_FAULT, tf); @@ -134,7 +126,7 @@ prefetch_abort_handler(struct trapframe } /* User-mode prefetch abort */ - pc = tf->tf_r15 & R15_PC; + vaddr_t pc = tf->tf_r15 & R15_PC; do_fault(tf, l, &p->p_vmspace->vm_map, pc, VM_PROT_EXECUTE); @@ -144,13 +136,13 @@ prefetch_abort_handler(struct trapframe void data_abort_handler(struct trapframe *tf) { - vaddr_t pc, va; - vsize_t asize; - struct proc *p; - struct lwp *l; + struct lwp * const l = curlwp; + struct proc * const p = l->l_proc; vm_prot_t atype; bool usrmode, twopages; struct vm_map *map; + vaddr_t pc, va; + vsize_t asize; /* * Data aborts in kernel mode are possible (copyout etc), so @@ -167,13 +159,8 @@ data_abort_handler(struct trapframe *tf) if ((tf->tf_r15 & R15_IRQ_DISABLE) == 0) int_on(); curcpu()->ci_data.cpu_ntrap++; - l = curlwp; - if (l == NULL) - l = &lwp0; - p = l->l_proc; if ((tf->tf_r15 & R15_MODE) == R15_MODE_USR) { - struct pcb *pcb = lwp_getpcb(l); - pcb->pcb_tf = tf; + lwp_settrapframe(l, tf); LWP_CACHE_CREDS(l, p); } pc = tf->tf_r15 & R15_PC; @@ -190,7 +177,7 @@ data_abort_handler(struct trapframe *tf) if (twopages) do_fault(tf, l, map, va + asize - 4, atype); - if ((tf->tf_r15 & R15_MODE) == R15_MODE_USR) + if (TRAP_USERMODE(tf)) userret(l); } @@ -202,16 +189,13 @@ do_fault(struct trapframe *tf, struct lw struct vm_map *map, vaddr_t va, vm_prot_t atype) { int error; - struct pcb *pcb; - void *onfault; - bool user; if (pmap_fault(map->pmap, va, atype)) return; - pcb = lwp_getpcb(l); - onfault = pcb->pcb_onfault; - user = (tf->tf_r15 & R15_MODE) == R15_MODE_USR; + struct pcb * const pcb = lwp_getpcb(l); + void * const onfault = pcb->pcb_onfault; + const bool user = TRAP_USERMODE(tf); if (cpu_intr_p()) { KASSERT(!user); @@ -459,7 +443,7 @@ data_abort_usrmode(struct trapframe *tf) { register_t insn; - if ((tf->tf_r15 & R15_MODE) == R15_MODE_USR) + if (TRAP_USERMODE(tf)) return true; insn = *(register_t *)(tf->tf_r15 & R15_PC); if ((insn & 0x0d200000) == 0x04200000) @@ -471,33 +455,30 @@ data_abort_usrmode(struct trapframe *tf) void address_exception_handler(struct trapframe *tf) { - struct lwp *l; - vaddr_t pc; + struct lwp * const l = curlwp; + struct pcb * const pcb = lwp_getpcb(l); ksiginfo_t ksi; /* Enable interrupts if they were enabled before the trap. */ if ((tf->tf_r15 & R15_IRQ_DISABLE) == 0) int_on(); + curcpu()->ci_data.cpu_ntrap++; - l = curlwp; - if (l == NULL) - l = &lwp0; - if ((tf->tf_r15 & R15_MODE) == R15_MODE_USR) { - struct pcb *pcb = lwp_getpcb(l); - pcb->pcb_tf = tf; + if (TRAP_USERMODE(tf)) { + lwp_settrapframe(l, tf); LWP_CACHE_CREDS(l, l->l_proc); } - if (curpcb->pcb_onfault != NULL) { + if (pcb->pcb_onfault != NULL) { tf->tf_r0 = EFAULT; tf->tf_r15 = (tf->tf_r15 & ~R15_PC) | - (register_t)curpcb->pcb_onfault; + (uintptr_t)pcb->pcb_onfault; return; } - pc = tf->tf_r15 & R15_PC; + vaddr_t pc = tf->tf_r15 & R15_PC; - if ((tf->tf_r15 & R15_MODE) != R15_MODE_USR) { + if (!TRAP_USERMODE(tf)) { #ifdef DDB db_printf("Address exception in kernel mode\n"); kdb_trap(T_FAULT, tf); Index: src/sys/arch/acorn26/acorn26/vm_machdep.c diff -u src/sys/arch/acorn26/acorn26/vm_machdep.c:1.28 src/sys/arch/acorn26/acorn26/vm_machdep.c:1.29 --- src/sys/arch/acorn26/acorn26/vm_machdep.c:1.28 Sun Feb 19 21:05:58 2012 +++ src/sys/arch/acorn26/acorn26/vm_machdep.c Thu Aug 16 17:35:01 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.28 2012/02/19 21:05:58 rmind Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.29 2012/08/16 17:35:01 matt Exp $ */ /*- * Copyright (c) 2000, 2001 Ben Harris @@ -64,7 +64,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.28 2012/02/19 21:05:58 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.29 2012/08/16 17:35:01 matt Exp $"); #include <sys/param.h> #include <sys/buf.h> @@ -80,6 +80,7 @@ __KERNEL_RCSID(0, "$NetBSD: vm_machdep.c #include <machine/frame.h> #include <machine/intr.h> #include <machine/machdep.h> +#include <machine/pcb.h> /* * Finish a fork operation, with thread l2 nearly set up. @@ -122,21 +123,21 @@ cpu_lwp_fork(struct lwp *l1, struct lwp tf = (struct trapframe *)(uvm_lwp_getuarea(l2) + USPACE) - 1; sf = (struct switchframe *)tf - 1; /* Duplicate old process's trapframe (if it had one) */ - if (pcb1->pcb_tf == NULL) + if (lwp_trapframe(l1) == NULL) memset(tf, 0, sizeof(*tf)); else - *tf = *pcb1->pcb_tf; + *tf = *lwp_trapframe(l1); /* If specified, give the child a different stack. */ if (stack != NULL) tf->tf_usr_sp = (u_int)stack + stacksize; - pcb2->pcb_tf = tf; + lwp_settrapframe(l2, tf); /* Fabricate a new switchframe */ memset(sf, 0, sizeof(*sf)); sf->sf_r13 = (register_t)tf; /* Initial stack pointer */ sf->sf_pc = (register_t)lwp_trampoline | R15_MODE_SVC; - pcb2->pcb_tf = tf; + lwp_settrapframe(l2, tf); pcb2->pcb_sf = sf; pcb2->pcb_onfault = NULL; sf->sf_r4 = (register_t)func; Index: src/sys/arch/acorn26/acorn26/machdep.c diff -u src/sys/arch/acorn26/acorn26/machdep.c:1.36 src/sys/arch/acorn26/acorn26/machdep.c:1.37 --- src/sys/arch/acorn26/acorn26/machdep.c:1.36 Fri May 11 15:39:17 2012 +++ src/sys/arch/acorn26/acorn26/machdep.c Thu Aug 16 17:35:01 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.36 2012/05/11 15:39:17 skrll Exp $ */ +/* $NetBSD: machdep.c,v 1.37 2012/08/16 17:35:01 matt Exp $ */ /*- * Copyright (c) 1998 Ben Harris @@ -32,7 +32,7 @@ #include <sys/param.h> -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.36 2012/05/11 15:39:17 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.37 2012/08/16 17:35:01 matt Exp $"); #include <sys/buf.h> #include <sys/kernel.h> @@ -169,8 +169,6 @@ cpu_startup(void) format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free)); printf("avail memory = %s\n", pbuf); - curpcb = lwp_getpcb(&lwp0); - #if 0 /* Test exception handlers */ __asm(".word 0x06000010"); /* undefined instruction */ Index: src/sys/arch/arm/arm/arm_machdep.c diff -u src/sys/arch/arm/arm/arm_machdep.c:1.32 src/sys/arch/arm/arm/arm_machdep.c:1.33 --- src/sys/arch/arm/arm/arm_machdep.c:1.32 Sun Aug 12 05:05:47 2012 +++ src/sys/arch/arm/arm/arm_machdep.c Thu Aug 16 17:35:01 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: arm_machdep.c,v 1.32 2012/08/12 05:05:47 matt Exp $ */ +/* $NetBSD: arm_machdep.c,v 1.33 2012/08/16 17:35:01 matt Exp $ */ /* * Copyright (c) 2001 Wasabi Systems, Inc. @@ -78,7 +78,7 @@ #include <sys/param.h> -__KERNEL_RCSID(0, "$NetBSD: arm_machdep.c,v 1.32 2012/08/12 05:05:47 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: arm_machdep.c,v 1.33 2012/08/16 17:35:01 matt Exp $"); #include <sys/exec.h> #include <sys/proc.h> @@ -94,7 +94,6 @@ __KERNEL_RCSID(0, "$NetBSD: arm_machdep. #include <arm/cpufunc.h> -#include <machine/pcb.h> #include <machine/vmparam.h> /* the following is used externally (sysctl_hw) */ @@ -152,11 +151,7 @@ EVCNT_ATTACH_STATIC(_lock_cas_fail); void setregs(struct lwp *l, struct exec_package *pack, vaddr_t stack) { - struct pcb *pcb; - struct trapframe *tf; - - pcb = lwp_getpcb(l); - tf = pcb->pcb_tf; + struct trapframe * const tf = lwp_trapframe(l); memset(tf, 0, sizeof(*tf)); tf->tf_r0 = l->l_proc->p_psstrp; @@ -173,12 +168,11 @@ setregs(struct lwp *l, struct exec_packa #endif #endif + l->l_md.md_flags = 0; #ifdef EXEC_AOUT if (pack->ep_esch->es_makecmds == exec_aout_makecmds) - pcb->pcb_flags = PCB_NOALIGNFLT; - else + l->l_md.md_flags |= MDLWP_NOALIGNFLT; #endif - pcb->pcb_flags = 0; #ifdef FPU_VFP vfp_discardcontext(); #endif Index: src/sys/arch/arm/arm/ast.c diff -u src/sys/arch/arm/arm/ast.c:1.20 src/sys/arch/arm/arm/ast.c:1.21 --- src/sys/arch/arm/arm/ast.c:1.20 Mon Dec 20 00:25:26 2010 +++ src/sys/arch/arm/arm/ast.c Thu Aug 16 17:35:01 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: ast.c,v 1.20 2010/12/20 00:25:26 matt Exp $ */ +/* $NetBSD: ast.c,v 1.21 2012/08/16 17:35:01 matt Exp $ */ /* * Copyright (c) 1994,1995 Mark Brinicombe @@ -41,7 +41,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ast.c,v 1.20 2010/12/20 00:25:26 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ast.c,v 1.21 2012/08/16 17:35:01 matt Exp $"); #include "opt_ddb.h" @@ -77,10 +77,7 @@ userret(struct lwp *l) mi_userret(l); #if defined(__PROG32) && defined(DIAGNOSTIC) - { - struct pcb *pcb = lwp_getpcb(l); - KASSERT((pcb->pcb_tf->tf_spsr & IF32_bits) == 0); - } + KASSERT((lwp_trapframe(l)->tf_spsr & IF32_bits) == 0); #endif } @@ -94,8 +91,7 @@ userret(struct lwp *l) void ast(struct trapframe *tf) { - struct lwp *l = curlwp; - struct proc *p; + struct lwp * const l = curlwp; #ifdef acorn26 /* Enable interrupts if they were enabled before the trap. */ @@ -109,20 +105,13 @@ ast(struct trapframe *tf) KASSERT((tf->tf_spsr & IF32_bits) == 0); #endif - curcpu()->ci_data.cpu_ntrap++; //curcpu()->ci_data.cpu_nast++; #ifdef DEBUG KDASSERT(curcpu()->ci_cpl == IPL_NONE); - if (l == NULL) - panic("ast: no curlwp!"); - if (lwp_getpcb(l) == NULL) - panic("ast: no pcb!"); #endif - p = l->l_proc; - if (l->l_pflag & LP_OWEUPC) { l->l_pflag &= ~LP_OWEUPC; ADDUPROF(l); Index: src/sys/arch/arm/arm/compat_13_machdep.c diff -u src/sys/arch/arm/arm/compat_13_machdep.c:1.16 src/sys/arch/arm/arm/compat_13_machdep.c:1.17 --- src/sys/arch/arm/arm/compat_13_machdep.c:1.16 Sat Nov 21 20:32:17 2009 +++ src/sys/arch/arm/arm/compat_13_machdep.c Thu Aug 16 17:35:01 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: compat_13_machdep.c,v 1.16 2009/11/21 20:32:17 rmind Exp $ */ +/* $NetBSD: compat_13_machdep.c,v 1.17 2012/08/16 17:35:01 matt Exp $ */ /* * Copyright (c) 1994-1998 Mark Brinicombe. @@ -38,7 +38,7 @@ #include <sys/param.h> -__KERNEL_RCSID(0, "$NetBSD: compat_13_machdep.c,v 1.16 2009/11/21 20:32:17 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: compat_13_machdep.c,v 1.17 2012/08/16 17:35:01 matt Exp $"); #include <sys/systm.h> #include <sys/signalvar.h> @@ -57,9 +57,8 @@ compat_13_sys_sigreturn(struct lwp *l, c syscallarg(struct sigcontext13 *) sigcntxp; } */ struct sigcontext13 *scp, context; - struct trapframe *tf; - struct proc *p = l->l_proc; - struct pcb *pcb; + struct trapframe * const tf = lwp_trapframe(l); + struct proc * const p = l->l_proc; sigset_t mask; /* @@ -79,8 +78,6 @@ compat_13_sys_sigreturn(struct lwp *l, c return EINVAL; /* Restore register context. */ - pcb = lwp_getpcb(l); - tf = pcb->pcb_tf; tf->tf_r0 = context.sc_r0; tf->tf_r1 = context.sc_r1; tf->tf_r2 = context.sc_r2; Index: src/sys/arch/arm/arm/compat_16_machdep.c diff -u src/sys/arch/arm/arm/compat_16_machdep.c:1.15 src/sys/arch/arm/arm/compat_16_machdep.c:1.16 --- src/sys/arch/arm/arm/compat_16_machdep.c:1.15 Thu Aug 16 16:41:53 2012 +++ src/sys/arch/arm/arm/compat_16_machdep.c Thu Aug 16 17:35:01 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: compat_16_machdep.c,v 1.15 2012/08/16 16:41:53 matt Exp $ */ +/* $NetBSD: compat_16_machdep.c,v 1.16 2012/08/16 17:35:01 matt Exp $ */ /* * Copyright (c) 1994-1998 Mark Brinicombe. @@ -42,7 +42,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: compat_16_machdep.c,v 1.15 2012/08/16 16:41:53 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: compat_16_machdep.c,v 1.16 2012/08/16 17:35:01 matt Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -62,7 +62,6 @@ __KERNEL_RCSID(0, "$NetBSD: compat_16_ma #include <machine/cpu.h> #include <machine/frame.h> -#include <machine/pcb.h> #ifndef acorn26 #include <arm/cpufunc.h> #endif Index: src/sys/arch/arm/arm/syscall.c diff -u src/sys/arch/arm/arm/syscall.c:1.55 src/sys/arch/arm/arm/syscall.c:1.56 --- src/sys/arch/arm/arm/syscall.c:1.55 Thu Aug 16 17:04:21 2012 +++ src/sys/arch/arm/arm/syscall.c Thu Aug 16 17:35:01 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: syscall.c,v 1.55 2012/08/16 17:04:21 matt Exp $ */ +/* $NetBSD: syscall.c,v 1.56 2012/08/16 17:35:01 matt Exp $ */ /*- * Copyright (c) 2000, 2003 The NetBSD Foundation, Inc. @@ -71,7 +71,7 @@ #include <sys/param.h> -__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.55 2012/08/16 17:04:21 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.56 2012/08/16 17:35:01 matt Exp $"); #include <sys/device.h> #include <sys/errno.h> @@ -87,7 +87,6 @@ __KERNEL_RCSID(0, "$NetBSD: syscall.c,v #include <machine/cpu.h> #include <machine/frame.h> -#include <machine/pcb.h> #include <arm/swi.h> #ifdef acorn26 @@ -97,8 +96,7 @@ __KERNEL_RCSID(0, "$NetBSD: syscall.c,v void swi_handler(trapframe_t *tf) { - lwp_t *l = curlwp; - struct pcb *pcb; + lwp_t * const l = curlwp; uint32_t insn; /* @@ -161,8 +159,7 @@ swi_handler(trapframe_t *tf) #endif } - pcb = lwp_getpcb(l); - pcb->pcb_tf = tf; + lwp_settrapframe(l, tf); #ifdef CPU_ARM7 /* @@ -314,9 +311,8 @@ syscall(struct trapframe *tf, lwp_t *l, void child_return(void *arg) { - lwp_t *l = arg; - struct pcb *pcb = lwp_getpcb(l); - struct trapframe *tf = pcb->pcb_tf; + lwp_t * const l = arg; + struct trapframe * const tf = lwp_trapframe(l); tf->tf_r0 = 0; #ifdef __PROG32 Index: src/sys/arch/arm/arm/undefined.c diff -u src/sys/arch/arm/arm/undefined.c:1.46 src/sys/arch/arm/arm/undefined.c:1.47 --- src/sys/arch/arm/arm/undefined.c:1.46 Sun Aug 12 05:05:47 2012 +++ src/sys/arch/arm/arm/undefined.c Thu Aug 16 17:35:01 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: undefined.c,v 1.46 2012/08/12 05:05:47 matt Exp $ */ +/* $NetBSD: undefined.c,v 1.47 2012/08/16 17:35:01 matt Exp $ */ /* * Copyright (c) 2001 Ben Harris. @@ -54,7 +54,7 @@ #include <sys/kgdb.h> #endif -__KERNEL_RCSID(0, "$NetBSD: undefined.c,v 1.46 2012/08/12 05:05:47 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: undefined.c,v 1.47 2012/08/16 17:35:01 matt Exp $"); #include <sys/kmem.h> #include <sys/queue.h> @@ -63,6 +63,7 @@ __KERNEL_RCSID(0, "$NetBSD: undefined.c, #include <sys/proc.h> #include <sys/syslog.h> #include <sys/vmmeter.h> +#include <sys/cpu.h> #ifdef FAST_FPE #include <sys/acct.h> #endif @@ -70,11 +71,12 @@ __KERNEL_RCSID(0, "$NetBSD: undefined.c, #include <uvm/uvm_extern.h> -#include <machine/cpu.h> #include <machine/frame.h> -#include <arm/undefined.h> +#include <machine/pcb.h> #include <machine/trap.h> +#include <arm/undefined.h> + #include <arch/arm/arm/disassem.h> #ifdef DDB @@ -363,13 +365,12 @@ undefinedinstruction(trapframe_t *frame) } if (user) { - struct pcb *pcb = lwp_getpcb(l); /* * Modify the fault_code to reflect the USR/SVC state at * time of fault. */ fault_code = FAULT_USER; - pcb->pcb_tf = frame; + lwp_settrapframe(l, frame); } else fault_code = 0; Index: src/sys/arch/arm/arm32/arm32_machdep.c diff -u src/sys/arch/arm/arm32/arm32_machdep.c:1.80 src/sys/arch/arm/arm32/arm32_machdep.c:1.81 --- src/sys/arch/arm/arm32/arm32_machdep.c:1.80 Tue Aug 14 20:42:33 2012 +++ src/sys/arch/arm/arm32/arm32_machdep.c Thu Aug 16 17:35:01 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: arm32_machdep.c,v 1.80 2012/08/14 20:42:33 matt Exp $ */ +/* $NetBSD: arm32_machdep.c,v 1.81 2012/08/16 17:35:01 matt Exp $ */ /* * Copyright (c) 1994-1998 Mark Brinicombe. @@ -42,7 +42,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: arm32_machdep.c,v 1.80 2012/08/14 20:42:33 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: arm32_machdep.c,v 1.81 2012/08/16 17:35:01 matt Exp $"); #include "opt_modular.h" #include "opt_md.h" @@ -70,7 +70,12 @@ __KERNEL_RCSID(0, "$NetBSD: arm32_machde #include <arm/arm32/katelib.h> #include <arm/arm32/machdep.h> + #include <machine/bootconfig.h> +#include <machine/pcb.h> + +//void (*cpu_reset_address)(void); /* Used by locore */ +//paddr_t cpu_reset_address_paddr; /* Used by locore */ struct vm_map *phys_map = NULL; @@ -251,11 +256,10 @@ cpu_startup(void) format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free)); printf("avail memory = %s\n", pbuf); - struct pcb * pcb = lwp_getpcb(&lwp0); - pcb->pcb_flags = 0; - pcb->pcb_un.un_32.pcb32_sp = - uvm_lwp_getuarea(&lwp0) + USPACE_SVC_STACK_TOP; - pcb->pcb_tf = (struct trapframe *)pcb->pcb_un.un_32.pcb32_sp - 1; + struct lwp * const l = &lwp0; + struct pcb * const pcb = lwp_getpcb(l); + pcb->pcb_sp = uvm_lwp_getuarea(l) + USPACE_SVC_STACK_TOP; + lwp_settrapframe(l, (struct trapframe *)pcb->pcb_sp - 1); } /* Index: src/sys/arch/arm/arm32/cpuswitch.S diff -u src/sys/arch/arm/arm32/cpuswitch.S:1.65 src/sys/arch/arm/arm32/cpuswitch.S:1.66 --- src/sys/arch/arm/arm32/cpuswitch.S:1.65 Tue Aug 14 20:42:33 2012 +++ src/sys/arch/arm/arm32/cpuswitch.S Thu Aug 16 17:35:01 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: cpuswitch.S,v 1.65 2012/08/14 20:42:33 matt Exp $ */ +/* $NetBSD: cpuswitch.S,v 1.66 2012/08/16 17:35:01 matt Exp $ */ /* * Copyright 2003 Wasabi Systems, Inc. @@ -89,7 +89,7 @@ #include <machine/asm.h> #include <machine/cpu.h> - RCSID("$NetBSD: cpuswitch.S,v 1.65 2012/08/14 20:42:33 matt Exp $") + RCSID("$NetBSD: cpuswitch.S,v 1.66 2012/08/16 17:35:01 matt Exp $") /* LINTSTUB: include <sys/param.h> */ @@ -295,7 +295,7 @@ ENTRY(cpu_switchto) */ ldr r2, [r5, #(P_RASLIST)] - ldr r1, [r7, #(PCB_TF)] /* r1 = trapframe (used below) */ + ldr r1, [r6, #(L_MD_TF)] /* r1 = trapframe (used below) */ teq r2, #0 /* p->p_nras == 0? */ bne .Lswitch_do_ras /* no, check for one */ @@ -316,7 +316,7 @@ ENTRY(cpu_switchto) mov r0, r5 /* first ras_lookup() arg */ bl _C_LABEL(ras_lookup) cmn r0, #1 /* -1 means "not in a RAS" */ - ldrne r1, [r7, #(PCB_TF)] + ldrne r1, [r6, #(L_MD_TF)] strne r0, [r1, #(TF_PC)] b .Lswitch_return @@ -403,7 +403,7 @@ ENTRY_NP(softint_switch) * it's existing state doesn't matter. We start the stack just * below the trapframe. */ - ldr sp, [r2, #(PCB_TF)] /* get new lwp's stack ptr */ + ldr sp, [r5, #(L_MD_TF)] /* get new lwp's stack ptr */ /* At this point we can allow IRQ's again. */ #ifndef __HAVE_UNNESTED_INTRS Index: src/sys/arch/arm/arm32/fault.c diff -u src/sys/arch/arm/arm32/fault.c:1.82 src/sys/arch/arm/arm32/fault.c:1.83 --- src/sys/arch/arm/arm32/fault.c:1.82 Tue Aug 14 20:42:33 2012 +++ src/sys/arch/arm/arm32/fault.c Thu Aug 16 17:35:01 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: fault.c,v 1.82 2012/08/14 20:42:33 matt Exp $ */ +/* $NetBSD: fault.c,v 1.83 2012/08/16 17:35:01 matt Exp $ */ /* * Copyright 2003 Wasabi Systems, Inc. @@ -81,7 +81,7 @@ #include "opt_kgdb.h" #include <sys/types.h> -__KERNEL_RCSID(0, "$NetBSD: fault.c,v 1.82 2012/08/14 20:42:33 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fault.c,v 1.83 2012/08/16 17:35:01 matt Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -98,9 +98,10 @@ __KERNEL_RCSID(0, "$NetBSD: fault.c,v 1. #include <arm/cpuconf.h> -#include <machine/frame.h> #include <arm/arm32/katelib.h> + #include <machine/intr.h> +#include <machine/pcb.h> #if defined(DDB) || defined(KGDB) #include <machine/db_machdep.h> #ifdef KGDB @@ -154,9 +155,6 @@ static const struct data_abort data_abor {NULL, "Permission Fault (P)"} }; -/* Determine if a fault came from user mode */ -#define TRAP_USERMODE(tf) ((tf->tf_spsr & PSR_MODE) == PSR_USR32_MODE) - /* Determine if 'x' is a permission fault */ #define IS_PERMISSION_FAULT(x) \ (((1 << ((x) & FAULT_TYPE_MASK)) & \ @@ -220,9 +218,9 @@ void data_abort_handler(trapframe_t *tf) { struct vm_map *map; - struct pcb *pcb; - struct lwp *l; - u_int user, far, fsr; + struct lwp * const l = curlwp; + struct cpu_info * const ci = curcpu(); + u_int far, fsr; vm_prot_t ftype; void *onfault; vaddr_t va; @@ -237,7 +235,7 @@ data_abort_handler(trapframe_t *tf) UVMHIST_CALLED(maphist); /* Update vmmeter statistics */ - curcpu()->ci_data.cpu_ntrap++; + ci->ci_data.cpu_ntrap++; /* Re-enable interrupts if they were enabled previously */ KASSERT(!TRAP_USERMODE(tf) || (tf->tf_spsr & IF32_bits) == 0); @@ -245,18 +243,17 @@ data_abort_handler(trapframe_t *tf) restore_interrupts(tf->tf_spsr & IF32_bits); /* Get the current lwp structure */ - KASSERT(curlwp != NULL); - l = curlwp; UVMHIST_LOG(maphist, " (pc=0x%x, l=0x%x, far=0x%x, fsr=0x%x)", tf->tf_pc, l, far, fsr); /* Data abort came from user mode? */ - if ((user = TRAP_USERMODE(tf)) != 0) + bool user = (TRAP_USERMODE(tf) != 0); + if (user) LWP_CACHE_CREDS(l, l->l_proc); /* Grab the current pcb */ - pcb = lwp_getpcb(l); + struct pcb * const pcb = lwp_getpcb(l); /* Invoke the appropriate handler, if necessary */ if (__predict_false(data_aborts[fsr & FAULT_TYPE_MASK].func != NULL)) { @@ -287,12 +284,12 @@ data_abort_handler(trapframe_t *tf) /* fusubailout is used by [fs]uswintr to avoid page faulting */ if (__predict_false(pcb->pcb_onfault == fusubailout)) { tf->tf_r0 = EFAULT; - tf->tf_pc = (register_t)(intptr_t) pcb->pcb_onfault; + tf->tf_pc = (intptr_t) pcb->pcb_onfault; return; } if (user) { - pcb->pcb_tf = tf; + lwp_settrapframe(l, tf); } /* @@ -359,7 +356,7 @@ data_abort_handler(trapframe_t *tf) * 2. pcb_onfault not set or * 3. pcb_onfault set and not LDRT/LDRBT/STRT/STRBT instruction. */ - if (user == 0 && (va >= VM_MIN_KERNEL_ADDRESS || + if (!user && (va >= VM_MIN_KERNEL_ADDRESS || (va < VM_MIN_ADDRESS && vector_page == ARM_VECTORS_LOW)) && __predict_true((pcb->pcb_onfault == NULL || (ReadWord(tf->tf_pc) & 0x05200000) != 0x04200000))) { @@ -379,7 +376,7 @@ data_abort_handler(trapframe_t *tf) * userland that actually runs in a priveledged mode * but uses USR mode permissions for its accesses. */ - user = 1; + user = true; goto do_trapsignal; } } else { @@ -524,9 +521,7 @@ out: static int dab_fatal(trapframe_t *tf, u_int fsr, u_int far, struct lwp *l, ksiginfo_t *ksi) { - const char *mode; - - mode = TRAP_USERMODE(tf) ? "user" : "kernel"; + const char * const mode = TRAP_USERMODE(tf) ? "user" : "kernel"; if (l != NULL) { printf("Fatal %s mode data abort: '%s'\n", mode, @@ -578,14 +573,12 @@ dab_fatal(trapframe_t *tf, u_int fsr, u_ static int dab_align(trapframe_t *tf, u_int fsr, u_int far, struct lwp *l, ksiginfo_t *ksi) { - struct pcb *pcb = lwp_getpcb(l); - /* Alignment faults are always fatal if they occur in kernel mode */ if (!TRAP_USERMODE(tf)) dab_fatal(tf, fsr, far, l, NULL); /* pcb_onfault *must* be NULL at this point */ - KDASSERT(pcb->pcb_onfault == NULL); + KDASSERT(((struct pcb *)lwp_getpcb(l))->pcb_onfault == NULL); /* See if the CPU state needs to be fixed up */ (void) data_abort_fixup(tf, fsr, far, l); @@ -597,7 +590,7 @@ dab_align(trapframe_t *tf, u_int fsr, u_ ksi->ksi_addr = (u_int32_t *)(intptr_t)far; ksi->ksi_trap = fsr; - pcb->pcb_tf = tf; + lwp_settrapframe(l, tf); return (1); } @@ -647,7 +640,7 @@ dab_buserr(trapframe_t *tf, u_int fsr, u * If the current trapframe is at the top of the kernel stack, * the fault _must_ have come from user mode. */ - if (tf != ((trapframe_t *)pcb->pcb_un.un_32.pcb32_sp) - 1) { + if (tf != ((trapframe_t *)pcb->pcb_sp) - 1) { /* * Kernel mode. We're either about to die a * spectacular death, or pcb_onfault will come @@ -704,7 +697,7 @@ dab_buserr(trapframe_t *tf, u_int fsr, u ksi->ksi_addr = (u_int32_t *)(intptr_t)far; ksi->ksi_trap = fsr; - pcb->pcb_tf = tf; + lwp_settrapframe(l, tf); return (1); } @@ -801,7 +794,7 @@ prefetch_abort_handler(trapframe_t *tf) ksi.ksi_signo = SIGILL; ksi.ksi_code = ILL_ILLOPC; ksi.ksi_addr = (u_int32_t *)(intptr_t) tf->tf_pc; - pcb->pcb_tf = tf; + lwp_settrapframe(l, tf); goto do_trapsignal; default: break; @@ -813,7 +806,7 @@ prefetch_abort_handler(trapframe_t *tf) /* Get fault address */ fault_pc = tf->tf_pc; - pcb->pcb_tf = tf; + lwp_settrapframe(l, tf); UVMHIST_LOG(maphist, " (pc=0x%x, l=0x%x, tf=0x%x)", fault_pc, l, tf, 0); Index: src/sys/arch/arm/arm32/genassym.cf diff -u src/sys/arch/arm/arm32/genassym.cf:1.48 src/sys/arch/arm/arm32/genassym.cf:1.49 --- src/sys/arch/arm/arm32/genassym.cf:1.48 Tue Aug 14 20:42:33 2012 +++ src/sys/arch/arm/arm32/genassym.cf Thu Aug 16 17:35:01 2012 @@ -1,4 +1,4 @@ -# $NetBSD: genassym.cf,v 1.48 2012/08/14 20:42:33 matt Exp $ +# $NetBSD: genassym.cf,v 1.49 2012/08/16 17:35:01 matt Exp $ # Copyright (c) 1982, 1990 The Regents of the University of California. # All rights reserved. @@ -50,6 +50,7 @@ include <arm/fiq.h> include <arm/arm32/pte.h> include <machine/pmap.h> include <machine/frame.h> +include <machine/pcb.h> include <machine/vmparam.h> include "opt_multiprocessor.h" @@ -109,10 +110,12 @@ define L_STAT offsetof(struct lwp, l_s define L_PROC offsetof(struct lwp, l_proc) define L_CTXSWTCH offsetof(struct lwp, l_ctxswtch) define L_PRIVATE offsetof(struct lwp, l_private) +define L_MD_FLAGS offsetof(struct lwp, l_md.md_flags) +define L_MD_TF offsetof(struct lwp, l_md.md_tf) +define MDLWP_NOALIGNFLT MDLWP_NOALIGNFLT + define P_RASLIST offsetof(struct proc, p_raslist) -define PCB_TF offsetof(struct pcb, pcb_tf) -define PCB_FLAGS offsetof(struct pcb, pcb_flags) define PCB_R8 offsetof(struct pcb, pcb_un.un_32.pcb32_r8) define PCB_R9 offsetof(struct pcb, pcb_un.un_32.pcb32_r9) define PCB_R10 offsetof(struct pcb, pcb_un.un_32.pcb32_r10) @@ -123,7 +126,6 @@ define PCB_LR offsetof(struct pcb, pcb define PCB_PC offsetof(struct pcb, pcb_un.un_32.pcb32_pc) define PCB_USER_PID_RW offsetof(struct pcb, pcb_un.un_32.pcb32_user_pid_rw) define PCB_ONFAULT offsetof(struct pcb, pcb_onfault) -define PCB_NOALIGNFLT PCB_NOALIGNFLT define PCB_SIZE sizeof(struct pcb) Index: src/sys/arch/arm/arm32/vm_machdep.c diff -u src/sys/arch/arm/arm32/vm_machdep.c:1.58 src/sys/arch/arm/arm32/vm_machdep.c:1.59 --- src/sys/arch/arm/arm32/vm_machdep.c:1.58 Sun Aug 12 05:05:47 2012 +++ src/sys/arch/arm/arm32/vm_machdep.c Thu Aug 16 17:35:01 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.58 2012/08/12 05:05:47 matt Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.59 2012/08/16 17:35:01 matt Exp $ */ /* * Copyright (c) 1994-1998 Mark Brinicombe. @@ -44,7 +44,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.58 2012/08/12 05:05:47 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.59 2012/08/16 17:35:01 matt Exp $"); #include "opt_armfpe.h" #include "opt_pmap_debug.h" @@ -56,6 +56,7 @@ __KERNEL_RCSID(0, "$NetBSD: vm_machdep.c #include <sys/proc.h> #include <sys/malloc.h> #include <sys/vnode.h> +#include <sys/cpu.h> #include <sys/buf.h> #include <sys/pmc.h> #include <sys/exec.h> @@ -63,7 +64,7 @@ __KERNEL_RCSID(0, "$NetBSD: vm_machdep.c #include <uvm/uvm_extern.h> -#include <machine/cpu.h> +#include <machine/pcb.h> #include <machine/pmap.h> #include <machine/reg.h> #include <machine/vmparam.h> @@ -118,7 +119,6 @@ cpu_lwp_fork(struct lwp *l1, struct lwp void (*func)(void *), void *arg) { struct pcb *pcb1, *pcb2; - struct trapframe *tf; struct switchframe *sf; vaddr_t uv; @@ -147,7 +147,7 @@ cpu_lwp_fork(struct lwp *l1, struct lwp * Note: this stack is not in use if we are forking from p1 */ uv = uvm_lwp_getuarea(l2); - pcb2->pcb_un.un_32.pcb32_sp = uv + USPACE_SVC_STACK_TOP; + pcb2->pcb_sp = uv + USPACE_SVC_STACK_TOP; #ifdef STACKCHECKS /* Fill the kernel stack with a known pattern */ @@ -170,9 +170,9 @@ cpu_lwp_fork(struct lwp *l1, struct lwp arm_fpe_copycontext(FP_CONTEXT(l1), FP_CONTEXT(l2)); #endif /* ARMFPE */ - tf = (struct trapframe *)pcb2->pcb_un.un_32.pcb32_sp - 1; - pcb2->pcb_tf = tf; - *tf = *pcb1->pcb_tf; + struct trapframe *tf = (struct trapframe *)pcb2->pcb_sp - 1; + lwp_settrapframe(l2, tf); + *tf = *lwp_trapframe(l1); /* * If specified, give the child a different stack (make sure @@ -186,7 +186,7 @@ cpu_lwp_fork(struct lwp *l1, struct lwp sf->sf_r5 = (u_int)arg; sf->sf_sp = (u_int)tf; sf->sf_pc = (u_int)lwp_trampoline; - pcb2->pcb_un.un_32.pcb32_sp = (u_int)sf; + pcb2->pcb_sp = (u_int)sf; } /* Index: src/sys/arch/arm/include/cpu.h diff -u src/sys/arch/arm/include/cpu.h:1.67 src/sys/arch/arm/include/cpu.h:1.68 --- src/sys/arch/arm/include/cpu.h:1.67 Tue Aug 14 20:42:33 2012 +++ src/sys/arch/arm/include/cpu.h Thu Aug 16 17:35:01 2012 @@ -77,7 +77,6 @@ #ifndef _LOCORE #include <machine/frame.h> -#include <machine/pcb.h> #endif /* !_LOCORE */ #include <arm/armreg.h> @@ -175,9 +174,9 @@ extern int cpu_do_powersave; * LWP_PC: Find out the program counter for the given lwp. */ #ifdef __PROG32 -#define LWP_PC(l) (((struct pcb *)lwp_getpcb(l))->pcb_tf->tf_pc) +#define LWP_PC(l) (lwp_trapframe(l)->tf_pc) #else -#define LWP_PC(l) (((struct pcb *)lwp_getpcb(l))->pcb_tf->tf_r15 & R15_PC) +#define LWP_PC(l) (lwp_trapframe(l)->tf_r15 & R15_PC) #endif /* Index: src/sys/arch/arm/include/frame.h diff -u src/sys/arch/arm/include/frame.h:1.16 src/sys/arch/arm/include/frame.h:1.17 --- src/sys/arch/arm/include/frame.h:1.16 Thu Aug 16 16:41:54 2012 +++ src/sys/arch/arm/include/frame.h Thu Aug 16 17:35:01 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: frame.h,v 1.16 2012/08/16 16:41:54 matt Exp $ */ +/* $NetBSD: frame.h,v 1.17 2012/08/16 17:35:01 matt Exp $ */ /* * Copyright (c) 1994-1997 Mark Brinicombe. @@ -79,6 +79,12 @@ typedef struct trapframe { #define tf_r14 tf_usr_lr #define tf_r15 tf_pc +#ifdef __PROG32 +#define TRAP_USERMODE(tf) (((tf)->tf_spsr & PSR_MODE) == PSR_USR32_MODE) +#elif defined(__PROG26) +#define TRAP_USERMODE(tf) (((tf)->tf_r15 & R15_MODE) == R15_MODE_USR) +#endif + /* * Signal frame. Pushed onto user stack before calling sigcode. */ @@ -99,7 +105,8 @@ __BEGIN_DECLS void sendsig_sigcontext(const ksiginfo_t *, const sigset_t *); void *getframe(struct lwp *, int, int *); __END_DECLS -#define lwp_trapframe(l) (((struct pcb *)lwp_getpcb(l))->pcb_tf) +#define lwp_trapframe(l) ((l)->l_md.md_tf) +#define lwp_settrapframe(l, tf) ((l)->l_md.md_tf = (tf)) #endif #endif /* _LOCORE */ Index: src/sys/arch/arm/include/pcb.h diff -u src/sys/arch/arm/include/pcb.h:1.23 src/sys/arch/arm/include/pcb.h:1.24 --- src/sys/arch/arm/include/pcb.h:1.23 Tue Aug 14 20:42:33 2012 +++ src/sys/arch/arm/include/pcb.h Thu Aug 16 17:35:01 2012 @@ -42,8 +42,6 @@ #include <arm/arm32/pte.h> #include <arm/reg.h> -struct trapframe; - struct pcb_arm32 { /* * WARNING! @@ -72,26 +70,28 @@ struct pcb_arm32 { #define pcb_dacr pcb_un.un_32.pcb32_dacr #define pcb_cstate pcb_un.un_32.pcb32_cstate #define pcb_user_pid_rw pcb_un.un_32.pcb32_user_pid_rw +#ifdef __PROG32 +#define pcb_sp pcb_un.un_32.pcb32_sp +#endif struct pcb_arm26 { struct switchframe *pcb26_sf; }; #define pcb_sf pcb_un.un_26.pcb26_sf +#ifdef __PROG26 +#define pcb_sp pcb_sf.sf_r13 +#endif /* * WARNING! * See warning for struct pcb_arm32, above, before changing struct pcb! */ struct pcb { - u_int pcb_flags; -#define PCB_OWNFPU 0x00000001 -#define PCB_NOALIGNFLT 0x00000002 /* For EXEC_AOUT */ - struct trapframe *pcb_tf; - void * pcb_onfault; /* On fault handler */ union { struct pcb_arm32 un_32; struct pcb_arm26 un_26; } pcb_un; + void * pcb_onfault; /* On fault handler */ struct fpe_sp_state pcb_fpstate; /* FPA Floating Point state */ struct vfpreg pcb_vfp; /* VFP registers */ }; Index: src/sys/arch/arm/include/proc.h diff -u src/sys/arch/arm/include/proc.h:1.11 src/sys/arch/arm/include/proc.h:1.12 --- src/sys/arch/arm/include/proc.h:1.11 Sun Aug 12 05:05:47 2012 +++ src/sys/arch/arm/include/proc.h Thu Aug 16 17:35:01 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: proc.h,v 1.11 2012/08/12 05:05:47 matt Exp $ */ +/* $NetBSD: proc.h,v 1.12 2012/08/16 17:35:01 matt Exp $ */ /* * Copyright (c) 1994 Mark Brinicombe. @@ -43,11 +43,13 @@ struct trapframe; struct lwp; struct mdlwp { + struct trapframe *md_tf; int md_flags; }; /* Flags setttings for md_flags */ -#define MDLWP_VFPUSED 0x00000001 /* Process used the VFP */ +#define MDLWP_VFPUSED 0x00000001 /* Process used the VFP */ +#define MDLWP_NOALIGNFLT 0x00000002 /* For EXEC_AOUT */ struct mdproc { Index: src/sys/arch/arm/include/arm32/frame.h diff -u src/sys/arch/arm/include/arm32/frame.h:1.30 src/sys/arch/arm/include/arm32/frame.h:1.31 --- src/sys/arch/arm/include/arm32/frame.h:1.30 Thu Aug 2 15:56:07 2012 +++ src/sys/arch/arm/include/arm32/frame.h Thu Aug 16 17:35:01 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: frame.h,v 1.30 2012/08/02 15:56:07 skrll Exp $ */ +/* $NetBSD: frame.h,v 1.31 2012/08/16 17:35:01 matt Exp $ */ /* * Copyright (c) 1994-1997 Mark Brinicombe. @@ -143,9 +143,9 @@ void validate_trapframe(trapframe_t *, i teq r0, #(PSR_USR32_MODE) ;\ GET_CURCPU(r4) /* r4 = cpuinfo */ ;\ bne 1f /* Not USR mode skip AFLT */ ;\ - ldr r1, [r4, #CI_CURPCB] /* get curpcb from cpu_info */ ;\ - ldr r1, [r1, #PCB_FLAGS] /* Fetch curpcb->pcb_flags */ ;\ - tst r1, #PCB_NOALIGNFLT ;\ + ldr r1, [r1, #CI_CURLWP] /* get curlwp from cpu_info */ ;\ + ldr r1, [r1, #L_MD_FLAGS] /* Fetch l_md.md_flags */ ;\ + tst r1, #MDLWP_NOALIGNFLT ;\ beq 1f /* AFLTs already enabled */ ;\ ldr r2, .Laflt_cpufuncs ;\ ldr r1, [r4, #CI_CTRL] /* Fetch control register */ ;\ @@ -172,9 +172,9 @@ void validate_trapframe(trapframe_t *, i 1: ldr r1, [r4, #CI_ASTPENDING] /* Pending AST? */ ;\ teq r1, #0x00000000 ;\ bne 2f /* Yup. Go deal with it */ ;\ - ldr r1, [r4, #CI_CURPCB] /* Get current PCB */ ;\ - ldr r0, [r1, #PCB_FLAGS] /* Fetch curpcb->pcb_flags */ ;\ - tst r0, #PCB_NOALIGNFLT ;\ + ldr r1, [r4, #CI_CURLWP] /* get curlwp from cpu_info */ ;\ + ldr r0, [r1, #L_MD_FLAGS] /* get md_flags from lwp */ ;\ + tst r0, #MDLWP_NOALIGNFLT ;\ beq 3f /* Keep AFLTs enabled */ ;\ ldr r1, [r4, #CI_CTRL] /* Fetch control register */ ;\ ldr r2, .Laflt_cpufuncs ;\ @@ -224,6 +224,7 @@ void validate_trapframe(trapframe_t *, i 2: #endif /* EXEC_AOUT */ +#ifndef _ARM_ARCH_6 #ifdef ARM_LOCK_CAS_DEBUG #define LOCK_CAS_DEBUG_LOCALS \ .L_lock_cas_restart: ;\ @@ -273,6 +274,11 @@ LOCK_CAS_DEBUG_LOCALS LOCK_CAS_DEBUG_COUNT_RESTART ;\ 99: +#else +#define LOCK_CAS_CHECK /* nothing */ +#define LOCK_CAS_CHECK_LOCALS /* nothing */ +#endif + /* * ASM macros for pushing and pulling trapframes from the stack *