From patchwork Fri Nov 27 17:25:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Maciej W. Rozycki" X-Patchwork-Id: 9842 Received: (qmail 15092 invoked by alias); 27 Nov 2015 17:25:21 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 15075 invoked by uid 89); 27 Nov 2015 17:25:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mailapp01.imgtec.com Date: Fri, 27 Nov 2015 17:25:09 +0000 From: "Maciej W. Rozycki" To: Subject: [PATCH] MIPS: Wire FCSR.ABS2008 to FCSR.NAN2008 Message-ID: User-Agent: Alpine 2.00 (DEB 1167 2008-08-23) MIME-Version: 1.0 Revision 3.50 of the MIPS architecture defined FCSR ABS2008 and NAN2008 bits as optionally read/write [1][2]. No hardware implementation has ever made use of this feature though. For example the first processor to implement these bits, the MIPS32r3 proAptiv core, has both bits read-only, hardwired to 1 [3]. And as from revision 5.03 of the MIPS architecture the bits are required to be read-only, preset by hardware [4][5]. Additionally all hardware implementations in existence have the bits hardwired both to the same value, either of `0' and `1'. These bits may still be read/write or hardwired to opposite values in simulated hardware implementations such as QEMU or the FPU emulator included with the Linux kernel. However to match real hardware implementations the Linux kernel will set FCSR ABS2008 and NAN2008 bits both to the same value where possible, reflecting the setting of the EF_MIPS_NAN2008 ELF file header bit. Therefore update the bit patterns in macro definitions we use for the control word, in the 2008-NaN encoding mode, so that both bits have the same value in a given bit pattern. Additionally mark the FCSR ABS2008 bit as reserved, so that high-level calls to change the control word do not affect the bit. This covers the regular FPU configurations, only leaving exotic corner cases with the value of FCSR control word initially set by the kernel different to what our code thinks it is. To address the remaining cases the AT_FPUCW auxiliary vector entry would have to be implemented in the Linux kernel, which currently is not. References: [1] "MIPS Architecture For Programmers, Volume I-A: Introduction to the MIPS32 Architecture", MIPS Technologies, Inc., Document Number: MD00082, Revision 3.50, September 20, 2012, Table 5.5 "FCSR Register Field Descriptions", p. 80 [2] "MIPS Architecture For Programmers, Volume I-A: Introduction to the MIPS64 Architecture", MIPS Technologies, Inc., Document Number: MD00083, Revision 3.50, September 20, 2012, Table 5.5 "FCSR Register Field Descriptions", p. 82 [3] "MIPS32 proAptiv Multiprocessing System Software User's Manual", MIPS Technologies, Inc., Document Number: MD00878, Revision 01.22, May 14, 2013, Table 12.10 "FCSR Bit Field Descriptions", p. 570 [4] "MIPS Architecture For Programmers, Volume I-A: Introduction to the MIPS32 Architecture", MIPS Technologies, Inc., Document Number: MD00082, Revision 5.03, Sept. 9, 2013, Table 5.7 "FCSR Register Field Descriptions", p. 82 [5] "MIPS Architecture For Programmers, Volume I-A: Introduction to the MIPS64 Architecture", MIPS Technologies, Inc., Document Number: MD00083, Revision 5.03, Sept. 9, 2013, Table 5.7 "FCSR Register Field Descriptions", p. 84 sysdeps/mips/ * fpu_control.h (_FPU_RESERVED): Include ABS2008. (_FPU_DEFAULT, _FPU_IEEE) [__mips_nan2008]: Set ABS2008. --- OK to apply? Maciej glibc-mips-abs-2008-fpucw.diff Index: glibc/sysdeps/mips/fpu_control.h =================================================================== --- glibc.orig/sysdeps/mips/fpu_control.h 2015-05-20 23:10:41.000000000 +0100 +++ glibc/sysdeps/mips/fpu_control.h 2015-07-07 22:52:20.728281676 +0100 @@ -93,20 +93,20 @@ extern fpu_control_t __fpu_control; /* Mask for rounding control. */ #define _FPU_RC_MASK 0x3 -#define _FPU_RESERVED 0xfe840000 /* Reserved bits in cw, incl NAN2008. */ +#define _FPU_RESERVED 0xfe8c0000 /* Reserved bits in cw, incl ABS/NAN2008. */ /* The fdlibm code requires strict IEEE double precision arithmetic, and no interrupts for exceptions, rounding to nearest. */ #ifdef __mips_nan2008 -# define _FPU_DEFAULT 0x00040000 +# define _FPU_DEFAULT 0x000C0000 #else # define _FPU_DEFAULT 0x00000000 #endif /* IEEE: same as above, but exceptions. */ #ifdef __mips_nan2008 -# define _FPU_IEEE 0x00040F80 +# define _FPU_IEEE 0x000C0F80 #else # define _FPU_IEEE 0x00000F80 #endif