acrn-kernel/arch/mips
Xi Ruoyao e333bbb557 mips: Call lose_fpu(0) before initializing fcr31 in mips_set_personality_nan
commit 59be5c35850171e307ca5d3d703ee9ff4096b948 upstream.

If we still own the FPU after initializing fcr31, when we are preempted
the dirty value in the FPU will be read out and stored into fcr31,
clobbering our setting.  This can cause an improper floating-point
environment after execve().  For example:

    zsh% cat measure.c
    #include <fenv.h>
    int main() { return fetestexcept(FE_INEXACT); }
    zsh% cc measure.c -o measure -lm
    zsh% echo $((1.0/3)) # raising FE_INEXACT
    0.33333333333333331
    zsh% while ./measure; do ; done
    (stopped in seconds)

Call lose_fpu(0) before setting fcr31 to prevent this.

Closes: https://lore.kernel.org/linux-mips/7a6aa1bbdbbe2e63ae96ff163fab0349f58f1b9e.camel@xry111.site/
Fixes: 9b26616c8d ("MIPS: Respect the ISA level in FCSR handling")
Cc: stable@vger.kernel.org
Signed-off-by: Xi Ruoyao <xry111@xry111.site>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-01-31 16:17:12 -08:00
..
alchemy MIPS: Alchemy: Fix an out-of-bound access in db1550_dev_setup() 2024-01-25 15:27:45 -08:00
ar7
ath25
ath79
bcm47xx
bcm63xx
bmips
boot MIPS: dts: loongson: drop incorrect dwmac fallback compatible 2024-01-20 11:50:07 +01:00
cavium-octeon
cobalt
configs
crypto
dec
fw
generic
include mips: dmi: Fix early remap on MIPS32 2024-01-25 15:27:45 -08:00
ingenic
jazz
kernel mips: Call lose_fpu(0) before initializing fcr31 in mips_set_personality_nan 2024-01-31 16:17:12 -08:00
kvm MIPS: KVM: Fix a build warning about variable set but not used 2023-12-03 07:32:09 +01:00
lantiq MIPS: lantiq: register smp_ops on non-smp platforms 2024-01-31 16:17:12 -08:00
lib
loongson2ef MIPS: Loongson: Move arch cflags to MIPS top level Makefile 2023-08-03 10:23:50 +02:00
loongson32
loongson64 MIPS: Loongson64: Enable DMA noncoherent support 2023-12-13 18:39:29 +01:00
math-emu
mm mips: Fix max_mapnr being uninitialized on early stages 2024-01-31 16:16:59 -08:00
mti-malta
n64
net
pci
pic32
power
ralink
rb532
sgi-ip22
sgi-ip27
sgi-ip30
sgi-ip32
sibyte
sni
tools
txx9
vdso MIPS: Use "grep -E" instead of "egrep" 2023-09-23 11:11:08 +02:00
Kbuild
Kbuild.platforms
Kconfig MIPS: Loongson64: Enable DMA noncoherent support 2023-12-13 18:39:29 +01:00
Kconfig.debug
Makefile MIPS: Use "grep -E" instead of "egrep" 2023-09-23 11:11:08 +02:00
Makefile.postlink