From owner-svn-src-stable-8@FreeBSD.ORG Tue Oct 26 14:56:47 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 53745106566B; Tue, 26 Oct 2010 14:56:47 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 409F68FC14; Tue, 26 Oct 2010 14:56:47 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o9QEulqh041420; Tue, 26 Oct 2010 14:56:47 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o9QEulei041414; Tue, 26 Oct 2010 14:56:47 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201010261456.o9QEulei041414@svn.freebsd.org> From: Nathan Whitehorn Date: Tue, 26 Oct 2010 14:56:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214376 - in stable/8/sys/powerpc: aim include X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Oct 2010 14:56:47 -0000 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 */