[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 02/25] linux-user/aarch64: Implement setup_sigtramp
From: |
Richard Henderson |
Subject: |
[PATCH v4 02/25] linux-user/aarch64: Implement setup_sigtramp |
Date: |
Mon, 27 Sep 2021 22:00:16 -0400 |
Create and record the rt signal trampoline.
Use it when the guest does not use SA_RESTORER.
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
linux-user/aarch64/target_signal.h | 2 ++
linux-user/aarch64/signal.c | 34 ++++++++++++++++++------------
2 files changed, 23 insertions(+), 13 deletions(-)
diff --git a/linux-user/aarch64/target_signal.h
b/linux-user/aarch64/target_signal.h
index 18013e1b23..7580d99403 100644
--- a/linux-user/aarch64/target_signal.h
+++ b/linux-user/aarch64/target_signal.h
@@ -25,4 +25,6 @@ typedef struct target_sigaltstack {
#define TARGET_SEGV_MTESERR 9 /* Synchronous ARM MTE exception */
#define TARGET_ARCH_HAS_SETUP_FRAME
+#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1
+
#endif /* AARCH64_TARGET_SIGNAL_H */
diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c
index 49025648cb..29c52db3f1 100644
--- a/linux-user/aarch64/signal.c
+++ b/linux-user/aarch64/signal.c
@@ -109,7 +109,6 @@ struct target_rt_sigframe {
struct target_rt_frame_record {
uint64_t fp;
uint64_t lr;
- uint32_t tramp[2];
};
static void target_setup_general_frame(struct target_rt_sigframe *sf,
@@ -461,9 +460,9 @@ static void target_setup_frame(int usig, struct
target_sigaction *ka,
layout.total_size = MAX(layout.total_size,
sizeof(struct target_rt_sigframe));
- /* Reserve space for the return code. On a real system this would
- * be within the VDSO. So, despite the name this is not a "real"
- * record within the frame.
+ /*
+ * Reserve space for the standard frame unwind pair: fp, lr.
+ * Despite the name this is not a "real" record within the frame.
*/
fr_ofs = layout.total_size;
layout.total_size += sizeof(struct target_rt_frame_record);
@@ -496,15 +495,7 @@ static void target_setup_frame(int usig, struct
target_sigaction *ka,
if (ka->sa_flags & TARGET_SA_RESTORER) {
return_addr = ka->sa_restorer;
} else {
- /*
- * mov x8,#__NR_rt_sigreturn; svc #0
- * Since these are instructions they need to be put as little-endian
- * regardless of target default or current CPU endianness.
- */
- __put_user_e(0xd2801168, &fr->tramp[0], le);
- __put_user_e(0xd4000001, &fr->tramp[1], le);
- return_addr = frame_addr + fr_ofs
- + offsetof(struct target_rt_frame_record, tramp);
+ return_addr = default_rt_sigreturn;
}
env->xregs[0] = usig;
env->xregs[29] = frame_addr + fr_ofs;
@@ -577,3 +568,20 @@ long do_sigreturn(CPUARMState *env)
{
return do_rt_sigreturn(env);
}
+
+void setup_sigtramp(abi_ulong sigtramp_page)
+{
+ uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 8, 0);
+ assert(tramp != NULL);
+
+ /*
+ * mov x8,#__NR_rt_sigreturn; svc #0
+ * Since these are instructions they need to be put as little-endian
+ * regardless of target default or current CPU endianness.
+ */
+ __put_user_e(0xd2801168, &tramp[0], le);
+ __put_user_e(0xd4000001, &tramp[1], le);
+
+ default_rt_sigreturn = sigtramp_page;
+ unlock_user(tramp, sigtramp_page, 8);
+}
--
2.25.1
- [PATCH v4 00/25] linux-user: Move signal trampolines to new page, Richard Henderson, 2021/09/27
- [PATCH v4 06/25] linux-user/alpha: Implement setup_sigtramp, Richard Henderson, 2021/09/27
- [PATCH v4 03/25] linux-user/arm: Drop v1 signal frames, Richard Henderson, 2021/09/27
- [PATCH v4 05/25] linux-user/arm: Implement setup_sigtramp, Richard Henderson, 2021/09/27
- [PATCH v4 02/25] linux-user/aarch64: Implement setup_sigtramp,
Richard Henderson <=
- [PATCH v4 01/25] linux-user: Add infrastructure for a signal trampoline page, Richard Henderson, 2021/09/27
- [PATCH v4 11/25] linux-user/x86_64: Raise SIGSEGV if SA_RESTORER not set, Richard Henderson, 2021/09/27
- [PATCH v4 10/25] linux-user/i386: Implement setup_sigtramp, Richard Henderson, 2021/09/27
- [PATCH v4 14/25] linux-user/mips: Tidy install_sigtramp, Richard Henderson, 2021/09/27
- [PATCH v4 12/25] linux-user/m68k: Implement setup_sigtramp, Richard Henderson, 2021/09/27
- [PATCH v4 16/25] linux-user/nios2: Document non-use of setup_sigtramp, Richard Henderson, 2021/09/27
- [PATCH v4 18/25] linux-user/ppc: Simplify encode_trampoline, Richard Henderson, 2021/09/27
- [PATCH v4 07/25] linux-user/cris: Implement setup_sigtramp, Richard Henderson, 2021/09/27