summaryrefslogtreecommitdiff
path: root/arch/x86/include/asm/fpu/api.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2021-02-20 20:07:44 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2021-02-20 20:07:44 -0800
commit8831d718aa5a9540aaeb527a582af5fc140aed6e (patch)
tree0ad3bfa743e5201654da6dbb6f09d18c5a6797f5 /arch/x86/include/asm/fpu/api.h
parentd00c4ed02e90c1a4290acdd4f9bc4d056a573859 (diff)
parent0a74d61c7d842b583f33f74d7a9e93201826f4c5 (diff)
downloadlinux-8831d718aa5a9540aaeb527a582af5fc140aed6e.tar.gz
linux-8831d718aa5a9540aaeb527a582af5fc140aed6e.tar.bz2
linux-8831d718aa5a9540aaeb527a582af5fc140aed6e.zip
Merge tag 'x86_fpu_for_v5.12' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 FPU updates from Borislav Petkov: "x86 fpu usage optimization and cleanups: - make 64-bit kernel code which uses 387 insns request a x87 init (FNINIT) explicitly when using the FPU - misc cleanups" * tag 'x86_fpu_for_v5.12' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/fpu/xstate: Use sizeof() instead of a constant x86/fpu/64: Don't FNINIT in kernel_fpu_begin() x86/fpu: Make the EFI FPU calling convention explicit
Diffstat (limited to 'arch/x86/include/asm/fpu/api.h')
-rw-r--r--arch/x86/include/asm/fpu/api.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/arch/x86/include/asm/fpu/api.h b/arch/x86/include/asm/fpu/api.h
index 67a4f1cb2aac..ed33a14188f6 100644
--- a/arch/x86/include/asm/fpu/api.h
+++ b/arch/x86/include/asm/fpu/api.h
@@ -32,7 +32,19 @@ extern void fpregs_mark_activate(void);
/* Code that is unaware of kernel_fpu_begin_mask() can use this */
static inline void kernel_fpu_begin(void)
{
+#ifdef CONFIG_X86_64
+ /*
+ * Any 64-bit code that uses 387 instructions must explicitly request
+ * KFPU_387.
+ */
+ kernel_fpu_begin_mask(KFPU_MXCSR);
+#else
+ /*
+ * 32-bit kernel code may use 387 operations as well as SSE2, etc,
+ * as long as it checks that the CPU has the required capability.
+ */
kernel_fpu_begin_mask(KFPU_387 | KFPU_MXCSR);
+#endif
}
/*