Re: [RFC][PATCH 1/2] x86, fpu: wrap get_xsave_addr() to make it safer

From: Oleg Nesterov
Date: Fri Jan 30 2015 - 13:39:50 EST


On 01/30, Oleg Nesterov wrote:
>
> On 01/30, Dave Hansen wrote:
> >
> > +void *tsk_get_xsave_field(struct task_struct *tsk, int xsave_field)
> > +{
> > + union thread_xstate *xstate;
> > +
> > + unlazy_fpu(tsk);
>
> ack, but to remind this depends on 2/3 I sent.
>
> > + xstate = tsk->thread.fpu.state;
> > + /*
> > + * This might be unallocated if the FPU
> > + * was never in use.
> > + */
> > + if (!xstate)
> > + return NULL;
>
> This is cosmetic, unlazy_fpu() is safe if !xstate, __thread_has_fpu()
> is not possible in this case.
>
> But perhaps
>
> if (!used_math())
> return NULL;
>
> will look better.

at the start of this helper, I meant

Oleg.

--
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/