Subject: Re: SIR Reset with todays sources
To: Eduardo Horvath <eeh@netbsd.org>
From: Juergen Hannken-Illjes <hannken@eis.cs.tu-bs.de>
List: port-sparc64
Date: 03/26/2007 19:12:59
On Mon, Mar 26, 2007 at 04:18:28PM +0000, Eduardo Horvath wrote:
> On Sun, 25 Mar 2007, Martin Husemann wrote:
> 
> > On Sun, Mar 25, 2007 at 08:59:31PM +0200, Martin Husemann wrote:
> > > But changing the one in pmap_remove_all to set the secondary context to
> > > -1 instead of 0 does the trick.
> > 
> > On second thought: removing that stxa(CTX_SECONDARY, ASI_DMMU, 0) completely
> > does the trick too.
> > 
> > I'm not sure there could be any data accesses happening between this and the
> > removal of the mapping in pmap_remove(), and if those would happen, if still
> > allowing them would be evil. I suppose we can ignore this.
> 
> What the heck are we trying to do here?  Setting the secondary context to 
> 0 merely makes user accesses (ASI_AIUS) use the kernel pmap, which means 
> you are allowing the kernel to trash itself, which is bogus.  Also, if 
> code tries to flush the secondary context out of the MMU it will flush out 
> he nucleus (kernel) context instead of whatever user context used to be 
> there.  What Chuck may have been trying to do there is flush the secondary 
> context, which is probably best done by calling sp_tlb_flush_ctx() in 
> locore.s, which, in theory, should DTRT.  (What's going on in the 
> non-spitfire code?  He's demapping the entire nucleus context?  It really 
> hurts to look at this stuff.  Sigh.)
> 
> Eduardo

s/in theory/in practice/ :-)

With the appended diff applied the machine comes up multi-user.  No SIR.

-- 
Juergen Hannken-Illjes - hannken@eis.cs.tu-bs.de - TU Braunschweig (Germany)

Index: pmap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sparc64/sparc64/pmap.c,v
retrieving revision 1.187
diff -p -u -2 -r1.187 pmap.c
--- pmap.c	12 Mar 2007 18:18:28 -0000	1.187
+++ pmap.c	26 Mar 2007 17:10:18 -0000
@@ -1438,4 +1438,5 @@ pmap_activate_pmap(struct pmap *pmap)
 	}
 	stxa(CTX_SECONDARY, ASI_DMMU, pmap->pm_ctx);
+	membar_sync();
 }
 
@@ -1847,5 +1848,5 @@ pmap_remove_all(pm)
 		return;
 	}
-	stxa(CTX_SECONDARY, ASI_DMMU, 0);
+	sp_tlb_flush_ctx(pm->pm_ctx);
 	pm->pm_refs = 0;
 	ctx_free(pm);