@@ -26,4 +26,6 @@ typedef struct target_sigaltstack {
#include "../generic/signal.h"
+#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1
+
#endif /* OPENRISC_TARGET_SIGNAL_H */
@@ -38,7 +38,6 @@ typedef struct target_ucontext {
typedef struct target_rt_sigframe {
struct target_siginfo info;
target_ucontext uc;
- uint32_t retcode[4]; /* trampoline code */
} target_rt_sigframe;
static void restore_sigcontext(CPUOpenRISCState *env, target_sigcontext *sc)
@@ -116,14 +115,8 @@ void setup_rt_frame(int sig, struct target_sigaction *ka,
__put_user(set->sig[i], &frame->uc.tuc_sigmask.sig[i]);
}
- /* This is l.ori r11,r0,__NR_sigreturn; l.sys 1; l.nop; l.nop */
- __put_user(0xa9600000 | TARGET_NR_rt_sigreturn, frame->retcode + 0);
- __put_user(0x20000001, frame->retcode + 1);
- __put_user(0x15000000, frame->retcode + 2);
- __put_user(0x15000000, frame->retcode + 3);
-
/* Set up registers for signal handler */
- cpu_set_gpr(env, 9, frame_addr + offsetof(target_rt_sigframe, retcode));
+ cpu_set_gpr(env, 9, default_rt_sigreturn);
cpu_set_gpr(env, 3, sig);
cpu_set_gpr(env, 4, frame_addr + offsetof(target_rt_sigframe, info));
cpu_set_gpr(env, 5, frame_addr + offsetof(target_rt_sigframe, uc));
@@ -169,3 +162,16 @@ long do_rt_sigreturn(CPUOpenRISCState *env)
force_sig(TARGET_SIGSEGV);
return 0;
}
+
+void setup_sigtramp(abi_ulong sigtramp_page)
+{
+ uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 8, 0);
+ assert(tramp != NULL);
+
+ /* This is l.ori r11,r0,__NR_sigreturn; l.sys 1 */
+ __put_user(0xa9600000 | TARGET_NR_rt_sigreturn, tramp + 0);
+ __put_user(0x20000001, tramp + 1);
+
+ default_rt_sigreturn = sigtramp_page;
+ unlock_user(tramp, sigtramp_page, 8);
+}