x86/mmx: Use KFPU_387 for MMX string operations
authorAndy Lutomirski <luto@kernel.org>
Thu, 21 Jan 2021 05:09:49 +0000 (21:09 -0800)
committerBorislav Petkov <bp@suse.de>
Thu, 21 Jan 2021 12:39:36 +0000 (13:39 +0100)
commit67de8dca50c027ca0fa3b62a488ee5035036a0da
treef695201938d5c13f15e02832df2b34f70d82c771
parente45122893a9870813f9bd7b4add4f613e6f29008
x86/mmx: Use KFPU_387 for MMX string operations

The default kernel_fpu_begin() doesn't work on systems that support XMM but
haven't yet enabled CR4.OSFXSR.  This causes crashes when _mmx_memcpy() is
called too early because LDMXCSR generates #UD when the aforementioned bit
is clear.

Fix it by using kernel_fpu_begin_mask(KFPU_387) explicitly.

Fixes: 7ad816762f9b ("x86/fpu: Reset MXCSR to default in kernel_fpu_begin()")
Reported-by: Krzysztof Mazur <krzysiek@podlesie.net>
Signed-off-by: Andy Lutomirski <luto@kernel.org>
Signed-off-by: Borislav Petkov <bp@suse.de>
Tested-by: Krzysztof Piotr Olędzki <ole@ans.pl>
Tested-by: Krzysztof Mazur <krzysiek@podlesie.net>
Cc: <stable@vger.kernel.org>
Link: https://lkml.kernel.org/r/e7bf21855fe99e5f3baa27446e32623358f69e8d.1611205691.git.luto@kernel.org
arch/x86/lib/mmx_32.c