summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/arch/x86/postcar_loader.c3
-rw-r--r--src/include/cbmem.h2
-rw-r--r--src/lib/fit_payload.c7
-rw-r--r--src/lib/imd_cbmem.c13
-rw-r--r--src/security/memory/memory_clear.c7
-rw-r--r--src/soc/intel/xeon_sp/memmap.c3
6 files changed, 20 insertions, 15 deletions
diff --git a/src/arch/x86/postcar_loader.c b/src/arch/x86/postcar_loader.c
index 2d7bb48d7d..aac4af8568 100644
--- a/src/arch/x86/postcar_loader.c
+++ b/src/arch/x86/postcar_loader.c
@@ -147,7 +147,8 @@ static void postcar_flush_cache(void)
uintptr_t stage_cache_base;
size_t stage_cache_size;
- cbmem_get_region((void **)&cbmem_base, &cbmem_size);
+ if (cbmem_get_region((void **)&cbmem_base, &cbmem_size))
+ die("Could not find cbmem region");
prog_segment_loaded(cbmem_base, cbmem_size, SEG_FINAL);
if (CONFIG(TSEG_STAGE_CACHE) && !romstage_handoff_is_resume()) {
stage_cache_external_region((void **)&stage_cache_base, &stage_cache_size);
diff --git a/src/include/cbmem.h b/src/include/cbmem.h
index de305ae0a0..fd258cda4e 100644
--- a/src/include/cbmem.h
+++ b/src/include/cbmem.h
@@ -102,7 +102,7 @@ void cbmem_run_init_hooks(int is_recovery);
/* Add the cbmem memory used to the memory map at boot. */
void cbmem_add_bootmem(void);
/* Return the cbmem memory used */
-void cbmem_get_region(void **baseptr, size_t *size);
+int cbmem_get_region(void **baseptr, size_t *size);
void cbmem_list(void);
void cbmem_add_records_to_cbtable(struct lb_header *header);
diff --git a/src/lib/fit_payload.c b/src/lib/fit_payload.c
index 21bc4e87ed..aea1ba75e9 100644
--- a/src/lib/fit_payload.c
+++ b/src/lib/fit_payload.c
@@ -110,8 +110,8 @@ static void add_cb_fdt_data(struct device_tree *tree)
{
u32 addr_cells = 1, size_cells = 1;
u64 reg_addrs[2], reg_sizes[2];
- void *baseptr = NULL;
- size_t size = 0;
+ void *baseptr;
+ size_t size;
static const char *firmware_path[] = {"firmware", NULL};
struct device_tree_node *firmware_node = dt_find_node(tree->root,
@@ -140,8 +140,7 @@ static void add_cb_fdt_data(struct device_tree *tree)
/* Second is the CBMEM area (which usually includes the coreboot
table). */
- cbmem_get_region(&baseptr, &size);
- if (!baseptr || size == 0) {
+ if (cbmem_get_region(&baseptr, &size)) {
printk(BIOS_WARNING, "FIT: CBMEM pointer/size not found!\n");
return;
}
diff --git a/src/lib/imd_cbmem.c b/src/lib/imd_cbmem.c
index a88cf98d6c..2fc54bfff7 100644
--- a/src/lib/imd_cbmem.c
+++ b/src/lib/imd_cbmem.c
@@ -193,16 +193,19 @@ void *cbmem_entry_start(const struct cbmem_entry *entry)
void cbmem_add_bootmem(void)
{
- void *baseptr = NULL;
- size_t size = 0;
+ void *baseptr;
+ size_t size;
- cbmem_get_region(&baseptr, &size);
+ if (cbmem_get_region(&baseptr, &size)) {
+ printk(BIOS_ERR, "CBMEM pointer/size not found!\n");
+ return;
+ }
bootmem_add_range((uintptr_t)baseptr, size, BM_MEM_TABLE);
}
-void cbmem_get_region(void **baseptr, size_t *size)
+int cbmem_get_region(void **baseptr, size_t *size)
{
- imd_region_used(&imd, baseptr, size);
+ return imd_region_used(&imd, baseptr, size);
}
#if ENV_PAYLOAD_LOADER || (CONFIG(EARLY_CBMEM_LIST) && ENV_HAS_CBMEM)
diff --git a/src/security/memory/memory_clear.c b/src/security/memory/memory_clear.c
index 9af3205b0e..9a8a23a1f7 100644
--- a/src/security/memory/memory_clear.c
+++ b/src/security/memory/memory_clear.c
@@ -74,12 +74,13 @@ static void clear_memory(void *unused)
BM_MEM_RAM);
/* Add reserved entries */
- void *baseptr = NULL;
- size_t size = 0;
+ void *baseptr;
+ size_t size;
/* Only skip CBMEM, stage program, stack and heap are included there. */
- cbmem_get_region(&baseptr, &size);
+ if (cbmem_get_region(&baseptr, &size))
+ die("Could not find cbmem region");
memranges_insert(&mem, (uintptr_t)baseptr, size, BM_MEM_TABLE);
if (ENV_X86) {
diff --git a/src/soc/intel/xeon_sp/memmap.c b/src/soc/intel/xeon_sp/memmap.c
index bf4c13e4d3..b70c1cc75a 100644
--- a/src/soc/intel/xeon_sp/memmap.c
+++ b/src/soc/intel/xeon_sp/memmap.c
@@ -35,7 +35,8 @@ void fill_postcar_frame(struct postcar_frame *pcf)
size_t cbmem_size;
/* Try account for the CBMEM region currently used and for future use */
- cbmem_get_region((void **)&cbmem_base, &cbmem_size);
+ if (cbmem_get_region((void **)&cbmem_base, &cbmem_size))
+ die("Could not find cbmem region");
printk(BIOS_DEBUG, "top_of_ram = 0x%lx\n", top_of_ram);
printk(BIOS_DEBUG, "cbmem base_ptr: 0x%lx, size: 0x%zx\n", cbmem_base, cbmem_size);
/* Assume 4MiB will be enough for future cbmem objects (FSP-S, ramstage, ...) */