Skip to content

RFC RISC-V: Add firmware loading support and default

Alistair Francis qemu-devel qemu-riscv 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest5 patches 24 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5hw/riscv: Split out the boot functionshw/riscv/Makefile.objs hw/riscv/boot.c hw/riscv/sifive_e.c +4 more+110 -932 replies
2/5hw/riscv: Add support for loading a firmwarehw/riscv/boot.c hw/riscv/sifive_e.c hw/riscv/sifive_u.c +3 more+57 -94 replies
3/5hw/riscv: Extend the kernel loading supporthw/riscv/boot.c+14 -53 replies
4/5roms: Add OpenSBI version 0.3.gitmodules Makefile configure +4 more+24 -15 replies
5/5hw/riscv: Load OpenSBI as the default firmwarehw/riscv/boot.c hw/riscv/sifive_u.c hw/riscv/virt.c +1 more+31 -61 reply

Reviews trailers per patch

1 of 5 patches has a Reviewed-by or Acked-by.

PatchBin Meng
1/5R-b T-b
2/5
3/5
4/5
5/5

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [Qemu-devel] [RFC v1 0/5] RISC-V: Add firmware loading support and default

This is an RFC as it will break ALL current users! See below for details.

This series consolidates the current RISC-V kernel loading impelementation while also adding support for the -bios option and more advanced kernel image types.

After consolidating the kernel loading we can extend the boot loader to support a -bios option. We can also extend the kernel loading options to support not just ELF files but other standard formats.

Finally we can include the OpenSBI firmware by default for QEMU users.

At the end of this series we are in the good place of no longer requiring users to build firmware to boot a kernel. Instead users can just run QEMu with the -kernel option and everything will work. They can also override the firmware with their own using the -bios option. Using "-bios none" will result in no firmware being loaded (as it is today).

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Unfortunately this series (patch 5 specifically) results in all current Linux boots being broken as users are already loading in their own firmware, which overlaps with the now included default. They will see this error:

rom: requested regions overlap (rom phdr #0: ./images/qemuriscv64/fw_jump.elf. free=0x0000000080008090, addr=0x0000000080000000)
qemu-system-riscv64: rom check and register reset failed

If a current user specieifies "-bios none" their flow will continue working. A user can instead no longer load their firmware and use the default or they can load their firmware with the -bios option.

At the moment the best idea I have to not break all users is to only include the default firmware if the user specifies "-bios opensbi". That is change the default to not loading the firmware. Then we can work on updating documentation and maybe in future change the default to include a firmware and anyone who doesn't want a default firmware can specify "-bios none".

Any other ideas on how to not break everything?

Alistair Francis (5):
hw/riscv: Split out the boot functions
hw/riscv: Add support for loading a firmware
hw/riscv: Extend the kernel loading support
roms: Add OpenSBI version 0.3
hw/riscv: Load OpenSBI as the default firmware

 .gitmodules                         |   3 +
 Makefile                            |   3 +-
 configure                           |   1 +
 hw/riscv/Makefile.objs              |   1 +
 hw/riscv/boot.c                     | 143 ++++++++++++++++++++++++++++
 hw/riscv/sifive_e.c                 |  17 +---
 hw/riscv/sifive_u.c                 |  19 +---
 hw/riscv/spike.c                    |  21 +---
 hw/riscv/virt.c                     |  54 ++---------
 include/hw/riscv/boot.h             |  30 ++++++
 pc-bios/opensbi-riscv32-fw_jump.elf | Bin 0 -> 197988 bytes
 pc-bios/opensbi-riscv64-fw_jump.elf | Bin 0 -> 200192 bytes
 roms/Makefile                       |  17 ++++
 roms/opensbi                        |   1 +
 14 files changed, 216 insertions(+), 94 deletions(-)
 create mode 100644 hw/riscv/boot.c
 create mode 100644 include/hw/riscv/boot.h
 create mode 100644 pc-bios/opensbi-riscv32-fw_jump.elf
 create mode 100644 pc-bios/opensbi-riscv64-fw_jump.elf
 create mode 160000 roms/opensbi
Signature · 1 line
2.22.0