[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 10/17] linux-user, sh4: fix signal retcode address
From: |
riku . voipio |
Subject: |
[Qemu-devel] [PULL 10/17] linux-user, sh4: fix signal retcode address |
Date: |
Mon, 11 Jan 2016 16:16:12 +0200 |
From: Laurent Vivier <address@hidden>
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 <address@hidden>
Signed-off-by: Riku Voipio <address@hidden>
---
linux-user/signal.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/linux-user/signal.c b/linux-user/signal.c
index 919aa83..d4d83f2 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 */
--
2.6.4
- [Qemu-devel] [PULL 04/17] linux-user/syscall.c: malloc()/calloc() to g_malloc()/g_try_malloc()/g_new0(), (continued)
- [Qemu-devel] [PULL 04/17] linux-user/syscall.c: malloc()/calloc() to g_malloc()/g_try_malloc()/g_new0(), riku . voipio, 2016/01/11
- [Qemu-devel] [PULL 05/17] linux-user: SOCK_PACKET uses network endian to encode protocol in socket(), riku . voipio, 2016/01/11
- [Qemu-devel] [PULL 03/17] linux-user: in poll(), if nfds is 0, pfd can be NULL, riku . voipio, 2016/01/11
- [Qemu-devel] [PULL 02/17] linux-user: correctly align target_epoll_event, riku . voipio, 2016/01/11
- [Qemu-devel] [PULL 08/17] linux-user: manage bind with a socket of SOCK_PACKET type., riku . voipio, 2016/01/11
- [Qemu-devel] [PULL 17/17] linux-user/mmap.c: Use end instead of real_end in target_mmap, riku . voipio, 2016/01/11
- [Qemu-devel] [PULL 11/17] linux-user/mmap.c: Always zero MAP_ANONYMOUS memory in mmap_frag(), riku . voipio, 2016/01/11
- [Qemu-devel] [PULL 07/17] linux-user: add a function hook to translate sockaddr, riku . voipio, 2016/01/11
- [Qemu-devel] [PULL 14/17] linux-user/syscall.c: Use SOL_SOCKET instead of level for setsockopt(), riku . voipio, 2016/01/11
- [Qemu-devel] [PULL 15/17] linux-user: Update m68k syscall definitions to match Linux 4.4., riku . voipio, 2016/01/11
- [Qemu-devel] [PULL 10/17] linux-user, sh4: fix signal retcode address,
riku . voipio <=
- [Qemu-devel] [PULL 09/17] linux-user: check fd is >= 0 in fd_trans_host_to_target_data/fd_trans_host_to_target_addr, riku . voipio, 2016/01/11
- [Qemu-devel] [PULL 13/17] linux-user: enable sigaltstack for all architectures, riku . voipio, 2016/01/11
- [Qemu-devel] [PULL 12/17] unicore32: convert get_sp_from_cpustate from macro to inline, riku . voipio, 2016/01/11
- [Qemu-devel] [PULL 16/17] linux-user: Add SOCKOP_sendmmsg and SOCKOP_recvmmsg socket call, wire them up., riku . voipio, 2016/01/11
- Re: [Qemu-devel] [PULL 00/17] linux-user queque, Peter Maydell, 2016/01/11