Skip to content

Commit 9799609

Browse files
svens-s390Avenger-285714
authored andcommitted
entry: Move enter_from_user_mode() to header file
mainline inclusion from mainline-v6.8-rc1 category: performance To allow inlining of enter_from_user_mode(), move it to entry-common.h. Signed-off-by: Sven Schnelle <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/r/[email protected] (cherry picked from commit caf4062) Signed-off-by: Wentao Guan <[email protected]>
1 parent f283d30 commit 9799609

File tree

2 files changed

+17
-24
lines changed

2 files changed

+17
-24
lines changed

include/linux/entry-common.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/livepatch.h>
1212
#include <linux/resume_user_mode.h>
1313
#include <linux/tick.h>
14+
#include <linux/kmsan.h>
1415

1516
#include <asm/entry-common.h>
1617

@@ -102,7 +103,19 @@ static __always_inline void arch_enter_from_user_mode(struct pt_regs *regs) {}
102103
* done between establishing state and enabling interrupts. The caller must
103104
* enable interrupts before invoking syscall_enter_from_user_mode_work().
104105
*/
105-
void enter_from_user_mode(struct pt_regs *regs);
106+
static __always_inline void enter_from_user_mode(struct pt_regs *regs)
107+
{
108+
arch_enter_from_user_mode(regs);
109+
lockdep_hardirqs_off(CALLER_ADDR0);
110+
111+
CT_WARN_ON(__ct_state() != CONTEXT_USER);
112+
user_exit_irqoff();
113+
114+
instrumentation_begin();
115+
kmsan_unpoison_entry_regs(regs);
116+
trace_hardirqs_off_finish();
117+
instrumentation_end();
118+
}
106119

107120
/**
108121
* syscall_enter_from_user_mode_prepare - Establish state and enable interrupts

kernel/entry/common.c

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,6 @@
1515
#define CREATE_TRACE_POINTS
1616
#include <trace/events/syscalls.h>
1717

18-
/* See comment for enter_from_user_mode() in entry-common.h */
19-
static __always_inline void __enter_from_user_mode(struct pt_regs *regs)
20-
{
21-
arch_enter_from_user_mode(regs);
22-
lockdep_hardirqs_off(CALLER_ADDR0);
23-
24-
CT_WARN_ON(__ct_state() != CONTEXT_USER);
25-
user_exit_irqoff();
26-
27-
instrumentation_begin();
28-
kmsan_unpoison_entry_regs(regs);
29-
trace_hardirqs_off_finish();
30-
instrumentation_end();
31-
}
32-
33-
void noinstr enter_from_user_mode(struct pt_regs *regs)
34-
{
35-
__enter_from_user_mode(regs);
36-
}
37-
3818
static inline void syscall_enter_audit(struct pt_regs *regs, long syscall)
3919
{
4020
if (unlikely(audit_context())) {
@@ -111,7 +91,7 @@ noinstr long syscall_enter_from_user_mode(struct pt_regs *regs, long syscall)
11191
{
11292
long ret;
11393

114-
__enter_from_user_mode(regs);
94+
enter_from_user_mode(regs);
11595

11696
instrumentation_begin();
11797
local_irq_enable();
@@ -123,7 +103,7 @@ noinstr long syscall_enter_from_user_mode(struct pt_regs *regs, long syscall)
123103

124104
noinstr void syscall_enter_from_user_mode_prepare(struct pt_regs *regs)
125105
{
126-
__enter_from_user_mode(regs);
106+
enter_from_user_mode(regs);
127107
instrumentation_begin();
128108
local_irq_enable();
129109
instrumentation_end();
@@ -272,7 +252,7 @@ __visible noinstr void syscall_exit_to_user_mode(struct pt_regs *regs)
272252

273253
noinstr void irqentry_enter_from_user_mode(struct pt_regs *regs)
274254
{
275-
__enter_from_user_mode(regs);
255+
enter_from_user_mode(regs);
276256
}
277257

278258
noinstr void irqentry_exit_to_user_mode(struct pt_regs *regs)

0 commit comments

Comments
 (0)