Skip to content

Commit 221a164

Browse files
svens-s390KAGA-KOKO
authored andcommitted
entry: Move syscall_enter_from_user_mode() to header file
To allow inlining of syscall_enter_from_user_mode(), move it to entry-common.h. Signed-off-by: Sven Schnelle <svens@linux.ibm.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Link: https://lore.kernel.org/r/20231218074520.1998026-4-svens@linux.ibm.com
1 parent caf4062 commit 221a164

2 files changed

Lines changed: 26 additions & 33 deletions

File tree

include/linux/entry-common.h

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ static __always_inline void enter_from_user_mode(struct pt_regs *regs)
134134
*/
135135
void syscall_enter_from_user_mode_prepare(struct pt_regs *regs);
136136

137+
long syscall_trace_enter(struct pt_regs *regs, long syscall,
138+
unsigned long work);
139+
137140
/**
138141
* syscall_enter_from_user_mode_work - Check and handle work before invoking
139142
* a syscall
@@ -157,7 +160,15 @@ void syscall_enter_from_user_mode_prepare(struct pt_regs *regs);
157160
* ptrace_report_syscall_entry(), __secure_computing(), trace_sys_enter()
158161
* 2) Invocation of audit_syscall_entry()
159162
*/
160-
long syscall_enter_from_user_mode_work(struct pt_regs *regs, long syscall);
163+
static __always_inline long syscall_enter_from_user_mode_work(struct pt_regs *regs, long syscall)
164+
{
165+
unsigned long work = READ_ONCE(current_thread_info()->syscall_work);
166+
167+
if (work & SYSCALL_WORK_ENTER)
168+
syscall = syscall_trace_enter(regs, syscall, work);
169+
170+
return syscall;
171+
}
161172

162173
/**
163174
* syscall_enter_from_user_mode - Establish state and check and handle work
@@ -176,7 +187,19 @@ long syscall_enter_from_user_mode_work(struct pt_regs *regs, long syscall);
176187
* Returns: The original or a modified syscall number. See
177188
* syscall_enter_from_user_mode_work() for further explanation.
178189
*/
179-
long syscall_enter_from_user_mode(struct pt_regs *regs, long syscall);
190+
static __always_inline long syscall_enter_from_user_mode(struct pt_regs *regs, long syscall)
191+
{
192+
long ret;
193+
194+
enter_from_user_mode(regs);
195+
196+
instrumentation_begin();
197+
local_irq_enable();
198+
ret = syscall_enter_from_user_mode_work(regs, syscall);
199+
instrumentation_end();
200+
201+
return ret;
202+
}
180203

181204
/**
182205
* local_irq_enable_exit_to_user - Exit to user variant of local_irq_enable()

kernel/entry/common.c

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ static inline void syscall_enter_audit(struct pt_regs *regs, long syscall)
2525
}
2626
}
2727

28-
static long syscall_trace_enter(struct pt_regs *regs, long syscall,
28+
long syscall_trace_enter(struct pt_regs *regs, long syscall,
2929
unsigned long work)
3030
{
3131
long ret = 0;
@@ -65,36 +65,6 @@ static long syscall_trace_enter(struct pt_regs *regs, long syscall,
6565
return ret ? : syscall;
6666
}
6767

68-
static __always_inline long
69-
__syscall_enter_from_user_work(struct pt_regs *regs, long syscall)
70-
{
71-
unsigned long work = READ_ONCE(current_thread_info()->syscall_work);
72-
73-
if (work & SYSCALL_WORK_ENTER)
74-
syscall = syscall_trace_enter(regs, syscall, work);
75-
76-
return syscall;
77-
}
78-
79-
long syscall_enter_from_user_mode_work(struct pt_regs *regs, long syscall)
80-
{
81-
return __syscall_enter_from_user_work(regs, syscall);
82-
}
83-
84-
noinstr long syscall_enter_from_user_mode(struct pt_regs *regs, long syscall)
85-
{
86-
long ret;
87-
88-
enter_from_user_mode(regs);
89-
90-
instrumentation_begin();
91-
local_irq_enable();
92-
ret = __syscall_enter_from_user_work(regs, syscall);
93-
instrumentation_end();
94-
95-
return ret;
96-
}
97-
9868
noinstr void syscall_enter_from_user_mode_prepare(struct pt_regs *regs)
9969
{
10070
enter_from_user_mode(regs);

0 commit comments

Comments
 (0)