[PATCH 01/11] x86: Use correct type for %cr4 [PATCH 02/11] x86: Merge fpu_init() [PATCH 03/11] x86: Merge tolerant_fwait() [PATCH 04/11] x86: Merge __save_init_fpu() [PATCH 05/11] x86-64: Disable preemption when using TS_USEDFPU [PATCH 06/11] x86-64: Fix %cs value in convert_from_fxsr() [PATCH 07/11] x86-64: Simplify constraints for fxsave/fxtstor [PATCH 08/11] x86-32: Remove math_emulate stub [PATCH 09/11] x86: Merge fpu_save_init() [PATCH 10/11] x86: Remove unnecessary ifdefs from i387 code. [PATCH 11/11] x86: Remove PSHUFB_XMM5_* macros arch/x86/include/asm/i387.h | 188 ++++++++++---------------------------- arch/x86/include/asm/processor.h | 4 +- arch/x86/kernel/cpu/common.c | 7 -- arch/x86/kernel/i387.c | 49 ++++------ arch/x86/kernel/process_64.c | 2 +- arch/x86/kernel/traps.c | 35 +------ 6 files changed, 78 insertions(+), 207 deletions(-) --
check_fpu() in bugs.c halts boot if no FPU is found and math emulation
isn't enabled. Therefore this stub will never be used.
Signed-off-by: Brian Gerst <brgerst@gmail.com>
---
arch/x86/kernel/traps.c | 23 ++++++-----------------
1 files changed, 6 insertions(+), 17 deletions(-)
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
index d0029eb..d439685 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -776,21 +776,10 @@ asmlinkage void math_state_restore(void)
}
EXPORT_SYMBOL_GPL(math_state_restore);
-#ifndef CONFIG_MATH_EMULATION
-void math_emulate(struct math_emu_info *info)
-{
- printk(KERN_EMERG
- "math-emulation not enabled and no coprocessor found.\n");
- printk(KERN_EMERG "killing %s.\n", current->comm);
- force_sig(SIGFPE, current);
- schedule();
-}
-#endif /* CONFIG_MATH_EMULATION */
-
dotraplinkage void __kprobes
do_device_not_available(struct pt_regs *regs, long error_code)
{
-#ifdef CONFIG_X86_32
+#ifdef CONFIG_MATH_EMULATION
if (read_cr0() & X86_CR0_EM) {
struct math_emu_info info = { };
@@ -798,12 +787,12 @@ do_device_not_available(struct pt_regs *regs, long error_code)
info.regs = regs;
math_emulate(&info);
- } else {
- math_state_restore(); /* interrupts still off */
- conditional_sti(regs);
+ return;
}
-#else
- math_state_restore();
+#endif
+ math_state_restore(); /* interrupts still off */
+#ifdef CONFIG_X86_32
+ conditional_sti(regs);
#endif
}
--
1.7.2.2
--
Acked-by: Pekka Enberg <penberg@kernel.org> --
Now that 32-bit can handle exceptions from the kernel, switch to using
the 64-bit version of tolerant_fwait() without fnclex. In the unlikely
event an exception is triggered, it is simply ignored.
Signed-off-by: Brian Gerst <brgerst@gmail.com>
---
arch/x86/include/asm/i387.h | 19 ++++---------------
1 files changed, 4 insertions(+), 15 deletions(-)
diff --git a/arch/x86/include/asm/i387.h b/arch/x86/include/asm/i387.h
index a73a8d5..5d8f9a7 100644
--- a/arch/x86/include/asm/i387.h
+++ b/arch/x86/include/asm/i387.h
@@ -77,15 +77,6 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
}
#ifdef CONFIG_X86_64
-
-/* Ignore delayed exceptions from user space */
-static inline void tolerant_fwait(void)
-{
- asm volatile("1: fwait\n"
- "2:\n"
- _ASM_EXTABLE(1b, 2b));
-}
-
static inline int fxrstor_checking(struct i387_fxsave_struct *fx)
{
int err;
@@ -220,11 +211,6 @@ extern void finit_soft_fpu(struct i387_soft_struct *soft);
static inline void finit_soft_fpu(struct i387_soft_struct *soft) {}
#endif
-static inline void tolerant_fwait(void)
-{
- asm volatile("fnclex ; fwait");
-}
-
/* perform fxrstor iff the processor has extended states, otherwise frstor */
static inline int fxrstor_checking(struct i387_fxsave_struct *fx)
{
@@ -344,7 +330,10 @@ static inline void __unlazy_fpu(struct task_struct *tsk)
static inline void __clear_fpu(struct task_struct *tsk)
{
if (task_thread_info(tsk)->status & TS_USEDFPU) {
- tolerant_fwait();
+ /* Ignore delayed exceptions from user space */
+ asm volatile("1: fwait\n"
+ "2:\n"
+ _ASM_EXTABLE(1b, 2b));
task_thread_info(tsk)->status &= ~TS_USEDFPU;
stts();
}
--
1.7.2.2
--
Why is 32-bit able to handle exceptions? Is that part of this series or is it some existing commit in tip or linus? --
Commit e2e75c915de045f0785387dc32f55e92fab0614c merged the 32-bit and 64-bit math exception handlers into one, which calls fixup_exception(). -- Brian Gerst --
That could be in the changelog. Acked-by: Pekka Enberg <penberg@kernel.org> --
