From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A18D6C4332F for ; Mon, 7 Nov 2022 18:37:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EB53A6B0071; Mon, 7 Nov 2022 13:37:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E65B96B0072; Mon, 7 Nov 2022 13:37:30 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D2CED8E0001; Mon, 7 Nov 2022 13:37:30 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id C17236B0071 for ; Mon, 7 Nov 2022 13:37:30 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 90A47140189 for ; Mon, 7 Nov 2022 18:37:30 +0000 (UTC) X-FDA: 80107504260.18.1E213D5 Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) by imf16.hostedemail.com (Postfix) with ESMTP id A98DB180004 for ; Mon, 7 Nov 2022 18:37:26 +0000 (UTC) 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 76AF71EC059D; Mon, 7 Nov 2022 19:37:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1667846242; 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=ltXQMShsByXnuTxy9rVs5hzHUnj2fKxptiwJ6JDDxxI=; b=WswS6nowYrD7HOA1CKiSinEVVs19Mx1DZJ4uL8wIXOH8iq5mjHNOq5BUqN3Zi+F/VLE5k4 sbVF7XPPF4xDL9ywiYCT7mZkuO35NXnjOevEOCyiB0ycO0OzCbdJ4AyaaigoYMoFwkjTLy jP11GdsqJjf3Gl9rB7peaxnb7aCERuA= Date: Mon, 7 Nov 2022 19:37:17 +0100 From: Borislav Petkov To: "Edgecombe, Rick P" Cc: "bsingharora@gmail.com" , "hpa@zytor.com" , "Syromiatnikov, Eugene" , "peterz@infradead.org" , "rdunlap@infradead.org" , "keescook@chromium.org" , "Yu, Yu-cheng" , "dave.hansen@linux.intel.com" , "kirill.shutemov@linux.intel.com" , "Eranian, Stephane" , "linux-mm@kvack.org" , "fweimer@redhat.com" , "nadav.amit@gmail.com" , "jannh@google.com" , "dethoma@microsoft.com" , "kcc@google.com" , "linux-arch@vger.kernel.org" , "pavel@ucw.cz" , "oleg@redhat.com" , "hjl.tools@gmail.com" , "linux-doc@vger.kernel.org" , "Lutomirski, Andy" , "arnd@arndb.de" , "jamorris@linux.microsoft.com" , "tglx@linutronix.de" , "mike.kravetz@oracle.com" , "x86@kernel.org" , "Yang, Weijiang" , "john.allen@amd.com" , "rppt@kernel.org" , "mingo@redhat.com" , "Shankar, Ravi V" , "corbet@lwn.net" , "linux-kernel@vger.kernel.org" , "linux-api@vger.kernel.org" , "gorcunov@gmail.com" , "akpm@linux-foundation.org" Subject: Re: [PATCH v3 04/37] x86/cpufeatures: Enable CET CR4 bit for shadow stack Message-ID: References: <20221104223604.29615-1-rick.p.edgecombe@intel.com> <20221104223604.29615-5-rick.p.edgecombe@intel.com> <14b4c6e3d5b7b259e832ff44e64597f1cf344ffe.camel@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <14b4c6e3d5b7b259e832ff44e64597f1cf344ffe.camel@intel.com> ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667846250; h=from:from:sender: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:dkim-signature; bh=ltXQMShsByXnuTxy9rVs5hzHUnj2fKxptiwJ6JDDxxI=; b=NUDvry+zjPpvk66ph/+3U2KHwdJeT4wSOg96AcrI2XpwNzgtCbEiSsKosP5Dq82xx+jqUw CUI5GOa9lkWnNMbLWHEfgytM+S6ZHWnyhcT9Dg7r9igmK5FQlBFu6eoezwsjDKS4h6LbsY 3ys4tgFh3NGiB1xhFwGC9x+XI1RxUrI= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=alien8.de header.s=dkim header.b=WswS6now; spf=temperror (imf16.hostedemail.com: error in processing during lookup of bp@alien8.de: DNS error) smtp.mailfrom=bp@alien8.de; dmarc=pass (policy=none) header.from=alien8.de ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1667846250; a=rsa-sha256; cv=none; b=Lb6uff2L1JpYW1mYQwC5jP8A9D/pZ3jYy8Lz9+oOYvpPIpRdNScKvNgfMuWrJM9j5DKLyq nXy1Ow0zoVEx1QWiiWjiRclJVr0KhyQj5l1yoSoxI72AhJVTRIvICqo2VHxLKJiL+IsWio M/UK8AlTp05KnswLmj9+Mn5VKv5gpbI= X-Rspamd-Queue-Id: A98DB180004 X-Rspam-User: X-Rspamd-Server: rspam08 Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=alien8.de header.s=dkim header.b=WswS6now; spf=temperror (imf16.hostedemail.com: error in processing during lookup of bp@alien8.de: DNS error) smtp.mailfrom=bp@alien8.de; dmarc=pass (policy=none) header.from=alien8.de X-Stat-Signature: 4r95rua9hpxt6aqksry5eg3qkjbwmtck X-HE-Tag: 1667846246-347484 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: On Mon, Nov 07, 2022 at 06:19:48PM +0000, Edgecombe, Rick P wrote: > It was to catch if the software user shadow stack feature gets disabled > at boot with the "clearcpuid" command. I don't understand. clearcpuid does setup_clear_cpu_cap() too. It would eventually clear the bit in boot_cpu_data.x86_capability's AFAICT. cpu_feature_enabled() looks at boot_cpu_data too. So what's the problem? Oh, and also, you've added that clearcpuid thing to the help docs. Please remove it. clearcpuid= taints the kernel and we've left it in because some of your colleagues really wanted it for testing or whatnot. But it is crap and it was on its way out at some point so we better not proliferate its use any more. > Is there a better way to do this? Yeah, cpu_feature_enabled() should be enough and if it isn't, then we need to fix it to be. Which reminds me, I'd need to take Maxim's patch too: https://lore.kernel.org/r/20220718141123.136106-3-mlevitsk@redhat.com as it is a simplification. > > Here you need to do > > > > setup_clear_cpu_cap(X86_FEATURE_IBT); > > setup_clear_cpu_cap(X86_FEATURE_SHSTK); > > This only gets called by kexec way after boot, as kexec is prepping to > transition to the new kernel. Do we want to be clearing feature bits at > that time? Hmm, I was under the impression you'll have the usual chicken bit "noshstk" which gets added with every big feature. So it'll call that thing here. > Sure, sorry about that. I'll target tip for the next version. Thanks! -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette