From patchwork Wed Dec 9 22:27:50 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: 11962807 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=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 A6C1BC4361B for ; Wed, 9 Dec 2020 22:28:21 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 553EE22CB2 for ; Wed, 9 Dec 2020 22:28:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 553EE22CB2 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 8E5868D007C; Wed, 9 Dec 2020 17:28:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 772A78D007B; Wed, 9 Dec 2020 17:28:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 41AE98D007D; Wed, 9 Dec 2020 17:28:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0227.hostedemail.com [216.40.44.227]) by kanga.kvack.org (Postfix) with ESMTP id 08C388D007B for ; Wed, 9 Dec 2020 17:28:15 -0500 (EST) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id C22C9181AEF1F for ; Wed, 9 Dec 2020 22:28:14 +0000 (UTC) X-FDA: 77575183308.13.owner41_5f17663273f3 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin13.hostedemail.com (Postfix) with ESMTP id A560618140B72 for ; Wed, 9 Dec 2020 22:28:14 +0000 (UTC) X-HE-Tag: owner41_5f17663273f3 X-Filterd-Recvd-Size: 3637 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by imf04.hostedemail.com (Postfix) with ESMTP for ; Wed, 9 Dec 2020 22:28:13 +0000 (UTC) IronPort-SDR: FZxHkgcFCSCq9rexv6lUzlEh+VPuLJQTDjG3UxRu9+NeeivOxiwIPPJOMoJzGZ79iHCnSwlZyF +TeXN3QlUbSg== X-IronPort-AV: E=McAfee;i="6000,8403,9830"; a="161918558" X-IronPort-AV: E=Sophos;i="5.78,407,1599548400"; d="scan'208";a="161918558" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Dec 2020 14:28:13 -0800 IronPort-SDR: DHHz8kgAXo4VNUR8QOh42hxlS2HgUkx7U9nsCdI95w3oxm+vdsmARqQIOWxZZJ9X2FqpnbH9Hp i/apbNVvofFQ== X-IronPort-AV: E=Sophos;i="5.78,407,1599548400"; d="scan'208";a="364333632" Received: from yyu32-desk.sc.intel.com ([143.183.136.146]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Dec 2020 14:28:12 -0800 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 v16 5/7] x86/cet/ibt: Update arch_prctl functions for Indirect Branch Tracking Date: Wed, 9 Dec 2020 14:27:50 -0800 Message-Id: <20201209222752.2911-6-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20201209222752.2911-1-yu-cheng.yu@intel.com> References: <20201209222752.2911-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 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/x86/kernel/cet_prctl.c b/arch/x86/kernel/cet_prctl.c index 4197d985b5ff..92120d8bdd9f 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)); } @@ -56,6 +59,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: