From nobody Tue Dec 16 18:33:12 2025 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 31B8BEE49B6 for ; Fri, 25 Aug 2023 10:21:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244535AbjHYKUy (ORCPT ); Fri, 25 Aug 2023 06:20:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244411AbjHYKUK (ORCPT ); Fri, 25 Aug 2023 06:20:10 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8622E2109; Fri, 25 Aug 2023 03:19:51 -0700 (PDT) Date: Fri, 25 Aug 2023 10:19:31 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1692958772; h=from:from:sender:sender:reply-to: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tHkizebMsECbcTe74PA3ogCCbvgICRT0m+8IAmbfh2U=; b=n6BhbZBF4F8dDftEJxbIRd7eVtDz+fZpMvURfseu+yv0mE95DieK4cBfoaPgsBsHIMQbqp GfQf88GjCojyuwnEveUAxN5rUMbZhCDcwXPYPE53cEDjRVdZriYJDLrekCsArIh7+Pn5m2 FkXpHSNV2ohaWFtqrvxtDBOTsnp1pvZUCH6vQDkx3QUSvtika8bw4ozZ9fUyjRixfnXVnm 2uEgzgxw/hZ3FGT8j4Khx6DGnkxMazve8aZFoJvSUd7A9XPsnMfX2QdSpG+yjLymDpuZ4t i/ooDRSpQ9usk16/khOLoTb2/YgYzF/+8Ha2hX7usRuTGPtihmhM10t55v3x9w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1692958772; h=from:from:sender:sender:reply-to: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tHkizebMsECbcTe74PA3ogCCbvgICRT0m+8IAmbfh2U=; b=AZiMy243d5SHrXJC+xtsSYuRnwYh8t1Ql5BeBfKvz74HsCAxLSjisNQAr/Si9UakoglCFx cjNS5Pjkuq0cO/Dw== From: "tip-bot2 for Josh Poimboeuf" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/bugs] x86/alternatives: Remove faulty optimization Cc: Josh Poimboeuf , Ingo Molnar , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: References: MIME-Version: 1.0 Message-ID: <169295877160.27769.14262638853493570689.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the x86/bugs branch of tip: Commit-ID: 4f643529501794ef9baabfe65612da8a2a8eff5b Gitweb: https://git.kernel.org/tip/4f643529501794ef9baabfe65612da8a2= a8eff5b Author: Josh Poimboeuf AuthorDate: Fri, 25 Aug 2023 00:01:43 -07:00 Committer: Ingo Molnar CommitterDate: Fri, 25 Aug 2023 11:22:00 +02:00 x86/alternatives: Remove faulty optimization The following commit: 095b8303f383 ("x86/alternative: Make custom return thunk unconditional") 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 Signed-off-by: Ingo Molnar Link: https://lore.kernel.org/r/ca76a2e94217d6fc8e007d2ca79fee219f3168f8.16= 92919072.git.jpoimboe@kernel.org --- 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 099d58d..34be5fb 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 *star= t, s32 *end) { s32 *s; =20 - /* - * 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 =3D=3D __x86_return_thunk)) - return; - for (s =3D start; s < end; s++) { void *dest =3D NULL, *addr =3D (void *)s + *s; struct insn insn;