hw/riscv: virt: Enable booting S-mode firmware from pflash
PATCH 1/1 hw/riscv: virt: Enable booting S-mode firmware from pflash
To boot S-mode firmware payload like EDK2 from persistent flash storage, qemu needs to pass the flash address as the next_addr in fw_dynamic_info to the opensbi.
Update the kernel_entry with the flash address when no kernel is specified via QEMU command line so that opensbi
can jump to the flash address. This assumes flash drive unit 1 is used to keep dynamic payload similar to other architectures.
--- hw/riscv/virt.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
hw/riscv/virt.c +12 -0
@@ -1284,6 +1284,18 @@ static void virt_machine_done(Notifier *notifier, void *data) start_addr = virt_memmap[VIRT_FLASH ].base; } +if (drive_get (IF_PFLASH ,0 ,1 )) { +/* +* Assume second pflash unit (unit=1) to hold the S-mode firmware +* like EDK2. Set kernel_entry to flash address if kernel argument +* is not set and pflash unit 1 is configured. +*/ +if (!kernel_entry) { + kernel_entry = virt_memmap[VIRT_FLASH ].base + + virt_memmap[VIRT_FLASH ].size /2 ; + } + } +/* * Init fw_cfg. Must be done before riscv_load_fdt, otherwise the device * tree cannot be altered and we get FDT_ERR_NOSPACE.
Signature · 1 line
2.25.1
Quoted 41 lines · Sunil V L
To boot S-mode firmware payload like EDK2 from persistent flash storage, qemu needs to pass the flash address as the
next_addrinfw_dynamic_infoto the opensbi.Update the
kernel_entrywith the flash address when no kernel is specified via QEMU command line so that opensbi
can jump to the flash address. This assumes flash drive unit 1 is used to keep dynamic payload similar to other architectures.Signed-off-by Sunil V L <[email protected]>--- hw/riscv/virt.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)hw/riscv/virt.c +12
-0@@ -1284,6 +1284,18 @@ static void virt_machine_done(Notifier *notifier, void *data) start_addr = virt_memmap[VIRT_FLASH ].base; } +if (drive_get (IF_PFLASH ,0 ,1 )) { +/* +* Assume second pflash unit (unit=1) to hold the S-mode firmware +* like EDK2. Set kernel_entry to flash address if kernel argument +* is not set and pflash unit 1 is configured. +*/ +if (!kernel_entry) { + kernel_entry = virt_memmap[VIRT_FLASH ].base + + virt_memmap[VIRT_FLASH ].size /2 ; + } + } +/* * Init fw_cfg. Must be done before riscv_load_fdt, otherwise the device * tree cannot be altered and we get FDT_ERR_NOSPACE. Signature · 1 line
2.25.1
Hi Sunil,
We should ensure we can use both edk2 and the '-kernel' option. For example, guest installation will typically do direct kernel boot, and when it's desired / necessary to boot that kernel with ACPI, then we'll also need edk2.
Thanks,
drew
Quoted 45 lines · Andrew Jones
Quoted 41 lines · Sunil V L
To boot S-mode firmware payload like EDK2 from persistent flash storage, qemu needs to pass the flash address as the
next_addrinfw_dynamic_infoto the opensbi.Update the
kernel_entrywith the flash address when no kernel is specified via QEMU command line so that opensbi
can jump to the flash address. This assumes flash drive unit 1 is used to keep dynamic payload similar to other architectures.Signed-off-by Sunil V L <[email protected]>--- hw/riscv/virt.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)hw/riscv/virt.c +12
-0@@ -1284,6 +1284,18 @@ static void virt_machine_done(Notifier *notifier, void *data) start_addr = virt_memmap[VIRT_FLASH ].base; } +if (drive_get (IF_PFLASH ,0 ,1 )) { +/* +* Assume second pflash unit (unit=1) to hold the S-mode firmware +* like EDK2. Set kernel_entry to flash address if kernel argument +* is not set and pflash unit 1 is configured. +*/ +if (!kernel_entry) { + kernel_entry = virt_memmap[VIRT_FLASH ].base + + virt_memmap[VIRT_FLASH ].size /2 ; + } + } +/* * Init fw_cfg. Must be done before riscv_load_fdt, otherwise the device * tree cannot be altered and we get FDT_ERR_NOSPACE. Signature · 1 line
2.25.1Hi Sunil,
Quoted 4 lines
We should ensure we can use both edk2 and the '-kernel' option. For example, guest installation will typically do direct kernel boot, and when it's desired / necessary to boot that kernel with ACPI, then we'll also need edk2.
Thank you very much, Drew. Let me revise the patch and send.
Thanks
Sunil
Quoted 3 lines
Thanks,
drew