From patchwork Fri Sep 21 15:03:25 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: 10610217 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 C10C25A4 for ; Fri, 21 Sep 2018 15:08:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF96A2E421 for ; Fri, 21 Sep 2018 15:08:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A2E482E423; Fri, 21 Sep 2018 15:08:51 +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 174812E421 for ; Fri, 21 Sep 2018 15:08:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2110F8E0009; Fri, 21 Sep 2018 11:08:50 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1978D8E0002; Fri, 21 Sep 2018 11:08:50 -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 085A58E0008; Fri, 21 Sep 2018 11:08:50 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by kanga.kvack.org (Postfix) with ESMTP id D1E5D8E0002 for ; Fri, 21 Sep 2018 11:08:49 -0400 (EDT) Received: by mail-pf1-f200.google.com with SMTP id p22-v6so6677835pfj.7 for ; Fri, 21 Sep 2018 08:08:49 -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=GItZ6zMjewsshyErngy5TzAWyns2xf+Aa7z7tr61mP8=; b=X03cW1SKHKCLCCVjLXDRKWKyOYl0rlsm7CXr+zH/NbDW0jSZHeykVqfx8GEs8UzU/r qvnUMIk8I2EmhdKoctC0cxlXkedwdVgJ7L+8DFTGSMUzTVLRNz7fRe6ejLYAeTOSU0uA B6QwMMAI74nlP/V3j2XFzW7Hm7W9SdL/tM/MSUDWiwXhV47yuPRfUpeNV8DKMQMEQopv GqX6uE/zJRgzl6bw0churdBTHNDZ9Xk3IF2DywyDFQv5OBxlexKfysaaFUW/TbxQapN2 HJ3uBaqYUYIslGQPgJ8lGyAhFDMSRuJzJJJ1U1lFHYjvic7WuHfwtaQ0j1RLIWTiH3cO Ei2g== 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: APzg51Dl28nGL9RB9Vtd0lmWKtUJR47mhHddUQ4hf7bW6U+Y7W4GFyUz PX32sq3Fy1F34LjQkhpdkxQDwYViD8UTVZLPf3iXjir14AKAfq9f9tr+R5you4WjWx57t76O3i4 VawfLlka0IN2Vs0R4XsUYCRw8CSwj6ajmpdffNQtgkdIn2AXOPgN8Pu1+Ml7/yz7qow== X-Received: by 2002:a63:4a09:: with SMTP id x9-v6mr40440126pga.34.1537542529513; Fri, 21 Sep 2018 08:08:49 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZzfJShXDDFvp0nlRiE7rBrJtzomxuBY8bSMCru33X+zSuzYDO869w39IwM6srDIHEKlw/D X-Received: by 2002:a63:4a09:: with SMTP id x9-v6mr40440073pga.34.1537542528504; Fri, 21 Sep 2018 08:08:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537542528; cv=none; d=google.com; s=arc-20160816; b=d21nwx2jrkIQUXz8ignmMkB3N9LR6ewPbYer6NppbRmcmwxbJj+a1KCoZBX6Ic3GoN UAdykzNAQq0gwSKOTYk7UANmhIXbU2ZB0p7cO4YRtq0ciL8TDSpHZLoFzAxFGqtQXvXd 2ULR0KM52Ip6BLYEeoM6iQPWZkTS6X5Si17GXC4IEBGzt81rMCbF9tjo0NOHo3dz6UXC hCR4QgdqiwdRLpC4oQgB9+1IjrXWG2vuACOic2+Lqfjr32CSzwIoKYCE6wUR9vql0jUg dw08HNXXgo+rtFdlW2PcHGPg3R3X1GVLFs2E+YQw1yQgYzz6h0nQ8VAX2R+7gOG0mPH3 PACA== 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=GItZ6zMjewsshyErngy5TzAWyns2xf+Aa7z7tr61mP8=; b=EZx1v2Xu9zMmRejcATEklt/EjaugxaujF86saJLqjkmfq6Ah1jiKSb3sTA8DJFywYI qcYsxOCs7Nf3hhh9zZ2HkjN3ZKmqTYwyXiOC5KYuWF4ZBAV5Eoez7GW7hJHrJjiFW01h k05gsbCrjA2e5AiZtOYHdXNYMnowZgUx1/fV0TjBNITEYSpOqz/YdOvafN+D+qSqvKin Rd9fQ5ILQx9Fl/A2B3eZhZNLs01HagBfRT8vLMSwjiLVTo0iQnkcv+DPj1SlhqZzSxQF uFjyx3NOBWqkS+cwg1w3pxCPqOxsgcGCc0T+h/7lq/uN1qDfHhCVKe73G4RbZHhrQT1z dDFA== 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 z1-v6si5733063pfc.97.2018.09.21.08.08.48 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Sep 2018 08:08:48 -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; 21 Sep 2018 08:08:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,285,1534834800"; d="scan'208";a="71856530" Received: from 2b52.sc.intel.com ([143.183.136.51]) by fmsmga007.fm.intel.com with ESMTP; 21 Sep 2018 08:08:47 -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 01/27] x86/cpufeatures: Add CPUIDs for Control-flow Enforcement Technology (CET) Date: Fri, 21 Sep 2018 08:03:25 -0700 Message-Id: <20180921150351.20898-2-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180921150351.20898-1-yu-cheng.yu@intel.com> References: <20180921150351.20898-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 Add CPUIDs for Control-flow Enforcement Technology (CET). CPUID.(EAX=7,ECX=0):ECX[bit 7] Shadow stack CPUID.(EAX=7,ECX=0):EDX[bit 20] Indirect branch tracking Signed-off-by: Yu-cheng Yu --- arch/x86/include/asm/cpufeatures.h | 2 ++ arch/x86/kernel/cpu/scattered.c | 1 + 2 files changed, 3 insertions(+) diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h index 89a048c2faec..fa69651a017e 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -221,6 +221,7 @@ #define X86_FEATURE_ZEN ( 7*32+28) /* "" CPU is AMD family 0x17 (Zen) */ #define X86_FEATURE_L1TF_PTEINV ( 7*32+29) /* "" L1TF workaround PTE inversion */ #define X86_FEATURE_IBRS_ENHANCED ( 7*32+30) /* Enhanced IBRS */ +#define X86_FEATURE_IBT ( 7*32+31) /* Indirect Branch Tracking */ /* Virtualization flags: Linux defined, word 8 */ #define X86_FEATURE_TPR_SHADOW ( 8*32+ 0) /* Intel TPR Shadow */ @@ -321,6 +322,7 @@ #define X86_FEATURE_PKU (16*32+ 3) /* Protection Keys for Userspace */ #define X86_FEATURE_OSPKE (16*32+ 4) /* OS Protection Keys Enable */ #define X86_FEATURE_AVX512_VBMI2 (16*32+ 6) /* Additional AVX512 Vector Bit Manipulation Instructions */ +#define X86_FEATURE_SHSTK (16*32+ 7) /* Shadow Stack */ #define X86_FEATURE_GFNI (16*32+ 8) /* Galois Field New Instructions */ #define X86_FEATURE_VAES (16*32+ 9) /* Vector AES */ #define X86_FEATURE_VPCLMULQDQ (16*32+10) /* Carry-Less Multiplication Double Quadword */ diff --git a/arch/x86/kernel/cpu/scattered.c b/arch/x86/kernel/cpu/scattered.c index 772c219b6889..63cbb4d9938e 100644 --- a/arch/x86/kernel/cpu/scattered.c +++ b/arch/x86/kernel/cpu/scattered.c @@ -21,6 +21,7 @@ struct cpuid_bit { static const struct cpuid_bit cpuid_bits[] = { { X86_FEATURE_APERFMPERF, CPUID_ECX, 0, 0x00000006, 0 }, { X86_FEATURE_EPB, CPUID_ECX, 3, 0x00000006, 0 }, + { X86_FEATURE_IBT, CPUID_EDX, 20, 0x00000007, 0}, { X86_FEATURE_CAT_L3, CPUID_EBX, 1, 0x00000010, 0 }, { X86_FEATURE_CAT_L2, CPUID_EBX, 2, 0x00000010, 0 }, { X86_FEATURE_CDP_L3, CPUID_ECX, 2, 0x00000010, 1 },