From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752046AbdAXBua (ORCPT ); Mon, 23 Jan 2017 20:50:30 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:35020 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751926AbdAXBu3 (ORCPT ); Mon, 23 Jan 2017 20:50:29 -0500 Date: Tue, 24 Jan 2017 09:50:12 +0800 From: Kevin Hao To: Dave Hansen Cc: Yu-cheng Yu , fenghua.yu@intel.com, dvlasenk@redhat.com, peterz@infradead.org, oleg@redhat.com, mingo@kernel.org, linux-kernel@vger.kernel.org, brgerst@gmail.com, luto@kernel.org, bp@alien8.de, jpoimboe@redhat.com, hpa@zytor.com, quentin.casasnovas@oracle.com, tglx@linutronix.de, torvalds@linux-foundation.org, riel@redhat.com, linux-tip-commits@vger.kernel.org Subject: Re: [tip:x86/urgent] x86/fpu: Set the xcomp_bv when we fake up a XSAVES area Message-ID: <20170124015012.GA9969@pek-khao-d1> References: <1485075023-30161-1-git-send-email-haokexin@gmail.com> <20170123165529.GA4996@test-lenovo> <2be814b7-9fd6-7955-b4e3-6ecb4ef76052@linux.intel.com> <20170123205725.GA3920@test-lenovo> <90b0fbee-273b-31c2-6fe9-228f00c0a205@linux.intel.com> <20170123211640.GA3976@test-lenovo> <20170124001447.GD15017@pek-khao-d1> <0d717394-eaf0-4d29-1aae-218ffcc8f06b@linux.intel.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="5vNYLRcllDrimb99" Content-Disposition: inline In-Reply-To: <0d717394-eaf0-4d29-1aae-218ffcc8f06b@linux.intel.com> User-Agent: Mutt/1.7.1 (2016-10-04) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --5vNYLRcllDrimb99 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jan 23, 2017 at 04:53:25PM -0800, Dave Hansen wrote: > >> The fix I am proposing is... > >> > >> state->xsave.header.xcomp_bv =3D XCOMP_BV_COMPACTED_FORMAT | > >> xfeatures_mask; > >=20 > > Actually I thought about this change before I made this patch, but I do= n't this > > is the right fix. It is always error prone to init the xcomp_bv to all = the > > supported feature. In case like copyin_to_xsaves(), it is possible that= the > > features which should be set in xcomp_bv do not equal to all the suppor= ted > > features. Please see the following codes in copyin_to_xsaves(): > > /* > > * The state that came in from userspace was user-state only. > > * Mask all the user states out of 'xfeatures': > > */ > > xsave->header.xfeatures &=3D XFEATURE_MASK_SUPERVISOR; > >=20 > > /* > > * Add back in the features that came in from userspace: > > */ > > xsave->header.xfeatures |=3D xfeatures; >=20 > Hi Kevin, >=20 > I think you may be confusing 'xfeatures' with 'xcomp_bv'. xfeatures > tells you what features are present in the buffer while xcomp_bv tells > you what *format* the buffer is in. According to the ISA manual, XSAVES also set the XCOMP_BV[62:0]. My code on= ly try to be compatible with what the cpu does when excuting XSAVES. The follo= wing is quoted from 325462-sdm-vol-1-2abcd-3abcd.pdf. The XSAVES instructions sets bit 63 of the XCOMP_BV field of the XSAVE he= ader while writing RFBM[62:0] to XCOMP_BV[62:0]. The XSAVES instruction does not write any part of the XSA= VE header other than the XSTATE_BV and XCOMP_BV fields. Thanks, Kevin >=20 > Userspace never dictates the *format* of the kernel buffer, only the > contents of each state. So, it makes sense that the copyin code would > not (and should not) modify xcomp_bv. >=20 > We ensure that xcomp_bv has all supported states set all the time, or > we're *supposed* to. --5vNYLRcllDrimb99 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJYhrLUAAoJEJNY7TDerrFx7AUH/0V4Z+VKK43DbdcEo2iWqYPQ OHhFYQal/H93syl2Y+rO2MefI7Zp7pvrXTSnSGoyd+kU05/vH7CWFE7KWEyJMN60 QHdgikoCY3Nzvh1jGuh+YvonhOcfcBGU89NrPdEmHqF2WB3Qk+Q7bLy4UTLjoDyG ILDtFu4nZddxYuHprlsVVDhmFHJmWzQ+oDgd5GBMp8lb9EdB88eB/iXScShbZpim CJhtAU7fBhmk6ZO1o4eOv9jbMjjJ+YtvA65XCt8WNjUjMnBbPgGScq5wBkHfzSZE 3Yz6j4BA894ssGrewaLQTNEWxJr+0lp0nTDzLev63ejK6EWnv2FtRtT+jN4nnho= =O4Yq -----END PGP SIGNATURE----- --5vNYLRcllDrimb99--