Raul Rangel has submitted this change. ( https://review.coreboot.org/c/coreboot/+/56577 )
Change subject: lib/cbfs: Enable cbfs_cache for x86 ......................................................................
lib/cbfs: Enable cbfs_cache for x86
The reason cbfs_cache was disabled on x86 was due to the lack of .data sections in the pre-RAM stages. By using ENV_STAGE_HAS_DATA_SECTION we enable x86 to start using the cbfs_cache.
We still need to add a cbfs_cache region into the memlayout for it to be enabled.
BUG=b:179699789 TEST=Build guybrush and verify cbfs_cache.size == 0.
Suggested-by: Julius Werner jwerner@chromium.org Signed-off-by: Raul E Rangel rrangel@chromium.org Change-Id: I74434ef9250ff059e7587147b1456aeabbee33aa Reviewed-on: https://review.coreboot.org/c/coreboot/+/56577 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Julius Werner jwerner@chromium.org Reviewed-by: Karthik Ramasubramanian kramasub@google.com --- M src/include/cbfs.h M src/lib/cbfs.c 2 files changed, 12 insertions(+), 11 deletions(-)
Approvals: build bot (Jenkins): Verified Julius Werner: Looks good to me, approved Karthik Ramasubramanian: Looks good to me, approved
diff --git a/src/include/cbfs.h b/src/include/cbfs.h index f27c60f..0d8ac60 100644 --- a/src/include/cbfs.h +++ b/src/include/cbfs.h @@ -111,12 +111,7 @@
/* * The shared memory pool for backing mapped CBFS files, and other CBFS allocation needs. - * On x86 platforms, this would only be needed to transparently map compressed files, but it - * would require a permanent CBMEM carveout to be safe to use during S3 resume. Since it's not - * clear whether this feature is necessary or worth the wasted memory, it is currently disabled - * but could be added behind a Kconfig later if desired. */ -#define CBFS_CACHE_AVAILABLE (!CONFIG(ARCH_X86)) extern struct mem_pool cbfs_cache;
/* diff --git a/src/lib/cbfs.c b/src/lib/cbfs.c index 52f7373..322f161 100644 --- a/src/lib/cbfs.c +++ b/src/lib/cbfs.c @@ -18,8 +18,11 @@ #include <symbols.h> #include <timestamp.h>
-#if CBFS_CACHE_AVAILABLE +#if ENV_STAGE_HAS_DATA_SECTION struct mem_pool cbfs_cache = MEM_POOL_INIT(_cbfs_cache, REGION_SIZE(cbfs_cache)); +#else +struct mem_pool cbfs_cache = MEM_POOL_INIT(NULL, 0); +#endif
static void switch_to_postram_cache(int unused) { @@ -28,7 +31,6 @@ REGION_SIZE(postram_cbfs_cache)); } ROMSTAGE_CBMEM_INIT_HOOK(switch_to_postram_cache); -#endif
cb_err_t cbfs_boot_lookup(const char *name, bool force_ro, union cbfs_mdata *mdata, struct region_device *rdev) @@ -111,8 +113,7 @@ * that requires a free() for the boot_device, they need to implement it via the * cbfs_cache mem_pool. */ - if (CBFS_CACHE_AVAILABLE) - mem_pool_free(&cbfs_cache, mapping); + mem_pool_free(&cbfs_cache, mapping); }
int cbfs_locate_file_in_region(struct cbfsf *fh, const char *region_name, @@ -319,8 +320,13 @@ }
return mapping; - } else if (!CBFS_CACHE_AVAILABLE) { - ERROR("Cannot map compressed file %s on x86\n", mdata.h.filename); + } else if (!cbfs_cache.size) { + /* + * In order to use the cbfs_cache you need to add a CBFS_CACHE to your + * memlayout. For stages that don't have .data sections (x86 pre-RAM), + * it is not possible to add a CBFS_CACHE. + */ + ERROR("Cannot map compressed file %s without cbfs_cache\n", mdata.h.filename); return NULL; } else { loc = mem_pool_alloc(&cbfs_cache, size);