Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1644268pxb; Wed, 9 Feb 2022 01:01:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJwnr57ENFnKGtdh2jZ9etByn32Zx4wpOoCPX0d10wvJFj2RzbFOzs8vVvhvOmwNV8HBVBUz X-Received: by 2002:a17:90a:7f85:: with SMTP id m5mr1404108pjl.5.1644397280422; Wed, 09 Feb 2022 01:01:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644397280; cv=none; d=google.com; s=arc-20160816; b=J+WiZhZJZkf8Urz/TauDQBMGRCJSCi2OqJ8sRt08ypygweZlcZepkxBnwF2lEu3PRr OfijfvZn33gQpXYa7Z5mV2jHqJqEprdZsySew2J1GuyLnfbWm/uaRnCU5xDt1RxuTJVe eAbHvp4//IjAs0X2SZB4dlNOWmQAzsYquq4MO+tW+Pea8S9L30G+zvB3Q8VkEOZBDONi gzM720Xn64NFxZ9MUf/Q7A8C5eqcjUWaExr2wAgdWvUWX9oE/WfSakmogp7rYK04rMD5 sKlCi8YwzshRcLp8M+kC0Z8LoKytVqWA4tBPEolYShaKs87uDlT8c1spyr8GYXMhaXvq c0Nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=krZ7XDngCuaQ/kaEDAhJETqO/lCcgabbGCGZ64ZW5mg=; b=vjWJAbr9iBf3xpSfjXRqnmQodChkvzs4mTzyAzndypNZWMeWqUOU1bGemRPzkmFL70 FnA7YyoB8anPpTlHEYVkck38S7/rddaW4mjuGhFkgeD31wXaiFOyXQvQBMDCxB+KAleB te0ozeiqxitUwDt9oK0a9+L2kzHf3TC3i8SayG1+/YhkYZTpW2R0Z8G/P5yyXHU9tEhi k5x2ZW72cdCo+EnrvdlhKrVjpYLeTrHo0qbOfO6h4jycC/y25APdGzHLRuXAoaBoGVPA i6ppaL1HPaUnWHJdSI0LrxvLcAvSPiD0Z6LQ0oGGKcN/1c3YnPaFECA6P30A5N2N7CzQ gFSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=B01e8AvR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id oa10si4778504pjb.146.2022.02.09.01.01.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 01:01:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=B01e8AvR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8F969C1DC16C; Wed, 9 Feb 2022 00:49:10 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239778AbiBICma (ORCPT + 99 others); Tue, 8 Feb 2022 21:42:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242104AbiBIBKd (ORCPT ); Tue, 8 Feb 2022 20:10:33 -0500 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 554FEC06174F for ; Tue, 8 Feb 2022 17:10:32 -0800 (PST) Received: by mail-pj1-x102a.google.com with SMTP id v5-20020a17090a4ec500b001b8b702df57so3596594pjl.2 for ; Tue, 08 Feb 2022 17:10:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=krZ7XDngCuaQ/kaEDAhJETqO/lCcgabbGCGZ64ZW5mg=; b=B01e8AvROu8wzAWvnNc18YbXO4k2zAp/FgRgRHBcFtqjYpKfCKhf7Kc6cTHWN3J1h+ Ckp20PmKRI8ExSgFiVFMDw1LR/I0GvkZyP8im4vYtSfL6Hyvf9Qg+MXw9i4rui+Giqwl 3JFxHmZuIKASMn6wPqEmWknLrINw4rKAFikTo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=krZ7XDngCuaQ/kaEDAhJETqO/lCcgabbGCGZ64ZW5mg=; b=Xl3Y4Zm1BolcIeAi63x++0YEKSQKh48Jnl8n9LQGgwz0auNwG3PEYwgC3cwaI0SYTF nJCC5kYPazDC3MfdbxOaC8vFdg+Ov+YAiJIt7/aJD8FK1xeivhEv8sDmJUPT3lkxiSBe LdrbCSzwwUbDQWwgJsnfXEfhSbqphDcj2RBJw/DgJlCssDE0or/DANhX+5logc3xN0bF 6HWq5mNXTYyxahAD2v9Trr2q+pSWG0vRhNwChcZ11/M2mpe7ObcNDcYe5uFFuu07DF6B ODMjHnTmNLPky8pcaXjD26fXqCiJ6c54kgKw5xpxaE706AOcnn+YbIjUkpVAcTMZ8T1F QtLw== X-Gm-Message-State: AOAM532a/1euv2PzTWSpS6cq+W4X+w0btgjZwXn8ZK48wy+l8RKcjRig Ypq+BDBDWihFn270L5e9WSrraA== X-Received: by 2002:a17:903:41c6:: with SMTP id u6mr7045085ple.74.1644369031529; Tue, 08 Feb 2022 17:10:31 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id b4sm17437326pfl.106.2022.02.08.17.10.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 17:10:31 -0800 (PST) Date: Tue, 8 Feb 2022 17:10:30 -0800 From: Kees Cook To: Rick Edgecombe Cc: 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 , 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, Yu-cheng Yu Subject: Re: [PATCH 03/35] x86/cpufeatures: Add CET CPU feature flags for Control-flow Enforcement Technology (CET) Message-ID: <202202081709.96226C0B@keescook> References: <20220130211838.8382-1-rick.p.edgecombe@intel.com> <20220130211838.8382-4-rick.p.edgecombe@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220130211838.8382-4-rick.p.edgecombe@intel.com> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jan 30, 2022 at 01:18:06PM -0800, Rick Edgecombe wrote: > 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 It looks like this only adds the SHSTK bit, maybe drop mention of IBT here. I wonder if we could land this (and the IBT part) without waiting for everything else in the respective series? -Kees > > 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 > -- Kees Cook