From patchwork Fri Oct 20 11:37:12 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: 156025 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp990494vqb; Fri, 20 Oct 2023 04:38:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHsoyp8BWinWJDVWmtftskVuE/E6GGT0RJhxv98tKN/S4CHqmj13zw3LQINT8hir1VYOCuz X-Received: by 2002:a17:90b:fd4:b0:27d:262b:93ae with SMTP id gd20-20020a17090b0fd400b0027d262b93aemr1338596pjb.33.1697801883781; Fri, 20 Oct 2023 04:38:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697801883; cv=none; d=google.com; s=arc-20160816; b=HGxlDOFGo66s9SpLSCe8BqBX4dQ7KOgNcwCmkgH9hA/dycodYnZGJT3Tc3eLyv96+f JxbAf3+jI8m7kGJ4cdi86vinmqOXtddu7eJh028EiXakhx8+Uy8QF7WAlLn3s/5UJ7fr yzLNj5rrD6zmCJx3fqW6Ev9fPC+MwoyS4r+EBKdngLAM7yT8sdVjrkB5B1S7g+l0JF1t n3G7fdb8oUHEncVvXGXWWy6RzeIeB6Aznn+8Scrdmq1ur16HsXvnTD3MS0rf+qZsurXW kUj3jW4p4h5tVJiGI3IrCybhQaa9JPiPk3MQaE619OsvMUnc6LFWg7ptq6mDR+z5J8Nf Rkuw== 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=tW7YSgvT1sIejWKhmFk87XKju2fsmJGO/qsh36cwBFg=; fh=uvrMkGs9W9ZoLeBS4T0vTU+pLgeqTdyZ4fbbeKTB9Mk=; b=RPQcboMTnl+/1On5rJrl6RqhIUYe0ZEy0vOz6XSQB98oGKtr4VBfgapxwV5cPCG9IY 2S0naJcU7k6y4SOjsC+BBBDoMzqCixmVEn9yBRD50O8KC07due8RbIy5pCJ4dzceo8zT gLEp/kPND9WPw5hYILIyRYY/BBDU8pPGoPBhxwtZ+9xuFeTZV915pT3gRZk7NL+5+pXo XHTcB3rJq8S7wl63kDYp8VF6KiJ/syAIkVWipEY874TCq3ZbFSsbqioZkwJMw5z0gEP9 7VULuUX6c8hXbVHib1kgzLrZiF7LWxVvI6MZFFy94KjCYJ4+Ugjj2t+vuzCEe5B5Of+5 EftQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=dRNM0VnU; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id ml15-20020a17090b360f00b0027d1326d6c3si1606977pjb.121.2023.10.20.04.38.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 04:38:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=dRNM0VnU; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id BBD1B829FDC6; Fri, 20 Oct 2023 04:37:57 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377235AbjJTLhd (ORCPT + 25 others); Fri, 20 Oct 2023 07:37:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377166AbjJTLhU (ORCPT ); Fri, 20 Oct 2023 07:37:20 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6510D4C; Fri, 20 Oct 2023 04:37:18 -0700 (PDT) Date: Fri, 20 Oct 2023 11:37:12 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1697801837; 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=tW7YSgvT1sIejWKhmFk87XKju2fsmJGO/qsh36cwBFg=; b=dRNM0VnUet/tRImlmov45zmlUUj76ZIVDZR3f/n1pChP+I7dw32LGM7uCfQj1tIKgkuV0v qTpADEd6yfebor2/2oS/ghuMt+y363GXiIU06StPuSgGs0pzf7EHf9pFJ0NOpZIXLK9+Sa /qtDpE5N7wrfAv1OA47jJS2j/2W4N3uEOtyvL1DPPe8FCtqo3iHAOr2gBqBkSX3GmMsvi+ qnCBfj3kPMd6Y42fwaSmTGRJ5xhO4aSHXfmOU/th5vDcZ/iQ2CCPFApThrhN7Qbou0PcqP eLIz4tgkoeKHJVWl3SHzCyQx2HZ4B49TwOowslie7dI/WtRhk5QvCYt4Q0Gd5A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1697801837; 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=tW7YSgvT1sIejWKhmFk87XKju2fsmJGO/qsh36cwBFg=; b=itJR1fpxYCK3P6ny2rzPYxaBGcwfOzrZqo4rol5pC2czz+8+Xke3BcQTb+53KjAlrDklNn wGL/rVasFM5YSNDA== From: "tip-bot2 for Borislav Petkov (AMD)" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/bugs] x86/retpoline: Document some thunk handling aspects Cc: Ingo Molnar , "Borislav Petkov (AMD)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20231010171020.462211-1-david.kaplan@amd.com> References: <20231010171020.462211-1-david.kaplan@amd.com> MIME-Version: 1.0 Message-ID: <169780183267.3135.3911908270721154685.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-0.8 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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Fri, 20 Oct 2023 04:37:57 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780274308410283967 X-GMAIL-MSGID: 1780274308410283967 The following commit has been merged into the x86/bugs branch of tip: Commit-ID: 9d9c22cc444af01ce254872b729af26864c43a3a Gitweb: https://git.kernel.org/tip/9d9c22cc444af01ce254872b729af26864c43a3a Author: Borislav Petkov (AMD) AuthorDate: Fri, 20 Oct 2023 13:17:14 +02:00 Committer: Borislav Petkov (AMD) CommitterDate: Fri, 20 Oct 2023 13:17:14 +02:00 x86/retpoline: Document some thunk handling aspects After a lot of experimenting (see thread Link points to) document for now the issues and requirements for future improvements to the thunk handling and potential issuing of a diagnostic when the default thunk hasn't been patched out. This documentation is only temporary and that close before the merge window it is only a placeholder for those future improvements. Suggested-by: Ingo Molnar Signed-off-by: Borislav Petkov (AMD) Link: https://lore.kernel.org/r/20231010171020.462211-1-david.kaplan@amd.com --- arch/x86/lib/retpoline.S | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/arch/x86/lib/retpoline.S b/arch/x86/lib/retpoline.S index d410aba..a48077c 100644 --- a/arch/x86/lib/retpoline.S +++ b/arch/x86/lib/retpoline.S @@ -129,6 +129,13 @@ SYM_CODE_END(__x86_indirect_jump_thunk_array) #ifdef CONFIG_RETHUNK +/* + * Be careful here: that label cannot really be removed because in + * some configurations and toolchains, the JMP __x86_return_thunk the + * compiler issues is either a short one or the compiler doesn't use + * relocations for same-section JMPs and that breaks the returns + * detection logic in apply_returns() and in objtool. + */ .section .text..__x86.return_thunk #ifdef CONFIG_CPU_SRSO @@ -361,6 +368,14 @@ SYM_FUNC_END(call_depth_return_thunk) * This code is only used during kernel boot or module init. All * 'JMP __x86_return_thunk' sites are changed to something else by * apply_returns(). + * + * This should be converted eventually to call a warning function which + * should scream loudly when the default return thunk is called after + * alternatives have been applied. + * + * That warning function cannot BUG() because the bug splat cannot be + * displayed in all possible configurations, leading to users not really + * knowing why the machine froze. */ SYM_CODE_START(__x86_return_thunk) UNWIND_HINT_FUNC