Re: [PATCH 1/1] x86/fpu: math_state_restore() should not blindly disable irqs

From: Ingo Molnar
Date: Fri Mar 06 2015 - 08:46:16 EST



* Oleg Nesterov <oleg@xxxxxxxxxx> wrote:

> On 03/06, Ingo Molnar wrote:
> >
> > * Oleg Nesterov <oleg@xxxxxxxxxx> wrote:
> >
> > > [...] The patch above looks "obviously safe", but perhaps I am
> > > paranoid too much...
> >
> > IMHO your hack above isn't really acceptable, even for a backport.
> > So lets test the patch below (assuming it's the right thing to do)
> > and move forward?
>
> OK, but please note that this patch is not beckportable. If you think
> that -stable doesn't need this fix, then I agree.
>
> If the caller is do_device_not_available(), then we can not enable
> irqs before __thread_fpu_begin() + restore_fpu_checking().
>
> 1. Preemption in between can destroy ->fpu.state initialized by
> fpu_finit(), __switch_to() will save the live (wrong) FPU state
> again.
>
> 2. kernel_fpu_begin() from irq right after __thread_fpu_begin() is
> not nice too. It will do __save_init_fpu() and this overwrites
> ->fpu.state too.
>
> Starting from v4.0 it does kernel_fpu_disable(), but the older kernels
> do not.
>
> Ingo, this code is really horrible and fragile. We need to cleanup it
> step-by-step, imho.

How about the patch from David Vrabel? That seems to solve the
irq-disable problem too, right?

Thanks,

Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/