Arthur Heymans has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/48480 )
Change subject: lib/cbfs.c: Update the cbfs_boot_device variable after cmbem_init ......................................................................
lib/cbfs.c: Update the cbfs_boot_device variable after cmbem_init
If CBFS is accessed before cbmem_init, the ro cbfs_boot_device will never point to the mcache in cbmem, so use CBMEM_INIT_HOOK to update the variable.
Change-Id: I6ce4683374c7a11c823e2f1b0b6f24e6db549ac7 Signed-off-by: Arthur Heymans arthur@aheymans.xyz --- M src/lib/cbfs.c 1 file changed, 10 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/80/48480/1
diff --git a/src/lib/cbfs.c b/src/lib/cbfs.c index 5e6fce4..3767a5d 100644 --- a/src/lib/cbfs.c +++ b/src/lib/cbfs.c @@ -449,10 +449,10 @@ return err; }
+static struct cbfs_boot_device ro; + const struct cbfs_boot_device *cbfs_get_boot_device(bool force_ro) { - static struct cbfs_boot_device ro; - /* Ensure we always init RO mcache, even if first file is from RW. Otherwise it may not be available when needed in later stages. */ if (ENV_INITIAL_STAGE && !force_ro && !region_device_sz(&ro.rdev)) @@ -487,6 +487,14 @@ return &ro; }
+static void setup_cbfs_mcache(int unused) +{ + cbfs_boot_device_find_mcache(&ro, CBMEM_ID_CBFS_RO_MCACHE); +} + +POSTCAR_CBMEM_INIT_HOOK(setup_cbfs_mcache); +RAMSTAGE_CBMEM_INIT_HOOK(setup_cbfs_mcache); + #if !CONFIG(NO_CBFS_MCACHE) static void mcache_to_cbmem(const struct cbfs_boot_device *cbd, u32 cbmem_id) {