From nobody Thu May 2 07:30:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1650175643363592.0850151271756; Sat, 16 Apr 2022 23:07:23 -0700 (PDT) Received: from localhost ([::1]:45064 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nfy49-0004kp-He for importer@patchew.org; Sun, 17 Apr 2022 02:07:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52238) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nfy1L-000464-CN for qemu-devel@nongnu.org; Sun, 17 Apr 2022 02:04:27 -0400 Received: from applejack.8vit.me ([165.227.58.191]:51388) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nfy1J-0000Tg-PA for qemu-devel@nongnu.org; Sun, 17 Apr 2022 02:04:27 -0400 Received: from gabby.8vit.me (unknown [192.168.28.2]) by applejack.8vit.me (Postfix) with ESMTPS id 0567123F7F4; Sun, 17 Apr 2022 15:02:53 +0900 (JST) Received: by gabby.8vit.me (Postfix, from userid 1000) id B0A131A7495; Sun, 17 Apr 2022 15:02:52 +0900 (JST) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: None (mailfrom) identity=mailfrom; client-ip=192.168.28.2; helo=gabby.8vit.me; envelope-from=yvt@gabby.8vit.me; receiver= From: Tomoaki Kawada To: qemu-devel@nongnu.org Subject: [PATCH] target/rx: update PC correctly in wait instruction Date: Sun, 17 Apr 2022 15:02:25 +0900 Message-Id: <20220417060224.2131788-1-i@yvt.jp> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: none client-ip=165.227.58.191; envelope-from=yvt@gabby.8vit.me; helo=applejack.8vit.me X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.249, SPF_HELO_PASS=-0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tomoaki Kawada , Yoshinori Sato Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1650175645112100001 Content-Type: text/plain; charset="utf-8" `cpu_pc` at this point does not necessary point to the current instruction (i.e., the wait instruction being translated), so it's incorrect to calculate the new value of `cpu_pc` based on this. It must be updated with `ctx->base.pc_next`, which contains the correct address of the next instruction. This change fixes the wait instruction skipping the subsequent branch when used in an idle loop like this: 0: wait bra.b 0b brk // should be unreachable Signed-off-by: Tomoaki Kawada Reviewed-by: Richard Henderson Reviewed-by: Yoshinori Sato --- target/rx/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/rx/translate.c b/target/rx/translate.c index 5db8f79a82..f8812e7a6c 100644 --- a/target/rx/translate.c +++ b/target/rx/translate.c @@ -2281,7 +2281,7 @@ static bool trans_INT(DisasContext *ctx, arg_INT *a) static bool trans_WAIT(DisasContext *ctx, arg_WAIT *a) { if (is_privileged(ctx, 1)) { - tcg_gen_addi_i32(cpu_pc, cpu_pc, 2); + tcg_gen_movi_i32(cpu_pc, ctx->base.pc_next); gen_helper_wait(cpu_env); } return true; --=20 2.35.1