Skip to content

Commit

Permalink
Initialize HDAT TPM Info
Browse files Browse the repository at this point in the history
Add code to initialize TPM Info on OpenPower systems to the correct
length and to all zeros.

Change-Id: Ica2cd689cdc32e93746f68fa613c8dfbca1740bc
RTC:166834
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/36967
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: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Reviewed-by: Michael Baiocchi <mbaiocch@us.ibm.com>
Reviewed-by: Stephen M. Cprek <smcprek@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
  • Loading branch information
popfuture authored and dcrowell77 committed Apr 2, 2017
1 parent d6aaf2f commit 91ada94
Show file tree
Hide file tree
Showing 5 changed files with 166 additions and 18 deletions.
25 changes: 14 additions & 11 deletions src/include/usr/hdat/hdat.H
Expand Up @@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2015,2016 */
/* Contributors Listed Below - COPYRIGHT 2015,2017 */
/* [+] International Business Machines Corp. */
/* */
/* */
Expand Down Expand Up @@ -129,25 +129,28 @@ struct hdatFruId_t
/*----------------------------------------------------------------------------*/
/* Constants */
/*----------------------------------------------------------------------------*/
const int32_t HDAT_SUCCESS = 0;
const int32_t HDAT_FAILURE = -1;
extern const int32_t HDAT_SUCCESS;
extern const int32_t HDAT_FAILURE;

/** @brief No children for a data structure*/
const uint32_t HDAT_NO_CHILD = 0;
extern const uint32_t HDAT_NO_CHILD;

/** @brief Structure id for an HDIF structure*/
const uint16_t HDAT_HDIF_STRUCT_ID = 0xD1F0;
extern const uint16_t HDAT_HDIF_STRUCT_ID;

/** @brief FFDC Version to classify data in error log */
const uint8_t HDAT_VERSION1 = 1;
extern const uint8_t HDAT_VERSION1;

/** @brief FFDC Sub Version to classify data in error log */
const uint8_t HDAT_PCIA_FFDC_SUBSEC = 1;
const uint8_t HDAT_NACA_FFDC_SUBSEC1 = 2;
const uint8_t HDAT_NACA_FFDC_SUBSEC2 = 3;
extern const uint8_t HDAT_PCIA_FFDC_SUBSEC;
extern const uint8_t HDAT_NACA_FFDC_SUBSEC1;
extern const uint8_t HDAT_NACA_FFDC_SUBSEC2;

const uint32_t HDAT_REAL_ADDRESS_MASK = 0x80000000;
const uint64_t HDAT_REAL_ADDRESS_MASK64 = 0x8000000000000000ull;
extern const uint32_t HDAT_REAL_ADDRESS_MASK;
extern const uint64_t HDAT_REAL_ADDRESS_MASK64;

/** @brief Align value for HDAT instances */
extern const uint8_t HDAT_HDIF_ALIGN;

// (this goes up to 8 threads on P8)
#define HDAT_MAX_THREADS_SUPPORTED 8
Expand Down
26 changes: 24 additions & 2 deletions src/usr/hdat/hdathdif.C
Expand Up @@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2016 */
/* Contributors Listed Below - COPYRIGHT 2016,2017 */
/* [+] International Business Machines Corp. */
/* */
/* */
Expand Down Expand Up @@ -36,7 +36,6 @@
#include "hdathdif.H"
#include "hdatutil.H"


namespace HDAT
{

Expand All @@ -53,6 +52,29 @@ const uint32_t HDAT_BOUNDARY = 16; // Pad structures to a 16 byte boundary
const char HDAT_PAD[15] = {'\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0', '\0'};

const int32_t HDAT_SUCCESS = 0;
const int32_t HDAT_FAILURE = -1;

/** @brief No children for a data structure*/
const uint32_t HDAT_NO_CHILD = 0;

/** @brief Structure id for an HDIF structure*/
const uint16_t HDAT_HDIF_STRUCT_ID = 0xD1F0;

/** @brief FFDC Version to classify data in error log */
const uint8_t HDAT_VERSION1 = 1;

/** @brief FFDC Sub Version to classify data in error log */
const uint8_t HDAT_PCIA_FFDC_SUBSEC = 1;
const uint8_t HDAT_NACA_FFDC_SUBSEC1 = 2;
const uint8_t HDAT_NACA_FFDC_SUBSEC2 = 3;

const uint32_t HDAT_REAL_ADDRESS_MASK = 0x80000000;
const uint64_t HDAT_REAL_ADDRESS_MASK64 = 0x8000000000000000ull;

/** @brief Align value for HDAT instances */
const uint8_t HDAT_HDIF_ALIGN = 128;


/** @brief See the prologue in hdathdif.H
*/
Expand Down
4 changes: 2 additions & 2 deletions src/usr/hdat/hdatspiraS.C
Expand Up @@ -646,8 +646,8 @@ errlHndl_t HdatSpiraS::loadDataArea( const hdat5Tuple_t& i_spirasHostEntry,
l_spirasEntry.hdatAllocCnt = l_count;
l_spirasEntry.hdatActualCnt = l_count;

uint32_t l_rem = l_size % 128;
uint32_t l_pad = l_rem ? (128 - l_rem) : 0;
uint32_t l_rem = l_size % HDAT_HDIF_ALIGN;
uint32_t l_pad = l_rem ? (HDAT_HDIF_ALIGN - l_rem) : 0;

l_spirasEntry.hdatAllocSize = l_size + l_pad;
l_spirasEntry.hdatActualSize = l_size;
Expand Down
86 changes: 85 additions & 1 deletion src/usr/hdat/hdattpmdata.C
Expand Up @@ -28,18 +28,26 @@
#include "hdatutil.H"
#include <sys/mm.h>
#include <sys/mmio.h>
#include <sys/internode.h>
#include <vpd/mvpdenums.H>
#include <pnor/pnorif.H>
#include <util/align.H>
#include <algorithm>

#include <devicefw/userif.H>
#include <targeting/common/util.H>
#include <targeting/common/target.H>
#include <targeting/common/targetservice.H>
#include <targeting/common/utilFilter.H>
#include <targeting/common/entitypath.H>

namespace HDAT
{

extern trace_desc_t *g_trac_hdat;

const uint8_t g_hdatTpmDataEyeCatch[] = {'T', 'P', 'M', 'R', 'E', 'L'};

HdatTpmData::HdatTpmData(errlHndl_t &o_errlHndl,
const HDAT::hdatMsAddr_t &i_msAddr):
iv_msAddr(i_msAddr),
Expand Down Expand Up @@ -135,11 +143,87 @@ HdatTpmData::~HdatTpmData()
}
}

errlHndl_t HdatTpmData::hdatLoadTpmData(uint32_t &o_size,uint32_t &o_count)
errlHndl_t HdatTpmData::hdatLoadTpmData(uint32_t &o_size, uint32_t &o_count)
{
errlHndl_t l_errl = nullptr;

o_size = 0;
o_count = 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
o_size += sizeof(hdatTpmData_t);

// account for the size of the TPM Info array header
o_size += sizeof(hdatSbTpmInfo_t);

// account for each element of the TPM Info array
o_size += ((sizeof(hdatSbTpmInstInfo_t) +
TPM_SRTM_EVENT_LOG_MAX +
TPM_DRTM_EVENT_LOG_MAX)
* hdatCalcMaxTpmsPerNode());

// account for User physical interaction mechanism info struct
// and Host I2C device information pointers
o_size += (sizeof(hdatPhysInterMechInfo_t) + sizeof(hdatI2cDevInfoPtrs_t) *
NUM_I2C_PHYS_PRESENCE_DEVICES);

// Align size value to match actual allocated size, because we also want to
// zero the padded part, and thus simplify multinode support going forward.
o_size = ALIGN_X(o_size, HDAT_HDIF_ALIGN);

// zero all of it
memset(iv_hdatTpmData,0,o_size);

// 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 eyecatcher
memcpy(iv_hdatTpmData->hdatHdr.hdatStructName,
g_hdatTpmDataEyeCatch,
sizeof(g_hdatTpmDataEyeCatch));

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

return l_errl;
}

uint16_t hdatCalcMaxTpmsPerNode()
{
size_t l_maxTpms = 0;

// calculate max # of TPMs per node

// look for class ENC type NODE and class chip TPM to find TPMs
TARGETING::TargetHandleList l_nodeEncList;

getEncResources(l_nodeEncList, TARGETING::TYPE_NODE,
TARGETING::UTIL_FILTER_ALL);

// loop thru the nodes and check number of TPMs
std::for_each(l_nodeEncList.begin(), l_nodeEncList.end(),
[&l_maxTpms](const TARGETING::Target* const i_pNode)
{
// for this Node, get a list of tpms
TARGETING::TargetHandleList l_tpmChipList;

getChildAffinityTargets ( l_tpmChipList, i_pNode,
TARGETING::CLASS_CHIP, TARGETING::TYPE_TPM, false );

l_maxTpms = std::max(l_maxTpms, l_tpmChipList.size());
} );
return l_maxTpms;
}

}
43 changes: 41 additions & 2 deletions src/usr/hdat/hdattpmdata.H
Expand Up @@ -38,12 +38,19 @@
#include <hdat/hdat_reasoncodes.H>
#include "hdatutil.H"
#include <hdat/hdat.H>
#include <sys/misc.h>

#define TPM_SRTM_EVENT_LOG_MAX (64 * KILOBYTE)

#define TPM_DRTM_EVENT_LOG_MAX (64 * KILOBYTE)

#define NUM_I2C_PHYS_PRESENCE_DEVICES 2

namespace HDAT
{

/**
* @brief Structure definition for HDAT Tpm Node Related Data header
* @brief Structure definition for HDAT Tpm Node Data Header
*/
struct hdatTpmData_t
{
Expand All @@ -61,7 +68,7 @@ struct hdatSbTpmInfo_t
{
uint32_t hdatSbTpmArrayOffset;
uint32_t hdatSbTpmArrayNumEntries;
uint32_t hdatsbTpmArraySize;
uint32_t hdatSbTpmArraySize;
} __attribute__ ((packed));


Expand All @@ -85,6 +92,28 @@ struct hdatSbTpmInstInfo_t
} __attribute__ ((packed));


/**
* @brief Structure definition for HDAT physical interaction mechanism info
*/
struct hdatPhysInterMechInfo_t
{
uint32_t hdatOffsetI2cDevInfoPtrs;
uint32_t hdatNumEntries;
uint32_t hdatSizeOfI2cDevInfoPtrs;
} __attribute__ ((packed));


/**
* @brief Structure definition for HDAT Host I2c Device Information pointers
*/
struct hdatI2cDevInfoPtrs_t
{
uint32_t hdatChipId;
uint32_t hdatDbobId; // Drawer/Book/Octant/Blade ID
uint32_t hdatHostI2cLinkId;
} __attribute__ ((packed));


/** Begin Class Description
*
* @brief The HdatTpmData class is used to construct the Node TPM Related Data
Expand Down Expand Up @@ -186,6 +215,16 @@ class HdatTpmData

}; // end of HdatTpmData class

/**
* @brief Calculate the maximum number of TPMs per node for this system.
*
* @pre None
*
* @post None
*
* @retval uint16_t Returns the maximum number of TPMs per node for this system
*/
uint16_t hdatCalcMaxTpmsPerNode();

}
#endif // HDATTPMDATA_H

0 comments on commit 91ada94

Please sign in to comment.