Re: [PATCH 1/2] x86/fpu: Reset MXCSR to default in kernel_fpu_begin()

From: Andy Lutomirski
Date: Fri Jun 19 2020 - 14:01:59 EST


On Fri, Jun 19, 2020 at 10:41 AM Borislav Petkov <bp@xxxxxxxxx> wrote:
>
> From: Petteri Aimonen <jpa@xxxxxxxxxxxxxxxxx>
>
> 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). ]

Acked-by: Andy Lutomirski <luto@xxxxxxxxxx>

but:

shouldn't kernel_fpu_begin() end with a barrier()?