From patchwork Thu Jun 14 20:25:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Edgar E. Iglesias" X-Patchwork-Id: 10465269 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 9067A600D0 for ; Thu, 14 Jun 2018 20:28:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 72E2E26530 for ; Thu, 14 Jun 2018 20:28:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 65D8B27DA4; Thu, 14 Jun 2018 20:28:44 +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=-3.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, FSL_HELO_FAKE, MAILING_LIST_MULTI, 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 1023726530 for ; Thu, 14 Jun 2018 20:28:43 +0000 (UTC) Received: from localhost ([::1]:42862 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTYrL-00050s-6q for patchwork-qemu-devel@patchwork.kernel.org; Thu, 14 Jun 2018 16:28:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50207) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTYnu-0002VW-5i for qemu-devel@nongnu.org; Thu, 14 Jun 2018 16:25:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fTYnt-0006BH-7w for qemu-devel@nongnu.org; Thu, 14 Jun 2018 16:25:10 -0400 Received: from mail-lf0-x244.google.com ([2a00:1450:4010:c07::244]:40432) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fTYns-0006AU-Vh for qemu-devel@nongnu.org; Thu, 14 Jun 2018 16:25:09 -0400 Received: by mail-lf0-x244.google.com with SMTP id q11-v6so11377417lfc.7 for ; Thu, 14 Jun 2018 13:25:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7JwRP7mYlf8afA3lslf6J5FrFC+NoixqaqyWvc31k5s=; b=q95n3dgUGYc85ujkDLFrmkOFlP9+ZBfcr1SQP7TnYoWbsTBQ9B4d+Iuk4s61l1gxs4 ckpfQW4JAlfisaziUM0q3ofzVtJSnF8QrGc9lJMveJBrC0gHMz3xyNHUMkE0Xo1jUFyO s+tsH80RTVAky07wmwb57izxacUQoZuaofddySZRk+X5ekSXNwM+acgBgMi1UOrTdcYe rLfQYq9ezJwu0D5LxW6FQR21ORJ3US4AXS1FEEgcc4X7jSWPBoxsJd3wcOgyLghaZoHI cEPveZkGGUTZ1XG1l4ArWwD8D8A3EwyAiVxPv+yjCppaberw+p4qRBIQrQiZSr1vJ+FG Qr5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7JwRP7mYlf8afA3lslf6J5FrFC+NoixqaqyWvc31k5s=; b=TTKMVqM0Z2jKq24TmA64EwUFf/7ouZ4gVnx5tO/9DScryCVAOymLcUCUZmgKBZiuU6 wK5gzHLa6f2oH2Dg0Y8S6ivYiCK/JoN7DSNHbK/Jm1SMZLsGn0PnCCRSOSEpiHnEU/cB B4kd4z3xa+KG1uQe961szFh6mp53bYJWPrRE8qtqZY5/hK6fvAfBgJxEre7KRxCzeKEO KUUO5z8MGWrGiHLbAr4CwEuM7fBMvVpPfNH7LOislZVlam+qIfEkjtX95geTpWnSjOz9 qj3Xbjerav44HfdBrXs3DFsBZXx27sdQ34A57VTZvuJV3EJ/agBoKhIQGY6YZccDk5P/ z+jA== X-Gm-Message-State: APt69E2l2dYtoQIEzXpD9m/Cv5jcDhO7rBlq4bR1Gjj3Qq4GctIw3gvk ur8dRiHCYfpCWyB67iNla7JyDg== X-Google-Smtp-Source: ADUXVKLlpMhkNhNoANDuEIi0m5cLn4fHR0273HpAWlFZ4PUGDF0aCQE3k26XP+r/LGLsQekQLWKR9g== X-Received: by 2002:a19:c1c1:: with SMTP id r184-v6mr7274479lff.51.1529007907382; Thu, 14 Jun 2018 13:25:07 -0700 (PDT) Received: from gmail.com (81-231-232-130-no39.tbcn.telia.com. [81.231.232.130]) by smtp.gmail.com with ESMTPSA id a67-v6sm1206667lfa.48.2018.06.14.13.25.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Jun 2018 13:25:06 -0700 (PDT) From: "Edgar E. Iglesias" To: qemu-devel@nongnu.org Date: Thu, 14 Jun 2018 22:25:02 +0200 Message-Id: <20180614202502.668-3-edgar.iglesias@gmail.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180614202502.668-1-edgar.iglesias@gmail.com> References: <20180614202502.668-1-edgar.iglesias@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4010:c07::244 Subject: [Qemu-devel] [PATCH v1 2/2] target-microblaze: Rework NOP/zero instruction handling 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: edgar.iglesias@xilinx.com, peter.maydell@linaro.org, sstabellini@kernel.org, sai.pavan.boddu@xilinx.com, frasse.iglesias@gmail.com, alistair@alistair23.me, richard.henderson@linaro.org, frederic.konrad@adacore.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: "Edgar E. Iglesias" Remove the abort on a sequence of NOP/zero instructions. Always return early and avoid decoding NOP/zero instructions. This fixes Coverity CID 1391443. Signed-off-by: Edgar E. Iglesias Reviewed-by: Philippe Mathieu-Daudé --- target/microblaze/translate.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/target/microblaze/translate.c b/target/microblaze/translate.c index 6c64946398..78ca265b04 100644 --- a/target/microblaze/translate.c +++ b/target/microblaze/translate.c @@ -90,7 +90,6 @@ typedef struct DisasContext { uint32_t jmp_pc; int abort_at_next_insn; - int nr_nops; struct TranslationBlock *tb; int singlestep_enabled; } DisasContext; @@ -1576,17 +1575,12 @@ static inline void decode(DisasContext *dc, uint32_t ir) dc->ir = ir; LOG_DIS("%8.8x\t", dc->ir); - if (dc->ir) - dc->nr_nops = 0; - else { + if (ir == 0) { trap_illegal(dc, dc->cpu->env.pvr.regs[2] & PVR2_OPCODE_0x0_ILL_MASK); - - LOG_DIS("nr_nops=%d\t", dc->nr_nops); - dc->nr_nops++; - if (dc->nr_nops > 4) { - cpu_abort(CPU(dc->cpu), "fetching nop sequence\n"); - } + /* Don't decode nop/zero instructions any further. */ + return; } + /* bit 2 seems to indicate insn type. */ dc->type_b = ir & (1 << 29); @@ -1633,7 +1627,6 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) dc->singlestep_enabled = cs->singlestep_enabled; dc->cpustate_changed = 0; dc->abort_at_next_insn = 0; - dc->nr_nops = 0; if (pc_start & 3) { cpu_abort(cs, "Microblaze: unaligned PC=%x\n", pc_start);