• Bug#1108898: riscv64: Illegal instruction appears when using rdcycle in

    From Han Gao@1:229/2 to All on Mon Jul 7 11:50:01 2025
    From: [email protected]

    Package: grub-efi-riscv64-unsigned
    User: [email protected]
    Usertags: riscv64
    X-Debbugs-Cc: [email protected]
    X-Debbugs-Cc: [email protected]
    Version: 2.12-8
    Severity: normal
    Tags: upstream

    Dear Maintainer,

    Illegal instructions will occur when debian riscv64 iso boots to grub.efi.

    Because grub uses the rdcycle instruction.

    Upstream[1] has fixed this issue and hopes to backport to 2.12.

    [1]: https://cgit.git.savannah.gnu.org/cgit/grub.git/commit/grub-core/kern/riscv/efi/init.c?id=c5ae124e11f28f637cbd38cb4d6c1b9817baa135

    sudo qemu-system-riscv64 --enable-kvm -M virt -cpu host -m 2048 -smp 2 -nographic \
    -boot d -cdrom debian-testing-riscv64-netinst.iso \
    -device virtio-net-device,netdev=eth0 -netdev user,id=eth0 \
    -device virtio-rng-pci \
    -kernel /usr/lib/u-boot/qemu-riscv64_smode/uboot.elf \
    -drive file=debian.qcow2,format=qcow2,if=virtio
    U-Boot 2025.01-3 (Apr 08 2025 - 23:07:41 +0000)
    CPU: riscv
    Model: riscv-virtio,qemu
    DRAM: 2 GiB
    Core: 28 devices, 13 uclasses, devicetree: board
    Flash: 32 MiB
    Loading Environment from nowhere... OK
    In: serial,usbkbd
    Out: serial,vidconsole
    Err: serial,vidconsole
    No USB controllers found
    Net: eth0: virtio-net#0
    Working FDT set to feee6c60
    Hit any key to stop autoboot: 0
    Device 0: unknown device
    Device 0: 1af4 VirtIO Block Device
    Type: Hard Disk
    Capacity: 610.2 MB = 0.5 GB (1249880 x 512)
    ... is now current device
    Scanning virtio 0:2...
    Failed to load '/'
    Failed to load '/dtb/'
    Failed to load EFI variables
    Error: writing contents
    ** Unable to write file ubootefi.var **
    Failed to persist EFI variables
    Error: writing contents
    ** Unable to write file ubootefi.var **
    Failed to persist EFI variables
    Error: writing contents
    ** Unable to write file ubootefi.var **
    Failed to persist EFI variables
    Error: writing contents
    ** Unable to write file ubootefi.var **
    Failed to persist EFI variables
    Error: writing contents
    ** Unable to write file ubootefi.var **
    Failed to persist EFI variables
    Booting: virtio 0
    Unhandled exception: Illegal instruction
    EPC: 00000000fdc7a0b8 RA: 00000000fdc7a0fa TVAL: 00000000c0002573
    EPC: 000000007e7720b8 RA: 000000007e7720fa reloc adjusted
    SP: 00000000feee5050 GP: 0000000000000000 TP: 0000000000000000
    T0: 00000000000000e0 T1: 00000000fdc6efe8 T2: 00000000000000f0
    S0: 00000000feee5160 S1: 00000000feee52b0 A0: 00000000fdc6efa0
    A1: 0000000000000000 A2: 00000000fdc6efe8 A3: fffffffffffffff8
    A4: ffffffffffffffb8 A5: 0000000000000001 A6: 0000000000000007
    A7: 0000000000000000 S2: 00000000fdc7f528 S3: 00000000fdc7f478
    S4: 0000000000000000 S5: 00000000ff7f782c S6: 0000000000000000
    S7: 00000000fef2fa70 S8: 0000000000000000 S9: 0000000000000001
    S10: 0000000000000001 S11: 0000000000000000 T3: 000000000000001f
    T4: 0000000000010000 T5: ffffffffffffffff T6: 00000000000000c0
    Code: 7d42 7da2 6149 8082 1141 e022 e406 0800 (2573 c000)
    UEFI image [0x00000000fdc6f000:0x00000000fdd8efff] pc=0xb0b8 '/\EFI\BOOT\BOOTRISCV64.EFI'

    Thanks,
    Han

    --- SoupGate-Win32 v1.05
    * Origin: you cannot sedate... all the things you hate (1:229/2)
  • From Bo YU@1:229/2 to Han Gao on Mon Jul 7 16:50:01 2025
    From: [email protected]

    Control: tags -1 patch

    Hi,

    On Mon, Jul 07, 2025 at 05:43:03PM +0800, Han Gao wrote:
    [...]

    Dear Maintainer,

    Illegal instructions will occur when debian riscv64 iso boots to grub.efi.

    Because grub uses the rdcycle instruction.

    Upstream[1] has fixed this issue and hopes to backport to 2.12.

    [1]: https://cgit.git.savannah.gnu.org/cgit/grub.git/commit/grub-core/kern/riscv/efi/init.c?id=c5ae124e11f28f637cbd38cb4d6c1b9817baa135

    I just backport the commit to generate one debdiff in order to facilitate maintainer to review this(hopefully) and built it on riscv64 also.

    --
    Regards,
    --
    Bo YU


    -----BEGIN PGP SIGNATURE-----

    iQIzBAABCgAdFiEEIcmhjYVTlmab0tjp+RVP3hQ+S68FAmhr3asACgkQ+RVP3hQ+ S6+ZKBAAmzgnlLcnq31WqcB7RtzhYZD1MRLffj0afoDd2HDPipNoEr5dM34uGDH6 HkE27YB++ZMgUz4ZUYYx11lgKbEwHjadQKJ8fi2GTfIKM0c6OSZ6egWlqE70vJ9k oUa5qJvz8MrHhLS/GsrGHK5YP7fvZYrFu8/KUq3clCFvr7tiKx1nnPVwiM9my8Ys zu8FH5Doyo0N20Fj5bw1HUHv2WrIIgwegNxBdnvM689EBF7Eyy4miqNKhnTfqMNT GI6Hw/6gq+sXXX64sB0CoTK0AiNYcXz6hSG09JF/t6PSQBc+O6ASmTjHx7N/A7zr k3/jBYzfJEfE8OU5uP4FZVKvKFbQ97AVlaOFi16eUD+pYGwJe/GVIVSgiNB5RHh4 adXPGd6TNnO5ohXxrYhDLkuNFCfvJ3LD9Cteb/3FOsvWeeqdCZUyDmmmFDwzgWXS 75WJrLn1yoxrBDsFjclPKhGXQIzaTJYyL9m4pJEt54BHFqqoSP/lM5D0nFCjgf6d bfzRihFp1b+DTy49b2VNjgRKJROuV2XsFUBcGpRKkFOZl7zFtCsdp5neAg72vwJF wUm2aAb6k08ybYRncK3A6GprORLog2LJPNugKUPsTvW+sxCkGtSHDE74ArqSzEzF iUjCvuPlecgzu7u9oj4VNLfy53HXQPeHrD/Y4rCLqqKS8QbGVtg=
    =zU6d
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: you cannot sedate... all the things you hate (1:229/2)