aboutsummaryrefslogtreecommitdiffstats
path: root/init/initramfs.c
diff options
context:
space:
mode:
authorYinghai Lu <yinghai@kernel.org>2014-08-08 17:23:14 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-08-08 18:57:26 -0400
commitd97b07c54f34e88352ebe676beb798c8f59ac588 (patch)
tree3b864aca26ab13d9fdcdca3d1bdabc69830cea01 /init/initramfs.c
parent38747439914c468ecba70b492b54dc4ef0b50453 (diff)
initramfs: support initramfs that is bigger than 2GiB
Now with 64bit bzImage and kexec tools, we support ramdisk that size is bigger than 2g, as we could put it above 4G. Found compressed initramfs image could not be decompressed properly. It turns out that image length is int during decompress detection, and it will become < 0 when length is more than 2G. Furthermore, during decompressing len as int is used for inbuf count, that has problem too. Change len to long, that should be ok as on 32 bit platform long is 32bits. Tested with following compressed initramfs image as root with kexec. gzip, bzip2, xz, lzma, lzop, lz4. run time for populate_rootfs(): size name Nehalem-EX Westmere-EX Ivybridge-EX 9034400256 root_img : 26s 24s 30s 3561095057 root_img.lz4 : 28s 27s 27s 3459554629 root_img.lzo : 29s 29s 28s 3219399480 root_img.gz : 64s 62s 49s 2251594592 root_img.xz : 262s 260s 183s 2226366598 root_img.lzma: 386s 376s 277s 2901482513 root_img.bz2 : 635s 599s Signed-off-by: Yinghai Lu <yinghai@kernel.org> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Rashika Kheria <rashika.kheria@gmail.com> Cc: Josh Triplett <josh@joshtriplett.org> Cc: Kyungsik Lee <kyungsik.lee@lge.com> Cc: P J P <ppandit@redhat.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp> Cc: "Daniel M. Weeks" <dan@danweeks.net> Cc: Alexandre Courbot <acourbot@nvidia.com> Cc: Jan Beulich <JBeulich@suse.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'init/initramfs.c')
-rw-r--r--init/initramfs.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/init/initramfs.c b/init/initramfs.c
index 4f276b6a167b..a7566031242e 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -197,7 +197,7 @@ static __initdata enum state {
197} state, next_state; 197} state, next_state;
198 198
199static __initdata char *victim; 199static __initdata char *victim;
200static __initdata unsigned count; 200static unsigned long count __initdata;
201static __initdata loff_t this_header, next_header; 201static __initdata loff_t this_header, next_header;
202 202
203static inline void __init eat(unsigned n) 203static inline void __init eat(unsigned n)
@@ -209,7 +209,7 @@ static inline void __init eat(unsigned n)
209 209
210static __initdata char *vcollected; 210static __initdata char *vcollected;
211static __initdata char *collected; 211static __initdata char *collected;
212static __initdata int remains; 212static long remains __initdata;
213static __initdata char *collect; 213static __initdata char *collect;
214 214
215static void __init read_into(char *buf, unsigned size, enum state next) 215static void __init read_into(char *buf, unsigned size, enum state next)
@@ -236,7 +236,7 @@ static int __init do_start(void)
236 236
237static int __init do_collect(void) 237static int __init do_collect(void)
238{ 238{
239 unsigned n = remains; 239 unsigned long n = remains;
240 if (count < n) 240 if (count < n)
241 n = count; 241 n = count;
242 memcpy(collect, victim, n); 242 memcpy(collect, victim, n);
@@ -407,7 +407,7 @@ static __initdata int (*actions[])(void) = {
407 [Reset] = do_reset, 407 [Reset] = do_reset,
408}; 408};
409 409
410static int __init write_buffer(char *buf, unsigned len) 410static long __init write_buffer(char *buf, unsigned long len)
411{ 411{
412 count = len; 412 count = len;
413 victim = buf; 413 victim = buf;
@@ -417,11 +417,11 @@ static int __init write_buffer(char *buf, unsigned len)
417 return len - count; 417 return len - count;
418} 418}
419 419
420static int __init flush_buffer(void *bufv, unsigned len) 420static long __init flush_buffer(void *bufv, unsigned long len)
421{ 421{
422 char *buf = (char *) bufv; 422 char *buf = (char *) bufv;
423 int written; 423 long written;
424 int origLen = len; 424 long origLen = len;
425 if (message) 425 if (message)
426 return -1; 426 return -1;
427 while ((written = write_buffer(buf, len)) < len && !message) { 427 while ((written = write_buffer(buf, len)) < len && !message) {
@@ -440,13 +440,13 @@ static int __init flush_buffer(void *bufv, unsigned len)
440 return origLen; 440 return origLen;
441} 441}
442 442
443static unsigned my_inptr; /* index of next byte to be processed in inbuf */ 443static unsigned long my_inptr; /* index of next byte to be processed in inbuf */
444 444
445#include <linux/decompress/generic.h> 445#include <linux/decompress/generic.h>
446 446
447static char * __init unpack_to_rootfs(char *buf, unsigned len) 447static char * __init unpack_to_rootfs(char *buf, unsigned long len)
448{ 448{
449 int written, res; 449 long written;
450 decompress_fn decompress; 450 decompress_fn decompress;
451 const char *compress_name; 451 const char *compress_name;
452 static __initdata char msg_buf[64]; 452 static __initdata char msg_buf[64];
@@ -480,7 +480,7 @@ static char * __init unpack_to_rootfs(char *buf, unsigned len)
480 decompress = decompress_method(buf, len, &compress_name); 480 decompress = decompress_method(buf, len, &compress_name);
481 pr_debug("Detected %s compressed data\n", compress_name); 481 pr_debug("Detected %s compressed data\n", compress_name);
482 if (decompress) { 482 if (decompress) {
483 res = decompress(buf, len, NULL, flush_buffer, NULL, 483 int res = decompress(buf, len, NULL, flush_buffer, NULL,
484 &my_inptr, error); 484 &my_inptr, error);
485 if (res) 485 if (res)
486 error("decompressor failed"); 486 error("decompressor failed");