Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp896604pxu; Wed, 2 Dec 2020 06:15:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJz9B31AOjQjkkpE0O3FoywkWCu1SRA6DkZZLxVahEEQOLSYXDaRjcKw5Vz6PF0h/1/jH1gM X-Received: by 2002:aa7:d34e:: with SMTP id m14mr120385edr.42.1606918533066; Wed, 02 Dec 2020 06:15:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606918533; cv=none; d=google.com; s=arc-20160816; b=WnPWxeYcM4ABBG58y5JAnHRevFdPRZh0C89Ab5JiYdoAQPEfk2aaQHc7o+bpQPjXlW ebHE1M43vIBGPTutfgy82cEZ1CAErPuVPg4zZUn0QIOd9s/4jKzazCrYSYo6IrRdLqa8 TcEiW/832pf1JPtj6L9ZQeJDmlzERIFLbQ7jbuIMcelqS5BiXBXen/y9vhDY8pYtv5jX rwOevRMfA7ctL2yjge7AltTueEzceKf0fVAjpLw0CqmjAFzhFSSejFgkCr/fU4nE0JdA fRdxXyAldgTusNs1uAp96SIoN5QJn+xmJJGHh4UN2z16RxFKjXAG5TsmjP/Y5vSByu5f QS3g== 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=AUM2gaFkcDESZlL/Zs/AAuoicx/U5PFmtLiqQr58+Q4=; b=fSsvyAbhd/QlABIwLo4f6e73nM4R1QX8dvlnAgMaXywP7R7zFPDkZuUdWWoM3n7Jgh zYOYndOAGJ5a54/9UqKu3UguE+D9u7L4Ba4ZXPlqs4xFa+MaxeJGQ79FrYH3xbWAwC6a sW9Hc8M/1ljjE7Y0rjf2LMGW2hTuL6LmHvf6LhskJLj2NgV7d6U1kj4VVGESurRo/uTt Fsn3KR8CDKmhKvFQfrMnXQ/AYZvrjcgjipCktjsPoeAMeMguM1Fg7keSk5F22GJnNole catPXrjgz+vSfStjEgtN3fl+/pxH5TBkvdkHY5SfSkD69HOKNYVRpPxWnuuUiuJwZiQm jz6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=xW6QX1PO; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id zc17si12849ejb.579.2020.12.02.06.15.09; Wed, 02 Dec 2020 06:15:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=xW6QX1PO; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1730230AbgLBOMo (ORCPT + 99 others); Wed, 2 Dec 2020 09:12:44 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:34282 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728214AbgLBOMn (ORCPT ); Wed, 2 Dec 2020 09:12:43 -0500 Date: Wed, 02 Dec 2020 14:12:01 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1606918322; 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=AUM2gaFkcDESZlL/Zs/AAuoicx/U5PFmtLiqQr58+Q4=; b=xW6QX1POm9lnYSPByR9vy7mZkSbEoDJSsa2hG+Qd4pPyPv9hmNaii78vnaBtSctKdeqyBJ JAX8Msim+0ifEAcKt51Zd3wbd9mZ936g2OHe/gL0x300m0mHHNeeJLcsII1+IQ7rsntdnZ jRrJnXsr2Hib2h6LBfXZW0cR9fptIVxMz71+YWnURV04DfvUBWVH/bPc6BaSUkkbXz0d0/ GFN9OBZq+ljLl9BcsZa/L6cpLmh32NHJuWqOWvDNWKUSn0Kf23ude+Yzfjbx8rHY+pSfJa 71zI04bQxaWwyM+JNyBUBLlrqPSVu+Py9QiRYnDpGA8SJTtaChDNkHFRNW6Lbw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1606918322; 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=AUM2gaFkcDESZlL/Zs/AAuoicx/U5PFmtLiqQr58+Q4=; b=h/L0Fac2V8Aqe1w66sE1MItVACRTzpPRYxkGhy9IG/GZZVzDidYfjMx8B2dAyLuwDpLr8U EikAoKtJnz2LJjBA== From: "tip-bot2 for Sven Schnelle" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: core/entry] entry: Add syscall_exit_to_user_mode_work() Cc: Sven Schnelle , Thomas Gleixner , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20201201142755.31931-6-svens@linux.ibm.com> References: <20201201142755.31931-6-svens@linux.ibm.com> MIME-Version: 1.0 Message-ID: <160691832132.3364.8915064201324508166.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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the core/entry branch of tip: Commit-ID: c6156e1da633f241e132eaea3b676d674376d770 Gitweb: https://git.kernel.org/tip/c6156e1da633f241e132eaea3b676d674376d770 Author: Sven Schnelle AuthorDate: Tue, 01 Dec 2020 15:27:55 +01:00 Committer: Thomas Gleixner CommitterDate: Wed, 02 Dec 2020 15:07:58 +01:00 entry: Add syscall_exit_to_user_mode_work() This is the same as syscall_exit_to_user_mode() but without calling exit_to_user_mode(). This can be used if there is an architectural reason to avoid the combo function, e.g. restarting a syscall without returning to userspace. Before returning to user space the caller has to invoke exit_to_user_mode(). [ tglx: Amended comments ] Signed-off-by: Sven Schnelle Signed-off-by: Thomas Gleixner Link: https://lore.kernel.org/r/20201201142755.31931-6-svens@linux.ibm.com --- include/linux/entry-common.h | 20 ++++++++++++++++++++ kernel/entry/common.c | 14 ++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/include/linux/entry-common.h b/include/linux/entry-common.h index e370be8..7c581a4 100644 --- a/include/linux/entry-common.h +++ b/include/linux/entry-common.h @@ -316,10 +316,26 @@ static inline void arch_syscall_exit_tracehook(struct pt_regs *regs, bool step) * is not suitable as the last step before returning to userspace. Must be * invoked with interrupts disabled and the caller must be * non-instrumentable. + * The caller has to invoke syscall_exit_to_user_mode_work() before this. */ void exit_to_user_mode(void); /** + * syscall_exit_to_user_mode_work - Handle work before returning to user mode + * @regs: Pointer to currents pt_regs + * + * Same as step 1 and 2 of syscall_exit_to_user_mode() but without calling + * exit_to_user_mode() to perform the final transition to user mode. + * + * Calling convention is the same as for syscall_exit_to_user_mode() and it + * returns with all work handled and interrupts disabled. The caller must + * invoke exit_to_user_mode() before actually switching to user mode to + * make the final state transitions. Interrupts must stay disabled between + * return from this function and the invocation of exit_to_user_mode(). + */ +void syscall_exit_to_user_mode_work(struct pt_regs *regs); + +/** * syscall_exit_to_user_mode - Handle work before returning to user mode * @regs: Pointer to currents pt_regs * @@ -343,6 +359,10 @@ void exit_to_user_mode(void); * * 3) Final transition (lockdep, tracing, context tracking, RCU), i.e. the * functionality in exit_to_user_mode(). + * + * This is a combination of syscall_exit_to_user_mode_work() (1,2) and + * exit_to_user_mode(). This function is preferred unless there is a + * compelling architectural reason to use the seperate functions. */ void syscall_exit_to_user_mode(struct pt_regs *regs); diff --git a/kernel/entry/common.c b/kernel/entry/common.c index 48d30ce..d6b7393 100644 --- a/kernel/entry/common.c +++ b/kernel/entry/common.c @@ -282,12 +282,22 @@ static void syscall_exit_to_user_mode_prepare(struct pt_regs *regs) syscall_exit_work(regs, work); } -__visible noinstr void syscall_exit_to_user_mode(struct pt_regs *regs) +static __always_inline void __syscall_exit_to_user_mode_work(struct pt_regs *regs) { - instrumentation_begin(); syscall_exit_to_user_mode_prepare(regs); local_irq_disable_exit_to_user(); exit_to_user_mode_prepare(regs); +} + +void syscall_exit_to_user_mode_work(struct pt_regs *regs) +{ + __syscall_exit_to_user_mode_work(regs); +} + +__visible noinstr void syscall_exit_to_user_mode(struct pt_regs *regs) +{ + instrumentation_begin(); + __syscall_exit_to_user_mode_work(regs); instrumentation_end(); __exit_to_user_mode(); }