QEMU RV64 - n-hys/illumos-gate GitHub Wiki

QEMU RV64

QEMU is a open source machine emulator.

Installing QEMU

Install QEMU 6.2.0 or later. (You can use vanilla QEMU.)
You can use the following packages on openSUSE Leap 15.4.

sudo zypper in qemu-extra qemu-tools

Creating a bridge interface on your PC

Create a bridge interface for using network from the QEMU virtual machine.
Create the file /usr/local/etc/qemu/bridge.conf (or /etc/qemu/bridge.conf) with the content:

allow br0

Creating a disk image

The following additional packages are required on openSUSE Leap 15.4.

zypper install gptfdisk

You need to use Solaris ROOT GUID (6A85CF4D-1DD2-11B2-99A6-080020736631) for the root slice.

disk_img=${base_dir}/disk-rv64.img

qemu-img create -f raw ${disk_img} 16G
sgdisk -g -e --clear --new=1:2048: --change-name=1:solaris --typecode=1:6A85CF4D-1DD2-11B2-99A6-080020736631 ${disk_img}

Booting from network

Run the following command. When booting from network, some errors occurr but you can ignore errors.
You can login as root without using password.

illumos_dir=${base_dir}/illumos-gate
disk_img=${base_dir}/disk-rv64.img

sudo qemu-system-riscv64 -nographic -machine virt -m 1G -smp 4 \
    -bios default \
    -kernel ${illumos_dir}/usr/src/psm/stand/boot/riscv64/virt/inetboot.bin \
    -append "-D /soc/virtio_mmio@10008000" \
    -netdev bridge,id=net0,br=br0 \
    -device virtio-net-device,netdev=net0,mac=52:54:00:70:0a:e3 \
    -drive file=${disk_img},format=raw,id=hd0 \
    -device virtio-blk-device,drive=hd0 \
    -gdb tcp::1234
boot.log

OpenSBI v0.9
   ____                    _____ ____ _____
  / __ \                  / ____|  _ \_   _|
 | |  | |_ __   ___ _ __ | (___ | |_) || |
 | |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
 | |__| | |_) |  __/ | | |____) | |_) || |_
  \____/| .__/ \___|_| |_|_____/|____/_____|
        | |
        |_|

Platform Name             : riscv-virtio,qemu
Platform Features         : timer,mfdeleg
Platform HART Count       : 4
Firmware Base             : 0x80000000
Firmware Size             : 124 KB
Runtime SBI Version       : 0.2

Domain0 Name              : root
Domain0 Boot HART         : 0
Domain0 HARTs             : 0*,1*,2*,3*
Domain0 Region00          : 0x0000000080000000-0x000000008001ffff ()
Domain0 Region01          : 0x0000000000000000-0xffffffffffffffff (R,W,X)
Domain0 Next Address      : 0x0000000080200000
Domain0 Next Arg1         : 0x00000000bf000000
Domain0 Next Mode         : S-mode
Domain0 SysReset          : yes

Boot HART ID              : 0
Boot HART Domain          : root
Boot HART ISA             : rv64imafdcsu
Boot HART Features        : scounteren,mcounteren,time
Boot HART PMP Count       : 16
Boot HART PMP Granularity : 4
Boot HART PMP Address Bits: 54
Boot HART MHPM Count      : 0
Boot HART MHPM Count      : 0
Boot HART MIDELEG         : 0x0000000000000222
Boot HART MEDELEG         : 0x000000000000b109
phys memory add 0000000080000000 - 00000000bfffffff
memory resv 0000000080000000 - 000000008001ffff
add io 10000000 1000 for ns16550a
add io 10008000 1000 for virtio,mmio
add io 10007000 1000 for virtio,mmio
add io 10006000 1000 for virtio,mmio
add io 10005000 1000 for virtio,mmio
add io 10004000 1000 for virtio,mmio
add io 10003000 1000 for virtio,mmio
add io 10002000 1000 for virtio,mmio
add io 10001000 1000 for virtio,mmio
add io c000000 210000 for riscv,plic0
add io 2000000 10000 for riscv,clint0
bootargs=-D /soc/virtio_mmio@10008000
bootpath=/soc/virtio_mmio@10008000
mfg_name=SUNW,virt
bpath=/soc/virtio_mmio@10008000
vdev_probe error
mfg_name=SUNW,virt

bop_init
done
Opening /boot/solaris/bootenv.rc
fd is 1
WARNING: cannot open system file: /etc/system
illumos Version SunOS_Development 64-bit
DEBUG enabled
rootnex_map_regspec: 10008000 -> ffffffc010008000
WARNING: Cannot mount /system/boot
rootnex_map_regspec: 10000000 -> ffffffc010000000
cpu0: RISC-V 64bit hart=0
cpu1: RISC-V 64bit hart=1
cpu1: QEMU VIRT CPU
cpu1 initialization complete - online
cpu2: RISC-V 64bit hart=2
cpu2: QEMU VIRT CPU
cpu2 initialization complete - online
cpu3: RISC-V 64bit hart=3
cpu3: QEMU VIRT CPU
cpu3 initialization complete - online
Loading smf(5) service descriptions: 138/138
ERROR: svc:/system/filesystem/usr:default failed to mount remount  (see 'svcs -x' for details)
Nov 10 07:07:33 svc.startd[100003]: svc:/system/filesystem/usr:default: Method "/lib/svc/method/fs-usr" failed with exit status 95.
Nov 10 07:07:33 svc.startd[100003]: system/filesystem/usr:default failed fatally: transitioned to maintenance (see 'svcs -xv' for details)
Hostname: virt
Requesting System Maintenance Mode
(See /lib/svc/share/README for more information.)
Console login service(s) cannot run

Enter user name for system maintenance (control-d to bypass): 

Enter user name for system maintenance (control-d to bypass): root
Enter root password (control-d to bypass): 
single-user privilege assigned to root on /dev/console.
Entering System Maintenance Mode

Nov 10 07:07:55 su: 'su root' succeeded for root on /dev/console
The illumos Project	SunOS Development	Aug. 15, 2022
illumos development build: naoyuki
root@virt:~# 

Partition

The solaris root partition will probably be /dev/dsk/c1t0d0s0.
To create a storage pool:

devfsadm
zpool create -f -o altroot=/mnt rpool /dev/dsk/c1t0d0s0

Booting from disk image

Run the following command. The difference with the network boot is -append "-D /soc/virtio_mmio@10007000".

illumos_dir=${base_dir}/illumos-gate
disk_img=${base_dir}/disk-rv64.img

sudo qemu-system-riscv64 -nographic -machine virt -m 1G -smp 4 \
    -bios default \
    -kernel ${illumos_dir}/usr/src/psm/stand/boot/riscv64/virt/inetboot.bin \
    -append "-D /soc/virtio_mmio@10007000" \
    -netdev bridge,id=net0,br=br0 \
    -device virtio-net-device,netdev=net0,mac=52:54:00:70:0a:e3 \
    -drive file=${disk_img},format=raw,id=hd0 \
    -device virtio-blk-device,drive=hd0 \
    -gdb tcp::1234
boot.log

OpenSBI v0.9
   ____                    _____ ____ _____
  / __ \                  / ____|  _ \_   _|
 | |  | |_ __   ___ _ __ | (___ | |_) || |
 | |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
 | |__| | |_) |  __/ | | |____) | |_) || |_
  \____/| .__/ \___|_| |_|_____/|____/_____|
        | |
        |_|

Platform Name             : riscv-virtio,qemu
Platform Features         : timer,mfdeleg
Platform HART Count       : 4
Firmware Base             : 0x80000000
Firmware Size             : 124 KB
Runtime SBI Version       : 0.2

Domain0 Name              : root
Domain0 Boot HART         : 1
Domain0 HARTs             : 0*,1*,2*,3*
Domain0 Region00          : 0x0000000080000000-0x000000008001ffff ()
Domain0 Region01          : 0x0000000000000000-0xffffffffffffffff (R,W,X)
Domain0 Next Address      : 0x0000000080200000
Domain0 Next Arg1         : 0x00000000bf000000
Domain0 Next Mode         : S-mode
Domain0 SysReset          : yes

Boot HART ID              : 1
Boot HART Domain          : root
Boot HART ISA             : rv64imafdcsu
Boot HART Features        : scounteren,mcounteren,time
Boot HART PMP Count       : 16
Boot HART PMP Granularity : 4
Boot HART PMP Address Bits: 54
Boot HART MHPM Count      : 0
Boot HART MHPM Count      : 0
Boot HART MIDELEG         : 0x0000000000000222
Boot HART MEDELEG         : 0x000000000000b109
phys memory add 0000000080000000 - 00000000bfffffff
memory resv 0000000080000000 - 000000008001ffff
add io 10000000 1000 for ns16550a
add io 10008000 1000 for virtio,mmio
add io 10007000 1000 for virtio,mmio
add io 10006000 1000 for virtio,mmio
add io 10005000 1000 for virtio,mmio
add io 10004000 1000 for virtio,mmio
add io 10003000 1000 for virtio,mmio
add io 10002000 1000 for virtio,mmio
add io 10001000 1000 for virtio,mmio
add io c000000 210000 for riscv,plic0
add io 2000000 10000 for riscv,clint0
bootargs=-D /soc/virtio_mmio@10007000
bootpath=/soc/virtio_mmio@10007000
zfs_lookup error /platform/SUNW,virt/boot_archive
zfs_lookup error /platform/riscv-virtio/boot_archive
vdev_probe error
mfg_name=SUNW,virt

bop_init
done
Opening /boot/solaris/bootenv.rc
fd is 1
WARNING: cannot open system file: /etc/system
illumos Version SunOS_Development 64-bit
DEBUG enabled
rootnex_map_regspec: 10007000 -> ffffffc010007000
WARNING: Cannot mount /system/boot
rootnex_map_regspec: 10000000 -> ffffffc010000000
cpu0: RISC-V 64bit hart=1
cpu1: RISC-V 64bit hart=0
cpu1: QEMU VIRT CPU
cpu1 initialization complete - online
cpu2: RISC-V 64bit hart=2
cpu2: QEMU VIRT CPU
cpu2 initialization complete - online
cpu3: RISC-V 64bit hart=3
cpu3: QEMU VIRT CPU
cpu3 initialization complete - online
Loading smf(5) service descriptions: 138/138
Hostname: unknown

WARNING: Reboot required.
The system has updated the cache of files (boot archive) that
is used during the early boot sequence. To avoid booting and
running the system with the previously out-of-sync version of
these files, the system will be restarted.

syncing file systems... done

OpenSBI v0.9
   ____                    _____ ____ _____
  / __ \                  / ____|  _ \_   _|
 | |  | |_ __   ___ _ __ | (___ | |_) || |
 | |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
 | |__| | |_) |  __/ | | |____) | |_) || |_
  \____/| .__/ \___|_| |_|_____/|____/_____|
        | |
        |_|

Platform Name             : riscv-virtio,qemu
Platform Features         : timer,mfdeleg
Platform HART Count       : 4
Firmware Base             : 0x80000000
Firmware Size             : 124 KB
Runtime SBI Version       : 0.2

Domain0 Name              : root
Domain0 Boot HART         : 0
Domain0 HARTs             : 0*,1*,2*,3*
Domain0 Region00          : 0x0000000080000000-0x000000008001ffff ()
Domain0 Region01          : 0x0000000000000000-0xffffffffffffffff (R,W,X)
Domain0 Next Address      : 0x0000000080200000
Domain0 Next Arg1         : 0x00000000bf000000
Domain0 Next Mode         : S-mode
Domain0 SysReset          : yes

Boot HART ID              : 0
Boot HART Domain          : root
Boot HART ISA             : rv64imafdcsu
Boot HART Features        : scounteren,mcounteren,time
Boot HART PMP Count       : 16
Boot HART PMP Granularity : 4
Boot HART PMP Address Bits: 54
Boot HART MHPM Count      : 0
Boot HART MHPM Count      : 0
Boot HART MIDELEG         : 0x0000000000000222
Boot HART MEDELEG         : 0x000000000000b109
phys memory add 0000000080000000 - 00000000bfffffff
memory resv 0000000080000000 - 000000008001ffff
add io 10000000 1000 for ns16550a
add io 10008000 1000 for virtio,mmio
add io 10007000 1000 for virtio,mmio
add io 10006000 1000 for virtio,mmio
add io 10005000 1000 for virtio,mmio
add io 10004000 1000 for virtio,mmio
add io 10003000 1000 for virtio,mmio
add io 10002000 1000 for virtio,mmio
add io 10001000 1000 for virtio,mmio
add io c000000 210000 for riscv,plic0
add io 2000000 10000 for riscv,clint0
bootargs=-D /soc/virtio_mmio@10007000
bootpath=/soc/virtio_mmio@10007000
zfs_lookup error /platform/SUNW,virt/boot_archive
zfs_lookup error /platform/riscv-virtio/boot_archive
vdev_probe error
mfg_name=SUNW,virt

bop_init
done
Opening /boot/solaris/bootenv.rc
fd is 1
illumos Version SunOS_Development 64-bit
DEBUG enabled
rootnex_map_regspec: 10007000 -> ffffffc010007000
WARNING: Cannot mount /system/boot
rootnex_map_regspec: 10000000 -> ffffffc010000000
cpu0: RISC-V 64bit hart=0
cpu1: RISC-V 64bit hart=1
cpu1: QEMU VIRT CPU
cpu1 initialization complete - online
cpu2: RISC-V 64bit hart=2
cpu2: QEMU VIRT CPU
cpu2 initialization complete - online
cpu3: RISC-V 64bit hart=3
cpu3: QEMU VIRT CPU
cpu3 initialization complete - online
Hostname: unknown

unknown console login: Nov 10 07:09:00 unknown rootnex: rootnex_map_regspec: 10008000 -> ffffffc010008000

unknown console login: root
Nov 10 07:10:24 unknown login: Solaris_audit getaddrinfo(unknown) failed[node name or service name not known]: Error 0
Nov 10 07:10:24 unknown login: Solaris_audit adt_get_local_address failed, no Audit IP address available, faking loopback and error: Network is down
Nov 10 07:10:24 unknown login: pam_unix_cred: cannot load ttyname: Network is down, continuing.
Nov 10 07:10:24 unknown login: ROOT LOGIN /dev/console
The illumos Project     SunOS Development       Aug. 15, 2022
illumos development build: naoyuki
root@unknown:~# 
⚠️ **GitHub.com Fallback** ⚠️