* [Qemu-devel] [RFC 00/11] linux-user: Sort out signal handling for MIPS n32 and n64
@ 2011-12-29 15:55 Andreas Färber
2011-12-29 15:55 ` [Qemu-devel] [PATCH 01/11] linux-user: Add default-configs for mipsn32[el] Andreas Färber
` (10 more replies)
0 siblings, 11 replies; 12+ messages in thread
From: Andreas Färber @ 2011-12-29 15:55 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Ehsan Ul Haq, Riku Voipio, Alexander Graf,
Brendan Kirby, Khansa Butt, Andreas Färber, Aurelien Jarno,
Richard Henderson
Hello,
Here's a suggestion for moving forward with mipsn32 and mips64.
For testing add the following to your --target-list:
mips-linux-user
mipsel-linux-user
mipsn32-linux-user
mipsn32el-linux-user
mips64-linux-user
mips64el-linux-user
Patches 1-4 are trivial and hopefully uncontroversial preparations
that can be cherry-picked right away!
The n32 ones are based on a patch by Uli found in openSUSE,
the n64 ones are extracted from Khansa's patch series.
Patch 5 is a bugfix based on a patch by Khansa/Ehsan.
The rest of the patches are in RFC status and attempt to implement
rth's suggestion of sharing signal handling between MIPS ABIs.
Depending on the issue the final patch brings up, even more code
might be shared.
Regards,
Andreas
Cc: Riku Voipio <riku.voipio@iki.fi>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Khansa Butt <khansa@kics.edu.pk>
Cc: Ehsan Ul Haq <ehsan.ulhaq@kics.edu.pk>
Cc: Ulrich Hecht <uli@suse.de>
Cc: Brendan Kirby <bkirby@mips.com>
Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: Alexander Graf <agraf@suse.de>
Andreas Färber (11):
linux-user: Add default-configs for mipsn32[el]
linux-user: Add default configs for mips64[el]
linux-user: Define TARGET_QEMU_ESIGRETURN for mipsn32
linux-user: Define TARGET_QEMU_ESIGRETURN for mips64
linux-user: Fix sa_flags byte swaps for mips
linux-user: Unify signal handling for mips
linux-user: target_sigcontext for mipsn32 and mips64
linux-user: Share {setup,restore}_sigcontext() for mips ABIs
linux-user: Setup/restore sc_acx for mips and mipsn32
linux-user: mipsn32 does not support non-RT signals
linux-user: Implement signal handling for mipsn32
default-configs/mips64-linux-user.mak | 1 +
default-configs/mips64el-linux-user.mak | 1 +
default-configs/mipsn32-linux-user.mak | 1 +
default-configs/mipsn32el-linux-user.mak | 1 +
linux-user/mips64/syscall.h | 3 +
linux-user/mipsn32/syscall.h | 3 +
linux-user/signal.c | 348 +++++++++++++++++++++---------
7 files changed, 251 insertions(+), 107 deletions(-)
create mode 100644 default-configs/mips64-linux-user.mak
create mode 100644 default-configs/mips64el-linux-user.mak
create mode 100644 default-configs/mipsn32-linux-user.mak
create mode 100644 default-configs/mipsn32el-linux-user.mak
--
1.7.7
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Qemu-devel] [PATCH 01/11] linux-user: Add default-configs for mipsn32[el]
2011-12-29 15:55 [Qemu-devel] [RFC 00/11] linux-user: Sort out signal handling for MIPS n32 and n64 Andreas Färber
@ 2011-12-29 15:55 ` Andreas Färber
2011-12-29 15:55 ` [Qemu-devel] [PATCH 02/11] linux-user: Add default configs for mips64[el] Andreas Färber
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Andreas Färber @ 2011-12-29 15:55 UTC (permalink / raw)
To: qemu-devel; +Cc: Riku Voipio, Andreas Färber
Prepares for mipsn32[el]-linux-user targets.
Signed-off-by: Ulricht Hecht <uli@suse.de>
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
default-configs/mipsn32-linux-user.mak | 1 +
default-configs/mipsn32el-linux-user.mak | 1 +
2 files changed, 2 insertions(+), 0 deletions(-)
create mode 100644 default-configs/mipsn32-linux-user.mak
create mode 100644 default-configs/mipsn32el-linux-user.mak
diff --git a/default-configs/mipsn32-linux-user.mak b/default-configs/mipsn32-linux-user.mak
new file mode 100644
index 0000000..5b97919
--- /dev/null
+++ b/default-configs/mipsn32-linux-user.mak
@@ -0,0 +1 @@
+# Default configuration for mipsn32-linux-user
diff --git a/default-configs/mipsn32el-linux-user.mak b/default-configs/mipsn32el-linux-user.mak
new file mode 100644
index 0000000..d6367ff
--- /dev/null
+++ b/default-configs/mipsn32el-linux-user.mak
@@ -0,0 +1 @@
+# Default configuration for mipsn32el-linux-user
--
1.7.7
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Qemu-devel] [PATCH 02/11] linux-user: Add default configs for mips64[el]
2011-12-29 15:55 [Qemu-devel] [RFC 00/11] linux-user: Sort out signal handling for MIPS n32 and n64 Andreas Färber
2011-12-29 15:55 ` [Qemu-devel] [PATCH 01/11] linux-user: Add default-configs for mipsn32[el] Andreas Färber
@ 2011-12-29 15:55 ` Andreas Färber
2011-12-29 15:55 ` [Qemu-devel] [PATCH 03/11] linux-user: Define TARGET_QEMU_ESIGRETURN for mipsn32 Andreas Färber
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Andreas Färber @ 2011-12-29 15:55 UTC (permalink / raw)
To: qemu-devel; +Cc: Riku Voipio, Khansa Butt, Andreas Färber
Prepares for mips64[el]-linux-user targets.
Signed-off-by: Khansa Butt <khansa@kics.edu.pk>
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
default-configs/mips64-linux-user.mak | 1 +
default-configs/mips64el-linux-user.mak | 1 +
2 files changed, 2 insertions(+), 0 deletions(-)
create mode 100644 default-configs/mips64-linux-user.mak
create mode 100644 default-configs/mips64el-linux-user.mak
diff --git a/default-configs/mips64-linux-user.mak b/default-configs/mips64-linux-user.mak
new file mode 100644
index 0000000..1598bfc
--- /dev/null
+++ b/default-configs/mips64-linux-user.mak
@@ -0,0 +1 @@
+# Default configuration for mips64-linux-user
diff --git a/default-configs/mips64el-linux-user.mak b/default-configs/mips64el-linux-user.mak
new file mode 100644
index 0000000..629f084
--- /dev/null
+++ b/default-configs/mips64el-linux-user.mak
@@ -0,0 +1 @@
+# Default configuration for mips64el-linux-user
--
1.7.7
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Qemu-devel] [PATCH 03/11] linux-user: Define TARGET_QEMU_ESIGRETURN for mipsn32
2011-12-29 15:55 [Qemu-devel] [RFC 00/11] linux-user: Sort out signal handling for MIPS n32 and n64 Andreas Färber
2011-12-29 15:55 ` [Qemu-devel] [PATCH 01/11] linux-user: Add default-configs for mipsn32[el] Andreas Färber
2011-12-29 15:55 ` [Qemu-devel] [PATCH 02/11] linux-user: Add default configs for mips64[el] Andreas Färber
@ 2011-12-29 15:55 ` Andreas Färber
2011-12-29 15:55 ` [Qemu-devel] [PATCH 04/11] linux-user: Define TARGET_QEMU_ESIGRETURN for mips64 Andreas Färber
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Andreas Färber @ 2011-12-29 15:55 UTC (permalink / raw)
To: qemu-devel; +Cc: Riku Voipio, Andreas Färber
Copied from mips/syscall.h.
Signed-off-by: Ulrich Hecht <uli@suse.de>
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
linux-user/mipsn32/syscall.h | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/linux-user/mipsn32/syscall.h b/linux-user/mipsn32/syscall.h
index 4ec506c..ebe98f2 100644
--- a/linux-user/mipsn32/syscall.h
+++ b/linux-user/mipsn32/syscall.h
@@ -218,4 +218,7 @@ struct target_pt_regs {
+/* Nasty hack: define a fake errno value for use by sigreturn. */
+#define TARGET_QEMU_ESIGRETURN 255
+
#define UNAME_MACHINE "mips64"
--
1.7.7
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Qemu-devel] [PATCH 04/11] linux-user: Define TARGET_QEMU_ESIGRETURN for mips64
2011-12-29 15:55 [Qemu-devel] [RFC 00/11] linux-user: Sort out signal handling for MIPS n32 and n64 Andreas Färber
` (2 preceding siblings ...)
2011-12-29 15:55 ` [Qemu-devel] [PATCH 03/11] linux-user: Define TARGET_QEMU_ESIGRETURN for mipsn32 Andreas Färber
@ 2011-12-29 15:55 ` Andreas Färber
2011-12-29 15:55 ` [Qemu-devel] [PATCH 05/11] linux-user: Fix sa_flags byte swaps for mips Andreas Färber
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Andreas Färber @ 2011-12-29 15:55 UTC (permalink / raw)
To: qemu-devel; +Cc: Riku Voipio, Khansa Butt, Andreas Färber
Copied from mips/syscall.h.
Signed-off-by: Khansa Butt <khansa@kics.edu.pk>
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
linux-user/mips64/syscall.h | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/linux-user/mips64/syscall.h b/linux-user/mips64/syscall.h
index 668a2b9..e436ea5 100644
--- a/linux-user/mips64/syscall.h
+++ b/linux-user/mips64/syscall.h
@@ -218,4 +218,7 @@ struct target_pt_regs {
+/* Nasty hack: define a fake errno value for use by sigreturn. */
+#define TARGET_QEMU_ESIGRETURN 255
+
#define UNAME_MACHINE "mips64"
--
1.7.7
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Qemu-devel] [PATCH 05/11] linux-user: Fix sa_flags byte swaps for mips
2011-12-29 15:55 [Qemu-devel] [RFC 00/11] linux-user: Sort out signal handling for MIPS n32 and n64 Andreas Färber
` (3 preceding siblings ...)
2011-12-29 15:55 ` [Qemu-devel] [PATCH 04/11] linux-user: Define TARGET_QEMU_ESIGRETURN for mips64 Andreas Färber
@ 2011-12-29 15:55 ` Andreas Färber
2011-12-29 15:55 ` [Qemu-devel] [RFC 06/11] linux-user: Unify signal handling " Andreas Färber
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Andreas Färber @ 2011-12-29 15:55 UTC (permalink / raw)
To: qemu-devel; +Cc: Riku Voipio, Ehsan Ul Haq, Andreas Färber
sa_flags is uint32_t for mips{,n32,64}, so don't use tswapal().
Reported-by: Khansa Butt <khansa@kics.edu.pk>
Suggested-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Andreas Färber <afaerber@suse.de>
Cc: Ehsan Ul Haq <ehsan.ulhaq@kics.edu.pk>
---
linux-user/signal.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/linux-user/signal.c b/linux-user/signal.c
index ded12ca..bafbc57 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -587,7 +587,11 @@ int do_sigaction(int sig, const struct target_sigaction *act,
#endif
if (oact) {
oact->_sa_handler = tswapal(k->_sa_handler);
+#if defined(TARGET_MIPS)
+ oact->sa_flags = bswap32(k->sa_flags);
+#else
oact->sa_flags = tswapal(k->sa_flags);
+#endif
#if !defined(TARGET_MIPS)
oact->sa_restorer = tswapal(k->sa_restorer);
#endif
@@ -596,7 +600,11 @@ int do_sigaction(int sig, const struct target_sigaction *act,
if (act) {
/* FIXME: This is not threadsafe. */
k->_sa_handler = tswapal(act->_sa_handler);
+#if defined(TARGET_MIPS)
+ k->sa_flags = bswap32(act->sa_flags);
+#else
k->sa_flags = tswapal(act->sa_flags);
+#endif
#if !defined(TARGET_MIPS)
k->sa_restorer = tswapal(act->sa_restorer);
#endif
--
1.7.7
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Qemu-devel] [RFC 06/11] linux-user: Unify signal handling for mips
2011-12-29 15:55 [Qemu-devel] [RFC 00/11] linux-user: Sort out signal handling for MIPS n32 and n64 Andreas Färber
` (4 preceding siblings ...)
2011-12-29 15:55 ` [Qemu-devel] [PATCH 05/11] linux-user: Fix sa_flags byte swaps for mips Andreas Färber
@ 2011-12-29 15:55 ` Andreas Färber
2011-12-29 15:55 ` [Qemu-devel] [RFC 07/11] linux-user: target_sigcontext for mipsn32 and mips64 Andreas Färber
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Andreas Färber @ 2011-12-29 15:55 UTC (permalink / raw)
To: qemu-devel
Cc: Riku Voipio, Khansa Butt, Andreas Färber, Richard Henderson
As suggested by Richard.
Signed-off-by: Andreas Färber <afaerber@suse.de>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Khansa Butt <khansa@kics.edu.pk>
---
linux-user/signal.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/linux-user/signal.c b/linux-user/signal.c
index bafbc57..394984d 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -2422,7 +2422,8 @@ void sparc64_get_context(CPUSPARCState *env)
force_sig(TARGET_SIGSEGV);
}
#endif
-#elif defined(TARGET_ABI_MIPSN64)
+#elif defined(TARGET_MIPS)
+#if defined(TARGET_ABI_MIPSN64)
# warning signal handling not implemented
@@ -2908,6 +2909,7 @@ badframe:
return 0;
}
+#endif /* TARGET_ABI_MIPSO32 */
#elif defined(TARGET_SH4)
/*
--
1.7.7
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Qemu-devel] [RFC 07/11] linux-user: target_sigcontext for mipsn32 and mips64
2011-12-29 15:55 [Qemu-devel] [RFC 00/11] linux-user: Sort out signal handling for MIPS n32 and n64 Andreas Färber
` (5 preceding siblings ...)
2011-12-29 15:55 ` [Qemu-devel] [RFC 06/11] linux-user: Unify signal handling " Andreas Färber
@ 2011-12-29 15:55 ` Andreas Färber
2011-12-29 15:55 ` [Qemu-devel] [RFC 08/11] linux-user: Share {setup, restore}_sigcontext() for mips ABIs Andreas Färber
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Andreas Färber @ 2011-12-29 15:55 UTC (permalink / raw)
To: qemu-devel
Cc: Riku Voipio, Khansa Butt, Andreas Färber, Richard Henderson
Based on arch/mips/include/asm/sigcontext.h.
Signed-off-by: Andreas Färber <afaerber@suse.de>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Khansa Butt <khansa@kics.edu.pk>
---
linux-user/signal.c | 64 ++++++++++++++++++++++++++++++++++----------------
1 files changed, 43 insertions(+), 21 deletions(-)
diff --git a/linux-user/signal.c b/linux-user/signal.c
index 394984d..6eeafcf 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -2423,6 +2423,49 @@ void sparc64_get_context(CPUSPARCState *env)
}
#endif
#elif defined(TARGET_MIPS)
+
+#if defined(TARGET_ABI_MIPSO32) || defined(TARGET_ABI_MIPSN32)
+struct target_sigcontext {
+ uint32_t sc_regmask; /* Unused */
+ uint32_t sc_status; /* Unused */
+ uint64_t sc_pc;
+ uint64_t sc_regs[32];
+ uint64_t sc_fpregs[32];
+ uint32_t sc_acx; /* only n32; was sc_ownedfp */
+ uint32_t sc_fpc_csr;
+ uint32_t sc_fpc_eir; /* Unused */
+ uint32_t sc_used_math;
+ uint32_t sc_dsp; /* dsp status, was sc_ssflags */
+ uint32_t pad0;
+ uint64_t sc_mdhi;
+ uint64_t sc_mdlo;
+ uint32_t sc_hi1; /* Was sc_cause */
+ uint32_t sc_lo1; /* Was sc_badvaddr */
+ uint32_t sc_hi2; /* Was sc_sigset[4] */
+ uint32_t sc_lo2;
+ uint32_t sc_hi3;
+ uint32_t sc_lo3;
+};
+#elif defined(TARGET_ABI_MIPSN64)
+struct target_sigcontext {
+ uint64_t sc_regs[32];
+ uint64_t sc_fpregs[32];
+ uint64_t sc_mdhi;
+ uint64_t sc_hi1;
+ uint64_t sc_hi2;
+ uint64_t sc_hi3;
+ uint64_t sc_mdlo;
+ uint64_t sc_lo1;
+ uint64_t sc_lo2;
+ uint64_t sc_lo3;
+ uint64_t sc_pc;
+ uint32_t sc_fpc_csr;
+ uint32_t sc_used_math;
+ uint32_t sc_dsp;
+ uint32_t sc_reserved;
+};
+#endif
+
#if defined(TARGET_ABI_MIPSN64)
# warning signal handling not implemented
@@ -2483,27 +2526,6 @@ long do_rt_sigreturn(CPUState *env)
#elif defined(TARGET_ABI_MIPSO32)
-struct target_sigcontext {
- uint32_t sc_regmask; /* Unused */
- uint32_t sc_status;
- uint64_t sc_pc;
- uint64_t sc_regs[32];
- uint64_t sc_fpregs[32];
- uint32_t sc_ownedfp; /* Unused */
- uint32_t sc_fpc_csr;
- uint32_t sc_fpc_eir; /* Unused */
- uint32_t sc_used_math;
- uint32_t sc_dsp; /* dsp status, was sc_ssflags */
- uint32_t pad0;
- uint64_t sc_mdhi;
- uint64_t sc_mdlo;
- target_ulong sc_hi1; /* Was sc_cause */
- target_ulong sc_lo1; /* Was sc_badvaddr */
- target_ulong sc_hi2; /* Was sc_sigset[4] */
- target_ulong sc_lo2;
- target_ulong sc_hi3;
- target_ulong sc_lo3;
-};
struct sigframe {
uint32_t sf_ass[4]; /* argument save space for o32 */
--
1.7.7
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Qemu-devel] [RFC 08/11] linux-user: Share {setup, restore}_sigcontext() for mips ABIs
2011-12-29 15:55 [Qemu-devel] [RFC 00/11] linux-user: Sort out signal handling for MIPS n32 and n64 Andreas Färber
` (6 preceding siblings ...)
2011-12-29 15:55 ` [Qemu-devel] [RFC 07/11] linux-user: target_sigcontext for mipsn32 and mips64 Andreas Färber
@ 2011-12-29 15:55 ` Andreas Färber
2011-12-29 15:55 ` [Qemu-devel] [RFC 09/11] linux-user: Setup/restore sc_acx for mips and mipsn32 Andreas Färber
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Andreas Färber @ 2011-12-29 15:55 UTC (permalink / raw)
To: qemu-devel
Cc: Riku Voipio, Khansa Butt, Andreas Färber, Richard Henderson
Shared for n32/n64 in arch/mips/kernel/signal.c;
o32 version in arch/mips/kernel/signal32.c.
Signed-off-by: Andreas Färber <afaerber@suse.de>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Khansa Butt <khansa@kics.edu.pk>
---
linux-user/signal.c | 204 +++++++++++++++++++++++++-------------------------
1 files changed, 102 insertions(+), 102 deletions(-)
diff --git a/linux-user/signal.c b/linux-user/signal.c
index 6eeafcf..a713cb2 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -2466,108 +2466,6 @@ struct target_sigcontext {
};
#endif
-#if defined(TARGET_ABI_MIPSN64)
-
-# warning signal handling not implemented
-
-static void setup_frame(int sig, struct target_sigaction *ka,
- target_sigset_t *set, CPUState *env)
-{
- fprintf(stderr, "setup_frame: not implemented\n");
-}
-
-static void setup_rt_frame(int sig, struct target_sigaction *ka,
- target_siginfo_t *info,
- target_sigset_t *set, CPUState *env)
-{
- fprintf(stderr, "setup_rt_frame: not implemented\n");
-}
-
-long do_sigreturn(CPUState *env)
-{
- fprintf(stderr, "do_sigreturn: not implemented\n");
- return -TARGET_ENOSYS;
-}
-
-long do_rt_sigreturn(CPUState *env)
-{
- fprintf(stderr, "do_rt_sigreturn: not implemented\n");
- return -TARGET_ENOSYS;
-}
-
-#elif defined(TARGET_ABI_MIPSN32)
-
-# warning signal handling not implemented
-
-static void setup_frame(int sig, struct target_sigaction *ka,
- target_sigset_t *set, CPUState *env)
-{
- fprintf(stderr, "setup_frame: not implemented\n");
-}
-
-static void setup_rt_frame(int sig, struct target_sigaction *ka,
- target_siginfo_t *info,
- target_sigset_t *set, CPUState *env)
-{
- fprintf(stderr, "setup_rt_frame: not implemented\n");
-}
-
-long do_sigreturn(CPUState *env)
-{
- fprintf(stderr, "do_sigreturn: not implemented\n");
- return -TARGET_ENOSYS;
-}
-
-long do_rt_sigreturn(CPUState *env)
-{
- fprintf(stderr, "do_rt_sigreturn: not implemented\n");
- return -TARGET_ENOSYS;
-}
-
-#elif defined(TARGET_ABI_MIPSO32)
-
-
-struct sigframe {
- uint32_t sf_ass[4]; /* argument save space for o32 */
- uint32_t sf_code[2]; /* signal trampoline */
- struct target_sigcontext sf_sc;
- target_sigset_t sf_mask;
-};
-
-struct target_ucontext {
- target_ulong tuc_flags;
- target_ulong tuc_link;
- target_stack_t tuc_stack;
- target_ulong pad0;
- struct target_sigcontext tuc_mcontext;
- target_sigset_t tuc_sigmask;
-};
-
-struct target_rt_sigframe {
- uint32_t rs_ass[4]; /* argument save space for o32 */
- uint32_t rs_code[2]; /* signal trampoline */
- struct target_siginfo rs_info;
- struct target_ucontext rs_uc;
-};
-
-/* Install trampoline to jump back from signal handler */
-static inline int install_sigtramp(unsigned int *tramp, unsigned int syscall)
-{
- int err;
-
- /*
- * Set up the return code ...
- *
- * li v0, __NR__foo_sigreturn
- * syscall
- */
-
- err = __put_user(0x24020000 + syscall, tramp + 0);
- err |= __put_user(0x0000000c , tramp + 1);
- /* flush_cache_sigtramp((unsigned long) tramp); */
- return err;
-}
-
static inline int
setup_sigcontext(CPUState *regs, struct target_sigcontext *sc)
{
@@ -2711,6 +2609,7 @@ restore_sigcontext(CPUState *regs, struct target_sigcontext *sc)
#endif
return err;
}
+
/*
* Determine which stack to use..
*/
@@ -2737,6 +2636,107 @@ get_sigframe(struct target_sigaction *ka, CPUState *regs, size_t frame_size)
return (sp - frame_size) & ~7;
}
+#if defined(TARGET_ABI_MIPSN64)
+
+# warning signal handling not implemented
+
+static void setup_frame(int sig, struct target_sigaction *ka,
+ target_sigset_t *set, CPUState *env)
+{
+ fprintf(stderr, "setup_frame: not implemented\n");
+}
+
+static void setup_rt_frame(int sig, struct target_sigaction *ka,
+ target_siginfo_t *info,
+ target_sigset_t *set, CPUState *env)
+{
+ fprintf(stderr, "setup_rt_frame: not implemented\n");
+}
+
+long do_sigreturn(CPUState *env)
+{
+ fprintf(stderr, "do_sigreturn: not implemented\n");
+ return -TARGET_ENOSYS;
+}
+
+long do_rt_sigreturn(CPUState *env)
+{
+ fprintf(stderr, "do_rt_sigreturn: not implemented\n");
+ return -TARGET_ENOSYS;
+}
+
+#elif defined(TARGET_ABI_MIPSN32)
+
+# warning signal handling not implemented
+
+static void setup_frame(int sig, struct target_sigaction *ka,
+ target_sigset_t *set, CPUState *env)
+{
+ fprintf(stderr, "setup_frame: not implemented\n");
+}
+
+static void setup_rt_frame(int sig, struct target_sigaction *ka,
+ target_siginfo_t *info,
+ target_sigset_t *set, CPUState *env)
+{
+ fprintf(stderr, "setup_rt_frame: not implemented\n");
+}
+
+long do_sigreturn(CPUState *env)
+{
+ fprintf(stderr, "do_sigreturn: not implemented\n");
+ return -TARGET_ENOSYS;
+}
+
+long do_rt_sigreturn(CPUState *env)
+{
+ fprintf(stderr, "do_rt_sigreturn: not implemented\n");
+ return -TARGET_ENOSYS;
+}
+
+#elif defined(TARGET_ABI_MIPSO32)
+
+struct sigframe {
+ uint32_t sf_ass[4]; /* argument save space for o32 */
+ uint32_t sf_code[2]; /* signal trampoline */
+ struct target_sigcontext sf_sc;
+ target_sigset_t sf_mask;
+};
+
+struct target_ucontext {
+ target_ulong tuc_flags;
+ target_ulong tuc_link;
+ target_stack_t tuc_stack;
+ target_ulong pad0;
+ struct target_sigcontext tuc_mcontext;
+ target_sigset_t tuc_sigmask;
+};
+
+struct target_rt_sigframe {
+ uint32_t rs_ass[4]; /* argument save space for o32 */
+ uint32_t rs_code[2]; /* signal trampoline */
+ struct target_siginfo rs_info;
+ struct target_ucontext rs_uc;
+};
+
+/* Install trampoline to jump back from signal handler */
+static inline int install_sigtramp(unsigned int *tramp, unsigned int syscall)
+{
+ int err;
+
+ /*
+ * Set up the return code ...
+ *
+ * li v0, __NR__foo_sigreturn
+ * syscall
+ */
+
+ err = __put_user(0x24020000 + syscall, tramp + 0);
+ err |= __put_user(0x0000000c , tramp + 1);
+ /* flush_cache_sigtramp((unsigned long) tramp); */
+ return err;
+}
+
/* compare linux/arch/mips/kernel/signal.c:setup_frame() */
static void setup_frame(int sig, struct target_sigaction * ka,
target_sigset_t *set, CPUState *regs)
--
1.7.7
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Qemu-devel] [RFC 09/11] linux-user: Setup/restore sc_acx for mips and mipsn32
2011-12-29 15:55 [Qemu-devel] [RFC 00/11] linux-user: Sort out signal handling for MIPS n32 and n64 Andreas Färber
` (7 preceding siblings ...)
2011-12-29 15:55 ` [Qemu-devel] [RFC 08/11] linux-user: Share {setup, restore}_sigcontext() for mips ABIs Andreas Färber
@ 2011-12-29 15:55 ` Andreas Färber
2011-12-29 15:55 ` [Qemu-devel] [PATCH 10/11] linux-user: mipsn32 does not support non-RT signals Andreas Färber
2011-12-29 15:55 ` [Qemu-devel] [RFC 11/11] linux-user: Implement signal handling for mipsn32 Andreas Färber
10 siblings, 0 replies; 12+ messages in thread
From: Andreas Färber @ 2011-12-29 15:55 UTC (permalink / raw)
To: qemu-devel; +Cc: Riku Voipio, Andreas Färber, Richard Henderson
Signed-off-by: Andreas Färber <afaerber@suse.de>
Cc: Richard Henderson <rth@twiddle.net>
---
linux-user/signal.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/linux-user/signal.c b/linux-user/signal.c
index a713cb2..bd13f9b 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -2487,6 +2487,9 @@ setup_sigcontext(CPUState *regs, struct target_sigcontext *sc)
save_gp_reg(31);
#undef save_gp_reg
+#if defined(TARGET_ABI_MIPSO32) || defined(TARGET_ABI_MIPSN32)
+ err |= __put_user(regs->active_tc.ACX[0], &sc->sc_acx);
+#endif
err |= __put_user(regs->active_tc.HI[0], &sc->sc_mdhi);
err |= __put_user(regs->active_tc.LO[0], &sc->sc_mdlo);
@@ -2548,6 +2551,9 @@ restore_sigcontext(CPUState *regs, struct target_sigcontext *sc)
err |= __get_user(regs->CP0_EPC, &sc->sc_pc);
+#if defined(TARGET_ABI_MIPSO32) || defined(TARGET_ABI_MIPSN32)
+ err |= __get_user(regs->active_tc.ACX[0], &sc->sc_acx);
+#endif
err |= __get_user(regs->active_tc.HI[0], &sc->sc_mdhi);
err |= __get_user(regs->active_tc.LO[0], &sc->sc_mdlo);
--
1.7.7
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Qemu-devel] [PATCH 10/11] linux-user: mipsn32 does not support non-RT signals
2011-12-29 15:55 [Qemu-devel] [RFC 00/11] linux-user: Sort out signal handling for MIPS n32 and n64 Andreas Färber
` (8 preceding siblings ...)
2011-12-29 15:55 ` [Qemu-devel] [RFC 09/11] linux-user: Setup/restore sc_acx for mips and mipsn32 Andreas Färber
@ 2011-12-29 15:55 ` Andreas Färber
2011-12-29 15:55 ` [Qemu-devel] [RFC 11/11] linux-user: Implement signal handling for mipsn32 Andreas Färber
10 siblings, 0 replies; 12+ messages in thread
From: Andreas Färber @ 2011-12-29 15:55 UTC (permalink / raw)
To: qemu-devel; +Cc: Riku Voipio, Andreas Färber
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
linux-user/signal.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/linux-user/signal.c b/linux-user/signal.c
index bd13f9b..b33f8cb 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -2678,7 +2678,7 @@ long do_rt_sigreturn(CPUState *env)
static void setup_frame(int sig, struct target_sigaction *ka,
target_sigset_t *set, CPUState *env)
{
- fprintf(stderr, "setup_frame: not implemented\n");
+ fprintf(stderr, "setup_frame: not supported in n32 ABI\n");
}
static void setup_rt_frame(int sig, struct target_sigaction *ka,
@@ -2690,7 +2690,7 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,
long do_sigreturn(CPUState *env)
{
- fprintf(stderr, "do_sigreturn: not implemented\n");
+ fprintf(stderr, "do_sigreturn: not supported in n32 ABI\n");
return -TARGET_ENOSYS;
}
--
1.7.7
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Qemu-devel] [RFC 11/11] linux-user: Implement signal handling for mipsn32
2011-12-29 15:55 [Qemu-devel] [RFC 00/11] linux-user: Sort out signal handling for MIPS n32 and n64 Andreas Färber
` (9 preceding siblings ...)
2011-12-29 15:55 ` [Qemu-devel] [PATCH 10/11] linux-user: mipsn32 does not support non-RT signals Andreas Färber
@ 2011-12-29 15:55 ` Andreas Färber
10 siblings, 0 replies; 12+ messages in thread
From: Andreas Färber @ 2011-12-29 15:55 UTC (permalink / raw)
To: qemu-devel
Cc: Riku Voipio, Khansa Butt, Andreas Färber, Richard Henderson
Mostly adapted from o32.
Linux no longer seems to have sf_code/rs_code for any of the ABIs.
It's u32 {sf,rt}_pad[2] /* Was: signal trampoline */ now...
Signed-off-by: Andreas Färber <afaerber@suse.de>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Khansa Butt <khansa@kics.edu.pk>
---
linux-user/signal.c | 104 +++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 100 insertions(+), 4 deletions(-)
diff --git a/linux-user/signal.c b/linux-user/signal.c
index b33f8cb..82ce4ac 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -2673,7 +2673,20 @@ long do_rt_sigreturn(CPUState *env)
#elif defined(TARGET_ABI_MIPSN32)
-# warning signal handling not implemented
+struct target_ucontext {
+ uint32_t tuc_flags;
+ int32_t tuc_link;
+ target_stack_t tuc_stack;
+ struct target_sigcontext tuc_mcontext;
+ target_sigset_t tuc_sigmask;
+};
+
+struct target_rt_sigframe {
+ uint32_t rs_ass[4]; /* argument save space for o32 */
+ uint32_t rs_pad[2]; /* Was: signal trampoline */
+ struct target_siginfo rs_info;
+ struct target_ucontext rs_uc;
+};
static void setup_frame(int sig, struct target_sigaction *ka,
target_sigset_t *set, CPUState *env)
@@ -2685,7 +2698,61 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,
target_siginfo_t *info,
target_sigset_t *set, CPUState *env)
{
- fprintf(stderr, "setup_rt_frame: not implemented\n");
+ struct target_rt_sigframe *frame;
+ abi_ulong frame_addr;
+ int i;
+
+ frame_addr = get_sigframe(ka, env, sizeof(*frame));
+ if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0))
+ goto give_sigsegv;
+
+ //install_sigtramp(frame->rs_pad, TARGET_NR_rt_sigreturn);
+
+ /* Create siginfo. */
+ copy_siginfo_to_user(&frame->rs_info, info);
+
+ /* Create the ucontext. */
+ __put_user(0, &frame->rs_uc.tuc_flags);
+ __put_user(0, &frame->rs_uc.tuc_link);
+ __put_user(target_sigaltstack_used.ss_sp, &frame->rs_uc.tuc_stack.ss_sp);
+ __put_user(target_sigaltstack_used.ss_size, &frame->rs_uc.tuc_stack.ss_size);
+ __put_user(sas_ss_flags(get_sp_from_cpustate(env)),
+ &frame->rs_uc.tuc_stack.ss_flags);
+
+ setup_sigcontext(env, &frame->rs_uc.tuc_mcontext);
+
+ for(i = 0; i < TARGET_NSIG_WORDS; i++) {
+ __put_user(set->sig[i], &frame->rs_uc.tuc_sigmask.sig[i]);
+ }
+
+ /*
+ * Arguments to signal handler:
+ *
+ * a0 = signal number
+ * a1 = pointer to struct siginfo
+ * a2 = pointer to struct ucontext
+ *
+ * $25 and PC point to the signal handler, $29 points to the
+ * struct sigframe.
+ */
+ env->active_tc.gpr[ 4] = sig;
+ env->active_tc.gpr[ 5] = frame_addr
+ + offsetof(struct target_rt_sigframe, rs_info);
+ env->active_tc.gpr[ 6] = frame_addr
+ + offsetof(struct target_rt_sigframe, rs_uc);
+ env->active_tc.gpr[29] = frame_addr;
+ //env->active_tc.gpr[31] = frame_addr
+ // + offsetof(struct target_rt_sigframe, rs_pad);
+ /* The original kernel code sets CP0_EPC to the handler
+ * since it returns to userland using eret
+ * we cannot do this here, and we must set PC directly */
+ env->active_tc.PC = env->active_tc.gpr[25] = ka->_sa_handler;
+ unlock_user_struct(frame, frame_addr, 1);
+ return;
+
+give_sigsegv:
+ unlock_user_struct(frame, frame_addr, 1);
+ force_sig(TARGET_SIGSEGV/*, current*/);
}
long do_sigreturn(CPUState *env)
@@ -2696,8 +2763,37 @@ long do_sigreturn(CPUState *env)
long do_rt_sigreturn(CPUState *env)
{
- fprintf(stderr, "do_rt_sigreturn: not implemented\n");
- return -TARGET_ENOSYS;
+ struct target_rt_sigframe *frame;
+ abi_ulong frame_addr;
+ sigset_t blocked;
+
+#if defined(DEBUG_SIGNAL)
+ fprintf(stderr, "do_rt_sigreturn\n");
+#endif
+ frame_addr = env->active_tc.gpr[29];
+ if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1))
+ goto badframe;
+
+ target_to_host_sigset(&blocked, &frame->rs_uc.tuc_sigmask);
+ sigprocmask(SIG_SETMASK, &blocked, NULL);
+
+ if (restore_sigcontext(env, &frame->rs_uc.tuc_mcontext))
+ goto badframe;
+
+ if (do_sigaltstack(frame_addr +
+ offsetof(struct target_rt_sigframe, rs_uc.tuc_stack),
+ 0, get_sp_from_cpustate(env)) == -EFAULT)
+ goto badframe;
+
+ env->active_tc.PC = env->CP0_EPC;
+ /* I am not sure this is right, but it seems to work
+ * maybe a problem with nested signals ? */
+ env->CP0_EPC = 0;
+ return -TARGET_QEMU_ESIGRETURN;
+
+badframe:
+ force_sig(TARGET_SIGSEGV/*, current*/);
+ return 0;
}
#elif defined(TARGET_ABI_MIPSO32)
--
1.7.7
^ permalink raw reply related [flat|nested] 12+ messages in thread
end of thread, other threads:[~2011-12-29 15:57 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-29 15:55 [Qemu-devel] [RFC 00/11] linux-user: Sort out signal handling for MIPS n32 and n64 Andreas Färber
2011-12-29 15:55 ` [Qemu-devel] [PATCH 01/11] linux-user: Add default-configs for mipsn32[el] Andreas Färber
2011-12-29 15:55 ` [Qemu-devel] [PATCH 02/11] linux-user: Add default configs for mips64[el] Andreas Färber
2011-12-29 15:55 ` [Qemu-devel] [PATCH 03/11] linux-user: Define TARGET_QEMU_ESIGRETURN for mipsn32 Andreas Färber
2011-12-29 15:55 ` [Qemu-devel] [PATCH 04/11] linux-user: Define TARGET_QEMU_ESIGRETURN for mips64 Andreas Färber
2011-12-29 15:55 ` [Qemu-devel] [PATCH 05/11] linux-user: Fix sa_flags byte swaps for mips Andreas Färber
2011-12-29 15:55 ` [Qemu-devel] [RFC 06/11] linux-user: Unify signal handling " Andreas Färber
2011-12-29 15:55 ` [Qemu-devel] [RFC 07/11] linux-user: target_sigcontext for mipsn32 and mips64 Andreas Färber
2011-12-29 15:55 ` [Qemu-devel] [RFC 08/11] linux-user: Share {setup, restore}_sigcontext() for mips ABIs Andreas Färber
2011-12-29 15:55 ` [Qemu-devel] [RFC 09/11] linux-user: Setup/restore sc_acx for mips and mipsn32 Andreas Färber
2011-12-29 15:55 ` [Qemu-devel] [PATCH 10/11] linux-user: mipsn32 does not support non-RT signals Andreas Färber
2011-12-29 15:55 ` [Qemu-devel] [RFC 11/11] linux-user: Implement signal handling for mipsn32 Andreas Färber
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).