foss-for-synopsys-dwc-arc-processors / linux

Helpful resources for users & developers of Linux kernel for ARC
22 stars 13 forks source link

port strace to ARC64 #41

Closed vineetgarc closed 3 years ago

vineetgarc commented 3 years ago

Started with v5.10 release. Only 2 lines of cod echange needed and it builds for ARC64. However when run, hangs (on SIGSTOP signal) so something is wrong in implementation.

# strace ls /
[1]+  Stopped (signal)           strace ls /
vineetgarc commented 3 years ago

This is not specific to ARC64. In the arc64 branch, strace is broken even for ARCv2. Same strace works fine on mainline kernels.

vineetgarc commented 3 years ago

git bisect pointed to commit 2020-05-26 4b61e03f7402 ARCv2: enable common code for ARCv2 and ARCv3

The issue was a benign looking code change: a piece of code presnet in both if and else was blocks was hoisted out with assumption that it would always execute. Turns out to not be the case (lesson relearnt despite knowing it forever: never add more code than needed by changelog)

commit c97d5729b59f1887703833b03bba2023a85551a4 (HEAD -> arc64, gh/arc64)
Author: Vineet Gupta <vgupta@synopsys.com>
Date:   Mon Feb 22 17:29:09 2021 -0800

    ARC: unbork syscall tracing

    Signed-off-by: Vineet Gupta <vgupta@synopsys.com>

diff --git a/arch/arc/kernel/signal.c b/arch/arc/kernel/signal.c
index 95d3d3eefbec..b0267c40f4be 100644
--- a/arch/arc/kernel/signal.c
+++ b/arch/arc/kernel/signal.c
@@ -390,10 +390,11 @@ void do_signal(struct pt_regs *regs)
                    regs->r0 == -ERESTARTSYS    ||
                    regs->r0 == -ERESTARTNOINTR) {
                        regs->r0 = regs->orig_r0;
+                       regs->ret -= syscall_trap_sz();
                } else if (regs->r0 == -ERESTART_RESTARTBLOCK) {
                        regs->r8 = __NR_restart_syscall;
+                       regs->ret -= syscall_trap_sz();
                }
-               regs->ret -= syscall_trap_sz();
                syscall_wont_restart(regs);     /* No more restarts */
vineetgarc commented 3 years ago

change needed for ARCv3 posted to strace mailing list. http://lists.infradead.org/pipermail/linux-snps-arc/2021-February/004827.html

buildroot change to incorporate above pushed github # arc64 branch.