aboutsummaryrefslogtreecommitdiffstats
path: root/lib/decompress_unlzma.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 /lib/decompress_unlzma.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 'lib/decompress_unlzma.c')
-rw-r--r--lib/decompress_unlzma.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/lib/decompress_unlzma.c b/lib/decompress_unlzma.c
index 32adb73a9038..0be83af62b88 100644
--- a/lib/decompress_unlzma.c
+++ b/lib/decompress_unlzma.c
@@ -65,11 +65,11 @@ static long long INIT read_int(unsigned char *ptr, int size)
65#define LZMA_IOBUF_SIZE 0x10000 65#define LZMA_IOBUF_SIZE 0x10000
66 66
67struct rc { 67struct rc {
68 int (*fill)(void*, unsigned int); 68 long (*fill)(void*, unsigned long);
69 uint8_t *ptr; 69 uint8_t *ptr;
70 uint8_t *buffer; 70 uint8_t *buffer;
71 uint8_t *buffer_end; 71 uint8_t *buffer_end;
72 int buffer_size; 72 long buffer_size;
73 uint32_t code; 73 uint32_t code;
74 uint32_t range; 74 uint32_t range;
75 uint32_t bound; 75 uint32_t bound;
@@ -82,7 +82,7 @@ struct rc {
82#define RC_MODEL_TOTAL_BITS 11 82#define RC_MODEL_TOTAL_BITS 11
83 83
84 84
85static int INIT nofill(void *buffer, unsigned int len) 85static long INIT nofill(void *buffer, unsigned long len)
86{ 86{
87 return -1; 87 return -1;
88} 88}
@@ -99,8 +99,8 @@ static void INIT rc_read(struct rc *rc)
99 99
100/* Called once */ 100/* Called once */
101static inline void INIT rc_init(struct rc *rc, 101static inline void INIT rc_init(struct rc *rc,
102 int (*fill)(void*, unsigned int), 102 long (*fill)(void*, unsigned long),
103 char *buffer, int buffer_size) 103 char *buffer, long buffer_size)
104{ 104{
105 if (fill) 105 if (fill)
106 rc->fill = fill; 106 rc->fill = fill;
@@ -280,7 +280,7 @@ struct writer {
280 size_t buffer_pos; 280 size_t buffer_pos;
281 int bufsize; 281 int bufsize;
282 size_t global_pos; 282 size_t global_pos;
283 int(*flush)(void*, unsigned int); 283 long (*flush)(void*, unsigned long);
284 struct lzma_header *header; 284 struct lzma_header *header;
285}; 285};
286 286
@@ -534,11 +534,11 @@ static inline int INIT process_bit1(struct writer *wr, struct rc *rc,
534 534
535 535
536 536
537STATIC inline int INIT unlzma(unsigned char *buf, int in_len, 537STATIC inline int INIT unlzma(unsigned char *buf, long in_len,
538 int(*fill)(void*, unsigned int), 538 long (*fill)(void*, unsigned long),
539 int(*flush)(void*, unsigned int), 539 long (*flush)(void*, unsigned long),
540 unsigned char *output, 540 unsigned char *output,
541 int *posp, 541 long *posp,
542 void(*error)(char *x) 542 void(*error)(char *x)
543 ) 543 )
544{ 544{
@@ -667,11 +667,11 @@ exit_0:
667} 667}
668 668
669#ifdef PREBOOT 669#ifdef PREBOOT
670STATIC int INIT decompress(unsigned char *buf, int in_len, 670STATIC int INIT decompress(unsigned char *buf, long in_len,
671 int(*fill)(void*, unsigned int), 671 long (*fill)(void*, unsigned long),
672 int(*flush)(void*, unsigned int), 672 long (*flush)(void*, unsigned long),
673 unsigned char *output, 673 unsigned char *output,
674 int *posp, 674 long *posp,
675 void(*error)(char *x) 675 void(*error)(char *x)
676 ) 676 )
677{ 677{