From patchwork Mon Nov 19 21:49:24 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: 10689569 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 31A6D6C5 for ; Mon, 19 Nov 2018 21:55:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 24E352A583 for ; Mon, 19 Nov 2018 21:55:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 17FD22A6EE; Mon, 19 Nov 2018 21:55:36 +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 A747F2A583 for ; Mon, 19 Nov 2018 21:55:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2FD776B1CB0; Mon, 19 Nov 2018 16:54:56 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 25C246B1CB1; Mon, 19 Nov 2018 16:54:56 -0500 (EST) 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 0DCA56B1CB2; Mon, 19 Nov 2018 16:54:55 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by kanga.kvack.org (Postfix) with ESMTP id A822C6B1CB0 for ; Mon, 19 Nov 2018 16:54:55 -0500 (EST) Received: by mail-pf1-f197.google.com with SMTP id i22-v6so26684750pfj.1 for ; Mon, 19 Nov 2018 13:54:55 -0800 (PST) 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=QCHYrD5sAwVf/rvr/h1K17NE542y7XSPWeOeWJqblEc=; b=kL2h9bcwfOxLwxaZUt0zZefKOXeHnvFbXkld1C19O45Ub7xBvJiftf3NoRa4CSJBuA nJde5IUvfMVwr5KCP/W2HPim7OdzOkAZI83+0H6QEqxwMNWdYrUyJM2LF8sKOYPa/io9 5H58vvHRJbopK5BwV8cS7fhRRlhbl5WfbFe4juzCM8I04fohrOPIlOUEgt4YTXqQKTTk BXObwqNoU4iY6XYXeKSSmFiHqg6vMTZV3tpdyWs8gmepDxmdEr1WIPj/B7+hJUNlUiWf swZsCQm2BioeOPMwPc2GPApdmulNGO95M4KbvKnWhC33n0qsvx6Gd72+VMJue3xM6riW gWbQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 192.55.52.93 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: AGRZ1gLuVDUPqMmA67CXaZk78U/vWbpyq/WBDy7WSadIWExhzib112Em ii8vNSUfhLVxsISf1Y/AioSk71amiy1QRCsgGE+0teVp4WmfFOJWXceKbAkdFEu08t9nblIyxUQ XB8K8JbrhcapSVI4VEsOe14lhXPB9VV3gtjFNjH6pbgB+fSYIkRO42bDQyAxVwEnAeg== X-Received: by 2002:a62:3101:: with SMTP id x1-v6mr25569312pfx.204.1542664495368; Mon, 19 Nov 2018 13:54:55 -0800 (PST) X-Google-Smtp-Source: AJdET5coHqItvzU8slVq1+rwK2cnKLW3pHOhh2cKW0bgnzpTDafDibHMAxuNcF3/xflQJ/kWsOwD X-Received: by 2002:a62:3101:: with SMTP id x1-v6mr25569278pfx.204.1542664494658; Mon, 19 Nov 2018 13:54:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542664494; cv=none; d=google.com; s=arc-20160816; b=NaEsCbezp880013t+CPVNu/1u15AoGCDpewzoR84kBK4OjcCTEKm6DYMb372XgO/Qn th58AsAliMyX/bHlRX9lgPaogT+c4wOjLZ42NkDPS082B4b18iiHe9dAOo4SP6H21HJi 409ZcRxqgqSPPd9pL5BBtn+t0amKP2kEgTfPCT3FqnFxnFc69Z5e8pTbfDVWDsAGYbst VxtMHYxmsGLluJbtzJPU7BgbqxO5fw+dCm7qrg0HQWcT0BLZopurcu5GuO5cAVA1RCce YlmzPoFsDFGS7hyqi/ECZMHYkYWQRUZ0J1R1D2G+dRX4Dgsw6y9ESZ/fGjnZJ951YGQ1 6CFg== 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=QCHYrD5sAwVf/rvr/h1K17NE542y7XSPWeOeWJqblEc=; b=tLdk+YRp51pU21cdh3sEuTTRu6RR3EeS6Ou4Zr31VIbK1nzDIc9SPk9BwAbem9t8Zo KbAtEXx66iRPfNJtCNqxN66G1bAvthPXTDzsOqgZ0gQyArPP9LdN7T9URvaxOkURoL1Z F2EFKcj7G77uqrs4bNL3Sn6afmUBA4NO4Fq0cgRSGmPvVIALITWdFaU+ZuGpC6ppHJqn 3OdcAs33VUdbfa/ryHCBtYzDh9XbyI2kLOiZmOcBPoX5OQDuFCeiwvmH1dNXULrw2Fmv NWWUjzP/qWCL4hb03tcf2BaE0LiyYiFpl9sG/6ruNxxw/rJT6ohU/l+eMefraG/c/GGF 6qHA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 192.55.52.93 as permitted sender) smtp.mailfrom=yu-cheng.yu@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga11.intel.com (mga11.intel.com. [192.55.52.93]) by mx.google.com with ESMTPS id s8si4586261plq.345.2018.11.19.13.54.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Nov 2018 13:54:54 -0800 (PST) Received-SPF: pass (google.com: domain of yu-cheng.yu@intel.com designates 192.55.52.93 as permitted sender) client-ip=192.55.52.93; Authentication-Results: mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 192.55.52.93 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 orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Nov 2018 13:54:54 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,254,1539673200"; d="scan'208";a="92423879" Received: from yyu32-desk1.sc.intel.com ([143.183.136.147]) by orsmga006.jf.intel.com with ESMTP; 19 Nov 2018 13:54:52 -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 , 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 Cc: Yu-cheng Yu Subject: [RFC PATCH v6 01/11] x86/cet/ibt: Add Kconfig option for user-mode Indirect Branch Tracking Date: Mon, 19 Nov 2018 13:49:24 -0800 Message-Id: <20181119214934.6174-2-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181119214934.6174-1-yu-cheng.yu@intel.com> References: <20181119214934.6174-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 and feature setup. Signed-off-by: Yu-cheng Yu --- arch/x86/Kconfig | 16 ++++++++++++++++ arch/x86/Makefile | 7 +++++++ 2 files changed, 23 insertions(+) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 73dfb94cde71..b7f30ac89e27 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1925,6 +1925,9 @@ config X86_INTEL_CET config ARCH_HAS_SHSTK def_bool n +config ARCH_HAS_AS_LIMIT + def_bool n + config ARCH_HAS_PROGRAM_PROPERTIES def_bool n @@ -1948,6 +1951,19 @@ 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_AS_LIMIT + 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 0e4746814452..7e6c4aeb0d92 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