From patchwork Fri Sep 25 14:58:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu-cheng Yu X-Patchwork-Id: 11800023 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7807A92C for ; Fri, 25 Sep 2020 14:58:47 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3B4D420715 for ; Fri, 25 Sep 2020 14:58:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3B4D420715 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 1C64A900004; Fri, 25 Sep 2020 10:58:19 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0FBDB900003; Fri, 25 Sep 2020 10:58:19 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F2CE8900004; Fri, 25 Sep 2020 10:58:18 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id CBDBA900002 for ; Fri, 25 Sep 2020 10:58:18 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 8AB98180AD802 for ; Fri, 25 Sep 2020 14:58:18 +0000 (UTC) X-FDA: 77301889476.01.cats84_44084d627168 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin01.hostedemail.com (Postfix) with ESMTP id 6E4D61004075D for ; Fri, 25 Sep 2020 14:58:18 +0000 (UTC) X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,yu-cheng.yu@intel.com,,RULES_HIT:30051:30054:30056:30064:30070,0,RBL:134.134.136.100:@intel.com:.lbl8.mailshell.net-62.18.0.100 64.95.201.95;04y8z3n5sg46omgdoq9i3e9me69mqochfxxznjjiunbmqn8a3t8zxtszp5jejrr.iuauikoizd9obonsjuohgocycc698mej45rf9ca4k48tcmeyicwhru9ss17pp1k.n-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:ft,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: cats84_44084d627168 X-Filterd-Recvd-Size: 4049 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by imf06.hostedemail.com (Postfix) with ESMTP for ; Fri, 25 Sep 2020 14:58:17 +0000 (UTC) IronPort-SDR: GbaWWSb1egUJHMlMpa3kKoQKgT4HMrsL1mjlJAwjGUAoRNY5cdkotwpcdr/qQsUfulKDFJQL3q Ik3w2I3oSLiw== X-IronPort-AV: E=McAfee;i="6000,8403,9755"; a="225704490" X-IronPort-AV: E=Sophos;i="5.77,302,1596524400"; d="scan'208";a="225704490" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Sep 2020 07:58:14 -0700 IronPort-SDR: 7xOXXexJwcxygu2Xzf9kweeyko7guPmI7zayEU+/z/sFyyGLF5H8l7arDdhOPWAfCnfgh1GqEA cAz+Z87qiLRg== X-IronPort-AV: E=Sophos;i="5.77,302,1596524400"; d="scan'208";a="512916975" Received: from yyu32-desk.sc.intel.com ([143.183.136.146]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Sep 2020 07:58:14 -0700 From: Yu-cheng Yu To: 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 , Pengfei Xu Cc: Yu-cheng Yu Subject: [PATCH v13 5/8] x86/cet/ibt: Update arch_prctl functions for Indirect Branch Tracking Date: Fri, 25 Sep 2020 07:58:01 -0700 Message-Id: <20200925145804.5821-6-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200925145804.5821-1-yu-cheng.yu@intel.com> References: <20200925145804.5821-1-yu-cheng.yu@intel.com> MIME-Version: 1.0 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: From: "H.J. Lu" Update ARCH_X86_CET_STATUS and ARCH_X86_CET_DISABLE for Indirect Branch Tracking. Signed-off-by: H.J. Lu Signed-off-by: Yu-cheng Yu --- arch/x86/kernel/cet_prctl.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/cet_prctl.c b/arch/x86/kernel/cet_prctl.c index bd5ad11763e4..0af1ec5d028f 100644 --- a/arch/x86/kernel/cet_prctl.c +++ b/arch/x86/kernel/cet_prctl.c @@ -22,6 +22,9 @@ static int copy_status_to_user(struct cet_status *cet, u64 arg2) buf[2] = (u64)cet->shstk_size; } + if (cet->ibt_enabled) + buf[0] |= GNU_PROPERTY_X86_FEATURE_1_IBT; + return copy_to_user((u64 __user *)arg2, buf, sizeof(buf)); } @@ -42,7 +45,8 @@ int prctl_cet(int option, u64 arg2) if (option == ARCH_X86_CET_STATUS) return copy_status_to_user(cet, arg2); - if (!static_cpu_has(X86_FEATURE_SHSTK)) + if (!static_cpu_has(X86_FEATURE_SHSTK) && + !static_cpu_has(X86_FEATURE_IBT)) return -EOPNOTSUPP; switch (option) { @@ -56,6 +60,8 @@ int prctl_cet(int option, u64 arg2) return -EINVAL; if (features & GNU_PROPERTY_X86_FEATURE_1_SHSTK) cet_disable_shstk(); + if (features & GNU_PROPERTY_X86_FEATURE_1_IBT) + cet_disable_ibt(); return 0; case ARCH_X86_CET_LOCK: