public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] fdt_resize(): fix actualsize calculations with unaligned blobs
@ 2009-01-14 12:52 Peter Korsgaard
  2009-01-17 18:19 ` Jerry Van Baren
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Korsgaard @ 2009-01-14 12:52 UTC (permalink / raw)
  To: u-boot

The code in fdt_resize() to extend the fdt size to end on a page boundary
is wrong for fdt's not located at an address aligned on a page boundary.
What's even worse, the code would make actualsize shrink rather than grow
if (blob & 0xfff) was bigger than the amount of padding added by ALIGN(),
causing fdt_add_mem_rsv to fail.

Fix it by aligning end address (blob + size) to a page boundary instead.
For aligned fdt's this is equivalent to what we had before.

Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
---
 This was already discussed back in October:
    http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/48912
 But the commit (f242a08871) only fixed part of the problem.
 common/fdt_support.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/common/fdt_support.c b/common/fdt_support.c
index 5a83bca..a79bc08 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -610,7 +610,7 @@ int fdt_resize(void *blob)
 		fdt_size_dt_strings(blob) + sizeof(struct fdt_reserve_entry);
 
 	/* Make it so the fdt ends on a page boundary */
-	actualsize = ALIGN(actualsize, 0x1000);
+	actualsize = ALIGN(actualsize + ((uint)blob & 0xfff), 0x1000);
 	actualsize = actualsize - ((uint)blob & 0xfff);
 
 	/* Change the fdt header to reflect the correct size */
-- 
1.5.6.5

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-01-17 18:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-14 12:52 [U-Boot] [PATCH] fdt_resize(): fix actualsize calculations with unaligned blobs Peter Korsgaard
2009-01-17 18:19 ` Jerry Van Baren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox