Skip to contentSkip to conversation

Fix initrd length miscalculation in bootm command

PATCH New Timur Tabi 4 participants 22 messages Feb 5, 2007 – Mar 27, 2007

lore
Share & tools
lore

Timur Tabi

author
#0 lore raw

PATCH 1/1 Fix initrd length miscalculation in bootm command

The do_bootm_linux() function was using the same variable ('len') to calculate the the dtu length and the initrd length, which meant that the initrd length was incorrect. This patch creates renames 'len' and 'data' to 'initrd_len' and 'initrd_data', thereby preventing any future confusion. It also deletes 'len' and 'data' because the dtu calculations don't actually need them.

---
 common/cmd_bootm.c |   57 +++++++++++++++++++++++----------------------------
 1 files changed, 26 insertions(+), 31 deletions(-)
common/cmd_bootm.c +26 -31
index 7aae8a6..0c092c7 100644
@@ -518,11 +518,10 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int fl
 		int	verify)
 {
 	ulong	sp;
-	ulong	len, checksum;
-	ulong	initrd_start, initrd_end;
+	ulong	checksum;
+	ulong	initrd_start, initrd_end, initrd_data, initrd_len;
 	ulong	cmd_start, cmd_end;
 	ulong	initrd_high;
-	ulong	data;
 	int	initrd_copy_to_ram = 1;
 	char    *cmdline;
 	char	*s;
@@ -626,7 +625,7 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int fl
 	/* Look for a '-' which indicates to ignore the ramdisk argument */
 	if (argc >= 3 && strcmp(argv[2], "-") ==  0) {
 			debug ("Skipping initrd\n");
-			len = data = 0;
+			initrd_len = initrd_data = 0;
 		}
 	else
 #endif
@@ -647,13 +646,10 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int fl
 			do_reset (cmdtp, flag, argc, argv);
 		}
 
-		data = (ulong)&header;
-		len  = sizeof(image_header_t);
-
 		checksum = ntohl(hdr->ih_hcrc);
 		hdr->ih_hcrc = 0;
 
-		if (crc32 (0, (uchar *)data, len) != checksum) {
+		if (crc32 (0, (uchar *) &header, sizeof(image_header_t)) != checksum) {
 			puts ("Bad Header Checksum\n");
 			SHOW_BOOT_PROGRESS (-11);
 			do_reset (cmdtp, flag, argc, argv);
@@ -663,13 +659,13 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int fl
 
 		print_image_hdr (hdr);
 
-		data = addr + sizeof(image_header_t);
-		len  = ntohl(hdr->ih_size);
+		initrd_data = addr + sizeof(image_header_t);
+		initrd_len  = ntohl(hdr->ih_size);
 
 		if (verify) {
 			ulong csum = 0;
 #if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
-			ulong cdata = data, edata = cdata + len;
+			ulong cdata = initrd_data, edata = cdata + initrd_len;
 #endif	/* CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG */
 
 			puts ("   Verifying Checksum ... ");
@@ -687,7 +683,7 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int fl
 				WATCHDOG_RESET();
 			}
 #else	/* !(CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG) */
-			csum = crc32 (0, (uchar *)data, len);
+			csum = crc32 (0, (uchar *) initrd_data, initrd_len);
 #endif	/* CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG */
 
 			if (csum != ntohl(hdr->ih_dcrc)) {
@@ -718,17 +714,17 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int fl
 		SHOW_BOOT_PROGRESS (13);
 
 		/* skip kernel length and terminator */
-		data = (ulong)(&len_ptr[2]);
+		initrd_data = (ulong)(&len_ptr[2]);
 		/* skip any additional image length fields */
 		for (i=1; len_ptr[i]; ++i)
-			data += 4;
+			initrd_data += 4;
 		/* add kernel length, and align */
-		data += ntohl(len_ptr[0]);
+		initrd_data += ntohl(len_ptr[0]);
 		if (tail) {
-			data += 4 - tail;
+			initrd_data += 4 - tail;
 		}
 
-		len   = ntohl(len_ptr[1]);
+		initrd_len   = ntohl(len_ptr[1]);
 
 	} else {
 		/*
@@ -736,7 +732,7 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int fl
 		 */
 		SHOW_BOOT_PROGRESS (14);
 
-		len = data = 0;
+		initrd_len = initrd_data = 0;
 	}
 
 #ifdef CONFIG_OF_FLAT_TREE
@@ -771,9 +767,8 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int fl
 
 			checksum = ntohl(hdr->ih_dcrc);
 			addr = (ulong)((uchar *)(hdr) + sizeof(image_header_t));
-			len = ntohl(hdr->ih_size);
 
-			if(checksum != crc32(0, (uchar *)addr, len)) {
+			if(checksum != crc32(0, (uchar *)addr, ntohl(hdr->ih_size))) {
 				printf("ERROR: Flat Device Tree checksum is invalid\n");
 				return;
 			}
@@ -835,16 +830,16 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int fl
 		}
 	}
 #endif
-	if (!data) {
+	if (!initrd_data) {
 		debug ("No initrd\n");
 	}
 
-	if (data) {
+	if (initrd_data) {
 	    if (!initrd_copy_to_ram) {	/* zero-copy ramdisk support */
-		initrd_start = data;
-		initrd_end = initrd_start + len;
+		initrd_start = initrd_data;
+		initrd_end = initrd_start + initrd_len;
 	    } else {
-		initrd_start  = (ulong)kbd - len;
+		initrd_start  = (ulong)kbd - initrd_len;
 		initrd_start &= ~(4096 - 1);	/* align on page */
 
 		if (initrd_high) {
@@ -865,7 +860,7 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int fl
 			nsp &= ~0xF;
 			if (nsp > initrd_high)	/* limit as specified */
 				nsp = initrd_high;
-			nsp -= len;
+			nsp -= initrd_len;
 			nsp &= ~(4096 - 1);	/* align on page */
 			if (nsp >= sp)
 				initrd_start = nsp;
@@ -874,16 +869,16 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int fl
 		SHOW_BOOT_PROGRESS (12);
 
 		debug ("## initrd at 0x%08lX ... 0x%08lX (len=%ld=0x%lX)\n",
-			data, data + len - 1, len, len);
+			initrd_data, initrd_data + initrd_len - 1, initrd_len, initrd_len);
 
-		initrd_end    = initrd_start + len;
+		initrd_end    = initrd_start + initrd_len;
 		printf ("   Loading Ramdisk to %08lx, end %08lx ... ",
 			initrd_start, initrd_end);
 #if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
 		{
-			size_t l = len;
+			size_t l = initrd_len;
 			void *to = (void *)initrd_start;
-			void *from = (void *)data;
+			void *from = (void *)initrd_data;
 
 			while (l > 0) {
 				size_t tail = (l > CHUNKSZ) ? CHUNKSZ : l;
@@ -895,7 +890,7 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int fl
 			}
 		}
 #else	/* !(CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG) */
-		memmove ((void *)initrd_start, (void *)data, len);
+		memmove ((void *)initrd_start, (void *)initrd_data, initrd_len);
 #endif	/* CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG */
 		puts ("OK\n");
 	    }
Signature · 1 line
1.4.4
#1 lore raw

PATCH 1/1 Fix initrd length miscalculation in bootm command

Quoted 5 lines · In message <[email protected]> you wrote:

The do_bootm_linux() function was using the same variable ('len') to calculate the the dtu length and the initrd length, which meant that the initrd length was incorrect. This patch creates renames 'len' and 'data' to 'initrd_len' and 'initrd_data', thereby preventing any future confusion. It also deletes 'len' and 'data' because the dtu calculations don't actually need them.

I can't parse this. 'len' was used twice, but actually it wasn't used in the second case, but you renamed the only remaining use it had?

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH, HRB 165235 Munich, CEO: Wolfgang Denk
Office:  Kirchenstr. 5,       D-82194 Groebenzell,            Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Vor allem kein Gedanke! Nichts ist kompromittierender als ein  Gedan-
ke!            - Friedrich Wilhelm Nietzsche _Der Fall Wagner_ (1888)
author
#2 lore raw

PATCH 1/1 Fix initrd length miscalculation in bootm command

Quoted 9 lines · Wolfgang Denk
Quoted 5 lines · In message <[email protected]> you wrote:

The do_bootm_linux() function was using the same variable ('len') to calculate the the dtu length and the initrd length, which meant that the initrd length was incorrect. This patch creates renames 'len' and 'data' to 'initrd_len' and 'initrd_data', thereby preventing any future confusion. It also deletes 'len' and 'data' because the dtu calculations don't actually need them.

I can't parse this. 'len' was used twice, but actually it wasn't used in the second case, but you renamed the only remaining use it had?

Sorry, it looks like I have a few typos in my description. Here's a new one:

"The do_bootm_linux() function was using the same variable ('len') to calculate the dtu length and the initrd length. This meant that the initrd length was incorrect when it came time to book the kernel. This resulted in the inability to boot with an initrd on an OF-based kernel. This patch renames the local variables 'len' and 'data' to 'initrd_len' and 'initrd_data', respectively, and it uses initrd_len and initrd_data only for initrd calculations.

In addition, there were a few places where 'len' and 'data' where being used as temporary variables. The code was modified to eliminate the need for temporary variables."

Does this explain everything? Do you want me to resubmit the patch with the new changelog text?

Signature · 2 lines
Timur Tabi
Linux Kernel Developer @ Freescale
#3 lore raw

PATCH 1/1 Fix initrd length miscalculation in bootm command

Quoted 20 lines · Timur Tabi
Quoted 13 lines · Wolfgang Denk

In message <[email protected]> you

Quoted 10 lines · wrote:

The do_bootm_linux() function was using the same variable ('len') to calculate
the the dtu length and the initrd length, which meant that the initrd length
was incorrect. This patch creates renames 'len' and 'data' to 'initrd_len'
and 'initrd_data', thereby preventing any future confusion. It also deletes
'len' and 'data' because the dtu calculations don't actually need them.

Quoted 2 lines

I can't parse this. 'len' was used twice, but actually it wasn't used in the second case, but you renamed the only remaining use it had?

Sorry, it looks like I have a few typos in my description. Here's a new one:

Quoted 6 lines

"The do_bootm_linux() function was using the same variable ('len') to calculate
the dtu length and the initrd length. This meant that the initrd length was
incorrect when it came time to book the kernel. This resulted in the inability

book -> boot

Quoted 12 lines

to boot with an initrd on an OF-based kernel. This patch renames the local
variables 'len' and 'data' to 'initrd_len' and 'initrd_data', respectively, and
it uses initrd_len and initrd_data only for initrd calculations.

In addition, there were a few places where 'len' and 'data' where being used as
temporary variables. The code was modified to eliminate the need for temporary
variables."

Quoted 3 lines

Does this explain everything? Do you want me to resubmit the patch with the new
changelog text?

Did you test this with a multi image as well? (kernel + initrd + dtb)

- k

author
#4 lore raw

PATCH 1/1 Fix initrd length miscalculation in bootm command

Quoted 4 lines · Kumar Gala
Quoted 2 lines

incorrect when it came time to book the kernel. This resulted in the inability

book -> boot

Ugh.

Quoted 1 line

Did you test this with a multi image as well? (kernel + initrd + dtb)

I've never heard of multi image before. How do I make one? The README doesn't explain it.

Signature · 2 lines
Timur Tabi
Linux Kernel Developer @ Freescale
#5 lore raw

PATCH 1/1 Fix initrd length miscalculation in bootm command

Quoted 7 lines · Timur Tabi
Quoted 3 lines · Kumar Gala
Quoted 2 lines

incorrect when it came time to book the kernel. This resulted in the inability

book -> boot

Ugh.

;)

Quoted 4 lines
Quoted 1 line

Did you test this with a multi image as well? (kernel + initrd + dtb)

I've never heard of multi image before. How do I make one? The README doesn't explain it.

mkimage -A ppc -O Linux -T multi -C gzip -n 'Linux Multiboot-Image' - e 0 -a 0 -d vmlinux.gz:rootfs.ext2.gz:oftree.dtb kern+fs+dtb.bin

- k

author
#6 lore raw

PATCH 1/1 Fix initrd length miscalculation in bootm command

Quoted 2 lines · Kumar Gala

mkimage -A ppc -O Linux -T multi -C gzip -n 'Linux Multiboot-Image' -e 0 -a 0 -d vmlinux.gz:rootfs.ext2.gz:oftree.dtb kern+fs+dtb.bin

Ok, I'll test it out later this week. I got something higher priority to finish first.

Signature · 2 lines
Timur Tabi
Linux Kernel Developer @ Freescale
author
#7 lore raw

PATCH 1/1 Fix initrd length miscalculation in bootm command

In reply to Kumar Gala
Quoted 5 lines · Kumar Gala
Quoted 2 lines

I've never heard of multi image before. How do I make one? The README doesn't explain it.

mkimage -A ppc -O Linux -T multi -C gzip -n 'Linux Multiboot-Image' -e 0 -a 0 -d vmlinux.gz:rootfs.ext2.gz:oftree.dtb kern+fs+dtb.bin

I need some more help getting the multi-image to work. I have the following files:

vmlinux.bin.gz (built myself)
rootfs.ext2.gz.uboot (from the BSP, because I don't know how to build a root file system. I don't know what the ".uboot" is for.) mpc8349emitx.dtb (built myself)

I create the multi image per you instructions, tftp them to $loadaddr (200000), and do "bootm $loadaddr". I get this output:

bootm $loadaddr
## Booting image at 00200000 ...

    Image Name:   Linux Multiboot-Image
    Created:      2007-02-19  23:46:03 UTC
    Image Type:   PowerPC Linux Multi-File Image (gzip compressed)
    Data Size:    20407814 Bytes = 19.5 MB
    Load Address: 00000000
    Entry Point:  00000000
    Contents:
    Image 0:  1416615 Bytes =  1.4 MB
    Image 1: 18987128 Bytes = 18.1 MB
    Image 2:     4054 Bytes =  4 kB
    Verifying Checksum ... OK
    Uncompressing Multi-File Image ... OK

U-Boot 1.2.0-g2e892316-dirty (Feb 9 2007 - 15:56:37) MPC83XX

So the image appears to be okay, but it doesn't boot at all. Is there something obvious I'm doing wrong, or will I have to debug this?

Signature · 2 lines
Timur Tabi
Linux Kernel Developer @ Freescale
#8 lore raw

PATCH 1/1 Fix initrd length miscalculation in bootm command

Quoted 35 lines · Timur Tabi
Quoted 5 lines · Kumar Gala
Quoted 2 lines

I've never heard of multi image before. How do I make one? The README doesn't explain it.

mkimage -A ppc -O Linux -T multi -C gzip -n 'Linux Multiboot- Image' -e 0 -a 0 -d vmlinux.gz:rootfs.ext2.gz:oftree.dtb kern+fs +dtb.bin

I need some more help getting the multi-image to work. I have the following files:

vmlinux.bin.gz (built myself)
rootfs.ext2.gz.uboot (from the BSP, because I don't know how to build a root file system. I don't know what the ".uboot" is for.) mpc8349emitx.dtb (built myself)

I create the multi image per you instructions, tftp them to $loadaddr (200000), and do "bootm $loadaddr". I get this output:

bootm $loadaddr
## Booting image at 00200000 ...

   Image Name:   Linux Multiboot-Image
   Created:      2007-02-19  23:46:03 UTC
   Image Type:   PowerPC Linux Multi-File Image (gzip compressed)
   Data Size:    20407814 Bytes = 19.5 MB
   Load Address: 00000000
   Entry Point:  00000000
   Contents:
   Image 0:  1416615 Bytes =  1.4 MB
   Image 1: 18987128 Bytes = 18.1 MB
   Image 2:     4054 Bytes =  4 kB
   Verifying Checksum ... OK
   Uncompressing Multi-File Image ... OK
Quoted 5 lines

U-Boot 1.2.0-g2e892316-dirty (Feb 9 2007 - 15:56:37) MPC83XX

So the image appears to be okay, but it doesn't boot at all. Is there something obvious I'm doing wrong, or will I have to debug this?

Sounds right, I'd double check that your rootfs.ext2.gz.uboot isn't already a uImage, but the actual ext2 image gziped.

Also, can you boot these three files if you keep them separate? If so that makes me think a bug in the bootm changes.

- k

author
#9 lore raw

PATCH 1/1 Fix initrd length miscalculation in bootm command

Quoted 2 lines · Kumar Gala

Sounds right, I'd double check that your rootfs.ext2.gz.uboot isn't already a uImage, but the actual ext2 image gziped.

Yes, it is a uImage. I guess I need to find the original now.

Also, I was wondering if 200000 is too low of a load address. Doesn't the kernel lock that memory or something?

Signature · 2 lines
Timur Tabi
Linux Kernel Developer @ Freescale
#10 lore raw

PATCH 1/1 Fix initrd length miscalculation in bootm command

Quoted 3 lines · In message <[email protected]> you wrote:

Also, I was wondering if 200000 is too low of a load address. Doesn't the kernel lock that memory or something?

If you hve a big kernel, that's definitely too low.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH, HRB 165235 Munich, CEO: Wolfgang Denk
Office:  Kirchenstr. 5,       D-82194 Groebenzell,            Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"What the scientists have in their briefcases is terrifying."
- Nikita Khrushchev
author
#11 lore raw

PATCH 1/1 Fix initrd length miscalculation in bootm command

Quoted 5 lines · Wolfgang Denk
Quoted 2 lines · In message <[email protected]> you wrote:

Also, I was wondering if 200000 is too low of a load address. Doesn't the kernel lock that memory or something?

If you hve a big kernel, that's definitely too low.

I moved it to 400000, and now the kernel starts to boot, but it panics.

bootm $loadaddr
## Booting image at 00400000 ...

    Image Name:   Linux Multiboot-Image
    Created:      2007-02-20  17:28:04 UTC
    Image Type:   PowerPC Linux Multi-File Image (gzip compressed)
    Data Size:    20407878 Bytes = 19.5 MB
    Load Address: 00000000
    Entry Point:  00000000
    Contents:
    Image 0:  1416615 Bytes =  1.4 MB
    Image 1: 18987192 Bytes = 18.1 MB
    Image 2:     4054 Bytes =  4 kB
    Verifying Checksum ... OK
    Uncompressing Multi-File Image ... OK
    Loading Ramdisk to 0ed59000, end 0ff748b8 ... OK
    Loading Device Tree to 0ed56000, end 0ed56fd5 ... Using MPC834x ITX machine 
description
Linux version 2.6.20-gc2944612 (b04825 at ld0169-tx32) (gcc version 4.0.2) #1 Mon 
Feb 19 17:22:35 CST 2007

Found initrd at 0xced59000:0xcff748b8

[snip]

Kernel command line: root=/dev/ram rw console=ttyS0,115200

[snip]

md: Autodetecting RAID arrays.
md: autorun ...
md: ... autorun DONE.
RAMDISK: Couldn't find valid RAM disk image starting at 0. No filesystem could mount root, tried: ext3 ext2 msdos vfat

Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(1,0)

Now here's something interesting. The output from "Using MPC834x ITX machine description" and "PID hash table entries: 1024 (order: 10, 4096 bytes)" is actually displayed twice. It's as if the kernel spontaneously reboot after display the PID line, and then on the second boot it continues as normal. Is this what really happens, or is it some kind of early printk() funkiness?

BTW, the above happens with or without my patch.

Signature · 2 lines
Timur Tabi
Linux Kernel Developer @ Freescale
author
#12 lore raw

PATCH 1/1 Fix initrd length miscalculation in bootm command

In reply to Wolfgang Denk
Quoted 5 lines · Wolfgang Denk
Quoted 2 lines · In message <[email protected]> you wrote:

Also, I was wondering if 200000 is too low of a load address. Doesn't the kernel lock that memory or something?

If you hve a big kernel, that's definitely too low.

I had to set loadaddr to 800000 and ramdisk_size to 80000 to get it to work.

I can confirm that multi-images work both with and without my patch. So if there are no objections, please apply this patch. Thanks.

Signature · 2 lines
Timur Tabi
Linux Kernel Developer @ Freescale
#13 lore raw

PATCH 1/1 Fix initrd length miscalculation in bootm command

Quoted 3 lines · In message <[email protected]> you wrote:

I can confirm that multi-images work both with and without my patch. So if there are no objections, please apply this patch. Thanks.

Since it doesn't fix a problem I see little reason to change the code.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH, HRB 165235 Munich, CEO: Wolfgang Denk
Office:  Kirchenstr. 5,       D-82194 Groebenzell,            Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Vulcans never bluff.
	-- Spock, "The Doomsday Machine", stardate 4202.1
author
#14 lore raw

PATCH 1/1 Fix initrd length miscalculation in bootm command

Quoted 6 lines · Wolfgang Denk
Quoted 2 lines · In message <[email protected]> you wrote:

I can confirm that multi-images work both with and without my patch. So if there are no objections, please apply this patch. Thanks.

Since it doesn't fix a problem I see little reason to change the code.

What are you talking about? Without this patch, you cannot have an initrd with an OF-enable kernel! It won't work! There's a bug in do_bootm_linux(), and my patch fixes it.

Signature · 2 lines
Timur Tabi
Linux Kernel Developer @ Freescale
author
#15 lore raw

PATCH 1/1 Fix initrd length miscalculation in bootm command

In reply to Wolfgang Denk
Quoted 6 lines · Wolfgang Denk
Quoted 2 lines · In message <[email protected]> you wrote:

I can confirm that multi-images work both with and without my patch. So if there are no objections, please apply this patch. Thanks.

Since it doesn't fix a problem I see little reason to change the code.

Wolfgang, I didn't get a response from you about my last email on this thread, so I just want to make sure that you understand that my patch, "Fix initrd length miscalculation in bootm command," does fix a real bug in do_bootm_linux().

Here's the changelog for the patch:

"The do_bootm_linux() function was using the same variable ('len') to calculate the the dtu length and the initrd length, which meant that the initrd length was incorrect. This patch creates renames 'len' and 'data' to 'initrd_len' and 'initrd_data', thereby preventing any future confusion. It also deletes 'len' and 'data' because the dtu calculations don't actually need them."

The tracking number is DNX#2007020542000011.

Signature · 2 lines
Timur Tabi
Linux Kernel Developer @ Freescale
#16 lore raw

PATCH 1/1 Fix initrd length miscalculation in bootm command

Quoted 3 lines · In message <[email protected]> you wrote:
Quoted 2 lines · Wolfgang Denk
Quoted 1 line · In message <[email protected]> you wrote:

I can confirm that multi-images work both with and without my patch. So if

     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

there are no objections, please apply this patch. Thanks.

Since it doesn't fix a problem I see little reason to change the code.

Wolfgang, I didn't get a response from you about my last email on this thread,

Been sick, trying to recover, even less time than normal :-(

Quoted 4 lines

so I just want to make sure that you understand that my patch, "Fix initrd length miscalculation in bootm command," does fix a real bug in do_bootm_linux().

Here's the changelog for the patch:

I remember the changelog, but your statement that "multi-images work both with and without" your patch. Confuses me. If it works without your patch, then what's the problem?

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH, HRB 165235 Munich, CEO: Wolfgang Denk
Office:  Kirchenstr. 5,       D-82194 Groebenzell,            Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The human race is faced with a cruel choice: work  or  daytime  tele-
vision.
author
#17 lore raw

PATCH 1/1 Fix initrd length miscalculation in bootm command

Quoted 3 lines · Wolfgang Denk

I remember the changelog, but your statement that "multi-images work both with and without" your patch. Confuses me. If it works without your patch, then what's the problem?

Now that I think about it, I guess that statement doesn't make any sense. I was trying to say that I didn't *break* multi-images. The patch fixes a problem with initrd + OF. If you're not using an initrd, then my patch doesn't change anything, so I just wanted to make sure that things that worked before my patch still work after my patch.

Signature · 2 lines
Timur Tabi
Linux Kernel Developer @ Freescale
author
#18 lore raw

PATCH 1/1 Fix initrd length miscalculation in bootm command

Quoted 4 lines · Timur Tabi

Now that I think about it, I guess that statement doesn't make any sense. I was trying to say that I didn't *break* multi-images. The patch fixes a problem with initrd + OF. If you're not using an initrd, then my patch doesn't change anything, so I just wanted to make sure that things that worked before my patch still work after my patch.

Wolfgang,

I just wanted to make sure that you understood that this patch does indeed fix a real and severe problem with U-Boot, and therefore should be applied. I submitted this patch over a month ago, and it's still not in your repository. Without this patch, you cannot use an
initrd on any ARCH=powerpc kernel.

Signature · 2 lines
Timur Tabi
Linux Kernel Developer @ Freescale
#19 lore raw

PATCH 1/1 Fix initrd length miscalculation in bootm command

Quoted 7 lines · Timur Tabi
Quoted 4 lines · Timur Tabi

Now that I think about it, I guess that statement doesn't make any sense. I was trying to say that I didn't *break* multi-images. The patch fixes a problem with initrd + OF. If you're not using an initrd, then my patch doesn't change anything, so I just wanted to make sure that things that worked before my patch still work after my patch.

Quoted 6 lines

Wolfgang,

I just wanted to make sure that you understood that this patch does indeed fix a real and severe problem with U-Boot, and therefore should be applied. I submitted this patch over a month ago, and it's still not in your repository. Without this patch, you cannot use an
initrd on any ARCH=powerpc kernel.

Just want to confirm that the booting of "arch/powerpc" kernels with an initrd is currently broken in u-boot 1.2.0. And, that Timur's patch fixes the issue.

-- Johns

#20 lore raw

PATCH 1/1 Fix initrd length miscalculation in bootm command

Quoted 10 lines · Johns Daniel
Quoted 9 lines · Timur Tabi
Quoted 4 lines · Timur Tabi

Now that I think about it, I guess that statement doesn't make any sense. I was trying to say that I didn't *break* multi-images. The patch fixes a problem with initrd + OF. If you're not using an initrd, then my patch doesn't change anything, so I just wanted to make sure that things that worked before my patch still work after my patch.

Wolfgang,

Quoted 8 lines
Quoted 4 lines

I just wanted to make sure that you understood that this patch does indeed fix a real and severe problem with U-Boot, and therefore should be applied. I submitted this patch over a month ago, and it's still not in your repository. Without this patch, you cannot use an
initrd on any ARCH=powerpc kernel.

Just want to confirm that the booting of "arch/powerpc" kernels with an initrd is currently broken in u-boot 1.2.0. And, that Timur's patch fixes the issue.

One more note to add to that. The only part of Timur's patch that is really important is this bit:
@@ -771,9 +767,8 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int fl

                       checksum = ntohl(hdr->ih_dcrc);
                       addr = (ulong)((uchar *)(hdr) + sizeof(image_header_t));

- len = ntohl(hdr->ih_size);

- if(checksum != crc32(0, (uchar *)addr, len)) {
+ if(checksum != crc32(0, (uchar *)addr,
ntohl(hdr->ih_size))) {
printf("ERROR: Flat Device Tree

checksum is invalid\n");
                               return;
                       }

The "len" variable should not be used for the DTB image.

-- Johns

author
#21 lore raw

PATCH 1/1 Fix initrd length miscalculation in bootm command

Quoted 16 lines · Johns Daniel

One more note to add to that. The only part of Timur's patch that is really important is this bit:

(quoted diff) +1 -2
@@ -771,9 +767,8 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int fl
 
                       checksum = ntohl(hdr->ih_dcrc);
                       addr = (ulong)((uchar *)(hdr) + sizeof(image_header_t));
-                       len = ntohl(hdr->ih_size);
 
-                       if(checksum != crc32(0, (uchar *)addr, len)) {
+                       if(checksum != crc32(0, (uchar *)addr,
 ntohl(hdr->ih_size))) {
                               printf("ERROR: Flat Device Tree
 checksum is invalid\n");
                               return;
                       }
Quoted 1 line

The "len" variable should not be used for the DTB image.

One of the goals of my patch is to make it very clear what 'len' is supposed to be. It is only supposed to be the initrd length. Calling it 'len' is what confused the programmer who added the OF code. He saw 'len' and thought it was a scratch variable.

Signature · 2 lines
Timur Tabi
Linux Kernel Developer @ Freescale