From patchwork Mon Jul 2 13:57:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 10501485 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 05A006028F for ; Mon, 2 Jul 2018 14:08:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E928C28974 for ; Mon, 2 Jul 2018 14:08:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DD5B928AE7; Mon, 2 Jul 2018 14:08:02 +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=-7.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 8AD0C28974 for ; Mon, 2 Jul 2018 14:08:02 +0000 (UTC) Received: from localhost ([::1]:32996 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fZzUn-0001Pg-QI for patchwork-qemu-devel@patchwork.kernel.org; Mon, 02 Jul 2018 10:08:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47263) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fZzLZ-0002GU-Of for qemu-devel@nongnu.org; Mon, 02 Jul 2018 09:58:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fZzLY-00083U-SS for qemu-devel@nongnu.org; Mon, 02 Jul 2018 09:58:29 -0400 Received: from mail-pg0-x233.google.com ([2607:f8b0:400e:c05::233]:36648) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fZzLY-00082D-Md for qemu-devel@nongnu.org; Mon, 02 Jul 2018 09:58:28 -0400 Received: by mail-pg0-x233.google.com with SMTP id m19-v6so3662330pgv.3 for ; Mon, 02 Jul 2018 06:58:28 -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=egPnLBVgtP7NhsuuXtIHrGJQwyDZe26xfhEhEduYjIY=; b=Oi6GlD41fuiKjm6nbzVVH8dXTQVtKhGIKUnXun9/me0JKAPABvKXbi2WRXPzt9QmVh 0lKpVlLpzX7T1/r9jiquXg6zje2/Q9dVYDuZulyFZljQiUPDOO9Qxfv+ULs2ATsLLpdN nQ7+bHe2k9f6BYsWdiivoEvMj24u7WZPNOl15frk55ku0S7haQaLxiINSL/rZ+0+sMHg ROpu0HeSCqCxh1oGRAahyhjHjw1cn74j5tGtkI/SE1V5RUBizZZhoukZhz6Su1kVAbNn TXEgbGjZj7Mu6pgrtwDR2GrJ0AAe9z7ufBow2alF4M2mA1o9iWkoDgYfOmeGYgXhZ0ER IwDQ== 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=egPnLBVgtP7NhsuuXtIHrGJQwyDZe26xfhEhEduYjIY=; b=fbokLjgi9J0hIV/Ej/gjycYq7+MJ11urWHW+JfoIfuyeUC4BhmVdEK5uVwcyNJvHMC j0ChhRtBqsJzsybLboEnYBQ1c33m9SQB5Bsh1hDgwiJmzoaroAKvYv6kjdnDW5p0cUdi KEsYuUCmteeqqUjNVQ6qKMIpNf6KWZc3C/npJFkSZkgKow4KjL7dANNp8UxiccNVB7MX 7Q6FUiANHtxjX4gWszhD/eIyovY5/ghtY1u02YwkVfV4QMlpahNYvL+tRn8LzefAyrnB gzPZ6aBcom5qI0LXC3YLFFaPFGT2lmXNbuwAexPhXE3zj8kXdEnTLdyIoJnrk8nses3p ZADg== X-Gm-Message-State: APt69E1i6QQxyM0Ua0feuvcvVIzHlOGRkYwKEcLDB0Jm/tQwvWEITH9Q C0gs91jXLZx9FfC3vDHb/CE= X-Google-Smtp-Source: AAOMgpe3a0LlNjYdTg8nrZ0o+Pi9FtsO6bBAfOkQk3zPGaLwezUfT2bO3I5x2hbnB0GobPlQLgLQtA== X-Received: by 2002:a63:5624:: with SMTP id k36-v6mr1546696pgb.146.1530539907768; Mon, 02 Jul 2018 06:58:27 -0700 (PDT) Received: from localhost (g90.124-44-6.ppp.wakwak.ne.jp. [124.44.6.90]) by smtp.gmail.com with ESMTPSA id t21-v6sm42331266pfi.22.2018.07.02.06.58.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 06:58:27 -0700 (PDT) From: Stafford Horne To: Peter Maydell Date: Mon, 2 Jul 2018 22:57:47 +0900 Message-Id: <20180702135806.7087-7-shorne@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180702135806.7087-1-shorne@gmail.com> References: <20180702135806.7087-1-shorne@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::233 Subject: [Qemu-devel] [PULL 06/25] target/openrisc: Fix singlestep_enabled 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: Stafford Horne , Richard Henderson , QEMU Development Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Richard Henderson We failed to store to cpu_pc before raising the exception, which caused us to re-execute the same insn that we stepped. Reviewed-by: Stafford Horne Signed-off-by: Richard Henderson Signed-off-by: Stafford Horne --- target/openrisc/translate.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c index 43bdf378eb..22848b17ad 100644 --- a/target/openrisc/translate.c +++ b/target/openrisc/translate.c @@ -1335,31 +1335,30 @@ static void openrisc_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs) { DisasContext *dc = container_of(dcbase, DisasContext, base); + /* If we have already exited the TB, nothing following has effect. */ + if (dc->base.is_jmp == DISAS_NORETURN) { + return; + } + if ((dc->tb_flags & TB_FLAGS_DFLAG ? 1 : 0) != (dc->delayed_branch != 0)) { tcg_gen_movi_i32(cpu_dflag, dc->delayed_branch != 0); } tcg_gen_movi_tl(cpu_ppc, dc->base.pc_next - 4); - if (dc->base.is_jmp == DISAS_NEXT) { - dc->base.is_jmp = DISAS_UPDATE; - tcg_gen_movi_tl(cpu_pc, dc->base.pc_next); - } - if (unlikely(dc->base.singlestep_enabled)) { - gen_exception(dc, EXCP_DEBUG); - } else { - switch (dc->base.is_jmp) { - case DISAS_TOO_MANY: - gen_goto_tb(dc, 0, dc->base.pc_next); - break; - case DISAS_NORETURN: - break; - case DISAS_UPDATE: - case DISAS_EXIT: + switch (dc->base.is_jmp) { + case DISAS_TOO_MANY: + gen_goto_tb(dc, 0, dc->base.pc_next); + break; + case DISAS_UPDATE: + case DISAS_EXIT: + if (unlikely(dc->base.singlestep_enabled)) { + gen_exception(dc, EXCP_DEBUG); + } else { tcg_gen_exit_tb(NULL, 0); - break; - default: - g_assert_not_reached(); } + break; + default: + g_assert_not_reached(); } }