From patchwork Tue Aug 19 08:32:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 35552 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oi0-f71.google.com (mail-oi0-f71.google.com [209.85.218.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id DB7492136C for ; Tue, 19 Aug 2014 08:34:56 +0000 (UTC) Received: by mail-oi0-f71.google.com with SMTP id e131sf35903185oig.10 for ; Tue, 19 Aug 2014 01:34:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=HdDeoYzTuxb9ZurSV8BR3T1v53LvPbFNdyxxjGOy3Oo=; b=Pmcha8B3Z8kvC1hVFrnjGj1uuRMU8Ghd9houKYBAxp9iqE2w3mnpdFDvSx/VjjS5RT uNunMHm4wPYAe4R8WyX8yO6VmKYYUjDf+IeFGTC+88faGXswlCZmcX244yFDSJF4RdZM t8mCEXmIybDgWdhc78zG2ILDNTq3k6c9/gw4CAHxf0Ro9Ppem9C6lMf0aGbpNM6y6gsT qzWMzkrD+Z+gjqJ1iSoVztaMZGlct9+2FNbSzL/dVLcpcPqoYJwl0f/hBm0hNuFSEzy+ 60QQmdi/T67kjw/RedeYLk6kBU2VyeE+Cc2dO/fiw9U9HB8T+UpwaBlgrgKmid8c5i+9 IAGg== X-Gm-Message-State: ALoCoQmfGyPKEVFMbAVaLmH1ALnOX4J0KeXfu/w9Me32LK+wfz4MEIA7Pg225yyJcV5j2zOsAuV0 X-Received: by 10.43.64.202 with SMTP id xj10mr21783443icb.0.1408437296384; Tue, 19 Aug 2014 01:34:56 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.47.242 with SMTP id m105ls2670067qga.84.gmail; Tue, 19 Aug 2014 01:34:56 -0700 (PDT) X-Received: by 10.52.239.108 with SMTP id vr12mr2144241vdc.30.1408437296270; Tue, 19 Aug 2014 01:34:56 -0700 (PDT) Received: from mail-vc0-f179.google.com (mail-vc0-f179.google.com [209.85.220.179]) by mx.google.com with ESMTPS id i4si8334683vdg.41.2014.08.19.01.34.56 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 19 Aug 2014 01:34:56 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.179 as permitted sender) client-ip=209.85.220.179; Received: by mail-vc0-f179.google.com with SMTP id hq11so7024047vcb.38 for ; Tue, 19 Aug 2014 01:34:56 -0700 (PDT) X-Received: by 10.52.142.102 with SMTP id rv6mr4395246vdb.26.1408437296155; Tue, 19 Aug 2014 01:34:56 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp220222vcb; Tue, 19 Aug 2014 01:34:55 -0700 (PDT) X-Received: by 10.140.32.134 with SMTP id h6mr61828309qgh.49.1408437295294; Tue, 19 Aug 2014 01:34:55 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id q20si28012083qac.7.2014.08.19.01.34.55 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 19 Aug 2014 01:34:55 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:49073 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XJesY-0003BT-Sf for patch@linaro.org; Tue, 19 Aug 2014 04:34:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57296) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XJeqq-0000wI-5C for qemu-devel@nongnu.org; Tue, 19 Aug 2014 04:33:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XJeqk-0001YT-Mz for qemu-devel@nongnu.org; Tue, 19 Aug 2014 04:33:08 -0400 Received: from afflict.kos.to ([92.243.29.197]:35145) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XJeqk-0001Xx-HW for qemu-devel@nongnu.org; Tue, 19 Aug 2014 04:33:02 -0400 Received: from afflict.kos.to (afflict [92.243.29.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by afflict.kos.to (Postfix) with ESMTPSA id 69BBA26581; Tue, 19 Aug 2014 10:33:01 +0200 (CEST) From: riku.voipio@linaro.org To: Peter Maydell , qemu-devel@nongnu.org Date: Tue, 19 Aug 2014 11:32:38 +0300 Message-Id: <82ab62e758cc310bc616e13487120090947375b9.1408436940.git.riku.voipio@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 92.243.29.197 Cc: Jincheng Miao Subject: [Qemu-devel] [PULL v2 03/23] linux-user: Fix syscall instruction usermode emulation on X86_64 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: riku.voipio@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.179 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Jincheng Miao 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 Reviewed-by: Richard Henderson Signed-off-by: Riku Voipio --- 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; } }