mit-pdos / xv6-riscv

Xv6 for RISC-V
Other
6.63k stars 2.4k forks source link

Unable to run properly in MacBook m1 #83

Closed MrZLeo closed 1 year ago

MrZLeo commented 3 years ago

I download the necessary dependencies and type make qemu in xv6's directory, it seems some troubles happened:

qemu-system-riscv64 -machine virt -bios none -kernel kernel/kernel -m 128M -smp 3 -nographic -drive file=fs.img,if=none,format=raw,id=x0 -device virtio-blk-device,drive=x0,bus=virtio-mmio-bus.0
qemu-system-riscv64: qemu_mprotect__osdep: mprotect failed: Permission denied
qemu-system-riscv64: qemu_mprotect__osdep: mprotect failed: Permission denied
qemu-system-riscv64: qemu_mprotect__osdep: mprotect failed: Permission denied
qemu-system-riscv64: qemu_mprotect__osdep: mprotect failed: Permission denied
qemu-system-riscv64: qemu_mprotect__osdep: mprotect failed: Permission denied
qemu-system-riscv64: qemu_mprotect__osdep: mprotect failed: Permission denied
qemu-system-riscv64: qemu_mprotect__osdep: mprotect failed: Permission denied
qemu-system-riscv64: qemu_mprotect__osdep: mprotect failed: Permission denied
qemu-system-riscv64: qemu_mprotect__osdep: mprotect failed: Permission denied
qemu-system-riscv64: qemu_mprotect__osdep: mprotect failed: Permission denied
qemu-system-riscv64: qemu_mprotect__osdep: mprotect failed: Permission denied
qemu-system-riscv64: qemu_mprotect__osdep: mprotect failed: Permission denied
qemu-system-riscv64: qemu_mprotect__osdep: mprotect failed: Permission denied
qemu-system-riscv64: qemu_mprotect__osdep: mprotect failed: Permission denied
qemu-system-riscv64: qemu_mprotect__osdep: mprotect failed: Permission denied
qemu-system-riscv64: qemu_mprotect__osdep: mprotect failed: Permission denied
qemu-system-riscv64: qemu_mprotect__osdep: mprotect failed: Permission denied
qemu-system-riscv64: qemu_mprotect__osdep: mprotect failed: Permission denied
qemu-system-riscv64: qemu_mprotect__osdep: mprotect failed: Permission denied
qemu-system-riscv64: qemu_mprotect__osdep: mprotect failed: Permission denied
qemu-system-riscv64: qemu_mprotect__osdep: mprotect failed: Permission denied
qemu-system-riscv64: qemu_mprotect__osdep: mprotect failed: Permission denied
qemu-system-riscv64: qemu_mprotect__osdep: mprotect failed: Permission denied
qemu-system-riscv64: qemu_mprotect__osdep: mprotect failed: Permission denied

I don't know what does it means and how to solve it. But it seems I have to exit it by ctrl + A + x rather than ctrl + c, which indicates that the problem may come from qemu.

My device:

MacBook Pro m1,
macOS 11.4,
qemu 6.0,
riscv64-unknown-elf-gcc (GCC) 10.2.0
MrZLeo commented 3 years ago

And I have tried sudo make qemu as well, it did not work.

TrenDavi commented 2 years ago

I am running Qemu on a M1 too. Ending up having the exact same error when trying to boot. :(

knightsc commented 2 years ago

The comments on this thread make it sound like Qemu was patched in May to address this issue.

https://bugs.launchpad.net/qemu/+bug/1914849

Perhaps try using Qemu 6.1.0

tresf commented 1 year ago

I'm not sure if this is the right place to post this, but at time of writing this, homebrew has qemu 7.2.0, which works pretty well with riscv.

image

Command:

qemu-system-riscv64 \
    -machine virt \
    -cpu rv64 \
    -m 4G \
    -device virtio-blk-device,drive=hd \
    -drive file=overlay.qcow2,if=none,id=hd \
    -device virtio-net-device,netdev=net \
    -netdev user,id=net,hostfwd=tcp::2222-:22 \
    -kernel ./u-boot-qemu/uboot.elf \ # extracted from u-boot-qemu_2021.01+dfsg-5_all.deb
    -object rng-random,filename=/dev/urandom,id=rng \
    -device virtio-rng-device,rng=rng \
    -append "root=LABEL=rootfs console=ttyS0" \
    -nographic
MrZLeo commented 1 year ago

@tresf Yes, it works now. It has been supported by qemu right now : )