summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2001-01-24 09:49:49 +0000
committerjhb <jhb@FreeBSD.org>2001-01-24 09:49:49 +0000
commit1b7c29442e5ad3530e88e080d18fb4e82c39a7ff (patch)
tree54bd07b4a323bfff75ce5289882590616ae8e8c0
parent8e161d3269e181e90230c96d4cd3dd335f5a934f (diff)
downloadFreeBSD-src-1b7c29442e5ad3530e88e080d18fb4e82c39a7ff.zip
FreeBSD-src-1b7c29442e5ad3530e88e080d18fb4e82c39a7ff.tar.gz
- Proc locking.
- P_INMEM -> PS_INMEM.
-rw-r--r--sys/amd64/amd64/pmap.c6
-rw-r--r--sys/i386/i386/pmap.c6
-rw-r--r--sys/i386/i386/procfs_machdep.c49
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));
}
OpenPOWER on IntegriCloud