Received: by 2002:a05:7412:1492:b0:e2:908c:2ebd with SMTP id s18csp193408rdh; Mon, 21 Aug 2023 11:50:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEA8ydZMvp5QtNto51upgclXe/sCF/StQy4RAvykAtdJ4wLOn+ko/zHXC+LdsWzCfkDk3Qk X-Received: by 2002:a05:6a20:5485:b0:123:3ec2:360d with SMTP id i5-20020a056a20548500b001233ec2360dmr10863051pzk.5.1692643818907; Mon, 21 Aug 2023 11:50:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692643818; cv=none; d=google.com; s=arc-20160816; b=Tu0gV4i7dY5zPYKZoP2IbOGy86BpzAsbJqKA5JjPw66scZSc8CLmAFlGayyoLOj+3A 08chiQC+iMM5tZoDibfpnbcsPFY8JrgcZ6Y43AQNOKdK2pY8BhDiLuopIqkeFiCzLpIY mEF8ihvRVanR1EhOPeVbOsBan7x//lyrPSo+7obHhgKrpItSpaH4gtlAbYpEg1edMyrR SPu1cPpgq5u7QpAjN/jlWFSBQpCBTxHH7vrdq1JLCxFWbFsOAawvdljDxu+roH0rUcvL 2FAJOVdoAquwaagB2Xd4yFMlYCYti5CjZvhc14jIHPvJt3By4lTfiOHrRxnkb4s+NCZv yr5A== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pWv0nf2X417tL/81eMVP7ailstorSri2x+z25WkoKC0=; fh=1KVrD/LnRsN9N7k2d12iARV4DA2tVMW012QtKSrD46c=; b=Rjgt8W2eR2lZM0OOtB6+UcEVTjIB2lR4/nAWAZYclfrThnzWFPwK0tqWoZb9lJJSPf WOtcWhlknQws7z5opT2em6XQd4dfSCpM1GAvvdat63A15pS59nbhM2JZsMlgnQV5EPv5 VFrzoNpkVhBdCHK9vux604uC1NNbozx2g5i08/jBI/yS1ZeRsIGGXVm9iOUNvV1B++TL L9zC88MzUx0jYX+Rz6Dt4AF+2hORcg826BgPUZu7zBoF1VupaumFzjJ42a6kJUBzVREV /jm8dGyKIXuVdH4gL6Ww+bTBzcQ/NG+R0cn95W3bQwfN1YI1RrvSvjiC7aJAaMb/nWET s7hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PMu8yu8b; 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=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id y4-20020a056a001c8400b00689ede9d38asi7640453pfw.72.2023.08.21.11.50.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Aug 2023 11:50:18 -0700 (PDT) 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=@kernel.org header.s=k20201202 header.b=PMu8yu8b; 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=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6F48C185; Mon, 21 Aug 2023 11:28:44 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232408AbjHUBTz (ORCPT + 99 others); Sun, 20 Aug 2023 21:19:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232324AbjHUBTk (ORCPT ); Sun, 20 Aug 2023 21:19:40 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D826CB6 for ; Sun, 20 Aug 2023 18:19:36 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B061162605 for ; Mon, 21 Aug 2023 01:19:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A9984C433C7; Mon, 21 Aug 2023 01:19:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692580776; bh=oDaAPQ4MM+hX/ir4eTMXwkf2sKUGdJD31TI52vLR7Iw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PMu8yu8bGBSOxDDJAD/LQfRypkvl/aa+5CU8CEtQ6JVIGGAwTzbCkP+auHMIc1xfe 0X4OFfS9iHcmqrU3LND5ZfbcmsUOyPsc3UsAnCI+E7jWWvqI5HLhyiYokBiLU7dir4 Fj7y5bCkYpYH29nCjmjRU3mbrhH/kA/56E3EHC0Fq39Db6fX9joP6jx3VqJXgfRuMH +CsmpEyGhySaelaCPN2ZUbYScL80/Zky9jdhNzizWglHw/SIZZa9Sk2NXe3HSD/91V aFKhXqIvrsG9TdozGKTxyapYEUaRq1Sk1eUayoQl0Ekz3bTSCz1WZ85WjZ3kr5DTMl LJ35YrF+E0sUw== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Borislav Petkov , Peter Zijlstra , Babu Moger , Paolo Bonzini , Sean Christopherson , David.Kaplan@amd.com, Andrew Cooper , Nikolay Borisov , gregkh@linuxfoundation.org, Thomas Gleixner Subject: [PATCH 15/22] x86/alternatives: Remove faulty optimization Date: Sun, 20 Aug 2023 18:19:12 -0700 Message-ID: <6820be098b2a450294980d19b0f7b0d75758202d.1692580085.git.jpoimboe@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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 The following commit 095b8303f383 ("x86/alternative: Make custom return thunk made '__x86_return_thunk' a placeholder value. All code setting X86_FEATURE_RETHUNK also changes the value of 'x86_return_thunk'. So the optimization at the beginning of apply_returns() is dead code. Also, before the above-mentioned commit, the optimization actually had a bug It bypassed __static_call_fixup(), causing some raw returns to remain unpatched in static call trampolines. Thus the 'Fixes' tag. Fixes: d2408e043e72 ("x86/alternative: Optimize returns patching") Signed-off-by: Josh Poimboeuf --- arch/x86/kernel/alternative.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c index 099d58d02a26..34be5fbaf41e 100644 --- a/arch/x86/kernel/alternative.c +++ b/arch/x86/kernel/alternative.c @@ -720,14 +720,6 @@ void __init_or_module noinline apply_returns(s32 *start, s32 *end) { s32 *s; - /* - * Do not patch out the default return thunks if those needed are the - * ones generated by the compiler. - */ - if (cpu_feature_enabled(X86_FEATURE_RETHUNK) && - (x86_return_thunk == __x86_return_thunk)) - return; - for (s = start; s < end; s++) { void *dest = NULL, *addr = (void *)s + *s; struct insn insn; -- 2.41.0