Skip to content

Commit b86678c

Browse files
krisman-at-collaboraKAGA-KOKO
authored andcommitted
entry: Wire up syscall_work in common entry code
Prepare the common entry code to use the SYSCALL_WORK flags. They will be defined in subsequent patches for each type of syscall work. SYSCALL_WORK_ENTRY/EXIT are defined for the transition, as they will replace the TIF_ equivalent defines. Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Andy Lutomirski <luto@kernel.org> Link: https://lore.kernel.org/r/20201116174206.2639648-4-krisman@collabora.com
1 parent 3136b93 commit b86678c

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

‎include/linux/entry-common.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@
6464
(_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
6565
_TIF_SYSCALL_TRACEPOINT | ARCH_SYSCALL_EXIT_WORK)
6666

67+
#define SYSCALL_WORK_ENTER (0)
68+
#define SYSCALL_WORK_EXIT (0)
69+
6770
/*
6871
* TIF flags handled in exit_to_user_mode_loop()
6972
*/

‎kernel/entry/common.c‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static inline void syscall_enter_audit(struct pt_regs *regs, long syscall)
4242
}
4343

4444
static long syscall_trace_enter(struct pt_regs *regs, long syscall,
45-
unsigned long ti_work)
45+
unsigned long ti_work, unsigned long work)
4646
{
4747
long ret = 0;
4848

@@ -74,11 +74,12 @@ static long syscall_trace_enter(struct pt_regs *regs, long syscall,
7474
static __always_inline long
7575
__syscall_enter_from_user_work(struct pt_regs *regs, long syscall)
7676
{
77+
unsigned long work = READ_ONCE(current_thread_info()->syscall_work);
7778
unsigned long ti_work;
7879

7980
ti_work = READ_ONCE(current_thread_info()->flags);
80-
if (ti_work & SYSCALL_ENTER_WORK)
81-
syscall = syscall_trace_enter(regs, syscall, ti_work);
81+
if (work & SYSCALL_WORK_ENTER || ti_work & SYSCALL_ENTER_WORK)
82+
syscall = syscall_trace_enter(regs, syscall, ti_work, work);
8283

8384
return syscall;
8485
}
@@ -225,7 +226,8 @@ static inline bool report_single_step(unsigned long ti_work)
225226
}
226227
#endif
227228

228-
static void syscall_exit_work(struct pt_regs *regs, unsigned long ti_work)
229+
static void syscall_exit_work(struct pt_regs *regs, unsigned long ti_work,
230+
unsigned long work)
229231
{
230232
bool step;
231233

@@ -245,6 +247,7 @@ static void syscall_exit_work(struct pt_regs *regs, unsigned long ti_work)
245247
*/
246248
static void syscall_exit_to_user_mode_prepare(struct pt_regs *regs)
247249
{
250+
unsigned long work = READ_ONCE(current_thread_info()->syscall_work);
248251
u32 cached_flags = READ_ONCE(current_thread_info()->flags);
249252
unsigned long nr = syscall_get_nr(current, regs);
250253

@@ -262,8 +265,8 @@ static void syscall_exit_to_user_mode_prepare(struct pt_regs *regs)
262265
* enabled, we want to run them exactly once per syscall exit with
263266
* interrupts enabled.
264267
*/
265-
if (unlikely(cached_flags & SYSCALL_EXIT_WORK))
266-
syscall_exit_work(regs, cached_flags);
268+
if (unlikely(work & SYSCALL_WORK_EXIT || cached_flags & SYSCALL_EXIT_WORK))
269+
syscall_exit_work(regs, cached_flags, work);
267270
}
268271

269272
__visible noinstr void syscall_exit_to_user_mode(struct pt_regs *regs)

0 commit comments

Comments
 (0)