Subject: Re: NetBSD2.0/sparc not ready for prime time?
To: Michael <macallan18@earthlink.net>
From: Chuck Silvers <chuq@chuq.com>
List: port-sparc
Date: 02/02/2005 08:52:44
--VS++wcV0S1rZb1Fb
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
please try the attached patch for the sun4c-specific pthreads problem.
you'll need both a new kernel and a new libpthread.so
(built with the fixed lock.h)
-Chuck
--VS++wcV0S1rZb1Fb
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="diff.sparc.pthread"
Index: src/sys/arch/sparc/include/lock.h
===================================================================
RCS file: /cvsroot/src/sys/arch/sparc/include/lock.h,v
retrieving revision 1.17
diff -u -p -r1.17 lock.h
--- src/sys/arch/sparc/include/lock.h 20 Apr 2004 08:48:03 -0000 1.17
+++ src/sys/arch/sparc/include/lock.h 2 Feb 2005 16:47:13 -0000
@@ -57,7 +57,7 @@ static __inline__ int __ldstub(__cpu_sim
int v;
__asm __volatile("ldstub [%1],%0"
- : "=r" (v)
+ : "=&r" (v)
: "r" (addr)
: "memory");
Index: src/sys/arch/sparc/sparc/trap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sparc/sparc/trap.c,v
retrieving revision 1.155
diff -u -p -r1.155 trap.c
--- src/sys/arch/sparc/sparc/trap.c 28 Aug 2004 17:53:02 -0000 1.155
+++ src/sys/arch/sparc/sparc/trap.c 2 Feb 2005 16:47:22 -0000
@@ -947,6 +947,20 @@ mem_access_fault(type, ser, v, pc, psr,
goto fault;
}
atype = ser & SER_WRITE ? VM_PROT_WRITE : VM_PROT_READ;
+ if ((ser & SER_PROT) && atype == VM_PROT_READ && type != T_TEXTFAULT) {
+ int inst;
+
+ /*
+ * The hardware reports protection faults by the atomic
+ * load/store instructions as read faults. If the faulting
+ * instruction is one of those, indicate that this fault is
+ * both read and write.
+ */
+ inst = fuword((void *)pc);
+ if ((inst & 0xc1680000) == 0xc0680000) {
+ atype = VM_PROT_READ | VM_PROT_WRITE;
+ }
+ }
va = trunc_page(v);
if (psr & PSR_PS) {
extern char Lfsbail[];
--VS++wcV0S1rZb1Fb--