From patchwork Mon Jul 2 15:10:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 10501825 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 112206028F for ; Mon, 2 Jul 2018 15:19:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 02705286F2 for ; Mon, 2 Jul 2018 15:19:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EAE8528BDC; Mon, 2 Jul 2018 15:19:54 +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 97405286F2 for ; Mon, 2 Jul 2018 15:19:54 +0000 (UTC) Received: from localhost ([::1]:33487 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0cL-0002kY-Me for patchwork-qemu-devel@patchwork.kernel.org; Mon, 02 Jul 2018 11:19:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48642) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0Tg-0003wJ-BI for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:10:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fa0Tf-0007pP-8S for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:10:56 -0400 Received: from mail-pf0-x22c.google.com ([2607:f8b0:400e:c00::22c]:40443) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fa0Tf-0007pF-2R for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:10:55 -0400 Received: by mail-pf0-x22c.google.com with SMTP id z24-v6so7656123pfe.7 for ; Mon, 02 Jul 2018 08:10:55 -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=e4pm6DSzkfHdk/TR2CU8+/bP9WYycKetJu5llGfPfLcIAlS/gBUafIg5GLf/+AzTL0 IxrFC3BJ2tS+lr0KApvjJYOKdJNnyxPNW7ohE85OF196WbPv4Nns3uYOy/mqZ6eWKX7D DQGum9Pp6dP8L8vEM+dnslh2xeocudPL7aY8I7hqLu0cQveZah67Si49Mj87ZkvklMtx AE/UMiZKarX+9ERoeio+Ab68g7WqT8DtFJ2HNmZ6fTLMvhnKKmU1OjS4zKXlkHo+rfNe Kqak99ntHm6EfP3fHsHayx4gd6xg1fNmFHZ/lvPBYxuIuRmQ322uYQQlsXet++BvV6dg EicQ== 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=gCP9jfWZkMIcsz6EGTwrvuUdn3g7lbZ12EAVqnBnf2OgTRRaQFmqkrqkvhPIupE5gW USgsnRvXG68Hl0RBHKMiQSZMxM7MHBTI/iItCH1k7a1NZM9o6q8v4QHVKboJYnDLvu/5 r5PGFKCHIVA4VjRJ6G3JZKolzlV/83FJSj1WyIeh3x+LoMg3hy9i5yB47WcZgyBLmH1/ C05OwQzxYPljmgDy+23ejd4uNaFa4BWGYaDAirFSgGuyv/RsYq4cVSfNN+h1U3Ynq8X3 HOQYC8XLEWVCgifCRV25d1WNBFc2W/SWfxxda8yALQJl1xOmXDHb4eUMYZ5rxDM3/9Nm 5Fow== X-Gm-Message-State: APt69E3BPjsYiIxebQITGqb8Oqo6U4mtGxq/QRYxm7I9pAAaJY98Vn/f eiPhDPRIYkVJN3ZsgxbdvoU7es0G X-Google-Smtp-Source: AAOMgpdLABDivou7981f1gvquzYCuyTfO7M1aE2ZRfOlJ41iXHaBWaIm2PqQyN/XCNTUOWBsdi02yw== X-Received: by 2002:a62:2ec1:: with SMTP id u184-v6mr25972153pfu.184.1530544254247; Mon, 02 Jul 2018 08:10:54 -0700 (PDT) Received: from localhost (g90.124-44-6.ppp.wakwak.ne.jp. [124.44.6.90]) by smtp.gmail.com with ESMTPSA id 15-v6sm28346424pfq.81.2018.07.02.08.10.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 08:10:53 -0700 (PDT) From: Stafford Horne To: Peter Maydell Date: Tue, 3 Jul 2018 00:10:04 +0900 Message-Id: <20180702151023.24532-7-shorne@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180702151023.24532-1-shorne@gmail.com> References: <20180702151023.24532-1-shorne@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::22c Subject: [Qemu-devel] [PULL v2 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(); } }