lib/cbfs: Enable LZ4 decompression in pre-RAM stages

LZ4 decompression was being incorrectly disabled in romstage when a
separate romstage was used and CONFIG_COMPRESS_RAMSTAGE_LZ4 was not
enabled. This occurred because ENV_RAMSTAGE_LOADER is defined as
ENV_SEPARATE_ROMSTAGE in such configurations, causing
cbfs_lz4_enabled() to hit the ramstage-loader check and return false.

This regression was introduced by commit f12d2997fc ("lib/cbfs:
Don't include unused LZ4 code to shrink postcar stage"), which added
the ramstage-loader check to avoid including the LZ4 decompressor in
the postcar stage when it's not needed for the ramstage.

This patch adds an explicit check for ENV_ROMSTAGE_OR_BEFORE and
CONFIG_COMPRESS_PRERAM_STAGES to ensure LZ4 remains enabled in these
stages regardless of the ramstage compression settings.

BUG=none
TEST=Verified on Quartz

Change-Id: Icf5a2848ffe4c830bd462ab5dc7782afea3616e5
Signed-off-by: Jayvik Desai <jayvik@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/91581
Reviewed-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Reviewed-by: Kapil Porwal <kapilporwal@google.com>
Reviewed-by: Subrata Banik <subratabanik@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Jayvik Desai 2026-03-06 21:15:45 +05:30 committed by Subrata Banik
commit 1bdfc97c54

View file

@ -131,8 +131,8 @@ static inline bool cbfs_lz4_enabled(void)
if (fspm_env() && CONFIG(FSP_COMPRESS_FSP_M_LZ4))
return true;
if ((ENV_BOOTBLOCK || ENV_SEPARATE_VERSTAGE) && !CONFIG(COMPRESS_PRERAM_STAGES))
return false;
if (ENV_ROMSTAGE_OR_BEFORE && CONFIG(COMPRESS_PRERAM_STAGES))
return true;
if (ENV_SMM)
return false;