Skip to content

Commit e1ceb09

Browse files
Merge patch "RISC-V: Fix unannoted hardirqs-on in return to userspace slow-path"
I'm merging this in as a single patch to make it easier to handle the backports. * b4-shazam-merge: RISC-V: Fix unannoted hardirqs-on in return to userspace slow-path Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
2 parents 4bd1d80 + b0f4c74 commit e1ceb09

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

arch/riscv/kernel/entry.S

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -264,12 +264,11 @@ SYM_CODE_START_NOALIGN(ret_from_exception)
264264
bnez s0, resume_kernel
265265
SYM_CODE_END(ret_from_exception)
266266

267-
resume_userspace:
268267
/* Interrupts must be disabled here so flags are checked atomically */
269268
REG_L s0, TASK_TI_FLAGS(tp) /* current_thread_info->flags */
270269
andi s1, s0, _TIF_WORK_MASK
271-
bnez s1, work_pending
272-
270+
bnez s1, resume_userspace_slow
271+
resume_userspace:
273272
#ifdef CONFIG_CONTEXT_TRACKING_USER
274273
call user_enter_callable
275274
#endif
@@ -369,19 +368,12 @@ resume_kernel:
369368
j restore_all
370369
#endif
371370

372-
work_pending:
371+
resume_userspace_slow:
373372
/* Enter slow path for supplementary processing */
374-
la ra, ret_from_exception
375-
andi s1, s0, _TIF_NEED_RESCHED
376-
bnez s1, work_resched
377-
work_notifysig:
378-
/* Handle pending signals and notify-resume requests */
379-
csrs CSR_STATUS, SR_IE /* Enable interrupts for do_notify_resume() */
380373
move a0, sp /* pt_regs */
381374
move a1, s0 /* current_thread_info->flags */
382-
tail do_notify_resume
383-
work_resched:
384-
tail schedule
375+
call do_work_pending
376+
j resume_userspace
385377

386378
/* Slow paths for ptrace. */
387379
handle_syscall_trace_enter:

arch/riscv/kernel/signal.c

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -313,19 +313,27 @@ static void do_signal(struct pt_regs *regs)
313313
}
314314

315315
/*
316-
* notification of userspace execution resumption
317-
* - triggered by the _TIF_WORK_MASK flags
316+
* Handle any pending work on the resume-to-userspace path, as indicated by
317+
* _TIF_WORK_MASK. Entered from assembly with IRQs off.
318318
*/
319-
asmlinkage __visible void do_notify_resume(struct pt_regs *regs,
320-
unsigned long thread_info_flags)
319+
asmlinkage __visible void do_work_pending(struct pt_regs *regs,
320+
unsigned long thread_info_flags)
321321
{
322-
if (thread_info_flags & _TIF_UPROBE)
323-
uprobe_notify_resume(regs);
324-
325-
/* Handle pending signal delivery */
326-
if (thread_info_flags & (_TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL))
327-
do_signal(regs);
328-
329-
if (thread_info_flags & _TIF_NOTIFY_RESUME)
330-
resume_user_mode_work(regs);
322+
do {
323+
if (thread_info_flags & _TIF_NEED_RESCHED) {
324+
schedule();
325+
} else {
326+
local_irq_enable();
327+
if (thread_info_flags & _TIF_UPROBE)
328+
uprobe_notify_resume(regs);
329+
/* Handle pending signal delivery */
330+
if (thread_info_flags & (_TIF_SIGPENDING |
331+
_TIF_NOTIFY_SIGNAL))
332+
do_signal(regs);
333+
if (thread_info_flags & _TIF_NOTIFY_RESUME)
334+
resume_user_mode_work(regs);
335+
}
336+
local_irq_disable();
337+
thread_info_flags = read_thread_flags();
338+
} while (thread_info_flags & _TIF_WORK_MASK);
331339
}

0 commit comments

Comments
 (0)