From: Ben Gras Date: Tue, 5 Mar 2013 16:17:21 +0000 (+0100) Subject: VM: shared memory pagefault fix X-Git-Tag: v3.3.0~1106 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/zlib_tech.html?a=commitdiff_plain;h=449ed1783384122c32cb8b80fef7c5f043d7df22;p=minix.git VM: shared memory pagefault fix . if there is no memory there, it's not writable; this check bug by the shared memory's writable() method causes pagefaults not to be handled at all in certain situations, triggering an assert() in pt_writemap() . added some assert()s to catch this and similar situations in the future Change-Id: Ife89bfab4f9a3aa7bf4e33dfb0b13b89dcd5bb94 --- diff --git a/servers/vm/mem_anon.c b/servers/vm/mem_anon.c index 0971708fd..55d30bc23 100644 --- a/servers/vm/mem_anon.c +++ b/servers/vm/mem_anon.c @@ -108,9 +108,11 @@ static int anon_sanitycheck(struct phys_region *pr, char *file, int line) static int anon_writable(struct phys_region *pr) { assert(pr->ph->refcount > 0); + if(pr->ph->phys == MAP_NONE) + return 0; if(pr->parent->remaps > 0) return 1; - return pr->ph->phys != MAP_NONE && pr->ph->refcount == 1; + return pr->ph->refcount == 1; } static int anon_resize(struct vmproc *vmp, struct vir_region *vr, vir_bytes l) diff --git a/servers/vm/region.c b/servers/vm/region.c index 8d55fe3ae..78ad03f31 100644 --- a/servers/vm/region.c +++ b/servers/vm/region.c @@ -1032,9 +1032,11 @@ int write; assert(ph); assert(ph->ph); + assert(ph->ph->phys != MAP_NONE); } assert(ph->ph); + assert(ph->ph->phys != MAP_NONE); if((r = map_ph_writept(vmp, region, ph)) != OK) { printf("map_pf: writept failed\n");