acrn-kernel/arch/mips/kernel
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
..
syscalls
.gitignore
Makefile
access-helper.h
asm-offsets.c
bmips_5xxx_init.S
bmips_vec.S
branch.c
cacheinfo.c
cevt-bcm1480.c
cevt-ds1287.c
cevt-gt641xx.c
cevt-r4k.c
cevt-sb1250.c
cevt-txx9.c
cmpxchg.c
cps-vec-ns16550.S
cps-vec.S
cpu-probe.c MIPS: Loongson: Fix cpu_probe_loongson() again 2023-07-23 13:49:33 +02:00
cpu-r3k-probe.c
crash.c
crash_dump.c
csrc-bcm1480.c
csrc-ioasic.c
csrc-r4k.c
csrc-sb1250.c
early_printk.c
early_printk_8250.c
elf.c mips: Call lose_fpu(0) before initializing fcr31 in mips_set_personality_nan 2024-01-31 16:17:12 -08:00
entry.S
fpu-probe.c
fpu-probe.h
ftrace.c
genex.S
gpio_txx9.c
head.S
i8253.c
idle.c
irq-gt641xx.c
irq-msc01.c
irq.c
irq_txx9.c
jump_label.c
kgdb.c
kprobes.c
linux32.c
machine_kexec.c
mcount.S
mips-cm.c
mips-cpc.c
mips-mt-fpaff.c
mips-mt.c
mips-r2-to-r6-emul.c
module.c
octeon_switch.S
perf_event.c
perf_event_mipsxx.c
perf_regs.c
pm-cps.c
pm.c
probes-common.h
proc.c
process.c MIPS: kernel: Clear FPU states when setting up kernel threads 2023-12-13 18:39:28 +01:00
prom.c
ptrace.c
ptrace32.c
r4k-bugs64.c
r4k_fpu.S
r4k_switch.S
r2300_fpu.S
r2300_switch.S
relocate.c
relocate_kernel.S
reset.c
rtlx-cmp.c
rtlx-mt.c
rtlx.c
scall32-o32.S
scall64-n32.S
scall64-n64.S
scall64-o32.S
segment.c
setup.c mips: Fix incorrect max_low_pfn adjustment 2024-01-25 15:27:45 -08:00
signal-common.h
signal.c
signal32.c
signal_n32.c
signal_o32.c
smp-bmips.c
smp-cmp.c
smp-cps.c
smp-mt.c
smp-up.c
smp.c mips/smp: Call rcutree_report_cpu_starting() earlier 2024-01-25 15:27:39 -08:00
spinlock_test.c
spram.c
stacktrace.c
sync-r4k.c
syscall.c
sysrq.c
time.c
topology.c
traps.c
unaligned.c
uprobes.c
vdso.c
vmlinux.lds.S
vpe-cmp.c
vpe-mt.c
vpe.c
watch.c