From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750808AbdAXFTA (ORCPT ); Tue, 24 Jan 2017 00:19:00 -0500 Received: from mail-pf0-f194.google.com ([209.85.192.194]:32781 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750703AbdAXFS5 (ORCPT ); Tue, 24 Jan 2017 00:18:57 -0500 Date: Tue, 24 Jan 2017 13:18:33 +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: <20170124051833.GA10737@pek-khao-d1> References: <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> <20170124015012.GA9969@pek-khao-d1> <1b4e8b6c-c143-1867-712c-8b2e336a6ce0@linux.intel.com> <20170124020921.GC9969@pek-khao-d1> <2b638f89-70b4-7c0b-a271-a430157c5bfd@linux.intel.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="X1bOJ3K7DJ5YkBrT" Content-Disposition: inline In-Reply-To: <2b638f89-70b4-7c0b-a271-a430157c5bfd@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 --X1bOJ3K7DJ5YkBrT Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jan 23, 2017 at 06:38:42PM -0800, Dave Hansen wrote: > On 01/23/2017 06:09 PM, Kevin Hao wrote: > > On Mon, Jan 23, 2017 at 06:01:10PM -0800, Dave Hansen wrote: > >> On 01/23/2017 05:50 PM, Kevin Hao wrote: > >>> According to the ISA manual, XSAVES also set the XCOMP_BV[62:0]. My c= ode only > >>> try to be compatible with what the cpu does when excuting XSAVES. The= following > >>> is quoted from 325462-sdm-vol-1-2abcd-3abcd.pdf. > >>> The XSAVES instructions sets bit 63 of the XCOMP_BV field of the XS= AVE header while writing RFBM[62:0] to > >>> XCOMP_BV[62:0]. The XSAVES instruction does not write any part of t= he XSAVE header other than the XSTATE_BV > >>> and XCOMP_BV fields. > >> What purpose does it serve to make copyin_to_xsaves() set that bit, > > We try to fake up a memory area which is supposed to be composed by XSA= VES > > instruction. My code is just trying to do what the XSAVES do. >=20 > No. copyin_to_xsaves() copies data into an *existing* XSAVES-formatted > buffer. If you want to change what it does, fine, but that's not what > it does or tries to do today. No, I didn't change what the function copyin_to_xsaves() does. I just tried= to fix the bug in it. >=20 > >> other than helping to hide bugs? > > Why do you think it hide the bug? In contrast, I think my patch fixes w= hat the > > bug really is. The memory area we fake up is bug, we should fix it ther= e. >=20 > Yu-cheng found the bug. That bug will probably manifest in other code > paths than copyin_to_xsaves(). If we did your patch, it would hide the > bug in those other code paths. The XCOMP_BV[62:0] is supposed to be updated by XSAVEC/XSAVES instructions. It should not be touched by the software in theory except some special cases like what we do in copyin_to_xsaves(). Trying to init the XCOMP_BV[62:0] to= some assuming values in fpstate_init() should be error prone and just paper over= the real bug. Thanks, Kevin --X1bOJ3K7DJ5YkBrT Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJYhuOpAAoJEJNY7TDerrFxSaMIAM13/Ch4AckGBQPK1MPFWzRy 08c2UcOlZsSCDerikGNLbDqYtUd4LDKLpCoaffXx2GLnuRf6yAzjLGCp7JFZS7/0 c3ABd5y7kQfYDnK2TMrXv1FB94wxV6wuAb173LCAm68Q58JZ2Anhjx00XTR6Rklx VLScoGIF+alH1bil3LnC8F9T2K5BaCVrXg9bOOePG+gwfz7LavQHaFJBfos2ajPD 0nF7tkGHCJcI+v73pWOixIvBDCCH007CGrBbvALCtAvBpwXGOJzmAM4KgY24GzLC vlyYZxTXrdCPJNicbFB82gHifOvSHgn6v3g5/Ff+QCsDhCC5Rw4Dd5F4auZdz5o= =lDBQ -----END PGP SIGNATURE----- --X1bOJ3K7DJ5YkBrT--