From: Matt Turner <[email protected]>

With the vdso, default_sigreturn and default_rt_sigreturn point at
__kernel_sigreturn and __kernel_rt_sigreturn and setup_sigtramp() is no
longer used. The vdso trampolines load the syscall number with mov.l
instead of the kernel's mov.w/trapa/or r0,r0 sequence, which undoes
commit 9ac5aa7227 ("linux-user/sh4: Fix setup_sigtramp to match Linux
kernel trampoline pattern"): libunwind's unw_is_signal_frame() no longer
recognizes the signal frame, so unwinding through a signal handler stops
there.

Use the sequence from the kernel's own vdso,
arch/sh/kernel/vsyscall/vsyscall-sigreturn.S.

Fixes: 975bd51a88 ("linux-user/sh4: add VDSO support for sh4 and sh4eb")
Cc: [email protected]
Signed-off-by: Matt Turner <[email protected]>
Reviewed-by: Helge Deller <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
(cherry picked from commit 170dfd8d1f86d4baa0bd7ba7d615febde3252086)
Signed-off-by: Michael Tokarev <[email protected]>

diff --git a/linux-user/sh4/vdso-be.so b/linux-user/sh4/vdso-be.so
index 4f50143f828..bc1fb37e108 100755
Binary files a/linux-user/sh4/vdso-be.so and b/linux-user/sh4/vdso-be.so differ
diff --git a/linux-user/sh4/vdso-le.so b/linux-user/sh4/vdso-le.so
index c41cb5831b9..c1ff560cc16 100755
Binary files a/linux-user/sh4/vdso-le.so and b/linux-user/sh4/vdso-le.so differ
diff --git a/linux-user/sh4/vdso.S b/linux-user/sh4/vdso.S
index 4fb5ee9d31b..1faa6657746 100644
--- a/linux-user/sh4/vdso.S
+++ b/linux-user/sh4/vdso.S
@@ -43,6 +43,22 @@ vdso_syscall __vdso_clock_gettime64, __NR_clock_gettime64
 vdso_syscall __vdso_clock_getres, __NR_clock_getres
 vdso_syscall __vdso_gettimeofday, __NR_gettimeofday
 
+/*
+ * Same instruction sequence as the kernel's
+ * arch/sh/kernel/vsyscall/vsyscall-sigreturn.S. libunwind matches these
+ * bytes to recognize a signal frame.
+ */
+.macro sigreturn_tramp nr
+       mov.w   1f, r3
+       trapa   #0x10
+       or      r0, r0
+       or      r0, r0
+       or      r0, r0
+       or      r0, r0
+       or      r0, r0
+1:     .word   \nr
+.endm
+
 /*
  * Signal return trampolines.
  *
@@ -122,20 +138,14 @@ vdso_syscall __vdso_gettimeofday, __NR_gettimeofday
 
 sigreturn_region_start:
 __kernel_sigreturn:
-       mov.l   1f, r3
-       trapa   #0x10
-       .align  2
-1:     .long   __NR_sigreturn
+       sigreturn_tramp __NR_sigreturn
 endf __kernel_sigreturn
 
        /* Update CFA base for the rt_sigreturn frame layout. */
        .cfi_def_cfa_offset     RT_SIGFRAME_SC_OFFSET
 
 __kernel_rt_sigreturn:
-       mov.l   2f, r3
-       trapa   #0x10
-       .align  2
-2:     .long   __NR_rt_sigreturn
+       sigreturn_tramp __NR_rt_sigreturn
 endf __kernel_rt_sigreturn
 sigreturn_region_end:
 
-- 
2.47.3


Reply via email to