[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL v3 03/22] linux-user: Fix syscall instruction usermod
From: |
riku . voipio |
Subject: |
[Qemu-devel] [PULL v3 03/22] linux-user: Fix syscall instruction usermode emulation on X86_64 |
Date: |
Fri, 22 Aug 2014 16:24:21 +0300 |
From: Jincheng Miao <address@hidden>
Currently syscall instruction is buggy on user mode X86_64,
the EIP is updated after do_syscall(), that is too late for
clone(). Because clone() will create a thread at the env->EIP
(the address of syscall insn), and then child thread enters
do_syscall() again, that is not expected. Sometimes it is tragic.
User mode syscall insn emulation is not used MSR, so the
action should be same to INT 0x80. INT 0x80 will update EIP in
do_interrupt(), ditto for syscall() for consistency.
Signed-off-by: Jincheng Miao <address@hidden>
Reviewed-by: Richard Henderson <address@hidden>
Signed-off-by: Riku Voipio <address@hidden>
---
linux-user/main.c | 1 -
target-i386/seg_helper.c | 4 ++--
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/linux-user/main.c b/linux-user/main.c
index b453a39..472a16d 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -309,7 +309,6 @@ void cpu_loop(CPUX86State *env)
env->regs[8],
env->regs[9],
0, 0);
- env->eip = env->exception_next_eip;
break;
#endif
case EXCP0B_NOSEG:
diff --git a/target-i386/seg_helper.c b/target-i386/seg_helper.c
index 2d970d0..13eefba 100644
--- a/target-i386/seg_helper.c
+++ b/target-i386/seg_helper.c
@@ -1127,8 +1127,8 @@ static void do_interrupt_user(CPUX86State *env, int
intno, int is_int,
/* Since we emulate only user space, we cannot do more than
exiting the emulation with the suitable exception and error
- code */
- if (is_int) {
+ code. So update EIP for INT 0x80 and EXCP_SYSCALL. */
+ if (is_int || intno == EXCP_SYSCALL) {
env->eip = next_eip;
}
}
--
2.0.1
- [Qemu-devel] [PULL v3 00/22] Linux-user updates, riku . voipio, 2014/08/22
- [Qemu-devel] [PULL v3 01/22] linux-user: /proc/self/maps content, riku . voipio, 2014/08/22
- [Qemu-devel] [PULL v3 07/22] linux-user: support ioprio_{get, set} syscalls, riku . voipio, 2014/08/22
- [Qemu-devel] [PULL v3 05/22] linux-user: fix readlink handling with magic exe symlink, riku . voipio, 2014/08/22
- [Qemu-devel] [PULL v3 06/22] linux-user: support timerfd_{create, gettime, settime} syscalls, riku . voipio, 2014/08/22
- [Qemu-devel] [PULL v3 08/22] linux-user: add setns and unshare, riku . voipio, 2014/08/22
- [Qemu-devel] [PULL v3 03/22] linux-user: Fix syscall instruction usermode emulation on X86_64,
riku . voipio <=
- [Qemu-devel] [PULL v3 02/22] linux-user: redirect openat calls, riku . voipio, 2014/08/22
- [Qemu-devel] [PULL v3 10/22] linux-user: Dereference Pointer Argument to ipc/semctl Sys Call, riku . voipio, 2014/08/22
- [Qemu-devel] [PULL v3 09/22] linux-user: PPC64 semid_ds Doesnt Include _unused1 and _unused2, riku . voipio, 2014/08/22
- [Qemu-devel] [PULL v3 04/22] linux-user: Fix conversion of sigevent argument to timer_create, riku . voipio, 2014/08/22
- [Qemu-devel] [PULL v3 12/22] linux-user: Make ipc syscall's third argument an abi_long, riku . voipio, 2014/08/22
- [Qemu-devel] [PULL v3 18/22] linux-user: Minimum Sig Handler Stack Size for PPC64 ELF V2, riku . voipio, 2014/08/22
- [Qemu-devel] [PULL v3 19/22] linux-user: clock_nanosleep errno Handling on PPC, riku . voipio, 2014/08/22
- [Qemu-devel] [PULL v3 16/22] linux-user: Detect fault in sched_rr_get_interval, riku . voipio, 2014/08/22
- [Qemu-devel] [PULL v3 22/22] linux-user: check return value of malloc(), riku . voipio, 2014/08/22
- [Qemu-devel] [PULL v3 15/22] linux-user: Handle NULL sched_param argument to sched_*, riku . voipio, 2014/08/22