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 EC20ACA0FE2 for ; Tue, 5 Sep 2023 16:33:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352629AbjIEQ1w (ORCPT ); Tue, 5 Sep 2023 12:27:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350993AbjIEFFT (ORCPT ); Tue, 5 Sep 2023 01:05:19 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91FB9CCF for ; Mon, 4 Sep 2023 22:05:16 -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 sin.source.kernel.org (Postfix) with ESMTPS id C1889CE10A3 for ; Tue, 5 Sep 2023 05:05:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A00BEC433C9; Tue, 5 Sep 2023 05:05:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1693890313; bh=M0a/H/pEcZzBFFM+N5QiV+JwT5qTf0DWq1jP92T/lrQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KcCit0MPQ0HnJSGUQfsZmxxM2bUxQIRSETXau2n+eWtQz31dypini42TkDWTGzVOZ XgEW0CtLhsLJ9wkhike5qbboOHCqBHwPKJ8vTYr6UMsqnuHitl3IOI9VXEGJoDPH/c R33fx59r4dx+WDR5MtSKzuXuF1Nbo+BJ+0BJznmSUfrFdKlStkKQyACOWCC/hLxQn+ T5Qls47z4XCCNn6vemLzBnwn/Fl18tf2hb9lGD58TDMr442kHxoRgn/D2CwNQg5AGR dkcESPZ90FyfcrsjHIbWF/qgppQDv+yKnVc3e2yNipmUGito6Dg0Pn9T9bp20aW89s KkjTln9B5LmDw== 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 v3 10/20] x86/alternatives: Remove faulty optimization Date: Mon, 4 Sep 2023 22:04:54 -0700 Message-ID: <16d19d2249d4485d8380fb215ffaae81e6b8119e.1693889988.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 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 --- 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