From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42790) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XH6Q9-0005NW-OZ for qemu-devel@nongnu.org; Tue, 12 Aug 2014 03:23:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XH6Q3-0006pB-JP for qemu-devel@nongnu.org; Tue, 12 Aug 2014 03:23:01 -0400 Received: from afflict.kos.to ([92.243.29.197]:55187) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XH6Q3-0006op-CK for qemu-devel@nongnu.org; Tue, 12 Aug 2014 03:22:55 -0400 Date: Tue, 12 Aug 2014 10:22:53 +0300 From: Riku Voipio Message-ID: <20140812072253.GA5555@afflict.kos.to> References: <1407470214-10792-1-git-send-email-jmiao@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1407470214-10792-1-git-send-email-jmiao@redhat.com> Subject: Re: [Qemu-devel] [PATCH] linux-user: Fix syscall instruction usermode emulation on X86_64 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jincheng Miao Cc: peter.maydell@linaro.org, riku.voipio@iki.fi, qemu-devel@nongnu.org, rth@twiddle.net On Fri, Aug 08, 2014 at 11:56:54AM +0800, Jincheng Miao wrote: > 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. Thanks applied to linux-user tree for next pull request. Riku > Signed-off-by: Jincheng Miao > --- > 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; > } > } > -- > 1.7.1 >