hw/arm/boot: load device tree to base of DRAM if no -kernel option was passed
PATCH 1/1 hw/arm/boot: load device tree to base of DRAM if no -kernel option was passed
If we are running the 'virt' machine, we may have a device tree blob but no kernel to supply it to if no -kernel option was passed. In that case, copy it to the base of DRAM where it can be picked up by a bootloader executing from NOR flash.
--- hw/arm/boot.c | 8 ++++++++ 1 file changed, 8 insertions(+)
hw/arm/boot.c +8 -0
@@ -455,6 +455,14 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)/* Load the kernel. */ if (!info->kernel_filename) { +/* +* If we have a device tree blob, but no kernel to supply it to, copy it +* to the base of DRAM for a bootloader executing from NOR flash to +* pick up. +*/ +if (have_dtb (info)) +load_dtb (info->loader_start, info); +/* If no kernel specified, do nothing; we will start from address 0 * (typically a boot ROM image) in the same way as hardware. */
Signature · 1 line
1.8.3.2
Quoted 6 lines · Ard Biesheuvel
If we are running the 'virt' machine, we may have a device tree blob but no kernel to supply it to if no -kernel option was passed. In that case, copy it to the base of DRAM where it can be picked up by a bootloader executing from NOR flash.
Signed-off-by Ard Biesheuvel <[email protected]>
In general I like this approach for providing a BIOS/bootloader with information about the platform it's running on. (For the benefit of readers who may be missing context, this bootloader is likely to be UEFI.) Since we already have DTB for telling the guest about the shape of the platform this makes more sense to me than having a separate fw_cfg style interface to repeat the same information.
I should dig out the NOR-flash-in-virt patches and get them through review/commit so this code has a more immediately obvious purpose.
A couple of style nits below.
Quoted 9 lines
--- hw/arm/boot.c | 8 ++++++++ 1 file changed, 8 insertions(+)hw/arm/boot.c +0
-0
hw/arm/boot.c void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) · line 464
Quoted 10 lines
hw/arm/boot.c +7
-0@@ -455,6 +455,14 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)/* Load the kernel. */ if (!info->kernel_filename) { +/* +* If we have a device tree blob, but no kernel to supply it to, copy it +* to the base of DRAM for a bootloader executing from NOR flash to +* pick up. +*/ +if (have_dtb (info)) +load_dtb (info->loader_start, info);
Our coding style demands braces even on single-statement if()s. Also, we should check the return value from load_dtb() and exit(1) on failure (compare the existing callsite).
hw/arm/boot.c void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) · line 468
Quoted 4 lines
hw/arm/boot.c +1
-0+/* If no kernel specified, do nothing; we will start from address 0 * (typically a boot ROM image) in the same way as hardware. */
A style nit so minuscule I wouldn't point it out if you weren't going to reroll this patch anyway: notice how this comment differs from yours slightly in style...
Quoted 2 lines
--
1.8.3.2
thanks
-- PMM
Quoted 8 lines · Peter Maydell
Quoted 6 lines · Ard Biesheuvel
If we are running the 'virt' machine, we may have a device tree blob but no kernel to supply it to if no -kernel option was passed. In that case, copy it to the base of DRAM where it can be picked up by a bootloader executing from NOR flash.
Signed-off-by Ard Biesheuvel <[email protected]>
Quoted 8 lines
In general I like this approach for providing a BIOS/bootloader with information about the platform it's running on. (For the benefit of readers who may be missing context, this bootloader is likely to be UEFI.) Since we already have DTB for telling the guest about the shape of the platform this makes more sense to me than having a separate
fw_cfgstyle interface to repeat the same information.
I agree. But perhaps we should address the reset issue we discussed over IRC last Friday?
Currently, reset does not work at all when using -bios (and your patch), but we should fix that in a sane way, i.e., the DTB should be reloaded into DRAM, and this patch currently does not cover that.
Quoted 16 lines
I should dig out the NOR-flash-in-virt patches and get them through review/commit so this code has a more immediately obvious purpose.
A couple of style nits below.
Quoted 10 lines
--- hw/arm/boot.c | 8 ++++++++ 1 file changed, 8 insertions(+)hw/arm/boot.c +0
-0@@ -455,6 +455,14 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)
Quoted 14 lines
hw/arm/boot.c void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) · line 464
Quoted 9 lines
hw/arm/boot.c +7
-0/* Load the kernel. */ if (!info->kernel_filename) { +/* +* If we have a device tree blob, but no kernel to supply it to, copy it +* to the base of DRAM for a bootloader executing from NOR flash to +* pick up. +*/ +if (have_dtb (info)) +load_dtb (info->loader_start, info);Our coding style demands braces even on single-statement if()s. Also, we should check the return value from
load_dtb()and exit(1) on failure (compare the existing callsite).
OK
Quoted 9 lines
hw/arm/boot.c void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) · line 468
Quoted 4 lines
hw/arm/boot.c +1
-0+/* If no kernel specified, do nothing; we will start from address 0 * (typically a boot ROM image) in the same way as hardware. */ A style nit so minuscule I wouldn't point it out if you weren't going to reroll this patch anyway: notice how this comment differs from yours slightly in style...
OK
Quoted 5 lines
Quoted 2 lines
--
1.8.3.2thanks
-- PMM
Quoted 18 lines · Ard Biesheuvel
Quoted 8 lines · Peter Maydell
Quoted 6 lines · Ard Biesheuvel
If we are running the 'virt' machine, we may have a device tree blob but no kernel to supply it to if no -kernel option was passed. In that case, copy it to the base of DRAM where it can be picked up by a bootloader executing from NOR flash.
Signed-off-by Ard Biesheuvel <[email protected]>Quoted 8 lines
In general I like this approach for providing a BIOS/bootloader with information about the platform it's running on. (For the benefit of readers who may be missing context, this bootloader is likely to be UEFI.) Since we already have DTB for telling the guest about the shape of the platform this makes more sense to me than having a separate
fw_cfgstyle interface to repeat the same information.
Quoted 2 lines
I agree. But perhaps we should address the reset issue we discussed over IRC last Friday?
Also true; I thought about mentioning those but decided they were orthogonal. We should probably pull together a list of all the UEFI related QEMU patches and required work.
Quoted 3 lines
Currently, reset does not work at all when using -bios (and your patch), but we should fix that in a sane way, i.e., the DTB should be reloaded into DRAM, and this patch currently does not cover that.
Yep. That's also a bug with the -kernel support, though:
currently we rely on the guest kernel never writing over the dtb we pass it since we don't reinstate it on reset...
thanks
-- PMM
Quoted 19 lines · Peter Maydell
Quoted 18 lines · Ard Biesheuvel
Quoted 16 lines · Peter Maydell
Quoted 6 lines · Ard Biesheuvel
If we are running the 'virt' machine, we may have a device tree blob but no kernel to supply it to if no -kernel option was passed. In that case, copy it to the base of DRAM where it can be picked up by a bootloader executing from NOR flash.
Signed-off-by Ard Biesheuvel <[email protected]>In general I like this approach for providing a BIOS/bootloader with information about the platform it's running on. (For the benefit of readers who may be missing context, this bootloader is likely to be UEFI.) Since we already have DTB for telling the guest about the shape of the platform this makes more sense to me than having a separate
fw_cfgstyle interface to repeat the same information.
Quoted 7 lines
Quoted 2 lines
I agree. But perhaps we should address the reset issue we discussed over IRC last Friday?
Also true; I thought about mentioning those but decided they were orthogonal. We should probably pull together a list of all the UEFI related QEMU patches and required work.
By orthogonal, do you mean this bit still belongs in arm_load_kernel(), and the reset handling should be adapted to call arm_load_kernel() again in its entirety?
Quoted 10 lines
Quoted 3 lines
Currently, reset does not work at all when using -bios (and your patch), but we should fix that in a sane way, i.e., the DTB should be reloaded into DRAM, and this patch currently does not cover that.
Yep. That's also a bug with the -kernel support, though:
currently we rely on the guest kernel never writing over the dtb we pass it since we don't reinstate it on reset...thanks
-- PMM
Quoted 8 lines · Ard Biesheuvel
Quoted 3 lines · Peter Maydell
Also true; I thought about mentioning those but decided they were orthogonal. We should probably pull together a list of all the UEFI related QEMU patches and required work.
By orthogonal, do you mean this bit still belongs in
arm_load_kernel(), and the reset handling should be adapted to callarm_load_kernel()again in its entirety?
I mean I think this bit is fine, that load_dtb() should put the DTB in a rom-blob, and that then there's no need to do anything on reset because the rom-blob's reset handling does it for us. (As I say, this also gets us correct handling of the DTB on reset in the -kernel case too.)
-- PMM