From patchwork Tue Sep 19 09:53:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 141857 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp3346908vqi; Tue, 19 Sep 2023 05:30:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFn4GLqaM129HUqg2Vk8vvggRYpKD787ZenAggu/7b/DaouxwHMaJ5zHYceUICgv169+vXx X-Received: by 2002:a17:90a:bd8b:b0:263:72fe:3ef7 with SMTP id z11-20020a17090abd8b00b0026372fe3ef7mr10673952pjr.42.1695126651882; Tue, 19 Sep 2023 05:30:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695126651; cv=none; d=google.com; s=arc-20160816; b=qlqkFGGjMfSZM6QTr789Da7H2bx6JpMdedu0Fwbxo2knBsrxN87REO0mNrZin6WK+U OlRGawoTpP+W2cMgPJLkRhvxCWXmtkVjpBEm2K8rDRqBQKxCUY9TEWhcu+azrjaMmXl8 O8A+DktX8rlNa9de/gRHEdjvClzLtE5A3eHxLgh/vjp3VxTS+suQtvBrPR5IFouOhQFt H09uEdOtDGPII/D5xv5NIVx1wKvca1H8hJ0wK4YUHLyP/HRW699L5SI8AI5qlE2KjU83 XW24MXnDnpIyRy26TLFYMljPlV0Bl6XyAnSuPAqdyHRMuV2B5ZptrkI5v8NwkHvGS8+f wrNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=xBMH5cY+WWuS+ewEgw1SpLF0Nkjac+v6iZCL+I4aQrY=; fh=TJa98jjcJcAUyvo2yQiOqi+wukdLlQU80th5XskGe8U=; b=egQQz0Q3E3adAfH9Rn+Q4Lyyt/hluSEoq5VI1mC+j6UHVclVQv1pSM4JSSEU/IA1Je xGOof1JxLI7kEmX7dPMyv/CD72psWshG8mUpRNMy626rE8M4hHI5tML+lqoIoD2mesYW NKq07XarV3qj1wTRlBzm6//Aiolq1MHWqFukEN5jP6Eq3sXIYc2EJrgYOCkV8YhnS0QT /595UJexaFYy6QrSngKd9xawv3Ss3J30t5aEZCWLCCK3S3oz+Kw82DyAE80aLGrM4v1i QruVH8jYrSzJDZl7MomnEQJGnzPY7P3++9IboKURBHB68y1J0lcXuOqa8AV9JNAlNZvZ 690g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=UUqm9Dvt; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id mn20-20020a17090b189400b002631e44f48csi9553199pjb.179.2023.09.19.05.30.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 05:30:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=UUqm9Dvt; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id DBAFB81F3412; Tue, 19 Sep 2023 02:54:53 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231853AbjISJyC (ORCPT + 26 others); Tue, 19 Sep 2023 05:54:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231837AbjISJxV (ORCPT ); Tue, 19 Sep 2023 05:53:21 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10DD1CD2; Tue, 19 Sep 2023 02:53:15 -0700 (PDT) Date: Tue, 19 Sep 2023 09:53:13 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1695117193; 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=xBMH5cY+WWuS+ewEgw1SpLF0Nkjac+v6iZCL+I4aQrY=; b=UUqm9DvtN4FRP1tTT0uHJcRcMgsuXnITchPKLHWT5a7tav4EaRIyKwJORk8zrb/4IHKnYt T15UFph3L255P69DvlWaAVXz4PZHinLPxZb4T+yToDeeU2Sj62qFZzUl+N2lcmeWvnPV/f zWHrmPvAGU5oZIXhFQirA6t+kIFFkigD7RHzGvvPEIZ0tu946aPdcKaCGDkj2fcTISUmFi n00G053/N6k3FSD5+a95CLse3lb7WLA7atFfhbDSBTSr5klQrlceDit8uqD0sUib7jZ14i tTshSthhvHYfC0T1pAkusUK8eqYwykpqguY12TRqbnELqBMC55bO8C7jmaFfmA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1695117193; 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=xBMH5cY+WWuS+ewEgw1SpLF0Nkjac+v6iZCL+I4aQrY=; b=uLKt8kXzFYyh5hNFWX7O1/2ciL+SFDzgus089txAI0Alcqu3o4hKxjd1WHmHHtrdhEBiPb KwVjCe2urGR+TiCQ== 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 , "Borislav Petkov (AMD)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <16d19d2249d4485d8380fb215ffaae81e6b8119e.1693889988.git.jpoimboe@kernel.org> References: <16d19d2249d4485d8380fb215ffaae81e6b8119e.1693889988.git.jpoimboe@kernel.org> MIME-Version: 1.0 Message-ID: <169511719305.27769.14807367532070919458.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Tue, 19 Sep 2023 02:54:54 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777469124029236617 X-GMAIL-MSGID: 1777469124029236617 The following commit has been merged into the x86/bugs branch of tip: Commit-ID: eae1a2bb7dd350195c18f1788f5d687684d8d92d Gitweb: https://git.kernel.org/tip/eae1a2bb7dd350195c18f1788f5d687684d8d92d Author: Josh Poimboeuf AuthorDate: Mon, 04 Sep 2023 22:04:54 -07:00 Committer: Ingo Molnar CommitterDate: Tue, 19 Sep 2023 11:42:47 +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 Acked-by: Borislav Petkov (AMD) Link: https://lore.kernel.org/r/16d19d2249d4485d8380fb215ffaae81e6b8119e.1693889988.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 a5ead6a..c850f5a 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;