Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Matthias Brugger <mbrugger@suse.com>
To: kexec@lists.infradead.org, geoff@infradead.org
Cc: panand@redhat.com, catalin.marinas@arm.com,
	Matthias Brugger <mbrugger@suse.com>,
	ard.biesheuvel@linaro.org
Subject: [PATCH] arm64: Fix initrd requierements
Date: Wed,  7 Dec 2016 17:26:15 +0100	[thread overview]
Message-ID: <1481127975-9156-1-git-send-email-mbrugger@suse.com> (raw)

The initrd doesn't need to be aligend to 1 GB, which breaks kexec for system with
RAM <= 1 GB. Instead the memory size between the kernel start rounded down to 1 GB
and the end of the initrd rounded up to 1 GB can't be bigger then 32 GB.

Signed-off-by: Matthias Brugger <mbrugger@suse.com>
---
 kexec/arch/arm64/kexec-arm64.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/kexec/arch/arm64/kexec-arm64.c b/kexec/arch/arm64/kexec-arm64.c
index 288548f..04fd396 100644
--- a/kexec/arch/arm64/kexec-arm64.c
+++ b/kexec/arch/arm64/kexec-arm64.c
@@ -327,6 +327,7 @@ int arm64_load_other_segments(struct kexec_info *info,
 	unsigned long dtb_base;
 	unsigned long hole_min;
 	unsigned long hole_max;
+	unsigned long initrd_end;
 	char *initrd_buf = NULL;
 	struct dtb dtb;
 	char command_line[COMMAND_LINE_SIZE] = "";
@@ -366,27 +367,27 @@ int arm64_load_other_segments(struct kexec_info *info,
 		if (!initrd_buf)
 			fprintf(stderr, "kexec: Empty ramdisk file.\n");
 		else {
-			/*
-			 * Put the initrd after the kernel.  As specified in
-			 * booting.txt, align to 1 GiB.
-			 */
+			/* Put the initrd after the kernel. */
 
 			initrd_base = add_buffer_phys_virt(info, initrd_buf,
-				initrd_size, initrd_size, GiB(1),
+				initrd_size, initrd_size, 0,
 				hole_min, hole_max, 1, 0);
 
-			/* initrd_base is valid if we got here. */
-
-			dbgprintf("initrd: base %lx, size %lxh (%ld)\n",
-				initrd_base, initrd_size, initrd_size);
+			initrd_end = initrd_base + initrd_size;
 
-			/* Check size limit as specified in booting.txt. */
+			/* Check limits as specified in booting.txt.
+			 * The kernel may have as little as 32 GB of address space to map
+			 * system memory and both kernel and initrd must be 1GB aligend.
+			 */
 
-			if (initrd_base - image_base + initrd_size > GiB(32)) {
+			if (_ALIGN_UP(initrd_end, GiB(1)) - _ALIGN_DOWN(image_base, GiB(1)) > GiB(32)) {
 				fprintf(stderr, "kexec: Error: image + initrd too big.\n");
 				return -EFAILED;
 			}
 
+			dbgprintf("initrd: base %lx, size %lxh (%ld)\n",
+				initrd_base, initrd_size, initrd_size);
+
 			result = dtb_set_initrd((char **)&dtb.buf,
 				&dtb.size, initrd_base,
 				initrd_base + initrd_size);
-- 
2.6.6


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

             reply	other threads:[~2016-12-07 16:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-07 16:26 Matthias Brugger [this message]
2016-12-09  7:59 ` [PATCH] arm64: Fix initrd requierements Simon Horman

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=1481127975-9156-1-git-send-email-mbrugger@suse.com \
    --to=mbrugger@suse.com \
    --cc=ard.biesheuvel@linaro.org \
    --cc=catalin.marinas@arm.com \
    --cc=geoff@infradead.org \
    --cc=kexec@lists.infradead.org \
    --cc=panand@redhat.com \
    /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