mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Patrick Boettcher <p@yai.se>
To: barebox@lists.infradead.org
Cc: Patrick Boettcher <p@yai.se>
Subject: [PATCH] bootm: abort if kernel is outside the first 128MB
Date: Sun, 28 Oct 2018 15:24:51 +0100	[thread overview]
Message-ID: <20181028142451.23205-1-p@yai.se> (raw)

Huge images and the pessimistic approach of barebox to put the
kernel-image at five times its size may lead to it being
positioned not in the first 128MiB of RAM. This is however
required for it to be boot. (Referring to

  https://www.kernel.org/doc/Documentation/arm/Booting

"Calling the kernel image")

This commit aborts the boot and displays a message if the
image is located outside the first 128MB.

Signed-off-by: Patrick Boettcher <p@yai.se>
---
 arch/arm/lib32/bootm.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/arch/arm/lib32/bootm.c b/arch/arm/lib32/bootm.c
index 4cf570e57..42febdc71 100644
--- a/arch/arm/lib32/bootm.c
+++ b/arch/arm/lib32/bootm.c
@@ -121,6 +121,12 @@ static int get_kernel_addresses(size_t image_size,
 		spacing += image_decomp_size;
 	}
 
+	if ((*load_address - mem_start) > SZ_128M) {
+		printf("boot aborted: kernel address outside 128MiB "
+		       "(0x%08lx)\n", *load_address);
+		return -ENOMEM;
+	}
+
 	*mem_free = PAGE_ALIGN(*load_address + image_size + spacing);
 
 	/*
-- 
2.19.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

             reply	other threads:[~2018-10-28 14:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-28 14:24 Patrick Boettcher [this message]
2018-10-29 11:55 ` Sascha Hauer
2018-10-29 13:24   ` Patrick Boettcher

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=20181028142451.23205-1-p@yai.se \
    --to=p@yai.se \
    --cc=barebox@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox