coreboot/util/cbfstool
Arthur Heymans 0421ef2cd8 util/cbfstool: Add zstd support
This adds zstd support to cbfstool. The code is taken from zstd-1.5.7
with modifications:
- renaming bits.h to zstd_bits.h to avoid conflicts with coreboot's
  bits.h used on riscv
- renaming compiler.h to zstd_compiler.h to avoid conflicts with
  coreboot's compiler.h
- Dropped all streaming API functions
- Dropped multithreaded support, since it's now unused
- Dropped local DDict support

zstd offers similar compression ratios to LZMA, but a vastly fast
decompress speed. Typically zstd results in slightly larger binaries
than LZMA. Whether zstd should then be preferred over LZMA depends on
a few things:
- Caching: When loading from memory mapped boot devices, zstd will read
  the boot medium multiple times, while LZMA will not. If the memory
  mapped boot medium is not cached zstd results in much slower
  decompression.
- Boot medium speed: Often, but not always LZMA results in smaller
  binaries. If the boot medium is the bottleneck, than loading smaller
  binaries might actually be faster. On a fast boot medium (high spi
  freq, using quad/dual io), the performance benefits from zstd might be
  more substantial
- zstd decompression code has a much larger footprint than LZMA. If the
  stage (postcar) is loaded in uncached memory the size increase might
  slow things down.
  On QEMU Q35 postcar .text section size doubled, while heap section
  has growen by 50%.
- zstd uses a lot of .bss (CTX is about 32KiB large). This might not be
  available in some environments.

Orignal commit from 2022 was using zstd-1.5.2. Updated to zstd-1.5.7.

Change-Id: I34508268f8767008ef25cb9e466d201345881232
Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/69753
Reviewed-by: Julius Werner <jwerner@chromium.org>
Reviewed-by: Matt DeVillier <matt.devillier@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2025-12-20 17:35:43 +00:00
..
bpdt_formats util: Rename Makefiles from .inc to .mk 2024-01-26 12:43:18 +00:00
console util/cbfstool: Wrap logging macros in do - while 2022-10-13 17:07:02 +00:00
flashmap util/cbfstool: Refine type and signatures 2025-01-12 07:54:27 +00:00
fpt_formats util: Rename Makefiles from .inc to .mk 2024-01-26 12:43:18 +00:00
lz4 lib/xxhash: Move to commonlib/bsd 2025-12-20 17:35:33 +00:00
lzma
tests
.gitignore
amdcompress.c util/cbfstool/amdcompress: Bail out on invalid ELF 2025-07-23 17:00:41 +00:00
cbfs-mkpayload.c cbfs: Remove broken remnants of PAYLOAD_INFO feature 2024-03-13 18:51:11 +00:00
cbfs-mkstage.c util/cbfstool: Deal with how lld organizes loadable segments 2024-11-06 04:54:22 +00:00
cbfs-payload-linux.c util/cbfstool/cbfs-payload-linux.c: Remove TODO 2025-11-06 20:48:21 +00:00
cbfs.h util/cbfstool: Add zstd support 2025-12-20 17:35:43 +00:00
cbfs_glue.h cbfs/vboot: Adapt to new vb2_digest API 2022-09-02 23:51:29 +00:00
cbfs_image.c util/cbfstool: Add missing \n and use __func__ in debug messages 2025-02-27 16:24:53 +00:00
cbfs_image.h util/cbfstool: Fix truncate command error handling and cbfs_image_from_buffer() 2022-08-03 23:24:49 +00:00
cbfs_sections.c
cbfs_sections.h
cbfscomptool.c
cbfstool.c lib/xxhash: Move to commonlib/bsd 2025-12-20 17:35:33 +00:00
coff.h
common.c treewide: Work around GCC 15 Werror=unterminated-string-initialization 2025-06-09 07:19:09 +00:00
common.h util/cbfstool/common.h Fix wrong return value doc 2024-08-05 13:10:08 +00:00
compress.c util/cbfstool: Add zstd support 2025-12-20 17:35:43 +00:00
cse_fpt.c
cse_fpt.h
cse_helpers.c
cse_helpers.h
cse_serger.c region: Turn region_end() into an inclusive region_last() 2024-08-23 01:08:16 +00:00
cse_serger.h
default-x86.fmd mb/*/*/*.fmd: Start flash at 0 2025-04-09 17:11:43 +00:00
default.fmd mb/*/*/*.fmd: Start flash at 0 2025-04-09 17:11:43 +00:00
description.md
elf.h
elfheaders.c cbfstool: Read XIP stage alignment requirements from ELF 2024-06-20 19:34:14 +00:00
elfparsing.h cbfstool: Read XIP stage alignment requirements from ELF 2024-06-20 19:34:14 +00:00
elogtool.c util/cbfstool/eventlog: Use LocalTime or UTC timestamps 2023-03-02 13:05:35 +00:00
eventlog.c commonlib/bsd: Add Bluetooth wake source in ELOG event data 2025-09-10 21:39:05 +00:00
eventlog.h util/cbfstool/eventlog: Use LocalTime or UTC timestamps 2023-03-02 13:05:35 +00:00
EXAMPLE
fdt.h
fit.c ifittool: allow adding files from a separate region 2025-11-16 18:35:12 +00:00
fit.h ifittool: allow adding files from a separate region 2025-11-16 18:35:12 +00:00
flashmap_tests.c
flashrom.c util: Drop flashrom -p host alias which equals to -p internal 2023-09-25 14:06:32 +00:00
flashrom.h treewide: Unify Google branding 2022-07-04 14:02:26 +00:00
fmap_from_fmd.c
fmap_from_fmd.h
fmaptool.c
fmd.c
fmd.h
fmd_parser.c_shipped util/cbfstool: Revise lex/yacc (bison) generation 2023-09-28 21:28:37 +00:00
fmd_parser.h_shipped util/cbfstool: Revise lex/yacc (bison) generation 2023-09-28 21:28:37 +00:00
fmd_parser.y
fmd_scanner.c_shipped util/cbfstool: Revise lex/yacc (bison) generation 2023-09-28 21:28:37 +00:00
fmd_scanner.h_shipped util/cbfstool: Revise lex/yacc (bison) generation 2023-09-28 21:28:37 +00:00
fmd_scanner.l
fv.h
ifittool.c ifittool: allow adding files from a separate region 2025-11-16 18:35:12 +00:00
ifwitool.c util: Use C99 flexible arrays 2023-08-01 12:51:25 +00:00
linux.h util/cbfstool: Qualify struct e820entry as packed 2023-04-16 14:04:32 +00:00
linux_trampoline.c util/cbfstool/linux_trampoline: Support more e820 entries 2024-02-18 07:50:28 +00:00
linux_trampoline.h
linux_trampoline.S util/cbfstool: Fix linux_trampoline.c generation 2024-06-03 16:54:02 +00:00
Makefile util: Break up spdx identifier text in scripts & makefiles 2024-06-19 17:42:43 +00:00
Makefile.mk util/cbfstool: Add zstd support 2025-12-20 17:35:43 +00:00
option.h
partitioned_file.c
partitioned_file.h
platform_fixups.c cbfstool: Add multi ELF support 2025-06-26 16:56:14 +00:00
ProcessorBind.h
rmodtool.c
rmodule.c cbfstool: Skip relocation entries pointing to undefined symbol 2023-10-20 14:32:20 +00:00
rmodule.h cbfstool: Make add-stage support multiple loadable segments 2023-09-14 21:01:56 +00:00
xdr.c