From patchwork Wed Oct 26 16:15:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 687214 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3t3wlD1qhgz9t1L for ; Thu, 27 Oct 2016 03:41:28 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=j4qNmyJl; dkim-atps=neutral Received: from localhost ([::1]:36025 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bzRGX-0006hZ-Fc for incoming@patchwork.ozlabs.org; Wed, 26 Oct 2016 12:41:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37402) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bzQsy-0002vg-IK for qemu-devel@nongnu.org; Wed, 26 Oct 2016 12:17:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bzQsx-0002TE-J8 for qemu-devel@nongnu.org; Wed, 26 Oct 2016 12:17:04 -0400 Received: from mail-qt0-x244.google.com ([2607:f8b0:400d:c0d::244]:35256) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1bzQsx-0002Sk-Et for qemu-devel@nongnu.org; Wed, 26 Oct 2016 12:17:03 -0400 Received: by mail-qt0-x244.google.com with SMTP id g49so312131qtc.2 for ; Wed, 26 Oct 2016 09:17:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=Fzb0ufHpFRDcg8Bg0UxEC2cSWiFyErD0DgVDLUwgNkk=; b=j4qNmyJlqPcu0xdSrN2L8D6/0IFiV/dG+qmlca5hmTSUMZrSWp/NsVW/CX7IkS4M45 ds5kMae/CqSR5DNLjWPhd/4dGdrG5tNvpeuonatKLRjt+kvi56o25pnNGcuHa95a6RTY Ca6S0qtrseLY42SC6Zn/EWsiaW3FG1SXTg5NzvkaoBYzV7moP+8wDYGPuGbseaGR381G F/Zi/3Yd+KMaG90ykpPmRi7t65sYD0Mww+Iw9EHSUYfLPT1aYDpk5LxlE5Fwc2NMDHkj T2yOXLxr4YSrnzmDXOfm5Kmfhyib6hF5p4N65ADPEeYsY6qS3I4n1hlMghVbK+MWN8gx 2E9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=Fzb0ufHpFRDcg8Bg0UxEC2cSWiFyErD0DgVDLUwgNkk=; b=fk4aqAsvHIobNV2IwONVh3DrYN6pMMoryBWvbGsH8ID8CUpkKS36sA9Tj4wr/lKQ2N Uvp7ZKnFU2zuKRlfQHBgSquDu99Vv+G8DakVMhXPACwf5aokVOPyH+DUXqrsvc6OcM5D zvpmZEl3x5EtGZ59TsCYpp3l6EuRFtDSEqeqlgsGUpP7WLvuM5nQgpSBLuE7TKRHHrST /9x2X+owxyyAu1a2yLP4X8pF5SlMBoT81l7fDT8m/WW0oH+MrWB/zqLBy9/em3DgoHcr mU4JjgrOeQ0rWRzj0SkWUSJzPEdwCWOXM4bYO4MPABcI64dCOguvxFUybHhTRSZ58mMo r/7Q== X-Gm-Message-State: ABUngvdTdyRh2HU7Ya8hypDAM3Kdb+769/BSQEXiq5NhLK5aGxM7ErubQ1SA09j9ulMfAg== X-Received: by 10.200.37.177 with SMTP id e46mr2644497qte.14.1477498622999; Wed, 26 Oct 2016 09:17:02 -0700 (PDT) Received: from bigtime.com (174-24-157-40.tukw.qwest.net. [174.24.157.40]) by smtp.gmail.com with ESMTPSA id e185sm1337941qkd.13.2016.10.26.09.17.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Oct 2016 09:17:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 26 Oct 2016 09:15:49 -0700 Message-Id: <1477498563-29091-24-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477498563-29091-1-git-send-email-rth@twiddle.net> References: <1477498563-29091-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400d:c0d::244 Subject: [Qemu-devel] [PULL v2 23/37] target-i386: emulate LOCK'ed NEG using cmpxchg 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@linaro.org, "Emilio G. Cota" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" [rth: Move redundant qemu_load out of cmpxchg loop.] Signed-off-by: Emilio G. Cota Message-Id: <1467054136-10430-16-git-send-email-cota@braap.org> Signed-off-by: Richard Henderson --- target-i386/translate.c | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/target-i386/translate.c b/target-i386/translate.c index 6d71564..d2edbd9 100644 --- a/target-i386/translate.c +++ b/target-i386/translate.c @@ -4712,11 +4712,41 @@ static target_ulong disas_insn(CPUX86State *env, DisasContext *s, } break; case 3: /* neg */ - tcg_gen_neg_tl(cpu_T0, cpu_T0); - if (mod != 3) { - gen_op_st_v(s, ot, cpu_T0, cpu_A0); + if (s->prefix & PREFIX_LOCK) { + TCGLabel *label1; + TCGv a0, t0, t1, t2; + + if (mod == 3) { + goto illegal_op; + } + a0 = tcg_temp_local_new(); + t0 = tcg_temp_local_new(); + label1 = gen_new_label(); + + tcg_gen_mov_tl(a0, cpu_A0); + tcg_gen_mov_tl(t0, cpu_T0); + + gen_set_label(label1); + t1 = tcg_temp_new(); + t2 = tcg_temp_new(); + tcg_gen_mov_tl(t2, t0); + tcg_gen_neg_tl(t1, t0); + tcg_gen_atomic_cmpxchg_tl(t0, a0, t0, t1, + s->mem_index, ot | MO_LE); + tcg_temp_free(t1); + tcg_gen_brcond_tl(TCG_COND_NE, t0, t2, label1); + + tcg_temp_free(t2); + tcg_temp_free(a0); + tcg_gen_mov_tl(cpu_T0, t0); + tcg_temp_free(t0); } else { - gen_op_mov_reg_v(ot, rm, cpu_T0); + tcg_gen_neg_tl(cpu_T0, cpu_T0); + if (mod != 3) { + gen_op_st_v(s, ot, cpu_T0, cpu_A0); + } else { + gen_op_mov_reg_v(ot, rm, cpu_T0); + } } gen_op_update_neg_cc(); set_cc_op(s, CC_OP_SUBB + ot);