Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp227233rdb; Thu, 19 Oct 2023 02:41:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHDybfva0I5VUu7wO0dncVONbm4wom2z0u9BcBoo1xj6Zylvgv4KcVbWCGByHty2DaHbuJ3 X-Received: by 2002:aca:1b19:0:b0:3b2:defb:e562 with SMTP id b25-20020aca1b19000000b003b2defbe562mr1694548oib.45.1697708478356; Thu, 19 Oct 2023 02:41:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697708478; cv=none; d=google.com; s=arc-20160816; b=auTbrzkUXrrfcOQwVxNFfKFqFI1hS0e99hBQh9Dfy8wPMIK72FGVv6OiMa+iz1j/LI rgWAFasPpM889PwjpSNSGJ84Emqz5FxnV5t8JMCow7AU6DlHgPrTknzQtEbGTEpZdjrj kyobomu1xIZKngf3YbGcHuFmcx7PwsaUKQC69c4WXd+heeL5nrFgxTNIkcv8XRro9SeQ DQAoyvEM8XRQ7hZY/0OMrQWUwgU3SYy6ftYEQNzpG5KXwcbqS/nXnDZBKUjqWfqjnBt3 Cr7vq30bFIeJP/y4bnWETZcTlOFN07iFSTC/4Of2dfnIxUwvP6jTEpjbkLrbnxYGcHb1 Tw0g== 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=yUJTtqQy8fxReyCCLvdrNXSV2ZMQEboWT57HId+dVGE=; fh=4aeplautAs7bU5gJ7ngaVl0sohDCu59iYYwp4ByJ6sI=; b=yQlMa/78dz5WaRzEPxnkomNHrfCKZ6mPhV9buOP7rwPtAs213CME+U9YvgXYuqxeEP 0P7huVcdI5SoRliHsmKohqB1ZpEEaxdRAYuyexXP6vG1FZ3JTP3227RsGFa1LYySLSc8 2WlB9VzJ+pCdJtodPZ8Cny2+NowJecjF2pzbxVncG38gx7mRdRF8BieTrH1lrA7bkXgo gnE82ELOENs2NjvjAVtVUo5/OQzf3fdDPmM/f+Gwj8QIzmSPB4v7pza+sTFwBi3ibYYw hB7h5spkNNuRbztq64odqiZAKVcZ5CRpoXZh9d6+mdQhWt8OyvMjnJGPxai9qC9KHY7r GROw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=GVsg1dGe; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id x4-20020a056a00188400b006be30cdc3d8si6049849pfh.163.2023.10.19.02.41.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 02:41:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=GVsg1dGe; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id 048D6826E5A2; Thu, 19 Oct 2023 02:41:02 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345046AbjJSJky (ORCPT + 99 others); Thu, 19 Oct 2023 05:40:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229660AbjJSJks (ORCPT ); Thu, 19 Oct 2023 05:40:48 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BB56B8; Thu, 19 Oct 2023 02:40:46 -0700 (PDT) Date: Thu, 19 Oct 2023 09:40:42 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1697708444; 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=yUJTtqQy8fxReyCCLvdrNXSV2ZMQEboWT57HId+dVGE=; b=GVsg1dGe2b5VqgRj8oOnpSoxwVcc4fUyoxTH6aK82wRyJbigYF2CbmxqxwibTExKCC1UOy hCaROgeG5utE114eJUhlilEQ11Xe0P4ndEh70LW79pm9LW4rvLF5dQQSB5ppgNgZzPz7D4 Za3AsBmftO1S3kcvg2nmLNjndtnLoU88IOgwvHn5ZXi5P7+1Yf3ggYrV2SONgxAzSZjcFN H56Fl5w3CoQb99rG5wWRgNDaWxVICkzbk3IqHTlzFzNs/Z8V9Qcy1oOjorVKag/+DHtXKE aatsRpL45IklnWsQU/2ej0lqP3Q/0W7XydHMPGBINT3e+lCwxssiuiiv8WL8Gg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1697708444; 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=yUJTtqQy8fxReyCCLvdrNXSV2ZMQEboWT57HId+dVGE=; b=OxQf2vEeXbrfrcCTSabG30/pepop5YpP2nMyiL10w1ldPbi7ZKvPtFAoXeC9s5AZzFB6wx l7nxghLbpd0OnFBA== 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] Revert "x86/retpoline: Remove .text..__x86.return_thunk section" Cc: David Howells , "Borislav Petkov (AMD)" , Josh Poimboeuf , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20231018175531.GEZTAcE2p92U1AuVp1@fat_crate.local> References: <20231018175531.GEZTAcE2p92U1AuVp1@fat_crate.local> MIME-Version: 1.0 Message-ID: <169770844297.3135.7611435585309229027.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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 morse.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 (morse.vger.email [0.0.0.0]); Thu, 19 Oct 2023 02:41:02 -0700 (PDT) The following commit has been merged into the x86/bugs branch of tip: Commit-ID: 59e6ce1eaaa2d9b2f9c89a108ce3fc7510bcd7ea Gitweb: https://git.kernel.org/tip/59e6ce1eaaa2d9b2f9c89a108ce3fc7510bcd7ea Author: Borislav Petkov (AMD) AuthorDate: Thu, 19 Oct 2023 11:09:41 +02:00 Committer: Borislav Petkov (AMD) CommitterDate: Thu, 19 Oct 2023 11:25:19 +02:00 Revert "x86/retpoline: Remove .text..__x86.return_thunk section" This reverts commit e92626af3234708fe30f53b269d210d202b95206. David Howells reported his box freezing without being able to see a panic. However, it managed to issue a warning beforehand: missing return thunk: __x86_indirect_thunk_r15+0xa/0x5f-0x0: eb 74 66 66 2e WARNING: CPU: 0 PID: 0 at arch/x86/kernel/alternative.c:755 apply_returns+0xca/0x247 Modules linked in: CPU: 0 PID: 0 Comm: swapper/0 Not tainted 6.6.0-rc5-next-20231013-build3+ #3044 Hardware name: ASUS All Series/H97-PLUS, BIOS 2306 10/09/2014 RIP: 0010:apply_returns+0xca/0x247 this happened with linux-next and with gcc 13. Looking at the compiler output and particularly paying attention to the two JMP instructions: <__x86_indirect_thunk_r14>: e8 01 00 00 00 call ffffffff81d71206 <__x86_indirect_thunk_r14+0x6> cc int3 4c 89 34 24 mov %r14,(%rsp) e9 91 00 00 00 jmp ffffffff81d712a0 <__x86_return_thunk> 66 66 2e 0f 1f 84 00 data16 cs nopw 0x0(%rax,%rax,1) 00 00 00 00 66 0f 1f 44 00 00 nopw 0x0(%rax,%rax,1) <__x86_indirect_thunk_r15>: e8 01 00 00 00 call ffffffff81d71226 <__x86_indirect_thunk_r15+0x6> cc int3 4c 89 3c 24 mov %r15,(%rsp) eb 74 jmp ffffffff81d712a0 <__x86_return_thunk> the second JMP is a short JMP one. This is likely some new gcc optimization to size the JMP offsets and generate a small one if it fits. However, the apply_returns() logic does not expect a short JMP: if (op == JMP32_INSN_OPCODE) dest = addr + insn.length + insn.immediate.value; and that JMP32_INSN_OPCODE is 0xe9. Now, if __x86_return_thunk is in another section, the compiler cannot do those shortcuts and will have to generate a JMP with a s32 offset. As a matter of fact, the removal of the section broke another case, see https://lore.kernel.org/r/20231010171020.462211-2-david.kaplan@amd.com so revert for now until all the possible code generation issues have been assessed, addressed and verified properly. Reported-by: David Howells Tested-by: David Howells Signed-off-by: Borislav Petkov (AMD) Cc: Josh Poimboeuf Link: https://lore.kernel.org/r/20231018175531.GEZTAcE2p92U1AuVp1@fat_crate.local --- arch/x86/kernel/vmlinux.lds.S | 3 +++ arch/x86/lib/retpoline.S | 2 ++ 2 files changed, 5 insertions(+) diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S index 9cdb1a7..54a5596 100644 --- a/arch/x86/kernel/vmlinux.lds.S +++ b/arch/x86/kernel/vmlinux.lds.S @@ -132,7 +132,10 @@ SECTIONS LOCK_TEXT KPROBES_TEXT SOFTIRQENTRY_TEXT +#ifdef CONFIG_RETPOLINE *(.text..__x86.indirect_thunk) + *(.text..__x86.return_thunk) +#endif STATIC_CALL_TEXT ALIGN_ENTRY_TEXT_BEGIN diff --git a/arch/x86/lib/retpoline.S b/arch/x86/lib/retpoline.S index 6376d01..d410aba 100644 --- a/arch/x86/lib/retpoline.S +++ b/arch/x86/lib/retpoline.S @@ -129,6 +129,8 @@ SYM_CODE_END(__x86_indirect_jump_thunk_array) #ifdef CONFIG_RETHUNK + .section .text..__x86.return_thunk + #ifdef CONFIG_CPU_SRSO /*