Skip to content

Commit

Permalink
Propagate TPM information into HDAT on non-master nodes
Browse files Browse the repository at this point in the history
Extends HDAT population to add TPM data to all functional nodes
- Added message sends from the master to each node
- Each node updates # of instances, sizes of structures, etc.
- Each node navigates to its appropriate offset in HDAT
- HDAT now populates entries for all TPMs in the blueprint
- Physical presence interaction mechanism is master-only obtained
- TPM SRTM and DRTM logs are no longer interlaced between TPM info
- Single node workaround reverted

Change-Id: Ic77cbeb7ba3d35a9f02ba68525ed79f27159e9bf
RTC:167290
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/55283
Reviewed-by: Nicholas E. Bofferding <bofferdn@us.ibm.com>
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: ILYA SMIRNOV <ismirno@us.ibm.com>
Reviewed-by: Michael Baiocchi <mbaiocch@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
  • Loading branch information
popfuture authored and dcrowell77 committed Apr 6, 2018
1 parent d5ba462 commit be53610
Show file tree
Hide file tree
Showing 8 changed files with 224 additions and 71 deletions.
1 change: 1 addition & 0 deletions src/include/usr/mbox/ipc_msg_types.H
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ namespace IPC
IPC_CLOSE_TCES,
IPC_FREQ_ATTR_DATA, // frequency attribute data from master to other drawers

IPC_POPULATE_TPM_INFO_BY_NODE,
};

}; // namespace IPC
Expand Down
1 change: 1 addition & 0 deletions src/include/usr/mbox/mbox_queues.H
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ namespace MBOX
HB_SBE_SYSCONFIG_MSGQ = 12, //For SBE System Config response
HB_CLOSE_TCES_MSGQ = 13, // close/disable TCEs
HB_FREQ_ATTR_DATA_MSGQ = 14, // freq attributes data from master to all other drawers
HB_POP_TPM_INFO_MSGQ = 15, // response to populate TPM info by node

// Add HB mbox msg queue ids (services) before this line
HB_LAST_VALID_MSGQ, // end of valid HB mbox msgQ ids
Expand Down
14 changes: 12 additions & 2 deletions src/include/usr/runtime/runtime.H
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,21 @@ errlHndl_t populate_hbSecurebootData( void );
errlHndl_t populate_hbTpmInfo( void );

/**
* @brief Fills in Tpm Info in HDAT for current node
* @brief Fills in Tpm Info in HDAT for node passed in to the specified HDAT
* instance
*
* @param[in] i_instance - the instance number to use to populate the current
* node's data into HDAT, as directed by the master node.
* This function is typically called upon receiving a
* message of type IPC_POPULATE_TPM_INFO_BY_NODE, which
* provides the instance to use as an MBOX parameter. Each
* node must have a unique instance number, but beyond that
* there is no guaranteed direct correlation between nodes
* and instances at all.
*
* @return errlHndl_t nullptr on success else pointer to error log
*/
errlHndl_t populate_TpmInfoByNode();
errlHndl_t populate_TpmInfoByNode(const uint64_t i_instance);

/**
* @brief Timer function for safe error handling in sendSBESystemConfig
Expand Down
11 changes: 2 additions & 9 deletions src/usr/hdat/hdatcommonutil.C
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2017 */
/* Contributors Listed Below - COPYRIGHT 2017,2018 */
/* [+] International Business Machines Corp. */
/* */
/* */
Expand Down Expand Up @@ -72,17 +72,10 @@ uint16_t hdatCalcMaxTpmsPerNode()
return l_maxTpms;
}

uint32_t hdatTpmDataCalcMaxSize()
uint32_t hdatTpmDataCalcInstanceSize()
{
uint32_t l_size = 0;

// TODO RTC 167290 - In order to support multiple nodes, this calculation
// needs to be #nodes * [ the entire 18.x set of structures ] and the
// initialization needs to be done on each instance. The reported size
// (in variable o_size) needs to be the size of a single instance and the
// reported count (via o_count) needs to be the number of nodes. For now,
// we assume one node.

// account for the size of the TPM data header
l_size += sizeof(hdatTpmData_t);

Expand Down
57 changes: 40 additions & 17 deletions src/usr/hdat/hdattpmdata.C
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2017 */
/* Contributors Listed Below - COPYRIGHT 2017,2018 */
/* [+] International Business Machines Corp. */
/* */
/* */
Expand Down Expand Up @@ -55,7 +55,23 @@ HdatTpmData::HdatTpmData(errlHndl_t &o_errlHndl,

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

// get the top level target
TARGETING::Target* sys = nullptr;
TARGETING::targetService().getTopLevelTarget( sys );
assert(sys != nullptr,
"HdatTpmData::HdatTpmData: Bug! Could not obtain top level target");

// get the node bit string to see what our node layout looks like
auto l_nodeBits = sys->getAttr<TARGETING::ATTR_HB_EXISTING_IMAGE>();

// count the bits to get the functional/present nodes
iv_numNodes = __builtin_popcount(l_nodeBits);

// Must be at least one. Add one in the zero case.
iv_numNodes += !iv_numNodes;

const auto maxLogicalSize = hdatTpmDataCalcInstanceSize() * iv_numNodes;
const uint64_t l_size = ALIGN_PAGE(maxLogicalSize) + PAGESIZE;

const uint64_t l_alignedAddr = ALIGN_PAGE_DOWN(l_baseAddr);
Expand All @@ -69,9 +85,6 @@ HdatTpmData::HdatTpmData(errlHndl_t &o_errlHndl,
iv_hdatTpmData = reinterpret_cast<hdatTpmData_t *>(l_virtAddr +
l_offset);

// 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, maxLogicalSize);

HDAT_DBG("Ctr iv_hdatTpmData addr 0x%.16llX virtual addr 0x%.16llX",
Expand Down Expand Up @@ -147,25 +160,35 @@ errlHndl_t HdatTpmData::hdatLoadTpmData(uint32_t &o_size, uint32_t &o_count)

o_count = 0;

o_size = hdatTpmDataCalcMaxSize();
// calculate the size of each instance
o_size = hdatTpmDataCalcInstanceSize();

// Note: HdatTpmData constructor already cleared the memory to the tune of
// o_size (hdatTpmDataCalcMaxSize()) bytes
auto l_hdatTpmData = iv_hdatTpmData;

// 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
// work here would just be duplicated later during the runtime istep.
for (uint32_t i_instance = 0; i_instance < iv_numNodes; i_instance++)
{
// Note: HdatTpmData constructor already cleared the memory to the tune
// of o_size (hdatTpmDataCalcInstanceSize()) 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
// work here would just be duplicated later during the runtime istep.

// add the format magic number
iv_hdatTpmData->hdatHdr.hdatStructId = HDAT::HDAT_HDIF_STRUCT_ID;
// add the format magic number
iv_hdatTpmData->hdatHdr.hdatStructId = HDAT::HDAT_HDIF_STRUCT_ID;

// add the eyecatcher
memcpy(iv_hdatTpmData->hdatHdr.hdatStructName,
// add the eyecatcher
memcpy(iv_hdatTpmData->hdatHdr.hdatStructName,
g_hdatTpmDataEyeCatch,
strlen(g_hdatTpmDataEyeCatch));

// account for this one instance of Node TPM Related Data
++o_count;
// Account for this one instance of Node TPM Related Data.
++o_count;

// Move to the next instance
l_hdatTpmData = reinterpret_cast<hdatTpmData_t *>(
reinterpret_cast<uint8_t*>(l_hdatTpmData) + o_size);
}

return l_errl;
}
Expand Down
17 changes: 12 additions & 5 deletions src/usr/hdat/hdattpmdata.H
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2017 */
/* Contributors Listed Below - COPYRIGHT 2017,2018 */
/* [+] International Business Machines Corp. */
/* */
/* */
Expand Down Expand Up @@ -239,10 +239,11 @@ class HdatTpmData

private:

HDAT::hdatMsAddr_t iv_msAddr;
HDAT::hdatMsAddr_t iv_msAddr;

hdatTpmData_t *iv_hdatTpmData;

uint32_t iv_numNodes;

}; // end of HdatTpmData class

Expand All @@ -258,15 +259,21 @@ class HdatTpmData
uint16_t hdatCalcMaxTpmsPerNode();

/**
* @brief Calculate the maximum size of the HDAT TPM data section
* @brief Calculate the maximum size of an instance of HDAT TPM data. There
* will be one instance per functional node in the system. It is assumed
* that this function will be used determine how much space one node's
* worth of HDAT TPM data will occupy worst case. It is assumed that each
* instance will have the same max size and that the instances will be
* placed one after another in memory (not page aligned) with enough
* space to accommodate the maximum possible size of each node.
*
* @pre None
*
* @post None
*
* @retval uint32_t Maximum size of the HDAT TPM data section
* @retval uint32_t Maximum size of one instance of HDAT TPM data.
*/
uint32_t hdatTpmDataCalcMaxSize();
uint32_t hdatTpmDataCalcInstanceSize();

}
#endif // HDATTPMDATA_H
32 changes: 30 additions & 2 deletions src/usr/mbox/ipcSp.C
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,35 @@ void IpcSp::msgHandler()

switch(msg->type)
{
case IPC_POPULATE_TPM_INFO_BY_NODE:
{
// msg->extra_data contains PAYLOAD Base
RUNTIME::setPayloadBaseAddress(
reinterpret_cast<uint64_t>(msg->extra_data));

// msg->data[0] contains the HDAT TPM info instance to populate
err = RUNTIME::populate_TpmInfoByNode(msg->data[0]);

if (err)
{
TRACFCOMP( g_trac_ipc, ERR_MRK"IpcSp::msgHandler: populate_TpmInfoByNode errored - must shutdown now!!!");
const auto l_errPlid = err->plid();
errlCommit(err, IPC_COMP_ID);
INITSERVICE::doShutdown(l_errPlid, true);
}

// give a response back to the sender
err = MBOX::send(MBOX::HB_POP_TPM_INFO_MSGQ, msg, msg->data[1]);
if (err)
{
const auto l_errPlid = err->plid();
errlCommit(err,IPC_COMP_ID);
msg_free(msg);
INITSERVICE::doShutdown(l_errPlid, true);
}
break;
}

case IPC_POPULATE_ATTRIBUTES:
// make sure runtime module is loaded
if ( !VFS::module_is_loaded( "libruntime.so" ) )
Expand Down Expand Up @@ -266,8 +295,7 @@ void IpcSp::msgHandler()
INITSERVICE::doShutdown(l_errPlid, true);
}
break;
}

}
case IPC_FREQ_ATTR_DATA:
{
TRACFCOMP( g_trac_ipc,
Expand Down

0 comments on commit be53610

Please sign in to comment.