Skip to contentSkip to conversation

Fix flags for initramfs LZ4 compression

PATCH In review Daniel M. Weeks 3 participants 4 messages Feb 15, 2014 – Feb 19, 2014 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix flags for initramfs LZ4 compression

LZ4 as implemented in the kernel differs from the default method now used by the reference implementation of LZ4. Until the in-kernel method is updated to support the new default, passing the legacy flag (-l) to the compressor is necessary. Without this flag the kernel-generated, LZ4-compressed initramfs is junk.

---
 scripts/gen_initramfs_list.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/gen_initramfs_list.sh +1 -1
index ef47409..17fa901 100644
@@ -257,7 +257,7 @@ case "$arg" in
                 && compr="lzop -9 -f"
 		echo "$output_file" | grep -q "\.lz4$" \
                 && [ -x "`which lz4 2> /dev/null`" ] \
-                && compr="lz4 -9 -f"
+                && compr="lz4 -l -9 -f"
 		echo "$output_file" | grep -q "\.cpio$" && compr="cat"
 		shift
 		;;
Signature · 1 line
Daniel M. Weeks
#1 lore raw
Quoted 5 lines · On Sat, 15 Feb 2014 18:14:57 -0500 "Daniel M. Weeks" <[email protected]> wrote:

LZ4 as implemented in the kernel differs from the default method now used by the reference implementation of LZ4. Until the in-kernel method is updated to support the new default, passing the legacy flag (-l) to the compressor is necessary. Without this flag the kernel-generated, LZ4-compressed initramfs is junk.

Well that's bad. Kyungsik, cuold you please comment?

Quoted 11 lines
scripts/gen_initramfs_list.sh +1 -1
@@ -257,7 +257,7 @@ case "$arg" in
                 && compr="lzop -9 -f"
 		echo "$output_file" | grep -q "\.lz4$" \
                 && [ -x "`which lz4 2> /dev/null`" ] \
-                && compr="lz4 -9 -f"
+                && compr="lz4 -l -9 -f"
 		echo "$output_file" | grep -q "\.cpio$" && compr="cat"
 		shift
 		;;
#2 lore raw
In reply to Daniel M. Weeks
Quoted 11 lines · On Sat, 15 Feb 2014 18:14:57 -0500 "Daniel M. Weeks" <[email protected]> wrote:

LZ4 as implemented in the kernel differs from the default method now used by the reference implementation of LZ4. Until the in-kernel method is updated to support the new default, passing the legacy flag (-l) to the compressor is necessary. Without this flag the kernel-generated, LZ4-compressed initramfs is junk.

...

scripts/gen_initramfs_list.sh case "$arg" in · line 263

Quoted 8 lines
scripts/gen_initramfs_list.sh +1 -1
@@ -257,7 +257,7 @@ case "$arg" in
                 && compr="lzop -9 -f"
 		echo "$output_file" | grep -q "\.lz4$" \
                 && [ -x "`which lz4 2> /dev/null`" ] \
-                && compr="lz4 -9 -f"
+                && compr="lz4 -l -9 -f"
 		echo "$output_file" | grep -q "\.cpio$" && compr="cat"
 		shift
 		;;

What happens is the user is running an old version of /bin/lz4? A version which predates this switch to a new format? Do those earlier versions accept -l, even though they don't need it? Or will the kernel build fail?

Acked-by
#3 lore raw

Hello,

Quoted 10 lines · Andrew Morton
Quoted 8 lines · On Sat, 15 Feb 2014 18:14:57 -0500 "Daniel M. Weeks" <[email protected]> wrote:

LZ4 as implemented in the kernel differs from the default method now used by the reference implementation of LZ4. Until the in-kernel method is updated to support the new default, passing the legacy flag (-l) to the compressor is necessary. Without this flag the kernel-generated, LZ4-compressed initramfs is junk.

...

Quoted 16 lines

scripts/gen_initramfs_list.sh case "$arg" in · line 263

Quoted 11 lines
scripts/gen_initramfs_list.sh +1 -1
@@ -257,7 +257,7 @@ case "$arg" in
                 && compr="lzop -9 -f"
 		echo "$output_file" | grep -q "\.lz4$" \
                 && [ -x "`which lz4 2> /dev/null`" ] \
-                && compr="lz4 -9 -f"
+                && compr="lz4 -l -9 -f"
 		echo "$output_file" | grep -q "\.cpio$" && compr="cat"
 		shift
 		;;

What happens is the user is running an old version of /bin/lz4? A version which predates this switch to a new format? Do those earlier versions accept -l, even though they don't need it? Or will the kernel build fail?

It seems that lz4 supports legacy format with the same option as lz4c does. Just looking at the first few bytes of lz4 compressed image, we can see whether it is new format or not.

It shows new format magic number without this patch. New format magic number is 0x184d2204.

$ hexdump -C ./initramfs_data.cpio.lz4 |more
00000000  04 22 4d 18 64 70 b9 69 (Little Endian)
...

Currently Kernel supports legacy format only.

Thanks,
Kyungsik