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 9BF59EE49A6 for ; Mon, 21 Aug 2023 01:19:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232411AbjHUBT4 (ORCPT ); Sun, 20 Aug 2023 21:19:56 -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 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