xvisor / xvisor

Xvisor: eXtensible Versatile hypervISOR
http://xhypervisor.org
GNU General Public License v2.0
546 stars 247 forks source link

Can not kick basic riscv test VM #175

Closed inochisa closed 1 year ago

inochisa commented 1 year ago

I got a mmap fault when kicking a basic VM created by following the tutorial in tests/riscv/virt64/basic/README, but got the following fault:

XVisor# guest kick guest0
guest0: Kicked
XVisor# cpu_vcpu_stage2_map: guest_phys=0x000127170AA04000 size=0x4096 map failed
do_error: CPU0: VCPU=guest0/vcpu0 page fault failed (error -1)
           zero=0x0000000000000000          ra=0x0000000000000000
             sp=0x0000000000000000          gp=0x0000000000000000
             tp=0x0000000000000000          s0=0x0000000000000000
             s1=0x0000000000000000          a0=0x0000000000000000
             a1=0x0000000000000000          a2=0x0000000000000000
             a3=0x0000000000000000          a4=0x000127170AA04C63
             a5=0x0000000000000000          a6=0x0000000000000000
             a7=0x000127170AA04C63          s2=0x0000000000000000
             s3=0x0000000000000000          s4=0x0000000000000000
             s5=0x0000000000000000          s6=0x0000000000000000
             s7=0x0000000000000000          s8=0x0000000000000000
             s9=0x0000000000000000         s10=0x0000000000000000
            s11=0x0000000000000000          t0=0x0000000000000000
             t1=0x0000000000000000          t2=0x0000000000000000
             t3=0x0000000000000000          t4=0x0000000000000000
             t5=0x0000000000000000          t6=0x0000000000000000
           sepc=0x0000000000000026     sstatus=0x0000000200004120
        hstatus=0x00000002002001C0     sp_exec=0x0000000010A41000
         scause=0x0000000000000017       stval=0x000127170AA04C63
          htval=0x000049C5C2A81318      htinst=0x0000000001103023

It seems to like the VM halted at the very early stage, but I have no idea about what caused this.


Qemu command:

qemu-system-riscv64 -cpu rv64 -M virt -m 2G -display none -serial stdio -kernel ./build/vmm.bin -initrd ./build/disk.img -append "vmm.bootcmd=\"vfs mount initrd /;vfs run /boot.xscript;vfs cat /system/banner.txt\""

Software: qemu 8.1.2-1 (OpenSBI is provided by the qemu) kernel 6.5.9-arch2-1 riscv64-linux-gnu-gcc 12.2.0 (Arch LInux)

avpatel commented 1 year ago

As-per error message, the first thing running in Guest is accessing a non-existent memory region.

inochisa commented 1 year ago

I recompiled this with the upstream toolchain and everything worked fine.

I think this is a gcc bug related to the arch linux riscv64 toolchain. It is OK to closed it.

endeneer commented 1 year ago

I recompiled this with the upstream toolchain and everything worked fine.

I think this is a gcc bug related to the arch linux riscv64 toolchain. It is OK to closed it.

Similar situation here, if I use the riscv64-linux-gnu toolchain in Ubuntu 22.04, the guest kick fails with the exact error complaining about accessing guest_phys=0x000127170AA04000.

$ riscv64-linux-gnu-gcc -v
Using built-in specs.
COLLECT_GCC=riscv64-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc-cross/riscv64-linux-gnu/11/lto-wrapper
Target: riscv64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 11.4.0-1ubuntu1~22.04' --with-bugurl=file:///usr/share/doc/gcc-11/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-11 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libitm --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --without-target-system-zlib --enable-multiarch --disable-werror --disable-multilib --with-arch=rv64gc --with-abi=lp64d --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=riscv64-linux-gnu --program-prefix=riscv64-linux-gnu- --includedir=/usr/riscv64-linux-gnu/include --with-build-config=bootstrap-lto-lean --enable-link-serialization=2
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.4.0 (Ubuntu 11.4.0-1ubuntu1~22.04)

After switching to another toolchain, and recompiled Xvisor, the guest kick succeded.

$ riscv64-unknown-linux-gnu-gcc -v
Using built-in specs.
COLLECT_GCC=riscv64-unknown-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/home/user/toolchain_build/riscv-toolchain/install/riscv64-unknown-linux-gnu/bin/../libexec/gcc/riscv64-unknown-linux-gnu/12.2.1/lto-wrapper
Target: riscv64-unknown-linux-gnu
Configured with: /home/user/toolchain_build/riscv-toolchain/crosstool-ng/.build/riscv64-unknown-linux-gnu/src/gcc/configure --build=x86_64-build_pc-linux-gnu --host=x86_64-build_pc-linux-gnu --target=riscv64-unknown-linux-gnu --prefix=/home/user/toolchain_build/riscv-toolchain/install/riscv64-unknown-linux-gnu --enable-shared --exec_prefix=/home/user/toolchain_build/riscv-toolchain/install/riscv64-unknown-linux-gnu --with-sysroot=/home/user/toolchain_build/riscv-toolchain/install/riscv64-unknown-linux-gnu/riscv64-unknown-linux-gnu/sysroot --enable-languages=c,c++,fortran --with-arch=rv64gcb --with-abi=lp64d --with-pkgversion='Custom GCC-Linux-2023-06-30' --disable-libmudflap --disable-libssp --disable-libquadmath --disable-libquadmath-support --disable-libsanitizer --with-gmp=/home/user/toolchain_build/riscv-toolchain/crosstool-ng/.build/riscv64-unknown-linux-gnu/buildtools --with-mpfr=/home/user/toolchain_build/riscv-toolchain/crosstool-ng/.build/riscv64-unknown-linux-gnu/buildtools --with-mpc=/home/user/toolchain_build/riscv-toolchain/crosstool-ng/.build/riscv64-unknown-linux-gnu/buildtools --with-isl=/home/user/toolchain_build/riscv-toolchain/crosstool-ng/.build/riscv64-unknown-linux-gnu/buildtools --enable-threads=posix --disable-nls --with-system-zlib --enable-tls --disable-multilib --with-local-prefix=/home/user/toolchain_build/riscv-toolchain/install/riscv64-unknown-linux-gnu/riscv64-unknown-linux-gnu/sysroot --enable-long-long 'CFLAGS_FOR_TARGET=-O2 -mcmodel=medany -march=rv64gcb' 'CXXFLAGS_FOR_TARGET=-O2 -mcmodel=medany -march=rv64gcb'
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 12.2.1 20230307 (Custom GCC-Linux-2023-06-30)