Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 19 Apr 2009 06:30:01 +0000 (UTC)
From:      Nathan Whitehorn <nwhitehorn@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r191261 - in head/sys/powerpc: aim include
Message-ID:  <200904190630.n3J6U14U001240@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: nwhitehorn
Date: Sun Apr 19 06:30:00 2009
New Revision: 191261
URL: http://svn.freebsd.org/changeset/base/191261

Log:
  Fix a typo in the SRR1 comparison for program exceptions. While here,
  replace magic numbers with constants to keep this from happening again.
  
  Without this fix, some programs would occasionally get SIGTRAP instead
  of SIGILL on an illegal instruction. This affected Altivec detection
  in pixman, and possibly other software.
  
  Reported by:	Andreas Tobler
  MFC after:	1 week

Modified:
  head/sys/powerpc/aim/trap.c
  head/sys/powerpc/include/trap_aim.h

Modified: head/sys/powerpc/aim/trap.c
==============================================================================
--- head/sys/powerpc/aim/trap.c	Sun Apr 19 05:34:07 2009	(r191260)
+++ head/sys/powerpc/aim/trap.c	Sun Apr 19 06:30:00 2009	(r191261)
@@ -208,9 +208,8 @@ trap(struct trapframe *frame)
 			break;
 
 		case EXC_PGM:
-			/* XXX temporarily */
-			/* XXX: Magic Number? */
-			if (frame->srr1 & 0x0002000)
+			/* Identify the trap reason */
+			if (frame->srr1 & EXC_PGM_TRAP)
 				sig = SIGTRAP;
  			else
 				sig = SIGILL;

Modified: head/sys/powerpc/include/trap_aim.h
==============================================================================
--- head/sys/powerpc/include/trap_aim.h	Sun Apr 19 05:34:07 2009	(r191260)
+++ head/sys/powerpc/include/trap_aim.h	Sun Apr 19 06:30:00 2009	(r191261)
@@ -103,4 +103,15 @@
 #define EXC_ALI_RST(dsisr) ((dsisr >> 5) & 0x1f)   /* source or target */
 #define EXC_ALI_RA(dsisr) (dsisr & 0x1f)
 
+/*
+ * SRR1 bits for program exception traps. These identify what caused
+ * the program exception. See section 6.5.9 of the Power ISA Version
+ * 2.05.
+ */
+
+#define	EXC_PGM_FPENABLED	(1UL << 20)
+#define	EXC_PGM_ILLEGAL		(1UL << 19)
+#define	EXC_PGM_PRIV		(1UL << 18)
+#define	EXC_PGM_TRAP		(1UL << 17)
+
 #endif	/* _POWERPC_TRAP_H_ */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200904190630.n3J6U14U001240>