From patchwork Fri Sep 21 15:05:45 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: 10610297 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 7F9A214BD for ; Fri, 21 Sep 2018 15:11:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 70A062E448 for ; Fri, 21 Sep 2018 15:11:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6E4152E52A; Fri, 21 Sep 2018 15:11:07 +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 022EA2E51E for ; Fri, 21 Sep 2018 15:11:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 58EC58E0024; Fri, 21 Sep 2018 11:10:30 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 543328E0023; Fri, 21 Sep 2018 11:10:30 -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 406138E0024; Fri, 21 Sep 2018 11:10:30 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by kanga.kvack.org (Postfix) with ESMTP id F2AD18E0023 for ; Fri, 21 Sep 2018 11:10:29 -0400 (EDT) Received: by mail-pg1-f199.google.com with SMTP id v186-v6so4776668pgb.14 for ; Fri, 21 Sep 2018 08:10:29 -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=9ge0BToENFLkDFx5+uBu/yHmjAvnoFdBtu1gWRK9/M0=; b=EQ75kn0NIjADTIqPIqFP9iwQf3xX6ek4HbPnUdRnwGuGNE57opWYvl2REOnq4lkmjJ RT2/3RHajRt2z7sYE8IUDIj0o4t14W5YyW32Q00WlYnkVda+OVKnPAiGBsHRbawngLbk 8RNIw/k3bZcZEmx2lBuGdkhhfqnAsdaAQQ0JP0UMtVwceyfgnkJdMNlKSswpT5Ia32/r yeHVQrQLxgq8sz6rCR7D+2woN3L8voCK429uBfEh++4KC858HKfNbbyjydqc6tY9rvst bdvREN/cfAHaJFMbqdBpuuqExQIqeG+ffxTv37+qaAGmXjGIe7incaYKEalLuiCd7C+z SGLg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 192.55.52.115 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: APzg51Cga9fQAkQvQedVR2klaQkmvXqU1vNfjPhkzgp39B3oWXcqhzJt 2YqMb++yYoed1+IMaOUJSXiL/awVseIThDj7qU5+Ta6kFxuTIwAjrFNcSv+pXd4EJH3TBbpTQfw bX/7YCroJX+npt2qRfSqERDOiSzxnp74t4WHkjq3xnfSE6RKTC/4HMmDSES4FteTOHQ== X-Received: by 2002:a62:6711:: with SMTP id b17-v6mr47234256pfc.243.1537542629668; Fri, 21 Sep 2018 08:10:29 -0700 (PDT) X-Google-Smtp-Source: ANB0VdafwLelzMiduygTnnBG8EquDiavcHOb/XGgtQPJ5l8DBpzjN28t8D230jAE3BKe6YYX6O6U X-Received: by 2002:a62:6711:: with SMTP id b17-v6mr47234173pfc.243.1537542628412; Fri, 21 Sep 2018 08:10:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537542628; cv=none; d=google.com; s=arc-20160816; b=wo0uJnkaMHwJ2aBmvno8DDZo7HS2s2pR3WnG+NWpOpdIFtwRQAYlIcJgPZbAsZLEnl O4Lia2CS9OdApC7CTLDEgzxeKta3kQBv9UugvusdF6lAkvyiEnASxPYxEiE8G8FXMpV9 4BlxcMtPIhEW3Qu1wK7FH+dt0l+YV/M71ZXNh91V8ZH/kXS+yRCe0js0cX9CIyDLZBVN oiXZJyyOY4GJkLwwvmDQTurNFtm8xf9dyGSrp1Rexx1IESIvaOwnpZSGk/c/TdM6M2OF NEp2A0atUScRnl5Gh/jQi/vgi2FD+5DaoxNCukLSVOQo7w93uRlx/ErV+1CW/RIIq4yA VgdQ== 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; bh=9ge0BToENFLkDFx5+uBu/yHmjAvnoFdBtu1gWRK9/M0=; b=LnestYi7+WGPqvrEXPW6WRo8EFOGsXcxEx1rgvdxp1FfJ4Q7YQS70GijHgCdFKdNyO ZvyKa05MRqs14JzjDQFNatgA9yi09892ft3op5fdMHO3CXK8nScb7VL9AVRHmv2wVJrv jb4x4nUG+HfgYIwgdeSDImPUDdkaRtM8HbrOMGCCmuSYRfiIaXXpWsYHnZ18npfCnlYv +fZVc2AKEfen+bJB5sUT0hK+G2j5V9Ow8SJyvqop4HjSYFPulLlIj1tBvh2c6iHlNAFV iNktrFuNilY7awhwWD9+bWnj8nEXVnbFZS25/nt/Esh0RirI1KdVQ3968VG/RaBRd8wp wOuA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 192.55.52.115 as permitted sender) smtp.mailfrom=yu-cheng.yu@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga14.intel.com (mga14.intel.com. [192.55.52.115]) by mx.google.com with ESMTPS id g16-v6si2805450pgd.354.2018.09.21.08.10.28 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Sep 2018 08:10:28 -0700 (PDT) Received-SPF: pass (google.com: domain of yu-cheng.yu@intel.com designates 192.55.52.115 as permitted sender) client-ip=192.55.52.115; Authentication-Results: mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 192.55.52.115 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 fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Sep 2018 08:10:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,285,1534834800"; d="scan'208";a="88187961" Received: from 2b52.sc.intel.com ([143.183.136.51]) by fmsmga002.fm.intel.com with ESMTP; 21 Sep 2018 08:10:27 -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 , Randy Dunlap , "Ravi V. Shankar" , Vedvyas Shanbhogue Cc: Yu-cheng Yu Subject: [RFC PATCH v4 1/9] x86/cet/ibt: Add Kconfig option for user-mode Indirect Branch Tracking Date: Fri, 21 Sep 2018 08:05:45 -0700 Message-Id: <20180921150553.21016-2-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180921150553.21016-1-yu-cheng.yu@intel.com> References: <20180921150553.21016-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 6377125543cc..2a0ff538a229 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 programming 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 b28842b80295..ff652bba849f 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