hw/riscv/boot.c: calculate fdt size after fdt_pack()
fdt_pack() can change the fdt size, meaning that fdt_totalsize() can contain a now deprecated (bigger) value. Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> Message-Id: <20230201171212.1219375-2-dbarboza@ventanamicro.com> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
This commit is contained in:
parent
26934f9a95
commit
909f7da604
|
@ -253,8 +253,13 @@ uint64_t riscv_load_fdt(hwaddr dram_base, uint64_t mem_size, void *fdt)
|
|||
{
|
||||
uint64_t temp, fdt_addr;
|
||||
hwaddr dram_end = dram_base + mem_size;
|
||||
int ret, fdtsize = fdt_totalsize(fdt);
|
||||
int ret = fdt_pack(fdt);
|
||||
int fdtsize;
|
||||
|
||||
/* Should only fail if we've built a corrupted tree */
|
||||
g_assert(ret == 0);
|
||||
|
||||
fdtsize = fdt_totalsize(fdt);
|
||||
if (fdtsize <= 0) {
|
||||
error_report("invalid device-tree");
|
||||
exit(1);
|
||||
|
@ -269,9 +274,6 @@ uint64_t riscv_load_fdt(hwaddr dram_base, uint64_t mem_size, void *fdt)
|
|||
temp = (dram_base < 3072 * MiB) ? MIN(dram_end, 3072 * MiB) : dram_end;
|
||||
fdt_addr = QEMU_ALIGN_DOWN(temp - fdtsize, 2 * MiB);
|
||||
|
||||
ret = fdt_pack(fdt);
|
||||
/* Should only fail if we've built a corrupted tree */
|
||||
g_assert(ret == 0);
|
||||
/* copy in the device tree */
|
||||
qemu_fdt_dumpdtb(fdt, fdtsize);
|
||||
|
||||
|
|
Loading…
Reference in New Issue