From patchwork Mon Jul 10 08:13:56 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: 117727 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp4884589vqx; Mon, 10 Jul 2023 02:04:19 -0700 (PDT) X-Google-Smtp-Source: APBJJlFrJ4ZDnIMKaep3wGV9qXeJz4r8lRYYgWue/AY82IHIhcwtSTc+tjYyo9696XQLuiB3sUEv X-Received: by 2002:a17:902:9a0c:b0:1b8:a7ec:38c5 with SMTP id v12-20020a1709029a0c00b001b8a7ec38c5mr9103233plp.57.1688979858626; Mon, 10 Jul 2023 02:04:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688979858; cv=none; d=google.com; s=arc-20160816; b=SSlvDuyxaQMT++0KD+99V0Uq28N/083HuhxtRbgsOYE4Cc5JYFLKZpwbypEr/eAK9r ewCeEqSXIJYXLE0DvG7ypCbdLJyahGTF+5o5/du+hYCcOv7osO8T9kxHGmcuzDzZrx10 ZDQ9FXSz7EqkJoK/CgC5MGAw1tyZB+7It8dgWAoc15ebds+zsEVyweNhUwJb1TUFqswi RYvF+NDkh7HI/6zOIrStXqePtpErIUea5Q59NRh0ZQGd9QkP7bnm61wiazE5RRIvH/Q6 zdbSikIeUT2yxAWX6OzieUYgrQqJ4YEBVkqFhwhtJqc8cFPHpnTsgs1OgHDSVbEe8i3h xEAA== 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=EOtDsWidxulmTHHJmhH5S2A/34jwRP1wgHitph7bleo=; fh=PK9Ni4Z6k2JNEZEkuWt1R7XDlExCoWxEbGPoLHJ2kjM=; b=MklWIoja7HHQiXHkJLmROtYUI7+PcuOoPaHmWFNxilZb6tet5vi+8/2+jbluofUdjZ TLcWWtXOU0p/OfrBZsJxeyw7PbqjIiu7WKNw9RmJ3TcWbKdhoTcKWtY0bnwsMWKY3SO/ MEm+mh3HJ8sybi8CaTXHwdoRdslpn5moOdlGmNVFYZk89Yg/ipx3sQKHsPS5ovQdz2aZ nz2uovKTv2cp5tk50ZB8j/yS0M0UVIfJUv3VAA4fyYQSW8HkjWDXAjAMMJr2SfsXejoO dBXfx5IOh59qH/xLBikKdPvgVevxiR0d2UPIHwtX2eMnZzIboRyd5LD1jNHEs9aAbiii bEfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=CMAFuLvV; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=UoE61XaP; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k3-20020a170902e90300b001b8bb836d45si3082628pld.69.2023.07.10.02.04.06; Mon, 10 Jul 2023 02:04:18 -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=@linutronix.de header.s=2020 header.b=CMAFuLvV; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=UoE61XaP; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232855AbjGJIPl (ORCPT + 99 others); Mon, 10 Jul 2023 04:15:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232674AbjGJIN7 (ORCPT ); Mon, 10 Jul 2023 04:13:59 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5AFB3E7; Mon, 10 Jul 2023 01:13:58 -0700 (PDT) Date: Mon, 10 Jul 2023 08:13:56 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1688976837; 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=EOtDsWidxulmTHHJmhH5S2A/34jwRP1wgHitph7bleo=; b=CMAFuLvV6wWa7N1QaRCCIF/B4d4m3lIIsKs2JoZZ3w0NO+tCfCLRs9S8AQ0H99eZ43avSq L+EBT1WhAFH7fGUxx37mV0Nm66i6xsKVAqUMwWuWC7TlEQ9tUhvaQ3GcDEYS/48ch6hDr4 Bx8gmoB0PBcz5G3HNkfkKt5XWUXGjUJpbQWTroZpol6HlKN9EU6Nvf8UEqiQtL710eHfBh ADAcMv+hHPuy0qRhSHxyVZCF/boW5ECqAZyWFNKDqGza4UzlYd6axujCpD9xybWc1BKPHR K1cGNDQs03lFnQ3POYrAYdS42/WnI3oY+MtSxqndPhkgNc6ozO3tJn4yygGPMQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1688976837; 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=EOtDsWidxulmTHHJmhH5S2A/34jwRP1wgHitph7bleo=; b=UoE61XaP+CqBT7jo5KbtTwuTHuI6MnB4xwFKnqpGlwqwNAeujkEEP53JPZgekTZuxpDt2M g96cji8O0w5zM/Cg== From: "tip-bot2 for Brian Gerst" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/urgent] x86/32: Remove schedule_tail_wrapper() Cc: Brian Gerst , "Peter Zijlstra (Intel)" , Kees Cook , Sami Tolvanen , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230623225529.34590-2-brgerst@gmail.com> References: <20230623225529.34590-2-brgerst@gmail.com> MIME-Version: 1.0 Message-ID: <168897683652.404.733058783899665441.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1769536052043766700 X-GMAIL-MSGID: 1771023744045594885 The following commit has been merged into the x86/urgent branch of tip: Commit-ID: 81f755d561f365f544795fad92f05a085ea4f292 Gitweb: https://git.kernel.org/tip/81f755d561f365f544795fad92f05a085ea4f292 Author: Brian Gerst AuthorDate: Fri, 23 Jun 2023 18:55:28 -04:00 Committer: Peter Zijlstra CommitterDate: Mon, 10 Jul 2023 09:52:24 +02:00 x86/32: Remove schedule_tail_wrapper() The unwinder expects a return address at the very top of the kernel stack just below pt_regs and before any stack frame is created. Instead of calling a wrapper, set up a return address as if ret_from_fork() was called from the syscall entry code. Signed-off-by: Brian Gerst Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Kees Cook Reviewed-by: Sami Tolvanen Link: https://lkml.kernel.org/r/20230623225529.34590-2-brgerst@gmail.com --- arch/x86/entry/entry_32.S | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S index 91397f5..e56123f 100644 --- a/arch/x86/entry/entry_32.S +++ b/arch/x86/entry/entry_32.S @@ -720,26 +720,6 @@ SYM_CODE_END(__switch_to_asm) .popsection /* - * The unwinder expects the last frame on the stack to always be at the same - * offset from the end of the page, which allows it to validate the stack. - * Calling schedule_tail() directly would break that convention because its an - * asmlinkage function so its argument has to be pushed on the stack. This - * wrapper creates a proper "end of stack" frame header before the call. - */ -.pushsection .text, "ax" -SYM_FUNC_START(schedule_tail_wrapper) - FRAME_BEGIN - - pushl %eax - call schedule_tail - popl %eax - - FRAME_END - RET -SYM_FUNC_END(schedule_tail_wrapper) -.popsection - -/* * A newly forked process directly context switches into this address. * * eax: prev task we switched from @@ -748,16 +728,23 @@ SYM_FUNC_END(schedule_tail_wrapper) */ .pushsection .text, "ax" SYM_CODE_START(ret_from_fork) - call schedule_tail_wrapper + /* return address for the stack unwinder */ + pushl $.Lsyscall_32_done + + FRAME_BEGIN + pushl %eax + call schedule_tail + addl $4, %esp + FRAME_END testl %ebx, %ebx jnz 1f /* kernel threads are uncommon */ 2: /* When we fork, we trace the syscall return in the child, too. */ - movl %esp, %eax + leal 4(%esp), %eax call syscall_exit_to_user_mode - jmp .Lsyscall_32_done + RET /* kernel thread */ 1: movl %edi, %eax