From: Vineet.Gupta1@synopsys.com (Vineet Gupta)
To: linux-snps-arc@lists.infradead.org
Subject: [PATCH] rt_sigaction.h: ARC: Provide default sa_restorer
Date: Mon, 7 Mar 2016 17:21:53 +0530 [thread overview]
Message-ID: <1457351513-8310-1-git-send-email-vgupta@synopsys.com> (raw)
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(+)
diff --git a/include/lapi/rt_sigaction.h b/include/lapi/rt_sigaction.h
index 3a5a763ce094..c7fb04fc25be 100644
--- a/include/lapi/rt_sigaction.h
+++ b/include/lapi/rt_sigaction.h
@@ -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
--
2.5.0
reply other threads:[~2016-03-07 11:51 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1457351513-8310-1-git-send-email-vgupta@synopsys.com \
--to=vineet.gupta1@synopsys.com \
--cc=linux-snps-arc@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).