aboutsummaryrefslogtreecommitdiff
path: root/src/lib/bootmem.c
diff options
context:
space:
mode:
authorTing Shen <phoenixshen@google.com>2019-01-28 17:22:22 +0800
committerPatrick Georgi <pgeorgi@google.com>2019-01-30 11:04:49 +0000
commit05532260aee0302e43a4935a402c7b9268036267 (patch)
treef8d94e47280d41f0cc1b612975c0754dc625c056 /src/lib/bootmem.c
parentab92f26a13f4656821f9dff93f180cb1a33c1c3e (diff)
selfload: check target memory type in selfload_check
Currently, selflock_check() verifies that the binary is loaded in an usable RAM area. Extend its functionality so we can also check that BL31 is loaded in a manually reserved area, and fail early if the range is not protected. Change-Id: Iecdeedd9e8da67f73ac47d2a82e85b306469a626 Signed-off-by: Ting Shen <phoenixshen@google.com> Reviewed-on: https://review.coreboot.org/c/31122 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
Diffstat (limited to 'src/lib/bootmem.c')
-rw-r--r--src/lib/bootmem.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/src/lib/bootmem.c b/src/lib/bootmem.c
index 2f9b5dc0b1..c804df5973 100644
--- a/src/lib/bootmem.c
+++ b/src/lib/bootmem.c
@@ -201,33 +201,25 @@ bool bootmem_walk(range_action_t action, void *arg)
return false;
}
-static int bootmem_region_targets_ram(uint64_t start, uint64_t end,
- struct memranges *bm)
+int bootmem_region_targets_type(uint64_t start, uint64_t size,
+ enum bootmem_type dest_type)
{
const struct range_entry *r;
+ uint64_t end = start + size;
- memranges_each_entry(r, bm) {
+ memranges_each_entry(r, &bootmem) {
/* All further bootmem entries are beyond this range. */
if (end <= range_entry_base(r))
break;
if (start >= range_entry_base(r) && end <= range_entry_end(r)) {
- if (range_entry_tag(r) == BM_MEM_RAM)
+ if (range_entry_tag(r) == dest_type)
return 1;
}
}
return 0;
}
-/* Common testcase for loading any segments to bootmem.
- * Returns 1 if the requested memory range is all tagged as type BM_MEM_RAM.
- * Otherwise returns 0.
- */
-int bootmem_region_targets_usable_ram(uint64_t start, uint64_t size)
-{
- return bootmem_region_targets_ram(start, start + size, &bootmem);
-}
-
void *bootmem_allocate_buffer(size_t size)
{
const struct range_entry *r;