Skip to content

Commit

Permalink
Add TPM Presence Info to HDAT
Browse files Browse the repository at this point in the history
Populate HDAT TPM Section with TPM Presence Info by refering to
link IDs in HDAT PCRD section and verify that the PRCD section's
list of link IDs are unique and valid.

Change-Id: I49956aae129b325f55a6358caa0af4da1951b58c
RTC:170638
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/39658
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Reviewed-by: Nicholas E. Bofferding <bofferdn@us.ibm.com>
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Reviewed-by: Stephen M. Cprek <smcprek@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
  • Loading branch information
popfuture authored and dcrowell77 committed May 23, 2017
1 parent 8a22766 commit 096ef90
Show file tree
Hide file tree
Showing 11 changed files with 509 additions and 61 deletions.
16 changes: 15 additions & 1 deletion src/include/usr/runtime/runtime.H
Expand Up @@ -137,7 +137,8 @@ enum SectionId
SPIRA_L, //< Legacy SPIRA
NACA, //< NACA
HBRT, //< Hostboot Runtime
HBRT_DATA, //< Hostboot Runtime Data
HBRT_DATA, //< Hostboot Runtime Data
PCRD, //< Processor Chip Related Data
IPMI_DATA, //< IPMI Sensor Mapping Data
NODE_TPM_RELATED, //< Node TPM Related Data
RESERVED_MEM, //< Hostboot's Reserved Mainstore Memory
Expand All @@ -164,6 +165,19 @@ errlHndl_t get_host_data_section( SectionId i_section,
size_t& o_dataSize );
const size_t DATA_SIZE_UNKNOWN = 0xFFFFFFFFFFFFFFFF;

/**
* @brief Get the number of instances in a given section.
*
* @param[in] i_section The section for which the instance count is desired
*
* @param[out] o_count The number of instances in this section
*
* @return errlHndl_t Returns nullptr on success. Returns an error if the
* section id used is invalid or has no concept of instances. Also, can
* return an error if the n-tuple is either corrupt or unavailable.
*/
errlHndl_t get_instance_count( RUNTIME::SectionId i_section, uint64_t& o_count);

/**
* @brief Store the actual count of a section in local memory.
*
Expand Down
71 changes: 39 additions & 32 deletions src/include/usr/runtime/runtime_reasoncodes.H
Expand Up @@ -43,6 +43,7 @@ namespace RUNTIME
MOD_HDATSERVICE_FINDSPIRA = 0x09, /** hdatservice.C */
MOD_HDATSERVICE_UPDATE_SECTION_ACTUAL = 0x0A, /**< hdatservice.C */
MOD_HDATSERVICE_MAPREGION = 0x0B, /**< hdatservice.C */
MOD_HDATSERVICE_GETINSTANCECOUNT = 0x0C, /**< hdatservice.C */

// customize_attrs_for_payload.C
MOD_CUST_COMP_NON_PHYP_RT_TARGET = 0x12,
Expand All @@ -52,43 +53,49 @@ namespace RUNTIME
MOD_PM_RT_HCODE_UPDATE = 0x16, /**< rt_pm.C */
MOD_MAP_PHYS_ADDR = 0x17, /**< populate_hbruntime.C */
MOD_UNMAP_VIRT_ADDR = 0x18, /**< populate_hbruntime.C */
MOD_POPULATE_TPMINFOBYNODE = 0x19, /**< populate_hbruntime.C */
};

enum RuntimeReasonCode
{
RC_DO_NOT_USE_THIS = RUNTIME_COMP_ID | 0x00,
RC_ATTR_GET_FAIL = RUNTIME_COMP_ID | 0x01,
RC_BAD_HDAT_HEADER = RUNTIME_COMP_ID | 0x02,
RC_BAD_HDAT_TUPLE = RUNTIME_COMP_ID | 0x03,
RC_INVALID_STANDALONE = RUNTIME_COMP_ID | 0x04,
RC_CANNOT_MAP_MEMORY = RUNTIME_COMP_ID | 0x05,
//RC_XXX = RUNTIME_COMP_ID | 0x06,
RC_CANNOT_MAP_MEMORY2 = RUNTIME_COMP_ID | 0x07,
RC_INVALID_PAYLOAD_KIND = RUNTIME_COMP_ID | 0x08,
RC_NO_HSVC_NODE_DATA_FOUND = RUNTIME_COMP_ID | 0x09,
RC_BAD_NACA = RUNTIME_COMP_ID | 0x0A,
RC_INVALID_ADDRESS = RUNTIME_COMP_ID | 0x0B,
RC_INVALID_SECTION = RUNTIME_COMP_ID | 0x0C,
RC_CANNOT_MAP_MEMORY3 = RUNTIME_COMP_ID | 0x0D,
RC_TCE_INVALID_SIZE = RUNTIME_COMP_ID | 0x0E,
RC_TCE_ADDR_NOT_ALIGNED = RUNTIME_COMP_ID | 0x0F,
RC_TCE_INIT_NOT_RUN = RUNTIME_COMP_ID | 0x10,
RC_TCE_DEV_MAP_FAIL = RUNTIME_COMP_ID | 0x11,
RC_TCE_DEV_UNMAP_FAIL = RUNTIME_COMP_ID | 0x12,
RC_TCE_NO_ACTIVE_PSI = RUNTIME_COMP_ID | 0x13,
RC_DO_NOT_USE_THIS = RUNTIME_COMP_ID | 0x00,
RC_ATTR_GET_FAIL = RUNTIME_COMP_ID | 0x01,
RC_BAD_HDAT_HEADER = RUNTIME_COMP_ID | 0x02,
RC_BAD_HDAT_TUPLE = RUNTIME_COMP_ID | 0x03,
RC_INVALID_STANDALONE = RUNTIME_COMP_ID | 0x04,
RC_CANNOT_MAP_MEMORY = RUNTIME_COMP_ID | 0x05,
//RC_XXX = RUNTIME_COMP_ID | 0x06,
RC_CANNOT_MAP_MEMORY2 = RUNTIME_COMP_ID | 0x07,
RC_INVALID_PAYLOAD_KIND = RUNTIME_COMP_ID | 0x08,
RC_NO_HSVC_NODE_DATA_FOUND = RUNTIME_COMP_ID | 0x09,
RC_BAD_NACA = RUNTIME_COMP_ID | 0x0A,
RC_INVALID_ADDRESS = RUNTIME_COMP_ID | 0x0B,
RC_INVALID_SECTION = RUNTIME_COMP_ID | 0x0C,
RC_CANNOT_MAP_MEMORY3 = RUNTIME_COMP_ID | 0x0D,
RC_TCE_INVALID_SIZE = RUNTIME_COMP_ID | 0x0E,
RC_TCE_ADDR_NOT_ALIGNED = RUNTIME_COMP_ID | 0x0F,
RC_TCE_INIT_NOT_RUN = RUNTIME_COMP_ID | 0x10,
RC_TCE_DEV_MAP_FAIL = RUNTIME_COMP_ID | 0x11,
RC_TCE_DEV_UNMAP_FAIL = RUNTIME_COMP_ID | 0x12,
RC_TCE_NO_ACTIVE_PSI = RUNTIME_COMP_ID | 0x13,
RC_TCE_NOT_ENOUGH_FREE_ENTRIES = RUNTIME_COMP_ID | 0x14,
RC_TCE_ENTRY_NOT_CONTIGUOUS = RUNTIME_COMP_ID | 0x15,
RC_NO_SPIRA = RUNTIME_COMP_ID | 0x16,
RC_CANNOT_MAP_HDAT = RUNTIME_COMP_ID | 0x17,
RC_NOT_ENOUGH_SPACE = RUNTIME_COMP_ID | 0x18,
RT_UNIT_TARGET_NOT_FOUND = RUNTIME_COMP_ID | 0x19,
RT_TARGET_TYPE_NOT_SUPPORTED = RUNTIME_COMP_ID | 0x1A,
RT_NO_PROC_TARGET = RUNTIME_COMP_ID | 0x1B,
RC_UNMAP_FAIL = RUNTIME_COMP_ID | 0x1C,
RC_PM_RT_UNKNOWN_MODE = RUNTIME_COMP_ID | 0x1D,
RC_PM_RT_INTERFACE_ERR = RUNTIME_COMP_ID | 0x1E,
RC_PM_RT_HCODE_UPDATE_ERR = RUNTIME_COMP_ID | 0x1F,
RC_INVALID_RHB_INSTANCE = RUNTIME_COMP_ID | 0x20,
RC_TCE_ENTRY_NOT_CONTIGUOUS = RUNTIME_COMP_ID | 0x15,
RC_NO_SPIRA = RUNTIME_COMP_ID | 0x16,
RC_CANNOT_MAP_HDAT = RUNTIME_COMP_ID | 0x17,
RC_NOT_ENOUGH_SPACE = RUNTIME_COMP_ID | 0x18,
RT_UNIT_TARGET_NOT_FOUND = RUNTIME_COMP_ID | 0x19,
RT_TARGET_TYPE_NOT_SUPPORTED = RUNTIME_COMP_ID | 0x1A,
RT_NO_PROC_TARGET = RUNTIME_COMP_ID | 0x1B,
RC_UNMAP_FAIL = RUNTIME_COMP_ID | 0x1C,
RC_PM_RT_UNKNOWN_MODE = RUNTIME_COMP_ID | 0x1D,
RC_PM_RT_INTERFACE_ERR = RUNTIME_COMP_ID | 0x1E,
RC_PM_RT_HCODE_UPDATE_ERR = RUNTIME_COMP_ID | 0x1F,
RC_INVALID_RHB_INSTANCE = RUNTIME_COMP_ID | 0x20,
RC_DUPLICATE_I2C_LINK_IDS = RUNTIME_COMP_ID | 0x21,
RC_I2C_DEVICE_NOT_IN_MRW = RUNTIME_COMP_ID | 0x22,
RC_INSTANCES_UNSUPPORTED = RUNTIME_COMP_ID | 0x23,
RC_I2C_DEVICE_DUPLICATE_IN_MRW = RUNTIME_COMP_ID | 0x24,
RC_EXTRA_I2C_DEVICE_IN_MRW = RUNTIME_COMP_ID | 0x25,
};

enum UserDetailsTypes
Expand Down
2 changes: 1 addition & 1 deletion src/usr/hdat/hdatcommonutil.C
Expand Up @@ -86,7 +86,7 @@ uint32_t hdatTpmDataCalcMaxSize()
l_size += sizeof(hdatTpmData_t);

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

// account for each element of the TPM Info array
l_size += ((sizeof(hdatSbTpmInstInfo_t) +
Expand Down
3 changes: 0 additions & 3 deletions src/usr/hdat/hdatpcrd.C
Expand Up @@ -76,9 +76,6 @@ const HdatKeywordInfo l_mvpdKeywords[] =

};

//Max number of I2c devices for any given proc
#define HDAT_PCRD_MAX_I2C_DEV 64

/*******************************************************************************
* hdatSetPcrdHdrs
*
Expand Down
3 changes: 3 additions & 0 deletions src/usr/hdat/hdatpcrd.H
Expand Up @@ -56,6 +56,9 @@ namespace HDAT
const uint16_t HDAT_PCRD_VERSION = 0x20;
const char HDAT_PCRD_STRUCT_NAME[7] = "SPPCRD";

//Max number of I2c devices for any given proc
#define HDAT_PCRD_MAX_I2C_DEV 64

/** @enum hdatDataPtrs
* Enumeration which defines the data sections of the PCRD
*/
Expand Down
13 changes: 1 addition & 12 deletions src/usr/hdat/hdattpmdata.H
Expand Up @@ -60,6 +60,7 @@ enum {
TpmDataPtrCnt = 1,
TpmDataChildStrCnt = 0,
TpmDataChildStrOffset = 0,
TpmDataMinRqrdPcrdVersion = 0x1
};

/**
Expand All @@ -82,18 +83,6 @@ struct hdatTpmData_t
uint8_t hdatReserved1[16]; // Padding for alignment and growth/compatibility
} __attribute__ ((packed));


/**
* @brief Structure definition for Secureboot TPM Info Array
*/
struct hdatSbTpmInfo_t
{
uint32_t hdatSbTpmArrayOffset;
uint32_t hdatSbTpmArrayNumEntries;
uint32_t hdatSbTpmArrayEntrySize;
} __attribute__ ((packed));


/**
* @brief Structure definition for Secureboot TPM Instance Info
*/
Expand Down
123 changes: 123 additions & 0 deletions src/usr/runtime/hdatservice.C
Expand Up @@ -868,6 +868,38 @@ errlHndl_t hdatService::getHostDataSection( SectionId i_section,
o_dataSize = record_size;
o_dataAddr = base_addr + i_instance * o_dataSize;
}
else if( RUNTIME::PCRD == i_section )
{
hdat5Tuple_t* tuple = nullptr;
if( iv_spiraS )
{
tuple = &(iv_spiraS->hdatDataArea[SPIRAS_PCRD]);
}
else if( unlikely(iv_spiraL != nullptr) )
{
tuple = &(iv_spiraL->hdatDataArea[SPIRAL_PCRD]);
}
TRACUCOMP( g_trac_runtime, "PCRD_DATA tuple=%p", tuple );

errhdl = check_tuple( i_section, tuple );
if( errhdl )
{
break;
}

uint64_t base_addr = 0;
errhdl = getSpiraTupleVA(tuple, base_addr);
if( errhdl )
{
break;
}

TRACUCOMP( g_trac_runtime, "pcrd_data=%p", base_addr );

record_size = tuple->hdatAllocSize;
o_dataSize = record_size;
o_dataAddr = base_addr + i_instance * o_dataSize;
}
// MS DUMP Source Table - MDST
else if( RUNTIME::MS_DUMP_SRC_TBL == i_section )
{
Expand Down Expand Up @@ -1425,6 +1457,91 @@ void hdatService::rediscoverHDAT( void )
iv_mem_regions.clear();
}

/*
* @brief Get the number of instances in an HDAT section
*/
errlHndl_t hdatService::getInstanceCount(RUNTIME::SectionId i_section,
uint64_t& o_count)
{
errlHndl_t errhdl = nullptr;
hdat5Tuple_t* tuple = nullptr;

do
{
hdatSpiraSDataAreas l_spiraS = SPIRAS_INVALID;
hdatSpiraLegacyDataAreas l_spiraL = SPIRAL_INVALID;
hdatSpiraHDataAreas l_spiraH = SPIRAH_INVALID;

switch(i_section)
{
case RUNTIME::NODE_TPM_RELATED:
l_spiraS = SPIRAS_TPM_DATA;
l_spiraL = SPIRAL_TPM_DATA;
break;
case RUNTIME::PCRD:
l_spiraS = SPIRAS_PCRD;
l_spiraL = SPIRAL_PCRD;
break;
case RUNTIME::MS_DUMP_SRC_TBL:
l_spiraH = SPIRAH_MS_DUMP_SRC_TBL;
l_spiraL = SPIRAL_MS_DUMP_SRC_TBL;
break;
case RUNTIME::MS_DUMP_DST_TBL:
l_spiraH = SPIRAH_MS_DUMP_DST_TBL;
l_spiraL = SPIRAL_MS_DUMP_DST_TBL;
break;
case RUNTIME::MS_DUMP_RESULTS_TBL:
l_spiraH = SPIRAH_MS_DUMP_RSLT_TBL;
l_spiraL = SPIRAL_MS_DUMP_RSLT_TBL;
break;
default:
TRACFCOMP( g_trac_runtime,
"getInstanceCount> section %d has no concept of instances",
i_section );
/*@
* @errortype
* @moduleid RUNTIME::MOD_HDATSERVICE_GETINSTANCECOUNT
* @reasoncode RUNTIME::RC_INSTANCES_UNSUPPORTED
* @userdata1 Section Id
* @userdata2 <unused>
* @devdesc Unsupported section requested
* @custdesc Unexpected boot firmware error.
*/
errhdl = new ERRORLOG::ErrlEntry(
ERRORLOG::ERRL_SEV_UNRECOVERABLE,
RUNTIME::MOD_HDATSERVICE_GETINSTANCECOUNT,
RUNTIME::RC_INSTANCES_UNSUPPORTED,
i_section,
0,
true /*Add HB Software Callout*/);
errhdl->collectTrace(RUNTIME_COMP_NAME,KILOBYTE);
break;
}

if( iv_spiraS )
{
tuple = &(iv_spiraS->hdatDataArea[l_spiraS]);
}
else if( iv_spiraH )
{
tuple = &(iv_spiraH->hdatDataArea[l_spiraH]);
}
else if( unlikely(iv_spiraL != nullptr) )
{
tuple = &(iv_spiraL->hdatDataArea[l_spiraL]);
}
errhdl = check_tuple( i_section, tuple );
if( errhdl )
{
break;
}
o_count = tuple->hdatActualCnt;

} while (0);

return errhdl;
}

/********************
Public Methods
********************/
Expand Down Expand Up @@ -1477,6 +1594,12 @@ void rediscover_hdat( void )
Singleton<hdatService>::instance().rediscoverHDAT();
}

errlHndl_t get_instance_count( RUNTIME::SectionId i_section, uint64_t& o_count )
{
return Singleton<RUNTIME::hdatService>::instance().
getInstanceCount(i_section, o_count);
}

};

/********************
Expand Down
10 changes: 8 additions & 2 deletions src/usr/runtime/hdatservice.H
Expand Up @@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2013,2015 */
/* Contributors Listed Below - COPYRIGHT 2013,2017 */
/* [+] International Business Machines Corp. */
/* */
/* */
Expand Down Expand Up @@ -97,6 +97,12 @@ namespace RUNTIME
uint64_t& o_dataAddr,
size_t& o_dataSize );

/**
* @brief See documentation for get_instance_count in runtime.H
*/
errlHndl_t getInstanceCount( RUNTIME::SectionId i_section,
uint64_t& o_count);

/**
* @brief Update the actual count of section. Only supported for
* memory dump results table
Expand Down Expand Up @@ -267,7 +273,7 @@ namespace RUNTIME

public:
/**
* @brief Store the actual count of a section.
* @brief Store the actual count of a section.
*
* @param[in] i_section Chunk of data to update
* @param[in] i_count Actual count for MDRT entries
Expand Down
3 changes: 3 additions & 0 deletions src/usr/runtime/hdatstructs.H
Expand Up @@ -74,6 +74,7 @@ struct hdatNaca_t
*/
enum hdatSpiraLegacyDataAreas
{
SPIRAL_INVALID = -1,
SPIRAL_FIRST = 0,
SPIRAL_SP_SUBSYS = 0, // service processor subsystem
SPIRAL_IPL_PARMS = 1, // IPL parameters
Expand Down Expand Up @@ -111,6 +112,7 @@ enum hdatSpiraLegacyDataAreas
*/
enum hdatSpiraHDataAreas
{
SPIRAH_INVALID = -1,
SPIRAH_FIRST = 0,
SPIRAH_HOST_DATA_AREAS = 0, // Reserved memory for FSP-filled data
SPIRAH_PROC_INIT = 1, // phyp-supplied processor init data
Expand All @@ -127,6 +129,7 @@ enum hdatSpiraHDataAreas
*/
enum hdatSpiraSDataAreas
{
SPIRAS_INVALID = -1,
SPIRAS_FIRST = 0,
SPIRAS_SP_SUBSYS = 0, // service processor subsystem
SPIRAS_IPL_PARMS = 1, // IPL parameters
Expand Down

0 comments on commit 096ef90

Please sign in to comment.