Subject: Re: port-i386/33725: HAVE_GCC=4 causes INSTALL kernel to not work right
To: None <port-i386-maintainer@netbsd.org, gnats-admin@netbsd.org,>
From: David Laight <david@l8s.co.uk>
List: netbsd-bugs
Date: 08/12/2006 17:45:02
The following reply was made to PR port-i386/33725; it has been noted by GNATS.

From: David Laight <david@l8s.co.uk>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: port-i386/33725: HAVE_GCC=4 causes INSTALL kernel to not work right
Date: Sat, 12 Aug 2006 18:40:51 +0100

 On Sat, Aug 12, 2006 at 04:15:05PM +0000, David Laight wrote:
 
 The following patch seems to fix it:
 
 Index: cpufunc.h
 ===================================================================
 RCS file: /cvsroot/src/sys/arch/i386/include/cpufunc.h,v
 retrieving revision 1.31
 diff -u -p -r1.31 cpufunc.h
 --- cpufunc.h   28 Dec 2005 19:09:29 -0000      1.31
 +++ cpufunc.h   12 Aug 2006 17:31:06 -0000
 @@ -75,9 +75,10 @@ invlpg(u_int addr)
  }  
  
  static __inline void
 -lidt(void *p)
 +lidt(void *v_p)
  {
 -	__asm volatile("lidt (%0)" : : "r" (p));
 +	uint32_t *p = v_p;
 +	__asm volatile("lidt %0" : : "m" (*p));
  }
  
  static __inline void
 
 With the existing code, if setregion() gets inlined, then the assignments
 are discared because gcc doesn't detect that the lidt() code references
 the 'region' variable.
 
 Compiling with -Os or -O3 seems to be enough to inline setregion().
 
 I'm not 100% certain the above is enough to guarantee that both
 assignements are done - but they do seem to be in my tests.
 
 I'm not sure how many other places have similar __asm() statements.
 amd64 and xen have the exact equivalent, but similar things could
 happen elsewhere.
 
 	David
 
 -- 
 David Laight: david@l8s.co.uk