Skip to content

Commit 0fe4f4e

Browse files
terrellnIngo Molnar
authored andcommitted
x86: Bump ZO_z_extra_bytes margin for zstd
Bump the ZO_z_extra_bytes margin for zstd. Zstd needs 3 bytes per 128 KB, and has a 22 byte fixed overhead. Zstd needs to maintain 128 KB of space at all times, since that is the maximum block size. See the comments regarding in-place decompression added in lib/decompress_unzstd.c for details. The existing code is written so that all the compression algorithms use the same ZO_z_extra_bytes. It is taken to be the maximum of the growth rate plus the maximum fixed overhead. The comments just above this diff state that: Signed-off-by: Nick Terrell <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Tested-by: Sedat Dilek <[email protected]> Reviewed-by: Kees Cook <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent a30d8a3 commit 0fe4f4e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

arch/x86/boot/header.S

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,8 +539,14 @@ pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
539539
# the size-dependent part now grows so fast.
540540
#
541541
# extra_bytes = (uncompressed_size >> 8) + 65536
542+
#
543+
# ZSTD compressed data grows by at most 3 bytes per 128K, and only has a 22
544+
# byte fixed overhead but has a maximum block size of 128K, so it needs a
545+
# larger margin.
546+
#
547+
# extra_bytes = (uncompressed_size >> 8) + 131072
542548

543-
#define ZO_z_extra_bytes ((ZO_z_output_len >> 8) + 65536)
549+
#define ZO_z_extra_bytes ((ZO_z_output_len >> 8) + 131072)
544550
#if ZO_z_output_len > ZO_z_input_len
545551
# define ZO_z_extract_offset (ZO_z_output_len + ZO_z_extra_bytes - \
546552
ZO_z_input_len)

0 commit comments

Comments
 (0)