[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150422131618.GA16785@redhat.com>
Date: Wed, 22 Apr 2015 15:16:18 +0200
From: Oleg Nesterov <oleg@...hat.com>
To: Borislav Petkov <bp@...en8.de>
Cc: Dave Hansen <dave@...1.net>, linux-kernel@...r.kernel.org,
x86@...nel.org, tglx@...utronix.de, dave.hansen@...ux.intel.com,
riel@...hat.com, sbsiddha@...il.com, luto@...capital.net,
mingo@...hat.com, hpa@...or.com, fenghua.yu@...el.com
Subject: Re: [PATCH 01/16] x86, fpu: wrap get_xsave_addr() to make it safer
On 04/22, Borislav Petkov wrote:
>
> On Tue, Mar 31, 2015 at 05:46:24PM -0700, Dave Hansen wrote:
> > + *
> > + * 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))
>
> ?
I agree, tsk_used_math(tsk) looks better, simpy because we have this
argument.
But this "tsk" should be always current, otherwise this code is wrong
anyway. Say, unlazy_fpu(tsk) can't work if tsk != current.
So perhaps the comment should be updated...
> 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?
Not sure I understand... "current" can't change from under us?
Even if this CPU switches to another thread which executes the same code,
that thread will obviously see another "current", but its "tsk" variable
will still match its "current".
Oleg.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists