All of lore.kernel.org
 help / color / mirror / Atom feed
From: rmk@armlinux.org.uk (Russell King)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/2] arm: take account of TEXT_OFFSET for subsequent images
Date: Fri, 17 Jun 2016 20:44:37 +0100	[thread overview]
Message-ID: <E1bDzgz-0006Zy-1g@e0050434b2927.dyn.armlinux.org.uk> (raw)
In-Reply-To: <20160617194405.GN1041@n2100.armlinux.org.uk>

The ARM kexec code was not taking account of the 32k text offset when
applying the size(s) of the kernel image.  We need to take account of
this so when we decide to place the initrd at 4x the compressed image
length, it is appropriately placed.

Signed-off-by: Russell King <rmk@armlinux.org.uk>
---
 kexec/arch/arm/kexec-zImage-arm.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/kexec/arch/arm/kexec-zImage-arm.c b/kexec/arch/arm/kexec-zImage-arm.c
index aab0c861..297b7fd8 100644
--- a/kexec/arch/arm/kexec-zImage-arm.c
+++ b/kexec/arch/arm/kexec-zImage-arm.c
@@ -340,7 +340,7 @@ static int setup_dtb_prop(char **bufp, off_t *sizep, int parentoffset,
 int zImage_arm_load(int argc, char **argv, const char *buf, off_t len,
 	struct kexec_info *info)
 {
-	unsigned long base;
+	unsigned long base, kernel_base;
 	unsigned int atag_offset = 0x1000; /* 4k offset from memory start */
 	unsigned int extra_size = 0x8000; /* TEXT_OFFSET */
 	const char *command_line;
@@ -517,15 +517,17 @@ int zImage_arm_load(int argc, char **argv, const char *buf, off_t len,
 	if (base == ULONG_MAX)
 		return -1;
 
+	kernel_base = base + extra_size;
+
 	if (kexec_arm_image_size) {
 		/* If the image size was passed as command line argument,
 		 * use that value for determining the address for initrd,
 		 * atags and dtb images. page-align the given length.*/
-		initrd_base = base + _ALIGN(kexec_arm_image_size, getpagesize());
+		initrd_base = kernel_base + _ALIGN(kexec_arm_image_size, getpagesize());
 	} else {
 		/* Otherwise, assume the maximum kernel compression ratio
 		 * is 4, and just to be safe, place ramdisk after that */
-		initrd_base = base + _ALIGN(len * 4, getpagesize());
+		initrd_base = kernel_base + _ALIGN(len * 4, getpagesize());
 	}
 
 	if (use_atags) {
@@ -617,9 +619,9 @@ int zImage_arm_load(int argc, char **argv, const char *buf, off_t len,
 		            dtb_offset, dtb_length);
 	}
 
-	add_segment(info, buf, len, base + extra_size, len);
+	add_segment(info, buf, len, kernel_base, len);
 
-	info->entry = (void*)base + extra_size;
+	info->entry = (void*)kernel_base;
 
 	return 0;
 }
-- 
1.9.1

WARNING: multiple messages have this Message-ID (diff)
From: Russell King <rmk@armlinux.org.uk>
To: Kees Cook <keescook@google.com>,
	Simon Horman <horms@verge.net.au>, Baoquan He <bhe@redhat.com>,
	Pratyush Anand <panand@redhat.com>
Cc: kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/2] arm: take account of TEXT_OFFSET for subsequent images
Date: Fri, 17 Jun 2016 20:44:37 +0100	[thread overview]
Message-ID: <E1bDzgz-0006Zy-1g@e0050434b2927.dyn.armlinux.org.uk> (raw)
In-Reply-To: <20160617194405.GN1041@n2100.armlinux.org.uk>

The ARM kexec code was not taking account of the 32k text offset when
applying the size(s) of the kernel image.  We need to take account of
this so when we decide to place the initrd at 4x the compressed image
length, it is appropriately placed.

Signed-off-by: Russell King <rmk@armlinux.org.uk>
---
 kexec/arch/arm/kexec-zImage-arm.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/kexec/arch/arm/kexec-zImage-arm.c b/kexec/arch/arm/kexec-zImage-arm.c
index aab0c861..297b7fd8 100644
--- a/kexec/arch/arm/kexec-zImage-arm.c
+++ b/kexec/arch/arm/kexec-zImage-arm.c
@@ -340,7 +340,7 @@ static int setup_dtb_prop(char **bufp, off_t *sizep, int parentoffset,
 int zImage_arm_load(int argc, char **argv, const char *buf, off_t len,
 	struct kexec_info *info)
 {
-	unsigned long base;
+	unsigned long base, kernel_base;
 	unsigned int atag_offset = 0x1000; /* 4k offset from memory start */
 	unsigned int extra_size = 0x8000; /* TEXT_OFFSET */
 	const char *command_line;
@@ -517,15 +517,17 @@ int zImage_arm_load(int argc, char **argv, const char *buf, off_t len,
 	if (base == ULONG_MAX)
 		return -1;
 
+	kernel_base = base + extra_size;
+
 	if (kexec_arm_image_size) {
 		/* If the image size was passed as command line argument,
 		 * use that value for determining the address for initrd,
 		 * atags and dtb images. page-align the given length.*/
-		initrd_base = base + _ALIGN(kexec_arm_image_size, getpagesize());
+		initrd_base = kernel_base + _ALIGN(kexec_arm_image_size, getpagesize());
 	} else {
 		/* Otherwise, assume the maximum kernel compression ratio
 		 * is 4, and just to be safe, place ramdisk after that */
-		initrd_base = base + _ALIGN(len * 4, getpagesize());
+		initrd_base = kernel_base + _ALIGN(len * 4, getpagesize());
 	}
 
 	if (use_atags) {
@@ -617,9 +619,9 @@ int zImage_arm_load(int argc, char **argv, const char *buf, off_t len,
 		            dtb_offset, dtb_length);
 	}
 
-	add_segment(info, buf, len, base + extra_size, len);
+	add_segment(info, buf, len, kernel_base, len);
 
-	info->entry = (void*)base + extra_size;
+	info->entry = (void*)kernel_base;
 
 	return 0;
 }
-- 
1.9.1


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

  reply	other threads:[~2016-06-17 19:44 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-17 19:44 [PATCH 0/2] Simple fix to the ARM kexec tools implementation Russell King - ARM Linux
2016-06-17 19:44 ` Russell King - ARM Linux
2016-06-17 19:44 ` Russell King [this message]
2016-06-17 19:44   ` [PATCH 1/2] arm: take account of TEXT_OFFSET for subsequent images Russell King
2016-06-17 19:44 ` [PATCH 2/2] arm: fix kernel image size Russell King
2016-06-17 19:44   ` Russell King
     [not found]   ` <E1bDzh4-0006a4-7p-yeZebKftTXNiEPTqdM/vLBqCBvEC6TWiNEsB0oqw8pBaa/9Udqfwiw@public.gmane.org>
2016-06-21  7:43     ` Tony Lindgren
2016-06-21  7:43       ` Tony Lindgren
2016-06-21  7:43       ` Tony Lindgren
     [not found]       ` <20160621074319.GH22406-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2016-06-21  9:47         ` Russell King - ARM Linux
2016-06-21  9:47           ` Russell King - ARM Linux
2016-06-21  9:47           ` Russell King - ARM Linux
     [not found]           ` <20160621094737.GA5783-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2016-06-21 10:38             ` Tony Lindgren
2016-06-21 10:38               ` Tony Lindgren
2016-06-21 10:38               ` Tony Lindgren
     [not found]               ` <20160621103810.GI22406-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2016-06-21 10:57                 ` Tony Lindgren
2016-06-21 10:57                   ` Tony Lindgren
2016-06-21 10:57                   ` Tony Lindgren
     [not found]                   ` <20160621105720.GK22406-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2016-06-21 15:44                     ` Russell King - ARM Linux
2016-06-21 15:44                       ` Russell King - ARM Linux
2016-06-21 15:44                       ` Russell King - ARM Linux
     [not found]                       ` <20160621154407.GB5783-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2016-06-21 16:55                         ` Tony Lindgren
2016-06-21 16:55                           ` Tony Lindgren
2016-06-21 16:55                           ` Tony Lindgren
     [not found]                           ` <20160621165523.GY22406-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2016-06-21 21:51                             ` Russell King - ARM Linux
2016-06-21 21:51                               ` Russell King - ARM Linux
2016-06-21 21:51                               ` Russell King - ARM Linux
     [not found]                               ` <20160621215141.GC5783-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2016-06-22  7:36                                 ` Tony Lindgren
2016-06-22  7:36                                   ` Tony Lindgren
2016-06-22  7:36                                   ` Tony Lindgren
     [not found]                                   ` <20160622073614.GZ22406-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2016-06-22  8:29                                     ` Russell King - ARM Linux
2016-06-22  8:29                                       ` Russell King - ARM Linux
2016-06-22  8:29                                       ` Russell King - ARM Linux
     [not found]                                       ` <20160622082958.GD5783-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2016-06-22  8:51                                         ` Tony Lindgren
2016-06-22  8:51                                           ` Tony Lindgren
2016-06-22  8:51                                           ` Tony Lindgren
2016-06-21 11:02   ` Mason
2016-06-21  6:11 ` [PATCH 0/2] Simple fix to the ARM kexec tools implementation Pratyush Anand
2016-06-21  6:11   ` Pratyush Anand
2016-06-21  8:20   ` Russell King - ARM Linux
2016-06-21  8:20     ` Russell King - ARM Linux
2016-06-23  0:41     ` Simon Horman
2016-06-23  0:41       ` 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=E1bDzgz-0006Zy-1g@e0050434b2927.dyn.armlinux.org.uk \
    --to=rmk@armlinux.org.uk \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.