kernel_samsung_a53x/arch/mips
Xi Ruoyao ff49d5abe8 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: 9b26616c8d9d ("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-11-18 12:13:07 +01:00
..
alchemy MIPS: Alchemy: Fix an out-of-bound access in db1550_dev_setup() 2024-11-18 12:12:48 +01:00
ar7 Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ath25 Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ath79 Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
bcm47xx Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
bcm63xx Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
bmips Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
boot Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cavium-octeon Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cobalt Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
configs Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
crypto Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
dec Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
fw Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
generic Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
include mips: dmi: Fix early remap on MIPS32 2024-11-18 12:12:48 +01:00
ingenic Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
jazz Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
kernel mips: Call lose_fpu(0) before initializing fcr31 in mips_set_personality_nan 2024-11-18 12:13:07 +01:00
kvm MIPS: KVM: Fix a build warning about variable set but not used 2024-11-18 12:10:56 +01:00
lantiq Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
lib Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
loongson2ef Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
loongson32 Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
loongson64 Revert "MIPS: Loongson64: Enable DMA noncoherent support" 2024-11-18 12:12:04 +01:00
math-emu Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mm Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mti-malta Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
net Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
netlogic Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
oprofile Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
pci Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
pic32 Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
pistachio Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
power Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ralink Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
rb532 Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sgi-ip22 Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sgi-ip27 Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sgi-ip30 Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sgi-ip32 Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sibyte Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sni Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
tools Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
txx9 Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
vdso Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
vr41xx Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Kbuild Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Kbuild.platforms Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Kconfig Revert "MIPS: Loongson64: Enable DMA noncoherent support" 2024-11-18 12:12:04 +01:00
Kconfig.debug Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Makefile Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Makefile.postlink Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00