Skip to content

Commit

Permalink
Fix size calculation when allocating TPM data
Browse files Browse the repository at this point in the history
- Allocated max size before clearing TPM related HDAT data
- Eliminated duplicate TPM related HDAT data clear

Change-Id: I3cb38204e4641ec9e02c6c6dda29bf0fc08c9694
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/42411
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Reviewed-by: Stephen M. Cprek <smcprek@us.ibm.com>
Reviewed-by: Michael Baiocchi <mbaiocch@us.ibm.com>
Reviewed-by: Prachi Gupta <pragupta@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
  • Loading branch information
Nick Bofferding authored and dcrowell77 committed Jun 27, 2017
1 parent 81acff6 commit dee2360
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/usr/hdat/hdattpmdata.C
Expand Up @@ -55,8 +55,8 @@ HdatTpmData::HdatTpmData(errlHndl_t &o_errlHndl,

const uint64_t l_baseAddr = static_cast<uint64_t>(i_msAddr.hi) << 32
| i_msAddr.lo;

const uint64_t l_size = ALIGN_PAGE(sizeof(hdatTpmData_t)) + PAGESIZE;
const auto maxLogicalSize = hdatTpmDataCalcMaxSize();
const uint64_t l_size = ALIGN_PAGE(maxLogicalSize) + PAGESIZE;

const uint64_t l_alignedAddr = ALIGN_PAGE_DOWN(l_baseAddr);

Expand All @@ -72,7 +72,7 @@ HdatTpmData::HdatTpmData(errlHndl_t &o_errlHndl,
// TODO RTC 167290 - This memset needs to be revisited for multinode
// support. We may need to do this memset once per node or use some
// other approach to initialization.
memset(iv_hdatTpmData, 0x0, sizeof(hdatTpmData_t));
memset(iv_hdatTpmData, 0x0, maxLogicalSize);

HDAT_DBG("Ctr iv_hdatTpmData addr 0x%.16llX virtual addr 0x%.16llX",
reinterpret_cast<uint64_t>(iv_hdatTpmData),
Expand Down Expand Up @@ -149,8 +149,8 @@ errlHndl_t HdatTpmData::hdatLoadTpmData(uint32_t &o_size, uint32_t &o_count)

o_size = hdatTpmDataCalcMaxSize();

// zero all of it
memset(iv_hdatTpmData,0,o_size);
// Note: HdatTpmData constructor already cleared the memory to the tune of
// o_size (hdatTpmDataCalcMaxSize()) bytes

// We add the first two fields for a reference to aid in debugging,
// but the rest will be populated in FSP/OpenPower common code. Any
Expand Down

0 comments on commit dee2360

Please sign in to comment.