]> git.baikalelectronics.ru Git - kernel.git/commit
x86/fpu: Reset MXCSR to default in kernel_fpu_begin()
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>
Tue, 16 Jun 2020 09:12:57 +0000 (11:12 +0200)
committerBorislav Petkov <bp@suse.de>
Mon, 29 Jun 2020 08:02:00 +0000 (10:02 +0200)
commit2fa2a2f4068b9e77ff771cc70ec5f32e97944fd2
treec5d8c330779d14854cdc27618bfd323700c9655b
parente86d80f3f3da4d1072ca810bbe97a8ef4bd674b0
x86/fpu: Reset MXCSR to default in kernel_fpu_begin()

Previously, kernel floating point code would run with the MXCSR control
register value last set by userland code by the thread that was active
on the CPU core just before kernel call. This could affect calculation
results if rounding mode was changed, or a crash if a FPU/SIMD exception
was unmasked.

Restore MXCSR to the kernel's default value.

 [ bp: Carve out from a bigger patch by Petteri, add feature check, add
   FNINIT call too (amluto). ]

Signed-off-by: Petteri Aimonen <jpa@git.mail.kapsi.fi>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://bugzilla.kernel.org/show_bug.cgi?id=207979
Link: https://lkml.kernel.org/r/20200624114646.28953-2-bp@alien8.de
arch/x86/include/asm/fpu/internal.h
arch/x86/kernel/fpu/core.c