diff mbox

[U-Boot] Gracefully handle 64-bit signed-extended 32-bit Load addresses

Message ID 1455631066-3625-1-git-send-email-wcohen@redhat.com
State Accepted
Commit c190fbd010a00e16e9599575b43c5a7c7bc7ec09
Delegated to: Tom Rini
Headers show

Commit Message

William Cohen Feb. 16, 2016, 1:57 p.m. UTC
To follow the MIPS 32-bit and 64-bit memory map conventions (*) recent
MIPS Linux kernels are using a 64-bit sign extended value
(0xffffffff80010000) for the 32-bit load address (0x80010000) of the
Creator CI20 board kernel.  When this 64-bit argument was passed to
mkimage running on a 32-bit machine such as the Creator CI20 board the
load address was incorrectly formed from the upper 32-bit sign-extend
bits (0xffffffff) by the strtoul instead of from the lower 32-bits
(0x80010000).  The mkimage should be able to tolerate the longer
sign-extended 64-bit version of the 32-bit arguments with the use of
strtoull.  Use of the strtoll in place of the strtol in mkimage.c
resolves the issue of self hosted kernel builds for the Creator CI20
board (+) and (++).

(*) http://techpubs.sgi.com/library/dynaweb_docs/0620/SGI_Developer/books/DevDriver_PG/sgi_html/ch01.html
(+) https://github.com/MIPS/CI20_linux/issues/23
(++) https://github.com/MIPS/CI20_linux/issues/22

Signed-off-by: William Cohen <wcohen@redhat.com>
---
 tools/mkimage.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Tom Rini Feb. 25, 2016, 3:23 p.m. UTC | #1
On Tue, Feb 16, 2016 at 08:57:46AM -0500, William Cohen wrote:

> To follow the MIPS 32-bit and 64-bit memory map conventions (*) recent
> MIPS Linux kernels are using a 64-bit sign extended value
> (0xffffffff80010000) for the 32-bit load address (0x80010000) of the
> Creator CI20 board kernel.  When this 64-bit argument was passed to
> mkimage running on a 32-bit machine such as the Creator CI20 board the
> load address was incorrectly formed from the upper 32-bit sign-extend
> bits (0xffffffff) by the strtoul instead of from the lower 32-bits
> (0x80010000).  The mkimage should be able to tolerate the longer
> sign-extended 64-bit version of the 32-bit arguments with the use of
> strtoull.  Use of the strtoll in place of the strtol in mkimage.c
> resolves the issue of self hosted kernel builds for the Creator CI20
> board (+) and (++).
> 
> (*) http://techpubs.sgi.com/library/dynaweb_docs/0620/SGI_Developer/books/DevDriver_PG/sgi_html/ch01.html
> (+) https://github.com/MIPS/CI20_linux/issues/23
> (++) https://github.com/MIPS/CI20_linux/issues/22
> 
> Signed-off-by: William Cohen <wcohen@redhat.com>

Applied to u-boot/master, thanks!
diff mbox

Patch

diff --git a/tools/mkimage.c b/tools/mkimage.c
index 8f8b6df..facebcd 100644
--- a/tools/mkimage.c
+++ b/tools/mkimage.c
@@ -129,7 +129,7 @@  int main(int argc, char **argv)
 			case 'a':
 				if (--argc <= 0)
 					usage ();
-				params.addr = strtoul (*++argv, &ptr, 16);
+				params.addr = strtoull(*++argv, &ptr, 16);
 				if (*ptr) {
 					fprintf (stderr,
 						"%s: invalid load address %s\n",
@@ -146,7 +146,7 @@  int main(int argc, char **argv)
 			case 'e':
 				if (--argc <= 0)
 					usage ();
-				params.ep = strtoul (*++argv, &ptr, 16);
+				params.ep = strtoull(*++argv, &ptr, 16);
 				if (*ptr) {
 					fprintf (stderr,
 						"%s: invalid entry point %s\n",