[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 14/23] linux-user/mips: Implement setup_sigtramp
From: |
Richard Henderson |
Subject: |
[PATCH v2 14/23] linux-user/mips: Implement setup_sigtramp |
Date: |
Fri, 18 Jun 2021 12:29:42 -0700 |
Create and record the two signal trampolines.
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
linux-user/mips/target_signal.h | 1 +
linux-user/mips64/target_signal.h | 2 ++
linux-user/mips/signal.c | 34 ++++++++++++++++++++++---------
3 files changed, 27 insertions(+), 10 deletions(-)
diff --git a/linux-user/mips/target_signal.h b/linux-user/mips/target_signal.h
index d521765f6b..780a4ddf29 100644
--- a/linux-user/mips/target_signal.h
+++ b/linux-user/mips/target_signal.h
@@ -73,6 +73,7 @@ typedef struct target_sigaltstack {
/* compare linux/arch/mips/kernel/signal.c:setup_frame() */
#define TARGET_ARCH_HAS_SETUP_FRAME
#endif
+#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1
/* bit-flags */
#define TARGET_SS_AUTODISARM (1U << 31) /* disable sas during sighandling */
diff --git a/linux-user/mips64/target_signal.h
b/linux-user/mips64/target_signal.h
index d857c55e4c..275e9b7f9a 100644
--- a/linux-user/mips64/target_signal.h
+++ b/linux-user/mips64/target_signal.h
@@ -76,4 +76,6 @@ typedef struct target_sigaltstack {
/* compare linux/arch/mips/kernel/signal.c:setup_frame() */
#define TARGET_ARCH_HAS_SETUP_FRAME
#endif
+#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1
+
#endif /* MIPS64_TARGET_SIGNAL_H */
diff --git a/linux-user/mips/signal.c b/linux-user/mips/signal.c
index 7cad7526ea..a3db08bfec 100644
--- a/linux-user/mips/signal.c
+++ b/linux-user/mips/signal.c
@@ -208,8 +208,6 @@ void setup_frame(int sig, struct target_sigaction * ka,
goto give_sigsegv;
}
- install_sigtramp(frame->sf_code, TARGET_NR_sigreturn);
-
setup_sigcontext(regs, &frame->sf_sc);
for(i = 0; i < TARGET_NSIG_WORDS; i++) {
@@ -230,7 +228,7 @@ void setup_frame(int sig, struct target_sigaction * ka,
regs->active_tc.gpr[ 5] = 0;
regs->active_tc.gpr[ 6] = frame_addr + offsetof(struct sigframe, sf_sc);
regs->active_tc.gpr[29] = frame_addr;
- regs->active_tc.gpr[31] = frame_addr + offsetof(struct sigframe, sf_code);
+ regs->active_tc.gpr[31] = default_sigreturn;
/* 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 */
@@ -304,8 +302,6 @@ void setup_rt_frame(int sig, struct target_sigaction *ka,
goto give_sigsegv;
}
- install_sigtramp(frame->rs_code, TARGET_NR_rt_sigreturn);
-
tswap_siginfo(&frame->rs_info, info);
__put_user(0, &frame->rs_uc.tuc_flags);
@@ -334,11 +330,13 @@ void setup_rt_frame(int sig, struct target_sigaction *ka,
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_code);
- /* 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.gpr[31] = default_rt_sigreturn;
+
+ /*
+ * 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;
mips_set_hflags_isa_mode_from_pc(env);
unlock_user_struct(frame, frame_addr, 1);
@@ -378,3 +376,19 @@ badframe:
force_sig(TARGET_SIGSEGV);
return -TARGET_QEMU_ESIGRETURN;
}
+
+void setup_sigtramp(abi_ulong sigtramp_page)
+{
+ uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 2 * 8, 0);
+ assert(tramp != NULL);
+
+#ifdef TARGET_ARCH_HAS_SETUP_FRAME
+ default_sigreturn = sigtramp_page;
+ install_sigtramp(tramp, TARGET_NR_sigreturn);
+#endif
+
+ default_rt_sigreturn = sigtramp_page + 8;
+ install_sigtramp(tramp + 2, TARGET_NR_rt_sigreturn);
+
+ unlock_user(tramp, sigtramp_page, 2 * 8);
+}
--
2.25.1
- Re: [PATCH v2 13/23] linux-user/mips: Tidy install_sigtramp, (continued)
- [PATCH v2 12/23] linux-user/microblaze: Implement setup_sigtramp, Richard Henderson, 2021/06/18
- [PATCH v2 16/23] linux-user/openrisc: Implement setup_sigtramp, Richard Henderson, 2021/06/18
- [PATCH v2 20/23] linux-user/sh4: Implement setup_sigtramp, Richard Henderson, 2021/06/18
- [PATCH v2 14/23] linux-user/mips: Implement setup_sigtramp,
Richard Henderson <=
- [PATCH v2 11/23] linux-user/m68k: Implement setup_sigtramp, Richard Henderson, 2021/06/18
- [PATCH v2 10/23] linux-user/i386: Implement setup_sigtramp, Richard Henderson, 2021/06/18
- [PATCH v2 17/23] linux-user/ppc: Implement setup_sigtramp, Richard Henderson, 2021/06/18
- [PATCH v2 21/23] linux-user/sparc: Implement setup_sigtramp, Richard Henderson, 2021/06/18
- [PATCH v2 23/23] linux-user: Remove default for TARGET_ARCH_HAS_SIGTRAMP_PAGE, Richard Henderson, 2021/06/18
- [PATCH v2 19/23] linux-user/s390x: Implement setup_sigtramp, Richard Henderson, 2021/06/18
- [PATCH v2 15/23] linux-user/nios2: Document non-use of setup_sigtramp, Richard Henderson, 2021/06/18