Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 26 Oct 2010 14:56:47 +0000 (UTC)
From:      Nathan Whitehorn <nwhitehorn@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r214376 - in stable/8/sys/powerpc: aim include
Message-ID:  <201010261456.o9QEulei041414@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: nwhitehorn
Date: Tue Oct 26 14:56:46 2010
New Revision: 214376
URL: http://svn.freebsd.org/changeset/base/214376

Log:
  MFC r213456:
  Handle vector assist traps without a kernel panic, by setting denormalized
  values to zero. A correct solution would involve emulating vector
  operations on denormalized values, but this has little effect on accuracy
  and is much less complicated for now.

Modified:
  stable/8/sys/powerpc/aim/machdep.c
  stable/8/sys/powerpc/aim/trap.c
  stable/8/sys/powerpc/include/altivec.h
  stable/8/sys/powerpc/include/pcb.h
  stable/8/sys/powerpc/include/trap_aim.h
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/powerpc/aim/machdep.c
==============================================================================
--- stable/8/sys/powerpc/aim/machdep.c	Tue Oct 26 14:06:59 2010	(r214375)
+++ stable/8/sys/powerpc/aim/machdep.c	Tue Oct 26 14:56:46 2010	(r214376)
@@ -474,8 +474,8 @@ powerpc_init(u_int startkernel, u_int en
 	bcopy(generictrap, (void *)EXC_SC,   (size_t)&trapsize);
 	bcopy(generictrap, (void *)EXC_FPA,  (size_t)&trapsize);
 	bcopy(generictrap, (void *)EXC_VEC,  (size_t)&trapsize);
-	bcopy(generictrap, (void *)EXC_VECAST, (size_t)&trapsize);
-	bcopy(generictrap, (void *)EXC_THRM, (size_t)&trapsize);
+	bcopy(generictrap, (void *)EXC_VECAST_G4, (size_t)&trapsize);
+	bcopy(generictrap, (void *)EXC_VECAST_G5, (size_t)&trapsize);
 	__syncicache(EXC_RSVD, EXC_LAST - EXC_RSVD);
 
 	/*

Modified: stable/8/sys/powerpc/aim/trap.c
==============================================================================
--- stable/8/sys/powerpc/aim/trap.c	Tue Oct 26 14:06:59 2010	(r214375)
+++ stable/8/sys/powerpc/aim/trap.c	Tue Oct 26 14:56:46 2010	(r214376)
@@ -196,9 +196,19 @@ trap(struct trapframe *frame)
 			enable_vec(td);
 			break;
 
-		case EXC_VECAST:
-			printf("Vector assist exception!\n");
-			sig = SIGILL;
+		case EXC_VECAST_G4:
+		case EXC_VECAST_G5:
+			/*
+			 * We get a VPU assist exception for IEEE mode
+			 * vector operations on denormalized floats.
+			 * Emulating this is a giant pain, so for now,
+			 * just switch off IEEE mode and treat them as
+			 * zero.
+			 */
+
+			save_vec(td);
+			td->td_pcb->pcb_vec.vscr |= ALTIVEC_VSCR_NJ;
+			enable_vec(td);
 			break;
 
 		case EXC_ALI:

Modified: stable/8/sys/powerpc/include/altivec.h
==============================================================================
--- stable/8/sys/powerpc/include/altivec.h	Tue Oct 26 14:06:59 2010	(r214375)
+++ stable/8/sys/powerpc/include/altivec.h	Tue Oct 26 14:56:46 2010	(r214376)
@@ -29,6 +29,9 @@
 #ifndef	_MACHINE_ALTIVEC_H_
 #define	_MACHINE_ALTIVEC_H_
 
+#define ALTIVEC_VSCR_NJ		0x00010000	/* Enable non-Java mode */
+#define ALTIVEC_VSCR_SAT	0x00000001	/* Saturation status bit */
+
 void    enable_vec(struct thread *);
 void    save_vec(struct thread *);
 

Modified: stable/8/sys/powerpc/include/pcb.h
==============================================================================
--- stable/8/sys/powerpc/include/pcb.h	Tue Oct 26 14:06:59 2010	(r214375)
+++ stable/8/sys/powerpc/include/pcb.h	Tue Oct 26 14:56:46 2010	(r214376)
@@ -58,7 +58,7 @@ struct pcb {
 		uint32_t vr[32][4];
 		register_t vrsave;
 		register_t spare[2];
-		register_t vscr;
+		register_t vscr;	/* aligned at vector element 3 */
 	} pcb_vec __attribute__((aligned(16)));	/* Vector processor */
 	unsigned int	pcb_veccpu;		/* which CPU had our vector
 							stuff. */

Modified: stable/8/sys/powerpc/include/trap_aim.h
==============================================================================
--- stable/8/sys/powerpc/include/trap_aim.h	Tue Oct 26 14:06:59 2010	(r214375)
+++ stable/8/sys/powerpc/include/trap_aim.h	Tue Oct 26 14:56:46 2010	(r214376)
@@ -52,9 +52,12 @@
 /* The following is only available on the 601: */
 #define	EXC_RUNMODETRC	0x2000		/* Run Mode/Trace Exception */
 
+/* The following are only available on 970(G5): */
+#define	EXC_VECAST_G5	0x1700		/* AltiVec Assist */
+
 /* The following are only available on 7400(G4): */
 #define	EXC_VEC		0x0f20		/* AltiVec Unavailable */
-#define	EXC_VECAST	0x1600		/* AltiVec Assist */
+#define	EXC_VECAST_G4	0x1600		/* AltiVec Assist */
 
 /* The following are only available on 604/750/7400: */
 #define	EXC_PERF	0x0f00		/* Performance Monitoring */



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