move create_fw_cfg() to init() (Gitlab #1343)
cover move create_fw_cfg() to init() (Gitlab #1343)
Hi,
This patch fixes a regression introduced with 1c20d3ff6004 ("hw/riscv:
virt: Add a machine done notifier") that is preventing qemu-system-riscv64 to use the ramfb device starting in QEMU 7.1.
Fix is based on top of Alistair's riscv-to-apply.next:
https://github.com/alistair23/qemu/tree/riscv-to-apply.next
Daniel Henrique Barboza (1):
hw/riscv/virt.c: move create_fw_cfg() back to virt_machine_init()
hw/riscv/virt.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
Signature · 1 line
2.39.0
PATCH 1/1 hw/riscv/virt.c: move create_fw_cfg() back to virt_machine_init()
Commit 1c20d3ff6004 ("hw/riscv: virt: Add a machine done notifier") moved the initialization of fw_cfg to the virt_machine_done() callback.
Problem is that the validation of fw_cfg by devices such as ramfb is done before the machine done notifier is called. Moving create_fw_cfg() to machine_done() results in QEMU failing to boot when using a ramfb device:
./qemu-system-riscv64 -machine virt -device ramfb -serial stdio
qemu-system-riscv64: -device ramfb: ramfb device requires fw_cfg with DMA
The fix is simple: move create_fw_cfg() config back to virt_machine_init(). This happens to be the same way the ARM 'virt' machine deals with fw_cfg (see machvirt_init() and virt_machine_done() in hw/arm/virt.c), so we're keeping consistency with how other machines handle this device.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1343
--- hw/riscv/virt.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
hw/riscv/virt.c +7 -7
@@ -1254,13 +1254,6 @@ static void virt_machine_done(Notifier *notifier, void *data) firmware_end_addr =riscv_find_and_load_firmware (machine, firmware_name, start_addr,NULL ); -/* -* Init fw_cfg. Must be done before riscv_load_fdt, otherwise the device -* tree cannot be altered and we get FDT_ERR_NOSPACE. -*/ - s->fw_cfg =create_fw_cfg (machine); -rom_set_fw (s->fw_cfg); -if (drive_get (IF_PFLASH ,0 ,1 )) {/* * S-mode FW like EDK2 will be kept in second plash (unit 1).
@@ -1468,6 +1461,13 @@ static void virt_machine_init(MachineState *machine)memory_region_add_subregion (system_memory, memmap[VIRT_MROM ].base, mask_rom); +/* +* Init fw_cfg. Must be done before riscv_load_fdt, otherwise the +* device tree cannot be altered and we get FDT_ERR_NOSPACE. +*/ + s->fw_cfg =create_fw_cfg (machine); +rom_set_fw (s->fw_cfg); +/* SiFive Test MMIO device */ sifive_test_create (memmap[VIRT_TEST ].base);
Signature · 1 line
2.39.0
Re: [PATCH 1/1] hw/riscv/virt.c: move create_fw_cfg() back to virt_machine_init()
Quoted 12 lines · Daniel Henrique Barboza
Commit
1c20d3ff6004("hw/riscv: virt: Add a machine done notifier") moved the initialization offw_cfgto thevirt_machine_done()callback.Problem is that the validation of
fw_cfgby devices such as ramfb is done before the machine done notifier is called. Movingcreate_fw_cfg()tomachine_done()results in QEMU failing to boot when using a ramfb device:./qemu-system-riscv64 -machine virt -device ramfb -serial stdio
qemu-system-riscv64: -device ramfb: ramfb device requiresfw_cfgwith DMA
Quoted 8 lines
The fix is simple: move
create_fw_cfg()config back tovirt_machine_init(). This happens to be the same way the ARM 'virt' machine deals withfw_cfg(seemachvirt_init()andvirt_machine_done()inhw/arm/virt.c), so we're keeping consistency with how other machines handle this device.Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1343
Signed-off-by Daniel Henrique Barboza <[email protected]>
Thanks for the fix!
Alistair
Quoted 40 lines
--- hw/riscv/virt.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)hw/riscv/virt.c +7
-8@@ -1254,13 +1254,6 @@ static void virt_machine_done(Notifier *notifier, void *data) firmware_end_addr =riscv_find_and_load_firmware (machine, firmware_name, start_addr,NULL ); -/* -* Init fw_cfg. Must be done before riscv_load_fdt, otherwise the device -* tree cannot be altered and we get FDT_ERR_NOSPACE. -*/ - s->fw_cfg =create_fw_cfg (machine); -rom_set_fw (s->fw_cfg); -if (drive_get (IF_PFLASH ,0 ,1 )) {/* * S-mode FW like EDK2 will be kept in second plash (unit 1). @@ -1468,6 +1461,13 @@ static void virt_machine_init(MachineState *machine)memory_region_add_subregion (system_memory, memmap[VIRT_MROM ].base, mask_rom); +/* +* Init fw_cfg. Must be done before riscv_load_fdt, otherwise the +* device tree cannot be altered and we get FDT_ERR_NOSPACE. +*/ + s->fw_cfg =create_fw_cfg (machine); +rom_set_fw (s->fw_cfg); +/* SiFive Test MMIO device */ sifive_test_create (memmap[VIRT_TEST ].base); --2.39.0
Alistair Francis
AppliedRe: [PATCH 1/1] hw/riscv/virt.c: move create_fw_cfg() back to virt_machine_init()
In reply to Daniel Henrique BarbozaQuoted 12 lines · Daniel Henrique Barboza
Commit
1c20d3ff6004("hw/riscv: virt: Add a machine done notifier") moved the initialization offw_cfgto thevirt_machine_done()callback.Problem is that the validation of
fw_cfgby devices such as ramfb is done before the machine done notifier is called. Movingcreate_fw_cfg()tomachine_done()results in QEMU failing to boot when using a ramfb device:./qemu-system-riscv64 -machine virt -device ramfb -serial stdio
qemu-system-riscv64: -device ramfb: ramfb device requiresfw_cfgwith DMA
Quoted 8 lines
The fix is simple: move
create_fw_cfg()config back tovirt_machine_init(). This happens to be the same way the ARM 'virt' machine deals withfw_cfg(seemachvirt_init()andvirt_machine_done()inhw/arm/virt.c), so we're keeping consistency with how other machines handle this device.Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1343
Signed-off-by Daniel Henrique Barboza <[email protected]>
Thanks!
Applied to riscv-to-apply.next
Alistair
Quoted 40 lines
--- hw/riscv/virt.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)hw/riscv/virt.c +7
-8@@ -1254,13 +1254,6 @@ static void virt_machine_done(Notifier *notifier, void *data) firmware_end_addr =riscv_find_and_load_firmware (machine, firmware_name, start_addr,NULL ); -/* -* Init fw_cfg. Must be done before riscv_load_fdt, otherwise the device -* tree cannot be altered and we get FDT_ERR_NOSPACE. -*/ - s->fw_cfg =create_fw_cfg (machine); -rom_set_fw (s->fw_cfg); -if (drive_get (IF_PFLASH ,0 ,1 )) {/* * S-mode FW like EDK2 will be kept in second plash (unit 1). @@ -1468,6 +1461,13 @@ static void virt_machine_init(MachineState *machine)memory_region_add_subregion (system_memory, memmap[VIRT_MROM ].base, mask_rom); +/* +* Init fw_cfg. Must be done before riscv_load_fdt, otherwise the +* device tree cannot be altered and we get FDT_ERR_NOSPACE. +*/ + s->fw_cfg =create_fw_cfg (machine); +rom_set_fw (s->fw_cfg); +/* SiFive Test MMIO device */ sifive_test_create (memmap[VIRT_TEST ].base); --2.39.0