Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp619477pxb; Tue, 1 Feb 2022 07:07:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJwyvor2WPTyE2In8COH+GohEVCQ/4g/0rvtklxrnRO0VcmvJeFcUulMpWiXxj58k/KTmiYM X-Received: by 2002:a05:6402:510b:: with SMTP id m11mr25716484edd.290.1643728074400; Tue, 01 Feb 2022 07:07:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643728074; cv=none; d=google.com; s=arc-20160816; b=f7+2GmXaBnvgPFtNelgk6T+ZgW5eqLihpWNwQ3DF72C2lOqQ7dXQKiDZnt5Hyjyp6v CfaiL9WO/p3fqtcb1GlezGZ/mVin/66c+VkJt2msp7yrKbUelV2uuCwBBHw7U58szbT8 LeL5VB4I6kQtxZLkFwULwlcTOVf18cyrKdfzdRpMkFIrkrXbVmd8MbBBuIfJ1i/TevDc +tgYJszHAgJOAKnGdBkFdoT2r8h/8tLnSTz2yuIn3B4XEdejrodb7F/3+s6aw3iJ5+8o GQiBV3ojYmCUxXx9ieAH5LuhQDNKj9cbcjHNbHFXFAX6iLiJH1DaJ68bjly6dUszazOR gT7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=XSkW1Og7jHRh4w7YuWn3DORd0x/IKnsafBTZ5/MAgu0=; b=CqfXQLjRJCu5YC44rjNO3VrxRHNLgrgn121wvGRrIpsehv7uf1CRJEISlxXCB3/gCP Quj/0P5YkQUb0Kn+CTaKEA1o7rRueTfQHN+BxDpbdsKKH0o3JWOPHUhhXYWM/j7c+fee Ir99AC82bDM++sYGDQ6dcGRiYdaZCTXm4p2MhX9uE1CX88ug7Bf4Tc1JuH3QetxzkN09 PFJ5yMFXHHLkPWBqeqXMoGk6ubG22GS+BsFQyD06uFjXrYXOrMaBALLUD7b6DZQusuGd Azy5Xf1UWU/5nsIqUmgyAFwYSmp2gDwI2qn4TpCrpK893MuRW1Up4exj/0Pe0dYHeDJF K/9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=NuVM01z8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s2si8822880ejs.394.2022.02.01.07.07.28; Tue, 01 Feb 2022 07:07:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=NuVM01z8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356522AbiA3VWA (ORCPT + 99 others); Sun, 30 Jan 2022 16:22:00 -0500 Received: from mga06.intel.com ([134.134.136.31]:52015 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356440AbiA3VVt (ORCPT ); Sun, 30 Jan 2022 16:21:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643577709; x=1675113709; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=GmgTdNk6+MhoR9z6kCfchMrEnFl9sg5ugfj0SfBqJ+w=; b=NuVM01z8F0AYb8RPMjPo8JyLsdodO0fQOhpFXW/t9n9ECGZvKnNueq+X FFU2t+YwuU/Xf3rISTCQNcGscYtNAspDo9cq1hdET650bOnu2oCv9TLCA iI59znlaGhDIXYH2BLVHWmsbLEJhfX3e82h/+1Drb4gysjhPcKdwegV3g lSyY7Mr3IP1j+a51yOGzWm/PJ5OB3Gyt601mxxElYKM2XyhBbTc6hsfxJ EIheg6kv9cZLJh0hwx58x1rT6/9p7mnX+g8tz41lkUjOFeUe2vEJ21A+Y m/qA3zAQEiEba5mEQ0aR+avN/xUR7G115RcHxswnCq7lXRDhtTdYO8Wn0 g==; X-IronPort-AV: E=McAfee;i="6200,9189,10243"; a="308104885" X-IronPort-AV: E=Sophos;i="5.88,329,1635231600"; d="scan'208";a="308104885" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jan 2022 13:21:49 -0800 X-IronPort-AV: E=Sophos;i="5.88,329,1635231600"; d="scan'208";a="536856671" Received: from avmallar-mobl1.amr.corp.intel.com (HELO rpedgeco-desk.amr.corp.intel.com) ([10.209.123.171]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jan 2022 13:21:48 -0800 From: Rick Edgecombe 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 , Borislav Petkov , 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" , Dave Martin , Weijiang Yang , "Kirill A . Shutemov" , joao.moreira@intel.com, John Allen , kcc@google.com, eranian@google.com Cc: rick.p.edgecombe@intel.com, Yu-cheng Yu Subject: [PATCH 03/35] x86/cpufeatures: Add CET CPU feature flags for Control-flow Enforcement Technology (CET) Date: Sun, 30 Jan 2022 13:18:06 -0800 Message-Id: <20220130211838.8382-4-rick.p.edgecombe@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220130211838.8382-1-rick.p.edgecombe@intel.com> References: <20220130211838.8382-1-rick.p.edgecombe@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yu-cheng Yu Add CPU feature flags 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 Signed-off-by: Rick Edgecombe Cc: Kees Cook --- v1: - Remove IBT, can be added in a follow on IBT series. Yu-cheng v25: - Make X86_FEATURE_IBT depend on X86_FEATURE_SHSTK. Yu-cheng v24: - Update for splitting CONFIG_X86_CET to CONFIG_X86_SHADOW_STACK and CONFIG_X86_IBT. - Move DISABLE_IBT definition to the IBT series. arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/include/asm/disabled-features.h | 8 +++++++- arch/x86/kernel/cpu/cpuid-deps.c | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h index 6db4e2932b3d..c3eb94b13fef 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -355,6 +355,7 @@ #define X86_FEATURE_OSPKE (16*32+ 4) /* OS Protection Keys Enable */ #define X86_FEATURE_WAITPKG (16*32+ 5) /* UMONITOR/UMWAIT/TPAUSE Instructions */ #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/include/asm/disabled-features.h b/arch/x86/include/asm/disabled-features.h index 8f28fafa98b3..b7728f7afb2b 100644 --- a/arch/x86/include/asm/disabled-features.h +++ b/arch/x86/include/asm/disabled-features.h @@ -65,6 +65,12 @@ # define DISABLE_SGX (1 << (X86_FEATURE_SGX & 31)) #endif +#ifdef CONFIG_X86_SHADOW_STACK +#define DISABLE_SHSTK 0 +#else +#define DISABLE_SHSTK (1 << (X86_FEATURE_SHSTK & 31)) +#endif + /* * Make sure to add features to the correct mask */ @@ -85,7 +91,7 @@ #define DISABLED_MASK14 0 #define DISABLED_MASK15 0 #define DISABLED_MASK16 (DISABLE_PKU|DISABLE_OSPKE|DISABLE_LA57|DISABLE_UMIP| \ - DISABLE_ENQCMD) + DISABLE_ENQCMD|DISABLE_SHSTK) #define DISABLED_MASK17 0 #define DISABLED_MASK18 0 #define DISABLED_MASK19 0 diff --git a/arch/x86/kernel/cpu/cpuid-deps.c b/arch/x86/kernel/cpu/cpuid-deps.c index c881bcafba7d..bf1b55a1ba21 100644 --- a/arch/x86/kernel/cpu/cpuid-deps.c +++ b/arch/x86/kernel/cpu/cpuid-deps.c @@ -78,6 +78,7 @@ static const struct cpuid_dep cpuid_deps[] = { { X86_FEATURE_XFD, X86_FEATURE_XSAVES }, { X86_FEATURE_XFD, X86_FEATURE_XGETBV1 }, { X86_FEATURE_AMX_TILE, X86_FEATURE_XFD }, + { X86_FEATURE_SHSTK, X86_FEATURE_XSAVES }, {} }; -- 2.17.1