From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6B6D0C433EF for ; Mon, 18 Apr 2022 13:22:07 +0000 (UTC) Received: from localhost ([::1]:47172 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ngRKQ-0003wz-BQ for qemu-devel@archiver.kernel.org; Mon, 18 Apr 2022 09:22:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58156) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ngRH4-0001hL-U5 for qemu-devel@nongnu.org; Mon, 18 Apr 2022 09:18:38 -0400 Received: from mail08.asahi-net.or.jp ([202.224.55.48]:46937) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ngRH3-000261-4O for qemu-devel@nongnu.org; Mon, 18 Apr 2022 09:18:38 -0400 Received: from sakura.ysato.name (ik1-413-38519.vs.sakura.ne.jp [153.127.30.23]) (Authenticated sender: PQ4Y-STU) by mail08.asahi-net.or.jp (Postfix) with ESMTPA id 166F5285E5; Mon, 18 Apr 2022 22:18:34 +0900 (JST) Received: from SIOS1075.ysato.ml (ZM005235.ppp.dion.ne.jp [222.8.5.235]) by sakura.ysato.name (Postfix) with ESMTPSA id 73DD01C0173; Mon, 18 Apr 2022 22:18:34 +0900 (JST) Date: Mon, 18 Apr 2022 22:18:34 +0900 Message-ID: <87mtgimswl.wl-ysato@users.sourceforge.jp> From: Yoshinori Sato To: Tomoaki Kawada Subject: Re: [PATCH] target/rx: update PC correctly in wait instruction In-Reply-To: <20220417060224.2131788-1-i@yvt.jp> References: <20220417060224.2131788-1-i@yvt.jp> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Received-SPF: softfail client-ip=202.224.55.48; envelope-from=ysato@users.sourceforge.jp; helo=mail08.asahi-net.or.jp X-Spam_score_int: -11 X-Spam_score: -1.2 X-Spam_bar: - X-Spam_report: (-1.2 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665, 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: qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On Sun, 17 Apr 2022 15:02:25 +0900, Tomoaki Kawada wrote: > > `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 > --- > 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; > -- > 2.35.1 > Reviewed-by: Yoshinori Sato -- Yosinori Sato