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
This commit is contained in:
Nathan Whitehorn 2009-04-19 06:30:00 +00:00
parent f2cc3668fc
commit 55fba05bf5
2 changed files with 13 additions and 3 deletions

View File

@ -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;

View File

@ -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_ */