All of lore.kernel.org
 help / color / mirror / Atom feed
From: "tip-bot2 for Sven Schnelle" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Sven Schnelle <svens@linux.ibm.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: core/entry] entry: Add syscall_exit_to_user_mode_work()
Date: Wed, 02 Dec 2020 09:38:26 -0000	[thread overview]
Message-ID: <160690190640.3364.10751265538936902967.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20201201142755.31931-6-svens@linux.ibm.com>

The following commit has been merged into the core/entry branch of tip:

Commit-ID:     1568b5540b3e6ff3fe43a2cf889cb777cf8149fc
Gitweb:        https://git.kernel.org/tip/1568b5540b3e6ff3fe43a2cf889cb777cf8149fc
Author:        Sven Schnelle <svens@linux.ibm.com>
AuthorDate:    Tue, 01 Dec 2020 15:27:55 +01:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 02 Dec 2020 10:32:18 +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 <svens@linux.ibm.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
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();
 }

  reply	other threads:[~2020-12-02  9:39 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-01 14:27 [PATCH v2] split up lockdep and syscall related functionality in generic entry code Sven Schnelle
2020-12-01 14:27 ` [PATCH v2 1/5] entry: rename enter_from_user_mode() Sven Schnelle
2020-12-02  9:38   ` [tip: core/entry] entry: Rename enter_from_user_mode() tip-bot2 for Sven Schnelle
2020-12-02 14:12   ` tip-bot2 for Sven Schnelle
2020-12-01 14:27 ` [PATCH v2 2/5] entry: rename exit_from_user_mode() Sven Schnelle
2020-12-01 14:41   ` Sven Schnelle
2020-12-02  9:38   ` [tip: core/entry] entry: Rename exit_to_user_mode() tip-bot2 for Sven Schnelle
2020-12-02 14:12   ` tip-bot2 for Sven Schnelle
2020-12-01 14:27 ` [PATCH v2 3/5] entry: add enter_from_user_mode() wrapper Sven Schnelle
2020-12-02  9:38   ` [tip: core/entry] entry_Add_enter_from_user_mode_wrapper tip-bot2 for Sven Schnelle
2020-12-02 14:12   ` tip-bot2 for Sven Schnelle
2020-12-01 14:27 ` [PATCH v2 4/5] entry: add exit_to_user_mode() wrapper Sven Schnelle
2020-12-02  9:38   ` [tip: core/entry] entry: Add " tip-bot2 for Sven Schnelle
2020-12-02 14:12   ` tip-bot2 for Sven Schnelle
2020-12-01 14:27 ` [PATCH v2 5/5] entry: add syscall_exit_to_user_mode_work() Sven Schnelle
2020-12-02  9:38   ` tip-bot2 for Sven Schnelle [this message]
2020-12-02 14:12   ` [tip: core/entry] entry: Add syscall_exit_to_user_mode_work() tip-bot2 for Sven Schnelle
2020-12-01 23:17 ` [PATCH v2] split up lockdep and syscall related functionality in generic entry code Thomas Gleixner
2020-12-02  0:33 ` Thomas Gleixner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=160690190640.3364.10751265538936902967.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=svens@linux.ibm.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.