Skip to content

Commit b9e2f22

Browse files
t-8chjmberg-intel
authored andcommitted
um: Re-evaluate thread flags repeatedly
The thread flags may change during their processing. For example a task_work can queue a new signal to be sent. This signal should be delivered before returning to usespace again. Evaluate the flags repeatedly similar to other architectures. Signed-off-by: Thomas Weißschuh <[email protected]> Reviewed-by: Nam Cao <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Johannes Berg <[email protected]>
1 parent ac1ad16 commit b9e2f22

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

arch/um/include/asm/thread_info.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ struct thread_info {
5252
#define _TIF_NOTIFY_SIGNAL (1 << TIF_NOTIFY_SIGNAL)
5353
#define _TIF_MEMDIE (1 << TIF_MEMDIE)
5454
#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)
55+
#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
5556
#define _TIF_SECCOMP (1 << TIF_SECCOMP)
5657
#define _TIF_SINGLESTEP (1 << TIF_SINGLESTEP)
5758

59+
#define _TIF_WORK_MASK (_TIF_NEED_RESCHED | _TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL | \
60+
_TIF_NOTIFY_RESUME)
61+
5862
#endif

arch/um/kernel/process.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,18 @@ struct task_struct *__switch_to(struct task_struct *from, struct task_struct *to
8282
void interrupt_end(void)
8383
{
8484
struct pt_regs *regs = &current->thread.regs;
85-
86-
if (need_resched())
87-
schedule();
88-
if (test_thread_flag(TIF_SIGPENDING) ||
89-
test_thread_flag(TIF_NOTIFY_SIGNAL))
90-
do_signal(regs);
91-
if (test_thread_flag(TIF_NOTIFY_RESUME))
92-
resume_user_mode_work(regs);
85+
unsigned long thread_flags;
86+
87+
thread_flags = read_thread_flags();
88+
while (thread_flags & _TIF_WORK_MASK) {
89+
if (thread_flags & _TIF_NEED_RESCHED)
90+
schedule();
91+
if (thread_flags & (_TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL))
92+
do_signal(regs);
93+
if (thread_flags & _TIF_NOTIFY_RESUME)
94+
resume_user_mode_work(regs);
95+
thread_flags = read_thread_flags();
96+
}
9397
}
9498

9599
int get_current_pid(void)

0 commit comments

Comments
 (0)