aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Vivier <laurent@vivier.eu>2015-11-23 11:38:26 +0100
committerRiku Voipio <riku.voipio@linaro.org>2016-01-08 15:24:57 +0200
commit2a0fa68fb9761e2eb3dae4034131948d33018dc9 (patch)
treebc45e914b06f678d92bc879c890005c8da5caa04
parent861d72cd28b5793fc367c46b7821a5372b66e3f4 (diff)
linux-user,sh4: fix signal retcode address
To return from a signal, setup_frame() puts an instruction to be executed in the stack. This sequence calls the syscall sigreturn(). The address of the instruction must be set in the PR register to be executed. This patch fixes this: the current code sets the register to the address of the instruction in the host address space (which can be 64bit whereas PR is only 32bit), but the virtual CPU can't access this address space, so we put in PR the address of the instruction in the guest address space. This patch also removes an useless variable (ret) in the modified functions. Signed-off-by: Laurent Vivier <laurent@vivier.eu> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
-rw-r--r--linux-user/signal.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/linux-user/signal.c b/linux-user/signal.c
index 919aa836fa..d4d83f247a 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -3210,7 +3210,6 @@ static void setup_frame(int sig, struct target_sigaction *ka,
struct target_sigframe *frame;
abi_ulong frame_addr;
int i;
- int err = 0;
frame_addr = get_sigframe(ka, regs->gregs[15], sizeof(*frame));
trace_user_setup_frame(regs, frame_addr);
@@ -3229,15 +3228,14 @@ static void setup_frame(int sig, struct target_sigaction *ka,
regs->pr = (unsigned long) ka->sa_restorer;
} else {
/* Generate return code (system call to sigreturn) */
+ abi_ulong retcode_addr = frame_addr +
+ offsetof(struct target_sigframe, retcode);
__put_user(MOVW(2), &frame->retcode[0]);
__put_user(TRAP_NOARG, &frame->retcode[1]);
__put_user((TARGET_NR_sigreturn), &frame->retcode[2]);
- regs->pr = (unsigned long) frame->retcode;
+ regs->pr = (unsigned long) retcode_addr;
}
- if (err)
- goto give_sigsegv;
-
/* Set up registers for signal handler */
regs->gregs[15] = frame_addr;
regs->gregs[4] = sig; /* Arg for signal handler */
@@ -3260,7 +3258,6 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,
struct target_rt_sigframe *frame;
abi_ulong frame_addr;
int i;
- int err = 0;
frame_addr = get_sigframe(ka, regs->gregs[15], sizeof(*frame));
trace_user_setup_rt_frame(regs, frame_addr);
@@ -3290,15 +3287,14 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,
regs->pr = (unsigned long) ka->sa_restorer;
} else {
/* Generate return code (system call to sigreturn) */
+ abi_ulong retcode_addr = frame_addr +
+ offsetof(struct target_rt_sigframe, retcode);
__put_user(MOVW(2), &frame->retcode[0]);
__put_user(TRAP_NOARG, &frame->retcode[1]);
__put_user((TARGET_NR_rt_sigreturn), &frame->retcode[2]);
- regs->pr = (unsigned long) frame->retcode;
+ regs->pr = (unsigned long) retcode_addr;
}
- if (err)
- goto give_sigsegv;
-
/* Set up registers for signal handler */
regs->gregs[15] = frame_addr;
regs->gregs[4] = sig; /* Arg for signal handler */