From eb3b1f018c6d6dbe6ccea320bcd6905335547ede Mon Sep 17 00:00:00 2001 From: peter Date: Thu, 25 Jan 1996 06:05:38 +0000 Subject: This time, really make the procfs work when reading stuff from the UPAGES. This is a really ugly bandaid on the problem, but it works well enough for 'ps -u' to start working again. The problem was caused by the user address space shrinking by a little bit and the UPAGES being "cast off" to become a seperate entity rather than being at the top of the process's vmspace. That optimization was part of John's most recent VM speedups. Now, rather than decoding the VM space, it merely ensures the pages are in core and accesses them the same way the ptrace(PT_READ_U..) code does, ie: off the p->p_addr pointer. --- sys/fs/procfs/procfs_mem.c | 49 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 15 deletions(-) (limited to 'sys/fs/procfs') diff --git a/sys/fs/procfs/procfs_mem.c b/sys/fs/procfs/procfs_mem.c index f772c4b..04b3a37 100644 --- a/sys/fs/procfs/procfs_mem.c +++ b/sys/fs/procfs/procfs_mem.c @@ -37,7 +37,7 @@ * * @(#)procfs_mem.c 8.4 (Berkeley) 1/21/94 * - * $Id: procfs_mem.c,v 1.15 1996/01/19 03:58:32 dyson Exp $ + * $Id: procfs_mem.c,v 1.16 1996/01/24 18:41:06 peter Exp $ */ /* @@ -96,20 +96,6 @@ procfs_rwmem(p, uio) int fix_prot; uva = (vm_offset_t) uio->uio_offset; - if (uva >= VM_MAXUSER_ADDRESS) { - - if (writing || (uva >= (VM_MAXUSER_ADDRESS + UPAGES * PAGE_SIZE))) { - error = 0; - break; - } - /* we are reading the "U area", fill it in */ - PHOLD(p); - if (p->p_flag & P_INMEM) { - p->p_addr->u_kproc.kp_proc = *p; - fill_eproc (p, &p->p_addr->u_kproc.kp_eproc); - } - PRELE(p); - } /* * Get the page number of this segment. @@ -122,6 +108,39 @@ procfs_rwmem(p, uio) */ len = min(PAGE_SIZE - page_offset, uio->uio_resid); + if (uva >= VM_MAXUSER_ADDRESS) { + if (writing || (uva >= (VM_MAXUSER_ADDRESS + UPAGES * PAGE_SIZE))) { + error = 0; + break; + } + + /* we are reading the "U area", force it into core */ + PHOLD(p); + + /* sanity check */ + if (!(p->p_flag & P_INMEM)) { + /* aiee! */ + error = EFAULT; + break; + } + + /* populate the ptrace/procfs area */ + p->p_addr->u_kproc.kp_proc = *p; + fill_eproc (p, &p->p_addr->u_kproc.kp_eproc); + + /* locate the in-core address */ + kva = (u_int)p->p_addr + uva - VM_MAXUSER_ADDRESS; + + /* transfer it */ + error = uiomove((caddr_t)kva, len, uio); + + /* let the pages go */ + PRELE(p); + + continue; + } + + /* * The map we want... */ -- cgit v1.1