From: guoren@kernel.org
To: arnd@arndb.de
Cc: linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org,
Guo Ren <guoren@linux.alibaba.com>
Subject: [PATCH 03/11] csky: Add support for restartable sequence
Date: Fri, 3 Apr 2020 12:41:42 +0800 [thread overview]
Message-ID: <20200403044150.20562-3-guoren@kernel.org> (raw)
In-Reply-To: <20200403044150.20562-1-guoren@kernel.org>
From: Guo Ren <guoren@linux.alibaba.com>
Copied and adapted from vincent's patch, but modified for csky.
ref:
https://lore.kernel.org/linux-riscv/1572919114-3886-3-git-send-email-vincent.chen@sifive.com/raw
Add calls to rseq_signal_deliver(), rseq_handle_notify_resume() and
rseq_syscall() to introduce RSEQ support.
1. Call the rseq_handle_notify_resume() function on return to userspace
if TIF_NOTIFY_RESUME thread flag is set.
2. Call the rseq_signal_deliver() function to fixup on the pre-signal
frame when a signal is delivered on top of a restartable sequence
critical section.
3. Check that system calls are not invoked from within rseq critical
sections by invoking rseq_signal() from ret_from_syscall(). With
CONFIG_DEBUG_RSEQ, such behavior results in termination of the
process with SIGSEGV.
Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
---
arch/csky/Kconfig | 1 +
arch/csky/kernel/entry.S | 5 ++++-
arch/csky/kernel/signal.c | 3 +++
3 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/arch/csky/Kconfig b/arch/csky/Kconfig
index 2dfd3fb07db9..0e9b14367fa8 100644
--- a/arch/csky/Kconfig
+++ b/arch/csky/Kconfig
@@ -49,6 +49,7 @@ config CSKY
select HAVE_PERF_USER_STACK_DUMP
select HAVE_DMA_CONTIGUOUS
select HAVE_REGS_AND_STACK_ACCESS_API
+ select HAVE_RSEQ
select HAVE_STACKPROTECTOR
select HAVE_SYSCALL_TRACEPOINTS
select MAY_HAVE_SPARSE_IRQ
diff --git a/arch/csky/kernel/entry.S b/arch/csky/kernel/entry.S
index 007706328000..0bde1d9fd277 100644
--- a/arch/csky/kernel/entry.S
+++ b/arch/csky/kernel/entry.S
@@ -128,7 +128,10 @@ tlbop_end 1
ENTRY(csky_systemcall)
SAVE_ALL TRAP0_SIZE
zero_fp
-
+#ifdef CONFIG_RSEQ_DEBUG
+ mov a0, sp
+ jbsr rseq_syscall
+#endif
psrset ee, ie
lrw r11, __NR_syscalls
diff --git a/arch/csky/kernel/signal.c b/arch/csky/kernel/signal.c
index 9b1b7c039ddf..3d6b728cbb72 100644
--- a/arch/csky/kernel/signal.c
+++ b/arch/csky/kernel/signal.c
@@ -175,6 +175,8 @@ static void handle_signal(struct ksignal *ksig, struct pt_regs *regs)
sigset_t *oldset = sigmask_to_save();
int ret;
+ rseq_signal_deliver(ksig, regs);
+
/* Are we from a system call? */
if (in_syscall(regs)) {
/* Avoid additional syscall restarting via ret_from_exception */
@@ -258,5 +260,6 @@ asmlinkage void do_notify_resume(struct pt_regs *regs,
if (thread_info_flags & _TIF_NOTIFY_RESUME) {
clear_thread_flag(TIF_NOTIFY_RESUME);
tracehook_notify_resume(regs);
+ rseq_handle_notify_resume(NULL, regs);
}
}
--
2.17.0
next prev parent reply other threads:[~2020-04-03 4:42 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-03 4:41 [PATCH 01/11] csky: Fixup init_fpu compile warning with __init guoren
2020-04-03 4:41 ` [PATCH 02/11] csky: Implement ptrace regs and stack API guoren
2020-04-03 4:41 ` guoren [this message]
2020-04-03 4:41 ` [PATCH 04/11] csky: Implement ftrace with regs guoren
2020-04-03 4:41 ` [PATCH 05/11] csky/ftrace: Fixup ftrace_modify_code deadlock without CPU_HAS_ICACHE_INS guoren
2020-04-03 4:41 ` [PATCH 06/11] csky: Fixup get wrong psr value from phyical reg guoren
2020-04-03 4:41 ` [PATCH 07/11] csky: Enable the gcov function guoren
2020-04-03 4:41 ` [PATCH 08/11] csky: Enable LOCKDEP_SUPPORT guoren
2020-04-03 4:41 ` [PATCH 09/11] csky: Add kprobes supported guoren
2020-04-03 4:41 ` [PATCH 10/11] csky: Add uprobes support guoren
2020-04-03 4:41 ` [PATCH 11/11] csky: Fixup cpu speculative execution to IO area guoren
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200403044150.20562-3-guoren@kernel.org \
--to=guoren@kernel.org \
--cc=arnd@arndb.de \
--cc=guoren@linux.alibaba.com \
--cc=linux-csky@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.