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/27/2007 17:31:35
On Tue, Mar 27, 2007 at 03:24:43PM +0000, Eduardo Horvath wrote:
> On Mon, 26 Mar 2007, Juergen Hannken-Illjes wrote:
> 
> > 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();
> 
> The above code is not safe.  The compiler can schedule other instructions 
> between the stxa and membar #Sync, which could cause the machine to crash.  
> You should code this as a single __asm() which has the membar #Sync right 
> after the stxa instruction, preventing the compiler from scheduling any 
> other operations in between.
> 
> Eduardo

This one is from martin@.  I suppose it is better to change function `stxa()':

 static __inline void
 stxa(paddr_t loc, int asi, uint64_t value)
 {
 	__asm volatile(
 		"wr %2,%%g0,%%asi;	"
-		"stxa %0,[%1]%%asi	"
+		"stxa %0,[%1]%%asi;	"
+		"membar #Sync		"
 		: : "r" ((unsigned long)(value)),
 		"r" ((unsigned long)(loc)), "r" (asi)
 		: "memory");
 }

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