Hello,

I also hit this bug on 32-bit mipsel, on the Malta platform in QEMU.

I used images from 
https://ftp.debian.org/debian/dists/Debian12.8/main/installer-mipsel/current/images/malta/netboot/

Command line:

qemu-system-mipsel     -cpu    24Kc     -M      malta     -m      512          
-kernel debian12.8/installer-mipsel/malta/vmlinuz-6.1.0-27-4kc-malta     -initrd
debian12.8/installer-mipsel/malta/initrd.gz  -hda 
/media/1T-data/virtual_machines/debian_mips/hda.raw    -append "root=/dev/sda1 
nokaslr"     -nographic

I was able to work around it by doing the equivalent of:

    ~ # mkfs.ext4 /dev/sda1
    ~ # mount /dev/sda1 /target
    ~ # cd /target
    /target # mkdir -p etc/initramfs-tools/conf.d
    /target # cd etc/initramfs-tools/conf.d/
    /target/etc/initramfs-tools/conf.d # ls
    /target/etc/initramfs-tools/conf.d # echo 'COMPRESS=gzip' > compress
    /target/etc/initramfs-tools/conf.d # cd
    ~ # umount /target

and having the installer not erase the partition during installation.

I have run gdb and the offending instruction is in the ZSTD_RowFindBestMatch 
function and it is the "prefx" instruction.

   0x555b02f8 <+1160>:    addiu    v0,v0,31
   0x555b02fc <+1164>:    andi    v0,v0,0xf
   0x555b0300 <+1168>:    sll    v0,v0,0x2
   0x555b0304 <+1172>:    addu    v0,a3,v0
   0x555b0308 <+1176>:    lw    v0,0(v0)
   0x555b030c <+1180>:    b    0x555b0368 
<ZSTD_RowFindBestMatch_noDict_5_4+1272>
   0x555b0310 <+1184>:    move    t7,v0
=> 0x555b0314 <+1188>:    prefx    0x6,t7(s5)
   0x555b0318 <+1192>:    subu    v0,a1,v0
   0x555b031c <+1196>:    sw    t7,0(a2)
   0x555b0320 <+1200>:    addiu    t9,a0,-1
   0x555b0324 <+1204>:    and    a1,a1,v0
   0x555b0328 <+1208>:    and    a0,a0,t9

It appears that this instruction requires a floating-point coprocessor and is a 
CP1X instruction.
It is used to prefetch locations from memory.

Indeed, when using the 24Kf variant (qemu-system-mipsel -cpu 24Kf), zstd -9 
works.

The question is why the Linux kernel's math-emu module (which is compiled in 
and enabled) didn't catch and emulate it.

    root@mateusz-debian-mips:/sys/kernel/debug/mips# cat fpuemustats_clear
    root@mateusz-debian-mips:/sys/kernel/debug/mips# zstd -9 </etc/fstab 
>/dev/null
    Caught SIGILL signal, printing stack:
    Illegal instruction
    root@mateusz-debian-mips:/sys/kernel/debug/mips# grep -r . fpuemustats/*
    fpuemustats/branches:11
    fpuemustats/cp1ops:44
    fpuemustats/cp1xops:1
    fpuemustats/ds_emul:1
    fpuemustats/emulated:535
    fpuemustats/errors:0
    fpuemustats/ieee754_inexact:4
    fpuemustats/ieee754_invalidop:0
    fpuemustats/ieee754_overflow:0
    fpuemustats/ieee754_underflow:0
    fpuemustats/ieee754_zerodiv:0
    [...]

Greetings,

Mateusz

Reply via email to