From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peng Fan Date: Mon, 12 Sep 2016 17:18:53 +0800 Subject: [U-Boot] [PATCH] cmd: booti: fix the image runtime location In-Reply-To: <1473671278-23831-1-git-send-email-peng.fan@nxp.com> References: <1473671278-23831-1-git-send-email-peng.fan@nxp.com> Message-ID: <20160912091850.GA23934@linux-7smt.suse> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Mon, Sep 12, 2016 at 05:07:58PM +0800, Peng Fan wrote: >We should not use "bi_dram[0].start + text_offset" as the image dst. >The text_offset maybe 0 for some images, such as XEN. Then the dst >is actually bi_dram[0].start, which maybe the location of spin table. > >Let's use "images->ep & ~(ih->text_offset)" as the dst address. This patch maybe not that correct according to the doc from Linux kernel. " The Image must be placed text_offset bytes from a 2MB aligned base address anywhere in usable system RAM and called there. The region between the 2 MB aligned base address and the start of the image has no special significance to the kernel, and may be used for other purposes. " Now I do not have a good idea that we may have a spin table in the start of DRAM or even a small firmware. Is it better to change gd->bd->bi_dram[0].start? For example physical dram starts from 0x80000000, but 4K is reserved at the beginning. So is it ok to change gd->bd->bi_dram[0].start to 0x80001000? Thanks, Peng. > >Signed-off-by: Peng Fan >Cc: Tom Rini >--- > cmd/booti.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > >diff --git a/cmd/booti.c b/cmd/booti.c >index 6c1c998..afc87e3 100644 >--- a/cmd/booti.c >+++ b/cmd/booti.c >@@ -54,7 +54,9 @@ static int booti_setup(bootm_headers_t *images) > * If we are not at the correct run-time location, set the new > * correct location and then move the image there. > */ >- dst = gd->bd->bi_dram[0].start + le64_to_cpu(ih->text_offset); >+ dst = images->ep & ~(ih->text_offset); >+ if (dst < gd->bd->bi_dram[0].start) >+ dst = gd->bd->bi_dram[0].start + le64_to_cpu(ih->text_offset); > > unmap_sysmem(ih); > >-- >2.6.2 >