Skip to contentSkip to conversation

rt_sigaction.h: ARC: Provide default sa_restorer

PATCH New Vineet Gupta 2 participants 2 messages Mar 7, 2016 Synopsys ARC architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rt_sigaction.h: ARC: Provide default sa_restorer

LTP tests the raw (non libc) sigaction ABI to kernel such as validation of various params.

sigaction on ARC relies on default userspace sa restorer to invoke a sigreturn syscall when returning from a signal handler. Thus libc provides a default sa restorer.

LTP tests the raw sigaction syscall ABI (w/o libc) hence needs the restorer userspace infrastructure, which this patch provides for ARC.

Signed-off-by Vineet Gupta <vgupta at synopsys.com>
---
 include/lapi/rt_sigaction.h | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
include/lapi/rt_sigaction.h +26 -0
index 3a5a763ce094..c7fb04fc25be 100644
@@ -145,6 +145,30 @@ static void __attribute__((used)) __sigreturn_stub(void)
 # endif
 #endif /* __sparc__ */
 
+#ifdef __arc__
+
+#undef SA_RESTORER
+#define SA_RESTORER     0x04000000
+
+/*
+ * based on uClibc/libc/sysdeps/linux/arc/sigaction.c
+ */
+static void
+__attribute__ ((optimize("Os"))) __attribute__((used)) restore_rt(void)
+{
+	__asm__ (
+		"mov r8, %0	\n\t"
+#ifdef __ARCHS__
+		"trap_s	0	\n\t"
+#else
+		"trap0	\n\t"
+#endif
+		: /* no outputs */
+		: "i" (__NR_rt_sigreturn)
+		: "r8");
+}
+#endif
+
 /* This is a wrapper for __NR_rt_sigaction syscall.
  * act/oact values of INVAL_SA_PTR is used to pass
  * an invalid pointer to syscall(__NR_rt_sigaction)
@@ -176,8 +200,10 @@ static int ltp_rt_sigaction(int signum, const struct sigaction *act,
 	else if (oact)
 		koact_p = &koact;
 
+#if defined __x86_64__ || defined __arc__
 #ifdef __x86_64__
 	sig_initial(signum);
+#endif
 	kact.sa_flags |= SA_RESTORER;
 	kact.sa_restorer = restore_rt;
 #endif
Signature · 1 line
2.5.0
#1 lore raw

PATCH 1/1 rt_sigaction.h: ARC: Provide default sa_restorer

Hi!

include/lapi/rt_sigaction.h static int ltp_rt_sigaction(int signum, const struct sigaction *act, · line 209

Quoted 7 lines
include/lapi/rt_sigaction.h +2 -0
+#if defined __x86_64__ || defined __arc__
 #ifdef __x86_64__
 	sig_initial(signum);
+#endif
 	kact.sa_flags |= SA_RESTORER;
 	kact.sa_restorer = restore_rt;
 #endif

I've changed this so that there are no nested #ifdefs here and pushed, thanks.

Signature · 2 lines
Cyril Hrubis
[email protected]