Module Name:    src
Committed By:   matt
Date:           Mon Mar 23 17:42:02 UTC 2015

Modified Files:
        src/sys/arch/arm/vfp: vfp_init.c

Log Message:
Fix some inverted return values.  Don't return SIGILL if there is an active
FPU exception.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/arch/arm/vfp/vfp_init.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/vfp/vfp_init.c
diff -u src/sys/arch/arm/vfp/vfp_init.c:1.46 src/sys/arch/arm/vfp/vfp_init.c:1.47
--- src/sys/arch/arm/vfp/vfp_init.c:1.46	Fri Mar 20 01:27:34 2015
+++ src/sys/arch/arm/vfp/vfp_init.c	Mon Mar 23 17:42:02 2015
@@ -1,4 +1,4 @@
-/*      $NetBSD: vfp_init.c,v 1.46 2015/03/20 01:27:34 matt Exp $ */
+/*      $NetBSD: vfp_init.c,v 1.47 2015/03/23 17:42:02 matt Exp $ */
 
 /*
  * Copyright (c) 2008 ARM Ltd
@@ -397,15 +397,19 @@ vfp_handler(u_int address, u_int insn, t
 	}
 
 	/*
-	 * If we are just changing/fetching FPSCR, don't bother loading it.
+	 * If we are just changing/fetching FPSCR, don't bother loading it
+	 * just emulate the instruction.
 	 */
 	if (!vfp_fpscr_handler(address, insn, frame, fault_code))
-		return 1;
+		return 0;
 
-	/* if we already own the FPU and it's enabled, raise SIGILL */
+	/* 
+	 * If we already own the FPU and it's enabled (and no exception), raise
+	 * SIGILL.  If there is an exception, drop through to raise a SIGFPE.
+	 */
 	if (curcpu()->ci_pcu_curlwp[PCU_FPU] == curlwp
-	    && (armreg_fpexc_read() & VFP_FPEXC_EN) != 0)
-		return 0;
+	    && (armreg_fpexc_read() & (VFP_FPEXC_EX|VFP_FPEXC_EN)) == VFP_FPEXC_EN)
+		return 1;
 
 	/*
 	 * Make sure we own the FP.
@@ -477,7 +481,7 @@ neon_handler(u_int address, u_int insn, 
 	/* if we already own the FPU and it's enabled, raise SIGILL */
 	if (curcpu()->ci_pcu_curlwp[PCU_FPU] == curlwp
 	    && (armreg_fpexc_read() & VFP_FPEXC_EN) != 0)
-		return 0;
+		return 1;
 
 	pcu_load(&arm_vfp_ops);
 

Reply via email to