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=-7.0 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no 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 B9E3CC433E8 for ; Thu, 23 Jul 2020 16:22:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 85FF0206D8 for ; Thu, 23 Jul 2020 16:22:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 85FF0206D8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 150C16B000D; Thu, 23 Jul 2020 12:22:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0D8BB6B0027; Thu, 23 Jul 2020 12:22:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F0B186B0029; Thu, 23 Jul 2020 12:22:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0047.hostedemail.com [216.40.44.47]) by kanga.kvack.org (Postfix) with ESMTP id D912A6B000D for ; Thu, 23 Jul 2020 12:22:22 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 6F776181AEF10 for ; Thu, 23 Jul 2020 16:22:22 +0000 (UTC) X-FDA: 77069858124.25.dirt16_0a17b9726f40 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin25.hostedemail.com (Postfix) with ESMTP id 8782F1804D8D0 for ; Thu, 23 Jul 2020 16:22:18 +0000 (UTC) X-HE-Tag: dirt16_0a17b9726f40 X-Filterd-Recvd-Size: 5422 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by imf35.hostedemail.com (Postfix) with ESMTP for ; Thu, 23 Jul 2020 16:22:17 +0000 (UTC) IronPort-SDR: 42PzsppjhMa1jC5vHD3cVuJTSdis0zLdiwAwfi6G4SloD7SesRdPUtb5HxN4x4qGz42xvEF5fN DKp3XdYlSaJA== X-IronPort-AV: E=McAfee;i="6000,8403,9691"; a="150551229" X-IronPort-AV: E=Sophos;i="5.75,387,1589266800"; d="scan'208";a="150551229" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jul 2020 09:22:15 -0700 IronPort-SDR: OJt4vWrnoAP6pK5ymUZfgjDLP5rmH9XKLAPLTI79wcTcZb9YrBtgh2IIbZMntAMNwYvSx0bkCH eLMX9JaGcUSA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,387,1589266800"; d="scan'208";a="363096816" Received: from yyu32-desk.sc.intel.com ([143.183.136.146]) by orsmga001.jf.intel.com with ESMTP; 23 Jul 2020 09:22:14 -0700 Message-ID: <2590914945c04d7758f54a9c51dfc6b82924b4e6.camel@intel.com> Subject: Re: [PATCH v10 03/26] x86/fpu/xstate: Introduce CET MSR XSAVES supervisor states From: Yu-cheng Yu To: Sean Christopherson Cc: x86@kernel.org, "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-api@vger.kernel.org, Arnd Bergmann , Andy Lutomirski , Balbir Singh , Borislav Petkov , Cyrill Gorcunov , Dave Hansen , Eugene Syromiatnikov , Florian Weimer , "H.J. Lu" , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , "Ravi V. Shankar" , Vedvyas Shanbhogue , Dave Martin , Weijiang Yang Date: Thu, 23 Jul 2020 09:21:16 -0700 In-Reply-To: <20200723161039.GE21891@linux.intel.com> References: <20200429220732.31602-1-yu-cheng.yu@intel.com> <20200429220732.31602-4-yu-cheng.yu@intel.com> <20200723161039.GE21891@linux.intel.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.32.4 (3.32.4-1.fc30) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 8782F1804D8D0 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, 2020-07-23 at 09:10 -0700, Sean Christopherson wrote: > On Wed, Apr 29, 2020 at 03:07:09PM -0700, Yu-cheng Yu wrote: > > diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h > > index 12c9684d59ba..47f603729543 100644 > > --- a/arch/x86/include/asm/msr-index.h > > +++ b/arch/x86/include/asm/msr-index.h > > @@ -885,4 +885,22 @@ > > #define MSR_VM_IGNNE 0xc0010115 > > #define MSR_VM_HSAVE_PA 0xc0010117 > > > > +/* Control-flow Enforcement Technology MSRs */ > > +#define MSR_IA32_U_CET 0x6a0 /* user mode cet setting */ > > +#define MSR_IA32_S_CET 0x6a2 /* kernel mode cet setting */ > > +#define MSR_IA32_PL0_SSP 0x6a4 /* kernel shstk pointer */ > > +#define MSR_IA32_PL1_SSP 0x6a5 /* ring-1 shstk pointer */ > > +#define MSR_IA32_PL2_SSP 0x6a6 /* ring-2 shstk pointer */ > > +#define MSR_IA32_PL3_SSP 0x6a7 /* user shstk pointer */ > > +#define MSR_IA32_INT_SSP_TAB 0x6a8 /* exception shstk table */ > > + > > +/* MSR_IA32_U_CET and MSR_IA32_S_CET bits */ > > +#define MSR_IA32_CET_SHSTK_EN 0x0000000000000001ULL > > Can we drop the MSR_IA32 prefix for the individual bits? Mostly to yield > shorter line lengths, but also because it's more or less redundant info, > and in some ways unhelpful as it's hard to quickly differentiate between > "this is an MSR index" and "this is a bit/mask for an MSR". Agree! > > My vote would also be to use BIT() or BIT_ULL(). The SDM defines the flags > by their (decimal) bit number. Manually converting the bits to masks makes > it difficult to check for correctness. > > E.g. > > #define CET_SHSTK_EN BIT(0) > #define CET_WRSS_EN BIT(1) > #define CET_ENDBR_EN BIT(2) > #define CET_LEG_IW_EN BIT(3) > #define CET_NO_TRACK_EN BIT(4) > #define CET_WAIT_ENDBR BIT(5) I will change them. > > > +#define MSR_IA32_CET_WRSS_EN 0x0000000000000002ULL > > +#define MSR_IA32_CET_ENDBR_EN 0x0000000000000004ULL > > +#define MSR_IA32_CET_LEG_IW_EN 0x0000000000000008ULL > > +#define MSR_IA32_CET_NO_TRACK_EN 0x0000000000000010ULL > > +#define MSR_IA32_CET_WAIT_ENDBR 0x00000000000000800UL > > +#define MSR_IA32_CET_BITMAP_MASK 0xfffffffffffff000ULL > > This particular define, the so called BITMAP_MASK, is no longer used in the > IBT series. IMO it'd be better off dropping this mask as it's not clear > from the name that this is really nothing more than a mask for a virtual > address, e.g. at first glance (for someone without CET knowledge) it looks > like bits 63:12 hold a bitmap as opposed to holding a pointer to a bitmap. I will remove this. Thanks, Yu-cheng