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 B2671C7EE2C for ; Fri, 25 Aug 2023 07:03:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243109AbjHYHC6 (ORCPT ); Fri, 25 Aug 2023 03:02:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242624AbjHYHCL (ORCPT ); Fri, 25 Aug 2023 03:02:11 -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 0F271D3 for ; Fri, 25 Aug 2023 00:02:10 -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 E452366618 for ; Fri, 25 Aug 2023 07:02:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E5660C433C8; Fri, 25 Aug 2023 07:02:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692946929; bh=oDaAPQ4MM+hX/ir4eTMXwkf2sKUGdJD31TI52vLR7Iw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=stHo7l2GonNEWy4AsrdykJlkht0Lsq6esLszF0M5/WdYmi3uK27/uWuGFJlgLtduR sVmDek5FodlX/ZnGt4G5oP2oX65woe76/agqYLW8JwjA8B8sj/bY7j+OnfEZCXiUjd pO3jIfsGYCA1riZGpyoAWYYdPPjuoRlF/m1eOCLVopTBfq5BtCA2b/nTjCpjFaOleJ o2Pm2lvbV3k3cHKkPQtLQGF0/pZfjtEheMrubOFBTwYlNfVFN14EKqQg9xfiF3UvZ2 fAYX5dO01DHRN5bDe1oxEEYI1YQkXX0+5kmGOpaTDBmJEIr6xlibkzHIL7cjz/D9Mv VUHuNZggbbH9w== 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 12/23] x86/alternatives: Remove faulty optimization Date: Fri, 25 Aug 2023 00:01:43 -0700 Message-ID: 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