lkml.org 
[lkml]   [2015]   [Apr]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 01/16] x86, fpu: wrap get_xsave_addr() to make it safer
On Tue, Mar 31, 2015 at 05:46:24PM -0700, Dave Hansen wrote:
> +/*
> + * This wraps up the common operations that need to occur when retrieving
> + * data from an xsave struct. It first ensures that the task was actually
> + * using the FPU and retrieves the data in to a buffer. It then calculates
> + * the offset of the requested field in the buffer.
> + *
> + * This function is safe to call whether the FPU is in use or not.
> + *
> + * Inputs:
> + * @tsk: the task from which we are fetching xsave state
> + * @xsave_field: state which is defined in xsave.h (e.g. XSTATE_FP,
> + * XSTATE_SSE, etc...)
> + * Output:
> + * address of the state in the xsave area.
> + */
> +void *tsk_get_xsave_field(struct task_struct *tsk, int xsave_field)
> +{
> + union thread_xstate *xstate;
> +
> + if (!used_math())
> + return NULL;

Shouldn't this be

if (!tsk_used_math(tsk))

?

Because used_math() is looking at current, maybe even in
preemption-enabled paths - I'm eyeing task_get_bounds_dir() - and
that current might get changed from under us and it might happen that
current != tsk. Yes, no?

> + /*
> + * unlazy_fpu() is poorly named and will actually
> + * save the xstate off in to the memory buffer.
> + */
> + unlazy_fpu(tsk);
> + xstate = tsk->thread.fpu.state;
> +
> + return get_xsave_addr(&xstate->xsave, xsave_field);

And I understand this as "give me the xsave address of @tsk".

Right?

Thanks.

--
Regards/Gruss,
Boris.

ECO tip #101: Trim your mails when you reply.
--


\
 
 \ /
  Last update: 2015-04-22 13:21    [W:0.082 / U:0.956 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site