linux-kernel.vger.kernel.org archive mirror
 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 exit_to_user_mode() wrapper
Date: Wed, 02 Dec 2020 09:38:26 -0000	[thread overview]
Message-ID: <160690190672.3364.7128119989932562048.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20201201142755.31931-5-svens@linux.ibm.com>

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

Commit-ID:     7918e4b844d1481c2200445f758bb2d1cd14346c
Gitweb:        https://git.kernel.org/tip/7918e4b844d1481c2200445f758bb2d1cd14346c
Author:        Sven Schnelle <svens@linux.ibm.com>
AuthorDate:    Tue, 01 Dec 2020 15:27:54 +01:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 02 Dec 2020 10:32:18 +01:00

entry: Add exit_to_user_mode() wrapper

Called from architecture specific code when syscall_exit_to_user_mode() is
not suitable. It simply calls __exit_to_user_mode().

This way __exit_to_user_mode() can still be inlined because it is declared
static __always_inline.

[ tglx: Amended comments and moved it to a different place in the header ]

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-5-svens@linux.ibm.com

---
 include/linux/entry-common.h | 23 +++++++++++++++++++++--
 kernel/entry/common.c        | 18 ++++++------------
 2 files changed, 27 insertions(+), 14 deletions(-)

diff --git a/include/linux/entry-common.h b/include/linux/entry-common.h
index da60980..e370be8 100644
--- a/include/linux/entry-common.h
+++ b/include/linux/entry-common.h
@@ -301,6 +301,25 @@ static inline void arch_syscall_exit_tracehook(struct pt_regs *regs, bool step)
 #endif
 
 /**
+ * exit_to_user_mode - Fixup state when exiting to user mode
+ *
+ * Syscall/interrupt exit enables interrupts, but the kernel state is
+ * interrupts disabled when this is invoked. Also tell RCU about it.
+ *
+ * 1) Trace interrupts on state
+ * 2) Invoke context tracking if enabled to adjust RCU state
+ * 3) Invoke architecture specific last minute exit code, e.g. speculation
+ *    mitigations, etc.: arch_exit_to_user_mode()
+ * 4) Tell lockdep that interrupts are enabled
+ *
+ * Invoked from architecture specific code when syscall_exit_to_user_mode()
+ * is not suitable as the last step before returning to userspace. Must be
+ * invoked with interrupts disabled and the caller must be
+ * non-instrumentable.
+ */
+void exit_to_user_mode(void);
+
+/**
  * syscall_exit_to_user_mode - Handle work before returning to user mode
  * @regs:	Pointer to currents pt_regs
  *
@@ -322,8 +341,8 @@ static inline void arch_syscall_exit_tracehook(struct pt_regs *regs, bool step)
  *	- Architecture specific one time work arch_exit_to_user_mode_prepare()
  *	- Address limit and lockdep checks
  *
- *  3) Final transition (lockdep, tracing, context tracking, RCU). Invokes
- *     arch_exit_to_user_mode() to handle e.g. speculation mitigations
+ *  3) Final transition (lockdep, tracing, context tracking, RCU), i.e. the
+ *     functionality in exit_to_user_mode().
  */
 void syscall_exit_to_user_mode(struct pt_regs *regs);
 
diff --git a/kernel/entry/common.c b/kernel/entry/common.c
index 17b1e03..48d30ce 100644
--- a/kernel/entry/common.c
+++ b/kernel/entry/common.c
@@ -117,18 +117,7 @@ noinstr void syscall_enter_from_user_mode_prepare(struct pt_regs *regs)
 	instrumentation_end();
 }
 
-/**
- * __exit_to_user_mode - Fixup state when exiting to user mode
- *
- * Syscall/interupt exit enables interrupts, but the kernel state is
- * interrupts disabled when this is invoked. Also tell RCU about it.
- *
- * 1) Trace interrupts on state
- * 2) Invoke context tracking if enabled to adjust RCU state
- * 3) Invoke architecture specific last minute exit code, e.g. speculation
- *    mitigations, etc.
- * 4) Tell lockdep that interrupts are enabled
- */
+/* See comment for exit_to_user_mode() in entry-common.h */
 static __always_inline void __exit_to_user_mode(void)
 {
 	instrumentation_begin();
@@ -141,6 +130,11 @@ static __always_inline void __exit_to_user_mode(void)
 	lockdep_hardirqs_on(CALLER_ADDR0);
 }
 
+void noinstr exit_to_user_mode(void)
+{
+	__exit_to_user_mode();
+}
+
 /* Workaround to allow gradual conversion of architecture code */
 void __weak arch_do_signal_or_restart(struct pt_regs *regs, bool has_signal) { }
 

  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-bot2 for Sven Schnelle [this message]
2020-12-02 14:12   ` [tip: core/entry] entry: Add " 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: core/entry] entry: Add syscall_exit_to_user_mode_work() tip-bot2 for Sven Schnelle
2020-12-02 14:12   ` 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=160690190672.3364.7128119989932562048.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).