From nobody Mon Nov 25 01:27:24 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 1718716127095198.71794250904566; Tue, 18 Jun 2024 06:08:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJYZK-0002tE-G5; Tue, 18 Jun 2024 09:08:14 -0400 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 1sJYZI-0002so-BT; Tue, 18 Jun 2024 09:08:12 -0400 Received: from mail.loongson.cn ([114.242.206.163]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJYZF-0000sv-C6; Tue, 18 Jun 2024 09:08:12 -0400 Received: from loongson.cn (unknown [10.2.5.185]) by gateway (Coremail) with SMTP id _____8CxL_CvhnFma+oHAA--.31871S3; Tue, 18 Jun 2024 21:07:59 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.185]) by localhost.localdomain (Coremail) with SMTP id AQAAf8CxJMWuhnFmkYcnAA--.19305S2; Tue, 18 Jun 2024 21:07:59 +0800 (CST) From: Song Gao To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org, git@xen0n.name, maobibo@loongson.cn, yijun@loongson.cn, qemu-stable@nongnu.org Subject: [PATCH] tcg/loongarch64: Fix tcg_out_movi tcg_debug_assert() error Date: Tue, 18 Jun 2024 20:50:44 +0800 Message-Id: <20240618125044.687443-1-gaosong@loongson.cn> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: AQAAf8CxJMWuhnFmkYcnAA--.19305S2 X-CM-SenderInfo: 5jdr20tqj6z05rqj20fqof0/ X-Coremail-Antispam: 1Uk129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7 ZEXasCq-sGcSsGvfJ3UbIjqfuFe4nvWSU5nxnvy29KBjDU0xBIdaVrnUUvcSsGvfC2Kfnx nUUI43ZEXa7xR_UUUUUUUUU== 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: pass client-ip=114.242.206.163; envelope-from=gaosong@loongson.cn; helo=mail.loongson.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_NONE=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1718716130211100001 On Loongnix 20.5 systems, QEMU configure with option '--enable-debug' or '--enable-debug-tcg ', booting the Loongnix 20.5 VM in tcg mode will get an assertion error. "... [ 31.484992] [drm] Initialized virtio_gpu 0.0.1 0 for virtio1 on mino= r 0 qemu-system-loongarch64: /home1/gaosong/code/github/clean/qemu/tcg/loon= garch64/tcg-target.c.inc:394=EF=BC=9Atcg_out_movi: =E5=81=87=E8=AE=BE =E2= =80=98offset_hi =3D=3D sextreg(offset_hi, 0, 20)=E2=80=99 =E5=A4=B1=E8=B4= =A5=E3=80=82 ./start.sh: =E8=A1=8C 14: 2433006 =E5=B7=B2=E6=94=BE=E5=BC=83 = (=E6=A0=B8=E5=BF=83=E5=B7=B2=E8=BD=AC=E5=82=A8)./build/qemu-system-loo= ngarch64 --accel tcg -m 8G -cpu la464 -machine virt -smp 8 -serial stdio -b= ios ./QEMU_EFI.fd -monitor telnet:localhost:4498,server,nowait -device virt= io-gpu-pci -net nic, -net user -device nec-usb-xhci,id=3Dxhci,addr=3D0x1b -= device usb-tablet,id=3Dtablet,bus=3Dxhci.0,port=3D1 -device usb-kbd,id=3Dke= yboard,bus=3Dxhci.0,port=3D2 -device virtio-blk-pci,drive=3Dtest -drive if= =3Dnone,id=3Dtest,file=3D./Loongnix-20.5.cartoon.mini.loongarch64.cn.qcow2 " The values of offset_hi and sextreg(offset_hi, 0, 20) are: "[ 29.975240] virtio_gpu virtio1: fb0: virtiodrmfb frame buffer device offset_hi is 80000 sextreg(offset_hi, 0, 20) is fffffffffff80000 offset_hi is 80000 sextreg(offset_hi, 0, 20) is fffffffffff80000 offset_hi is 80000 sextreg(offset_hi, 0, 20) is fffffffffff80000 ..." When pcalau12i + ori is not satisfied, we should use other methods instead, instead of generating an assertion error. Cc: qemu-stable@nongnu.org Reported-by: yijun Signed-off-by: Song Gao --- tcg/loongarch64/tcg-target.c.inc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.= c.inc index 06ca1ab11c..592494c48d 100644 --- a/tcg/loongarch64/tcg-target.c.inc +++ b/tcg/loongarch64/tcg-target.c.inc @@ -391,7 +391,9 @@ static void tcg_out_movi(TCGContext *s, TCGType type, T= CGReg rd, pc_hi =3D (val - pc_offset) >> 12; offset_hi =3D val_hi - pc_hi; =20 - tcg_debug_assert(offset_hi =3D=3D sextreg(offset_hi, 0, 20)); + if (offset_hi !=3D sextreg(offset_hi, 0, 20)) { + goto out; + } tcg_out_opc_pcalau12i(s, rd, offset_hi); if (val_lo !=3D 0) { tcg_out_opc_ori(s, rd, rd, val_lo & 0xfff); @@ -399,6 +401,7 @@ static void tcg_out_movi(TCGContext *s, TCGType type, T= CGReg rd, return; } =20 +out: hi12 =3D sextreg(val, 12, 20); hi32 =3D sextreg(val, 32, 20); hi52 =3D sextreg(val, 52, 12); --=20 2.39.3