From c87fc953502f943685199323ece6b3a780ea5426 Mon Sep 17 00:00:00 2001 From: jhb Date: Wed, 16 May 2001 00:47:27 +0000 Subject: Lock the procfs functions for doing a single step and reading/writing registers better. Hold sched_lock not only for checking the flag but also while performing the actual operation to ensure the process doesn't get swapped out by another CPU while we the operation is being performed. --- sys/ia64/ia64/procfs_machdep.c | 43 ++++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 27 deletions(-) (limited to 'sys/ia64') diff --git a/sys/ia64/ia64/procfs_machdep.c b/sys/ia64/ia64/procfs_machdep.c index e771a37..6deaafa 100644 --- a/sys/ia64/ia64/procfs_machdep.c +++ b/sys/ia64/ia64/procfs_machdep.c @@ -81,19 +81,25 @@ #include +#define PROCFS_ACTION(action) do { \ + int error; \ + \ + mtx_lock_spin(&sched_lock); \ + if ((p->p_sflag & PS_INMEM) == 0) \ + error = EIO; \ + else \ + error = (action); \ + mtx_unlock_spin(&sched_lock); \ + return (error); \ +} while(0) + int procfs_read_regs(p, regs) struct proc *p; struct reg *regs; { - mtx_lock_spin(&sched_lock); - if ((p->p_sflag & PS_INMEM) == 0) { - mtx_unlock_spin(&sched_lock); - return (EIO); - } - mtx_unlock_spin(&sched_lock); - return (fill_regs(p, regs)); + PROCFS_ACTION(fill_regs(p, regs)); } int @@ -102,13 +108,7 @@ procfs_write_regs(p, regs) struct reg *regs; { - mtx_lock_spin(&sched_lock); - if ((p->p_sflag & PS_INMEM) == 0) { - mtx_unlock_spin(&sched_lock); - return (EIO); - } - mtx_unlock_spin(&sched_lock); - return (set_regs(p, regs)); + PROCFS_ACTION(set_regs(p, regs)); } /* @@ -122,12 +122,7 @@ procfs_read_fpregs(p, fpregs) struct fpreg *fpregs; { - mtx_lock_spin(&sched_lock); - if ((p->p_sflag & PS_INMEM) == 0) { - mtx_unlock_spin(&sched_lock); - return (EIO); - } - return (fill_fpregs(p, fpregs)); + PROCFS_ACTION(fill_fpregs(p, fpregs)); } int @@ -136,13 +131,7 @@ procfs_write_fpregs(p, fpregs) struct fpreg *fpregs; { - mtx_lock_spin(&sched_lock); - if ((p->p_sflag & PS_INMEM) == 0) { - mtx_unlock_spin(&sched_lock); - return (EIO); - } - mtx_unlock_spin(&sched_lock); - return (set_fpregs(p, fpregs)); + PROCFS_ACTION(set_fpregs(p, fpregs)); } int -- cgit v1.1