Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp459900imi; Fri, 22 Jul 2022 02:52:32 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vtPOTwJ7HLueHTlJKiPD351Vl6XyQO2WD1NKneIimFqcsBP3rNRW4ljWrsm/CVgANeS9qQ X-Received: by 2002:a17:906:98c8:b0:72b:408f:f499 with SMTP id zd8-20020a17090698c800b0072b408ff499mr2470323ejb.736.1658483552168; Fri, 22 Jul 2022 02:52:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658483552; cv=none; d=google.com; s=arc-20160816; b=Eae8zFyNEAbRvTRz84XrgFWJJly/JtbQt8dLDMgy+3mFtYyUCxjIQ8mLTXPJ9QHUVT lBLj3wzilQpq33IAS3nD4tv/WdXNSsS5KK2osiYPR9awY2D/0/QP+4ordFxb4CQyklig aNTjRnjeTFUA+NN+ZbAkHgt0NEIiQAKPWR+1V+YdfRo7QgHKoiaGRoq69kyIi566DZBx tISGRAxXWVRcyWJgZcMUQJQr+OtZO/dFpLl+ZrScwZDdqTI8b7o/Mg3FC5y7CMa9vUYm r8ChlF3NwIoXYcS8U+S1SjxCJ1zDpQ70tVVB2GBx9uMtCYWKnc10Y+sT3IEQV1cyWpNH 9Efg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8qODVT4eXtLwFSwppDBg06+cZJEE/qsyFiVN/HJL6KQ=; b=UhT3iq49MGIsETf0eh6HdPq6Cglh6wA+gq/B3bh6QuKx8Pm//havnkcL8jjY5bF0wo bmT+Q1JDC1MqMHR9a9ks98p/6PW1JHycIAjrzEUEejWKi1aSa1VcsXHVkDDI9nfwHjN8 a8rZZQngWSbYcLZ0qzcR3Vre+YkH593uo2lNUroSeokrnePlJk0O31bQRxI0Th3DukO7 4fIvMHO8owT0VVELzAmkXoAjd98F6Qbyi67jinymTQl5dRxM7fgdBXINPJewpyzDj1Gr 2SSmUTkC6omRsZ93MZH+Tti09Pqtweizdz67yDZT8bJEpem5INcyR6d3bSh8bMI9bN1B IAWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hgzxY4iS; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qa19-20020a170907869300b006feb3a01b16si5550696ejc.683.2022.07.22.02.52.06; Fri, 22 Jul 2022 02:52:32 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=hgzxY4iS; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235325AbiGVJMQ (ORCPT + 99 others); Fri, 22 Jul 2022 05:12:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234853AbiGVJLm (ORCPT ); Fri, 22 Jul 2022 05:11:42 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39823A9BB4; Fri, 22 Jul 2022 02:09:46 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3BA8361EBB; Fri, 22 Jul 2022 09:09:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3C20DC341C6; Fri, 22 Jul 2022 09:09:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658480984; bh=8XmEH2KkaR85M0+HGzx6p/eDV1VjnMNBHree5pGpxsg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hgzxY4iSR1PHFGysS5Yh0sNhhefu2kNSkVp9RoZxfr6NufNK/hKNYfET5xt82UYuQ jhE7QbVV7O6nwO+WjaQdxBic9oHQpiCFyd605L0GISVs8RaDz78ittzzmieNdvsRRu HP7Lz2X0DE7PyEZxDM8/E4HrbVJyLS6/2M9yDyEA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Peter Zijlstra (Intel)" , Borislav Petkov , Josh Poimboeuf , Thadeu Lima de Souza Cascardo Subject: [PATCH 5.18 08/70] x86/retpoline: Cleanup some #ifdefery Date: Fri, 22 Jul 2022 11:07:03 +0200 Message-Id: <20220722090651.188747502@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220722090650.665513668@linuxfoundation.org> References: <20220722090650.665513668@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 From: Peter Zijlstra commit 369ae6ffc41a3c1137cab697635a84d0cc7cdcea upstream. On it's own not much of a cleanup but it prepares for more/similar code. Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Borislav Petkov Reviewed-by: Borislav Petkov Reviewed-by: Josh Poimboeuf Signed-off-by: Borislav Petkov Signed-off-by: Thadeu Lima de Souza Cascardo Signed-off-by: Greg Kroah-Hartman --- arch/x86/include/asm/disabled-features.h | 9 ++++++++- arch/x86/include/asm/nospec-branch.h | 7 +++---- arch/x86/net/bpf_jit_comp.c | 7 +++---- 3 files changed, 14 insertions(+), 9 deletions(-) --- a/arch/x86/include/asm/disabled-features.h +++ b/arch/x86/include/asm/disabled-features.h @@ -56,6 +56,13 @@ # define DISABLE_PTI (1 << (X86_FEATURE_PTI & 31)) #endif +#ifdef CONFIG_RETPOLINE +# define DISABLE_RETPOLINE 0 +#else +# define DISABLE_RETPOLINE ((1 << (X86_FEATURE_RETPOLINE & 31)) | \ + (1 << (X86_FEATURE_RETPOLINE_LFENCE & 31))) +#endif + #ifdef CONFIG_INTEL_IOMMU_SVM # define DISABLE_ENQCMD 0 #else @@ -82,7 +89,7 @@ #define DISABLED_MASK8 0 #define DISABLED_MASK9 (DISABLE_SMAP|DISABLE_SGX) #define DISABLED_MASK10 0 -#define DISABLED_MASK11 0 +#define DISABLED_MASK11 (DISABLE_RETPOLINE) #define DISABLED_MASK12 0 #define DISABLED_MASK13 0 #define DISABLED_MASK14 0 --- a/arch/x86/include/asm/nospec-branch.h +++ b/arch/x86/include/asm/nospec-branch.h @@ -120,17 +120,16 @@ _ASM_PTR " 999b\n\t" \ ".popsection\n\t" -#ifdef CONFIG_RETPOLINE - typedef u8 retpoline_thunk_t[RETPOLINE_THUNK_SIZE]; +extern retpoline_thunk_t __x86_indirect_thunk_array[]; + +#ifdef CONFIG_RETPOLINE #define GEN(reg) \ extern retpoline_thunk_t __x86_indirect_thunk_ ## reg; #include #undef GEN -extern retpoline_thunk_t __x86_indirect_thunk_array[]; - #ifdef CONFIG_X86_64 /* --- a/arch/x86/net/bpf_jit_comp.c +++ b/arch/x86/net/bpf_jit_comp.c @@ -407,16 +407,15 @@ static void emit_indirect_jump(u8 **ppro { u8 *prog = *pprog; -#ifdef CONFIG_RETPOLINE if (cpu_feature_enabled(X86_FEATURE_RETPOLINE_LFENCE)) { EMIT_LFENCE(); EMIT2(0xFF, 0xE0 + reg); } else if (cpu_feature_enabled(X86_FEATURE_RETPOLINE)) { OPTIMIZER_HIDE_VAR(reg); emit_jump(&prog, &__x86_indirect_thunk_array[reg], ip); - } else -#endif - EMIT2(0xFF, 0xE0 + reg); + } else { + EMIT2(0xFF, 0xE0 + reg); + } *pprog = prog; }