Re: [PATCH 0/6] target/riscv: Expose RV32 cpu to RV64 QEMU
On Wed, Jul 3, 2024 at 12:25 AM Philippe Mathieu-Daudé wrote: > > Hi Zhiwei, > > On 1/7/24 05:37, LIU Zhiwei wrote: > > From: TANG Tiancheng > > > > This patch set aims to expose 32-bit RISC-V cpu to RV64 QEMU. Thus > > qemu-system-riscv64 can directly boot a RV32 Linux. > > > > This patch set has been tested with 6.9.0 Linux Image. > > > > - Run RV64 QEMU with RV32 CPU > > qemu-system-riscv64 -cpu rv32 -M virt -nographic \ > > -kernel Image \ > > -append "root=/dev/vda ro console=ttyS0" \ > > -drive file=rootfs.ext2,format=raw,id=hd0 \ > > -device virtio-blk-device,drive=hd0 -netdev user,id=net0 \ > > -device virtio-net-device,netdev=net0 > > > > OpenSBI v1.4 > > QEMU emulator version 9.0.50 (v9.0.0-1132-g7799dc2e3b) > > [0.00] Linux version 6.9.0 (developer@11109ca35736) > > (riscv32-unknown-linux-gnu-gcc (gc891d8dc23e-dirty) 13.2.0, GNU ld (GNU > > Binutils) 2.42) #3 SMP Fri May 31 08:42:15 UTC 2024 > > [0.00] random: crng init done > > [0.00] OF: fdt: Ignoring memory range 0x8000 - 0x8040 > > [0.00] Machine model: riscv-virtio,qemu > > [0.00] SBI specification v2.0 detected > > [0.00] SBI implementation ID=0x1 Version=0x10004 > > [0.00] SBI TIME extension detected > > [0.00] SBI IPI extension detected > > [0.00] SBI RFENCE extension detected > > [0.00] SBI SRST extension detected > > [0.00] SBI DBCN extension detected > > [0.00] efi: UEFI not found. > > [0.00] OF: reserved mem: 0x8000..0x8003 (256 KiB) nomap > > non-reusable mmode_resv1@8000 > > [0.00] OF: reserved mem: 0x8004..0x8004 (64 KiB) nomap > > non-reusable mmode_resv0@8004 > > [0.00] Zone ranges: > > [0.00] Normal [mem 0x8040-0x87ff] > > [0.00] Movable zone start for each node > > [0.00] Early memory node ranges > > [0.00] node 0: [mem 0x8040-0x87ff] > > [0.00] Initmem setup node 0 [mem > > 0x8040-0x87ff] > > [0.00] On node 0, zone Normal: 1024 pages in unavailable ranges > > [0.00] SBI HSM extension detected > > [0.00] riscv: base ISA extensions acdfhim > > [0.00] riscv: ELF capabilities acdfim > > [0.00] percpu: Embedded 17 pages/cpu s37728 r8192 d23712 u69632 > > [0.00] Kernel command line: root=/dev/vda ro console=ttyS0 > > [0.00] Dentry cache hash table entries: 16384 (order: 4, 65536 > > bytes, linear) > > [0.00] Inode-cache hash table entries: 8192 (order: 3, 32768 bytes, > > linear) > > [0.00] Built 1 zonelists, mobility grouping on. Total pages: 31465 > > [0.00] mem auto-init: stack:all(zero), heap alloc:off, heap free:off > > [0.00] Virtual kernel memory layout: > > [0.00] fixmap : 0x9c80 - 0x9d00 (8192 kB) > > [0.00] pci io : 0x9d00 - 0x9e00 ( 16 MB) > > [0.00] vmemmap : 0x9e00 - 0xa000 ( 32 MB) > > [0.00] vmalloc : 0xa000 - 0xc000 ( 512 MB) > > [0.00] lowmem : 0xc000 - 0xc7c0 ( 124 MB) > > [0.00] Memory: 95700K/126976K available (9090K kernel code, 8845K > > rwdata, 4096K rodata, 4231K init, 341K bss, 31276K reserved, 0K > > cma-reserved) > > ... > > Welcome to Buildroot > > buildroot login: root > > # cat /proc/cpuinfo > > processor : 0 > > hart: 0 > > isa : > > rv32imafdch_zicbom_zicboz_zicntr_zicsr_zifencei_zihintntl_zihintpause_zihpm_zfa_zba_zbb_zbc_zbs_sstc > > mmu : sv32 > > Please provide an Avocado test (i.e. checking /proc/cpuinfo > contains "isa : rv32"). See for reference > tests/avocado/boot_linux_console.py. Awesome! Thanks for this, this is very exciting. I agree we should add an Avacado test, that way this will be regularly tested as it's something that seems prone to breakage. Alistair > > Thanks! >
Re: [PATCH 0/6] target/riscv: Expose RV32 cpu to RV64 QEMU
Hi Zhiwei, On 1/7/24 05:37, LIU Zhiwei wrote: From: TANG Tiancheng This patch set aims to expose 32-bit RISC-V cpu to RV64 QEMU. Thus qemu-system-riscv64 can directly boot a RV32 Linux. This patch set has been tested with 6.9.0 Linux Image. - Run RV64 QEMU with RV32 CPU qemu-system-riscv64 -cpu rv32 -M virt -nographic \ -kernel Image \ -append "root=/dev/vda ro console=ttyS0" \ -drive file=rootfs.ext2,format=raw,id=hd0 \ -device virtio-blk-device,drive=hd0 -netdev user,id=net0 \ -device virtio-net-device,netdev=net0 OpenSBI v1.4 QEMU emulator version 9.0.50 (v9.0.0-1132-g7799dc2e3b) [0.00] Linux version 6.9.0 (developer@11109ca35736) (riscv32-unknown-linux-gnu-gcc (gc891d8dc23e-dirty) 13.2.0, GNU ld (GNU Binutils) 2.42) #3 SMP Fri May 31 08:42:15 UTC 2024 [0.00] random: crng init done [0.00] OF: fdt: Ignoring memory range 0x8000 - 0x8040 [0.00] Machine model: riscv-virtio,qemu [0.00] SBI specification v2.0 detected [0.00] SBI implementation ID=0x1 Version=0x10004 [0.00] SBI TIME extension detected [0.00] SBI IPI extension detected [0.00] SBI RFENCE extension detected [0.00] SBI SRST extension detected [0.00] SBI DBCN extension detected [0.00] efi: UEFI not found. [0.00] OF: reserved mem: 0x8000..0x8003 (256 KiB) nomap non-reusable mmode_resv1@8000 [0.00] OF: reserved mem: 0x8004..0x8004 (64 KiB) nomap non-reusable mmode_resv0@8004 [0.00] Zone ranges: [0.00] Normal [mem 0x8040-0x87ff] [0.00] Movable zone start for each node [0.00] Early memory node ranges [0.00] node 0: [mem 0x8040-0x87ff] [0.00] Initmem setup node 0 [mem 0x8040-0x87ff] [0.00] On node 0, zone Normal: 1024 pages in unavailable ranges [0.00] SBI HSM extension detected [0.00] riscv: base ISA extensions acdfhim [0.00] riscv: ELF capabilities acdfim [0.00] percpu: Embedded 17 pages/cpu s37728 r8192 d23712 u69632 [0.00] Kernel command line: root=/dev/vda ro console=ttyS0 [0.00] Dentry cache hash table entries: 16384 (order: 4, 65536 bytes, linear) [0.00] Inode-cache hash table entries: 8192 (order: 3, 32768 bytes, linear) [0.00] Built 1 zonelists, mobility grouping on. Total pages: 31465 [0.00] mem auto-init: stack:all(zero), heap alloc:off, heap free:off [0.00] Virtual kernel memory layout: [0.00] fixmap : 0x9c80 - 0x9d00 (8192 kB) [0.00] pci io : 0x9d00 - 0x9e00 ( 16 MB) [0.00] vmemmap : 0x9e00 - 0xa000 ( 32 MB) [0.00] vmalloc : 0xa000 - 0xc000 ( 512 MB) [0.00] lowmem : 0xc000 - 0xc7c0 ( 124 MB) [0.00] Memory: 95700K/126976K available (9090K kernel code, 8845K rwdata, 4096K rodata, 4231K init, 341K bss, 31276K reserved, 0K cma-reserved) ... Welcome to Buildroot buildroot login: root # cat /proc/cpuinfo processor : 0 hart: 0 isa : rv32imafdch_zicbom_zicboz_zicntr_zicsr_zifencei_zihintntl_zihintpause_zihpm_zfa_zba_zbb_zbc_zbs_sstc mmu : sv32 Please provide an Avocado test (i.e. checking /proc/cpuinfo contains "isa : rv32"). See for reference tests/avocado/boot_linux_console.py. Thanks!
[PATCH 0/6] target/riscv: Expose RV32 cpu to RV64 QEMU
From: TANG Tiancheng This patch set aims to expose 32-bit RISC-V cpu to RV64 QEMU. Thus qemu-system-riscv64 can directly boot a RV32 Linux. This patch set has been tested with 6.9.0 Linux Image. - Run RV64 QEMU with RV32 CPU qemu-system-riscv64 -cpu rv32 -M virt -nographic \ -kernel Image \ -append "root=/dev/vda ro console=ttyS0" \ -drive file=rootfs.ext2,format=raw,id=hd0 \ -device virtio-blk-device,drive=hd0 -netdev user,id=net0 \ -device virtio-net-device,netdev=net0 OpenSBI v1.4 QEMU emulator version 9.0.50 (v9.0.0-1132-g7799dc2e3b) [0.00] Linux version 6.9.0 (developer@11109ca35736) (riscv32-unknown-linux-gnu-gcc (gc891d8dc23e-dirty) 13.2.0, GNU ld (GNU Binutils) 2.42) #3 SMP Fri May 31 08:42:15 UTC 2024 [0.00] random: crng init done [0.00] OF: fdt: Ignoring memory range 0x8000 - 0x8040 [0.00] Machine model: riscv-virtio,qemu [0.00] SBI specification v2.0 detected [0.00] SBI implementation ID=0x1 Version=0x10004 [0.00] SBI TIME extension detected [0.00] SBI IPI extension detected [0.00] SBI RFENCE extension detected [0.00] SBI SRST extension detected [0.00] SBI DBCN extension detected [0.00] efi: UEFI not found. [0.00] OF: reserved mem: 0x8000..0x8003 (256 KiB) nomap non-reusable mmode_resv1@8000 [0.00] OF: reserved mem: 0x8004..0x8004 (64 KiB) nomap non-reusable mmode_resv0@8004 [0.00] Zone ranges: [0.00] Normal [mem 0x8040-0x87ff] [0.00] Movable zone start for each node [0.00] Early memory node ranges [0.00] node 0: [mem 0x8040-0x87ff] [0.00] Initmem setup node 0 [mem 0x8040-0x87ff] [0.00] On node 0, zone Normal: 1024 pages in unavailable ranges [0.00] SBI HSM extension detected [0.00] riscv: base ISA extensions acdfhim [0.00] riscv: ELF capabilities acdfim [0.00] percpu: Embedded 17 pages/cpu s37728 r8192 d23712 u69632 [0.00] Kernel command line: root=/dev/vda ro console=ttyS0 [0.00] Dentry cache hash table entries: 16384 (order: 4, 65536 bytes, linear) [0.00] Inode-cache hash table entries: 8192 (order: 3, 32768 bytes, linear) [0.00] Built 1 zonelists, mobility grouping on. Total pages: 31465 [0.00] mem auto-init: stack:all(zero), heap alloc:off, heap free:off [0.00] Virtual kernel memory layout: [0.00] fixmap : 0x9c80 - 0x9d00 (8192 kB) [0.00] pci io : 0x9d00 - 0x9e00 ( 16 MB) [0.00] vmemmap : 0x9e00 - 0xa000 ( 32 MB) [0.00] vmalloc : 0xa000 - 0xc000 ( 512 MB) [0.00] lowmem : 0xc000 - 0xc7c0 ( 124 MB) [0.00] Memory: 95700K/126976K available (9090K kernel code, 8845K rwdata, 4096K rodata, 4231K init, 341K bss, 31276K reserved, 0K cma-reserved) ... Welcome to Buildroot buildroot login: root # cat /proc/cpuinfo processor : 0 hart: 0 isa : rv32imafdch_zicbom_zicboz_zicntr_zicsr_zifencei_zihintntl_zihintpause_zihpm_zfa_zba_zbb_zbc_zbs_sstc mmu : sv32 TANG Tiancheng (6): target/riscv: Add fw_dynamic_info32 for booting RV32 OpenSBI target/riscv: Adjust PMP size for no-MMU RV64 QEMU running RV32 target/riscv: Correct SXL return value for RV32 in RV64 QEMU target/riscv: Detect sxl to set bit width for RV32 in RV64 target/riscv: Correct mcause/scause bit width for RV32 in RV64 QEMU target/riscv: Enable RV32 CPU support in RV64 QEMU configs/targets/riscv64-softmmu.mak | 2 +- hw/riscv/boot.c | 35 +++-- hw/riscv/sifive_u.c | 3 ++- include/hw/riscv/boot.h | 4 +++- include/hw/riscv/boot_opensbi.h | 29 target/riscv/cpu.c | 17 ++ target/riscv/cpu.h | 5 - target/riscv/cpu_helper.c | 23 ++- target/riscv/pmp.c | 2 +- 9 files changed, 93 insertions(+), 27 deletions(-) -- 2.43.0