From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756370AbbDVKk5 (ORCPT ); Wed, 22 Apr 2015 06:40:57 -0400 Received: from mail.skyhub.de ([78.46.96.112]:46555 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752613AbbDVKkz (ORCPT ); Wed, 22 Apr 2015 06:40:55 -0400 Date: Wed, 22 Apr 2015 12:40:47 +0200 From: Borislav Petkov To: Dave Hansen Cc: linux-kernel@vger.kernel.org, x86@kernel.org, tglx@linutronix.de, dave.hansen@linux.intel.com, oleg@redhat.com, riel@redhat.com, sbsiddha@gmail.com, luto@amacapital.net, mingo@redhat.com, hpa@zytor.com, fenghua.yu@intel.com Subject: Re: [PATCH 01/16] x86, fpu: wrap get_xsave_addr() to make it safer Message-ID: <20150422104047.GA6897@pd.tnic> References: <20150401004623.894DF37A@viggo.jf.intel.com> <20150401004624.49096AD0@viggo.jf.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20150401004624.49096AD0@viggo.jf.intel.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. --