* [PATCH] arm64: signal: Delay calling signals in atomic
@ 2021-10-12 8:44 ` He Zhe
0 siblings, 0 replies; 4+ messages in thread
From: He Zhe @ 2021-10-12 8:44 UTC (permalink / raw)
To: catalin.marinas, will, linux-arm-kernel, linux-kernel, zhe.he,
bigeasy, tglx, rostedt, linux-rt-users
Debugging with breakpoints on arm64 and RT would trigger the following
call trace. When CONFIG_PREEMPT_RT is enabled, spin_locks become mutexes,
and one of these is the spin lock used in signal handling.
BUG: sleeping function called from invalid context at kernel/locking/spinlock_rt.c:46
in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 357, name: multi-timer
preempt_count: 1, expected: 0
RCU nest depth: 0, expected: 0
Preemption disabled at:
[<ffffffc01002f11c>] do_debug_exception+0x58/0x14c
CPU: 0 PID: 357 Comm: multi-timer Not tainted 5.15.0-rc4-rt8-yocto-preempt-rt #1
Hardware name: linux,dummy-virt (DT)
Call trace:
dump_backtrace+0x0/0x19c
show_stack+0x24/0x30
dump_stack_lvl+0x7c/0xa0
dump_stack+0x18/0x34
__might_resched+0x160/0x1c0
rt_spin_lock+0x3c/0xb0
force_sig_info_to_task+0x38/0x14c
force_sig_fault+0x60/0x84
arm64_force_sig_fault+0x4c/0x7c
send_user_sigtrap+0x70/0x84
single_step_handler+0x50/0xf0
do_debug_exception+0xa4/0x14c
el0_dbg+0x20/0x60
el0t_64_sync_handler+0x110/0x1b0
el0t_64_sync+0x1a0/0x1a4
Fix potential sleep while atomic in the similar way of
2dbbc3a07009 ("signal/x86: Delay calling signals in atomic")
Define ARCH_RT_DELAYS_SIGNAL_SEND to enable delaying action in
force_sig_info_to_task. Add actual sending action to arm64 specific path.
Signed-off-by: He Zhe <zhe.he@windriver.com>
---
arch/arm64/include/asm/signal.h | 4 ++++
arch/arm64/kernel/signal.c | 8 ++++++++
2 files changed, 12 insertions(+)
diff --git a/arch/arm64/include/asm/signal.h b/arch/arm64/include/asm/signal.h
index ef449f5f4ba8..5e535c3e4926 100644
--- a/arch/arm64/include/asm/signal.h
+++ b/arch/arm64/include/asm/signal.h
@@ -22,4 +22,8 @@ static inline void __user *arch_untagged_si_addr(void __user *addr,
}
#define arch_untagged_si_addr arch_untagged_si_addr
+#if defined(CONFIG_PREEMPT_RT)
+#define ARCH_RT_DELAYS_SIGNAL_SEND
+#endif
+
#endif
diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c
index 8a9194ed981c..1d65f2801e13 100644
--- a/arch/arm64/kernel/signal.c
+++ b/arch/arm64/kernel/signal.c
@@ -928,6 +928,14 @@ void do_notify_resume(struct pt_regs *regs, unsigned long thread_flags)
} else {
local_daif_restore(DAIF_PROCCTX);
+#ifdef ARCH_RT_DELAYS_SIGNAL_SEND
+ if (unlikely(current->forced_info.si_signo)) {
+ struct task_struct *t = current;
+ force_sig_info(&t->forced_info);
+ t->forced_info.si_signo = 0;
+ }
+#endif
+
if (thread_flags & _TIF_UPROBE)
uprobe_notify_resume(regs);
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] arm64: signal: Delay calling signals in atomic
@ 2021-10-12 8:44 ` He Zhe
0 siblings, 0 replies; 4+ messages in thread
From: He Zhe @ 2021-10-12 8:44 UTC (permalink / raw)
To: catalin.marinas, will, linux-arm-kernel, linux-kernel, zhe.he,
bigeasy, tglx, rostedt, linux-rt-users
Debugging with breakpoints on arm64 and RT would trigger the following
call trace. When CONFIG_PREEMPT_RT is enabled, spin_locks become mutexes,
and one of these is the spin lock used in signal handling.
BUG: sleeping function called from invalid context at kernel/locking/spinlock_rt.c:46
in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 357, name: multi-timer
preempt_count: 1, expected: 0
RCU nest depth: 0, expected: 0
Preemption disabled at:
[<ffffffc01002f11c>] do_debug_exception+0x58/0x14c
CPU: 0 PID: 357 Comm: multi-timer Not tainted 5.15.0-rc4-rt8-yocto-preempt-rt #1
Hardware name: linux,dummy-virt (DT)
Call trace:
dump_backtrace+0x0/0x19c
show_stack+0x24/0x30
dump_stack_lvl+0x7c/0xa0
dump_stack+0x18/0x34
__might_resched+0x160/0x1c0
rt_spin_lock+0x3c/0xb0
force_sig_info_to_task+0x38/0x14c
force_sig_fault+0x60/0x84
arm64_force_sig_fault+0x4c/0x7c
send_user_sigtrap+0x70/0x84
single_step_handler+0x50/0xf0
do_debug_exception+0xa4/0x14c
el0_dbg+0x20/0x60
el0t_64_sync_handler+0x110/0x1b0
el0t_64_sync+0x1a0/0x1a4
Fix potential sleep while atomic in the similar way of
2dbbc3a07009 ("signal/x86: Delay calling signals in atomic")
Define ARCH_RT_DELAYS_SIGNAL_SEND to enable delaying action in
force_sig_info_to_task. Add actual sending action to arm64 specific path.
Signed-off-by: He Zhe <zhe.he@windriver.com>
---
arch/arm64/include/asm/signal.h | 4 ++++
arch/arm64/kernel/signal.c | 8 ++++++++
2 files changed, 12 insertions(+)
diff --git a/arch/arm64/include/asm/signal.h b/arch/arm64/include/asm/signal.h
index ef449f5f4ba8..5e535c3e4926 100644
--- a/arch/arm64/include/asm/signal.h
+++ b/arch/arm64/include/asm/signal.h
@@ -22,4 +22,8 @@ static inline void __user *arch_untagged_si_addr(void __user *addr,
}
#define arch_untagged_si_addr arch_untagged_si_addr
+#if defined(CONFIG_PREEMPT_RT)
+#define ARCH_RT_DELAYS_SIGNAL_SEND
+#endif
+
#endif
diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c
index 8a9194ed981c..1d65f2801e13 100644
--- a/arch/arm64/kernel/signal.c
+++ b/arch/arm64/kernel/signal.c
@@ -928,6 +928,14 @@ void do_notify_resume(struct pt_regs *regs, unsigned long thread_flags)
} else {
local_daif_restore(DAIF_PROCCTX);
+#ifdef ARCH_RT_DELAYS_SIGNAL_SEND
+ if (unlikely(current->forced_info.si_signo)) {
+ struct task_struct *t = current;
+ force_sig_info(&t->forced_info);
+ t->forced_info.si_signo = 0;
+ }
+#endif
+
if (thread_flags & _TIF_UPROBE)
uprobe_notify_resume(regs);
--
2.17.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] arm64: signal: Delay calling signals in atomic
2021-10-12 8:44 ` He Zhe
@ 2021-10-15 17:03 ` Sebastian Andrzej Siewior
-1 siblings, 0 replies; 4+ messages in thread
From: Sebastian Andrzej Siewior @ 2021-10-15 17:03 UTC (permalink / raw)
To: He Zhe
Cc: catalin.marinas, will, linux-arm-kernel, linux-kernel, tglx,
rostedt, linux-rt-users
On 2021-10-12 16:44:21 [+0800], He Zhe wrote:
> Debugging with breakpoints on arm64 and RT would trigger the following
> call trace. When CONFIG_PREEMPT_RT is enabled, spin_locks become mutexes,
> and one of these is the spin lock used in signal handling.
Applied.
Sebastian
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] arm64: signal: Delay calling signals in atomic
@ 2021-10-15 17:03 ` Sebastian Andrzej Siewior
0 siblings, 0 replies; 4+ messages in thread
From: Sebastian Andrzej Siewior @ 2021-10-15 17:03 UTC (permalink / raw)
To: He Zhe
Cc: catalin.marinas, will, linux-arm-kernel, linux-kernel, tglx,
rostedt, linux-rt-users
On 2021-10-12 16:44:21 [+0800], He Zhe wrote:
> Debugging with breakpoints on arm64 and RT would trigger the following
> call trace. When CONFIG_PREEMPT_RT is enabled, spin_locks become mutexes,
> and one of these is the spin lock used in signal handling.
Applied.
Sebastian
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-10-15 17:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-12 8:44 [PATCH] arm64: signal: Delay calling signals in atomic He Zhe
2021-10-12 8:44 ` He Zhe
2021-10-15 17:03 ` Sebastian Andrzej Siewior
2021-10-15 17:03 ` Sebastian Andrzej Siewior
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.