From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751448AbdBJB31 (ORCPT ); Thu, 9 Feb 2017 20:29:27 -0500 Received: from mga05.intel.com ([192.55.52.43]:4944 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751208AbdBJB3Z (ORCPT ); Thu, 9 Feb 2017 20:29:25 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,138,1484035200"; d="scan'208";a="819104320" Date: Thu, 9 Feb 2017 16:45:41 -0800 From: Yu-cheng Yu To: Rik van Riel Cc: mingo@kernel.org, linux-kernel@vger.kernel.org, luto@kernel.org, dave.hansen@linux.intel.com, bp@suse.de, hpa@zytor.com Subject: Re: [PATCH v2] x86/fpu: copy MXCSR & MXCSR_FLAGS with SSE/YMM state Message-ID: <20170210004541.GA20800@test-lenovo> References: <20170209184347.2ef977b9@annuminas.surriel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170209184347.2ef977b9@annuminas.surriel.com> User-Agent: Mutt/1.5.21 (2010-09-15) 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: > /* > + * Weird legacy quirk: SSE and YMM states store information in the > + * MXCSR and MXCSR_FLAGS fields of the FP area. That means if the FP > + * area is marked as unused in the xfeatures header, we need to copy > + * MXCSR and MXCSR_FLAGS if either SSE or YMM are in use. > + */ > +static inline bool xfeatures_need_mxcsr_copy(u64 xfeatures) > +{ > + if (!(xfeatures & (XFEATURE_MASK_SSE|XFEATURE_MASK_YMM))) > + return 0; > + > + if (xfeatures & XFEATURE_MASK_FP) > + return 0; > + > + return 1; > +} Would you consider separating MXCSR & MXCSR_FLAGS from XFEATURE_MASK_FP. Here we assume if both xstate[0] and xstate[1] are being copied, then there is no need to copy MXCSR/MXCSR_FLAGS again. What if only xstate[0] is copied and MXCSR/MXCSR_FLAGS is invalid? Yu-cheng