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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 49F82C43217 for ; Fri, 14 Oct 2022 17:12:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231251AbiJNRMz (ORCPT ); Fri, 14 Oct 2022 13:12:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231248AbiJNRMy (ORCPT ); Fri, 14 Oct 2022 13:12:54 -0400 Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DE6F8E782; Fri, 14 Oct 2022 10:12:53 -0700 (PDT) Received: from zn.tnic (p200300ea9733e7ed329c23fffea6a903.dip0.t-ipconnect.de [IPv6:2003:ea:9733:e7ed: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 864DA1EC0731; Fri, 14 Oct 2022 19:12:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1665767567; 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=+EYBcfkVNy99Prgg508di+96dEqLLAK9qFDJ8Xcfxdg=; b=b22IDJ7VlnTcVzaDIlOVqru2/dYLiTv0JFljcboinwtN21OTqd5okpwv6ZA6heznM/CbCw 5fxuDDzM103FZ/4e7f16Ctfe2epR2FIGi+sklkTfwoLxbh57cvMIozN9RlYhlKSUSsOaXi 7rlcQcZVUlBm+B9APq8gNrIXtrniSNU= Date: Fri, 14 Oct 2022 19:12:41 +0200 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" , joao.moreira@intel.com, John Allen , kcc@google.com, eranian@google.com, rppt@kernel.org, jamorris@linux.microsoft.com, dethoma@microsoft.com, Yu-cheng Yu Subject: Re: [PATCH v2 04/39] x86/cpufeatures: Enable CET CR4 bit for shadow stack Message-ID: References: <20220929222936.14584-1-rick.p.edgecombe@intel.com> <20220929222936.14584-5-rick.p.edgecombe@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220929222936.14584-5-rick.p.edgecombe@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-doc@vger.kernel.org On Thu, Sep 29, 2022 at 03:29:01PM -0700, Rick Edgecombe wrote: > static __always_inline void setup_cet(struct cpuinfo_x86 *c) > { > - u64 msr = CET_ENDBR_EN; > + bool kernel_ibt = HAS_KERNEL_IBT && cpu_feature_enabled(X86_FEATURE_IBT); So I'd love it if we can get rid of that HAS_KERNEL_IBT thing and use the usual ifdeffery with Kconfig symbols. I wouldn't like for yet another HAS_XXX feature checking method to proliferate as this is the only one: $ git grep -E "\WHAS_" arch/x86/ arch/x86/include/asm/ibt.h:18: * When all the above are satisfied, HAS_KERNEL_IBT will be 1, otherwise 0. arch/x86/include/asm/ibt.h:22:#define HAS_KERNEL_IBT 1 arch/x86/include/asm/ibt.h:92:#define HAS_KERNEL_IBT 0 arch/x86/include/asm/ibt.h:114:#define ENDBR_INSN_SIZE (4*HAS_KERNEL_IBT) arch/x86/include/asm/idtentry.h:8:#define IDT_ALIGN (8 * (1 + HAS_KERNEL_IBT)) arch/x86/kernel/cpu/common.c:601: bool kernel_ibt = HAS_KERNEL_IBT && cpu_feature_enabled(X86_FEATURE_IBT); arch/x86/kernel/cpu/common.c:1942: if (HAS_KERNEL_IBT && cpu_feature_enabled(X86_FEATURE_IBT)) > __noendbr void cet_disable(void) > { > - if (cpu_feature_enabled(X86_FEATURE_IBT)) > - wrmsrl(MSR_IA32_S_CET, 0); > + if (!(cpu_feature_enabled(X86_FEATURE_IBT) || > + cpu_feature_enabled(X86_FEATURE_SHSTK))) > + return; > + > + wrmsrl(MSR_IA32_S_CET, 0); > + wrmsrl(MSR_IA32_U_CET, 0); > } > > + Stray newline. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette