* [PATCH v2 1/5] entry: rename enter_from_user_mode()
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 ` 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
` (5 subsequent siblings)
6 siblings, 2 replies; 19+ messages in thread
From: Sven Schnelle @ 2020-12-01 14:27 UTC (permalink / raw)
To: Thomas Gleixner; +Cc: linux-kernel, Sven Schnelle
In order to make this function publicly available rename
it so it can still be inlined. An addtional enter_from_user_mode()
function will be added with a later commit.
Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
---
kernel/entry/common.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/kernel/entry/common.c b/kernel/entry/common.c
index e9e2df3f3f9e..683a8e1b5388 100644
--- a/kernel/entry/common.c
+++ b/kernel/entry/common.c
@@ -9,7 +9,7 @@
#include <trace/events/syscalls.h>
/**
- * enter_from_user_mode - Establish state when coming from user mode
+ * __enter_from_user_mode - Establish state when coming from user mode
*
* Syscall/interrupt entry disables interrupts, but user mode is traced as
* interrupts enabled. Also with NO_HZ_FULL RCU might be idle.
@@ -18,7 +18,7 @@
* 2) Invoke context tracking if enabled to reactivate RCU
* 3) Trace interrupts off state
*/
-static __always_inline void enter_from_user_mode(struct pt_regs *regs)
+static __always_inline void __enter_from_user_mode(struct pt_regs *regs)
{
arch_check_user_regs(regs);
lockdep_hardirqs_off(CALLER_ADDR0);
@@ -92,7 +92,7 @@ noinstr long syscall_enter_from_user_mode(struct pt_regs *regs, long syscall)
{
long ret;
- enter_from_user_mode(regs);
+ __enter_from_user_mode(regs);
instrumentation_begin();
local_irq_enable();
@@ -104,7 +104,7 @@ noinstr long syscall_enter_from_user_mode(struct pt_regs *regs, long syscall)
noinstr void syscall_enter_from_user_mode_prepare(struct pt_regs *regs)
{
- enter_from_user_mode(regs);
+ __enter_from_user_mode(regs);
instrumentation_begin();
local_irq_enable();
instrumentation_end();
@@ -270,7 +270,7 @@ __visible noinstr void syscall_exit_to_user_mode(struct pt_regs *regs)
noinstr void irqentry_enter_from_user_mode(struct pt_regs *regs)
{
- enter_from_user_mode(regs);
+ __enter_from_user_mode(regs);
}
noinstr void irqentry_exit_to_user_mode(struct pt_regs *regs)
--
2.17.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [tip: core/entry] entry: Rename enter_from_user_mode()
2020-12-01 14:27 ` [PATCH v2 1/5] entry: rename enter_from_user_mode() Sven Schnelle
@ 2020-12-02 9:38 ` tip-bot2 for Sven Schnelle
2020-12-02 14:12 ` tip-bot2 for Sven Schnelle
1 sibling, 0 replies; 19+ messages in thread
From: tip-bot2 for Sven Schnelle @ 2020-12-02 9:38 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Sven Schnelle, Thomas Gleixner, x86, linux-kernel
The following commit has been merged into the core/entry branch of tip:
Commit-ID: e2391bd55155ca98293b1bbaa44aa2815d3d054f
Gitweb: https://git.kernel.org/tip/e2391bd55155ca98293b1bbaa44aa2815d3d054f
Author: Sven Schnelle <svens@linux.ibm.com>
AuthorDate: Tue, 01 Dec 2020 15:27:51 +01:00
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 02 Dec 2020 10:32:17 +01:00
entry: Rename enter_from_user_mode()
In order to make this function publicly available rename it so it can still
be inlined. An additional enter_from_user_mode() function will be added with
a later commit.
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-2-svens@linux.ibm.com
---
kernel/entry/common.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/kernel/entry/common.c b/kernel/entry/common.c
index e661e70..8e294a7 100644
--- a/kernel/entry/common.c
+++ b/kernel/entry/common.c
@@ -11,7 +11,7 @@
#include <trace/events/syscalls.h>
/**
- * enter_from_user_mode - Establish state when coming from user mode
+ * __enter_from_user_mode - Establish state when coming from user mode
*
* Syscall/interrupt entry disables interrupts, but user mode is traced as
* interrupts enabled. Also with NO_HZ_FULL RCU might be idle.
@@ -20,7 +20,7 @@
* 2) Invoke context tracking if enabled to reactivate RCU
* 3) Trace interrupts off state
*/
-static __always_inline void enter_from_user_mode(struct pt_regs *regs)
+static __always_inline void __enter_from_user_mode(struct pt_regs *regs)
{
arch_check_user_regs(regs);
lockdep_hardirqs_off(CALLER_ADDR0);
@@ -103,7 +103,7 @@ noinstr long syscall_enter_from_user_mode(struct pt_regs *regs, long syscall)
{
long ret;
- enter_from_user_mode(regs);
+ __enter_from_user_mode(regs);
instrumentation_begin();
local_irq_enable();
@@ -115,7 +115,7 @@ noinstr long syscall_enter_from_user_mode(struct pt_regs *regs, long syscall)
noinstr void syscall_enter_from_user_mode_prepare(struct pt_regs *regs)
{
- enter_from_user_mode(regs);
+ __enter_from_user_mode(regs);
instrumentation_begin();
local_irq_enable();
instrumentation_end();
@@ -304,7 +304,7 @@ __visible noinstr void syscall_exit_to_user_mode(struct pt_regs *regs)
noinstr void irqentry_enter_from_user_mode(struct pt_regs *regs)
{
- enter_from_user_mode(regs);
+ __enter_from_user_mode(regs);
}
noinstr void irqentry_exit_to_user_mode(struct pt_regs *regs)
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [tip: core/entry] entry: Rename enter_from_user_mode()
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
1 sibling, 0 replies; 19+ messages in thread
From: tip-bot2 for Sven Schnelle @ 2020-12-02 14:12 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Sven Schnelle, Thomas Gleixner, x86, linux-kernel
The following commit has been merged into the core/entry branch of tip:
Commit-ID: 6666bb714fb3bc7b2e8be72b9c92f2d8a89ea2dc
Gitweb: https://git.kernel.org/tip/6666bb714fb3bc7b2e8be72b9c92f2d8a89ea2dc
Author: Sven Schnelle <svens@linux.ibm.com>
AuthorDate: Tue, 01 Dec 2020 15:27:51 +01:00
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 02 Dec 2020 15:07:57 +01:00
entry: Rename enter_from_user_mode()
In order to make this function publicly available rename it so it can still
be inlined. An additional enter_from_user_mode() function will be added with
a later commit.
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-2-svens@linux.ibm.com
---
kernel/entry/common.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/kernel/entry/common.c b/kernel/entry/common.c
index e661e70..8e294a7 100644
--- a/kernel/entry/common.c
+++ b/kernel/entry/common.c
@@ -11,7 +11,7 @@
#include <trace/events/syscalls.h>
/**
- * enter_from_user_mode - Establish state when coming from user mode
+ * __enter_from_user_mode - Establish state when coming from user mode
*
* Syscall/interrupt entry disables interrupts, but user mode is traced as
* interrupts enabled. Also with NO_HZ_FULL RCU might be idle.
@@ -20,7 +20,7 @@
* 2) Invoke context tracking if enabled to reactivate RCU
* 3) Trace interrupts off state
*/
-static __always_inline void enter_from_user_mode(struct pt_regs *regs)
+static __always_inline void __enter_from_user_mode(struct pt_regs *regs)
{
arch_check_user_regs(regs);
lockdep_hardirqs_off(CALLER_ADDR0);
@@ -103,7 +103,7 @@ noinstr long syscall_enter_from_user_mode(struct pt_regs *regs, long syscall)
{
long ret;
- enter_from_user_mode(regs);
+ __enter_from_user_mode(regs);
instrumentation_begin();
local_irq_enable();
@@ -115,7 +115,7 @@ noinstr long syscall_enter_from_user_mode(struct pt_regs *regs, long syscall)
noinstr void syscall_enter_from_user_mode_prepare(struct pt_regs *regs)
{
- enter_from_user_mode(regs);
+ __enter_from_user_mode(regs);
instrumentation_begin();
local_irq_enable();
instrumentation_end();
@@ -304,7 +304,7 @@ __visible noinstr void syscall_exit_to_user_mode(struct pt_regs *regs)
noinstr void irqentry_enter_from_user_mode(struct pt_regs *regs)
{
- enter_from_user_mode(regs);
+ __enter_from_user_mode(regs);
}
noinstr void irqentry_exit_to_user_mode(struct pt_regs *regs)
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 2/5] entry: rename exit_from_user_mode()
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-01 14:27 ` Sven Schnelle
2020-12-01 14:41 ` Sven Schnelle
` (2 more replies)
2020-12-01 14:27 ` [PATCH v2 3/5] entry: add enter_from_user_mode() wrapper Sven Schnelle
` (4 subsequent siblings)
6 siblings, 3 replies; 19+ messages in thread
From: Sven Schnelle @ 2020-12-01 14:27 UTC (permalink / raw)
To: Thomas Gleixner; +Cc: linux-kernel, Sven Schnelle
In order to make this function publicly available rename
it so it can still be inlined. An additional exit_from_user_mode()
function will be added with a later commit.
Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
---
kernel/entry/common.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/kernel/entry/common.c b/kernel/entry/common.c
index 683a8e1b5388..076ee1cde67f 100644
--- a/kernel/entry/common.c
+++ b/kernel/entry/common.c
@@ -111,7 +111,7 @@ noinstr void syscall_enter_from_user_mode_prepare(struct pt_regs *regs)
}
/**
- * exit_to_user_mode - Fixup state when exiting to user mode
+ * __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.
@@ -122,7 +122,7 @@ noinstr void syscall_enter_from_user_mode_prepare(struct pt_regs *regs)
* mitigations, etc.
* 4) Tell lockdep that interrupts are enabled
*/
-static __always_inline void exit_to_user_mode(void)
+static __always_inline void __exit_to_user_mode(void)
{
instrumentation_begin();
trace_hardirqs_on_prepare();
@@ -265,7 +265,7 @@ __visible noinstr void syscall_exit_to_user_mode(struct pt_regs *regs)
local_irq_disable_exit_to_user();
exit_to_user_mode_prepare(regs);
instrumentation_end();
- exit_to_user_mode();
+ __exit_to_user_mode();
}
noinstr void irqentry_enter_from_user_mode(struct pt_regs *regs)
@@ -278,7 +278,7 @@ noinstr void irqentry_exit_to_user_mode(struct pt_regs *regs)
instrumentation_begin();
exit_to_user_mode_prepare(regs);
instrumentation_end();
- exit_to_user_mode();
+ __exit_to_user_mode();
}
noinstr irqentry_state_t irqentry_enter(struct pt_regs *regs)
--
2.17.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH v2 2/5] entry: rename exit_from_user_mode()
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
2 siblings, 0 replies; 19+ messages in thread
From: Sven Schnelle @ 2020-12-01 14:41 UTC (permalink / raw)
To: Thomas Gleixner; +Cc: linux-kernel
Sven Schnelle <svens@linux.ibm.com> writes:
> In order to make this function publicly available rename
> it so it can still be inlined. An additional exit_from_user_mode()
> function will be added with a later commit.
That should of course be exit_to_user_mode() in the commit
description...
> Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
> ---
> kernel/entry/common.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/kernel/entry/common.c b/kernel/entry/common.c
> index 683a8e1b5388..076ee1cde67f 100644
> --- a/kernel/entry/common.c
> +++ b/kernel/entry/common.c
> @@ -111,7 +111,7 @@ noinstr void syscall_enter_from_user_mode_prepare(struct pt_regs *regs)
> }
>
> /**
> - * exit_to_user_mode - Fixup state when exiting to user mode
> + * __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.
> @@ -122,7 +122,7 @@ noinstr void syscall_enter_from_user_mode_prepare(struct pt_regs *regs)
> * mitigations, etc.
> * 4) Tell lockdep that interrupts are enabled
> */
> -static __always_inline void exit_to_user_mode(void)
> +static __always_inline void __exit_to_user_mode(void)
> {
> instrumentation_begin();
> trace_hardirqs_on_prepare();
> @@ -265,7 +265,7 @@ __visible noinstr void syscall_exit_to_user_mode(struct pt_regs *regs)
> local_irq_disable_exit_to_user();
> exit_to_user_mode_prepare(regs);
> instrumentation_end();
> - exit_to_user_mode();
> + __exit_to_user_mode();
> }
>
> noinstr void irqentry_enter_from_user_mode(struct pt_regs *regs)
> @@ -278,7 +278,7 @@ noinstr void irqentry_exit_to_user_mode(struct pt_regs *regs)
> instrumentation_begin();
> exit_to_user_mode_prepare(regs);
> instrumentation_end();
> - exit_to_user_mode();
> + __exit_to_user_mode();
> }
>
> noinstr irqentry_state_t irqentry_enter(struct pt_regs *regs)
^ permalink raw reply [flat|nested] 19+ messages in thread
* [tip: core/entry] entry: Rename exit_to_user_mode()
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-bot2 for Sven Schnelle
2020-12-02 14:12 ` tip-bot2 for Sven Schnelle
2 siblings, 0 replies; 19+ messages in thread
From: tip-bot2 for Sven Schnelle @ 2020-12-02 9:38 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Sven Schnelle, Thomas Gleixner, x86, linux-kernel
The following commit has been merged into the core/entry branch of tip:
Commit-ID: f052615ca0112378c3571fc9662bbbcd18cf6b8d
Gitweb: https://git.kernel.org/tip/f052615ca0112378c3571fc9662bbbcd18cf6b8d
Author: Sven Schnelle <svens@linux.ibm.com>
AuthorDate: Tue, 01 Dec 2020 15:27:52 +01:00
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 02 Dec 2020 10:32:18 +01:00
entry: Rename exit_to_user_mode()
In order to make this function publicly available rename it so it can still
be inlined. An additional exit_to_user_mode() function will be added with
a later commit.
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-3-svens@linux.ibm.com
---
kernel/entry/common.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/kernel/entry/common.c b/kernel/entry/common.c
index 8e294a7..dff07b4 100644
--- a/kernel/entry/common.c
+++ b/kernel/entry/common.c
@@ -122,7 +122,7 @@ noinstr void syscall_enter_from_user_mode_prepare(struct pt_regs *regs)
}
/**
- * exit_to_user_mode - Fixup state when exiting to user mode
+ * __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.
@@ -133,7 +133,7 @@ noinstr void syscall_enter_from_user_mode_prepare(struct pt_regs *regs)
* mitigations, etc.
* 4) Tell lockdep that interrupts are enabled
*/
-static __always_inline void exit_to_user_mode(void)
+static __always_inline void __exit_to_user_mode(void)
{
instrumentation_begin();
trace_hardirqs_on_prepare();
@@ -299,7 +299,7 @@ __visible noinstr void syscall_exit_to_user_mode(struct pt_regs *regs)
local_irq_disable_exit_to_user();
exit_to_user_mode_prepare(regs);
instrumentation_end();
- exit_to_user_mode();
+ __exit_to_user_mode();
}
noinstr void irqentry_enter_from_user_mode(struct pt_regs *regs)
@@ -312,7 +312,7 @@ noinstr void irqentry_exit_to_user_mode(struct pt_regs *regs)
instrumentation_begin();
exit_to_user_mode_prepare(regs);
instrumentation_end();
- exit_to_user_mode();
+ __exit_to_user_mode();
}
noinstr irqentry_state_t irqentry_enter(struct pt_regs *regs)
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [tip: core/entry] entry: Rename exit_to_user_mode()
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
2 siblings, 0 replies; 19+ messages in thread
From: tip-bot2 for Sven Schnelle @ 2020-12-02 14:12 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Sven Schnelle, Thomas Gleixner, x86, linux-kernel
The following commit has been merged into the core/entry branch of tip:
Commit-ID: bb793562f0da7317adf6c456316bca651ff46f5d
Gitweb: https://git.kernel.org/tip/bb793562f0da7317adf6c456316bca651ff46f5d
Author: Sven Schnelle <svens@linux.ibm.com>
AuthorDate: Tue, 01 Dec 2020 15:27:52 +01:00
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 02 Dec 2020 15:07:57 +01:00
entry: Rename exit_to_user_mode()
In order to make this function publicly available rename it so it can still
be inlined. An additional exit_to_user_mode() function will be added with
a later commit.
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-3-svens@linux.ibm.com
---
kernel/entry/common.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/kernel/entry/common.c b/kernel/entry/common.c
index 8e294a7..dff07b4 100644
--- a/kernel/entry/common.c
+++ b/kernel/entry/common.c
@@ -122,7 +122,7 @@ noinstr void syscall_enter_from_user_mode_prepare(struct pt_regs *regs)
}
/**
- * exit_to_user_mode - Fixup state when exiting to user mode
+ * __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.
@@ -133,7 +133,7 @@ noinstr void syscall_enter_from_user_mode_prepare(struct pt_regs *regs)
* mitigations, etc.
* 4) Tell lockdep that interrupts are enabled
*/
-static __always_inline void exit_to_user_mode(void)
+static __always_inline void __exit_to_user_mode(void)
{
instrumentation_begin();
trace_hardirqs_on_prepare();
@@ -299,7 +299,7 @@ __visible noinstr void syscall_exit_to_user_mode(struct pt_regs *regs)
local_irq_disable_exit_to_user();
exit_to_user_mode_prepare(regs);
instrumentation_end();
- exit_to_user_mode();
+ __exit_to_user_mode();
}
noinstr void irqentry_enter_from_user_mode(struct pt_regs *regs)
@@ -312,7 +312,7 @@ noinstr void irqentry_exit_to_user_mode(struct pt_regs *regs)
instrumentation_begin();
exit_to_user_mode_prepare(regs);
instrumentation_end();
- exit_to_user_mode();
+ __exit_to_user_mode();
}
noinstr irqentry_state_t irqentry_enter(struct pt_regs *regs)
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 3/5] entry: add enter_from_user_mode() wrapper
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-01 14:27 ` [PATCH v2 2/5] entry: rename exit_from_user_mode() Sven Schnelle
@ 2020-12-01 14:27 ` 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
` (3 subsequent siblings)
6 siblings, 2 replies; 19+ messages in thread
From: Sven Schnelle @ 2020-12-01 14:27 UTC (permalink / raw)
To: Thomas Gleixner; +Cc: linux-kernel, Sven Schnelle
Can be called from architecture dependent code, and simply
calls __enter_from_user_mode(). This way __enter_from_user_mode
can still be inlined because it is declared static.
Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
---
include/linux/entry-common.h | 11 +++++++++++
kernel/entry/common.c | 15 +++++----------
2 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/include/linux/entry-common.h b/include/linux/entry-common.h
index 474f29638d2c..28a8554fad7d 100644
--- a/include/linux/entry-common.h
+++ b/include/linux/entry-common.h
@@ -402,4 +402,15 @@ void irqentry_exit_cond_resched(void);
*/
void noinstr irqentry_exit(struct pt_regs *regs, irqentry_state_t state);
+/**
+ * enter_from_user_mode - Establish state when coming from user mode
+ *
+ * Syscall/interrupt entry disables interrupts, but user mode is traced as
+ * interrupts enabled. Also with NO_HZ_FULL RCU might be idle.
+ *
+ * 1) Tell lockdep that interrupts are disabled
+ * 2) Invoke context tracking if enabled to reactivate RCU
+ * 3) Trace interrupts off state
+ */
+void enter_from_user_mode(struct pt_regs *regs);
#endif
diff --git a/kernel/entry/common.c b/kernel/entry/common.c
index 076ee1cde67f..ee588ee9f122 100644
--- a/kernel/entry/common.c
+++ b/kernel/entry/common.c
@@ -8,16 +8,6 @@
#define CREATE_TRACE_POINTS
#include <trace/events/syscalls.h>
-/**
- * __enter_from_user_mode - Establish state when coming from user mode
- *
- * Syscall/interrupt entry disables interrupts, but user mode is traced as
- * interrupts enabled. Also with NO_HZ_FULL RCU might be idle.
- *
- * 1) Tell lockdep that interrupts are disabled
- * 2) Invoke context tracking if enabled to reactivate RCU
- * 3) Trace interrupts off state
- */
static __always_inline void __enter_from_user_mode(struct pt_regs *regs)
{
arch_check_user_regs(regs);
@@ -31,6 +21,11 @@ static __always_inline void __enter_from_user_mode(struct pt_regs *regs)
instrumentation_end();
}
+void noinstr enter_from_user_mode(struct pt_regs *regs)
+{
+ __enter_from_user_mode(regs);
+}
+
static inline void syscall_enter_audit(struct pt_regs *regs, long syscall)
{
if (unlikely(audit_context())) {
--
2.17.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [tip: core/entry] entry_Add_enter_from_user_mode_wrapper
2020-12-01 14:27 ` [PATCH v2 3/5] entry: add enter_from_user_mode() wrapper Sven Schnelle
@ 2020-12-02 9:38 ` tip-bot2 for Sven Schnelle
2020-12-02 14:12 ` tip-bot2 for Sven Schnelle
1 sibling, 0 replies; 19+ messages in thread
From: tip-bot2 for Sven Schnelle @ 2020-12-02 9:38 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Sven Schnelle, Thomas Gleixner, x86, linux-kernel
The following commit has been merged into the core/entry branch of tip:
Commit-ID: 6546601d7e7c8da38f5d87204aa01f7b394f4fb3
Gitweb: https://git.kernel.org/tip/6546601d7e7c8da38f5d87204aa01f7b394f4fb3
Author: Sven Schnelle <svens@linux.ibm.com>
AuthorDate: Tue, 01 Dec 2020 15:27:53 +01:00
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 02 Dec 2020 10:32:18 +01:00
entry_Add_enter_from_user_mode_wrapper
To be called from architecture specific code if the combo interfaces are
not suitable. It simply calls __enter_from_user_mode(). This way
__enter_from_user_mode will still be inlined because it is declared static
__always_inline.
[ tglx: Amend comments and move it to a different location 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-4-svens@linux.ibm.com
---
include/linux/entry-common.h | 24 +++++++++++++++++++++++-
kernel/entry/common.c | 16 ++++++----------
2 files changed, 29 insertions(+), 11 deletions(-)
diff --git a/include/linux/entry-common.h b/include/linux/entry-common.h
index a6e98b4..da60980 100644
--- a/include/linux/entry-common.h
+++ b/include/linux/entry-common.h
@@ -102,6 +102,27 @@ static inline __must_check int arch_syscall_enter_tracehook(struct pt_regs *regs
#endif
/**
+ * enter_from_user_mode - Establish state when coming from user mode
+ *
+ * Syscall/interrupt entry disables interrupts, but user mode is traced as
+ * interrupts enabled. Also with NO_HZ_FULL RCU might be idle.
+ *
+ * 1) Tell lockdep that interrupts are disabled
+ * 2) Invoke context tracking if enabled to reactivate RCU
+ * 3) Trace interrupts off state
+ *
+ * Invoked from architecture specific syscall entry code with interrupts
+ * disabled. The calling code has to be non-instrumentable. When the
+ * function returns all state is correct and interrupts are still
+ * disabled. The subsequent functions can be instrumented.
+ *
+ * This is invoked when there is architecture specific functionality to be
+ * done between establishing state and enabling interrupts. The caller must
+ * enable interrupts before invoking syscall_enter_from_user_mode_work().
+ */
+void enter_from_user_mode(struct pt_regs *regs);
+
+/**
* syscall_enter_from_user_mode_prepare - Establish state and enable interrupts
* @regs: Pointer to currents pt_regs
*
@@ -110,7 +131,8 @@ static inline __must_check int arch_syscall_enter_tracehook(struct pt_regs *regs
* function returns all state is correct, interrupts are enabled and the
* subsequent functions can be instrumented.
*
- * This handles lockdep, RCU (context tracking) and tracing state.
+ * This handles lockdep, RCU (context tracking) and tracing state, i.e.
+ * the functionality provided by enter_from_user_mode().
*
* This is invoked when there is extra architecture specific functionality
* to be done between establishing state and handling user mode entry work.
diff --git a/kernel/entry/common.c b/kernel/entry/common.c
index dff07b4..17b1e03 100644
--- a/kernel/entry/common.c
+++ b/kernel/entry/common.c
@@ -10,16 +10,7 @@
#define CREATE_TRACE_POINTS
#include <trace/events/syscalls.h>
-/**
- * __enter_from_user_mode - Establish state when coming from user mode
- *
- * Syscall/interrupt entry disables interrupts, but user mode is traced as
- * interrupts enabled. Also with NO_HZ_FULL RCU might be idle.
- *
- * 1) Tell lockdep that interrupts are disabled
- * 2) Invoke context tracking if enabled to reactivate RCU
- * 3) Trace interrupts off state
- */
+/* See comment for enter_from_user_mode() in entry-common.h */
static __always_inline void __enter_from_user_mode(struct pt_regs *regs)
{
arch_check_user_regs(regs);
@@ -33,6 +24,11 @@ static __always_inline void __enter_from_user_mode(struct pt_regs *regs)
instrumentation_end();
}
+void noinstr enter_from_user_mode(struct pt_regs *regs)
+{
+ __enter_from_user_mode(regs);
+}
+
static inline void syscall_enter_audit(struct pt_regs *regs, long syscall)
{
if (unlikely(audit_context())) {
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [tip: core/entry] entry_Add_enter_from_user_mode_wrapper
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
1 sibling, 0 replies; 19+ messages in thread
From: tip-bot2 for Sven Schnelle @ 2020-12-02 14:12 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Sven Schnelle, Thomas Gleixner, x86, linux-kernel
The following commit has been merged into the core/entry branch of tip:
Commit-ID: 96e2fbccd0fc806364a964fdf072bfc858a66109
Gitweb: https://git.kernel.org/tip/96e2fbccd0fc806364a964fdf072bfc858a66109
Author: Sven Schnelle <svens@linux.ibm.com>
AuthorDate: Tue, 01 Dec 2020 15:27:53 +01:00
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 02 Dec 2020 15:07:57 +01:00
entry_Add_enter_from_user_mode_wrapper
To be called from architecture specific code if the combo interfaces are
not suitable. It simply calls __enter_from_user_mode(). This way
__enter_from_user_mode will still be inlined because it is declared static
__always_inline.
[ tglx: Amend comments and move it to a different location 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-4-svens@linux.ibm.com
---
include/linux/entry-common.h | 24 +++++++++++++++++++++++-
kernel/entry/common.c | 16 ++++++----------
2 files changed, 29 insertions(+), 11 deletions(-)
diff --git a/include/linux/entry-common.h b/include/linux/entry-common.h
index a6e98b4..da60980 100644
--- a/include/linux/entry-common.h
+++ b/include/linux/entry-common.h
@@ -102,6 +102,27 @@ static inline __must_check int arch_syscall_enter_tracehook(struct pt_regs *regs
#endif
/**
+ * enter_from_user_mode - Establish state when coming from user mode
+ *
+ * Syscall/interrupt entry disables interrupts, but user mode is traced as
+ * interrupts enabled. Also with NO_HZ_FULL RCU might be idle.
+ *
+ * 1) Tell lockdep that interrupts are disabled
+ * 2) Invoke context tracking if enabled to reactivate RCU
+ * 3) Trace interrupts off state
+ *
+ * Invoked from architecture specific syscall entry code with interrupts
+ * disabled. The calling code has to be non-instrumentable. When the
+ * function returns all state is correct and interrupts are still
+ * disabled. The subsequent functions can be instrumented.
+ *
+ * This is invoked when there is architecture specific functionality to be
+ * done between establishing state and enabling interrupts. The caller must
+ * enable interrupts before invoking syscall_enter_from_user_mode_work().
+ */
+void enter_from_user_mode(struct pt_regs *regs);
+
+/**
* syscall_enter_from_user_mode_prepare - Establish state and enable interrupts
* @regs: Pointer to currents pt_regs
*
@@ -110,7 +131,8 @@ static inline __must_check int arch_syscall_enter_tracehook(struct pt_regs *regs
* function returns all state is correct, interrupts are enabled and the
* subsequent functions can be instrumented.
*
- * This handles lockdep, RCU (context tracking) and tracing state.
+ * This handles lockdep, RCU (context tracking) and tracing state, i.e.
+ * the functionality provided by enter_from_user_mode().
*
* This is invoked when there is extra architecture specific functionality
* to be done between establishing state and handling user mode entry work.
diff --git a/kernel/entry/common.c b/kernel/entry/common.c
index dff07b4..17b1e03 100644
--- a/kernel/entry/common.c
+++ b/kernel/entry/common.c
@@ -10,16 +10,7 @@
#define CREATE_TRACE_POINTS
#include <trace/events/syscalls.h>
-/**
- * __enter_from_user_mode - Establish state when coming from user mode
- *
- * Syscall/interrupt entry disables interrupts, but user mode is traced as
- * interrupts enabled. Also with NO_HZ_FULL RCU might be idle.
- *
- * 1) Tell lockdep that interrupts are disabled
- * 2) Invoke context tracking if enabled to reactivate RCU
- * 3) Trace interrupts off state
- */
+/* See comment for enter_from_user_mode() in entry-common.h */
static __always_inline void __enter_from_user_mode(struct pt_regs *regs)
{
arch_check_user_regs(regs);
@@ -33,6 +24,11 @@ static __always_inline void __enter_from_user_mode(struct pt_regs *regs)
instrumentation_end();
}
+void noinstr enter_from_user_mode(struct pt_regs *regs)
+{
+ __enter_from_user_mode(regs);
+}
+
static inline void syscall_enter_audit(struct pt_regs *regs, long syscall)
{
if (unlikely(audit_context())) {
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 4/5] entry: add exit_to_user_mode() wrapper
2020-12-01 14:27 [PATCH v2] split up lockdep and syscall related functionality in generic entry code Sven Schnelle
` (2 preceding siblings ...)
2020-12-01 14:27 ` [PATCH v2 3/5] entry: add enter_from_user_mode() wrapper Sven Schnelle
@ 2020-12-01 14:27 ` 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
` (2 subsequent siblings)
6 siblings, 2 replies; 19+ messages in thread
From: Sven Schnelle @ 2020-12-01 14:27 UTC (permalink / raw)
To: Thomas Gleixner; +Cc: linux-kernel, Sven Schnelle
Can be called from architecture dependent code, and simply
calls __exit_to_user_mode(). This way __exit_to_user_mode()
can still be inlined because it is declared static.
Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
---
include/linux/entry-common.h | 15 +++++++++++++++
kernel/entry/common.c | 17 +++++------------
2 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/include/linux/entry-common.h b/include/linux/entry-common.h
index 28a8554fad7d..112007525f50 100644
--- a/include/linux/entry-common.h
+++ b/include/linux/entry-common.h
@@ -413,4 +413,19 @@ void noinstr irqentry_exit(struct pt_regs *regs, irqentry_state_t state);
* 3) Trace interrupts off state
*/
void enter_from_user_mode(struct pt_regs *regs);
+
+/**
+ * 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.
+ * 4) Tell lockdep that interrupts are enabled
+ */
+
+void exit_to_user_mode(void);
#endif
diff --git a/kernel/entry/common.c b/kernel/entry/common.c
index ee588ee9f122..e696f6912642 100644
--- a/kernel/entry/common.c
+++ b/kernel/entry/common.c
@@ -105,18 +105,6 @@ 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
- */
static __always_inline void __exit_to_user_mode(void)
{
instrumentation_begin();
@@ -129,6 +117,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(struct pt_regs *regs) { }
--
2.17.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [tip: core/entry] entry: Add exit_to_user_mode() wrapper
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
2020-12-02 14:12 ` tip-bot2 for Sven Schnelle
1 sibling, 0 replies; 19+ messages in thread
From: tip-bot2 for Sven Schnelle @ 2020-12-02 9:38 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Sven Schnelle, Thomas Gleixner, x86, linux-kernel
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) { }
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [tip: core/entry] entry: Add exit_to_user_mode() wrapper
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
1 sibling, 0 replies; 19+ messages in thread
From: tip-bot2 for Sven Schnelle @ 2020-12-02 14:12 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Sven Schnelle, Thomas Gleixner, x86, linux-kernel
The following commit has been merged into the core/entry branch of tip:
Commit-ID: 310de1a678b2184c078c593dae343cb79c807f8d
Gitweb: https://git.kernel.org/tip/310de1a678b2184c078c593dae343cb79c807f8d
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 15:07:57 +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) { }
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 5/5] entry: add syscall_exit_to_user_mode_work()
2020-12-01 14:27 [PATCH v2] split up lockdep and syscall related functionality in generic entry code Sven Schnelle
` (3 preceding siblings ...)
2020-12-01 14:27 ` [PATCH v2 4/5] entry: add exit_to_user_mode() wrapper Sven Schnelle
@ 2020-12-01 14:27 ` 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
6 siblings, 2 replies; 19+ messages in thread
From: Sven Schnelle @ 2020-12-01 14:27 UTC (permalink / raw)
To: Thomas Gleixner; +Cc: linux-kernel, Sven Schnelle
This is the same as syscall_exit_to_user_mode() but without
calling exit_to_user_mode(). This is useful if a syscall has to be
restarted without leaving to user space.
Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
---
include/linux/entry-common.h | 9 +++++++++
kernel/entry/common.c | 14 ++++++++++++--
2 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/include/linux/entry-common.h b/include/linux/entry-common.h
index 112007525f50..bdf6b005bbfb 100644
--- a/include/linux/entry-common.h
+++ b/include/linux/entry-common.h
@@ -312,6 +312,15 @@ static inline void arch_syscall_exit_tracehook(struct pt_regs *regs, bool step)
*/
void syscall_exit_to_user_mode(struct pt_regs *regs);
+/**
+ * syscall_exit_to_user_mode_work - Handle work before returning to user mode
+ * @regs: Pointer to currents pt_regs
+ *
+ * Same as syscall_exit_to_user_mode() but without calling exit_to_user_mode()
+ * to perform the final transition to user mode.
+ */
+void syscall_exit_to_user_mode_work(struct pt_regs *regs);
+
/**
* irqentry_enter_from_user_mode - Establish state before invoking the irq handler
* @regs: Pointer to currents pt_regs
diff --git a/kernel/entry/common.c b/kernel/entry/common.c
index e696f6912642..c3c4ba21824a 100644
--- a/kernel/entry/common.c
+++ b/kernel/entry/common.c
@@ -246,12 +246,22 @@ static void syscall_exit_to_user_mode_prepare(struct pt_regs *regs)
syscall_exit_work(regs, cached_flags);
}
-__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();
}
--
2.17.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [tip: core/entry] entry: Add syscall_exit_to_user_mode_work()
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
2020-12-02 14:12 ` tip-bot2 for Sven Schnelle
1 sibling, 0 replies; 19+ messages in thread
From: tip-bot2 for Sven Schnelle @ 2020-12-02 9:38 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Sven Schnelle, Thomas Gleixner, x86, linux-kernel
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();
}
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [tip: core/entry] entry: Add syscall_exit_to_user_mode_work()
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
1 sibling, 0 replies; 19+ messages in thread
From: tip-bot2 for Sven Schnelle @ 2020-12-02 14:12 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Sven Schnelle, Thomas Gleixner, x86, linux-kernel
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 <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 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 <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();
}
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH v2] split up lockdep and syscall related functionality in generic entry code
2020-12-01 14:27 [PATCH v2] split up lockdep and syscall related functionality in generic entry code Sven Schnelle
` (4 preceding siblings ...)
2020-12-01 14:27 ` [PATCH v2 5/5] entry: add syscall_exit_to_user_mode_work() Sven Schnelle
@ 2020-12-01 23:17 ` Thomas Gleixner
2020-12-02 0:33 ` Thomas Gleixner
6 siblings, 0 replies; 19+ messages in thread
From: Thomas Gleixner @ 2020-12-01 23:17 UTC (permalink / raw)
To: Sven Schnelle; +Cc: linux-kernel
On Tue, Dec 01 2020 at 15:27, Sven Schnelle wrote:
> __do_syscall is the function which gets called by low level entry.S code:
>
> void noinstr __do_syscall(struct pt_regs *regs)
> {
> enter_from_user_mode(regs); /* sets lockdep state, and other initial stuff */
>
> /*
> * functions that need to run with irqs disabled,
> * but lockdep state and other stuff set up
> */
> memcpy(®s->gprs[8], S390_lowcore.save_area_sync, 8 * sizeof(unsigned long));
> memcpy(®s->int_code, &S390_lowcore.svc_ilc, sizeof(regs->int_code));
> regs->psw = S390_lowcore.svc_old_psw;
As __do_syscall() is marked noinstr you want to add
instrumentation_begin();
>
> update_timer_sys();
>
> local_irq_enable();
>
> regs->orig_gpr2 = regs->gprs[2];
>
> do {
> regs->flags = _PIF_SYSCALL;
> do_syscall(regs);
> } while (test_pt_regs_flag(regs, PIF_SYSCALL_RESTART));
instrumentation_end();
for two reasons:
- it clearly documents the boundaries in the code
- it will make objtool happy.
I know it does not have s390 support yet, but I only can recommend
to add that. It's annoying to analyze all the spots it complains
about violating the noinstr rules, but it's way more reliable than
human inspection.
> exit_to_user_mode();
> }
Thanks,
tglx
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2] split up lockdep and syscall related functionality in generic entry code
2020-12-01 14:27 [PATCH v2] split up lockdep and syscall related functionality in generic entry code Sven Schnelle
` (5 preceding siblings ...)
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
6 siblings, 0 replies; 19+ messages in thread
From: Thomas Gleixner @ 2020-12-02 0:33 UTC (permalink / raw)
To: Sven Schnelle; +Cc: linux-kernel
On Tue, Dec 01 2020 at 15:27, Sven Schnelle wrote:
> this is v2 of the patch. I've split it up the to multiple ones,
> and added documentation. The first patch was basically a hack to demonstrate
> what i need, sorry for not sending a more cleaned up version.
It would have been nice to send it against the branch which carries the
entry changes (tip: core/entry), but I fixed it up already, so no need
to resend.
Thanks,
tglx
^ permalink raw reply [flat|nested] 19+ messages in thread