From: Konrad Rzeszutek Wilk Date: Wed, 16 Sep 2015 18:23:29 +0000 (-0700) Subject: Revert "x86, fpu: Avoid possible error in math_state_restore()" X-Git-Tag: v4.1.12-92~280^2~2 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=37a546806877a5933349e0d93fd0ea8073ab9f91;p=users%2Fjedix%2Flinux-maple.git Revert "x86, fpu: Avoid possible error in math_state_restore()" This reverts commit 5b5e1763859439f4733aafc7585b15b28ab94209. The patch does not fix the underlaying problem. The patch "xen/fpu: stts() before the local_irq_enable(), and clts() after the local_irq_disable()" fixes the issue. Acked-by: Annie Li Signed-off-by: Konrad Rzeszutek Wilk Signed-off-by: Santosh Shilimkar --- diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c index 705304841210..324ab5247687 100644 --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c @@ -841,18 +841,20 @@ void math_state_restore(void) { struct task_struct *tsk = current; - /* - * FIXME:The patch has one known problem when the machine is running baremetal - * (or PVHVM) and when there is low amount of memory. The problem is that the - * applications won't get SIGKILL when the FPU area can't be allocated and - * instead they will continue on running - without any FPU context - * allocated for them. The 'init_fpu(tsk)' can return -ENOMEM and that - * patch does not check that condition. This update will be tracked - * in another bug since the patch alrady fixes two known issues related - * to corruption. - */ - if (!tsk_used_math(tsk)) - init_fpu(tsk); + if (!tsk_used_math(tsk)) { + local_irq_enable(); + /* + * does a slab alloc which can sleep + */ + if (init_fpu(tsk)) { + /* + * ran out of memory! + */ + do_group_exit(SIGKILL); + return; + } + local_irq_disable(); + } /* Avoid __kernel_fpu_begin() right after __thread_fpu_begin() */ kernel_fpu_disable();