linux/arch/mips
Maciej W. Rozycki 232b6ec5df MIPS: math-emu: Make ABS.fmt and NEG.fmt arithmetic again
The ABS.fmt and NEG.fmt instructions have been specified as arithmetic
in the MIPS architecture, which in particular implies handling NaN data
in the usual way with qNaN bit patterns propagated unchanged and sNaN
bit patterns signalling the usual IEEE 754 Invalid Operation exception
and quieted by default.

A series of changes applied over time to our implementation:

c5033d78 [MIPS] ieee754[sd]p_neg workaround
cea2be44 MIPS: Fix abs.[sd] and neg.[sd] emulation for NaN operands

has led to the current situation where the sign bit is updated according
to the operation requested even for NaN inputs.  This is according to
these commits a workaround so that broken binaries produced by GCC
disregarding the properties of these instructions have a chance to work.

For sNaN inputs this remains within IEEE Std 754 as the standard leaves
the choice of output qNaN bit patterns produced under the default
Invalid Operation exception handling for individual sNaN input bit
patterns to implementer's discretion, even though it still recommends as
much NaN input information to be preserved in NaN outputs.

For qNaN inputs however it violates the standard as it requires a qNaN
input bit patterns to propagate unchanged to output.

This is also unlike real MIPS FPU hardware behaves where sNaN and/or
qNaN processing has been fully implemented with no Unimplemented
Operation exception signalled.  Such hardware propagates any input qNaN
bit pattern unchanged.  It also quiets any input sNaN bit pattern in an
implementer-specific manner, for example the MIPS 74Kf processor returns
the default qNaN pattern with the sign bit always clear and the Broadcom
SB-1 and BMIPS5000 processors propagate the input sNaN bit pattern with
the sign bit unchanged and the quiet bit first cleared in the trailing
significand field and then the next lower bit set if clearing the quiet
bit left the field with no other bit set.

Especially the latter observation indicates the limited usefulness of
the workaround as it will cover many hardware configurations, but not
all of them, only making it harder to discover such broken binaries that
need to be recompiled with GCC told to avoid the use of ABS.fmt and
NEG.fmt instructions where non-arithmetic semantics is required by the
algorithm used.

Revert the damage done by the series of changes then, and take the
opportunity to simplify implementation by calling `ieee754dp_sub' and
`ieee754dp_add' as required and also the rounding mode set towards -Inf
temporarily so that the sign of 0 is correctly handled.

Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/9710/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
2015-04-08 01:10:34 +02:00
..
alchemy Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus 2015-02-21 19:41:38 -08:00
ar7 MIPS: AR7: Replace mac address parsing 2015-04-02 13:54:22 +02:00
ath25 MIPS: ath25: add Wireless device support 2014-11-24 07:45:29 +01:00
ath79 MIPS: ath79: Increase max memory limit to 256MByte 2015-04-01 17:21:57 +02:00
bcm47xx MIPS: BCM47xx: Move filling most of SPROM to the generic function 2015-04-02 14:00:13 +02:00
bcm63xx MIPS: Remove useless parentheses 2014-11-24 07:44:49 +01:00
bmips MIPS: BMIPS: restrict DTB selection to BMIPS_GENERIC 2015-04-01 17:22:04 +02:00
boot MIPS: Reduce kernel image size for !CONFIG_DEBUG_ZBOOT 2015-04-02 13:54:25 +02:00
cavium-octeon MIPS: Octeon: Make octeon-md5 driver endian-agnostic 2015-04-01 17:22:15 +02:00
cobalt
configs MIPS: XPA: Add new configuration file. 2015-04-01 17:21:45 +02:00
dec
emma
fw MIPS: ARC: Use __noreturn / unreachable in ARC termination functions. 2015-01-13 16:04:27 +01:00
include MIPS: math-emu: Define IEEE 754-2008 feature control bits 2015-04-08 01:10:31 +02:00
jazz
jz4740 MIPS: jz4740: Implement read_sched_clock 2015-04-01 17:21:31 +02:00
kernel MIPS: math-emu: Set FIR feature flags for full emulation 2015-04-08 01:10:25 +02:00
kvm KVM: MIPS: Enable after disabling interrupt 2015-03-02 19:18:12 -03:00
lantiq MIPS: mark prom_free_prom_memory() everywhere with __init 2015-04-01 17:21:58 +02:00
lasat MIPS: Lasat: Remove unused function from sysctl code. 2015-04-02 13:54:22 +02:00
lib MIPS: csum_partial: Improve instruction parallelism. 2015-04-01 17:22:11 +02:00
loongson MIPS: Loongson-3: Add chipset ACPI platform driver 2015-04-01 17:22:18 +02:00
loongson1 MIPS: Loongson1B: Add a clockevent/clocksource using PWM Timer 2014-11-24 07:45:09 +01:00
math-emu MIPS: math-emu: Make ABS.fmt and NEG.fmt arithmetic again 2015-04-08 01:10:34 +02:00
mm MIPS: c-r4k.c: Fix the 74K D-cache alias erratum workaround 2015-04-02 13:54:18 +02:00
mti-malta MIPS: Malta: malta-time: Ensure GIC counter is running 2015-03-31 12:04:13 +02:00
mti-sead3 MIPS: SEAD3: Combine all platform device registrations in one file. 2015-04-02 17:07:26 +02:00
net module: remove mod arg from module_free, rename module_memfree(). 2015-01-20 11:38:33 +10:30
netlogic MIPS: Netlogic: Add built-in dts for XLP5xx boards 2015-04-01 17:21:54 +02:00
oprofile MIPS: Add R16000 detection 2015-04-01 17:22:13 +02:00
paravirt
pci MIPS: PCI: Add a hook for IORESOURCE_BUS in pci_controller/bridge_controller 2015-04-01 17:22:16 +02:00
pistachio MIPS: Add support for the IMG Pistachio SoC 2015-03-31 12:04:12 +02:00
pmcs-msp71xx kconfig: use bool instead of boolean for type definition attributes 2015-01-07 13:08:04 +01:00
pnx833x
power MIPS: Hibernate: Restructure files and functions 2015-04-01 17:22:09 +02:00
ralink Driver core patches for 3.19-rc1 2014-12-14 16:10:09 -08:00
rb532 MIPS: Replace use of phys_t with phys_addr_t. 2014-11-24 22:47:31 +01:00
sgi-ip22 MIPS: ip22-gio: Remove legacy suspend/resume support 2015-02-20 13:30:55 +01:00
sgi-ip27 MIPS: sgi-ip27: Implement read_sched_clock 2015-04-01 17:21:29 +02:00
sgi-ip32 MIPS: IP32: ip32-platform is not a module. 2015-04-01 17:22:13 +02:00
sibyte MIPS: Replace use of phys_t with phys_addr_t. 2014-11-24 22:47:31 +01:00
sni
txx9 Driver core patches for 3.19-rc1 2014-12-14 16:10:09 -08:00
vr41xx
Kbuild
Kbuild.platforms MIPS: bcm3384: Rename "bcm3384" target to "bmips" 2015-04-01 17:21:35 +02:00
Kconfig MIPS: perf: Add hardware perf events support for Loongson-3 2015-04-01 17:22:17 +02:00
Kconfig.debug MIPS: kernel: elf: Improve the overall ABI and FPU mode checks 2015-02-17 15:37:39 +00:00
Makefile MIPS: Add dtbs_install target 2015-04-01 17:21:34 +02:00