From patchwork Mon Jan 15 02:08:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: guoguangyao X-Patchwork-Id: 13519285 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 CF98BC4707B for ; Mon, 15 Jan 2024 02:09:43 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rPCPC-0003Vg-6O; Sun, 14 Jan 2024 21:08:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rPCP9-0003VP-3M for qemu-devel@nongnu.org; Sun, 14 Jan 2024 21:08:47 -0500 Received: from smtp81.cstnet.cn ([159.226.251.81] helo=cstnet.cn) by eggs.gnu.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1rPCP6-0001ZD-5h for qemu-devel@nongnu.org; Sun, 14 Jan 2024 21:08:46 -0500 Received: from nano.loongson.cn (unknown [123.125.11.126]) by APP-03 (Coremail) with SMTP id rQCowABnbrqSk6Rl5OBrBg--.43262S2; Mon, 15 Jan 2024 10:08:30 +0800 (CST) From: guoguangyao To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org, pbonzini@redhat.com, eduardo@habkost.net, guoguangyao Subject: [PATCH] target/i386: Eip error in x86_64-softmmu Date: Mon, 15 Jan 2024 10:08:04 +0800 Message-Id: <20240115020804.30272-1-guoguangyao18@mails.ucas.ac.cn> X-Mailer: git-send-email 2.34.1 MIME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CTnIWIevJa73UjIFyTuYvjfU0_-PUU UUU X-Originating-IP: [123.125.11.126] X-CM-SenderInfo: 5jxrw35dqj5trrryqzpdlo2hpxfd2hldfou0/ Received-SPF: pass client-ip=159.226.251.81; envelope-from=guoguangyao18@mails.ucas.ac.cn; helo=cstnet.cn X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org When closing PCREL, qemu-system-x86_64 run into error. Eip modification here leads to the result. Using s->pc in func gen_update_eip_next() solves the problem. Fixes: b5e0d5d22fbf("target/i386: Fix 32-bit wrapping of pc/eip computation") Signed-off-by: guoguangyao modified: target/i386/tcg/translate.c Reviewed-by: Richard Henderson --- target/i386/tcg/translate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index e1eb82a5c6..6f57d5a8a5 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -567,9 +567,9 @@ static void gen_update_eip_next(DisasContext *s) if (tb_cflags(s->base.tb) & CF_PCREL) { tcg_gen_addi_tl(cpu_eip, cpu_eip, s->pc - s->pc_save); } else if (CODE64(s)) { - tcg_gen_movi_tl(cpu_eip, s->base.pc_next); + tcg_gen_movi_tl(cpu_eip, s->pc); } else { - tcg_gen_movi_tl(cpu_eip, (uint32_t)(s->base.pc_next - s->cs_base)); + tcg_gen_movi_tl(cpu_eip, (uint32_t)(s->pc - s->cs_base)); } s->pc_save = s->pc; }