[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 24/36] linux-user/m68k: Implement setup_sigtramp
From: |
Richard Henderson |
Subject: |
[PATCH v2 24/36] linux-user/m68k: Implement setup_sigtramp |
Date: |
Tue, 6 Jul 2021 16:49:20 -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/m68k/target_signal.h | 2 ++
linux-user/m68k/signal.c | 47 +++++++++++++++------------------
2 files changed, 24 insertions(+), 25 deletions(-)
diff --git a/linux-user/m68k/target_signal.h b/linux-user/m68k/target_signal.h
index d096544ef8..94157bf1f4 100644
--- a/linux-user/m68k/target_signal.h
+++ b/linux-user/m68k/target_signal.h
@@ -22,4 +22,6 @@ typedef struct target_sigaltstack {
#include "../generic/signal.h"
#define TARGET_ARCH_HAS_SETUP_FRAME
+#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1
+
#endif /* M68K_TARGET_SIGNAL_H */
diff --git a/linux-user/m68k/signal.c b/linux-user/m68k/signal.c
index d06230655e..b4fade1ed6 100644
--- a/linux-user/m68k/signal.c
+++ b/linux-user/m68k/signal.c
@@ -38,7 +38,6 @@ struct target_sigframe
int sig;
int code;
abi_ulong psc;
- char retcode[8];
abi_ulong extramask[TARGET_NSIG_WORDS-1];
struct target_sigcontext sc;
};
@@ -75,7 +74,6 @@ struct target_rt_sigframe
int sig;
abi_ulong pinfo;
abi_ulong puc;
- char retcode[8];
struct target_siginfo info;
struct target_ucontext uc;
};
@@ -129,7 +127,6 @@ void setup_frame(int sig, struct target_sigaction *ka,
{
struct target_sigframe *frame;
abi_ulong frame_addr;
- abi_ulong retcode_addr;
abi_ulong sc_addr;
int i;
@@ -151,16 +148,7 @@ void setup_frame(int sig, struct target_sigaction *ka,
}
/* Set up to return from userspace. */
-
- retcode_addr = frame_addr + offsetof(struct target_sigframe, retcode);
- __put_user(retcode_addr, &frame->pretcode);
-
- /* moveq #,d0; trap #0 */
-
- __put_user(0x70004e40 + (TARGET_NR_sigreturn << 16),
- (uint32_t *)(frame->retcode));
-
- /* Set up to return from userspace */
+ __put_user(default_sigreturn, &frame->pretcode);
env->aregs[7] = frame_addr;
env->pc = ka->_sa_handler;
@@ -287,7 +275,6 @@ void setup_rt_frame(int sig, struct target_sigaction *ka,
{
struct target_rt_sigframe *frame;
abi_ulong frame_addr;
- abi_ulong retcode_addr;
abi_ulong info_addr;
abi_ulong uc_addr;
int err = 0;
@@ -324,17 +311,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka,
}
/* Set up to return from userspace. */
-
- retcode_addr = frame_addr + offsetof(struct target_sigframe, retcode);
- __put_user(retcode_addr, &frame->pretcode);
-
- /* moveq #,d0; notb d0; trap #0 */
-
- __put_user(0x70004600 + ((TARGET_NR_rt_sigreturn ^ 0xff) << 16),
- (uint32_t *)(frame->retcode + 0));
- __put_user(0x4e40, (uint16_t *)(frame->retcode + 4));
-
- /* Set up to return from userspace */
+ __put_user(default_rt_sigreturn, &frame->pretcode);
env->aregs[7] = frame_addr;
env->pc = ka->_sa_handler;
@@ -410,3 +387,23 @@ badframe:
force_sig(TARGET_SIGSEGV);
return -TARGET_QEMU_ESIGRETURN;
}
+
+void setup_sigtramp(abi_ulong sigtramp_page)
+{
+ void *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 4 + 6, 0);
+ assert(tramp != NULL);
+
+ default_sigreturn = sigtramp_page;
+
+ /* moveq #,d0; trap #0 */
+ __put_user(0x70004e40 + (TARGET_NR_sigreturn << 16), (uint32_t *)tramp);
+
+ default_rt_sigreturn = sigtramp_page + 4;
+
+ /* moveq #,d0; notb d0; trap #0 */
+ __put_user(0x70004600 + ((TARGET_NR_rt_sigreturn ^ 0xff) << 16),
+ (uint32_t *)(tramp + 4));
+ __put_user(0x4e40, (uint16_t *)(tramp + 8));
+
+ unlock_user(tramp, sigtramp_page, 4 + 6);
+}
--
2.25.1
- [PATCH v2 20/36] linux-user/hppa: Add vdso and use it for rt_sigreturn, (continued)
- [PATCH v2 20/36] linux-user/hppa: Add vdso and use it for rt_sigreturn, Richard Henderson, 2021/07/06
- [PATCH v2 21/36] linux-user/x86_64: Raise SIGSEGV if SA_RESTORER not set, Richard Henderson, 2021/07/06
- [PATCH v2 23/36] linux-user/x86_64: Add vdso, Richard Henderson, 2021/07/06
- [PATCH v2 22/36] linux-user/i386: Add vdso and use it for sigreturn, Richard Henderson, 2021/07/06
- [PATCH v2 28/36] linux-user/nios2: Document non-use of setup_sigtramp, Richard Henderson, 2021/07/06
- [PATCH v2 25/36] linux-user/microblaze: Implement setup_sigtramp, Richard Henderson, 2021/07/06
- [PATCH v2 29/36] linux-user/openrisc: Implement setup_sigtramp, Richard Henderson, 2021/07/06
- [PATCH v2 27/36] linux-user/mips: Implement setup_sigtramp, Richard Henderson, 2021/07/06
- [PATCH v2 26/36] linux-user/mips: Tidy install_sigtramp, Richard Henderson, 2021/07/06
- [PATCH v2 24/36] linux-user/m68k: Implement setup_sigtramp,
Richard Henderson <=
- [PATCH v2 30/36] target/ppc: Simplify encode_trampoline, Richard Henderson, 2021/07/06
- [PATCH v2 31/36] linux-user/ppc: Implement setup_sigtramp, Richard Henderson, 2021/07/06
- [PATCH v2 33/36] linux-user/s390x: Implement setup_sigtramp, Richard Henderson, 2021/07/06
- [PATCH v2 32/36] linux-user/riscv: Add vdso and use it for sigreturn, Richard Henderson, 2021/07/06
- [PATCH v2 34/36] linux-user/sh4: Implement setup_sigtramp, Richard Henderson, 2021/07/06
- [PATCH v2 35/36] linux-user/sparc: Implement setup_sigtramp, Richard Henderson, 2021/07/06
- [PATCH v2 36/36] linux-user/xtensa: Implement setup_sigtramp, Richard Henderson, 2021/07/06
- Re: [PATCH v2 00/36] linux-user: Signal trampolines and vdsos, Philippe Mathieu-Daudé, 2021/07/08