Skip to content

Commit 65bc3ec

Browse files
hkallweitmpe
authored andcommitted
powerpc/boot: Fix boot on systems with uncompressed kernel image
This commit broke boot on systems with an uncompressed kernel image, namely systems using a cuImage. On such systems the compressed boot image (boot wrapper, uncompressed kernel image, ..) is decompressed by u-boot already, therefore the boot wrapper code sees an uncompressed kernel image. The old decompression code silently assumed an uncompressed kernel image if it found no valid gzip signature, whilst the new code bailed out in this case. Fix this by re-introducing such a fallback if no valid compressed image is found. Fixes: 1b7898e ("Use the pre-boot decompression API") Signed-off-by: Heiner Kallweit <[email protected]> Signed-off-by: Michael Ellerman <[email protected]>
1 parent d2cf909 commit 65bc3ec

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

arch/powerpc/boot/main.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,16 @@ static struct addr_range prep_kernel(void)
3232
void *addr = 0;
3333
struct elf_info ei;
3434
long len;
35+
int uncompressed_image = 0;
3536

36-
partial_decompress(vmlinuz_addr, vmlinuz_size,
37+
len = partial_decompress(vmlinuz_addr, vmlinuz_size,
3738
elfheader, sizeof(elfheader), 0);
39+
/* assume uncompressed data if -1 is returned */
40+
if (len == -1) {
41+
uncompressed_image = 1;
42+
memcpy(elfheader, vmlinuz_addr, sizeof(elfheader));
43+
printf("No valid compressed data found, assume uncompressed data\n\r");
44+
}
3845

3946
if (!parse_elf64(elfheader, &ei) && !parse_elf32(elfheader, &ei))
4047
fatal("Error: not a valid PPC32 or PPC64 ELF file!\n\r");
@@ -67,6 +74,13 @@ static struct addr_range prep_kernel(void)
6774
"device tree\n\r");
6875
}
6976

77+
if (uncompressed_image) {
78+
memcpy(addr, vmlinuz_addr + ei.elfoffset, ei.loadsize);
79+
printf("0x%lx bytes of uncompressed data copied\n\r",
80+
ei.loadsize);
81+
goto out;
82+
}
83+
7084
/* Finally, decompress the kernel */
7185
printf("Decompressing (0x%p <- 0x%p:0x%p)...\n\r", addr,
7286
vmlinuz_addr, vmlinuz_addr+vmlinuz_size);
@@ -82,7 +96,7 @@ static struct addr_range prep_kernel(void)
8296
len, ei.loadsize);
8397

8498
printf("Done! Decompressed 0x%lx bytes\n\r", len);
85-
99+
out:
86100
flush_cache(addr, ei.loadsize);
87101

88102
return (struct addr_range){addr, ei.memsize};

0 commit comments

Comments
 (0)