From patchwork Thu Oct 11 15:16:44 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: 10636905 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 AE85617E1 for ; Thu, 11 Oct 2018 15:22:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9D5AD2BA2E for ; Thu, 11 Oct 2018 15:22:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 90BCB2B9DB; Thu, 11 Oct 2018 15:22:41 +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 1B4392BA24 for ; Thu, 11 Oct 2018 15:22:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7AC3E6B0298; Thu, 11 Oct 2018 11:21:45 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 783806B0299; Thu, 11 Oct 2018 11:21: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 625176B029B; Thu, 11 Oct 2018 11:21:45 -0400 (EDT) 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 1D6FF6B0299 for ; Thu, 11 Oct 2018 11:21:45 -0400 (EDT) Received: by mail-pf1-f197.google.com with SMTP id b27-v6so8122230pfm.15 for ; Thu, 11 Oct 2018 08:21:45 -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=Iq5Xh4cI/zY3DrkDmU3iCZiYvsCE7e2msv6ERSQ9RH8=; b=HGdZJVCwLYoYzmGGNjVosCQhMPZiZjjVypQEuB1Ci1uhk06cci13yWxqDkUPASvwyF 8nk9e99eS/94k3bWQ0WCjYlneptxun3Jb5w5h3qJwQf98LxT1v4E3SutgiTdZqqglGhg 9Tt1GMMbTMHK9Ar7fcmoYojFuZHNVhBVit/PVNOVPIzQPWYPzqVEySoIj5HeRkVxBZvq 4kvNCjQXvGvekiMjz5eHvC3e+UxLUr2/6TUbqV567/m9p8utqATGdVMUHHx9meCFAmH2 JJTuRTnlphaijka1Nn9ex6ql9ZmwrfqfItxC4tJKZ+uUTIVMmpv3HRrdwTL6edEw9GVn 8kNQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 134.134.136.24 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: ABuFfojEvMBAc3paxidT6Lk7e+6AUv7oYIRBVqtyEVg3OLHE1eZ4nEy1 Wt92E1jYwwSPc0SRf6g1Cj1IdzxhSXsXAdhLLdM2cDPU/k3SA59ENef8dJw2Ea5J3xfeo1sAMUb SdbKjv7lAFu1XAEkzR1gn8IpIvHSBAxyn1u2FIBw1XyUMpSApHygbIkOjAnVfBenykA== X-Received: by 2002:a62:f58a:: with SMTP id b10-v6mr2010994pfm.253.1539271304791; Thu, 11 Oct 2018 08:21:44 -0700 (PDT) X-Google-Smtp-Source: ACcGV63dk4yLa8qLgtgu0yKWHKJ5GzRpddcJDiZj57Rieepq5aNYgZbNvPr9lqTj+bipUlVkNMtl X-Received: by 2002:a62:f58a:: with SMTP id b10-v6mr2010949pfm.253.1539271304096; Thu, 11 Oct 2018 08:21:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539271304; cv=none; d=google.com; s=arc-20160816; b=ZR5FECLfarX07vslEdrhkqHTJAzwVmCgpOaDIPL4kt85tj1BtVG8iZN4rpTe5bMSD1 0QjBOcudrf0cDtegX+k7Tm1daPDFK5MKwLEcJVf/nk08z8TagLxIsu6cQSq0ZrHp8SSx /C+v7PaWFcSfA6xel9KctAn1ugpEHQjoSErz0iQwWNb+LP9vT+zpT7F6GYz6o4lg3s/i EBGitRq2HfTT+dPjoBLesiUF4yzEA5+fyG1DkWghL57r2L4WMOcyzA6OeA5wiwta4gCG jjRp4h3Ihys1yiEF5FuHrVpMlb+kkbm/hMfhrglMrIRLuo2/G9DLhQ5U+8i52XHT4Dh4 g3Iw== 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=Iq5Xh4cI/zY3DrkDmU3iCZiYvsCE7e2msv6ERSQ9RH8=; b=Zdg+O9LpgSJOSKazwdIR6bueLiEhVlUzrPWG8RoHSwJJuz59XOBu3dfW2GcbkSj1HT GEEnP9fATcesjIOzGiy7aZB+8pUTu80QMmY3IlCtArdmLKZOfF4fnhD7Q9LSTWIEIaej Yos3g4u8p527FjGL0RA0AX7GIX9DG0G+YodEJqaQ2F8Go6vjSiXjYPYxQ93WJM/WJTke sosVcOVjweYvvsUFGpGpCDVbJdO/gd0Rf7AmhRZwl1sr+nC/BqJfVmhTm04rdlyisj7i mS43t2v3fg2VB76L6gB2qUiLZnONAjQLZ3twRpoyFgoiKs8EeruFMhPSKxY4W0jSai89 8BbA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 134.134.136.24 as permitted sender) smtp.mailfrom=yu-cheng.yu@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga09.intel.com (mga09.intel.com. [134.134.136.24]) by mx.google.com with ESMTPS id w90-v6si28024425pfk.208.2018.10.11.08.21.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Oct 2018 08:21:44 -0700 (PDT) Received-SPF: pass (google.com: domain of yu-cheng.yu@intel.com designates 134.134.136.24 as permitted sender) client-ip=134.134.136.24; Authentication-Results: mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 134.134.136.24 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 fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Oct 2018 08:21:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,368,1534834800"; d="scan'208";a="77271617" Received: from 2b52.sc.intel.com ([143.183.136.147]) by fmsmga007.fm.intel.com with ESMTP; 11 Oct 2018 08:21:42 -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 , 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: [PATCH v5 01/11] x86/cet/ibt: Add Kconfig option for user-mode Indirect Branch Tracking Date: Thu, 11 Oct 2018 08:16:44 -0700 Message-Id: <20181011151654.27221-2-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181011151654.27221-1-yu-cheng.yu@intel.com> References: <20181011151654.27221-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 | 16 ++++++++++++++++ arch/x86/Makefile | 7 +++++++ 2 files changed, 23 insertions(+) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index ac2244896a18..dd65dae3c5cb 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1919,6 +1919,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 @@ -1943,6 +1946,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 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