From patchwork Tue Aug 12 13:42:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 35272 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f71.google.com (mail-oa0-f71.google.com [209.85.219.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 81B4420540 for ; Tue, 12 Aug 2014 13:55:19 +0000 (UTC) Received: by mail-oa0-f71.google.com with SMTP id g18sf45525520oah.2 for ; Tue, 12 Aug 2014 06:55:19 -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=FCYYe8ghf4NP0lPl3I1rCZlwMRZcsYAetkQlaofJTtSBnJaeozKFbNLzs+RuScPu9l wbJgjM5sXdeK8vv1Vxx7af0LKlnzey1u4SqGAQdRRB6YOFdJ8FBjgUWautBQQNDMyfhV BIpBTfyXC9HSuoS/5Gz6BuqqH+mCyVwvGLPP1mBxDq4HQfac4BjjAmKy3PeybihbxSRw j8m9LEMpVkezg6qBFd2VPTnx02PLUi/4sl8t4i2Mn+JR+QmbOK8EhDAdx9VfBLRzww6s WdZmUvwnLw3a6yyYJvW7repPperfTk4/Rk8U9e6/1CaFWbnz01FDMN0FYCddYPJbMCVH cQhg== X-Gm-Message-State: ALoCoQk9ArWeViz7JY0IxCViYYi2Jy+wkkauuIY+6tjtBXIPy7pxnfVRdgWuOE0rjR3ZsC8L3jK9 X-Received: by 10.50.138.167 with SMTP id qr7mr11274242igb.6.1407851718653; Tue, 12 Aug 2014 06:55:18 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.30.197 with SMTP id d63ls101264qgd.82.gmail; Tue, 12 Aug 2014 06:55:18 -0700 (PDT) X-Received: by 10.220.118.136 with SMTP id v8mr964188vcq.50.1407851718428; Tue, 12 Aug 2014 06:55:18 -0700 (PDT) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by mx.google.com with ESMTPS id sb10si8240654vdc.89.2014.08.12.06.55.18 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 12 Aug 2014 06:55:18 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.175 as permitted sender) client-ip=209.85.220.175; Received: by mail-vc0-f175.google.com with SMTP id ik5so13115731vcb.6 for ; Tue, 12 Aug 2014 06:55:18 -0700 (PDT) X-Received: by 10.220.15.8 with SMTP id i8mr1223328vca.45.1407851718359; Tue, 12 Aug 2014 06:55:18 -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 tc5csp250777vcb; Tue, 12 Aug 2014 06:55:17 -0700 (PDT) X-Received: by 10.140.104.138 with SMTP id a10mr6536436qgf.19.1407851717457; Tue, 12 Aug 2014 06:55:17 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id q14si13616597qay.126.2014.08.12.06.55.17 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 12 Aug 2014 06:55:17 -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]:42212 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XHCXk-0006Pq-Rm for patch@linaro.org; Tue, 12 Aug 2014 09:55:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41325) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XHCLR-0007Yh-NP for qemu-devel@nongnu.org; Tue, 12 Aug 2014 09:42:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XHCLH-00018k-1s for qemu-devel@nongnu.org; Tue, 12 Aug 2014 09:42:33 -0400 Received: from [2001:4b98:dc0:45:216:3eff:fe3d:166f] (port=42394 helo=afflict.kos.to) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XHCLG-000187-Sx for qemu-devel@nongnu.org; Tue, 12 Aug 2014 09:42:22 -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 81D6A2657B; Tue, 12 Aug 2014 15:42:21 +0200 (CEST) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Tue, 12 Aug 2014 16:42:14 +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: Jincheng Miao Subject: [Qemu-devel] [PATCH 04/10] 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.175 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; } }