[coreboot-gerrit] Change in coreboot[master]: [WIP] bootmem: Ensure payload doesn't conflict with ramstage

Nico Huber (Code Review) gerrit at coreboot.org
Fri Jun 8 20:25:48 CEST 2018


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 at 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;
 }
 

-- 
To view, visit https://review.coreboot.org/26988
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5459fe81a57609e6c766992fd7b29b985507146b
Gerrit-Change-Number: 26988
Gerrit-PatchSet: 1
Gerrit-Owner: Nico Huber <nico.h at gmx.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20180608/41a8be9f/attachment.html>


More information about the coreboot-gerrit mailing list