From patchwork Thu Jun 7 14:35:40 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: 10452241 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D497F60375 for ; Thu, 7 Jun 2018 14:40:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C461B294DD for ; Thu, 7 Jun 2018 14:40:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B8178294DF; Thu, 7 Jun 2018 14:40:01 +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 38371294DD for ; Thu, 7 Jun 2018 14:40:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2DAA66B0008; Thu, 7 Jun 2018 10:40:00 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2B09C6B0006; Thu, 7 Jun 2018 10:40:00 -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 178036B0008; Thu, 7 Jun 2018 10:40:00 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg0-f70.google.com (mail-pg0-f70.google.com [74.125.83.70]) by kanga.kvack.org (Postfix) with ESMTP id CADD96B0003 for ; Thu, 7 Jun 2018 10:39:59 -0400 (EDT) Received: by mail-pg0-f70.google.com with SMTP id o19-v6so3583564pgn.14 for ; Thu, 07 Jun 2018 07:39:59 -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=yO2Vm0WO2jzfqpcs9K9wigtb5AulckpT9TMgvNXc1ww=; b=Ye0KxUqQSkdn2/KQs/geeQurmxs8twxcqI8V7Zb0utjqStkJCNxl8g5v4Z+AOLvj08 /FfLov8f5sSeRRAPl3Yv6amxA2H2cGGtMem1CHYgeuubIXY2RBjGLQdiDVora6JlGwfn R/Ce1pcMXzv/mirGalAwccZ0Ux8qh9MZNc/OsCLy3T8en149tHZSZr+/f6Yn00jMTx56 sU3WvHC0gdbKWGCPvV49ARwPa6vUcUYSFFvaAws3f74GvQc7mmNSMwJBAT4gMfZC/bH1 CeITNj+9kT+UL6yddjBc53Ifbe6fFxy/8Kop2HCXjQe/TI3KRrYvevE6DlaWY9zJGlZn saQQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 134.134.136.20 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: APt69E0HXN7cuDeD6gHOYdQPnNnQkhdfWkN0T0C5SFzqgZfb87vYK9zD G4bvlgEbb86ki9kZv6oI+4su3vHmBnxakHFAvwiESQM9f8cQ734b/NK8pwgRnF9WXvOOLg2xqrh dwowZRWvv3FUT+6W+ZGNYFWUYfDa70+mQiKJhWC90dhFOmfNGzgbj7eP1NlFX/Wm8dw== X-Received: by 2002:a17:902:ac97:: with SMTP id h23-v6mr2355948plr.140.1528382399493; Thu, 07 Jun 2018 07:39:59 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKGnFzm/5jrLonskvzxTkFYixLYaZ/gqOlBBVxxsxeEc2N6bthPxRpuunE2OZGvdhl/FEXd X-Received: by 2002:a17:902:ac97:: with SMTP id h23-v6mr2355906plr.140.1528382398698; Thu, 07 Jun 2018 07:39:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528382398; cv=none; d=google.com; s=arc-20160816; b=aSR+hEtKF9+TSf3IGq/vgN60Fp1zKMo/ZZK2x3HNasd3LBteJZyrLZdMSypURsb7fh eW0+gtT3UoeZQ5PscwUjUlzlELap/igK7um6PoqxDf5bqwEL6dai2y7vDi7FMgsDlRZT j6lxdLEr/5oHDvZ+jBA+8VTtgaCYW5JiT1v5zVNqxA+pnBfjT9OGSH43395apnXvm0yC 2/KEIMLSPZuVKqu6g7vTKhlpXb1QR/oGYg+21nY8E3whaMVTFvTkCCHdmESqo60LrtKC ixTIel6QS4te4xWXfa8/xKI62LV+TSQNjwmWYfBOglWmS4d1PRe3K2XT7k6nAyk5+flJ h4Fg== 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=yO2Vm0WO2jzfqpcs9K9wigtb5AulckpT9TMgvNXc1ww=; b=LCpn+ePth+ZwXW8fQNaPH+yR0vnCty76fRAwLfL0hAnjRmYZln871aTcWOHfQUypd+ h2pZz3GtxvqsqM6Jz/PPfHCuGmunPhwdfF29PzjafZxO13SF3Ejm5Nft+7bCnqcQhT7m MO5EtdwLacB7Zw73YEgyIPFmKEQUShv/MaTT0a7vf7Ufl2v05oL4L+7IW4FvbvRM/E2b JhjsZgJ4QHDs5qthNVS3o8KEMRRjSNzpFTgIp5LHdosm+c9z1xFAyTR7OGIoP4w1g2NQ 8GIv6rPcY0vAOZbZiqC0i+3NF13NXEoO0V2ug2gu6zfWrm5icBooa5yurLGoFE5nLmR3 pbkg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 134.134.136.20 as permitted sender) smtp.mailfrom=yu-cheng.yu@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga02.intel.com (mga02.intel.com. [134.134.136.20]) by mx.google.com with ESMTPS id 88-v6si53306702pla.315.2018.06.07.07.39.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 07:39:58 -0700 (PDT) Received-SPF: pass (google.com: domain of yu-cheng.yu@intel.com designates 134.134.136.20 as permitted sender) client-ip=134.134.136.20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 134.134.136.20 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 orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Jun 2018 07:39:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,486,1520924400"; d="scan'208";a="54825986" Received: from 2b52.sc.intel.com ([143.183.136.51]) by fmsmga002.fm.intel.com with ESMTP; 07 Jun 2018 07:39:57 -0700 From: Yu-cheng Yu To: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, x86@kernel.org, "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , "H.J. Lu" , Vedvyas Shanbhogue , "Ravi V. Shankar" , Dave Hansen , Andy Lutomirski , Jonathan Corbet , Oleg Nesterov , Arnd Bergmann , Mike Kravetz Cc: Yu-cheng Yu Subject: [PATCH 1/5] x86/cpufeatures: Add CPUIDs for Control-flow Enforcement Technology (CET) Date: Thu, 7 Jun 2018 07:35:40 -0700 Message-Id: <20180607143544.3477-2-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180607143544.3477-1-yu-cheng.yu@intel.com> References: <20180607143544.3477-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 fb00a2fca990..244c2aa07f0c 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -219,6 +219,7 @@ #define X86_FEATURE_IBPB ( 7*32+26) /* Indirect Branch Prediction Barrier */ #define X86_FEATURE_STIBP ( 7*32+27) /* Single Thread Indirect Branch Predictors */ #define X86_FEATURE_ZEN ( 7*32+28) /* "" CPU is AMD family 0x17 (Zen) */ +#define X86_FEATURE_IBT ( 7*32+29) /* Indirect Branch Tracking */ /* Virtualization flags: Linux defined, word 8 */ #define X86_FEATURE_TPR_SHADOW ( 8*32+ 0) /* Intel TPR Shadow */ @@ -317,6 +318,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 },