From patchwork Thu Aug 30 14:40:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu-cheng Yu X-Patchwork-Id: 10581879 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5368A5A4 for ; Thu, 30 Aug 2018 14:45:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 42E6B2B560 for ; Thu, 30 Aug 2018 14:45:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 36EE02BC83; Thu, 30 Aug 2018 14:45:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C8E552B560 for ; Thu, 30 Aug 2018 14:45:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6C2A06B523E; Thu, 30 Aug 2018 10:44:45 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3D4786B5240; Thu, 30 Aug 2018 10:44:45 -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 11A646B5241; Thu, 30 Aug 2018 10:44:45 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by kanga.kvack.org (Postfix) with ESMTP id B7F986B5240 for ; Thu, 30 Aug 2018 10:44:44 -0400 (EDT) Received: by mail-pf1-f199.google.com with SMTP id x85-v6so4877531pfe.13 for ; Thu, 30 Aug 2018 07:44:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=lR86AMn4GmPcAYjY8yw8TqDa6SPHOetcxZ4l5Gjz5Fg=; b=O2WvDGcqVkusxvdsdbfHs8NkLxW5xsZIDbpxZ7HpNKAe8/mzIn5MgmEMD5ybi700Dq SkY+XTRtlXDPPx/+BnSHRVgFgGrfUUsTs94uglTvxrWrquVsovg1L037KT2sGU48Qvvl cYBoqO8WbiPb5FbKcerBRd0Cy/C3eNi4ORLlON6zoDl4bguqmxbaY7xNKWFNipE9KqHs CcRrXcwxuJmJ3sTtfrh+3HkgIJUjaO00i8XljwGEMf8e8l9EFgsea+4qAfMju1WBF0Kd bo+3GD5oETLArtsmK6iYB6yDA5u7vDyTsyCBDkGOfiSBhBLT3KDhq+1kr7TVhxAvBQwP MSwA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 134.134.136.126 as permitted sender) smtp.mailfrom=yu-cheng.yu@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: APzg51B/meDpQZQIbKtJStQBoxG+VP2VhUoJnn9nkWmIgpROsN022qJO O0QHrrE6yxLda6IaTlyXeAKMCK4sn91Yby3FdcrNVhO3JKCp8kfVIu1lMxfpWqR9+/w7gpaXDjp h696M7uQjeXX87JGjdgtg72J7Cn5wEjbzylYl5JekH2Bz1FILhCW/F3mibV8lB4Ij2g== X-Received: by 2002:a62:6bc5:: with SMTP id g188-v6mr6819838pfc.91.1535640284450; Thu, 30 Aug 2018 07:44:44 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYyjyOzweK7fBdS3lCVX5asm9IN6bG3nwS9ZgGym9xAh1c0EmwFOoiqiZ7rEQiDtWDortAT X-Received: by 2002:a62:6bc5:: with SMTP id g188-v6mr6819788pfc.91.1535640283704; Thu, 30 Aug 2018 07:44:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535640283; cv=none; d=google.com; s=arc-20160816; b=z8K50SjxUkfZqNZaOHQtwaWPpjExfWju/mjsFMb4H7t9rrNkGZPZYfVFl52XyDfMye 2F4kvzjKkAsZIqNR/hppVcyLiixcJu52dPV5oLnd3DfmxgRnzl+i+y/PFyVBXmsPErPF vNgJ3tiXunW4oQri4M64PoHkZr2sdFm4f4cUh0yqHHmdpoVk8mJCghQdybBoS2BOLQaG 7xG1+OdsDPGltZZO5vr7/N0mbIc/Ja/0v/NpD5pk/+f4WgQJmRlMEfYXGvnqndHk8AA+ uPYKeGNjowmjaIDDoen7Acyl/DDq4Kz4l8yBGqO4N3rXjOFtLVYaBVkrc76GMA9kT39k IWMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=lR86AMn4GmPcAYjY8yw8TqDa6SPHOetcxZ4l5Gjz5Fg=; b=t4u1WdmNP4JmOTAkezDqjkIh8r/0sqCgJNVyYiKmX9EBRfIVEe6o38B+Re8Y6WWBfE WfCJKmMMNY6PwXrLvvXHpYThtx+6nKHHINdtAIfUN9tzMr1o5B75Me1fZihtNnbAU1OL KLmTAo+iQRVnExUBdQC7UBnUi2HzCJTzknykmJxcq62+U3OB4ujCvwNJGL1cou4ASRU8 EO2SjZlP/eEu215RgfxSUs2FxpyJ8VmUpbfaDEPKJ/CH/xuwSIyFog2Ufv4snOxSViVn rTPKshX3Cp3UlricOi6yoAiUBD8WljZ0bd+eV8EzMlbyEaXXEU0QSEFJX9zqtWyy0r4S vRgA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 134.134.136.126 as permitted sender) smtp.mailfrom=yu-cheng.yu@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga18.intel.com (mga18.intel.com. [134.134.136.126]) by mx.google.com with ESMTPS id t10-v6si6980653pgn.667.2018.08.30.07.44.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Aug 2018 07:44:43 -0700 (PDT) Received-SPF: pass (google.com: domain of yu-cheng.yu@intel.com designates 134.134.136.126 as permitted sender) client-ip=134.134.136.126; Authentication-Results: mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 134.134.136.126 as permitted sender) smtp.mailfrom=yu-cheng.yu@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Aug 2018 07:44:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,307,1531810800"; d="scan'208";a="228910401" Received: from 2b52.sc.intel.com ([143.183.136.52]) by orsmga004.jf.intel.com with ESMTP; 30 Aug 2018 07:44:30 -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 , Cyrill Gorcunov , Dave Hansen , Florian Weimer , "H.J. Lu" , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , "Ravi V. Shankar" , Vedvyas Shanbhogue Cc: Yu-cheng Yu Subject: [RFC PATCH v3 1/8] x86/cet/ibt: Add Kconfig option for user-mode Indirect Branch Tracking Date: Thu, 30 Aug 2018 07:40:02 -0700 Message-Id: <20180830144009.3314-2-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180830144009.3314-1-yu-cheng.yu@intel.com> References: <20180830144009.3314-1-yu-cheng.yu@intel.com> 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: X-Virus-Scanned: ClamAV using ClamSMTP The user-mode indirect branch tracking support is done mostly by GCC to insert ENDBR64/ENDBR32 instructions at branch targets. The kernel provides CPUID enumeration, feature MSR setup and the allocation of legacy bitmap. Signed-off-by: Yu-cheng Yu --- arch/x86/Kconfig | 12 ++++++++++++ arch/x86/Makefile | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 2cfe11e1cf7f..0d97b03f35f6 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1941,6 +1941,18 @@ config X86_INTEL_SHADOW_STACK_USER If unsure, say y. +config X86_INTEL_BRANCH_TRACKING_USER + prompt "Intel Indirect Branch Tracking for user-mode" + def_bool n + depends on CPU_SUP_INTEL && X86_64 + select X86_INTEL_CET + select ARCH_HAS_PROGRAM_PROPERTIES + ---help--- + Indirect Branch Tracking provides hardware protection against return-/jmp- + oriented programing attacks. + + If unsure, say y + config EFI bool "EFI runtime service support" depends on ACPI diff --git a/arch/x86/Makefile b/arch/x86/Makefile index 00927853e409..0da5121c30db 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -159,6 +159,13 @@ ifdef CONFIG_X86_INTEL_SHADOW_STACK_USER endif endif +# Check compiler ibt support +ifdef CONFIG_X86_INTEL_BRANCH_TRACKING_USER + ifeq ($(call cc-option-yn, -fcf-protection=branch), n) + $(error CONFIG_X86_INTEL_BRANCH_TRACKING_USER not supported by compiler) + endif +endif + # # If the function graph tracer is used with mcount instead of fentry, # '-maccumulate-outgoing-args' is needed to prevent a GCC bug