[PATCH v1 0/4] Allow loading a no MMU kernel

Alistair Francis posted 4 patches 3 years, 7 months ago
Test FreeBSD passed
Test docker-mingw@fedora passed
Test checkpatch passed
Test docker-quick@centos7 passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/cover.1601652616.git.alistair.francis@wdc.com
Maintainers: Sagar Karandikar <sagark@eecs.berkeley.edu>, Palmer Dabbelt <palmer@dabbelt.com>, Bastian Koppelmann <kbastian@mail.uni-paderborn.de>, Alistair Francis <Alistair.Francis@wdc.com>
There is a newer version of this series
include/hw/riscv/boot.h     | 11 +++++----
include/hw/riscv/sifive_u.h |  1 +
hw/riscv/boot.c             | 47 ++++++++++++++++++++++++-------------
hw/riscv/opentitan.c        |  3 ++-
hw/riscv/sifive_e.c         |  3 ++-
hw/riscv/sifive_u.c         | 31 ++++++++++++++++++------
hw/riscv/spike.c            | 14 ++++++++---
hw/riscv/virt.c             | 14 ++++++++---
8 files changed, 89 insertions(+), 35 deletions(-)
[PATCH v1 0/4] Allow loading a no MMU kernel
Posted by Alistair Francis 3 years, 7 months ago
This series allows loading a noMMU kernel using the -kernel option.
Currently if using -kernel QEMU assumes you also have firmware and loads
the kernel at a hardcoded offset. This series changes that so we only
load the kernel at an offset if a firmware (-bios) was loaded.

This series also adds a function to check if the CPU is 32-bit. This is
a step towards running 32-bit and 64-bit CPUs on the 64-bit RISC-V build
by using run time checks instead of compile time checks. We also allow
the user to sepcify a CPU for the sifive_u machine.

Alistair Francis (4):
  hw/riscv: sifive_u: Allow specifying the CPU
  hw/riscv: Return the end address of the loaded firmware
  hw/riscv: Add a riscv_is_32_bit() function
  hw/riscv: Load the kernel after the firmware

 include/hw/riscv/boot.h     | 11 +++++----
 include/hw/riscv/sifive_u.h |  1 +
 hw/riscv/boot.c             | 47 ++++++++++++++++++++++++-------------
 hw/riscv/opentitan.c        |  3 ++-
 hw/riscv/sifive_e.c         |  3 ++-
 hw/riscv/sifive_u.c         | 31 ++++++++++++++++++------
 hw/riscv/spike.c            | 14 ++++++++---
 hw/riscv/virt.c             | 14 ++++++++---
 8 files changed, 89 insertions(+), 35 deletions(-)

-- 
2.28.0


Re: [PATCH v1 0/4] Allow loading a no MMU kernel
Posted by Bin Meng 3 years, 7 months ago
Hi Alistair,

On Fri, Oct 2, 2020 at 11:50 PM Alistair Francis
<alistair.francis@wdc.com> wrote:
>
> This series allows loading a noMMU kernel using the -kernel option.
> Currently if using -kernel QEMU assumes you also have firmware and loads
> the kernel at a hardcoded offset. This series changes that so we only
> load the kernel at an offset if a firmware (-bios) was loaded.
>
> This series also adds a function to check if the CPU is 32-bit. This is
> a step towards running 32-bit and 64-bit CPUs on the 64-bit RISC-V build
> by using run time checks instead of compile time checks. We also allow
> the user to sepcify a CPU for the sifive_u machine.

Could you please provide test scenarios for this series? I want to
have a try. Thanks.

>
> Alistair Francis (4):
>   hw/riscv: sifive_u: Allow specifying the CPU
>   hw/riscv: Return the end address of the loaded firmware
>   hw/riscv: Add a riscv_is_32_bit() function
>   hw/riscv: Load the kernel after the firmware
>
>  include/hw/riscv/boot.h     | 11 +++++----
>  include/hw/riscv/sifive_u.h |  1 +
>  hw/riscv/boot.c             | 47 ++++++++++++++++++++++++-------------
>  hw/riscv/opentitan.c        |  3 ++-
>  hw/riscv/sifive_e.c         |  3 ++-
>  hw/riscv/sifive_u.c         | 31 ++++++++++++++++++------
>  hw/riscv/spike.c            | 14 ++++++++---
>  hw/riscv/virt.c             | 14 ++++++++---
>  8 files changed, 89 insertions(+), 35 deletions(-)

Regards,
Bin

Re: [PATCH v1 0/4] Allow loading a no MMU kernel
Posted by Alistair Francis 3 years, 7 months ago
On Fri, Oct 9, 2020 at 2:53 AM Bin Meng <bmeng.cn@gmail.com> wrote:
>
> Hi Alistair,
>
> On Fri, Oct 2, 2020 at 11:50 PM Alistair Francis
> <alistair.francis@wdc.com> wrote:
> >
> > This series allows loading a noMMU kernel using the -kernel option.
> > Currently if using -kernel QEMU assumes you also have firmware and loads
> > the kernel at a hardcoded offset. This series changes that so we only
> > load the kernel at an offset if a firmware (-bios) was loaded.
> >
> > This series also adds a function to check if the CPU is 32-bit. This is
> > a step towards running 32-bit and 64-bit CPUs on the 64-bit RISC-V build
> > by using run time checks instead of compile time checks. We also allow
> > the user to sepcify a CPU for the sifive_u machine.
>
> Could you please provide test scenarios for this series? I want to
> have a try. Thanks.

Yep.

Build a noMMU kernel (you need the latest master commit a78c6f5956a9):
$ CROSS_COMPILE=riscv64-elf- ARCH=riscv make nommu_virt_defconfig
$ CROSS_COMPILE=riscv64-elf- ARCH=riscv make -j

Build a noMMU RISC-V userspace
$ git clonehttps://github.com/damien-lemoal/buildroot.git
$ make kendryte_k210_defconfig
$ make

Run QEMU:
./build/riscv64-softmmu/qemu-system-riscv64 -machine virt -m 64M \
-cpu rv64,mmu=false \
-serial mon:stdio -serial null -nographic \
-append "root=/dev/vda rw highres=off  console=ttyS0 mem=1G ip=dhcp
earlycon=sbi" \
-device virtio-net-device,netdev=net0,mac=52:54:00:12:34:02 -netdev
user,id=net0 \
-object rng-random,filename=/dev/urandom,id=rng0 -device
virtio-rng-device,rng=rng0 \
-smp 1 -d guest_errors \
-kernel ./Image \
-drive id=disk0,file=./nommu-rootfs.ext2,if=none,format=raw -device
virtio-blk-device,drive=disk0 -bios none

Alistair

>
> >
> > Alistair Francis (4):
> >   hw/riscv: sifive_u: Allow specifying the CPU
> >   hw/riscv: Return the end address of the loaded firmware
> >   hw/riscv: Add a riscv_is_32_bit() function
> >   hw/riscv: Load the kernel after the firmware
> >
> >  include/hw/riscv/boot.h     | 11 +++++----
> >  include/hw/riscv/sifive_u.h |  1 +
> >  hw/riscv/boot.c             | 47 ++++++++++++++++++++++++-------------
> >  hw/riscv/opentitan.c        |  3 ++-
> >  hw/riscv/sifive_e.c         |  3 ++-
> >  hw/riscv/sifive_u.c         | 31 ++++++++++++++++++------
> >  hw/riscv/spike.c            | 14 ++++++++---
> >  hw/riscv/virt.c             | 14 ++++++++---
> >  8 files changed, 89 insertions(+), 35 deletions(-)
>
> Regards,
> Bin