please refer offical site first
build&install toolchain
git clone https://github.com/riscv/riscv-gnu-toolchain
cd riscv-gnu-toolchain/
./configure --prefix=/usr/local/opt/riscv-gnu-toolchain
make
sudo make install
build&install QEMU
wget https://download.qemu.org/qemu-5.1.0.tar.xz
cd qemu-5.1.0/
./configure --target-list=riscv64-softmmu
make
sudo make install
build&install riscv
git clone git://github.com/mit-pdos/xv6-riscv-fall19.git
cd xv6-riscv-fall19/
make
run xv6 on QEMU
cd xv6-riscv-fall19/
make qemu
qemu-system-riscv64 -machine virt -bios none -kernel kernel/kernel -m 128M -smp 1 -nographic -drive file=fs.img,if=none,format=raw,id=x0 -device virtio-blk-device,drive=x0,bus=virtio-mmio-bus.0
xv6 kernel is booting
virtio disk init 0
init: starting sh
$