linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: eric.miao@canonical.com (Eric Miao)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH - kexec] arm: place initrd to safer place according to zImage length
Date: Fri, 23 Apr 2010 10:36:44 +0800	[thread overview]
Message-ID: <h2xf17812d71004221936s779a4585r8b458f7f2630f7b1@mail.gmail.com> (raw)

commit 4b6d55c7780dbf383c6b64e560d459d15a891006
Author: Eric Miao <eric.miao@canonical.com>
Date:   Fri Apr 23 10:19:43 2010 +0800

    arm: place initrd to safer place according to zImage length

    The original fixed address of 0x800000 may be overwritten after the
    kernel is decompressed.  Assume a maximum decompression ratio of 4
    and place initrd right after that, just to be safer.

    Signed-off-by: Eric Miao <eric.miao@canonical.com>

diff --git a/kexec/arch/arm/kexec-zImage-arm.c
b/kexec/arch/arm/kexec-zImage-arm.c
index 72fcdd8..1a446d9 100644
--- a/kexec/arch/arm/kexec-zImage-arm.c
+++ b/kexec/arch/arm/kexec-zImage-arm.c
@@ -130,7 +130,7 @@ struct tag * atag_read_tags(void)
 static
 int atag_arm_load(struct kexec_info *info, unsigned long base,
 	const char *command_line, off_t command_line_len,
-	const char *initrd, off_t initrd_len)
+	const char *initrd, off_t initrd_len, off_t initrd_off)
 {
 	struct tag *saved_tags = atag_read_tags();
 	char *buf;
@@ -196,10 +196,8 @@ int atag_arm_load(struct kexec_info *info,
unsigned long base,
 	add_segment(info, buf, len, base, len);

 	if (initrd) {
-		struct memory_range *range;
-		int ranges;
-		get_memory_ranges(&range, &ranges, info->kexec_flags);
-		*initrd_start = locate_hole(info, initrd_len, getpagesize(),
range[0].start + 0x800000, ULONG_MAX, INT_MAX);
+		*initrd_start = locate_hole(info, initrd_len, getpagesize(),
+				initrd_off, ULONG_MAX, INT_MAX);
 		if (*initrd_start == ULONG_MAX)
 			return -1;
 		add_segment(info, initrd, initrd_len, *initrd_start, initrd_len);
@@ -219,6 +217,7 @@ int zImage_arm_load(int argc, char **argv, const
char *buf, off_t len,
 	const char *ramdisk;
 	char *ramdisk_buf;
 	off_t ramdisk_length;
+	off_t ramdisk_offset;
 	int opt;
 #define OPT_APPEND	'a'
 #define OPT_RAMDISK	'r'
@@ -271,9 +270,14 @@ int zImage_arm_load(int argc, char **argv, const
char *buf, off_t len,
 	if (base == ULONG_MAX)
 		return -1;

+	/* assume the maximum kernel compression ratio is 4,
+	 * and just to be safe, place ramdisk after that
+	 */
+	ramdisk_offset = base + len * 4;
+
 	if (atag_arm_load(info, base + atag_offset,
 			 command_line, command_line_len,
-			 ramdisk_buf, ramdisk_length)    == -1)
+			 ramdisk_buf, ramdisk_length, ramdisk_offset) == -1)
 		return -1;

 	add_segment(info, buf, len, base + offset, len);

             reply	other threads:[~2010-04-23  2:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-23  2:36 Eric Miao [this message]
2010-05-11  3:28 ` [PATCH - kexec] arm: place initrd to safer place according to zImage length 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=h2xf17812d71004221936s779a4585r8b458f7f2630f7b1@mail.gmail.com \
    --to=eric.miao@canonical.com \
    --cc=linux-arm-kernel@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;
as well as URLs for NNTP newsgroup(s).