From 1b7c29442e5ad3530e88e080d18fb4e82c39a7ff Mon Sep 17 00:00:00 2001 From: jhb Date: Wed, 24 Jan 2001 09:49:49 +0000 Subject: - Proc locking. - P_INMEM -> PS_INMEM. --- sys/amd64/amd64/pmap.c | 6 ++++++ sys/i386/i386/pmap.c | 6 ++++++ sys/i386/i386/procfs_machdep.c | 49 ++++++++++++++++++++++++++++++++++++------ 3 files changed, 54 insertions(+), 7 deletions(-) diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c index b41dfb0..b7c0d0f 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -816,19 +816,25 @@ pmap_new_proc(p) /* * allocate object for the upages */ + PROC_LOCK(p); if ((upobj = p->p_upages_obj) == NULL) { + PROC_UNLOCK(p); upobj = vm_object_allocate( OBJT_DEFAULT, UPAGES); + PROC_LOCK(p); p->p_upages_obj = upobj; } /* get a kernel virtual address for the UPAGES for this proc */ if ((up = p->p_addr) == NULL) { + PROC_UNLOCK(p); up = (struct user *) kmem_alloc_nofault(kernel_map, UPAGES * PAGE_SIZE); if (up == NULL) panic("pmap_new_proc: u_map allocation failed"); + PROC_LOCK(p); p->p_addr = up; } + PROC_UNLOCK(p); ptek = (unsigned *) vtopte((vm_offset_t) up); diff --git a/sys/i386/i386/pmap.c b/sys/i386/i386/pmap.c index b41dfb0..b7c0d0f 100644 --- a/sys/i386/i386/pmap.c +++ b/sys/i386/i386/pmap.c @@ -816,19 +816,25 @@ pmap_new_proc(p) /* * allocate object for the upages */ + PROC_LOCK(p); if ((upobj = p->p_upages_obj) == NULL) { + PROC_UNLOCK(p); upobj = vm_object_allocate( OBJT_DEFAULT, UPAGES); + PROC_LOCK(p); p->p_upages_obj = upobj; } /* get a kernel virtual address for the UPAGES for this proc */ if ((up = p->p_addr) == NULL) { + PROC_UNLOCK(p); up = (struct user *) kmem_alloc_nofault(kernel_map, UPAGES * PAGE_SIZE); if (up == NULL) panic("pmap_new_proc: u_map allocation failed"); + PROC_LOCK(p); p->p_addr = up; } + PROC_UNLOCK(p); ptek = (unsigned *) vtopte((vm_offset_t) up); diff --git a/sys/i386/i386/procfs_machdep.c b/sys/i386/i386/procfs_machdep.c index a81adfd..cd4e469 100644 --- a/sys/i386/i386/procfs_machdep.c +++ b/sys/i386/i386/procfs_machdep.c @@ -85,8 +85,13 @@ procfs_read_regs(p, regs) struct proc *p; struct reg *regs; { - if ((p->p_flag & P_INMEM) == 0) + + mtx_enter(&sched_lock, MTX_SPIN); + if ((p->p_sflag & PS_INMEM) == 0) { + mtx_exit(&sched_lock, MTX_SPIN); return (EIO); + } + mtx_exit(&sched_lock, MTX_SPIN); return (fill_regs(p, regs)); } @@ -95,8 +100,13 @@ procfs_write_regs(p, regs) struct proc *p; struct reg *regs; { - if ((p->p_flag & P_INMEM) == 0) + + mtx_enter(&sched_lock, MTX_SPIN); + if ((p->p_sflag & PS_INMEM) == 0) { + mtx_exit(&sched_lock, MTX_SPIN); return (EIO); + } + mtx_exit(&sched_lock, MTX_SPIN); return (set_regs(p, regs)); } @@ -105,8 +115,13 @@ procfs_read_dbregs(p, dbregs) struct proc *p; struct dbreg *dbregs; { - if ((p->p_flag & P_INMEM) == 0) + + mtx_enter(&sched_lock, MTX_SPIN); + if ((p->p_sflag & PS_INMEM) == 0) { + mtx_exit(&sched_lock, MTX_SPIN); return (EIO); + } + mtx_exit(&sched_lock, MTX_SPIN); return (fill_dbregs(p, dbregs)); } @@ -115,8 +130,13 @@ procfs_write_dbregs(p, dbregs) struct proc *p; struct dbreg *dbregs; { - if ((p->p_flag & P_INMEM) == 0) + + mtx_enter(&sched_lock, MTX_SPIN); + if ((p->p_sflag & PS_INMEM) == 0) { + mtx_exit(&sched_lock, MTX_SPIN); return (EIO); + } + mtx_exit(&sched_lock, MTX_SPIN); return (set_dbregs(p, dbregs)); } @@ -130,8 +150,13 @@ procfs_read_fpregs(p, fpregs) struct proc *p; struct fpreg *fpregs; { - if ((p->p_flag & P_INMEM) == 0) + + mtx_enter(&sched_lock, MTX_SPIN); + if ((p->p_sflag & PS_INMEM) == 0) { + mtx_exit(&sched_lock, MTX_SPIN); return (EIO); + } + mtx_exit(&sched_lock, MTX_SPIN); return (fill_fpregs(p, fpregs)); } @@ -140,8 +165,13 @@ procfs_write_fpregs(p, fpregs) struct proc *p; struct fpreg *fpregs; { - if ((p->p_flag & P_INMEM) == 0) + + mtx_enter(&sched_lock, MTX_SPIN); + if ((p->p_sflag & PS_INMEM) == 0) { + mtx_exit(&sched_lock, MTX_SPIN); return (EIO); + } + mtx_exit(&sched_lock, MTX_SPIN); return (set_fpregs(p, fpregs)); } @@ -149,7 +179,12 @@ int procfs_sstep(p) struct proc *p; { - if ((p->p_flag & P_INMEM) == 0) + + mtx_enter(&sched_lock, MTX_SPIN); + if ((p->p_sflag & PS_INMEM) == 0) { + mtx_exit(&sched_lock, MTX_SPIN); return (EIO); + } + mtx_exit(&sched_lock, MTX_SPIN); return (ptrace_single_step(p)); } -- cgit v1.1