From patchwork Fri Aug 22 13:24:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 35798 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f198.google.com (mail-pd0-f198.google.com [209.85.192.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7757120540 for ; Fri, 22 Aug 2014 13:26:21 +0000 (UTC) Received: by mail-pd0-f198.google.com with SMTP id fp1sf78709401pdb.5 for ; Fri, 22 Aug 2014 06:26:20 -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=Gr0KzM7uYbvhTuU7jRx1XaX3jgwAMDERBHlL1B3uKwXIJUslAME1k9j4mQQS4vxk6I aju/7nvmCT30V3eVVM0VRZYyBq1hMM6q91POxaoWTYzAlM4LsJdPVxS7k36dabgd+KFx T3/R3VzyvW4OdYb4t0q7vDN3ZAWOzPWMD/tQUWXUFIcx8gORuPU3D7tZesWOqAtZl8nc SU3RYT67bBcvzJnSOkxzlXD38CK73S5VijZLB8qGMyfHkGoPpI4VdMwzwHh6coh257tl D3byq36vyKZmtPqOOcNszt2QxQWde9x6ucIqMOaw2ZURh+KDTHTbyhETZB7l9h3+r+5t SO8g== X-Gm-Message-State: ALoCoQlkVtW6HOPadhMsGyojOk3aRl5syadd22bsZLyi986Afsps2xsiRBXhRnKU1e0ZztZvQp3Z X-Received: by 10.68.216.231 with SMTP id ot7mr3375615pbc.2.1408713980326; Fri, 22 Aug 2014 06:26:20 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.37.148 with SMTP id r20ls1256891qgr.17.gmail; Fri, 22 Aug 2014 06:26:20 -0700 (PDT) X-Received: by 10.220.81.132 with SMTP id x4mr4150009vck.0.1408713980097; Fri, 22 Aug 2014 06:26:20 -0700 (PDT) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id b7si13552951vdx.54.2014.08.22.06.26.20 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 22 Aug 2014 06:26:20 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.178 as permitted sender) client-ip=209.85.220.178; Received: by mail-vc0-f178.google.com with SMTP id la4so12306543vcb.37 for ; Fri, 22 Aug 2014 06:26:20 -0700 (PDT) X-Received: by 10.52.179.161 with SMTP id dh1mr50789vdc.78.1408713980007; Fri, 22 Aug 2014 06:26:20 -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.45.67 with SMTP id uj3csp16731vcb; Fri, 22 Aug 2014 06:26:19 -0700 (PDT) X-Received: by 10.224.28.133 with SMTP id m5mr8242795qac.16.1408713978109; Fri, 22 Aug 2014 06:26:18 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id o17si42249353qge.25.2014.08.22.06.26.18 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 22 Aug 2014 06:26:18 -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]:37065 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XKorB-0007tP-L7 for patch@linaro.org; Fri, 22 Aug 2014 09:26:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55364) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XKopn-0006W3-HG for qemu-devel@nongnu.org; Fri, 22 Aug 2014 09:24:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XKopf-0002B2-Ol for qemu-devel@nongnu.org; Fri, 22 Aug 2014 09:24:51 -0400 Received: from afflict.kos.to ([92.243.29.197]:39299) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XKopf-0002Ab-IN for qemu-devel@nongnu.org; Fri, 22 Aug 2014 09:24:43 -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 76607264D9; Fri, 22 Aug 2014 15:24:42 +0200 (CEST) From: riku.voipio@linaro.org To: Peter Maydell , qemu-devel@nongnu.org Date: Fri, 22 Aug 2014 16:24:21 +0300 Message-Id: <47575997be9e0cae44a4fcaecbd172fec3746c96.1408712881.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 v3 03/22] 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.178 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; } }