All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
To: qemu-devel@nongnu.org
Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com,
	philmd@linaro.org,
	Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Subject: [PATCH v2 1/6] hw/riscv/boot.c: calculate fdt size after fdt_pack()
Date: Mon, 16 Jan 2023 14:34:15 -0300	[thread overview]
Message-ID: <20230116173420.1146808-2-dbarboza@ventanamicro.com> (raw)
In-Reply-To: <20230116173420.1146808-1-dbarboza@ventanamicro.com>

fdt_pack() can change the fdt size, meaning that fdt_totalsize() can
contain a now deprecated (bigger) value.

Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
---
 hw/riscv/boot.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/hw/riscv/boot.c b/hw/riscv/boot.c
index 2594276223..dc14d8cd14 100644
--- a/hw/riscv/boot.c
+++ b/hw/riscv/boot.c
@@ -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);
-- 
2.39.0



  reply	other threads:[~2023-01-16 17:34 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-16 17:34 [PATCH v2 0/6] riscv: fdt related cleanups Daniel Henrique Barboza
2023-01-16 17:34 ` Daniel Henrique Barboza [this message]
2023-01-19  0:36   ` [PATCH v2 1/6] hw/riscv/boot.c: calculate fdt size after fdt_pack() Alistair Francis
2023-01-16 17:34 ` [PATCH v2 2/6] hw/riscv: split fdt address calculation from fdt load Daniel Henrique Barboza
2023-01-19  2:13   ` Alistair Francis
2023-01-16 17:34 ` [PATCH v2 3/6] hw/riscv: simplify riscv_compute_fdt_addr() Daniel Henrique Barboza
2023-01-19  2:23   ` Alistair Francis
2023-01-19 13:00     ` Daniel Henrique Barboza
2023-01-19 16:47     ` Daniel Henrique Barboza
2023-01-16 17:34 ` [PATCH v2 4/6] hw/riscv/virt.c: calculate socket count once in create_fdt_imsic() Daniel Henrique Barboza
2023-01-19  2:15   ` Alistair Francis
2023-01-16 17:34 ` [PATCH v2 5/6] hw/riscv/virt.c: rename MachineState 'mc' pointers to 'ms' Daniel Henrique Barboza
2023-01-19  2:16   ` Alistair Francis
2023-01-16 17:34 ` [PATCH v2 6/6] hw/riscv/spike.c: rename MachineState 'mc' pointers to' ms' Daniel Henrique Barboza
2023-01-19  2:16   ` Alistair Francis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230116173420.1146808-2-dbarboza@ventanamicro.com \
    --to=dbarboza@ventanamicro.com \
    --cc=alistair.francis@wdc.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.