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
This commit is contained in:
Ben Gras 2013-03-05 17:17:21 +01:00
parent df04d571b1
commit 449ed17833
2 changed files with 5 additions and 1 deletions

View file

@ -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)

View file

@ -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");