diff options
author | Marty Gloff <mgloff@us.ibm.com> | 2018-02-13 10:46:34 -0600 |
---|---|---|
committer | Daniel M. Crowell <dcrowell@us.ibm.com> | 2018-04-09 16:36:24 -0400 |
commit | 519b09db143e87b3d43f39790486f6c5dc1be96b (patch) | |
tree | f065d8dfdd170952d0d633c0e0f1d322b43a2fe6 /src/usr | |
parent | 093052dd5cfac9e8c8d048eb5cf77223debf7e9d (diff) | |
download | talos-hostboot-519b09db143e87b3d43f39790486f6c5dc1be96b.tar.gz talos-hostboot-519b09db143e87b3d43f39790486f6c5dc1be96b.zip |
Support multiple nodes in HBRT - Concurrent Code Update
Enable HBRT to prepare for a concurrent code update on a multiple node system.
Modify preparation function called by Host to loop through all nodes on the
system. Make additional updates to go from supporting only a single node to
supporting multiple nodes.
Change-Id: I2d72b26abf40812641815051b968d6b540d27b00
RTC: 186584
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/53952
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: Christian R. Geddes <crgeddes@us.ibm.com>
Reviewed-by: Prachi Gupta <pragupta@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src/usr')
-rw-r--r-- | src/usr/errl/errlentry.C | 4 | ||||
-rwxr-xr-x | src/usr/targeting/attrrp_common.C | 7 | ||||
-rw-r--r-- | src/usr/targeting/common/target.C | 28 | ||||
-rw-r--r-- | src/usr/targeting/common/targetservice.C | 120 | ||||
-rw-r--r-- | src/usr/targeting/runtime/attrrp_rt.C | 50 | ||||
-rw-r--r-- | src/usr/targeting/runtime/rt_targeting.C | 120 | ||||
-rw-r--r-- | src/usr/targeting/runtime/test/testtargeting.H | 479 |
7 files changed, 481 insertions, 327 deletions
diff --git a/src/usr/errl/errlentry.C b/src/usr/errl/errlentry.C index 2605509ae..972c8b272 100644 --- a/src/usr/errl/errlentry.C +++ b/src/usr/errl/errlentry.C @@ -91,9 +91,9 @@ ErrlEntry::ErrlEntry(const errlSeverity_t i_sev, iv_eselCallhomeInfoEvent(false) { #ifdef CONFIG_ERRL_ENTRY_TRACE - TRACFCOMP( g_trac_errl, ERR_MRK"Error created : PLID=%.8X, RC=%.4X, Mod=%.2X, Userdata=%.16X %.16X", plid(), i_reasonCode, i_modId, i_user1, i_user2 ); + TRACFCOMP( g_trac_errl, ERR_MRK"Error created : PLID=%.8X, RC=%.4X, Mod=%.2X, Userdata=%.16llX %.16llX", plid(), i_reasonCode, i_modId, i_user1, i_user2 ); #else - TRACDCOMP( g_trac_errl, ERR_MRK"Error created : PLID=%.8X, RC=%.4X, Mod=%.2X, Userdata=%.16X %.16X", plid(), i_reasonCode, i_modId, i_user1, i_user2 ); + TRACDCOMP( g_trac_errl, ERR_MRK"Error created : PLID=%.8X, RC=%.4X, Mod=%.2X, Userdata=%.16llX %.16llX", plid(), i_reasonCode, i_modId, i_user1, i_user2 ); #endif // Collect the Backtrace and add it to the error log iv_pBackTrace = new ErrlUserDetailsBackTrace(); diff --git a/src/usr/targeting/attrrp_common.C b/src/usr/targeting/attrrp_common.C index 26213dcf5..173c249ec 100755 --- a/src/usr/targeting/attrrp_common.C +++ b/src/usr/targeting/attrrp_common.C @@ -61,6 +61,7 @@ namespace TARGETING if (iv_sections) // @TODO RTC:186585 move if... to #ifndef clause { delete[] iv_sections; + iv_sections = nullptr; } // @TODO RTC:186585 move if... to #ifndef clause #ifndef __HOSTBOOT_RUNTIME @@ -71,7 +72,13 @@ namespace TARGETING { if (iv_nodeContainer[i].pSections) { + if((i == NODE0) && (iv_sections == nullptr)) + { + iv_nodeContainer[i].pSections = nullptr; + continue; + } // @TODO RTC:186585 move if... delete[] iv_nodeContainer[i].pSections; + iv_nodeContainer[i].pSections = nullptr; } } diff --git a/src/usr/targeting/common/target.C b/src/usr/targeting/common/target.C index 1ee281576..90bfd6850 100644 --- a/src/usr/targeting/common/target.C +++ b/src/usr/targeting/common/target.C @@ -138,6 +138,34 @@ bool Target::_tryGetAttrUnsafe( } //****************************************************************************** +// Target::_tryGetAttrUnsafe +//****************************************************************************** +bool Target::_tryGetAttrUnsafe( + const ATTRIBUTE_ID i_attr, + const uint32_t i_size, + AttrRP* i_attrRP, + ATTRIBUTE_ID* i_pAttrId, + AbstractPointer<void>* i_ppAttrAddr, + void* const io_pAttrData) const +{ + #define TARG_FN "_tryGetAttrUnsafe()" + + bool l_found = false; + + void* l_pAttrData = NULL; + _getAttrPtr(i_attr, i_attrRP, i_pAttrId, i_ppAttrAddr, l_pAttrData); + if (l_pAttrData) + { + memcpy(io_pAttrData, l_pAttrData, i_size); + l_found = true; + } + + return l_found; + + #undef TARG_FN +} + +//****************************************************************************** // Target::_trySetAttr //****************************************************************************** diff --git a/src/usr/targeting/common/targetservice.C b/src/usr/targeting/common/targetservice.C index 652d8869c..3db2f75c7 100644 --- a/src/usr/targeting/common/targetservice.C +++ b/src/usr/targeting/common/targetservice.C @@ -507,23 +507,25 @@ Target* TargetService::getNextTarget(const Target* i_pTarget) const #define TARG_FN "getNextTarget(...)" Target* l_pTarget = const_cast<Target*>(i_pTarget); bool l_targetFound = false; + if(l_pTarget != NULL) { for(uint8_t i_node=0; i_node<MAX_NODE_ID; ++i_node) { if((iv_nodeData[i_node].initialized) && (iv_nodeData[i_node].maxTargets > 0) && - ((l_pTarget >= &(*(iv_nodeData[i_node]).targets)[0]) && - (l_pTarget <= &(*(iv_nodeData[i_node]).targets)[ + ((l_pTarget >= &(*(iv_nodeData[i_node].targets))[0]) && + (l_pTarget <= &(*(iv_nodeData[i_node].targets))[ iv_nodeData[i_node].maxTargets - 1]))) { - if( l_pTarget == &(*(iv_nodeData[i_node]).targets)[iv_nodeData[ + if( l_pTarget == &(*(iv_nodeData[i_node].targets))[iv_nodeData[ i_node].maxTargets - 1] ) { // Go for next node uint8_t l_nextNode = getNextInitializedNode( static_cast<NODE_ID>(i_node)); - if(l_nextNode != MAX_NODE_ID) + TARG_INF("getNextTarget: Using next node %d", l_nextNode); + if(l_nextNode < MAX_NODE_ID) { l_pTarget = &(*(iv_nodeData[l_nextNode].targets))[0]; l_targetFound = true; @@ -542,10 +544,34 @@ Target* TargetService::getNextTarget(const Target* i_pTarget) const break; } } + else if( !(iv_nodeData[i_node].initialized) || + (iv_nodeData[i_node].maxTargets == 0)) + { + TARG_ERR("getNextTarget: For node %d, initialized %d, " + "maximum targets %d", + i_node, + iv_nodeData[i_node].initialized, + iv_nodeData[i_node].maxTargets); + } + } + + if(l_targetFound == false) + { + for(uint8_t i_node=0; i_node<MAX_NODE_ID; ++i_node) + { + TARG_ERR("getNextTarget: Node %d targets: first %p, " + "current %p, last %p", + i_node, + &(*(iv_nodeData[i_node].targets))[0], + l_pTarget, + &(*(iv_nodeData[i_node].targets))[ + iv_nodeData[i_node].maxTargets - 1]); + } } } if(l_targetFound == false) { + TARG_ERR("getNextTarget: Target not found"); l_pTarget = NULL; } @@ -1472,15 +1498,15 @@ void TargetService::getMasterNodeTarget( } //****************************************************************************** -// TargetService::getTargetRangeFilter +// TargetService::getTargetArray //****************************************************************************** -TargetRangeFilter TargetService::getTargetRangeFilter(void *i_attrData, - AttrRP *i_attrRP, - uint32_t &o_maxTargets, - NODE_ID i_nodeId) +Target* TargetService::getTargetArray(void *i_attrData, + NODE_ID i_nodeId, + AttrRP *i_attrRP, + uint32_t &o_maxTargets) { - #define TARG_FN "getTargetRangeFilter(...)" + #define TARG_FN "getTargetArray(...)" TARG_ENTER(); // Get pointer to TargetingHeader for attribute data @@ -1494,39 +1520,67 @@ TargetRangeFilter TargetService::getTargetRangeFilter(void *i_attrData, "TargetingHeader eyecatcher 0x%16llX is incorrect", l_header->eyeCatcher) - // Create node info - TargetService::NodeSpecificInfo l_nodeSpecificInfo; - l_nodeSpecificInfo.nodeId = i_nodeId; + // Save away the address of the targeting data in l_pPnor variable + // l_pPnor--> points to uint32_t* --> points to --> uint32_t, targets[] + // (uint32_t*)+1 --> points to ------------> targets[] + const void *l_pPnor = + reinterpret_cast<const void*>(reinterpret_cast<char*>(l_header) + + l_header->headerSize); + + // Target count found by following the l_pPnor pointer + const AbstractPointer<uint32_t>* pNumTargetsPtr = + static_cast<const AbstractPointer<uint32_t>*>(l_pPnor); + uint32_t* pNumTargets = TARG_TO_PLAT_PTR(*pNumTargetsPtr); + + // Only translate addresses on platforms where addresses are 4 bytes wide + // (FSP). The compiler should perform dead code elimination of this path on + // platforms with 8 byte wide addresses (Hostboot), since the "if" check + // can be statically computed at compile time. + if(TARG_ADDR_TRANSLATION_REQUIRED) + { + pNumTargets = + static_cast<uint32_t*>(i_attrRP->translateAddr(pNumTargets, + i_nodeId)); + } - // Save away the address of the targeting data in pPnor field - l_nodeSpecificInfo.pPnor = - reinterpret_cast<uint32_t*>(reinterpret_cast<char*>(l_header) + - l_header->headerSize); + TARG_ASSERT(pNumTargets, TARG_ERR_LOC + "FATAL: Could not determine location of targets after " + "address translation"); - TargetService::_configureTargetPool(l_nodeSpecificInfo, - i_attrRP); + // Set maximum number of targets output + o_maxTargets = *pNumTargets; - l_nodeSpecificInfo.initialized = true; + TARG_INF("Max targets = %d", o_maxTargets); - // Create pointer to first target in new attribute data - // First target is after header and number of targets count - Target* l_pFirstTarget = &(*(l_nodeSpecificInfo.targets))[0]; - TARG_INF("getTargetRangeFilter: First target pointer %p, huid 0x%.8x", - l_pFirstTarget, - get_huid(l_pFirstTarget)); + // Targets array found by following the l_pPnor pointer + Target (*l_targets)[] = reinterpret_cast< Target(*)[] > ( + (TARG_TO_PLAT_PTR_AND_INC(*pNumTargetsPtr,1))); - // Create TargetRangeFilter for attribute data - TargetRangeFilter l_rangeFilter(TargetIterator(l_pFirstTarget), - TargetIterator(NULL), - NULL); + TARG_ASSERT(l_targets, TARG_ERR_LOC + "FATAL: Could not determine location of targets"); + TARG_INF("l_targets = %p", l_targets); - // Set maximum target value to be returned - o_maxTargets = l_nodeSpecificInfo.maxTargets; + // Only translate addresses on platforms where addresses are 4 bytes wide + // (FSP). The compiler should perform dead code elimination of this path on + // platforms with 8 byte wide addresses (Hostboot), since the "if" check + // can be statically computed at compile time. + if(TARG_ADDR_TRANSLATION_REQUIRED) + { + l_targets = + static_cast<Target(*)[]>(i_attrRP->translateAddr(l_targets, + i_nodeId)); + TARG_ASSERT(l_targets, TARG_ERR_LOC + "FATAL: Could not determine location of targets after " + "address translation"); + TARG_INF("l_targets after translation = %p", + l_targets); + } TARG_EXIT(); #undef TARG_FN - return l_rangeFilter; + // Return pointer to first target in array + return &(*(l_targets))[0]; } //****************************************************************************** diff --git a/src/usr/targeting/runtime/attrrp_rt.C b/src/usr/targeting/runtime/attrrp_rt.C index e13ecd3dc..8d260cf75 100644 --- a/src/usr/targeting/runtime/attrrp_rt.C +++ b/src/usr/targeting/runtime/attrrp_rt.C @@ -38,54 +38,6 @@ using namespace ERRORLOG; namespace TARGETING { - void AttrRP::fillInAttrRP(TargetingHeader* i_header) - { - TRACFCOMP(g_trac_targeting, ENTER_MRK"AttrRP::fillInAttrRP"); - - do - { - // Allocate section structures based on section count in header. - iv_sectionCount = i_header->numSections; - iv_sections = new AttrRP_Section[iv_sectionCount](); - - // Find start to the first section: - // (header address + size of header + offset in header) - TargetingSection* l_section = - reinterpret_cast<TargetingSection*>( - reinterpret_cast<uint64_t>(i_header) + - sizeof(TargetingHeader) + i_header->offsetToSections - ); - - uint64_t l_offset = 0; - - for (size_t i = 0; i < iv_sectionCount; ++i, ++l_section) - { - iv_sections[i].type = l_section->sectionType; - iv_sections[i].size = l_section->sectionSize; - - iv_sections[i].vmmAddress = - static_cast<uint64_t>( - TARG_TO_PLAT_PTR(i_header->vmmBaseAddress)) + - i_header->vmmSectionOffset*i; - iv_sections[i].pnorAddress = - reinterpret_cast<uint64_t>(i_header) + l_offset; - - l_offset += ALIGN_PAGE(iv_sections[i].size); - - TRACFCOMP(g_trac_targeting, - "Decoded Attribute Section: %d, 0x%lx, 0x%lx, 0x%lx", - iv_sections[i].type, - iv_sections[i].vmmAddress, - iv_sections[i].pnorAddress, - iv_sections[i].size); - } - } while(false); - - TRACFCOMP(g_trac_targeting, EXIT_MRK"AttrRP::fillInAttrRP"); - - return; - } - void AttrRP::startup(errlHndl_t& io_taskRetErrl, bool isMpipl) { TRACFCOMP(g_trac_targeting, "AttrRP::startup"); @@ -282,7 +234,7 @@ namespace TARGETING TargetingHeader* i_header, const NODE_ID i_nodeId) { - TRACFCOMP(g_trac_targeting, "AttrRP::nodeInfoInit"); + TRACFCOMP(g_trac_targeting, "AttrRP::nodeInfoInit %d", i_nodeId); errlHndl_t l_errl = nullptr; do diff --git a/src/usr/targeting/runtime/rt_targeting.C b/src/usr/targeting/runtime/rt_targeting.C index 8da93830d..8f1a9b5a1 100644 --- a/src/usr/targeting/runtime/rt_targeting.C +++ b/src/usr/targeting/runtime/rt_targeting.C @@ -202,13 +202,11 @@ errlHndl_t getHbTarget( * @param[in] Pointer to new LID Structure targeting binary data * @param[in] Pointer to current Reserved Memory targeting binary data * @param[out] Total size of all sections in the new lid - * @param[out] Error log userdata2 value associated with non-zero rtn code * @return 0 on success, else return code */ errlHndl_t validateData(void *i_lidStructPtr, void *i_rsvdMemPtr, - size_t& o_lidTotalSize, - uint64_t& o_userdata2) + size_t& o_lidTotalSize) { TRACFCOMP(g_trac_targeting, ENTER_MRK"validateData: %p %p", i_lidStructPtr, i_rsvdMemPtr); @@ -376,7 +374,7 @@ errlHndl_t validateData(void *i_lidStructPtr, o_lidTotalSize += l_sectionLid->sectionSize; } - // *** Could check if rc was set in for loop and break from do loop + // *** Could check if rc was set in for loop and break from do loop } while(false); TRACFCOMP(g_trac_targeting, @@ -391,24 +389,23 @@ errlHndl_t validateData(void *i_lidStructPtr, * into new LID Structure data * @param[in] Pointer to current Reserved Memory targeting binary data * @param[in/out] Pointer to new LID Structure targeting binary data - * @param[out] Error log userdata2 value associated with non-zero rtn code + * @param[in] Instance, ie, Node ID * @return 0 on success, else return code */ errlHndl_t saveRestoreAttrs(void *i_rsvdMemPtr, void *io_lidStructPtr, - uint64_t& o_userdata2) + uint8_t i_instance) { TRACFCOMP( g_trac_targeting, - ENTER_MRK"saveRestoreAttrs: %p %p", - i_rsvdMemPtr, io_lidStructPtr ); + ENTER_MRK"saveRestoreAttrs: %p %p %d", + i_rsvdMemPtr, io_lidStructPtr, i_instance ); errlHndl_t l_errhdl = nullptr; AttrRP *l_attrRPLid = nullptr; do { - // Node ID - NODE_ID l_nodeId = NODE0; + NODE_ID l_nodeId = static_cast<TARGETING::NODE_ID>(i_instance); // Locate current Reserved Memory data via TargetService TARGETING::TargetService& l_targSrv = TARGETING::targetService(); @@ -418,41 +415,47 @@ errlHndl_t saveRestoreAttrs(void *i_rsvdMemPtr, // Create temporary AttrRP instance for new LID Structure targeting data l_attrRPLid = - new AttrRP(reinterpret_cast<TargetingHeader*>(io_lidStructPtr)); + new AttrRP(reinterpret_cast<TargetingHeader*>(io_lidStructPtr), + l_nodeId, + l_attrRPRsvd->getNodeCount(), + l_attrRPRsvd->getInstanceStatus()); - // Create TargetRangeFilter for LID Structure targeting data + // Get pointer to array of targets in the targeting image uint32_t l_maxTargetsLid = 0; - TargetRangeFilter l_allTargetsLid = - l_targSrv.getTargetRangeFilter(io_lidStructPtr, - l_attrRPLid, - l_maxTargetsLid, - l_nodeId); + Target (*l_targetsLid)[] = reinterpret_cast< Target(*)[] >( + l_targSrv.getTargetArray(io_lidStructPtr, + l_nodeId, + l_attrRPLid, + l_maxTargetsLid)); TRACFCOMP( g_trac_targeting, - "Found %d targets in the lid", - l_maxTargetsLid ); + "Found %d targets in the lid for node %d", + l_maxTargetsLid, + l_nodeId ); // Set up variables for getting attribute information for a target uint32_t l_attrCountRsvd = 0; ATTRIBUTE_ID* l_pAttrIdRsvd = nullptr; AbstractPointer<void>* l_ppAttrAddrRsvd = nullptr; + uint32_t l_attrCountLid = 0; ATTRIBUTE_ID* l_pAttrIdLid = nullptr; AbstractPointer<void>* l_ppAttrAddrLid = nullptr; - uint32_t l_huidLid = 0; - EntityPath l_physPathLid; // Walk through new LID Structure Targets for(uint32_t l_targetNum = 1; (l_targetNum <= l_maxTargetsLid); - ++l_allTargetsLid, ++l_targetNum) + ++l_targetNum) { + // Get target for this pass through loop + Target *l_targetLid = &(*(l_targetsLid))[l_targetNum - 1]; + // Counts of how many new attribute values were kept uint32_t l_kept_for_added_attr = 0; uint32_t l_kept_for_unknown_size = 0; // Get attribute information for a target in LID Structure (new) - l_attrCountLid = l_targSrv.getTargetAttributes(*l_allTargetsLid, + l_attrCountLid = l_targSrv.getTargetAttributes(l_targetLid, l_attrRPLid, l_pAttrIdLid, l_ppAttrAddrLid); @@ -466,16 +469,35 @@ errlHndl_t saveRestoreAttrs(void *i_rsvdMemPtr, continue; } - l_huidLid = l_allTargetsLid->getAttr<ATTR_HUID>(); - l_physPathLid = l_allTargetsLid->getAttr<ATTR_PHYS_PATH>(); + // Get key attributes and trace the information + ATTR_CLASS_type l_classLid = + l_targetLid->getAttr<ATTR_CLASS>(l_attrRPLid, + l_pAttrIdLid, + l_ppAttrAddrLid); + ATTR_TYPE_type l_typeLid = + l_targetLid->getAttr<ATTR_TYPE>(l_attrRPLid, + l_pAttrIdLid, + l_ppAttrAddrLid); + ATTR_ORDINAL_ID_type l_ordinalIdLid = + l_targetLid->getAttr<ATTR_ORDINAL_ID>(l_attrRPLid, + l_pAttrIdLid, + l_ppAttrAddrLid); + ATTR_HUID_type l_huidLid = + l_targetLid->getAttr<ATTR_HUID>(l_attrRPLid, + l_pAttrIdLid, + l_ppAttrAddrLid); + ATTR_PHYS_PATH_type l_physPathLid = + l_targetLid->getAttr<ATTR_PHYS_PATH>(l_attrRPLid, + l_pAttrIdLid, + l_ppAttrAddrLid); TRACFCOMP( g_trac_targeting, "Target %3d has %3d attrs, class %0.8x, type %0.8x, " "ord ID %0.8x, HUID 0x%0.8x, %s", l_targetNum, l_attrCountLid, - l_allTargetsLid->getAttr<ATTR_CLASS>(), - l_allTargetsLid->getAttr<ATTR_TYPE>(), - l_allTargetsLid->getAttr<ATTR_ORDINAL_ID>(), + l_classLid, + l_typeLid, + l_ordinalIdLid, l_huidLid, l_physPathLid.toString()); @@ -492,11 +514,9 @@ errlHndl_t saveRestoreAttrs(void *i_rsvdMemPtr, l_allTargetsRsvd; ++l_allTargetsRsvd) { - if((l_allTargetsLid->getAttr<ATTR_CLASS>() == - l_allTargetsRsvd->getAttr<ATTR_CLASS>()) && - (l_allTargetsLid->getAttr<ATTR_TYPE>() == - l_allTargetsRsvd->getAttr<ATTR_TYPE>()) && - (l_allTargetsLid->getAttr<ATTR_ORDINAL_ID>() == + if((l_classLid == l_allTargetsRsvd->getAttr<ATTR_CLASS>()) && + (l_typeLid == l_allTargetsRsvd->getAttr<ATTR_TYPE>()) && + (l_ordinalIdLid == l_allTargetsRsvd->getAttr<ATTR_ORDINAL_ID>()) && (l_physPathLid == l_allTargetsRsvd->getAttr<ATTR_PHYS_PATH>())) @@ -575,11 +595,11 @@ errlHndl_t saveRestoreAttrs(void *i_rsvdMemPtr, { // Get the LID Structure attribute value pointer void* l_pAttrLid = nullptr; - l_allTargetsLid->_getAttrPtr(*l_pAttrId, - l_attrRPLid, - l_pAttrIdLid, - l_ppAttrAddrLid, - l_pAttrLid); + l_targetLid->_getAttrPtr(*l_pAttrId, + l_attrRPLid, + l_pAttrIdLid, + l_ppAttrAddrLid, + l_pAttrLid); // Check if attribute is in LID Structure data if(l_pAttrLid == nullptr) @@ -700,23 +720,31 @@ errlHndl_t saveRestoreAttrs(void *i_rsvdMemPtr, int hbrt_update_prep(void) { errlHndl_t pError = nullptr; - uint64_t l_userdata2 = 0; UtilLidMgr l_lidMgr(Util::TARGETING_BINARY_LIDID); void *l_lidStructPtr = nullptr; void* l_newMem = nullptr; - do + for(NODE_ID l_nodeId = NODE0; + l_nodeId < Singleton<AttrRP>::instance().getNodeCount(); + l_nodeId++) { // Get size and location of attributes in reserved memory uint64_t l_attr_size = 0; uint64_t l_rsvdMem = hb_get_rt_rsvd_mem(Util::HBRT_MEM_LABEL_ATTR, - 0, l_attr_size); + l_nodeId, l_attr_size); TRACFCOMP( g_trac_targeting, "l_rsvdMem @ %.16llX for 0x%llX", l_rsvdMem, l_attr_size ); // Set pointer to reserved memory targeting data void *l_rsvdMemPtr = reinterpret_cast<void*>(l_rsvdMem); + // Set LID for this node + pError = l_lidMgr.setLidId(Util::TARGETING_BINARY_LIDID + l_nodeId); + if(pError) + { + break; + } + // Create lidMgr and get size of Targeting Binary LID size_t l_lidSize = 0; pError = l_lidMgr.getLidSize(l_lidSize); @@ -734,9 +762,6 @@ int hbrt_update_prep(void) l_lidSize, l_attr_size); - l_userdata2 = TWO_UINT32_TO_UINT64(l_lidSize, - l_attr_size); - break; } @@ -755,8 +780,7 @@ int hbrt_update_prep(void) // Validate LID Structure against Reserved Memory pError = validateData(l_lidStructPtr, l_rsvdMemPtr, - l_lidDataSize, - l_userdata2); + l_lidDataSize); if(pError) { break; @@ -801,7 +825,7 @@ int hbrt_update_prep(void) // new LID Structure data pError = saveRestoreAttrs(l_rsvdMemPtr, l_newMem, - l_userdata2); + l_nodeId); if(pError) { break; @@ -831,7 +855,7 @@ int hbrt_update_prep(void) 0, l_setSize); } - } while(false); + } // Delete the scratch space for the new attributes if( l_newMem ) diff --git a/src/usr/targeting/runtime/test/testtargeting.H b/src/usr/targeting/runtime/test/testtargeting.H index c03f2fd27..fce91f46d 100644 --- a/src/usr/targeting/runtime/test/testtargeting.H +++ b/src/usr/targeting/runtime/test/testtargeting.H @@ -33,6 +33,7 @@ #include <targeting/attrPlatOverride.H> #include <util/runtime/util_rt.H> #include <targeting/attrrp.H> +#include <targeting/targplatreasoncodes.H> #define MEMCMPPTR(addr, offset) \ reinterpret_cast<void*>(reinterpret_cast<uint64_t>(addr) + offset) @@ -286,21 +287,280 @@ class TargetingTestSuite : public CxxTest::TestSuite allow_attr_overrides); } - // Test the two internal functions used during HBRT concurrent update. - // The first function validates the LID Structure against the Reserved - // Memory data. The second function saves and restores attribute - // values from current Reserved Memory data into new LID Structure - // data. This testcase uses Reserved Memory data to make its LID - // Structure, so it tests basic logic in the functions, but does not - // test more complex handling of special data conditions. - void _testSaveRestoreAttrs() + // Test internal function used during HBRT concurrent update to validate + // the LID Structure against the Reserved Memory data. This testcase + // uses Reserved Memory data to make its LID Structure, so it tests + // basic logic in the functions, but does not test more complex handling + // of special data conditions. + void testValidateData() + { + using namespace TARGETING; + TRACFCOMP(g_trac_targeting,ENTER_MRK"testValidateData"); + + errlHndl_t l_err = nullptr; + void *l_lidStruct = nullptr; + NODE_ID l_node = NODE0; // Runs on Standalone, so only Node 0 + + do + { + uint64_t l_attr_size = 0; + uint64_t l_rsvdMem = + hb_get_rt_rsvd_mem(Util::HBRT_MEM_LABEL_ATTR, + l_node, + l_attr_size); + void *l_rsvdMemPtr = reinterpret_cast<void*>(l_rsvdMem); + + // Access TargetingHeader in current data + TargetingHeader* l_headerRsvd = + reinterpret_cast<TargetingHeader*>(l_rsvdMemPtr); + + // Find start to the first section in current data: + // (header address + size of header + offset in header) + TargetingSection* l_sectionRsvd = + reinterpret_cast<TargetingSection*>( + reinterpret_cast<uint64_t>(l_headerRsvd) + + sizeof(TargetingHeader) + + l_headerRsvd->offsetToSections); + + // Allocate memory for new LID structure + l_lidStruct = malloc(l_attr_size); + + // Make LID structure from current Reserved Memory data + memcpy(l_lidStruct, + l_rsvdMemPtr, + l_attr_size); + + // Intentionally invalidate the eyecatcher for LID structure + // Then run validateData() to make sure this error is detected + TargetingHeader* l_headerLid = + reinterpret_cast<TargetingHeader*>(l_lidStruct); + uint32_t *l_pEyeCatcher = + reinterpret_cast<uint32_t*>(reinterpret_cast<uint64_t>( + &l_headerLid->eyeCatcher)); + *l_pEyeCatcher += 0x20202020; + size_t l_lidDataSize = 0; + l_err = RT_TARG::validateData(l_lidStruct, + l_rsvdMemPtr, + l_lidDataSize); + if(ERRL_GETRC_SAFE(l_err) != TARG_RT_BAD_EYECATCHER_LID) + { + TS_FAIL("testValidateData> unexpected reason code from " + "validateData, expected 0x%.4x, received 0x%.4x", + TARG_RT_BAD_EYECATCHER_LID, + ERRL_GETRC_SAFE(l_err)); + break; + } + else if(l_err && + (l_err->moduleId() != TARG_RT_VALIDATEDATA)) + { + TS_FAIL("testValidateData> unexpected module ID from " + "validateData, expected 0x86, received 0x%.2x", + TARG_RT_VALIDATEDATA, + l_err->moduleId()); + break; + } + else if(l_err && + (l_err->getUserData1() != l_headerLid->eyeCatcher)) + { + TS_FAIL("testValidateData> unexpected user data from " + "validateData, expected 0x%.16llx, rcvd 0x%.16llx", + l_headerLid->eyeCatcher, + l_err->getUserData1()); + break; + } + else + { + *l_pEyeCatcher -= 0x20202020; + } + + // Intentionally invalidate the eyecatcher for Reserved Memory + // Then run validateData() to make sure this error is detected + l_pEyeCatcher = + reinterpret_cast<uint32_t*>(reinterpret_cast<uint64_t>( + &l_headerRsvd->eyeCatcher)); + *l_pEyeCatcher += 0x00202020; + l_err = RT_TARG::validateData(l_lidStruct, + l_rsvdMemPtr, + l_lidDataSize); + if(ERRL_GETRC_SAFE(l_err) != TARG_RT_BAD_EYECATCHER_MEM) + { + TS_FAIL("testValidateData> unexpected reason code from " + "validateData, expected 0x%.4x, received 0x%.4x", + TARG_RT_BAD_EYECATCHER_MEM, + ERRL_GETRC_SAFE(l_err)); + break; + } + else if(l_err && + (l_err->moduleId() != TARG_RT_VALIDATEDATA)) + { + TS_FAIL("testValidateData> unexpected module ID from " + "validateData, expected 0x86, received 0x%.2x", + TARG_RT_VALIDATEDATA, + l_err->moduleId()); + break; + } + else if(l_err && + (l_err->getUserData1() != l_headerRsvd->eyeCatcher)) + { + TS_FAIL("testValidateData> unexpected user data from " + "validateData, expected 0x%.16llx, rcvd 0x%.16llx", + l_headerRsvd->eyeCatcher, + l_err->getUserData1()); + break; + } + else + { + *l_pEyeCatcher -= 0x00202020; + } + + // Intentionally cause mismatch with number of sections + // Then run validateData() to make sure this error is detected + uint32_t *l_pNumSections = + reinterpret_cast<uint32_t*>(reinterpret_cast<uint64_t>( + &l_headerRsvd->numSections)); + *l_pNumSections += 2; + l_err = RT_TARG::validateData(l_lidStruct, + l_rsvdMemPtr, + l_lidDataSize); + if(ERRL_GETRC_SAFE(l_err) != TARG_RT_SECTION_NUM_MISMATCH) + { + TS_FAIL("testValidateData> unexpected reason code from " + "validateData, expected 0x%.4x, received 0x%.4x", + TARG_RT_SECTION_NUM_MISMATCH, + ERRL_GETRC_SAFE(l_err)); + break; + } + else if(l_err && + (l_err->moduleId() != TARG_RT_VALIDATEDATA)) + { + TS_FAIL("testValidateData> unexpected module ID from " + "validateData, expected 0x86, received 0x%.2x", + TARG_RT_VALIDATEDATA, + l_err->moduleId()); + break; + } + else if(l_err && + ((l_err->getUserData1() != l_headerLid->numSections) || + (l_err->getUserData2() != l_headerRsvd->numSections))) + { + TS_FAIL("testValidateData> unexpected user data from " + "validateData, expected 0x%.16llx, rcvd 0x%.16llx, " + "expected 0x%.16llx, rcvd 0x%.16llx", + l_headerLid->numSections, + l_err->getUserData1(), + l_headerRsvd->numSections, + l_err->getUserData2()); + break; + } + else + { + *l_pNumSections -= 2; + } + + // Intentionally cause mismatch with TargetingSection type + // Then run validateData() to make sure this error is detected + TargetingSection* l_sectionLid = + reinterpret_cast<TargetingSection*>( + reinterpret_cast<uint64_t>(l_headerLid) + + sizeof(TargetingHeader) + + l_headerLid->offsetToSections); + uint8_t l_sectionType = l_sectionLid[0].sectionType; + uint8_t *l_pSectionType = + reinterpret_cast<uint8_t*>(reinterpret_cast<uint64_t>( + &l_sectionLid[0])); // sectionType is first field + *l_pSectionType = l_sectionType + 0xF0; + uint64_t l_expected = + TWO_UINT32_TO_UINT64(l_sectionLid[0].sectionType, + l_sectionRsvd[0].sectionType); + l_err = RT_TARG::validateData(l_lidStruct, + l_rsvdMemPtr, + l_lidDataSize); + if(ERRL_GETRC_SAFE(l_err) != TARG_RT_SECTION_MISMATCH) + { + TS_FAIL("testValidateData> unexpected reason code from " + "validateData, expected 0x%.4x, received 0x%.4x", + TARG_RT_SECTION_MISMATCH, + ERRL_GETRC_SAFE(l_err)); + break; + } + else if(l_err && + (l_err->moduleId() != TARG_RT_VALIDATEDATA)) + { + TS_FAIL("testValidateData> unexpected module ID from " + "validateData, expected 0x86, received 0x%.2x", + TARG_RT_VALIDATEDATA, + l_err->moduleId()); + break; + } + else if(l_err && + ((l_err->getUserData1() != 0) || + (l_err->getUserData2() != l_expected))) + { + TS_FAIL("testValidateData> unexpected user data from " + "validateData, expected 0, rcvd 0x%.16llx, " + "expected 0x%.16llx, rcvd 0x%.16llx", + l_err->getUserData1(), + l_expected, + l_err->getUserData2()); + break; + } + else + { + *l_pSectionType = l_sectionType; + } + + // Detect TargetingSection size mismatch + uint32_t l_sectionSize = l_sectionRsvd[0].sectionSize; + uint32_t *l_pSectionSize = + reinterpret_cast<uint32_t*>(reinterpret_cast<uint64_t>( + &l_sectionRsvd[0].sectionSize)); + *l_pSectionSize = l_sectionSize + 0x100; + l_err = RT_TARG::validateData(l_lidStruct, + l_rsvdMemPtr, + l_lidDataSize); + if(l_err) + { + TS_FAIL("testValidateData> unexpected error log from " + "validateData, should only trace mismatch"); + break; + } + else + { + *l_pSectionSize = l_sectionSize; + } + + // Validate LID Structure against Reserved Memory + l_err = RT_TARG::validateData(l_lidStruct, + l_rsvdMemPtr, + l_lidDataSize); + if(l_err) + { + TS_FAIL("testValidateData> unexpected error log from " + "validateData"); + break; + } + + TRACFCOMP(g_trac_targeting,"testValidateData SUCCESS"); + } while(false); + + free(l_lidStruct); + l_lidStruct = nullptr; + + TRACFCOMP(g_trac_targeting,EXIT_MRK"testValidateData"); + } + + // Test the internal function used during HBRT concurrent update to save + // and restoresattribute values from current Reserved Memory data into + // new LID Structure data. This testcase uses Reserved Memory data to + // make its LID Structure, so it tests basic logic in the functions, but + // does not test more complex handling of special data conditions. + void testSaveRestoreAttrs() { -#if 0 //@todo-RTC:188625-Turn this back on using namespace TARGETING; TRACFCOMP(g_trac_targeting,ENTER_MRK"testSaveRestoreAttrs"); - int rc = 0; - uint64_t l_userdata2 = 0; + errlHndl_t l_err = nullptr; + NODE_ID l_node = NODE0; // Runs on Standalone, so only Node 0 void *l_lidStruct = nullptr; do @@ -308,7 +568,7 @@ class TargetingTestSuite : public CxxTest::TestSuite uint64_t l_attr_size = 0; uint64_t l_rsvdMem = hb_get_rt_rsvd_mem(Util::HBRT_MEM_LABEL_ATTR, - 0, + l_node, l_attr_size); void *l_rsvdMemPtr = reinterpret_cast<void*>(l_rsvdMem); @@ -325,22 +585,13 @@ class TargetingTestSuite : public CxxTest::TestSuite number of sections match, and that the types of each TargetingSection match. */ size_t l_lidDataSize = 0; - rc = RT_TARG::validateData(l_lidStruct, - l_rsvdMemPtr, - l_lidDataSize, - l_userdata2); - if(rc) - { - TS_FAIL("testSaveRestoreAttrs> unexpected return code from " - "validateData, received 0x%.2x", - rc); - break; - } - else if(l_userdata2 != 0) + l_err = RT_TARG::validateData(l_lidStruct, + l_rsvdMemPtr, + l_lidDataSize); + if(l_err) { - TS_FAIL("testSaveRestoreAttrs> unexpected user data from " - "validateData, received 0x%.16llx", - l_userdata2); + TS_FAIL("testSaveRestoreAttrs> unexpected error log from " + "validateData"); break; } @@ -358,21 +609,13 @@ class TargetingTestSuite : public CxxTest::TestSuite into new LID Structure data. Leave attribute values in new LID Structure data as is, if there is no value from current Reserved Memory data. */ - rc = RT_TARG::saveRestoreAttrs(l_rsvdMemPtr, - l_lidStruct, - l_userdata2); - if(rc) - { - TS_FAIL("testSaveRestoreAttrs> unexpected return code from " - "saveRestoreAttrs, received 0x%.2x", - rc); - break; - } - else if(l_userdata2 != 0) + l_err = RT_TARG::saveRestoreAttrs(l_rsvdMemPtr, + l_lidStruct, + l_node); + if(l_err) { - TS_FAIL("testSaveRestoreAttrs> unexpected user data from " - "saveRestoreAttrs, received 0x%.8x", - l_userdata2); + TS_FAIL("testSaveRestoreAttrs> unexpected error log from " + "validateData"); break; } @@ -523,159 +766,6 @@ class TargetingTestSuite : public CxxTest::TestSuite break; } - // Detect invalid LID Structure TargetingHeader eyecatcher - TargetingHeader* l_headerLid = - reinterpret_cast<TargetingHeader*>(l_lidStruct); - uint32_t *l_pEyeCatcher = - reinterpret_cast<uint32_t*>(reinterpret_cast<uint64_t>( - &l_headerLid->eyeCatcher)); - *l_pEyeCatcher += 0x20202020; - rc = RT_TARG::validateData(l_lidStruct, - l_rsvdMemPtr, - l_lidDataSize, - l_userdata2); - if(rc != 0x11) - { - TS_FAIL("testSaveRestoreAttrs> unexpected return code from " - "validateData, expected 0x11, received 0x%.2x", - rc); - break; - } - else if(l_userdata2 != l_headerLid->eyeCatcher) - { - TS_FAIL("testSaveRestoreAttrs> unexpected user data from " - "validateData, expected 0x%.16llx, rcvd 0x%.16llx", - l_headerLid->eyeCatcher, - l_userdata2); - break; - } - else - { - *l_pEyeCatcher -= 0x20202020; - l_userdata2 = 0; - } - - // Detect invalid Reserved Memory TargetingHeader eyecatcher - l_pEyeCatcher = - reinterpret_cast<uint32_t*>(reinterpret_cast<uint64_t>( - &l_headerRsvd->eyeCatcher)); - *l_pEyeCatcher += 0x00202020; - rc = RT_TARG::validateData(l_lidStruct, - l_rsvdMemPtr, - l_lidDataSize, - l_userdata2); - if(rc != 0x12) - { - TS_FAIL("testSaveRestoreAttrs> unexpected return code from " - "validateData, expected 0x12, received 0x%.2x", - rc); - break; - } - else if(l_userdata2 != l_headerRsvd->eyeCatcher) - { - TS_FAIL("testSaveRestoreAttrs> unexpected user data from " - "validateData, expected 0x%.16llx, rcvd 0x%.16llx", - l_headerRsvd->eyeCatcher, - l_userdata2); - break; - } - else - { - *l_pEyeCatcher -= 0x00202020; - l_userdata2 = 0; - } - - // Detect TargetingHeader number of sections mismatch - uint32_t *l_pNumSections = - reinterpret_cast<uint32_t*>(reinterpret_cast<uint64_t>( - &l_headerRsvd->numSections)); - *l_pNumSections += 2; - uint64_t l_expected = - TWO_UINT32_TO_UINT64(l_headerLid->numSections, - l_headerRsvd->numSections); - rc = RT_TARG::validateData(l_lidStruct, - l_rsvdMemPtr, - l_lidDataSize, - l_userdata2); - if(rc != 0x13) - { - TS_FAIL("testSaveRestoreAttrs> unexpected return code from " - "validateData, expected 0x13, received 0x%.2x", - rc); - break; - } - else if(l_userdata2 != l_expected) - { - TS_FAIL("testSaveRestoreAttrs> unexpected user data from " - "validateData, expected 0x%.16llx, rcvd 0x%.16llx", - l_expected, - l_userdata2); - break; - } - else - { - *l_pNumSections -= 2; - l_userdata2 = 0; - } - - // Detect TargetingSection type mismatch - TargetingSection* l_sectionLid = - reinterpret_cast<TargetingSection*>( - reinterpret_cast<uint64_t>(l_headerLid) + - sizeof(TargetingHeader) + - l_headerLid->offsetToSections); - uint8_t l_sectionType = l_sectionLid[0].sectionType; - uint8_t *l_pSectionType = - reinterpret_cast<uint8_t*>(reinterpret_cast<uint64_t>( - &l_sectionLid[0])); // sectionType is first field - *l_pSectionType = l_sectionType + 0xF0; - l_expected = - TWO_UINT32_TO_UINT64(l_sectionLid[0].sectionType, - l_sectionRsvd[0].sectionType); - rc = RT_TARG::validateData(l_lidStruct, - l_rsvdMemPtr, - l_lidDataSize, - l_userdata2); - if(rc != 0x14) - { - TS_FAIL("testSaveRestoreAttrs> unexpected return code from " - "validateData, expected 0x14, received 0x%.2x", - rc); - break; - } - else if(l_userdata2 != l_expected) - { - TS_FAIL("testSaveRestoreAttrs> unexpected user data from " - "validateData, expected 0x%.16llx, rcvd 0x%.16llx", - l_expected, - l_userdata2); - break; - } - else - { - *l_pSectionType = l_sectionType; - l_userdata2 = 0; - } - - // Validate LID Structure against Reserved Memory - rc = RT_TARG::validateData(l_lidStruct, - l_rsvdMemPtr, - l_lidDataSize, - l_userdata2); - if(rc) - { - TS_FAIL("testSaveRestoreAttrs> unexpected return code from " - "validateData, received 0x%.2x", - rc); - break; - } - else if(l_userdata2 != 0) - { - TS_FAIL("testSaveRestoreAttrs> unexpected user data from " - "validateData, received 0x%.16llx", - l_userdata2); - break; - } TRACFCOMP(g_trac_targeting,"testSaveRestoreAttrs SUCCESS"); } while(false); @@ -684,7 +774,6 @@ class TargetingTestSuite : public CxxTest::TestSuite l_lidStruct = nullptr; TRACFCOMP(g_trac_targeting,EXIT_MRK"testSaveRestoreAttrs"); -#endif } }; |