Skip to content

Commit

Permalink
WOF Lid load: Remove extra malloc and use getStoredLidImage
Browse files Browse the repository at this point in the history
Currently, both hbrt and phyp are calling malloc when loading
WOF lids. This causes heap overflow when the heap is super
fragmented. So, a quick way to avoid heap overflow is to
remove malloc from HBRT. Additionally, we want to use getStoredLidImage
because it will return the cached copy of the lid if it exists.

Change-Id: I9bf6e8ec7c94d97a1998a56482f617608835d635
CQ:SW441541
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/64270
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Reviewed-by: Richard Ward <rward15@us.ibm.com>
Reviewed-by: ILYA SMIRNOV <ismirno@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
  • Loading branch information
Prachi Gupta authored and dcrowell77 committed Aug 15, 2018
1 parent c66059f commit c818c28
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/usr/fapi2/plat_wof_access.C
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,15 @@ fapi2::ReturnCode platParseWOFTables(uint8_t* o_wofData)
FAPI_INF("WOFDATA lid is %d bytes", l_lidImageSize);

#ifdef __HOSTBOOT_RUNTIME
// Locally allocate space for the lid
l_pWofImage = static_cast<void*>(malloc(l_lidImageSize));
// In HBRT case, phyp will call malloc and return
// the lid pointer to us. We do not need to malloc
// the space ourselves. In fact, two mallocs
// on the WOF partition were leading to heap overflows.
l_pWofImage = nullptr;

// Using getStoredLidImage because we want to use the cached copies
// if they exist.
l_errl = l_wofLidMgr.getStoredLidImage(l_pWofImage, l_lidImageSize);
#else
// Use a special VMM block to avoid the requirement for
// contiguous memory
Expand Down Expand Up @@ -328,11 +334,10 @@ fapi2::ReturnCode platParseWOFTables(uint8_t* o_wofData)
// Point my local pointer at the VMM space we allocated
l_pWofImage = g_wofdataVMM;

#endif


// Get the tables from pnor or lid
l_errl = l_wofLidMgr.getLid(l_pWofImage, l_lidImageSize);
#endif

if(l_errl)
{
FAPI_ERR("platParseWOFTables getLid failed "
Expand Down

0 comments on commit c818c28

Please sign in to comment.