From patchwork Fri Aug 15 11:01:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 35442 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f200.google.com (mail-ob0-f200.google.com [209.85.214.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6466E203C5 for ; Fri, 15 Aug 2014 11:09:41 +0000 (UTC) Received: by mail-ob0-f200.google.com with SMTP id nu7sf14169347obb.3 for ; Fri, 15 Aug 2014 04:09:41 -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=lTcSrS4oP/BPfX2GhMk6Qelo9INluDPRUoypDR7SF2Q=; b=fxstspEpyV7122hpdOd+1mufg9u66zQmgTmV+4UMgcpm2gsqJYrLosVs8BKkF/97eJ Toe9IygGF6+UcAtDBySokgzZ9ilqvIJ3034TttYIAEPfwi2smwU7Uo2umS04dXRHztZD xsw0lElTVmSD4ybbV25K8U+xlICc3T4h3sEBpesiw8XEF/9tsYQ9gtVftBj7NRl05qxh sXIetENOwfyZg1OGAPDn5Rn7I5OrydYQurqvaAKDmT1NXtuZBtiuwNW0pUEj6+fG4/CJ K6MOBC6KCTHcPdmZQjyLYvHBgOnujb0zHq7R06KELEpfBFPfM7pqqCxY9Y8NG4r4+7tj V9vg== X-Gm-Message-State: ALoCoQmrl/S1evTWDx+L7cMv7S0OsAMFu08VsRff25U3LBDaZIU/2HoeAkj496XrsVPiTV0X7iWC X-Received: by 10.43.152.197 with SMTP id kx5mr9765711icc.9.1408100980977; Fri, 15 Aug 2014 04:09:40 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.50.107 with SMTP id r98ls1411985qga.71.gmail; Fri, 15 Aug 2014 04:09:40 -0700 (PDT) X-Received: by 10.229.232.1 with SMTP id js1mr26542920qcb.20.1408100980867; Fri, 15 Aug 2014 04:09:40 -0700 (PDT) Received: from mail-vc0-f182.google.com (mail-vc0-f182.google.com [209.85.220.182]) by mx.google.com with ESMTPS id g110si11335011qgf.128.2014.08.15.04.09.40 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 15 Aug 2014 04:09:40 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.182 as permitted sender) client-ip=209.85.220.182; Received: by mail-vc0-f182.google.com with SMTP id hy4so2723994vcb.41 for ; Fri, 15 Aug 2014 04:09:40 -0700 (PDT) X-Received: by 10.220.97.5 with SMTP id j5mr9755886vcn.16.1408100980666; Fri, 15 Aug 2014 04:09:40 -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 tc5csp104421vcb; Fri, 15 Aug 2014 04:09:40 -0700 (PDT) X-Received: by 10.229.59.67 with SMTP id k3mr26634319qch.26.1408100979953; Fri, 15 Aug 2014 04:09:39 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 34si11374915qgi.18.2014.08.15.04.09.39 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 15 Aug 2014 04:09:39 -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]:58603 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XIFO7-0000qc-E5 for patch@linaro.org; Fri, 15 Aug 2014 07:09:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39505) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XIFGh-0004xY-Km for qemu-devel@nongnu.org; Fri, 15 Aug 2014 07:02:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XIFGU-00071A-0G for qemu-devel@nongnu.org; Fri, 15 Aug 2014 07:01:59 -0400 Received: from [2001:4b98:dc0:45:216:3eff:fe3d:166f] (port=44481 helo=afflict.kos.to) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XIFGT-00070g-Rb for qemu-devel@nongnu.org; Fri, 15 Aug 2014 07:01:45 -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 73F5026581; Fri, 15 Aug 2014 13:01:44 +0200 (CEST) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Fri, 15 Aug 2014 14:01:22 +0300 Message-Id: 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: 2001:4b98:dc0:45:216:3eff:fe3d:166f Cc: Peter Maydell , Jincheng Miao Subject: [Qemu-devel] [PULL 04/24] 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.182 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 c5878f9..bc1ff46 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; } }