@@ -69,6 +69,10 @@ typedef struct target_sigaltstack {
#ifdef TARGET_ABI32
#define TARGET_ARCH_HAS_SETUP_FRAME
+#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1
+#else
+/* For sparc64, use of KA_RESTORER is mandatory. */
+#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 0
#endif
/* bit-flags */
@@ -290,13 +290,7 @@ void setup_frame(int sig, struct target_sigaction *ka,
if (ka->ka_restorer) {
env->regwptr[WREG_O7] = ka->ka_restorer;
} else {
- env->regwptr[WREG_O7] = sf_addr +
- offsetof(struct target_signal_frame, insns) - 2 * 4;
-
- /* mov __NR_sigreturn, %g1 */
- __put_user(0x821020d8u, &sf->insns[0]);
- /* t 0x10 */
- __put_user(0x91d02010u, &sf->insns[1]);
+ env->regwptr[WREG_O7] = default_sigreturn;
}
unlock_user(sf, sf_addr, sf_size);
}
@@ -357,13 +351,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka,
if (ka->ka_restorer) {
env->regwptr[WREG_O7] = ka->ka_restorer;
} else {
- env->regwptr[WREG_O7] =
- sf_addr + offsetof(struct target_rt_signal_frame, insns) - 2 * 4;
-
- /* mov __NR_rt_sigreturn, %g1 */
- __put_user(0x82102065u, &sf->insns[0]);
- /* t 0x10 */
- __put_user(0x91d02010u, &sf->insns[1]);
+ env->regwptr[WREG_O7] = default_rt_sigreturn;
}
#else
env->regwptr[WREG_O7] = ka->ka_restorer;
@@ -774,4 +762,20 @@ do_sigsegv:
unlock_user_struct(ucp, ucp_addr, 1);
force_sig(TARGET_SIGSEGV);
}
+#else
+void setup_sigtramp(abi_ulong sigtramp_page)
+{
+ uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 2 * 8, 0);
+ assert(tramp != NULL);
+
+ default_sigreturn = sigtramp_page;
+ __put_user(0x821020d8u, &tramp[0]); /* mov __NR_sigreturn, %g1 */
+ __put_user(0x91d02010u, &tramp[1]); /* t 0x10 */
+
+ default_rt_sigreturn = sigtramp_page + 8;
+ __put_user(0x82102065u, &tramp[2]); /* mov __NR_rt_sigreturn, %g1 */
+ __put_user(0x91d02010u, &tramp[3]); /* t 0x10 */
+
+ unlock_user(tramp, sigtramp_page, 2 * 8);
+}
#endif
Create and record the two signal trampolines. Use them when the guest does not use SA_RESTORER. Cc: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> --- linux-user/sparc/target_signal.h | 4 ++++ linux-user/sparc/signal.c | 32 ++++++++++++++++++-------------- 2 files changed, 22 insertions(+), 14 deletions(-) -- 2.25.1