Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752652AbcD2WgT (ORCPT ); Fri, 29 Apr 2016 18:36:19 -0400 Received: from mga01.intel.com ([192.55.52.88]:19809 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752273AbcD2WgS (ORCPT ); Fri, 29 Apr 2016 18:36:18 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,553,1455004800"; d="scan'208";a="795366423" Subject: Re: [PATCH v4 07/10] x86/xsaves: Fix PTRACE frames for XSAVES To: Yu-cheng Yu References: <46ff4951eef7e9ad30b25df401fa536a5bc9100b.1457038929.git.yu-cheng.yu@intel.com> <5723C33E.1020303@linux.intel.com> <20160429223050.GA15714@test-lenovo> Cc: x86@kernel.org, "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , linux-kernel@vger.kernel.org, Andy Lutomirski , Borislav Petkov , Sai Praneeth Prakhya , "Ravi V. Shankar" , Fenghua Yu From: Dave Hansen Message-ID: <5723E1DC.6040207@linux.intel.com> Date: Fri, 29 Apr 2016 15:36:12 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <20160429223050.GA15714@test-lenovo> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 890 Lines: 24 On 04/29/2016 03:30 PM, Yu-cheng Yu wrote: > On Fri, Apr 29, 2016 at 01:25:34PM -0700, Dave Hansen wrote: >> On 03/04/2016 10:12 AM, Yu-cheng Yu wrote: >>> + for (i = 0; i < XFEATURE_MAX; i++) { >>> + /* >>> + * Copy only in-use xstates. >>> + */ >>> + if (((header.xfeatures >> i) & 1) && xfeature_enabled(i)) { >>> + void *src = get_xsave_addr_no_check(xsave, i); >> >> How could a bit in header.xfeatures get set if it is not set in >> xfeature_enabled() aka xfeatures_mask aka XCR0? > > Do you mean, we should test xfeature_enabled(i) first, like, > > if (xfeature_enabled(i) && ((header.xfeatures >> i) & 1)) ? > > The result will be the same, like you said, if XCR0[i] is not set, > hader.xfeatures[i] cannot be set. But if XCR0[i] is set, > header.xfeatures[i] can be cleared. I think the xfeature_enabled(i) is probably redundant. Does it serve any actual purpose?