From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BD400C47089 for ; Wed, 26 May 2021 21:17:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9B572613DD for ; Wed, 26 May 2021 21:17:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233664AbhEZVTT (ORCPT ); Wed, 26 May 2021 17:19:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:41532 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233241AbhEZVTR (ORCPT ); Wed, 26 May 2021 17:19:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2BFE8613D2; Wed, 26 May 2021 21:17:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1622063865; bh=P8I/YSnIlGt0BecmLDEFgrVyKPCt/3KOKGdpFJImRSo=; h=In-Reply-To:References:Date:From:To:Cc:Subject:From; b=ECcljrMQj9CmfendnYYEjB9+3XmW9zg3xP7pHdHcDjBL3NOx+eUCJWyBQ/yYBKr70 AgVdYkyi71Y+fMO3cFm2L66APQyx5r6ukepipimExoGtt01ffeVcoLt1piZfrX3/Sa iyCgIOlT4r/ZcSQw56+3jiudmZ8LDPp07js21fHPawoqRiAqSkyU+7Cnube4o2AvNx EnDiGGT2AKYIEjLMNFMeHv4VXl5tLxcPQIElqVTSkoq9hNDeXOVWUvouV/md++DDEI 8cntPWjxC5rQ4meVrMmgZYVazWGDv/ubPJaW1bQUinwZkQ3uM7EUlk6zjdzCQC+5rD S6E3MklTGNXPQ== Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailauth.nyi.internal (Postfix) with ESMTP id 3DD0B27C0054; Wed, 26 May 2021 17:17:41 -0400 (EDT) Received: from imap21 ([10.202.2.71]) by compute2.internal (MEProxy); Wed, 26 May 2021 17:17:41 -0400 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvdekfedgudeitdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvufgtgfesthhqredtreerjeenucfhrhhomhepfdet nhguhicunfhuthhomhhirhhskhhifdcuoehluhhtoheskhgvrhhnvghlrdhorhhgqeenuc ggtffrrghtthgvrhhnpedvleehjeejvefhuddtgeegffdtjedtffegveethedvgfejieev ieeufeevuedvteenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpegrnhguhidomhgvshhmthhprghuthhhphgvrhhsohhnrghlihhthidqudduiedu keehieefvddqvdeifeduieeitdekqdhluhhtoheppehkvghrnhgvlhdrohhrgheslhhinh hugidrlhhuthhordhush X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 4AC9D51C0060; Wed, 26 May 2021 17:17:34 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-448-gae190416c7-fm-20210505.004-gae190416 Mime-Version: 1.0 Message-Id: <6bc401e7-6e34-4fbc-8ce3-a99be7966528@www.fastmail.com> In-Reply-To: <718755e9-065e-c427-8821-228cdf8dd581@amd.com> References: <718755e9-065e-c427-8821-228cdf8dd581@amd.com> Date: Wed, 26 May 2021 14:17:13 -0700 From: "Andy Lutomirski" To: "Babu Moger" , "Linux Kernel Mailing List" , linux-kselftest@vger.kernel.org Cc: "Thomas Gleixner" , "Ingo Molnar" , "Borislav Petkov" , "the arch/x86 maintainers" , "H. Peter Anvin" , dave.hansen@linux.intel.com, "Peter Zijlstra (Intel)" , shuah@kernel.org, jroedel@suse.de, "Uros Bizjak" , viro@zeniv.linux.org.uk, "Petteri Aimonen" , "Fenghua Yu" , "Kan Liang" , "Andrew Morton" , "Mike Rapoport" , "Fan Yang" , anshuman.khandual@arm.com, "Benjamin Thiel" , "Juergen Gross" , keescook@chromium.org, "Sean Christopherson" , mh@glandium.org, sashal@kernel.org, krisman@collabora.com, "Bae, Chang Seok" , 0x7f454c46@gmail.com, jhubbard@nvidia.com, sandipan@linux.ibm.com, ziy@nvidia.com, kirill.shutemov@linux.intel.com, suxingxing@loongson.cn, harish@linux.ibm.com, rong.a.chen@intel.com, linuxram@us.ibm.com, bauerman@linux.ibm.com, dave.kleikamp@oracle.com Subject: Re: x86/fpu/xsave: protection key test failures Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 26, 2021, at 2:14 PM, Babu Moger wrote: >=20 >=20 > On 5/25/21 7:36 PM, Andy Lutomirski wrote: > > On 5/25/21 2:37 PM, Babu Moger wrote: > >=20 > >> Investigation so far. > >> 1. The test fails on AMD(Milan) systems. Test appears to pass on In= tel > >> systems. Tested on old Intel system available here. > >=20 > > Ten cents says that you have discovered that AMD returns a synthesiz= ed > > value for XINUSE[PKRU] and that write_pkru() is buggy. > >=20 > > Any volunteers to fix the if (!pk) case in write_pkru() and see if t= he > > problem goes away? (Or at least to print something for the if (!pk)= > > case and seee if it gets printed?) >=20 > I inserted this patch to test this path. >=20 >=20 > diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgt= able.h > index b1099f2d9800..a0bca917f864 100644 > --- a/arch/x86/include/asm/pgtable.h > +++ b/arch/x86/include/asm/pgtable.h > @@ -151,6 +160,8 @@ static inline void write_pkru(u32 pkru) > fpregs_lock(); > if (pk) > pk->pkru =3D pkru; > + else > + printk_once("%s read_pkru 0x%x\n",__FUNCTION__, read_p= kru()); > __write_pkru(pkru); > fpregs_unlock(); > } >=20 >=20 > Yes. The pk value is sometimes NULL and the value in the pkru register= is > 0 at that time. Here is the dmesg output. >=20 > [ 1.700889] write_pkru read_pkru 0x0 >=20 Sweet, maybe I get my hypothetical dime back! Both bugs are real. Dave and I (mostly Dave =E2=80=94 I=E2=80=99m supplying the snark) are w= orking on an omnibus patch to fix this whole mess. Thanks, Andy