From ef99a7a3dc55280fff9eb4a4755a5dde7cf37ee1 Mon Sep 17 00:00:00 2001 From: Ben Gras Date: Sat, 26 Nov 2011 15:12:17 +0000 Subject: [PATCH] vm: report cropped region sizes . when reporting on regions, only report part of the region (addr and length) that really has memory mapped into it . to minimise core files --- servers/vm/region.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/servers/vm/region.c b/servers/vm/region.c index c44062f85..2d63e1954 100644 --- a/servers/vm/region.c +++ b/servers/vm/region.c @@ -1991,9 +1991,19 @@ PUBLIC int get_region_info(struct vmproc *vmp, struct vm_region_info *vri, if(!(vr = region_get_iter(&v_iter))) return 0; for(count = 0; (vr = region_get_iter(&v_iter)) && count < max; count++, vri++) { - vri->vri_addr = arch_map2info(vmp, vr->vaddr, &vri->vri_seg, - &vri->vri_prot); - vri->vri_length = vr->length; + struct phys_region *ph1, *ph2; + + /* Report part of the region that's actually in use. */ + + /* Get first and last phys_regions, if any */ + ph1 = physr_search_least(vr->phys); + ph2 = physr_search_greatest(vr->phys); + if(!ph1 || !ph2) { assert(!ph1 && !ph2); continue; } + + /* Report start+length of region starting from lowest use. */ + vri->vri_addr = arch_map2info(vmp, vr->vaddr + ph1->offset, + &vri->vri_seg, &vri->vri_prot); + vri->vri_length = ph2->offset + ph2->ph->length - ph1->offset; /* "AND" the provided protection with per-page protection. */ if (!(vr->flags & VR_WRITABLE)) -- 2.44.0