[coreboot-gerrit] Change in coreboot[master]: soc/amd/common/pi: Fix issue in AGESA heap allocator

Marc Jones (Code Review) gerrit at coreboot.org
Thu Jan 11 02:01:39 CET 2018


Marc Jones has uploaded this change for review. ( https://review.coreboot.org/23211


Change subject: soc/amd/common/pi: Fix issue in AGESA heap allocator
......................................................................

soc/amd/common/pi: Fix issue in AGESA heap allocator

The heap allocator would try to split a buffer node that
was too small for another node. In the failing case, the buffer
node was 0x140 bytes and the requested size was 0x133 bytes.
The logic would check that there was room for the header and
buffer and try to split the buffer node. The buffer node header
is 0xC bytes, so 0x13F bytes need. The problem is that it didn't
leave room for another node header and a little space for a buffer.

BUG=b:71764350
TEST= Boot grunt.
BRANCH=none

Change-Id: Iece5e12d5787415a335bb953985331a5dc312152
Signed-off-by: Marc Jones <marcj303 at gmail.com>
---
M src/soc/amd/common/block/pi/heapmanager.c
1 file changed, 4 insertions(+), 3 deletions(-)



  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/11/23211/1

diff --git a/src/soc/amd/common/block/pi/heapmanager.c b/src/soc/amd/common/block/pi/heapmanager.c
index cea3171..65a70e7 100644
--- a/src/soc/amd/common/block/pi/heapmanager.c
+++ b/src/soc/amd/common/block/pi/heapmanager.c
@@ -159,11 +159,12 @@
 							BestFitPrevNodeOffset);
 
 		/*
-		 * If BestFitNode is larger than the requested buffer,
-		 * fragment the node further
+		 * If BestFitNode is larger than the requested buffer and
+		 * has room another buffer node, fragment the node further
 		 */
 		if (BestFitNodePtr->BufferSize >
-		    (AllocParams->BufferLength + sizeof(BIOS_BUFFER_NODE))) {
+		    (AllocParams->BufferLength + sizeof(BIOS_BUFFER_NODE) +
+		     sizeof(BIOS_BUFFER_NODE) + sizeof(uint32_t))) {
 			NextFreeOffset = BestFitNodeOffset +
 					 AllocParams->BufferLength +
 					 sizeof(BIOS_BUFFER_NODE);

-- 
To view, visit https://review.coreboot.org/23211
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: Iece5e12d5787415a335bb953985331a5dc312152
Gerrit-Change-Number: 23211
Gerrit-PatchSet: 1
Gerrit-Owner: Marc Jones <marc at marcjonesconsulting.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20180111/2dd38ef9/attachment-0001.html>


More information about the coreboot-gerrit mailing list