qemu-e2k/hw/riscv
Jessica Clarke 7e322a7f23 hw/riscv: Use load address rather than entry point for fw_dynamic next_addr
The original BBL boot method had the kernel embedded as an opaque blob
that was blindly jumped to, which OpenSBI implemented as fw_payload.
OpenSBI then implemented fw_jump, which allows the payload to be loaded
elsewhere, but still blindly jumps to a fixed address at which the
kernel is to be loaded. Finally, OpenSBI introduced fw_dynamic, which
allows the previous stage to inform it where to jump to, rather than
having to blindly guess like fw_jump, or embed the payload as part of
the build like fw_payload. When used with an opaque binary (i.e. the
output of objcopy -O binary), it matches the behaviour of the previous
methods. However, when used with an ELF, QEMU currently passes on the
ELF's entry point address, which causes a discrepancy compared with all
the other boot methods if that entry point is not the first instruction
in the binary.

This difference specific to fw_dynamic with an ELF is not apparent when
booting Linux, since its entry point is the first instruction in the
binary. However, FreeBSD has a separate ELF entry point, following the
calling convention used by its bootloader, that differs from the first
instruction in the binary, used for the legacy SBI entry point, and so
the specific combination of QEMU's default fw_dynamic firmware with
booting FreeBSD as an ELF rather than a raw binary does not work.

Thus, align the behaviour when loading an ELF with the behaviour when
loading a raw binary; namely, use the base address of the loaded kernel
in place of the entry point.

The uImage code is left as-is in using the U-Boot header's entry point,
since the calling convention for that entry point is the same as the SBI
one and it mirrors what U-Boot will do.

Signed-off-by: Jessica Clarke <jrtc27@jrtc27.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Message-Id: <20211214032456.70203-1-jrtc27@jrtc27.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
2021-12-20 14:53:31 +10:00
..
boot.c hw/riscv: Use load address rather than entry point for fw_dynamic next_addr 2021-12-20 14:53:31 +10:00
Kconfig
meson.build
microchip_pfsoc.c hw: Replace trivial drive_get_next() by drive_get() 2021-12-15 08:38:16 +01:00
numa.c
opentitan.c hw/riscv: opentitan: Fixup the PLIC context addresses 2021-10-28 14:39:23 +10:00
riscv_hart.c
shakti_c.c
sifive_e.c
sifive_u.c hw: Replace trivial drive_get_next() by drive_get() 2021-12-15 08:38:16 +01:00
spike.c hw/riscv: spike: Use MachineState::ram and MachineClass::default_ram_id 2021-10-22 23:35:47 +10:00
virt.c hw/riscv: virt: Use the PLIC config helper function 2021-10-28 14:39:23 +10:00