diff mbox series

tcg/loongarch64: Fix tcg_out_movi tcg_debug_assert() error

Message ID 20240618125044.687443-1-gaosong@loongson.cn (mailing list archive)
State New, archived
Headers show
Series tcg/loongarch64: Fix tcg_out_movi tcg_debug_assert() error | expand

Commit Message

gaosong June 18, 2024, 12:50 p.m. UTC
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 minor 0
    qemu-system-loongarch64: /home1/gaosong/code/github/clean/qemu/tcg/loongarch64/tcg-target.c.inc:394:tcg_out_movi: 假设 ‘offset_hi == sextreg(offset_hi, 0, 20)’ 失败。
    ./start.sh: 行 14: 2433006 已放弃               (核心已转储)./build/qemu-system-loongarch64 --accel tcg -m 8G -cpu la464 -machine virt -smp 8 -serial stdio -bios ./QEMU_EFI.fd -monitor telnet:localhost:4498,server,nowait -device virtio-gpu-pci -net nic, -net user -device nec-usb-xhci,id=xhci,addr=0x1b -device usb-tablet,id=tablet,bus=xhci.0,port=1 -device usb-kbd,id=keyboard,bus=xhci.0,port=2 -device virtio-blk-pci,drive=test -drive if=none,id=test,file=./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 <yijun@loongson.cn>
Signed-off-by: Song Gao <gaosong@loongson.cn>
---
 tcg/loongarch64/tcg-target.c.inc | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Michael Tokarev Aug. 11, 2024, 5:43 p.m. UTC | #1
18.06.2024 15:50, Song Gao wrote:
> 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 minor 0
>      qemu-system-loongarch64: /home1/gaosong/code/github/clean/qemu/tcg/loongarch64/tcg-target.c.inc:394:tcg_out_movi: 假设 ‘offset_hi == sextreg(offset_hi, 0, 20)’ 失败。
>      ./start.sh: 行 14: 2433006 已放弃               (核心已转储)./build/qemu-system-loongarch64 --accel tcg -m 8G -cpu la464 -machine virt -smp 8 -serial stdio -bios ./QEMU_EFI.fd -monitor telnet:localhost:4498,server,nowait -device virtio-gpu-pci -net nic, -net user -device nec-usb-xhci,id=xhci,addr=0x1b -device usb-tablet,id=tablet,bus=xhci.0,port=1 -device usb-kbd,id=keyboard,bus=xhci.0,port=2 -device virtio-blk-pci,drive=test -drive if=none,id=test,file=./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.

Hi!

Has this change been forgotten, or is it not needed anymore?

Thanks,

/mjt
Richard Henderson Aug. 12, 2024, 12:49 a.m. UTC | #2
On 8/12/24 03:43, Michael Tokarev wrote:
> 18.06.2024 15:50, Song Gao wrote:
>> 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 minor 0
>>      qemu-system-loongarch64: /home1/gaosong/code/github/clean/qemu/tcg/loongarch64/tcg- 
>> target.c.inc:394:tcg_out_movi: 假设 ‘offset_hi == sextreg(offset_hi, 0, 20)’ 失败。
>>      ./start.sh: 行 14: 2433006 已放弃               (核心已转储)./build/qemu-system- 
>> loongarch64 --accel tcg -m 8G -cpu la464 -machine virt -smp 8 -serial stdio -bios ./ 
>> QEMU_EFI.fd -monitor telnet:localhost:4498,server,nowait -device virtio-gpu-pci -net 
>> nic, -net user -device nec-usb-xhci,id=xhci,addr=0x1b -device usb- 
>> tablet,id=tablet,bus=xhci.0,port=1 -device usb-kbd,id=keyboard,bus=xhci.0,port=2 -device 
>> virtio-blk-pci,drive=test -drive if=none,id=test,file=./ 
>> 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.
> 
> Hi!
> 
> Has this change been forgotten, or is it not needed anymore?

Fixed with 521d7fb3ebdf88112ed13556a93e3037742b9eb8.


r~
diff mbox series

Patch

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, TCGReg rd,
         pc_hi = (val - pc_offset) >> 12;
         offset_hi = val_hi - pc_hi;
 
-        tcg_debug_assert(offset_hi == sextreg(offset_hi, 0, 20));
+        if (offset_hi != sextreg(offset_hi, 0, 20)) {
+            goto out;
+        }
         tcg_out_opc_pcalau12i(s, rd, offset_hi);
         if (val_lo != 0) {
             tcg_out_opc_ori(s, rd, rd, val_lo & 0xfff);
@@ -399,6 +401,7 @@  static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg rd,
         return;
     }
 
+out:
     hi12 = sextreg(val, 12, 20);
     hi32 = sextreg(val, 32, 20);
     hi52 = sextreg(val, 52, 12);