Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2178010rwb; Mon, 7 Nov 2022 10:03:54 -0800 (PST) X-Google-Smtp-Source: AMsMyM5EdqbPg3BGFHIEzHvEZclmn2SsGvscPuQlH6ea5NbbKwdy9Ooz9pfoc1i1sy+TGwzIU2ot X-Received: by 2002:a50:cc07:0:b0:453:4427:a918 with SMTP id m7-20020a50cc07000000b004534427a918mr51801366edi.121.1667844234399; Mon, 07 Nov 2022 10:03:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667844234; cv=none; d=google.com; s=arc-20160816; b=tkIOJaORtzqEdJdT1L8I94d/kgp/4QhhLCzvfUHOnWp3j1wt075xbr8/d8vZVfygSR u0NzqSmhPWi5ebaCx0bNW7YB2qTx8XQSB+PIFZtjV1RjxyvzSxWObZ8E0CPi973WEvG1 A024J3JFGXR+Ifj+DQUSp7qR08ap2/+4X73KAYmrzBfX1shHVGMsbw9IMzIstnTpthc8 0WH6Tq3RXUa5hrS5YS6HK3d3Xv7oQHTtkvaWVRNKBwhQ65A66WdZJkGaOwOcIcZpIVeQ FLMK2AdJZhAyCUdRuSdztkAfB4oNEV/PN030eDdMSOyLbtWfOlnDCeV+GhuE2Xu45GyJ UrcQ== 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=gJdffZO5kYB9eNhnO4vweVey1VWb+3Mzd1jym5+DC2I=; b=J9FPr+k3pk/02hHZguMFJtiOn1jZ1qeifJLSHjJOzlKal6eYEfoUMmE2WDMrCjLHBh AkH5FLrunJRL9LMaRpxyVmfM4CRt6hFDyZYvXqlKNOTw6DMdl7Ox7r33rzI1Rp4uxgc2 /aogD1P1en8RoxDAcZMPcOmVaHsny+5yfR2QwFfCSp2K91hd624vOv0WycIqenR6wcK1 9hUR5ZobG8VtGT9VUXA5tmh9JGEXU0O1pWcZSbDEfiMrPTssqsmN9jtW8qqX6Ks4givG 1NjMHqbggnA6BSfS/SKHKenPHOCsUKhg2fXlunnBEIeVHDOSU6Xgerd9lyRCgR2Vzxwb HrLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=ffvOmvwp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h7-20020a05640250c700b00463c30d3f54si10660713edb.340.2022.11.07.10.03.31; Mon, 07 Nov 2022 10:03:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=ffvOmvwp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232285AbiKGRmE (ORCPT + 92 others); Mon, 7 Nov 2022 12:42:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232938AbiKGRl7 (ORCPT ); Mon, 7 Nov 2022 12:41:59 -0500 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E9462126C; Mon, 7 Nov 2022 09:41:57 -0800 (PST) Received: from zn.tnic (p200300ea9733e71f329c23fffea6a903.dip0.t-ipconnect.de [IPv6:2003:ea:9733:e71f:329c:23ff:fea6:a903]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id C065B1EC0722; Mon, 7 Nov 2022 18:41:55 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1667842915; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=gJdffZO5kYB9eNhnO4vweVey1VWb+3Mzd1jym5+DC2I=; b=ffvOmvwpYJnDQy61JsxKGmrhyBduP1zuPftYGVnRVe0JJLAmzK2nPehrNtnVsx3a9e1tO3 SEEM8ppJWvAct3c6sERMe7eEyGZzGrc/aC2OCvrtvTACJ/ED6EELSOM0GLZKPTxN29S60Y Kbc77HICYcQpVecRwwNJN9N4hFdB6Bc= Date: Mon, 7 Nov 2022 18:41:50 +0100 From: Borislav Petkov 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 , 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" , Weijiang Yang , "Kirill A . Shutemov" , John Allen , kcc@google.com, eranian@google.com, rppt@kernel.org, jamorris@linux.microsoft.com, dethoma@microsoft.com, akpm@linux-foundation.org, Yu-cheng Yu Subject: Re: [PATCH v3 03/37] x86/cpufeatures: Add CPU feature flags for shadow stacks Message-ID: References: <20221104223604.29615-1-rick.p.edgecombe@intel.com> <20221104223604.29615-4-rick.p.edgecombe@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20221104223604.29615-4-rick.p.edgecombe@intel.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 Fri, Nov 04, 2022 at 03:35:30PM -0700, Rick Edgecombe wrote: > diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h > index b71f4f2ecdd5..5626ecb8a080 100644 > --- a/arch/x86/include/asm/cpufeatures.h > +++ b/arch/x86/include/asm/cpufeatures.h > @@ -304,6 +304,7 @@ > #define X86_FEATURE_UNRET (11*32+15) /* "" AMD BTB untrain return */ > #define X86_FEATURE_USE_IBPB_FW (11*32+16) /* "" Use IBPB during runtime firmware calls */ > #define X86_FEATURE_RSB_VMEXIT_LITE (11*32+17) /* "" Fill RSB on VM exit when EIBRS is enabled */ > +#define X86_FEATURE_USER_SHSTK (11*32+18) /* Shadow stack support for user mode applications */ This clashes with the calldepth tracking in tip, see updated diff below. > This is off of v6.1-rc3 In the future, please do all your x86 patches against latest tip/master so that there's no issues like that. Thx. --- diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h index 97669aaf1202..8d67249f5232 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -306,6 +306,7 @@ #define X86_FEATURE_RSB_VMEXIT_LITE (11*32+17) /* "" Fill RSB on VM exit when EIBRS is enabled */ #define X86_FEATURE_SGX_EDECCSSA (11*32+18) /* "" SGX EDECCSSA user leaf function */ #define X86_FEATURE_CALL_DEPTH (11*32+19) /* "" Call depth tracking for RSB stuffing */ +#define X86_FEATURE_USER_SHSTK (11*32+20) /* Shadow stack support for user mode applications */ /* Intel-defined CPU features, CPUID level 0x00000007:1 (EAX), word 12 */ #define X86_FEATURE_AVX_VNNI (12*32+ 4) /* AVX VNNI instructions */ @@ -367,6 +368,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 bbb03b25263e..79fbb7799526 100644 --- a/arch/x86/include/asm/disabled-features.h +++ b/arch/x86/include/asm/disabled-features.h @@ -93,6 +93,12 @@ # define DISABLE_TDX_GUEST (1 << (X86_FEATURE_TDX_GUEST & 31)) #endif +#ifdef CONFIG_X86_USER_SHADOW_STACK +#define DISABLE_USER_SHSTK 0 +#else +#define DISABLE_USER_SHSTK (1 << (X86_FEATURE_USER_SHSTK & 31)) +#endif + /* * Make sure to add features to the correct mask */ @@ -108,7 +114,7 @@ #define DISABLED_MASK9 (DISABLE_SGX) #define DISABLED_MASK10 0 #define DISABLED_MASK11 (DISABLE_RETPOLINE|DISABLE_RETHUNK|DISABLE_UNRET| \ - DISABLE_CALL_DEPTH_TRACKING) + DISABLE_CALL_DEPTH_TRACKING|DISABLE_USER_SHSTK) #define DISABLED_MASK12 0 #define DISABLED_MASK13 0 #define DISABLED_MASK14 0 diff --git a/arch/x86/kernel/cpu/cpuid-deps.c b/arch/x86/kernel/cpu/cpuid-deps.c index d95221117129..c3e4e5246df9 100644 --- a/arch/x86/kernel/cpu/cpuid-deps.c +++ b/arch/x86/kernel/cpu/cpuid-deps.c @@ -79,6 +79,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 }, {} }; -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette