Nico Huber has uploaded this change for review. ( https://review.coreboot.org/26988
Change subject: [WIP] bootmem: Ensure payload doesn't conflict with ramstage ......................................................................
[WIP] bootmem: Ensure payload doesn't conflict with ramstage
Change-Id: I5459fe81a57609e6c766992fd7b29b985507146b Signed-off-by: Nico Huber nico.h@gmx.de --- M src/lib/bootmem.c 1 file changed, 14 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/88/26988/1
diff --git a/src/lib/bootmem.c b/src/lib/bootmem.c index 07391a5..f66feb4 100644 --- a/src/lib/bootmem.c +++ b/src/lib/bootmem.c @@ -20,6 +20,7 @@ #include <cbmem.h> #include <device/resource.h> #include <stdlib.h> +#include <program_loading.h>
static int initialized; static struct memranges bootmem; @@ -124,10 +125,18 @@
int bootmem_region_targets_usable_ram(uint64_t start, uint64_t size) { + struct memranges bootmem_tmp, *bm = &bootmem; const struct range_entry *r; uint64_t end = start + size;
- memranges_each_entry(r, &bootmem) { + if (!arch_supports_bounce_buffer()) { + memranges_clone(&bootmem_tmp, bm); + bm = &bootmem_tmp; + memranges_insert(bm, (uintptr_t)_stack, _stack_size, LB_MEM_RESERVED); + memranges_insert(bm, (uintptr_t)_program, _program_size, LB_MEM_RESERVED); + } + + memranges_each_entry(r, bm) { /* All further bootmem entries are beyond this range. */ if (end <= range_entry_base(r)) break; @@ -137,6 +146,10 @@ return 1; } } + + if (bm == &bootmem_tmp) + memranges_teardown(bm); + return 0; }