public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Kumar Gala <galak@kernel.crashing.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] fdt: Fix fdt padding issue for initrd mem_rsv
Date: Wed, 21 Oct 2009 23:29:51 -0500	[thread overview]
Message-ID: <1256185791-5492-1-git-send-email-galak@kernel.crashing.org> (raw)

Its possible that we end up with a device tree that happens to be a
particular size that after we call fdt_resize() we don't have any
space left for the initrd mem_rsv.

Fix this be adding a second mem_rsv into the size calculation.  We
had one to cover the fdt itself and we have the potential of adding
a second for the initrd.

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
---
Wolfgang, this has been a long standing bug but only shows up if the fdt
blob happens to be a particular size.  Please include this for the v2009.11
release.

- k

 common/fdt_support.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/common/fdt_support.c b/common/fdt_support.c
index 89164a1..fecd904 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -604,10 +604,11 @@ int fdt_resize(void *blob)
 
 	/*
 	 * Calculate the actual size of the fdt
-	 * plus the size needed for fdt_add_mem_rsv
+	 * plus the size needed for two fdt_add_mem_rsv, one
+	 * for the fdt itself and one for a possible initrd
 	 */
 	actualsize = fdt_off_dt_strings(blob) +
-		fdt_size_dt_strings(blob) + sizeof(struct fdt_reserve_entry);
+		fdt_size_dt_strings(blob) + 2*sizeof(struct fdt_reserve_entry);
 
 	/* Make it so the fdt ends on a page boundary */
 	actualsize = ALIGN(actualsize + ((uint)blob & 0xfff), 0x1000);
-- 
1.6.0.6

             reply	other threads:[~2009-10-22  4:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-22  4:29 Kumar Gala [this message]
2009-10-22 11:48 ` [U-Boot] [PATCH] fdt: Fix fdt padding issue for initrd mem_rsv Jerry Van Baren
2009-10-24 20:39 ` Wolfgang Denk

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=1256185791-5492-1-git-send-email-galak@kernel.crashing.org \
    --to=galak@kernel.crashing.org \
    --cc=u-boot@lists.denx.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox