Remove p_nras from struct proc - use LIST_EMPTY(&p->p_raslist) instead.

Remove p_raslock and rename p_lwplock p_lock (one lock is enough).
Simplify window test when adding a ras and correct test on VM_MAXUSER_ADDRESS.
Avoid unpredictable branch in i386 locore.S
(pad fields left in struct proc to avoid kernel bump)
This commit is contained in:
dsl 2003-11-04 10:33:15 +00:00
parent 1431f7820b
commit 2ffbd2ab99
37 changed files with 129 additions and 136 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: cpuswitch.c,v 1.3 2003/07/14 22:48:20 lukem Exp $ */ /* $NetBSD: cpuswitch.c,v 1.4 2003/11/04 10:33:15 dsl Exp $ */
/* /*
* Copyright (c) 2000 Ben Harris. * Copyright (c) 2000 Ben Harris.
@ -38,7 +38,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: cpuswitch.c,v 1.3 2003/07/14 22:48:20 lukem Exp $"); __KERNEL_RCSID(0, "$NetBSD: cpuswitch.c,v 1.4 2003/11/04 10:33:15 dsl Exp $");
#include "opt_lockdebug.h" #include "opt_lockdebug.h"
@ -122,7 +122,7 @@ cpu_switch(struct lwp *l1, struct lwp *newl)
/* Check for Restartable Atomic Sequences. */ /* Check for Restartable Atomic Sequences. */
p2 = l2->l_proc; p2 = l2->l_proc;
if (p2->p_nras != 0) { if (!LIST_EMPTY(&p2->p_raslist) {
struct trapframe *tf = l2->l_addr->u_pcb.pcb_tf; struct trapframe *tf = l2->l_addr->u_pcb.pcb_tf;
caddr_t pc; caddr_t pc;

View File

@ -1,4 +1,4 @@
# $NetBSD: genassym.cf,v 1.9 2003/10/07 17:04:18 skd Exp $ # $NetBSD: genassym.cf,v 1.10 2003/11/04 10:33:16 dsl Exp $
# #
# Copyright (c) 1994, 1995 Gordon W. Ross # Copyright (c) 1994, 1995 Gordon W. Ross
@ -124,7 +124,7 @@ define L_MD_PCBPADDR offsetof(struct lwp, l_md.md_pcbpaddr)
define L_MD_TF offsetof(struct lwp, l_md.md_tf) define L_MD_TF offsetof(struct lwp, l_md.md_tf)
define P_VMSPACE offsetof(struct proc, p_vmspace) define P_VMSPACE offsetof(struct proc, p_vmspace)
define P_NRAS offsetof(struct proc, p_nras) define P_RASLIST offsetof(struct proc, p_raslist)
define P_MD_SYSCALL offsetof(struct proc, p_md.md_syscall) define P_MD_SYSCALL offsetof(struct proc, p_md.md_syscall)
define P_MD_ASTPENDING offsetof(struct proc, p_md.md_astpending) define P_MD_ASTPENDING offsetof(struct proc, p_md.md_astpending)
define PH_LINK offsetof(struct prochd, ph_link) define PH_LINK offsetof(struct prochd, ph_link)

View File

@ -1,4 +1,4 @@
/* $NetBSD: locore.s,v 1.104 2003/10/07 17:04:18 skd Exp $ */ /* $NetBSD: locore.s,v 1.105 2003/11/04 10:33:16 dsl Exp $ */
/*- /*-
* Copyright (c) 1999, 2000 The NetBSD Foundation, Inc. * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@ -74,7 +74,7 @@
#include <machine/asm.h> #include <machine/asm.h>
__KERNEL_RCSID(0, "$NetBSD: locore.s,v 1.104 2003/10/07 17:04:18 skd Exp $"); __KERNEL_RCSID(0, "$NetBSD: locore.s,v 1.105 2003/11/04 10:33:16 dsl Exp $");
#include "assym.h" #include "assym.h"
@ -910,8 +910,8 @@ switch_resume:
* Check for restartable atomic sequences (RAS). * Check for restartable atomic sequences (RAS).
*/ */
ldq a0, L_PROC(s2) /* first ras_lookup() arg */ ldq a0, L_PROC(s2) /* first ras_lookup() arg */
ldl t0, P_NRAS(a0) /* p->p_nras == 0? */ ldq t0, P_RASLIST(a0) /* any RAS entries? */
beq t0, 1f /* yes, skip */ beq t0, 1f /* no, skip */
ldq s1, L_MD_TF(s2) /* s1 = l->l_md.md_tf */ ldq s1, L_MD_TF(s2) /* s1 = l->l_md.md_tf */
ldq a1, (FRAME_PC*8)(s1) /* second ras_lookup() arg */ ldq a1, (FRAME_PC*8)(s1) /* second ras_lookup() arg */
CALL(ras_lookup) /* ras_lookup(p, PC) */ CALL(ras_lookup) /* ras_lookup(p, PC) */

View File

@ -1,4 +1,4 @@
# $NetBSD: genassym.cf,v 1.2 2003/05/04 23:46:41 fvdl Exp $ # $NetBSD: genassym.cf,v 1.3 2003/11/04 10:33:15 dsl Exp $
# #
# Copyright (c) 1998 The NetBSD Foundation, Inc. # Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -149,7 +149,7 @@ define PAGE_SIZE PAGE_SIZE
define MDP_IRET MDP_IRET define MDP_IRET MDP_IRET
define P_FLAG offsetof(struct proc, p_flag) define P_FLAG offsetof(struct proc, p_flag)
define P_NRAS offsetof(struct proc, p_nras) define P_RASLIST offsetof(struct proc, p_raslist)
define P_MD_SYSCALL offsetof(struct proc, p_md.md_syscall) define P_MD_SYSCALL offsetof(struct proc, p_md.md_syscall)
define P_MD_FLAGS offsetof(struct proc, p_md.md_flags) define P_MD_FLAGS offsetof(struct proc, p_md.md_flags)
define P_MD_ASTPENDING offsetof(struct proc, p_md.md_astpending) define P_MD_ASTPENDING offsetof(struct proc, p_md.md_astpending)

View File

@ -1,4 +1,4 @@
/* $NetBSD: locore.S,v 1.6 2003/08/20 21:48:47 fvdl Exp $ */ /* $NetBSD: locore.S,v 1.7 2003/11/04 10:33:15 dsl Exp $ */
/* /*
* Copyright-o-rama! * Copyright-o-rama!
@ -1024,7 +1024,7 @@ switch_restored:
*/ */
movq CPUVAR(CURLWP),%r12 movq CPUVAR(CURLWP),%r12
movq L_PROC(%r12),%rdi movq L_PROC(%r12),%rdi
cmpl $0,P_NRAS(%rdi) cmpq $0,P_RASLIST(%rdi)
je 1f je 1f
movq L_MD_REGS(%r12),%rbx movq L_MD_REGS(%r12),%rbx
movq TF_RIP(%rbx),%rsi movq TF_RIP(%rbx),%rsi

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.13 2003/10/21 00:46:09 fvdl Exp $ */ /* $NetBSD: trap.c,v 1.14 2003/11/04 10:33:15 dsl Exp $ */
/*- /*-
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@ -75,7 +75,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.13 2003/10/21 00:46:09 fvdl Exp $"); __KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.14 2003/11/04 10:33:15 dsl Exp $");
#include "opt_ddb.h" #include "opt_ddb.h"
#include "opt_kgdb.h" #include "opt_kgdb.h"
@ -563,7 +563,7 @@ faultcommon:
#ifdef MATH_EMULATE #ifdef MATH_EMULATE
trace: trace:
#endif #endif
if ((p->p_nras == 0) || if (LIST_EMPTY((&p->p_raslist) ||
(ras_lookup(p, (caddr_t)frame->tf_rip) == (caddr_t)-1)) { (ras_lookup(p, (caddr_t)frame->tf_rip) == (caddr_t)-1)) {
KSI_INIT_TRAP(&ksi); KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = SIGTRAP; ksi.ksi_signo = SIGTRAP;

View File

@ -1,4 +1,4 @@
# $NetBSD: genassym.cf,v 1.19 2003/09/22 14:27:00 cl Exp $ # $NetBSD: genassym.cf,v 1.20 2003/11/04 10:33:16 dsl Exp $
# #
# Copyright (c) 1982, 1990, 1993 # Copyright (c) 1982, 1990, 1993
@ -111,7 +111,7 @@ define L_PROC offsetof(struct lwp, l_proc)
define L_MD_REGS offsetof(struct lwp, l_md.md_regs) define L_MD_REGS offsetof(struct lwp, l_md.md_regs)
define L_MD_FLAGS offsetof(struct lwp, l_md.md_flags) define L_MD_FLAGS offsetof(struct lwp, l_md.md_flags)
define P_FLAG offsetof(struct proc, p_flag) define P_FLAG offsetof(struct proc, p_flag)
define P_NRAS offsetof(struct proc, p_nras) define P_RASLIST offsetof(struct proc, p_raslist)
define P_VMSPACE offsetof(struct proc, p_vmspace) define P_VMSPACE offsetof(struct proc, p_vmspace)
# lwp fields and values # lwp fields and values

View File

@ -1,4 +1,4 @@
/* $NetBSD: cpuswitch.S,v 1.38 2003/10/23 08:59:10 scw Exp $ */ /* $NetBSD: cpuswitch.S,v 1.39 2003/11/04 10:33:16 dsl Exp $ */
/* /*
* Copyright 2003 Wasabi Systems, Inc. * Copyright 2003 Wasabi Systems, Inc.
@ -746,7 +746,7 @@ ENTRY(cpu_switch)
* Check for restartable atomic sequences (RAS). * Check for restartable atomic sequences (RAS).
*/ */
ldr r2, [r5, #(P_NRAS)] ldr r2, [r5, #(P_RASLIST)]
ldr r1, [r7, #(PCB_TF)] /* r1 = trapframe (used below) */ ldr r1, [r7, #(PCB_TF)] /* r1 = trapframe (used below) */
teq r2, #0 /* p->p_nras == 0? */ teq r2, #0 /* p->p_nras == 0? */
bne .Lswitch_do_ras /* no, check for one */ bne .Lswitch_do_ras /* no, check for one */

View File

@ -1,4 +1,4 @@
# $NetBSD: genassym.cf,v 1.26 2003/10/25 19:44:42 scw Exp $ # $NetBSD: genassym.cf,v 1.27 2003/11/04 10:33:16 dsl Exp $
# Copyright (c) 1982, 1990 The Regents of the University of California. # Copyright (c) 1982, 1990 The Regents of the University of California.
# All rights reserved. # All rights reserved.
@ -88,7 +88,7 @@ define L_PRIORITY offsetof(struct lwp, l_priority)
define L_WCHAN offsetof(struct lwp, l_wchan) define L_WCHAN offsetof(struct lwp, l_wchan)
define L_STAT offsetof(struct lwp, l_stat) define L_STAT offsetof(struct lwp, l_stat)
define L_PROC offsetof(struct lwp, l_proc) define L_PROC offsetof(struct lwp, l_proc)
define P_NRAS offsetof(struct proc, p_nras) define P_RASLIST offsetof(struct proc, p_raslist)
# Process status constants # Process status constants
define LSONPROC LSONPROC define LSONPROC LSONPROC

View File

@ -1,4 +1,4 @@
# $NetBSD: genassym.cf,v 1.21 2003/09/22 14:27:03 cl Exp $ # $NetBSD: genassym.cf,v 1.22 2003/11/04 10:33:16 dsl Exp $
#- #-
# Copyright (c) 1997 The NetBSD Foundation, Inc. # Copyright (c) 1997 The NetBSD Foundation, Inc.
@ -94,7 +94,7 @@ define L_PROC offsetof(struct lwp, l_proc)
define L_MD_REGS offsetof(struct lwp, l_md.md_regs) define L_MD_REGS offsetof(struct lwp, l_md.md_regs)
define L_MD_FLAGS offsetof(struct lwp, l_md.md_flags) define L_MD_FLAGS offsetof(struct lwp, l_md.md_flags)
define P_FLAG offsetof(struct proc, p_flag) define P_FLAG offsetof(struct proc, p_flag)
define P_NRAS offsetof(struct proc, p_nras) define P_RASLIST offsetof(struct proc, p_raslist)
define P_VMSPACE offsetof(struct proc, p_vmspace) define P_VMSPACE offsetof(struct proc, p_vmspace)
# lwp fields and values # lwp fields and values

View File

@ -1,4 +1,4 @@
# $NetBSD: genassym.cf,v 1.5 2003/09/22 14:27:04 cl Exp $ # $NetBSD: genassym.cf,v 1.6 2003/11/04 10:33:16 dsl Exp $
# #
# Copyright (c) 1982, 1990, 1993 # Copyright (c) 1982, 1990, 1993
@ -111,7 +111,7 @@ define L_PROC offsetof(struct lwp, l_proc)
define L_MD_REGS offsetof(struct lwp, l_md.md_regs) define L_MD_REGS offsetof(struct lwp, l_md.md_regs)
define L_MD_FLAGS offsetof(struct lwp, l_md.md_flags) define L_MD_FLAGS offsetof(struct lwp, l_md.md_flags)
define P_FLAG offsetof(struct proc, p_flag) define P_FLAG offsetof(struct proc, p_flag)
define P_NRAS offsetof(struct proc, p_nras) define P_RASLIST offsetof(struct proc, p_raslist)
define P_VMSPACE offsetof(struct proc, p_vmspace) define P_VMSPACE offsetof(struct proc, p_vmspace)
# lwp fields and values # lwp fields and values

View File

@ -1,4 +1,4 @@
# $NetBSD: genassym.cf,v 1.30 2003/09/22 14:26:57 cl Exp $ # $NetBSD: genassym.cf,v 1.31 2003/11/04 10:33:15 dsl Exp $
# #
# Copyright (c) 1982, 1990, 1993 # Copyright (c) 1982, 1990, 1993
@ -161,7 +161,7 @@ define L_PROC offsetof(struct lwp, l_proc)
define L_MD_REGS offsetof(struct lwp, l_md.md_regs) define L_MD_REGS offsetof(struct lwp, l_md.md_regs)
define L_MD_FLAGS offsetof(struct lwp, l_md.md_flags) define L_MD_FLAGS offsetof(struct lwp, l_md.md_flags)
define P_FLAG offsetof(struct proc, p_flag) define P_FLAG offsetof(struct proc, p_flag)
define P_NRAS offsetof(struct proc, p_nras) define P_RASLIST offsetof(struct proc, p_raslist)
define P_VMSPACE offsetof(struct proc, p_vmspace) define P_VMSPACE offsetof(struct proc, p_vmspace)
# lwp fields and values # lwp fields and values

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.106 2003/11/02 16:49:38 cl Exp $ */ /* $NetBSD: trap.c,v 1.107 2003/11/04 10:33:15 dsl Exp $ */
/* /*
* Copyright (c) 1982, 1986, 1990, 1993 * Copyright (c) 1982, 1986, 1990, 1993
@ -77,7 +77,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.106 2003/11/02 16:49:38 cl Exp $"); __KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.107 2003/11/04 10:33:15 dsl Exp $");
#include "opt_ddb.h" #include "opt_ddb.h"
#include "opt_execfmt.h" #include "opt_execfmt.h"
@ -558,7 +558,7 @@ trap(type, code, v, frame)
/* /*
* Don't go stepping into a RAS. * Don't go stepping into a RAS.
*/ */
if ((p->p_nras != 0) && if (!LIST_EMPTY(&p->p_raslist) &&
(ras_lookup(p, (caddr_t)frame.f_pc) != (caddr_t)-1)) (ras_lookup(p, (caddr_t)frame.f_pc) != (caddr_t)-1))
goto out; goto out;
frame.f_sr &= ~PSL_T; frame.f_sr &= ~PSL_T;

View File

@ -1,4 +1,4 @@
# $NetBSD: genassym.cf,v 1.38 2003/07/03 21:25:45 christos Exp $ # $NetBSD: genassym.cf,v 1.39 2003/11/04 10:33:15 dsl Exp $
# #
# Copyright (c) 1998 The NetBSD Foundation, Inc. # Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -167,7 +167,7 @@ define L_MD_TSS_SEL offsetof(struct lwp, l_md.md_tss_sel)
define L_MD_REGS offsetof(struct lwp, l_md.md_regs) define L_MD_REGS offsetof(struct lwp, l_md.md_regs)
define L_CPU offsetof(struct lwp, l_cpu) define L_CPU offsetof(struct lwp, l_cpu)
define P_FLAG offsetof(struct proc, p_flag) define P_FLAG offsetof(struct proc, p_flag)
define P_NRAS offsetof(struct proc, p_nras) define P_RASLIST offsetof(struct proc, p_raslist)
define P_MD_SYSCALL offsetof(struct proc, p_md.md_syscall) define P_MD_SYSCALL offsetof(struct proc, p_md.md_syscall)
define P_MD_ASTPENDING offsetof(struct proc, p_md.md_astpending) define P_MD_ASTPENDING offsetof(struct proc, p_md.md_astpending)

View File

@ -1,4 +1,4 @@
/* $NetBSD: locore.S,v 1.19 2003/09/12 16:51:04 christos Exp $ */ /* $NetBSD: locore.S,v 1.20 2003/11/04 10:33:15 dsl Exp $ */
/*- /*-
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@ -1951,17 +1951,8 @@ switch_restored:
*/ */
movl CPUVAR(CURLWP),%edi movl CPUVAR(CURLWP),%edi
movl L_PROC(%edi),%esi movl L_PROC(%edi),%esi
cmpl $0,P_NRAS(%esi) cmpl $0,P_RASLIST(%esi)
je 1f jne 2f
movl L_MD_REGS(%edi),%ebx
movl TF_EIP(%ebx),%eax
pushl %eax
pushl %esi
call _C_LABEL(ras_lookup)
addl $8,%esp
cmpl $-1,%eax
je 1f
movl %eax,TF_EIP(%ebx)
1: 1:
movl $1,%ebx movl $1,%ebx
@ -1981,6 +1972,18 @@ switch_return:
popl %ebx popl %ebx
ret ret
2: # check RAS list
movl L_MD_REGS(%edi),%ebx
movl TF_EIP(%ebx),%eax
pushl %eax
pushl %esi
call _C_LABEL(ras_lookup)
addl $8,%esp
cmpl $-1,%eax
je 1b
movl %eax,TF_EIP(%ebx)
jmp 1b
/* /*
* void cpu_switchto(struct lwp *current, struct lwp *next) * void cpu_switchto(struct lwp *current, struct lwp *next)
* Switch to the specified next LWP. * Switch to the specified next LWP.

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.193 2003/10/27 14:11:47 junyoung Exp $ */ /* $NetBSD: trap.c,v 1.194 2003/11/04 10:33:15 dsl Exp $ */
/*- /*-
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@ -75,7 +75,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.193 2003/10/27 14:11:47 junyoung Exp $"); __KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.194 2003/11/04 10:33:15 dsl Exp $");
#include "opt_ddb.h" #include "opt_ddb.h"
#include "opt_kgdb.h" #include "opt_kgdb.h"
@ -672,7 +672,7 @@ copyfault:
/* /*
* Don't go single-stepping into a RAS. * Don't go single-stepping into a RAS.
*/ */
if ((p->p_nras == 0) || if (LIST_EMPTY(&p->p_raslist) ||
(ras_lookup(p, (caddr_t)frame->tf_eip) == (caddr_t)-1)) { (ras_lookup(p, (caddr_t)frame->tf_eip) == (caddr_t)-1)) {
KSI_INIT_TRAP(&ksi); KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = SIGTRAP; ksi.ksi_signo = SIGTRAP;

View File

@ -1,4 +1,4 @@
# $NetBSD: genassym.cf,v 1.9 2003/09/22 14:27:06 cl Exp $ # $NetBSD: genassym.cf,v 1.10 2003/11/04 10:33:16 dsl Exp $
# #
# Copyright (c) 1982, 1990, 1993 # Copyright (c) 1982, 1990, 1993
@ -111,7 +111,7 @@ define L_PROC offsetof(struct lwp, l_proc)
define L_MD_REGS offsetof(struct lwp, l_md.md_regs) define L_MD_REGS offsetof(struct lwp, l_md.md_regs)
define L_MD_FLAGS offsetof(struct lwp, l_md.md_flags) define L_MD_FLAGS offsetof(struct lwp, l_md.md_flags)
define P_FLAG offsetof(struct proc, p_flag) define P_FLAG offsetof(struct proc, p_flag)
define P_NRAS offsetof(struct proc, p_nras) define P_RASLIST offsetof(struct proc, p_raslist)
define P_VMSPACE offsetof(struct proc, p_vmspace) define P_VMSPACE offsetof(struct proc, p_vmspace)
# lwp fields and values # lwp fields and values

View File

@ -1,4 +1,4 @@
/* $NetBSD: switch_subr.s,v 1.7 2003/10/30 05:12:28 mycroft Exp $ */ /* $NetBSD: switch_subr.s,v 1.8 2003/11/04 10:33:16 dsl Exp $ */
/* /*
* Copyright (c) 1980, 1990, 1993 * Copyright (c) 1980, 1990, 1993
@ -392,7 +392,7 @@ Lsame_mmuctx:
*/ */
movl _C_LABEL(curlwp),%a0 movl _C_LABEL(curlwp),%a0
movl %a0@(L_PROC),%a2 movl %a0@(L_PROC),%a2
tstl %a2@(P_NRAS) tstl %a2@(P_RASLIST)
jeq 1f jeq 1f
movl %a0@(L_MD_REGS),%a1 movl %a0@(L_MD_REGS),%a1
movl %a1@(TF_PC),%sp@- movl %a1@(TF_PC),%sp@-

View File

@ -1,4 +1,4 @@
# $NetBSD: genassym.cf,v 1.26 2003/09/22 14:27:07 cl Exp $ # $NetBSD: genassym.cf,v 1.27 2003/11/04 10:33:16 dsl Exp $
# #
# Copyright (c) 1990 The Regents of the University of California. # Copyright (c) 1990 The Regents of the University of California.
@ -101,7 +101,7 @@ define L_PROC offsetof(struct lwp, l_proc)
define L_MD_REGS offsetof(struct lwp, l_md.md_regs) define L_MD_REGS offsetof(struct lwp, l_md.md_regs)
define L_MD_FLAGS offsetof(struct lwp, l_md.md_flags) define L_MD_FLAGS offsetof(struct lwp, l_md.md_flags)
define P_FLAG offsetof(struct proc, p_flag) define P_FLAG offsetof(struct proc, p_flag)
define P_NRAS offsetof(struct proc, p_nras) define P_RASLIST offsetof(struct proc, p_raslist)
define P_VMSPACE offsetof(struct proc, p_vmspace) define P_VMSPACE offsetof(struct proc, p_vmspace)
# lwp fields and values # lwp fields and values

View File

@ -1,4 +1,4 @@
# $NetBSD: genassym.cf,v 1.35 2003/09/29 14:34:44 tsutsui Exp $ # $NetBSD: genassym.cf,v 1.36 2003/11/04 10:33:15 dsl Exp $
# #
# Copyright (c) 1997 # Copyright (c) 1997
# Jonathan Stone. All rights reserved. # Jonathan Stone. All rights reserved.
@ -72,7 +72,7 @@ define L_MD_REGS offsetof(struct lwp, l_md.md_regs)
define L_MD_UPTE_0 offsetof(struct lwp, l_md.md_upte[0]) define L_MD_UPTE_0 offsetof(struct lwp, l_md.md_upte[0])
define L_MD_UPTE_1 offsetof(struct lwp, l_md.md_upte[1]) define L_MD_UPTE_1 offsetof(struct lwp, l_md.md_upte[1])
define P_NRAS offsetof(struct proc, p_nras) define P_RASLIST offsetof(struct proc, p_raslist)
define P_MD_ASTPENDING offsetof(struct proc, p_md.md_astpending) define P_MD_ASTPENDING offsetof(struct proc, p_md.md_astpending)
define P_MD_SYSCALL offsetof(struct proc, p_md.md_syscall) define P_MD_SYSCALL offsetof(struct proc, p_md.md_syscall)

View File

@ -1,4 +1,4 @@
/* $NetBSD: locore.S,v 1.156 2003/08/07 16:28:32 agc Exp $ */ /* $NetBSD: locore.S,v 1.157 2003/11/04 10:33:15 dsl Exp $ */
/* /*
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
@ -354,7 +354,7 @@ cpu_switch_queuescan:
*/ */
lw t1, L_PROC(s7) lw t1, L_PROC(s7)
lw a0, L_ADDR(s7) lw a0, L_ADDR(s7)
lw v1, P_NRAS(t1) lw v1, P_RASLIST(t1)
addu t0, a0, USPACE - FRAME_SIZ addu t0, a0, USPACE - FRAME_SIZ
beq v1, zero, 1f beq v1, zero, 1f

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.186 2003/11/02 08:27:41 christos Exp $ */ /* $NetBSD: trap.c,v 1.187 2003/11/04 10:33:15 dsl Exp $ */
/* /*
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
@ -78,7 +78,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.186 2003/11/02 08:27:41 christos Exp $"); __KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.187 2003/11/04 10:33:15 dsl Exp $");
#include "opt_cputype.h" /* which mips CPU levels do we support? */ #include "opt_cputype.h" /* which mips CPU levels do we support? */
#include "opt_ktrace.h" #include "opt_ktrace.h"
@ -688,7 +688,7 @@ mips_singlestep(l)
* We can't single-step into a RAS. Check if we're in * We can't single-step into a RAS. Check if we're in
* a RAS, and set the breakpoint just past it. * a RAS, and set the breakpoint just past it.
*/ */
if (p->p_nras != 0) { if (!LIST_EMPTY(&p->p_raslist) {
while (ras_lookup(p, (caddr_t)va) != (caddr_t)-1) while (ras_lookup(p, (caddr_t)va) != (caddr_t)-1)
va += sizeof(int); va += sizeof(int);
} }

View File

@ -1,4 +1,4 @@
# $NetBSD: genassym.cf,v 1.26 2003/09/22 14:27:09 cl Exp $ # $NetBSD: genassym.cf,v 1.27 2003/11/04 10:33:16 dsl Exp $
# #
# Copyright (c) 1982, 1990, 1993 # Copyright (c) 1982, 1990, 1993
@ -138,7 +138,7 @@ define L_PROC offsetof(struct lwp, l_proc)
define L_MD_REGS offsetof(struct lwp, l_md.md_regs) define L_MD_REGS offsetof(struct lwp, l_md.md_regs)
define L_MD_FLAGS offsetof(struct lwp, l_md.md_flags) define L_MD_FLAGS offsetof(struct lwp, l_md.md_flags)
define P_FLAG offsetof(struct proc, p_flag) define P_FLAG offsetof(struct proc, p_flag)
define P_NRAS offsetof(struct proc, p_nras) define P_RASLIST offsetof(struct proc, p_raslist)
define P_VMSPACE offsetof(struct proc, p_vmspace) define P_VMSPACE offsetof(struct proc, p_vmspace)
# lwp fields and values # lwp fields and values

View File

@ -1,4 +1,4 @@
# $NetBSD: genassym.cf,v 1.13 2003/09/22 14:27:10 cl Exp $ # $NetBSD: genassym.cf,v 1.14 2003/11/04 10:33:17 dsl Exp $
# #
# Copyright (c) 1982, 1990, 1993 # Copyright (c) 1982, 1990, 1993
@ -114,7 +114,7 @@ define L_PROC offsetof(struct lwp, l_proc)
define L_MD_REGS offsetof(struct lwp, l_md.md_regs) define L_MD_REGS offsetof(struct lwp, l_md.md_regs)
define L_MD_FLAGS offsetof(struct lwp, l_md.md_flags) define L_MD_FLAGS offsetof(struct lwp, l_md.md_flags)
define P_FLAG offsetof(struct proc, p_flag) define P_FLAG offsetof(struct proc, p_flag)
define P_NRAS offsetof(struct proc, p_nras) define P_RASLIST offsetof(struct proc, p_raslist)
define P_VMSPACE offsetof(struct proc, p_vmspace) define P_VMSPACE offsetof(struct proc, p_vmspace)
# lwp fields and values # lwp fields and values

View File

@ -1,4 +1,4 @@
# $NetBSD: genassym.cf,v 1.17 2003/09/22 14:27:11 cl Exp $ # $NetBSD: genassym.cf,v 1.18 2003/11/04 10:33:17 dsl Exp $
# #
# Copyright (c) 1982, 1990, 1993 # Copyright (c) 1982, 1990, 1993
@ -135,7 +135,7 @@ define L_PROC offsetof(struct lwp, l_proc)
define L_MD_REGS offsetof(struct lwp, l_md.md_regs) define L_MD_REGS offsetof(struct lwp, l_md.md_regs)
define L_MD_FLAGS offsetof(struct lwp, l_md.md_flags) define L_MD_FLAGS offsetof(struct lwp, l_md.md_flags)
define P_FLAG offsetof(struct proc, p_flag) define P_FLAG offsetof(struct proc, p_flag)
define P_NRAS offsetof(struct proc, p_nras) define P_RASLIST offsetof(struct proc, p_raslist)
define P_VMSPACE offsetof(struct proc, p_vmspace) define P_VMSPACE offsetof(struct proc, p_vmspace)
# lwp fields and values # lwp fields and values

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.93 2003/10/25 16:31:39 chs Exp $ */ /* $NetBSD: trap.c,v 1.94 2003/11/04 10:33:15 dsl Exp $ */
/* /*
* Copyright (C) 1995, 1996 Wolfgang Solfrank. * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@ -32,7 +32,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.93 2003/10/25 16:31:39 chs Exp $"); __KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.94 2003/11/04 10:33:15 dsl Exp $");
#include "opt_altivec.h" #include "opt_altivec.h"
#include "opt_ddb.h" #include "opt_ddb.h"
@ -104,7 +104,7 @@ trap(struct trapframe *frame)
/* FALLTHROUGH */ /* FALLTHROUGH */
case EXC_TRC|EXC_USER: case EXC_TRC|EXC_USER:
frame->srr1 &= ~PSL_SE; frame->srr1 &= ~PSL_SE;
if (p->p_nras == 0 || if (LIST_EMPTY(&p->p_raslist) ||
ras_lookup(p, (caddr_t)frame->srr0) == (caddr_t) -1) { ras_lookup(p, (caddr_t)frame->srr0) == (caddr_t) -1) {
KSI_INIT_TRAP(&ksi); KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = SIGTRAP; ksi.ksi_signo = SIGTRAP;

View File

@ -1,4 +1,4 @@
/* $NetBSD: locore_c.c,v 1.4 2003/10/22 21:13:44 uwe Exp $ */ /* $NetBSD: locore_c.c,v 1.5 2003/11/04 10:33:15 dsl Exp $ */
/*- /*-
* Copyright (c) 1996, 1997, 2002 The NetBSD Foundation, Inc. * Copyright (c) 1996, 1997, 2002 The NetBSD Foundation, Inc.
@ -111,7 +111,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: locore_c.c,v 1.4 2003/10/22 21:13:44 uwe Exp $"); __KERNEL_RCSID(0, "$NetBSD: locore_c.c,v 1.5 2003/11/04 10:33:15 dsl Exp $");
#include "opt_lockdebug.h" #include "opt_lockdebug.h"
@ -177,7 +177,7 @@ cpu_switch_search(struct lwp *oldlwp)
pmap_activate(l); pmap_activate(l);
/* Check for Restartable Atomic Sequences. */ /* Check for Restartable Atomic Sequences. */
if (p->p_nras != 0) { if (!LIST_EMPTY(&p->p_raslist) {
caddr_t pc; caddr_t pc;
pc = ras_lookup(p, (caddr_t) l->l_md.md_regs->tf_spc); pc = ras_lookup(p, (caddr_t) l->l_md.md_regs->tf_spc);

View File

@ -1,4 +1,4 @@
/* $NetBSD: cpu_switch.S,v 1.18 2003/10/05 09:57:47 scw Exp $ */ /* $NetBSD: cpu_switch.S,v 1.19 2003/11/04 10:33:15 dsl Exp $ */
/* /*
* Copyright 2002 Wasabi Systems, Inc. * Copyright 2002 Wasabi Systems, Inc.
@ -394,7 +394,7 @@ Lsw3:
*/ */
pta/l 2f, tr0 pta/l 2f, tr0
LDPTR r31, L_PROC, r2 LDPTR r31, L_PROC, r2
ld.l r2, P_NRAS, r0 LDPTR r2, P_RASLIST, r0
beq/l r0, r63, tr0 /* Skip if no RAS registered for proc */ beq/l r0, r63, tr0 /* Skip if no RAS registered for proc */
LEAF(_C_LABEL(ras_lookup), r0) LEAF(_C_LABEL(ras_lookup), r0)
ptabs/l r0, tr0 ptabs/l r0, tr0

View File

@ -1,4 +1,4 @@
# $NetBSD: genassym.cf,v 1.15 2003/03/13 13:44:19 scw Exp $ # $NetBSD: genassym.cf,v 1.16 2003/11/04 10:33:15 dsl Exp $
# Copyright 2002 Wasabi Systems, Inc. # Copyright 2002 Wasabi Systems, Inc.
# All rights reserved. # All rights reserved.
@ -255,7 +255,7 @@ define L_MD_FLAGS offsetof(struct lwp, l_md.md_flags)
define PH_LINK offsetof(struct prochd, ph_link) define PH_LINK offsetof(struct prochd, ph_link)
define P_NRAS offsetof(struct proc, p_nras) define P_RASLIST offsetof(struct proc, p_raslist)
define P_MD_SYSCALL offsetof(struct proc, p_md.md_syscall) define P_MD_SYSCALL offsetof(struct proc, p_md.md_syscall)
define P_MD_ASTPENDING offsetof(struct proc, p_md.md_astpending) define P_MD_ASTPENDING offsetof(struct proc, p_md.md_astpending)

View File

@ -1,4 +1,4 @@
# $NetBSD: genassym.cf,v 1.5 2003/09/22 14:27:15 cl Exp $ # $NetBSD: genassym.cf,v 1.6 2003/11/04 10:33:17 dsl Exp $
# #
# Copyright (c) 1994, 1995 Gordon W. Ross # Copyright (c) 1994, 1995 Gordon W. Ross
@ -138,7 +138,7 @@ define L_PROC offsetof(struct lwp, l_proc)
define L_MD_REGS offsetof(struct lwp, l_md.md_regs) define L_MD_REGS offsetof(struct lwp, l_md.md_regs)
define L_MD_FLAGS offsetof(struct lwp, l_md.md_flags) define L_MD_FLAGS offsetof(struct lwp, l_md.md_flags)
define P_FLAG offsetof(struct proc, p_flag) define P_FLAG offsetof(struct proc, p_flag)
define P_NRAS offsetof(struct proc, p_nras) define P_RASLIST offsetof(struct proc, p_raslist)
define P_VMSPACE offsetof(struct proc, p_vmspace) define P_VMSPACE offsetof(struct proc, p_vmspace)
# lwp fields and values # lwp fields and values

View File

@ -1,4 +1,4 @@
# $NetBSD: genassym.cf,v 1.23 2003/09/22 14:27:14 cl Exp $ # $NetBSD: genassym.cf,v 1.24 2003/11/04 10:33:17 dsl Exp $
# #
# Copyright (c) 1982, 1990, 1993 # Copyright (c) 1982, 1990, 1993
@ -118,7 +118,7 @@ define L_PROC offsetof(struct lwp, l_proc)
define L_MD_REGS offsetof(struct lwp, l_md.md_regs) define L_MD_REGS offsetof(struct lwp, l_md.md_regs)
define L_MD_FLAGS offsetof(struct lwp, l_md.md_flags) define L_MD_FLAGS offsetof(struct lwp, l_md.md_flags)
define P_FLAG offsetof(struct proc, p_flag) define P_FLAG offsetof(struct proc, p_flag)
define P_NRAS offsetof(struct proc, p_nras) define P_RASLIST offsetof(struct proc, p_raslist)
define P_VMSPACE offsetof(struct proc, p_vmspace) define P_VMSPACE offsetof(struct proc, p_vmspace)
# lwp fields and values # lwp fields and values

View File

@ -1,4 +1,4 @@
/* $NetBSD: init_main.c,v 1.225 2003/11/02 16:42:22 jdolecek Exp $ */ /* $NetBSD: init_main.c,v 1.226 2003/11/04 10:33:15 dsl Exp $ */
/* /*
* Copyright (c) 1982, 1986, 1989, 1991, 1992, 1993 * Copyright (c) 1982, 1986, 1989, 1991, 1992, 1993
@ -71,7 +71,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.225 2003/11/02 16:42:22 jdolecek Exp $"); __KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.226 2003/11/04 10:33:15 dsl Exp $");
#include "fs_nfs.h" #include "fs_nfs.h"
#include "opt_nfsserver.h" #include "opt_nfsserver.h"
@ -236,7 +236,6 @@ main(void)
* Initialize the current LWP pointer (curlwp) before * Initialize the current LWP pointer (curlwp) before
* any possible traps/probes to simplify trap processing. * any possible traps/probes to simplify trap processing.
*/ */
simple_lock_init(&proc0.p_raslock);
l = &lwp0; l = &lwp0;
curlwp = l; curlwp = l;
l->l_cpu = curcpu(); l->l_cpu = curcpu();

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_fork.c,v 1.111 2003/09/16 12:06:07 christos Exp $ */ /* $NetBSD: kern_fork.c,v 1.112 2003/11/04 10:33:15 dsl Exp $ */
/*- /*-
* Copyright (c) 1999, 2001 The NetBSD Foundation, Inc. * Copyright (c) 1999, 2001 The NetBSD Foundation, Inc.
@ -74,7 +74,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.111 2003/09/16 12:06:07 christos Exp $"); __KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.112 2003/11/04 10:33:15 dsl Exp $");
#include "opt_ktrace.h" #include "opt_ktrace.h"
#include "opt_systrace.h" #include "opt_systrace.h"
@ -276,7 +276,7 @@ fork1(struct lwp *l1, int flags, int exitsig, void *stack, size_t stacksize,
simple_lock_init(&p2->p_sigctx.ps_silock); simple_lock_init(&p2->p_sigctx.ps_silock);
CIRCLEQ_INIT(&p2->p_sigctx.ps_siginfo); CIRCLEQ_INIT(&p2->p_sigctx.ps_siginfo);
simple_lock_init(&p2->p_lwplock); simple_lock_init(&p2->p_lock);
LIST_INIT(&p2->p_lwps); LIST_INIT(&p2->p_lwps);
/* /*
@ -296,8 +296,6 @@ fork1(struct lwp *l1, int flags, int exitsig, void *stack, size_t stacksize,
crhold(p1->p_ucred); crhold(p1->p_ucred);
LIST_INIT(&p2->p_raslist); LIST_INIT(&p2->p_raslist);
p2->p_nras = 0;
simple_lock_init(&p2->p_raslock);
#if defined(__HAVE_RAS) #if defined(__HAVE_RAS)
ras_fork(p1, p2); ras_fork(p1, p2);
#endif #endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_lwp.c,v 1.14 2003/10/30 23:31:21 cl Exp $ */ /* $NetBSD: kern_lwp.c,v 1.15 2003/11/04 10:33:15 dsl Exp $ */
/*- /*-
* Copyright (c) 2001 The NetBSD Foundation, Inc. * Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.14 2003/10/30 23:31:21 cl Exp $"); __KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.15 2003/11/04 10:33:15 dsl Exp $");
#include "opt_multiprocessor.h" #include "opt_multiprocessor.h"
@ -110,9 +110,9 @@ sys__lwp_create(struct lwp *l, void *v, register_t *retval)
l2->l_stat = LSRUN; l2->l_stat = LSRUN;
setrunqueue(l2); setrunqueue(l2);
SCHED_UNLOCK(s); SCHED_UNLOCK(s);
simple_lock(&p->p_lwplock); simple_lock(&p->p_lock);
p->p_nrlwps++; p->p_nrlwps++;
simple_unlock(&p->p_lwplock); simple_unlock(&p->p_lock);
} else { } else {
l2->l_stat = LSSUSPENDED; l2->l_stat = LSSUSPENDED;
} }
@ -218,9 +218,9 @@ sys__lwp_suspend(struct lwp *l, void *v, register_t *retval)
remrunqueue(t); remrunqueue(t);
t->l_stat = LSSUSPENDED; t->l_stat = LSSUSPENDED;
SCHED_UNLOCK(s); SCHED_UNLOCK(s);
simple_lock(&p->p_lwplock); simple_lock(&p->p_lock);
p->p_nrlwps--; p->p_nrlwps--;
simple_unlock(&p->p_lwplock); simple_unlock(&p->p_lock);
break; break;
case LSSLEEP: case LSSLEEP:
t->l_stat = LSSUSPENDED; t->l_stat = LSSUSPENDED;
@ -397,11 +397,11 @@ lwp_wait1(struct lwp *l, lwpid_t lid, lwpid_t *departed, int flags)
LIST_REMOVE(l2, l_zlist); /* off zomblwp */ LIST_REMOVE(l2, l_zlist); /* off zomblwp */
proclist_unlock_write(s); proclist_unlock_write(s);
simple_lock(&p->p_lwplock); simple_lock(&p->p_lock);
LIST_REMOVE(l2, l_sibling); LIST_REMOVE(l2, l_sibling);
p->p_nlwps--; p->p_nlwps--;
p->p_nzlwps--; p->p_nzlwps--;
simple_unlock(&p->p_lwplock); simple_unlock(&p->p_lock);
/* XXX decrement limits */ /* XXX decrement limits */
pool_put(&lwp_pool, l2); pool_put(&lwp_pool, l2);
@ -504,11 +504,11 @@ newlwp(struct lwp *l1, struct proc *p2, vaddr_t uaddr, boolean_t inmem,
(arg != NULL) ? arg : l2); (arg != NULL) ? arg : l2);
simple_lock(&p2->p_lwplock); simple_lock(&p2->p_lock);
l2->l_lid = ++p2->p_nlwpid; l2->l_lid = ++p2->p_nlwpid;
LIST_INSERT_HEAD(&p2->p_lwps, l2, l_sibling); LIST_INSERT_HEAD(&p2->p_lwps, l2, l_sibling);
p2->p_nlwps++; p2->p_nlwps++;
simple_unlock(&p2->p_lwplock); simple_unlock(&p2->p_lock);
/* XXX should be locked differently... */ /* XXX should be locked differently... */
s = proclist_lock_write(); s = proclist_lock_write();
@ -555,9 +555,9 @@ lwp_exit(struct lwp *l)
} }
proclist_unlock_write(s); proclist_unlock_write(s);
simple_lock(&p->p_lwplock); simple_lock(&p->p_lock);
p->p_nrlwps--; p->p_nrlwps--;
simple_unlock(&p->p_lwplock); simple_unlock(&p->p_lock);
l->l_stat = LSDEAD; l->l_stat = LSDEAD;

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_proc.c,v 1.66 2003/09/16 12:05:49 christos Exp $ */ /* $NetBSD: kern_proc.c,v 1.67 2003/11/04 10:33:15 dsl Exp $ */
/*- /*-
* Copyright (c) 1999 The NetBSD Foundation, Inc. * Copyright (c) 1999 The NetBSD Foundation, Inc.
@ -69,7 +69,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.66 2003/09/16 12:05:49 christos Exp $"); __KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.67 2003/11/04 10:33:15 dsl Exp $");
#include "opt_kstack.h" #include "opt_kstack.h"
@ -464,7 +464,7 @@ proc0_insert(struct proc *p, struct lwp *l, struct pgrp *pgrp,
{ {
int s; int s;
simple_lock_init(&p->p_lwplock); simple_lock_init(&p->p_lock);
LIST_INIT(&p->p_lwps); LIST_INIT(&p->p_lwps);
LIST_INSERT_HEAD(&p->p_lwps, l, l_sibling); LIST_INSERT_HEAD(&p->p_lwps, l, l_sibling);
p->p_nlwps = 1; p->p_nlwps = 1;

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_ras.c,v 1.5 2003/06/28 14:52:10 simonb Exp $ */ /* $NetBSD: kern_ras.c,v 1.6 2003/11/04 10:33:15 dsl Exp $ */
/*- /*-
* Copyright (c) 2002 The NetBSD Foundation, Inc. * Copyright (c) 2002 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_ras.c,v 1.5 2003/06/28 14:52:10 simonb Exp $"); __KERNEL_RCSID(0, "$NetBSD: kern_ras.c,v 1.6 2003/11/04 10:33:15 dsl Exp $");
#include <sys/param.h> #include <sys/param.h>
#include <sys/lock.h> #include <sys/lock.h>
@ -84,18 +84,18 @@ ras_lookup(struct proc *p, caddr_t addr)
return ((caddr_t)-1); return ((caddr_t)-1);
#endif #endif
simple_lock(&p->p_raslock); simple_lock(&p->p_lock);
LIST_FOREACH(rp, &p->p_raslist, ras_list) { LIST_FOREACH(rp, &p->p_raslist, ras_list) {
if (addr > rp->ras_startaddr && addr < rp->ras_endaddr) { if (addr > rp->ras_startaddr && addr < rp->ras_endaddr) {
rp->ras_hits++; rp->ras_hits++;
simple_unlock(&p->p_raslock); simple_unlock(&p->p_lock);
#ifdef DIAGNOSTIC #ifdef DIAGNOSTIC
DPRINTF(("RAS hit: p=%p %p\n", p, addr)); DPRINTF(("RAS hit: p=%p %p\n", p, addr));
#endif #endif
return (rp->ras_startaddr); return (rp->ras_startaddr);
} }
} }
simple_unlock(&p->p_raslock); simple_unlock(&p->p_lock);
return ((caddr_t)-1); return ((caddr_t)-1);
} }
@ -108,20 +108,20 @@ int
ras_fork(struct proc *p1, struct proc *p2) ras_fork(struct proc *p1, struct proc *p2)
{ {
struct ras *rp, *nrp; struct ras *rp, *nrp;
int nras = 0;
DPRINTF(("ras_fork: p1=%p, p2=%p, p1->p_nras=%d\n", simple_lock(&p1->p_lock);
p1, p2, p1->p_nras));
simple_lock(&p1->p_raslock);
LIST_FOREACH(rp, &p1->p_raslist, ras_list) { LIST_FOREACH(rp, &p1->p_raslist, ras_list) {
nras++;
nrp = pool_get(&ras_pool, PR_NOWAIT); nrp = pool_get(&ras_pool, PR_NOWAIT);
nrp->ras_startaddr = rp->ras_startaddr; nrp->ras_startaddr = rp->ras_startaddr;
nrp->ras_endaddr = rp->ras_endaddr; nrp->ras_endaddr = rp->ras_endaddr;
nrp->ras_hits = 0; nrp->ras_hits = 0;
LIST_INSERT_HEAD(&p2->p_raslist, nrp, ras_list); LIST_INSERT_HEAD(&p2->p_raslist, nrp, ras_list);
} }
p2->p_nras = p1->p_nras; simple_unlock(&p1->p_lock);
simple_unlock(&p1->p_raslock);
DPRINTF(("ras_fork: p1=%p, p2=%p, nras=%d\n", p1, p2, nras));
return (0); return (0);
} }
@ -134,7 +134,7 @@ ras_purgeall(struct proc *p)
{ {
struct ras *rp; struct ras *rp;
simple_lock(&p->p_raslock); simple_lock(&p->p_lock);
while (!LIST_EMPTY(&p->p_raslist)) { while (!LIST_EMPTY(&p->p_raslist)) {
rp = LIST_FIRST(&p->p_raslist); rp = LIST_FIRST(&p->p_raslist);
DPRINTF(("RAS %p-%p, hits %d\n", rp->ras_startaddr, DPRINTF(("RAS %p-%p, hits %d\n", rp->ras_startaddr,
@ -142,8 +142,7 @@ ras_purgeall(struct proc *p)
LIST_REMOVE(rp, ras_list); LIST_REMOVE(rp, ras_list);
pool_put(&ras_pool, rp); pool_put(&ras_pool, rp);
} }
p->p_nras = 0; simple_unlock(&p->p_lock);
simple_unlock(&p->p_raslock);
return (0); return (0);
} }
@ -157,24 +156,20 @@ ras_install(struct proc *p, caddr_t addr, size_t len)
{ {
struct ras *rp; struct ras *rp;
caddr_t endaddr = addr + len; caddr_t endaddr = addr + len;
int nras = 0;
if (addr < (caddr_t)VM_MIN_ADDRESS || if (addr < (caddr_t)VM_MIN_ADDRESS ||
addr > (caddr_t)VM_MAXUSER_ADDRESS) endaddr > (caddr_t)VM_MAXUSER_ADDRESS)
return (EINVAL); return (EINVAL);
if (len <= 0) if (len <= 0)
return (EINVAL); return (EINVAL);
if (p->p_nras >= ras_per_proc) simple_lock(&p->p_lock);
return (EINVAL);
simple_lock(&p->p_raslock);
LIST_FOREACH(rp, &p->p_raslist, ras_list) { LIST_FOREACH(rp, &p->p_raslist, ras_list) {
if ((addr > rp->ras_startaddr && addr < rp->ras_endaddr) || if (++nras >= ras_per_proc ||
(endaddr > rp->ras_startaddr && (addr < rp->ras_endaddr && endaddr > rp->ras_startaddr)) {
endaddr < rp->ras_endaddr) || simple_unlock(&p->p_lock);
(addr < rp->ras_startaddr && endaddr > rp->ras_endaddr)) {
simple_unlock(&p->p_raslock);
return (EINVAL); return (EINVAL);
} }
} }
@ -183,8 +178,7 @@ ras_install(struct proc *p, caddr_t addr, size_t len)
rp->ras_endaddr = endaddr; rp->ras_endaddr = endaddr;
rp->ras_hits = 0; rp->ras_hits = 0;
LIST_INSERT_HEAD(&p->p_raslist, rp, ras_list); LIST_INSERT_HEAD(&p->p_raslist, rp, ras_list);
p->p_nras++; simple_unlock(&p->p_lock);
simple_unlock(&p->p_raslock);
return (0); return (0);
} }
@ -200,17 +194,16 @@ ras_purge(struct proc *p, caddr_t addr, size_t len)
caddr_t endaddr = addr + len; caddr_t endaddr = addr + len;
int error = ESRCH; int error = ESRCH;
simple_lock(&p->p_raslock); simple_lock(&p->p_lock);
LIST_FOREACH(rp, &p->p_raslist, ras_list) { LIST_FOREACH(rp, &p->p_raslist, ras_list) {
if (addr == rp->ras_startaddr && endaddr == rp->ras_endaddr) { if (addr == rp->ras_startaddr && endaddr == rp->ras_endaddr) {
LIST_REMOVE(rp, ras_list); LIST_REMOVE(rp, ras_list);
pool_put(&ras_pool, rp); pool_put(&ras_pool, rp);
p->p_nras--;
error = 0; error = 0;
break; break;
} }
} }
simple_unlock(&p->p_raslock); simple_unlock(&p->p_lock);
return (error); return (error);
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: sys_process.c,v 1.84 2003/08/07 16:31:55 agc Exp $ */ /* $NetBSD: sys_process.c,v 1.85 2003/11/04 10:33:15 dsl Exp $ */
/*- /*-
* Copyright (c) 1982, 1986, 1989, 1993 * Copyright (c) 1982, 1986, 1989, 1993
@ -89,7 +89,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sys_process.c,v 1.84 2003/08/07 16:31:55 agc Exp $"); __KERNEL_RCSID(0, "$NetBSD: sys_process.c,v 1.85 2003/11/04 10:33:15 dsl Exp $");
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
@ -296,7 +296,7 @@ sys_ptrace(l, v, retval)
/* /*
* Can't write to a RAS * Can't write to a RAS
*/ */
if ((t->p_nras != 0) && if (!LIST_EMPTY(&t->p_raslist) &&
(ras_lookup(t, SCARG(uap, addr)) != (caddr_t)-1)) { (ras_lookup(t, SCARG(uap, addr)) != (caddr_t)-1)) {
return (EACCES); return (EACCES);
} }