From patchwork Mon Jun 27 19:02:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emilio Cota X-Patchwork-Id: 9201221 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E4171607D3 for ; Mon, 27 Jun 2016 19:24:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D10AA27E78 for ; Mon, 27 Jun 2016 19:24:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C5781285BA; Mon, 27 Jun 2016 19:24:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 587DC27E78 for ; Mon, 27 Jun 2016 19:24:00 +0000 (UTC) Received: from localhost ([::1]:60618 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHc8V-0006nx-Ff for patchwork-qemu-devel@patchwork.kernel.org; Mon, 27 Jun 2016 15:23:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58970) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHboE-0006kJ-UQ for qemu-devel@nongnu.org; Mon, 27 Jun 2016 15:03:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bHboC-0008OS-78 for qemu-devel@nongnu.org; Mon, 27 Jun 2016 15:03:01 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:51059) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHbo9-0008G0-Uq for qemu-devel@nongnu.org; Mon, 27 Jun 2016 15:03:00 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 27AB1204F9; Mon, 27 Jun 2016 15:02:35 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute4.internal (MEProxy); Mon, 27 Jun 2016 15:02:35 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=braap.org; h=cc :date:from:in-reply-to:message-id:references:subject:to :x-sasl-enc:x-sasl-enc; s=mesmtp; bh=IMdB7CP+RlIjRVLrvOIItSucb6s =; b=sv8M6Wdhc+XOrTgegTEVHkLiyguUlbBXjW+yEixr7qK3lG+9lOkQjpgdDMU En6h3jUDxoeA2kvR0acQIskPED6zES9DfBpnsLqos8PR3UUbFC0K1EgnjPXvVW9b W6kWeQ9LKkf6ulmRB3V/DwYwfraABlq3ndo2taHCRp5armO4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=IMdB 7CP+RlIjRVLrvOIItSucb6s=; b=gkG3nK/5uh6uEj8Y/PhhEEYQhfY4jz7rkcUV 08ACeWNIDa0lkQdE8IIuT0YECQYXbiFEr4SGVc9GZAT34j74rJ3HlonvMAbsVmmS D/s8yAXOvV0zNsiaGqs1vMf0RXRPNByLVqvDxovO5JNcL4COvgzKV48Vc82iO13Q t3BO4y4= X-Sasl-enc: 0VTl9GdsQlOEigHCxqfSeIYOfvHpYQdCtgCPz4/QTaSO 1467054154 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id CDB94CCDB7; Mon, 27 Jun 2016 15:02:34 -0400 (EDT) From: "Emilio G. Cota" To: QEMU Developers , MTTCG Devel Date: Mon, 27 Jun 2016 15:02:04 -0400 Message-Id: <1467054136-10430-19-git-send-email-cota@braap.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1467054136-10430-1-git-send-email-cota@braap.org> References: <1467054136-10430-1-git-send-email-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.111.4.27 Subject: [Qemu-devel] [RFC 18/30] target-i386: emulate XCHG using atomic helper X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Alvise Rigo , Sergey Fedorov , Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Emilio G. Cota --- target-i386/translate.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/target-i386/translate.c b/target-i386/translate.c index b76b0ae..48c6742 100644 --- a/target-i386/translate.c +++ b/target-i386/translate.c @@ -1325,6 +1325,8 @@ GEN_ATOMIC_HELPER(and_fetch) GEN_ATOMIC_HELPER(or_fetch) GEN_ATOMIC_HELPER(sub_fetch) GEN_ATOMIC_HELPER(xor_fetch) + +GEN_ATOMIC_HELPER(xchg) #undef GEN_ATOMIC_HELPER /* if d == OR_TMP0, it means memory operand (address in A0) */ @@ -5666,12 +5668,7 @@ static target_ulong disas_insn(CPUX86State *env, DisasContext *s, gen_lea_modrm(env, s, modrm); gen_op_mov_v_reg(ot, cpu_T0, reg); /* for xchg, lock is implicit */ - if (!(prefixes & PREFIX_LOCK)) - gen_helper_lock(); - gen_op_ld_v(s, ot, cpu_T1, cpu_A0); - gen_op_st_v(s, ot, cpu_T0, cpu_A0); - if (!(prefixes & PREFIX_LOCK)) - gen_helper_unlock(); + gen_atomic_xchg(cpu_T1, cpu_A0, cpu_T0, ot); gen_op_mov_reg_v(ot, reg, cpu_T1); } break;