hasheddan / danielmangum.com

3 stars 2 forks source link

[question] timer.s can't reach supervisor or stap #371

Open yf13 opened 9 months ago

yf13 commented 9 months ago

Following this page: https://danielmangum.com/posts/risc-v-bytes-timer-interrupts

Take the timer.s from the full-picture section and try it with qemu-system-riscv64 on Ubuntu Jammy, it seems one can't reach supervisor or strap, the program stucks in mtrap actually :

# in terminal one
$ qemu-system-riscv64 -M virt -cpu rv64 -smp 1 -nographic -bios none -kernel build/timer -s -S
# in another terminal
$ gdb-multiarch -silent -ex "target remote :1234" -ex 'display /i $pc' -ex 'display /x $mstatus' \
        -ex 'display /x $mie'  -ex 'break *_start' -ex 'break *supervisor' \
        -ex 'break *mtrap' -ex 'break *strap' -ex 'display *0x2004000' -ex 'display *0x200bff8' \
        -ex 'set confirm off' build/timer
(gdb) info break
Num     Type           Disp Enb Address            What
1       breakpoint     keep y   0x0000000080000000 timer.s:7
     breakpoint already hit 1 time
2       breakpoint     keep y   0x0000000080000060 timer.s:30
3       breakpoint     keep y   0x0000000080000054 timer.s:25
     breakpoint already hit 5 times
4       breakpoint     keep y   0x0000000080000074 timer.s:36

$ /usr/bin/qemu-system-riscv64  --version
QEMU emulator version 6.2.0 (Debian 1:6.2+dfsg-2ubuntu6.11)
Copyright (c) 2003-2021 Fabrice Bellard and the QEMU Project developers
$ gdb-multiarch -version
GNU gdb (Ubuntu 12.0.90-0ubuntu1) 12.0.90