From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753164AbdBJADc (ORCPT ); Thu, 9 Feb 2017 19:03:32 -0500 Received: from mx2.suse.de ([195.135.220.15]:41895 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753103AbdBJADa (ORCPT ); Thu, 9 Feb 2017 19:03:30 -0500 Date: Fri, 10 Feb 2017 01:02:24 +0100 From: Borislav Petkov To: Rik van Riel Cc: mingo@kernel.org, linux-kernel@vger.kernel.org, luto@kernel.org, dave.hansen@linux.intel.com, yu-cheng.yu@intel.com, hpa@zytor.com Subject: Re: [PATCH v2] x86/fpu: copy MXCSR & MXCSR_FLAGS with SSE/YMM state Message-ID: <20170210000224.qgwwyozscwjegpqm@pd.tnic> References: <20170209184347.2ef977b9@annuminas.surriel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20170209184347.2ef977b9@annuminas.surriel.com> User-Agent: NeoMutt/20161014 (1.7.1) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 09, 2017 at 06:43:47PM -0500, Rik van Riel wrote: > On Skylake CPUs I noticed that XRSTOR is unable to deal with xsave areas > created by copyout_from_xsaves if the xstate has only SSE/YMM state, but > no FP state. That is, xfeatures had XFEATURE_MASK_SSE set, but not > XFEATURE_MASK_FP. > > The reason is that part of the SSE/YMM state lives in the MXCSR and > MXCSR_FLAGS fields of the FP area. > > Ensure that whenever we copy SSE or YMM state around, the MXCSR and > MXCSR_FLAGS fields are also copied around. > > Signed-off-by: Rik van Riel > --- > arch/x86/kernel/fpu/xstate.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 44 insertions(+) ... > @@ -987,6 +1004,13 @@ int copy_xstate_to_kernel(void *kbuf, struct xregs_state *xsave, unsigned int of > > } > > + if (xfeatures_need_mxcsr_copy(header.xfeatures)) { > + offset = offsetof(struct fxregs_state, mxcsr); > + size = sizeof(u64); // copy mxcsr & mxcsr_flags ^^^^^^^^^^^^^^^^^^^^^^^^^^^ We don't do // comments, do we? And side-line comments are always impairing the readability of the code unless it is a struct's members or asm or so ... -- Regards/Gruss, Boris. SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg) --