From patchwork Tue May 7 15:58:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Torbjorn Granlund X-Patchwork-Id: 242387 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 7777B2C00FD for ; Wed, 8 May 2013 01:59:19 +1000 (EST) Received: from localhost ([::1]:52507 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UZkIP-0003TE-QA for incoming@patchwork.ozlabs.org; Tue, 07 May 2013 11:59:17 -0400 Received: from eggs.gnu.org ([208.118.235.92]:35260) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UZkI1-0003Qu-Tt for qemu-devel@nongnu.org; Tue, 07 May 2013 11:58:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UZkHv-0003E5-Nr for qemu-devel@nongnu.org; Tue, 07 May 2013 11:58:53 -0400 Received: from gmplib-02.nada.kth.se ([130.237.222.242]:15640 helo=shell.gmplib.org) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UZkHv-0003Ap-HG; Tue, 07 May 2013 11:58:47 -0400 Received: by shell.gmplib.org (Postfix, from userid 1001) id D01A012060; Tue, 7 May 2013 17:58:45 +0200 (CEST) To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org References: <86sj20rql4.fsf@shell.gmplib.org> <5187ECAD.4050901@suse.de> <86obcorn76.fsf@shell.gmplib.org> <15FCEEAE-FE2D-44B9-9DC3-5419B29D5B16@suse.de> <86a9o7qe3u.fsf_-_@shell.gmplib.org> From: Torbjorn Granlund Date: Tue, 07 May 2013 17:58:45 +0200 In-Reply-To: <86a9o7qe3u.fsf_-_@shell.gmplib.org> (Torbjorn Granlund's message of "Tue\, 07 May 2013 12\:27\:33 +0200") Message-ID: <86fvxypyru.fsf_-_@shell.gmplib.org> User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.3 (berkeley-unix) MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: FreeBSD 8.x X-Received-From: 130.237.222.242 Subject: Re: [Qemu-devel] Incorrect handling of more PPC64 insns (PATCH) 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org OK, so took to reading some of translate to see how well it agrees with the PPC architecture definition. I spotted a bug with cmp, which was repeated 4 times. Somebody decided that NARROW_MODE should affect the handling of cmp instructions, which is contrary to the ISA documentation. The first hunk is just a comment about suspicious code. I don't suggest to apply that. Incidentally, this patch makes GMP testing go a bit further, and the testcase bug-qemu-ppc-again.s works correctly. diff --git a/target-ppc/translate.c b/target-ppc/translate.c index 1a84653..c44b96d 100644 --- a/target-ppc/translate.c +++ b/target-ppc/translate.c @@ -665,6 +665,7 @@ static inline void gen_op_cmpi32(TCGv arg0, target_ulong arg1, int s, int crf) static inline void gen_set_Rc0(DisasContext *ctx, TCGv reg) { +// suspicious code -- tege if (NARROW_MODE(ctx)) { gen_op_cmpi32(reg, 0, 1, 0); } else { @@ -675,7 +676,7 @@ static inline void gen_set_Rc0(DisasContext *ctx, TCGv reg) /* cmp */ static void gen_cmp(DisasContext *ctx) { - if (NARROW_MODE(ctx) || !(ctx->opcode & 0x00200000)) { + if (!(ctx->opcode & 0x00200000)) { gen_op_cmp32(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)], 1, crfD(ctx->opcode)); } else { @@ -687,7 +688,7 @@ static void gen_cmp(DisasContext *ctx) /* cmpi */ static void gen_cmpi(DisasContext *ctx) { - if (NARROW_MODE(ctx) || !(ctx->opcode & 0x00200000)) { + if (!(ctx->opcode & 0x00200000)) { gen_op_cmpi32(cpu_gpr[rA(ctx->opcode)], SIMM(ctx->opcode), 1, crfD(ctx->opcode)); } else { @@ -699,7 +700,7 @@ static void gen_cmpi(DisasContext *ctx) /* cmpl */ static void gen_cmpl(DisasContext *ctx) { - if (NARROW_MODE(ctx) || !(ctx->opcode & 0x00200000)) { + if (!(ctx->opcode & 0x00200000)) { gen_op_cmp32(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)], 0, crfD(ctx->opcode)); } else { @@ -711,7 +712,7 @@ static void gen_cmpl(DisasContext *ctx) /* cmpli */ static void gen_cmpli(DisasContext *ctx) { - if (NARROW_MODE(ctx) || !(ctx->opcode & 0x00200000)) { + if (!(ctx->opcode & 0x00200000)) { gen_op_cmpi32(cpu_gpr[rA(ctx->opcode)], UIMM(ctx->opcode), 0, crfD(ctx->opcode)); } else {