Blob Blame History Raw
From c82efe02674d5f34a3436f25a47826789cd662ab Mon Sep 17 00:00:00 2001
From: He Zhe <zhe.he@windriver.com>
Date: Tue, 12 Oct 2021 16:44:21 +0800
Subject: [PATCH] arm64: signal: Use ARCH_RT_DELAYS_SIGNAL_SEND.

References: SLE Realtime Extension
Patch-mainline: Queued in subsystem maintainer repository
Git-commit: c2921803d42d6ff17159c33a280a3bd3c5503664
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-rt-devel.git

The software breakpoint is handled via do_debug_exception() which
disables preemption. On PREEMPT_RT spinlock_t become sleeping locks and
must not be acquired with disabled preemption.

Use ARCH_RT_DELAYS_SIGNAL_SEND so the signal (from send_user_sigtrap())
is sent delayed in return to userland.

Signed-off-by: He Zhe <zhe.he@windriver.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Link: https://lore.kernel.org/r/20211012084421.35136-1-zhe.he@windriver.com
Signed-off-by: Mel Gorman <mgorman@suse.de>
---
 arch/arm64/Kconfig         | 1 +
 arch/arm64/kernel/signal.c | 8 ++++++++
 2 files changed, 9 insertions(+)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 2e4751f1b391..db26983fe5fc 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -95,6 +95,7 @@ config ARM64
 	select ARCH_WANT_HUGE_PMD_SHARE if ARM64_4K_PAGES || (ARM64_16K_PAGES && !ARM64_VA_BITS_36)
 	select ARCH_WANT_LD_ORPHAN_WARN
 	select ARCH_WANTS_NO_INSTR
+	select ARCH_WANTS_RT_DELAYED_SIGNALS
 	select ARCH_HAS_UBSAN_SANITIZE_ALL
 	select ARM_AMBA
 	select ARM_ARCH_TIMER
diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c
index 4c41672af805..78e0342c9def 100644
--- a/arch/arm64/kernel/signal.c
+++ b/arch/arm64/kernel/signal.c
@@ -937,6 +937,14 @@ asmlinkage void do_notify_resume(struct pt_regs *regs,
 		} else {
 			local_daif_restore(DAIF_PROCCTX);
 
+#ifdef CONFIG_RT_DELAYED_SIGNALS
+			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);