From patchwork Thu Aug 30 14:38:41 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: 10581829 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 E8E4B5A4 for ; Thu, 30 Aug 2018 14:43:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D79C12B560 for ; Thu, 30 Aug 2018 14:43:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CAFCE2BC25; Thu, 30 Aug 2018 14:43: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 542642B560 for ; Thu, 30 Aug 2018 14:43:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D54AB6B521C; Thu, 30 Aug 2018 10:43:45 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D2C936B521D; Thu, 30 Aug 2018 10:43: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 BA0526B521E; Thu, 30 Aug 2018 10:43:45 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by kanga.kvack.org (Postfix) with ESMTP id 688C96B521B for ; Thu, 30 Aug 2018 10:43:45 -0400 (EDT) Received: by mail-pg1-f198.google.com with SMTP id r130-v6so2461809pgr.13 for ; Thu, 30 Aug 2018 07:43: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=GItZ6zMjewsshyErngy5TzAWyns2xf+Aa7z7tr61mP8=; b=MlufohkZU3NNtS6vRzQxmApPtijzAD6qkQdyvwPLP6GRqxCT83WjCo2RQiaxhtaCIV UVmS2juMmlu6M6vTHpKsT0MD9heJURImKqNbbi95JYLqc3Vwz4HxvNMJW8RZpgB82Nfi Ct4vPOy9YHPnqADSpjkiM26cXuomlKRweV+uL1SqSW9UQmhBHDbabfW/N+kT5F006Jmw 3gje2Ywbz58IBmxdi3Av5+gyw/0VHVxHGwDflALLuo2l8W8PkbyA+0LRqjaOCJeumOov 7QrEcBS2z/wvo1xM2OgOJMU5bkXj8Jat0CojR83JYN5RZwQ1rjNcsRC4p6h34fLUr++x YEQQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 134.134.136.65 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: APzg51DUawyf+iNZWnVQ/umOt4s1SBgw0CzXjlug/nl6JObMq7nm8hNw dfXsHFe2VwRIW0vFv9OD+mDpwKw053g67GU8t+pamHw5gUvea7GQk0LUtOxb7qfmhhJqOthEGoa hp84v0ceUfwlnvByqDFFkj3ndDJEIXWGWcXinA9TIKkSP8tTWFXNRqzH5pLWjwdJsAw== X-Received: by 2002:a63:e914:: with SMTP id i20-v6mr10072206pgh.10.1535640225100; Thu, 30 Aug 2018 07:43:45 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdb6NGXeqEVRGEYKspXinzamcjMYwh2yg1S98UylXuuWxCUM1kKFDb8/Ka2Qp99y7hm8OVwl X-Received: by 2002:a63:e914:: with SMTP id i20-v6mr10072175pgh.10.1535640224453; Thu, 30 Aug 2018 07:43:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535640224; cv=none; d=google.com; s=arc-20160816; b=NGv1Yfx3Hf09ohpfJkx4bCikmutELXbapBwDwXVKXGDkSZ6uBs5Myhj4sj3qVpyKBa x7VDlWM0Ga4krxID5p1wv6QWTwJIBoUQ5fkxTW7OW+dC3Pw8x0IqEXlzT0sGeNbmPMLB amtuGpklVPZ/7oAhfTbQnSUy7LGpv4ceAH9O9vaDUBJR9hP2c0It8uJueDkv8s6KgHuL QuVk81oVHuUBLO3x0z3BTvjgZ/IXdPKk6W+d4cgJXLS1aqr6r49JOfMViLhScjbZc7Of UqeuBkXvMr0494aqpZdhiT8k1At97SRWFIoxu/9Yf1OoC0P5ejLp2Z/KJqhfXfHrJX86 pQTw== 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=GItZ6zMjewsshyErngy5TzAWyns2xf+Aa7z7tr61mP8=; b=Vu5GNiUv5g/SLse0c4FlLGMNI+O1R5yIxPlZaFGt+c+nEZDvyeFnbTbSTEHJYDGLhK 3O+DDv3IpkiN/qyqlAKGt07KA4yzBNTunwjiK0OMqNimB8rvY1ZhXH0Ji4UWw+M9W9q7 KGrADWxkfNOzJaP9Y67jIexQel5qBicXpV2aMsAFHg42034WFUxRsIvFxqbSE7Z5V9Fc 7zgCrkqZc6urX+SHVpS63NLh6HUDzWDl1SDoZc+AtofK9akNuf8wVPLtlHvYuBIiCilJ zHV/vstilGTP+mCXKtoTS0HBIr8QTM210FC9Z2T8ts1arvqX+qezhtKgJNBpdPCoUJtj 4yAQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 134.134.136.65 as permitted sender) smtp.mailfrom=yu-cheng.yu@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga03.intel.com (mga03.intel.com. [134.134.136.65]) by mx.google.com with ESMTPS id c15-v6si6092534plo.232.2018.08.30.07.43.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Aug 2018 07:43:44 -0700 (PDT) Received-SPF: pass (google.com: domain of yu-cheng.yu@intel.com designates 134.134.136.65 as permitted sender) client-ip=134.134.136.65; Authentication-Results: mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 134.134.136.65 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 fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Aug 2018 07:43:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,307,1531810800"; d="scan'208";a="67186662" Received: from 2b52.sc.intel.com ([143.183.136.52]) by fmsmga008.fm.intel.com with ESMTP; 30 Aug 2018 07:43:39 -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 01/24] x86/cpufeatures: Add CPUIDs for Control-flow Enforcement Technology (CET) Date: Thu, 30 Aug 2018 07:38:41 -0700 Message-Id: <20180830143904.3168-2-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180830143904.3168-1-yu-cheng.yu@intel.com> References: <20180830143904.3168-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 },