Skip to contentSkip to conversation

linux-user: Sort out signal handling for MIPS n32 and n64

RFC New Andreas Färber 1 participant 12 messages Dec 29, 2011

lore
Share & tools
lore
#1 lore raw

PATCH 1/11 linux-user: Add default-configs for mipsn32[el]

In reply to Andreas Färber

Prepares for mipsn32[el]-linux-user targets.

---
 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
default-configs/mipsn32-linux-user.mak new file +1 -0
new file mode 100644
index 0000000..5b97919
@@ -0,0 +1 @@
+# Default configuration for mipsn32-linux-user
default-configs/mipsn32el-linux-user.mak new file +1 -0
new file mode 100644
index 0000000..d6367ff
@@ -0,0 +1 @@
+# Default configuration for mipsn32el-linux-user
Signature · 1 line
1.7.7
#4 lore raw

PATCH 4/11 linux-user: Define TARGET_QEMU_ESIGRETURN for mips64

In reply to Andreas Färber

Copied from mips/syscall.h.

---
 linux-user/mips64/syscall.h |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
linux-user/mips64/syscall.h +3 -0
index 668a2b9..e436ea5 100644
@@ -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"
Signature · 1 line
1.7.7
#6 lore raw

RFC 6/11 linux-user: Unify signal handling for mips

In reply to Andreas Färber

As suggested by Richard.

Cc Richard Henderson <[email protected]>
Cc Khansa Butt <[email protected]>
---
 linux-user/signal.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
linux-user/signal.c +3 -1
index bafbc57..394984d 100644
@@ -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)
 
 /*
Signature · 1 line
1.7.7
#5 lore raw

PATCH 5/11 linux-user: Fix sa_flags byte swaps for mips

In reply to Andreas Färber

sa_flags is uint32_t for mips{,n32,64}, so don't use tswapal().

---
 linux-user/signal.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
linux-user/signal.c +8 -0
index ded12ca..bafbc57 100644
@@ -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
Signature · 1 line
1.7.7
#7 lore raw

RFC 7/11 linux-user: target_sigcontext for mipsn32 and mips64

In reply to Andreas Färber

Based on arch/mips/include/asm/sigcontext.h.

Cc Richard Henderson <[email protected]>
Cc Khansa Butt <[email protected]>
---
 linux-user/signal.c |   64 ++++++++++++++++++++++++++++++++++----------------
 1 files changed, 43 insertions(+), 21 deletions(-)
linux-user/signal.c +43 -21
index 394984d..6eeafcf 100644
@@ -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 */
Signature · 1 line
1.7.7
#10 lore raw

PATCH 10/11 linux-user: mipsn32 does not support non-RT signals

In reply to Andreas Färber
---
 linux-user/signal.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
linux-user/signal.c +2 -2
index bd13f9b..b33f8cb 100644
@@ -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;
 }
 
Signature · 1 line
1.7.7
#11 lore raw

RFC 11/11 linux-user: Implement signal handling for mipsn32

In reply to Andreas Färber

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...

Cc Richard Henderson <[email protected]>
Cc Khansa Butt <[email protected]>
---
 linux-user/signal.c |  104 +++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 100 insertions(+), 4 deletions(-)
linux-user/signal.c +100 -4
index b33f8cb..82ce4ac 100644
@@ -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)
Signature · 1 line
1.7.7
#0 lore raw

cover linux-user: Sort out signal handling for MIPS n32 and n64

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 <[email protected]>
Cc Aurelien Jarno <[email protected]>
Cc Richard Henderson <[email protected]>
Cc Khansa Butt <[email protected]>
Cc Ehsan Ul Haq <[email protected]>
Cc Ulrich Hecht <[email protected]>
Cc Brendan Kirby <[email protected]>
Cc Peter Maydell <[email protected]>
Cc Alexander Graf <[email protected]>

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
Signature · 1 line
1.7.7
#2 lore raw

PATCH 2/11 linux-user: Add default configs for mips64[el]

Prepares for mips64[el]-linux-user targets.

---
 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
default-configs/mips64-linux-user.mak new file +1 -0
new file mode 100644
index 0000000..1598bfc
@@ -0,0 +1 @@
+# Default configuration for mips64-linux-user
default-configs/mips64el-linux-user.mak new file +1 -0
new file mode 100644
index 0000000..629f084
@@ -0,0 +1 @@
+# Default configuration for mips64el-linux-user
Signature · 1 line
1.7.7
#3 lore raw

PATCH 3/11 linux-user: Define TARGET_QEMU_ESIGRETURN for mipsn32

In reply to Andreas Färber

Copied from mips/syscall.h.

---
 linux-user/mipsn32/syscall.h |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
linux-user/mipsn32/syscall.h +3 -0
index 4ec506c..ebe98f2 100644
@@ -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"
Signature · 1 line
1.7.7
#8 lore raw

RFC 8/11 linux-user: Share {setup, restore}_sigcontext() for mips ABIs

In reply to Andreas Färber

Shared for n32/n64 in arch/mips/kernel/signal.c; o32 version in arch/mips/kernel/signal32.c.

Cc Richard Henderson <[email protected]>
Cc Khansa Butt <[email protected]>
---
 linux-user/signal.c |  204 +++++++++++++++++++++++++-------------------------
 1 files changed, 102 insertions(+), 102 deletions(-)
linux-user/signal.c +102 -102
index 6eeafcf..a713cb2 100644
@@ -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)
Signature · 1 line
1.7.7
#9 lore raw

RFC 9/11 linux-user: Setup/restore sc_acx for mips and mipsn32

In reply to Andreas Färber
Cc Richard Henderson <[email protected]>
---
 linux-user/signal.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
linux-user/signal.c +6 -0
index a713cb2..bd13f9b 100644
@@ -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);
 
Signature · 1 line
1.7.7