9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] mmu fix?
@ 2009-11-12 20:57 erik quanstrom
  2009-11-12 21:19 ` Richard Miller
  0 siblings, 1 reply; 3+ messages in thread
From: erik quanstrom @ 2009-11-12 20:57 UTC (permalink / raw)
  To: 9fans

perhaps i'm missing something, but we experienced
a crash in mmuwalk that was explained by interpreting
the garbage in a page allocated by mmuwalk as valid
page flags.  of course this did not end well.

/n/dump/2009/1112/sys/src/9/pc/mmu.c:624,629 - mmu.c:624,630
  				map = rampage();
  			if(map == nil)
  				panic("mmuwalk xspanalloc failed");
+ 			memset(map, 0, BY2PG);	/* d'oh! */
  			*table = PADDR(map)|PTEWRITE|PTEVALID;
  		}
  		table = KADDR(PPN(*table));

is there something that i'm missing here?  it's hard
to imagine that this doesn't cause problems more often.

- erik



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [9fans] mmu fix?
  2009-11-12 20:57 [9fans] mmu fix? erik quanstrom
@ 2009-11-12 21:19 ` Richard Miller
  0 siblings, 0 replies; 3+ messages in thread
From: Richard Miller @ 2009-11-12 21:19 UTC (permalink / raw)
  To: 9fans

The two cases are:

/sys/src/9/pc/mmu.c:510,513
			if(didmmuinit)
				map = xspanalloc(BY2PG, BY2PG, 0);
			else
				map = rampage();

xspanalloc returns zeroed memory.  rampage is only called early
in startup, and returns virgin memory which in the olden days
would have been zeroed at boot time.  But nowadays:

/sys/src/9/pc/memory.c:443
			/* memset(va, 0, MB); so damn slow to memset all of memory */

So I think you want to clear the page only for the rampage case.




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [9fans] mmu fix?
       [not found] <<8a361ea78b8d25f710617b31c2eaf1ec@hamnavoe.com>
@ 2009-11-12 21:34 ` erik quanstrom
  0 siblings, 0 replies; 3+ messages in thread
From: erik quanstrom @ 2009-11-12 21:34 UTC (permalink / raw)
  To: 9fans

On Thu Nov 12 16:20:39 EST 2009, 9fans@hamnavoe.com wrote:
> The two cases are:
>
> /sys/src/9/pc/mmu.c:510,513
> 			if(didmmuinit)
> 				map = xspanalloc(BY2PG, BY2PG, 0);
> 			else
> 				map = rampage();
>
> xspanalloc returns zeroed memory.  rampage is only called early
> in startup, and returns virgin memory which in the olden days
> would have been zeroed at boot time.  But nowadays:
>
> /sys/src/9/pc/memory.c:443
> 			/* memset(va, 0, MB); so damn slow to memset all of memory */
>
> So I think you want to clear the page only for the rampage case.
>

thanks, richard.  since rampage() doesn't zero memory
but xspanalloc does, it makes sense to me to put the change
in rampage instead of mmuwalk.

/n/dump/2009/1112/sys/src/9/pc/memory.c:223,233 - memory.c:223,236
  rampage(void)
  {
  	ulong m;
-
+ 	void *p;
+
  	m = mapalloc(&rmapram, 0, BY2PG, BY2PG);
  	if(m == 0)
  		return nil;
- 	return KADDR(m);
+ 	p = KADDR(m);
+ 	memset(p, 0, BY2PG);
+ 	return p;
  }

- erik



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-11-12 21:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-12 20:57 [9fans] mmu fix? erik quanstrom
2009-11-12 21:19 ` Richard Miller
     [not found] <<8a361ea78b8d25f710617b31c2eaf1ec@hamnavoe.com>
2009-11-12 21:34 ` erik quanstrom

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).