Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2531291pxa; Mon, 24 Aug 2020 17:34:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxXTMXMSerpPnJAuRWKpXqehJ+MzvMs+7Avw8ZnLFEjdsvrMtbjDRPOqk3DR1DIO7rowxxR X-Received: by 2002:a50:9a85:: with SMTP id p5mr8049023edb.5.1598315639811; Mon, 24 Aug 2020 17:33:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598315639; cv=none; d=google.com; s=arc-20160816; b=yskUlK/kl7DCqtkIN7n4gmWnJIKCHO/nXAJ2nPqwBJNIEu1FwP4LOFtouHFM9olrQO 3FdNgadaMx8Mh+Gz0e2ZtMvzMUK77ItO7btrdvhooBpL+5FU71L8il9/iARibk6POwEG 0MU7Utb/+MIZVo/fskVLivHiDPNZ29HNC+j1sgFxts/Giezwcf7R+TFTVmaa1BeItg8E ATH8NWGTVe6OUFAPZxYabndPxOA3oiqC6hxoot6PXAc8VSQhhM0Qb2Cp+/0hsx6iKPXA E4Mapu87+JgYeg8zymEvY4tzo+FfKiKTZ0dAPoMkVgkr7QGm2ibOkIzyhOQ2QcUmbefv Zz/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=/UEGXNTjEmHV3UMjZZNkIZelvCZWdgSaPYWrEdhq9Lk=; b=NeirF0YiFjx+ngT8AciB5kL605CxTO0L42jIiQiPfCU5q1CiqMAK6wWoRQ/1t5XiMi wOvnkVn7riUqot+YPfpv9vgrfLRRkE06XJMwBPeW8UVRPdBZHUtXnQRunr8B9pCYXPvc 2GGUwphHZmORGP6rNec0iX5LqGCPBZeJYinnC6vFUeFOvBddE6+gVeEiivgQIawpB4Y/ sG1o5DVUYuUkfsmtxmjca2La+UC2s3BExNxI25sSxiESYNgmyYkG8P/jn4UsGOnl/4ou jAoTFvuUyO5ZAlf4JQ70AfkECRQubgOI0jF11CZSL/TjP//q+FiZYMuQG68Ux3QarM76 GpmA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dk2si8009500edb.542.2020.08.24.17.33.36; Mon, 24 Aug 2020 17:33:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728652AbgHYAbz (ORCPT + 99 others); Mon, 24 Aug 2020 20:31:55 -0400 Received: from mga01.intel.com ([192.55.52.88]:28757 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728473AbgHYAai (ORCPT ); Mon, 24 Aug 2020 20:30:38 -0400 IronPort-SDR: xL4kFBvQlNpHzkXYasBuMYqqUolaN1ni2URDKw58XlWxZ6ddP6BLNoEjnzUu+ynYT55BD1FBpm AUK87hD27LcA== X-IronPort-AV: E=McAfee;i="6000,8403,9723"; a="174053270" X-IronPort-AV: E=Sophos;i="5.76,350,1592895600"; d="scan'208";a="174053270" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Aug 2020 17:30:36 -0700 IronPort-SDR: 7R5NO8Y00591d02foMcLeXqtfwQA4+ex9md6DKlWZ250Mzuqy7PmZmnlR7AZGcTijUSG8HZw5R GhbhSH3JxPwg== X-IronPort-AV: E=Sophos;i="5.76,350,1592895600"; d="scan'208";a="443429321" Received: from yyu32-desk.sc.intel.com ([143.183.136.146]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Aug 2020 17:30:35 -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 Cc: Yu-cheng Yu Subject: [PATCH v11 5/9] x86/cet/ibt: Update arch_prctl functions for Indirect Branch Tracking Date: Mon, 24 Aug 2020 17:26:40 -0700 Message-Id: <20200825002645.3658-6-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200825002645.3658-1-yu-cheng.yu@intel.com> References: <20200825002645.3658-1-yu-cheng.yu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 cc49eef08ab0..2cd089e1542c 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)); } @@ -72,7 +75,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) { @@ -83,6 +87,8 @@ int prctl_cet(int option, u64 arg2) return -EINVAL; if (arg2 & GNU_PROPERTY_X86_FEATURE_1_SHSTK) cet_disable_free_shstk(current); + if (arg2 & GNU_PROPERTY_X86_FEATURE_1_IBT) + cet_disable_ibt(); return 0; case ARCH_X86_CET_LOCK: -- 2.21.0