Revert "csky: Fixup CONFIG_DEBUG_RSEQ"
Subsystems (3)
Mathieu Desnoyers
maintainerRFC PATCH 1/2 Revert "csky: Fixup CONFIG_DEBUG_RSEQ"
This reverts commit f36e0aab6f1f78d770ce859df3f07a9c5763ce5f.
The csky rseq support has been merged without ever notifying the rseq maintainers, and without any of the required asssembler glue in the rseq selftests, which means it is entirely untested.
It is also derived from a non-upstream riscv patch which has known bugs.
The assembly part of this revert should be carefully reviewed by the architecture maintainer because it touches code which has changed since the merge of the reverted patch.
The rseq selftests assembly glue should be introduced at the same time as the architecture rseq support. Without the presence of any test, I recommend reverting rseq support from csky for now.
--- arch/csky/kernel/entry.S | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
arch/csky/kernel/entry.S +5 -10
@@ -50,11 +50,15 @@ ENTRY(csky_systemcall) SAVE_ALL TRAP0_SIZE zero_fp context_tracking +#ifdef CONFIG_RSEQ_DEBUG + mov a0, sp + jbsr rseq_syscall +#endif psrset ee, ie lrw r9, __NR_syscalls cmphs syscallid, r9 /* Check nr of syscall */ - bt 1f + bt ret_from_exception lrw r9, sys_call_table ixw r9, syscallid
@@ -80,11 +84,6 @@ ENTRY(csky_systemcall) jsr syscallid #endif stw a0, (sp, LSAVE_A0) /* Save return value */ -1: -#ifdef CONFIG_DEBUG_RSEQ - mov a0, sp - jbsr rseq_syscall -#endif jmpi ret_from_exception csky_syscall_trace:
@@ -113,10 +112,6 @@ csky_syscall_trace: stw a0, (sp, LSAVE_A0) /* Save return value */ 1: -#ifdef CONFIG_DEBUG_RSEQ - mov a0, sp - jbsr rseq_syscall -#endif mov a0, sp /* right now, sp --> pt_regs */ jbsr syscall_trace_exit br ret_from_exception
Signature · 1 line
2.20.1
Mathieu Desnoyers
maintainerRFC PATCH 2/2 Revert "csky: Add support for restartable sequence"
This reverts commit 9866d141a0977ace974400bf1f793dfc163409ce.
The csky rseq support has been merged without ever notifying the rseq maintainers, and without any of the required asssembler glue in the rseq selftests, which means it is entirely untested.
It is also derived from a non-upstream riscv patch which has known bugs.
The assembly part of this revert should be carefully reviewed by the architecture maintainer because it touches code which has changed since the merge of the reverted patch.
The rseq selftests assembly glue should be introduced at the same time as the architecture rseq support. Without the presence of any test, I recommend reverting rseq support from csky for now.
--- arch/csky/Kconfig | 1 - arch/csky/kernel/entry.S | 4 ---- arch/csky/kernel/signal.c | 3 --- 3 files changed, 8 deletions(-)
arch/csky/Kconfig +0 -1
@@ -66,7 +66,6 @@ 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
arch/csky/kernel/entry.S +0 -4
@@ -50,10 +50,6 @@ ENTRY(csky_systemcall) SAVE_ALL TRAP0_SIZE zero_fp context_tracking -#ifdef CONFIG_RSEQ_DEBUG - mov a0, sp - jbsr rseq_syscall -#endif psrset ee, ie lrw r9, __NR_syscalls
arch/csky/kernel/signal.c +0 -3
@@ -175,8 +175,6 @@ 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 */
@@ -262,6 +260,5 @@ asmlinkage void do_notify_resume(struct pt_regs *regs,if (thread_info_flags & _TIF_NOTIFY_RESUME) {tracehook_notify_resume (regs); -rseq_handle_notify_resume (NULL , regs); } }
Signature · 1 line
2.20.1
Guo Ren
maintainerRe: [RFC PATCH 2/2] Revert "csky: Add support for restartable sequence"
Hi Mathieu,
Sorry for forgetting to CC you in the last patch, and that patch has been merged into master which has the problem of syscall restart.
I still want to keep rseq feature for csky, and implement the RSEQ_SKIP_FASTPATH for self-test, it that okay?
(quoted diff) +0 -0
b/tools/testing/selftests/rseq/param_test.c
index 699ad5f93c34..1e67b212ad98 100644
tools/testing/selftests/rseq/param_test.c +2 -0
@@ -208,6 +208,8 @@ unsigned int yield_mod_cnt, nr_abort;"bnez " INJECT_ASM_REG ", 222b\n\t" \ "333:\n\t" +#elif defined(__csky__) +#define RSEQ_SKIP_FASTPATH #else #error unsupported target#endif
(quoted diff) +0 -0
b/tools/testing/selftests/rseq/rseq.h
index 3f63eb362b92..c3dce298b36c 100644
tools/testing/selftests/rseq/rseq.h +2 -0
@@ -79,6 +79,8 @@ extern int __rseq_handled;#include <rseq-mips.h> #elif defined(__s390__)#include <rseq-s390.h> +#elif defined(__csky__) +#include <rseq-csky.h> #else #error unsupported target#endif
(quoted diff) +0 -0
b/tools/testing/selftests/rseq/rseq-csky.h
new file mode 100644
index 000000000000..ecad40e9aeda
tools/testing/selftests/rseq/rseq-csky.h new file +71 -0
71 lines not on this page · raw message
Quoted 8 lines · Mathieu Desnoyers
This reverts commit
9866d141a0977ace974400bf1f793dfc163409ce.The csky rseq support has been merged without ever notifying the rseq maintainers, and without any of the required asssembler glue in the rseq selftests, which means it is entirely untested.
It is also derived from a non-upstream riscv patch which has known bugs.
I noticed that in [1]:
As Al Viro pointed out on IRC, the rseq_signal_deliver() should go after syscall restart handling, similarly to what is done on every other supported architecture.
[1] https://lore.kernel.org/linux-riscv/[email protected]/
I still want to fixup it, instead of revert it.
Quoted 69 lines
The assembly part of this revert should be carefully reviewed by the architecture maintainer because it touches code which has changed since the merge of the reverted patch.
The rseq selftests assembly glue should be introduced at the same time as the architecture rseq support. Without the presence of any test, I recommend reverting rseq support from csky for now.
Signed-off-by Mathieu Desnoyers <[email protected]>Cc Guo Ren <[email protected]>Cc Al Viro <[email protected]>Cc Linus Torvalds <[email protected]>--- arch/csky/Kconfig | 1 - arch/csky/kernel/entry.S | 4 ---- arch/csky/kernel/signal.c | 3 --- 3 files changed, 8 deletions(-)arch/csky/Kconfig +0
-1@@ -66,7 +66,6 @@ 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_IRQarch/csky/kernel/entry.S +0
-4@@ -50,10 +50,6 @@ ENTRY(csky_systemcall) SAVE_ALL TRAP0_SIZE zero_fp context_tracking -#ifdef CONFIG_RSEQ_DEBUG - mov a0, sp - jbsr rseq_syscall -#endif psrset ee, ie lrw r9, __NR_syscallsarch/csky/kernel/signal.c +0
-4@@ -175,8 +175,6 @@ 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 */ @@ -262,6 +260,5 @@ asmlinkage void do_notify_resume(struct pt_regs *regs,if (thread_info_flags & _TIF_NOTIFY_RESUME) {tracehook_notify_resume (regs); -rseq_handle_notify_resume (NULL , regs); } } --
Quoted 2 lines
2.20.1
--
Best Regards
Guo Ren
Mathieu Desnoyers
maintainerRe: [RFC PATCH 2/2] Revert "csky: Add support for restartable sequence"
Quoted 7 lines · ----- On Jul 26, 2021, at 12:10 PM, Guo Ren [email protected] wrote:
Hi Mathieu,
Sorry for forgetting to CC you in the last patch, and that patch has been merged into master which has the problem of syscall restart.
I still want to keep rseq feature for csky, and implement the
RSEQ_SKIP_FASTPATHfor self-test, it that okay?
No, the RSEQ_SKIP_FASTPATH is the one special-case of test build which skips building rseq critical sections entirely. This leaves out any relevant testing of rseq per-se. With what we have in the upstream selftests, I expect this test configuration to abort at runtime because no slow-path fallbacks are available when the fastpath is disabled.
The asm glue to test rseq user-space really needs to be implemented for any useful testing to be done here.
Unless that asm glue is contributed, none of the rseq logic is actually tested on that architecture.
Considering the extremely-hard-to-debug nature of races with a broken rseq kernel implementation, proper testing coverage is paramount, so I still recommend the revert unless the selftests user-space asm glue is contributed for C-Sky.
Thanks,
Mathieu
Signature · 3 lines
Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com
Mathieu Desnoyers
maintainerRe: [RFC PATCH 2/2] Revert "csky: Add support for restartable sequence"
Quoted 19 lines · Mathieu Desnoyers
Quoted 7 lines · ----- On Jul 26, 2021, at 12:10 PM, Guo Ren [email protected] wrote:
Hi Mathieu,
Sorry for forgetting to CC you in the last patch, and that patch has been merged into master which has the problem of syscall restart.
I still want to keep rseq feature for csky, and implement the
RSEQ_SKIP_FASTPATHfor self-test, it that okay?No, the
RSEQ_SKIP_FASTPATHis the one special-case of test build which skips building rseq critical sections entirely. This leaves out any relevant testing of rseq per-se. With what we have in the upstream selftests, I expect this test configuration to abort at runtime because no slow-path fallbacks are available when the fastpath is disabled.The asm glue to test rseq user-space really needs to be implemented for any useful testing to be done here.
Quoted 7 lines
Unless that asm glue is contributed, none of the rseq logic is actually tested on that architecture.
Considering the extremely-hard-to-debug nature of races with a broken rseq kernel implementation, proper testing coverage is paramount, so I still recommend the revert unless the selftests user-space asm glue is contributed for C-Sky.
Hi Guo,
A friendly ping after 1.5 year about the fact that the selftests code is still missing for the csky architecture. So there is no way to validate that the kernel pieces that were merged actually work on that architecture.
What is the timeline for contribution of the missing bits needed to enable those tests ?
Here are the required header files:
tools/testing/selftests/rseq/rseq-csky.htools/testing/selftests/rseq/rseq-csky-thread-pointer.h (only if __builtin_thread_pointer is not implemented by gcc)
I'm open to suggestions from other rseq co-maintainers on how to best address this situation.
Thanks,
Mathieu
Signature · 3 lines
Mathieu Desnoyers EfficiOS Inc. https://www.efficios.com
Guo Ren
maintainerRe: [RFC PATCH 2/2] Revert "csky: Add support for restartable sequence"
Quoted 29 lines · Mathieu Desnoyers
Quoted 19 lines · Mathieu Desnoyers
Quoted 7 lines · ----- On Jul 26, 2021, at 12:10 PM, Guo Ren [email protected] wrote:
Hi Mathieu,
Sorry for forgetting to CC you in the last patch, and that patch has been merged into master which has the problem of syscall restart.
I still want to keep rseq feature for csky, and implement the
RSEQ_SKIP_FASTPATHfor self-test, it that okay?No, the
RSEQ_SKIP_FASTPATHis the one special-case of test build which skips building rseq critical sections entirely. This leaves out any relevant testing of rseq per-se. With what we have in the upstream selftests, I expect this test configuration to abort at runtime because no slow-path fallbacks are available when the fastpath is disabled.The asm glue to test rseq user-space really needs to be implemented for any useful testing to be done here.
Quoted 7 lines
Unless that asm glue is contributed, none of the rseq logic is actually tested on that architecture.
Considering the extremely-hard-to-debug nature of races with a broken rseq kernel implementation, proper testing coverage is paramount, so I still recommend the revert unless the selftests user-space asm glue is contributed for C-Sky.
Quoted 8 lines
Hi Guo,
A friendly ping after 1.5 year about the fact that the selftests code is still missing for the csky architecture. So there is no way to validate that the kernel pieces that were merged actually work on that architecture.
What is the timeline for contribution of the missing bits needed to enable those tests ?
I would send the 1st version of patchset before 2022/10/30, or just revert it from csky.
1. a patch for fixup the bug:
arch/csky/kernel/signal.c +0 -0
@@ -179,8 +179,6 @@ 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 */
@@ -206,6 +204,8 @@ static void handle_signal(struct ksignal *ksig,
struct pt_regs *regs)
}
}+ rseq_signal_deliver(ksig, regs);
+
/* Set up the stack frame */
ret = setup_rt_frame(ksig, oldset, regs);2. Add tools/testing/selftests/rseq/rseq-csky* codes.
Quoted 17 lines
Here are the required header files:
tools/testing/selftests/rseq/rseq-csky.htools/testing/selftests/rseq/rseq-csky-thread-pointer.h(only if__builtin_thread_pointeris not implemented by gcc)I'm open to suggestions from other rseq co-maintainers on how to best address this situation.
Thanks,
Mathieu
--
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com
Signature · 2 lines
Best Regards Guo Ren
Mathieu Desnoyers
maintainerRe: [RFC PATCH 2/2] Revert "csky: Add support for restartable sequence"
Quoted 1 line · Guo Ren
On Sat, Sep 10, 2022 at 4:01 AM Mathieu Desnoyers
[
Quoted 8 lines
Quoted 6 lines
A friendly ping after 1.5 year about the fact that the selftests code is still missing for the csky architecture. So there is no way to validate that the kernel pieces that were merged actually work on that architecture.
What is the timeline for contribution of the missing bits needed to enable those tests ?
I would send the 1st version of patchset before 2022/10/30, or just revert it from csky.
OK. I can help by answering questions or with code review. I'm not fluent in csky assembly, but I'll try to learn as I go.
Quoted 17 lines
1. a patch for fixup the bug:
arch/csky/kernel/signal.c +0
-2@@ -179,8 +179,6 @@ 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 */
arch/csky/kernel/signal.c static void handle_signal(struct ksignal *ksig, · line 211
Quoted 8 lines
arch/csky/kernel/signal.c +2
-0@@ -206,6 +204,8 @@ static void handle_signal(struct ksignal *ksig, struct pt_regs *regs) } } +rseq_signal_deliver (ksig, regs); +/* Set up the stack frame */ ret =setup_rt_frame (ksig, oldset, regs);
Yes, this fix is really needed.
Quoted 2 lines
2. Add
tools/testing/selftests/rseq/rseq-csky*codes.
It looks like a good plan,
Thanks,
Mathieu
Quoted 23 lines
Quoted 20 lines
Here are the required header files:
tools/testing/selftests/rseq/rseq-csky.htools/testing/selftests/rseq/rseq-csky-thread-pointer.h(only if__builtin_thread_pointeris not implemented by gcc)I'm open to suggestions from other rseq co-maintainers on how to best address this situation.
Thanks,
Mathieu
--
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com
Signature · 3 lines
Mathieu Desnoyers EfficiOS Inc. https://www.efficios.com