qqgnoe466263 / rv32-emu

A RISCV32IMAC Emulator
3 stars 0 forks source link

virtio block failed or stuck @ Freeing unused kernel memory: 212K #2

Open buxuluchudabaiya opened 2 months ago

buxuluchudabaiya commented 2 months ago

Hi, Thanks for your sharing. I followed the instructions in the readme.md file and ran the images with the emulator. It failed to boot linux and exited because of the FPU issue. I tried to re-compile a linux kernel image with the FPU disabled. The new kernel image and the old fw_jump and the old busybox.bin can work well in qemu. But when I used them with the emulator, it got ext4-fs error and failed to mount.

(1) Running in qemu:

` qemu-system-riscv32 -M virt -bios fw_jump-old.bin -kernel Image-00 -append "rootwait root=/dev/vda ro" -drive file=busybox-old.bin,format=raw,id=hd0 -device virtio-blk-device,drive=hd0 -netdev user,id=net0 -device virtio-net-device,netdev=net0 -nographic

... [ 0.596779] usbcore: registered new interface driver usbhid [ 0.597179] usbhid: USB HID core driver [ 0.599914] NET: Registered protocol family 10 [ 0.608568] Segment Routing with IPv6 [ 0.609640] sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver [ 0.613914] NET: Registered protocol family 17 [ 0.615979] 9pnet: Installing 9P2000 support [ 0.617867] Key type dns_resolver registered [ 0.619828] debug_vm_pgtable: [debug_vm_pgtable ]: Validating architecture page table helpers [ 0.678328] EXT4-fs (vda): mounted filesystem without journal. Opts: (null) [ 0.679148] VFS: Mounted root (ext4 filesystem) readonly on device 254:0. [ 0.683409] devtmpfs: mounted [ 0.738445] Freeing unused kernel memory: 212K [ 0.740213] Run /sbin/init as init process Hello, RISC-V `

(2) Running in the emulator:

`./rv_emu --bios linux5.4/fw_jump-old.bin --kernel linux5.4/Image-00 --rootfs linux5.4/busybox-old.bin --dtb dts/riscv_em.dtb

... [ 5.942524] 9pnet: Installing 9P2000 support [ 5.946724] Key type dns_resolver registered [ 5.953924] debug_vm_pgtable: [debug_vm_pgtable ]: Validating architecture page table helpers ▒[ 6.028351] virtio_blk virtio0: req.0:id 0 is not a head! [ 6.030348] blk_update_request: I/O error, dev vda, sector 64 op 0x0:(READ) flags 0x84700 phys_seg 1 prio class 0 [ 6.032810] blk_update_request: I/O error, dev vda, sector 72 op 0x0:(READ) flags 0x84700 phys_seg 1 prio class 0 [ 6.035260] blk_update_request: I/O error, dev vda, sector 80 op 0x0:(READ) flags 0x84700 phys_seg 1 prio class 0 [ 6.037710] blk_update_request: I/O error, dev vda, sector 88 op 0x0:(READ) flags 0x84700 phys_seg 1 prio class 0 [ 6.040160] blk_update_request: I/O error, dev vda, sector 96 op 0x0:(READ) flags 0x84700 phys_seg 1 prio class 0 [ 6.042563] blk_update_request: I/O error, dev vda, sector 104 op 0x0:(READ) flags 0x84700 phys_seg 1 prio class 0 [ 6.052161] blk_update_request: I/O error, dev vda, sector 112 op 0x0:(READ) flags 0x84700 phys_seg 1 prio class 0 [ 6.055202] blk_update_request: I/O error, dev vda, sector 120 op 0x0:(READ) flags 0x84700 phys_seg 1 prio class 0 [ 6.057666] blk_update_request: I/O error, dev vda, sector 128 op 0x0:(READ) flags 0x84700 phys_seg 1 prio class 0 [ 6.060130] blk_update_request: I/O error, dev vda, sector 136 op 0x0:(READ) flags 0x84700 phys_seg 1 prio class 0 [ 6.084192] EXT4-fs error (device vda): __ext4_get_inode_loc_noinmem:4514: inode #2: block 5: comm swapper/0: unable to read itable block [ 6.087744] Buffer I/O error on dev vda, logical block 0, lost sync page write [ 6.089840] EXT4-fs (vda): I/O error while writing superblock [ 6.091431] EXT4-fs (vda): get root inode failed [ 6.092593] EXT4-fs (vda): mount failed ^C `

I tried to rebuild a rootfs.ext2 to replace the busybox.bin. They can also work fine in qemu, but failed again when using the emulator. It said "EXT4-fs (vda): bad geometry: block count 61440 exceeds size of device (36864 blocks)", and stucked after "Freeing unused kernel memory: 212K".

`./rv_emu --bios linux5.4/fw_jump-old.bin --kernel linux5.4/Image-00 --rootfs linux5.4/rootfs.ext2 --dtb dts/riscv_em.dtb

... [ 5.953924] debug_vm_pgtable: [debug_vm_pgtable ]: Validating architecture page table helpers ▒[ 6.006474] EXT4-fs (vda): bad geometry: block count 61440 exceeds size of device (36864 blocks) [ 6.022052] EXT2-fs (vda): warning: mounting unchecked fs, running e2fsck is recommended [ 6.026786] VFS: Mounted root (ext2 filesystem) on device 254:0. [ 6.033983] devtmpfs: mounted [ 6.044207] Freeing unused kernel memory: 212K ^C `

I tried to modified the virtio.c file, changed vio->config[1]=0x20, and vio->config[2]=0x03, then re-compiled the emulator. It again showed the similar mesages as the previous example. `[ 5.953969] debug_vm_pgtable: [debug_vm_pgtable ]: Validating architecture page table helpers ▒[ 6.024494] virtio_blk virtio0: req.0:id 0 is not a head! [ 6.026491] blk_update_request: I/O error, dev vda, sector 16 op 0x0:(READ) flags 0x84700 phys_seg 1 prio class 0 [ 6.028952] blk_update_request: I/O error, dev vda, sector 18 op 0x0:(READ) flags 0x84700 phys_seg 1 prio class 0 [ 6.031402] blk_update_request: I/O error, dev vda, sector 20 op 0x0:(READ) flags 0x84700 phys_seg 1 prio class 0 [ 6.033852] blk_update_request: I/O error, dev vda, sector 22 op 0x0:(READ) flags 0x84700 phys_seg 1 prio class 0 [ 6.036302] blk_update_request: I/O error, dev vda, sector 24 op 0x0:(READ) flags 0x84700 phys_seg 1 prio class 0 [ 6.038702] blk_update_request: I/O error, dev vda, sector 26 op 0x0:(READ) flags 0x84700 phys_seg 1 prio class 0 [ 6.046460] blk_update_request: I/O error, dev vda, sector 28 op 0x0:(READ) flags 0x84700 phys_seg 1 prio class 0 [ 6.049488] blk_update_request: I/O error, dev vda, sector 30 op 0x0:(READ) flags 0x84700 phys_seg 1 prio class 0 [ 6.051938] blk_update_request: I/O error, dev vda, sector 32 op 0x0:(READ) flags 0x84700 phys_seg 1 prio class 0 [ 6.054388] blk_update_request: I/O error, dev vda, sector 34 op 0x0:(READ) flags 0x84700 phys_seg 1 prio class 0 [ 6.074560] EXT4-fs error (device vda): __ext4_get_inode_loc_noinmem:4514: inode #2: block 5: comm swapper/0: unable to read itable block [ 6.078115] Buffer I/O error on dev vda, logical block 1, lost sync page write [ 6.080233] EXT4-fs (vda): I/O error while writing superblock [ 6.081825] EXT4-fs (vda): get root inode failed [ 6.082987] EXT4-fs (vda): mount failed

`

I must have done something wrong but I don't know where it is. Can you help me out?

Another question, why xv6 can run when I mask the function tick(), but halt when keep it?

Thanks anyway.

qqgnoe466263 commented 2 months ago

Hello, I may not be able to help. As you can see, I haven't updated this project in a long time. This is a small project that I practiced for learning.

I recommand you to play the sysprog21/semu, it is still maintained. Of cause you can study the issue and send the PRs (But i think it is not easy).

Thanks~