Skip to content

Commit 270de60

Browse files
mrutland-armctmarinas
authored andcommitted
arm64: Simplify do_notify_resume() DAIF masking
In do_notify_resume, we handle _TIF_NEED_RESCHED differently from all other flags, leaving IRQ+FIQ masked when calling into schedule(). This masking is a historical artifact, and it is not currently necessary to mask IRQ+FIQ when calling into schedule (as evidenced by the generic exit_to_user_mode_loop(), which unmasks IRQs before checking _TIF_NEED_RESCHED and calling schedule()). This patch removes the special case for _TIF_NEED_RESCHED, moving this check into the main loop such that schedule() will be called from a regular process context with IRQ+FIQ unmasked. This is a minor simplification to do_notify_resume() and brings it into line with the generic exit_to_user_mode_loop() logic. This will also aid subsequent rework of DAIF management. Signed-off-by: Mark Rutland <[email protected]> Cc: James Morse <[email protected]> Cc: Mark Brown <[email protected]> Cc: Will Deacon <[email protected]> Reviewed-by: Mark Brown <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]> Tested-by: Itaru Kitayama <[email protected]>
1 parent 54be6c6 commit 270de60

File tree

1 file changed

+15
-19
lines changed

1 file changed

+15
-19
lines changed

arch/arm64/kernel/signal.c

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,32 +1281,28 @@ static void do_signal(struct pt_regs *regs)
12811281
void do_notify_resume(struct pt_regs *regs, unsigned long thread_flags)
12821282
{
12831283
do {
1284-
if (thread_flags & _TIF_NEED_RESCHED) {
1285-
/* Unmask Debug and SError for the next task */
1286-
local_daif_restore(DAIF_PROCCTX_NOIRQ);
1284+
local_daif_restore(DAIF_PROCCTX);
12871285

1286+
if (thread_flags & _TIF_NEED_RESCHED)
12881287
schedule();
1289-
} else {
1290-
local_daif_restore(DAIF_PROCCTX);
12911288

1292-
if (thread_flags & _TIF_UPROBE)
1293-
uprobe_notify_resume(regs);
1289+
if (thread_flags & _TIF_UPROBE)
1290+
uprobe_notify_resume(regs);
12941291

1295-
if (thread_flags & _TIF_MTE_ASYNC_FAULT) {
1296-
clear_thread_flag(TIF_MTE_ASYNC_FAULT);
1297-
send_sig_fault(SIGSEGV, SEGV_MTEAERR,
1298-
(void __user *)NULL, current);
1299-
}
1292+
if (thread_flags & _TIF_MTE_ASYNC_FAULT) {
1293+
clear_thread_flag(TIF_MTE_ASYNC_FAULT);
1294+
send_sig_fault(SIGSEGV, SEGV_MTEAERR,
1295+
(void __user *)NULL, current);
1296+
}
13001297

1301-
if (thread_flags & (_TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL))
1302-
do_signal(regs);
1298+
if (thread_flags & (_TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL))
1299+
do_signal(regs);
13031300

1304-
if (thread_flags & _TIF_NOTIFY_RESUME)
1305-
resume_user_mode_work(regs);
1301+
if (thread_flags & _TIF_NOTIFY_RESUME)
1302+
resume_user_mode_work(regs);
13061303

1307-
if (thread_flags & _TIF_FOREIGN_FPSTATE)
1308-
fpsimd_restore_current_state();
1309-
}
1304+
if (thread_flags & _TIF_FOREIGN_FPSTATE)
1305+
fpsimd_restore_current_state();
13101306

13111307
local_daif_mask();
13121308
thread_flags = read_thread_flags();

0 commit comments

Comments
 (0)