coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
hob_verify.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #include <cbmem.h>
4 #include <console/console.h>
5 #include <fsp/util.h>
6 
8 {
9  struct range_entry fsp_mem;
10  struct range_entry tolum;
11 
12  /* Verify the size of the TOLUM range */
14  if (range_entry_size(&tolum) < cbmem_overhead_size()) {
16  "FSP_BOOTLOADER_TOLUM_SIZE: 0x%08llx < 0x%08zx\n",
18  die("FSP_BOOTLOADER_TOLUM_HOB too small!\n");
19  }
20 
21  /* Verify the bootloader tolum is above the FSP reserved area */
22  fsp_find_reserved_memory(&fsp_mem);
23  if (range_entry_end(&tolum) <= range_entry_base(&fsp_mem)) {
25  "TOLUM end: 0x%08llx != 0x%08llx: FSP rsvd base\n",
26  range_entry_end(&tolum), range_entry_base(&fsp_mem));
27  die("FSP reserved region after BIOS TOLUM!\n");
28  }
29  if (range_entry_base(&tolum) < range_entry_end(&fsp_mem)) {
31  "TOLUM base: 0x%08llx < 0x%08llx: FSP rsvd end\n",
32  range_entry_base(&tolum), range_entry_end(&fsp_mem));
33  die("FSP reserved region overlaps BIOS TOLUM!\n");
34  }
35 
36  /* Verify that the FSP reserved area immediately follows the BIOS
37  * reserved area
38  */
39  if (range_entry_base(&tolum) != range_entry_end(&fsp_mem)) {
41  "TOLUM base: 0x%08llx != 0x%08llx: FSP rsvd end\n",
42  range_entry_base(&tolum), range_entry_end(&fsp_mem));
43  die("Space between FSP reserved region and BIOS TOLUM!\n");
44  }
45 
46  if (range_entry_end(&tolum) != (uintptr_t)cbmem_top()) {
47  printk(BIOS_CRIT, "TOLUM end: 0x%08llx != %p: cbmem_top\n",
48  range_entry_end(&tolum), cbmem_top());
49  die("Space between cbmem_top and BIOS TOLUM!\n");
50  }
51 }
void * cbmem_top(void)
Definition: imd_cbmem.c:18
static size_t cbmem_overhead_size(void)
Definition: cbmem.h:38
#define printk(level,...)
Definition: stdlib.h:16
void __noreturn die(const char *fmt,...)
Definition: die.c:17
void fsp_find_reserved_memory(struct range_entry *re)
void fsp_find_bootloader_tolum(struct range_entry *re)
void fsp_verify_memory_init_hobs(void)
Definition: hob_verify.c:7
#define BIOS_CRIT
BIOS_CRIT - Recovery unlikely.
Definition: loglevel.h:56
static resource_t range_entry_base(const struct range_entry *r)
Definition: memrange.h:44
static resource_t range_entry_end(const struct range_entry *r)
Definition: memrange.h:50
static resource_t range_entry_size(const struct range_entry *r)
Definition: memrange.h:56
unsigned long uintptr_t
Definition: stdint.h:21
Definition: memrange.h:24