Received: by 2002:a05:7412:1703:b0:e2:908c:2ebd with SMTP id dm3csp814058rdb; Fri, 25 Aug 2023 01:40:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHf66zm/k/dsc1hoq/TiAjnYEEYO/U7RqKcGJzBmrr/T48XJIwMFYfRhkRvSz3tQnPO6v8d X-Received: by 2002:aca:b06:0:b0:3a7:8e2a:6173 with SMTP id 6-20020aca0b06000000b003a78e2a6173mr2169806oil.2.1692952829740; Fri, 25 Aug 2023 01:40:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692952829; cv=none; d=google.com; s=arc-20160816; b=SaWeppknXGBPFT+DaK6GwPzDu0L6OoPxbXZjkJKJbFtLuOgfVd8/hMBEZQh07+v4w0 nY3OSkbeqqRDwdO7tJwyZDO0Jdzf6srlLbXTzwkC9XT6qFLjbkP6qS4+3ztx/FUbuSV5 gL/QEl/kJ/3JzCZCN4XglZgqEz4LN0A8rozLr83xdvBM3EoDKpymYc7hdUa/SbpW4LP0 Q0bSqc/m1wVs2TfZKQKy9Xz5zFypiwp2EmFeLThAJlN6CZ3tG3TnQC+J0jq6GhjiElm4 lrcTgtOCkEqnA8HH3dmYGQW9ms/JfK1ua0uVmdlCTh9/a6DgiL73pzc5IGuSS7gcj+8M EB/w== 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=ZwaEcDYNCnlh+U7YxZ1LCEcet9pcdhSkEX0cCEOksvY=; b=XeEM0ph4XFkRhRRyRFLSq5Qo8/rQ8tWOsQQvGqLzAPCUmJ/fXdam725crFTLxW3q3N 4AIjL50w5tRIRFqvSdKIrqjKKo741GD0Hxnd5zaemKn5QnsD2nlG+A03dgyxyNckeQxS yArLF9d1uoAjC6j2z1jbmzqokXxsfG4PlokRfEkQ+nMVLULZxZGZTr2e9X2TVI17+C3s sa5WBN1m8PJ4voVAWZ1+/Uxred4F8S4W8FJR5Pb9CSPo3l3p77Gre4CtKXXb7USdTCpd CwWXjMJMFw41nI+e1C0Ur2UzXwQimkB7UAjKZT9MOceOpsSV7KepqHcb/za4XtA+w0zH vJ3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=stHo7l2G; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m2-20020a056a00080200b0068a6f6d9f81si1504742pfk.126.2023.08.25.01.40.13; Fri, 25 Aug 2023 01:40:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=stHo7l2G; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243102AbjHYHC4 (ORCPT + 99 others); Fri, 25 Aug 2023 03:02:56 -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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,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