Patrick Georgi | ac95903 | 2020-05-05 22:49:26 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Lee Leahy | 52d0c68 | 2016-08-01 15:47:42 -0700 | [diff] [blame] | 2 | |
| 3 | #include <cbmem.h> |
| 4 | #include <console/console.h> |
| 5 | #include <fsp/util.h> |
| 6 | |
Lee Leahy | 52d0c68 | 2016-08-01 15:47:42 -0700 | [diff] [blame] | 7 | void fsp_verify_memory_init_hobs(void) |
| 8 | { |
| 9 | struct range_entry fsp_mem; |
| 10 | struct range_entry tolum; |
| 11 | |
Michael Niewöhner | bc1dbb3 | 2019-10-24 22:58:25 +0200 | [diff] [blame] | 12 | /* Verify the size of the TOLUM range */ |
| 13 | fsp_find_bootloader_tolum(&tolum); |
Lee Leahy | 52d0c68 | 2016-08-01 15:47:42 -0700 | [diff] [blame] | 14 | if (range_entry_size(&tolum) < cbmem_overhead_size()) { |
| 15 | printk(BIOS_CRIT, |
Paul Menzel | 8eed67b | 2017-10-21 11:22:57 +0200 | [diff] [blame] | 16 | "FSP_BOOTLOADER_TOLUM_SIZE: 0x%08llx < 0x%08zx\n", |
Lee Leahy | 52d0c68 | 2016-08-01 15:47:42 -0700 | [diff] [blame] | 17 | range_entry_size(&tolum), cbmem_overhead_size()); |
| 18 | die("FSP_BOOTLOADER_TOLUM_HOB too small!\n"); |
| 19 | } |
| 20 | |
Jonathan Neuschäfer | 45e6c82 | 2018-12-11 17:53:07 +0100 | [diff] [blame] | 21 | /* Verify the bootloader tolum is above the FSP reserved area */ |
Michael Niewöhner | bc1dbb3 | 2019-10-24 22:58:25 +0200 | [diff] [blame] | 22 | fsp_find_reserved_memory(&fsp_mem); |
Lee Leahy | 52d0c68 | 2016-08-01 15:47:42 -0700 | [diff] [blame] | 23 | if (range_entry_end(&tolum) <= range_entry_base(&fsp_mem)) { |
| 24 | printk(BIOS_CRIT, |
| 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)) { |
| 30 | printk(BIOS_CRIT, |
| 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)) { |
| 40 | printk(BIOS_CRIT, |
| 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 | |
Felix Held | 46e6a58 | 2021-07-06 18:39:05 +0200 | [diff] [blame] | 46 | if (range_entry_end(&tolum) != (uintptr_t)cbmem_top()) { |
Julius Werner | 540a980 | 2019-12-09 13:03:29 -0800 | [diff] [blame] | 47 | printk(BIOS_CRIT, "TOLUM end: 0x%08llx != %p: cbmem_top\n", |
Lee Leahy | 52d0c68 | 2016-08-01 15:47:42 -0700 | [diff] [blame] | 48 | range_entry_end(&tolum), cbmem_top()); |
| 49 | die("Space between cbmem_top and BIOS TOLUM!\n"); |
| 50 | } |
Lee Leahy | 52d0c68 | 2016-08-01 15:47:42 -0700 | [diff] [blame] | 51 | } |