diff options
Diffstat (limited to 'src')
4 files changed, 168 insertions, 102 deletions
diff --git a/src/import/chips/p9/procedures/xml/error_info/p9_sbe_common_errors.xml b/src/import/chips/p9/procedures/xml/error_info/p9_sbe_common_errors.xml index c9a65622f..a50cfeeb1 100644 --- a/src/import/chips/p9/procedures/xml/error_info/p9_sbe_common_errors.xml +++ b/src/import/chips/p9/procedures/xml/error_info/p9_sbe_common_errors.xml @@ -249,7 +249,14 @@ <target>TARGET_CHIPLET</target> </gard> </hwpError> - <!-- ******************************************************************** --> + <!-- ******************************************************************** --> + <hwpError> + <sbeError/> + <rc>RC_INVALID_SBE_FFDC_PACKET</rc> + <description>Invalid data detected in the SBE FFDC buffer</description> + <buffer>FFDC_BUFFER</buffer> + </hwpError> + <!-- ******************************************************************** --> <hwpError> <sbeError/> <rc>RC_CPLT_NOT_ALIGNED_ERR</rc> diff --git a/src/import/hwpf/fapi2/include/collect_reg_ffdc.H b/src/import/hwpf/fapi2/include/collect_reg_ffdc.H index 9bd3665a4..f17b83fa7 100644 --- a/src/import/hwpf/fapi2/include/collect_reg_ffdc.H +++ b/src/import/hwpf/fapi2/include/collect_reg_ffdc.H @@ -472,87 +472,94 @@ void collectRegFfdc(const fapi2::ffdc_t i_parent, std::vector<fapi2::Target<C> > l_targets; - Target<T> l_parent = - *(static_cast<const Target<T>*>(i_parent.ptr())); - - // Collect FFDC for functional or present chiplets of - // type C associated with i_target - yeah, odd syntax. - l_targets = l_parent.template getChildren<C>(i_childState); - - if (l_targets.empty()) + if( i_parent.ptr() == nullptr ) { - FAPI_INF("collect_reg_ffdc.C: Error: No chiplets found. "); - return; + FAPI_ERR("Target ptr in FFDC object was null, skipping register data collection."); } + else + { - std::vector<uint32_t> l_cfamAddresses; - std::vector<uint64_t> l_scomAddresses; + Target<T> l_parent = + *(static_cast<const Target<T>*>(i_parent.ptr())); - uint32_t l_ffdcSize = 0; // total size needed for all entries - uint32_t l_ffdcRegReadSize = 0; // readRegisters size addition + // Collect FFDC for functional or present chiplets of + // type C associated with i_target - yeah, odd syntax. + l_targets = l_parent.template getChildren<C>(i_childState); - // call generated code to fetch the address vectors - getAddressData(i_ffdcId, l_scomAddresses, l_cfamAddresses, l_ffdcRegReadSize); + if (l_targets.empty()) + { + FAPI_INF("collect_reg_ffdc.C: Error: No chiplets found. "); + return; + } - uint32_t l_position = 0; + std::vector<uint32_t> l_cfamAddresses; + std::vector<uint64_t> l_scomAddresses; - // initialize to single readRegister entry - l_ffdcSize = l_ffdcRegReadSize; + uint32_t l_ffdcSize = 0; // total size needed for all entries + uint32_t l_ffdcRegReadSize = 0; // readRegisters size addition - // add the position size to the total - l_ffdcSize += sizeof(l_position); + // call generated code to fetch the address vectors + getAddressData(i_ffdcId, l_scomAddresses, l_cfamAddresses, l_ffdcRegReadSize); - // update size for each target - l_ffdcSize = (l_ffdcSize * l_targets.size()); + uint32_t l_position = 0; - uint8_t l_pBuf[l_ffdcSize]; + // initialize to single readRegister entry + l_ffdcSize = l_ffdcRegReadSize; - uint8_t* l_pData = &l_pBuf[0]; + // add the position size to the total + l_ffdcSize += sizeof(l_position); - // grab the data for each child target - for( auto target : l_targets) - { - ReturnCode l_rc = - TargetPosition<C>(target).getPosition(l_position); + // update size for each target + l_ffdcSize = (l_ffdcSize * l_targets.size()); - // add chip/chiplets position to the data - memcpy(l_pData, &l_position, sizeof(l_position)); + uint8_t l_pBuf[l_ffdcSize]; - // advance the pointer into our buffer - l_pData += sizeof(l_position); + uint8_t* l_pData = &l_pBuf[0]; - if(i_childState == TARGET_STATE_FUNCTIONAL) + // grab the data for each child target + for( auto target : l_targets) { - FAPI_INF(" calling version for TARGET_STATE_FUNCTIONAL "); + ReturnCode l_rc = + TargetPosition<C>(target).getPosition(l_position); - // since its functional just read from the child target - readRegisters(target, l_pData, l_cfamAddresses, - l_scomAddresses, i_childOffsetMult); - } - else - { - // use the parent and read address + offset since the - // child targets may not be functional - uint32_t l_offset = i_childOffsetMult * l_position; + // add chip/chiplets position to the data + memcpy(l_pData, &l_position, sizeof(l_position)); - FAPI_INF(" calling version for TARGET_STATE_PRESENT "); + // advance the pointer into our buffer + l_pData += sizeof(l_position); - readRegisters(l_parent, l_pData, l_cfamAddresses, - l_scomAddresses, l_offset); - } + if(i_childState == TARGET_STATE_FUNCTIONAL) + { + FAPI_INF(" calling version for TARGET_STATE_FUNCTIONAL "); - // advance the pointer past readRegisters data entry - l_pData += l_ffdcRegReadSize; - } + // since its functional just read from the child target + readRegisters(target, l_pData, l_cfamAddresses, + l_scomAddresses, i_childOffsetMult); + } + else + { + // use the parent and read address + offset since the + // child targets may not be functional + uint32_t l_offset = i_childOffsetMult * l_position; + + FAPI_INF(" calling version for TARGET_STATE_PRESENT "); + + readRegisters(l_parent, l_pData, l_cfamAddresses, + l_scomAddresses, l_offset); + } - FAPI_INF("collectRegFfdc. SCOM address count: %#lx", l_scomAddresses.size()); - FAPI_INF("collectRegFfdc. CFAM address count: %#lx", l_cfamAddresses.size()); + // advance the pointer past readRegisters data entry + l_pData += l_ffdcRegReadSize; + } - FAPI_DBG("size info i_ffdcId = %d, l_pBuf = %p, l_ffdcSize=%d", i_ffdcId, l_pBuf, l_ffdcSize); + FAPI_INF("collectRegFfdc. SCOM address count: %#lx", l_scomAddresses.size()); + FAPI_INF("collectRegFfdc. CFAM address count: %#lx", l_cfamAddresses.size()); - // Create a ErrorInfoFfdc object and pass it back - o_errorInfoFfdc.push_back(std::shared_ptr<fapi2::ErrorInfoFfdc>(new ErrorInfoFfdc(i_ffdcId, l_pBuf, l_ffdcSize))); + FAPI_DBG("size info i_ffdcId = %d, l_pBuf = %p, l_ffdcSize=%d", i_ffdcId, l_pBuf, l_ffdcSize); + // Create a ErrorInfoFfdc object and pass it back + o_errorInfoFfdc.push_back(std::shared_ptr<fapi2::ErrorInfoFfdc>(new ErrorInfoFfdc(i_ffdcId, l_pBuf, l_ffdcSize))); + } } /// /// @brief Collect register data for a single target @@ -573,43 +580,51 @@ void collectRegFfdc(const fapi2::ffdc_t i_target, FAPI_INF("single target no children - "); - Target<T> l_target = - *(static_cast<const Target<T>*>(i_target.ptr())); + if( i_target.ptr() == nullptr ) + { + FAPI_ERR("Target ptr in FFDC object was null, skipping register data collection."); + } + else + { - std::vector<uint32_t> l_cfamAddresses; - std::vector<uint64_t> l_scomAddresses; + Target<T> l_target = + *(static_cast<const Target<T>*>(i_target.ptr())); - uint32_t l_ffdcSize = 0; + std::vector<uint32_t> l_cfamAddresses; + std::vector<uint64_t> l_scomAddresses; - // call generated code to fetch the address vectors - getAddressData(i_ffdcId, l_scomAddresses, l_cfamAddresses, l_ffdcSize); + uint32_t l_ffdcSize = 0; - uint32_t l_position = 0; + // call generated code to fetch the address vectors + getAddressData(i_ffdcId, l_scomAddresses, l_cfamAddresses, l_ffdcSize); - ReturnCode l_rc = TargetPosition<T>(l_target).getPosition(l_position); + uint32_t l_position = 0; - l_ffdcSize += sizeof(l_position); + ReturnCode l_rc = TargetPosition<T>(l_target).getPosition(l_position); - uint8_t l_pBuf[l_ffdcSize]; + l_ffdcSize += sizeof(l_position); - uint8_t* l_pData = &l_pBuf[0]; + uint8_t l_pBuf[l_ffdcSize]; - // add chip/chiplets position to the data - memcpy(l_pData, &l_position, sizeof(l_position)); + uint8_t* l_pData = &l_pBuf[0]; - l_pData += sizeof(l_position); + // add chip/chiplets position to the data + memcpy(l_pData, &l_position, sizeof(l_position)); - // do the work - readRegisters(l_target, l_pData, l_cfamAddresses, l_scomAddresses, - i_childOffset); + l_pData += sizeof(l_position); + + // do the work + readRegisters(l_target, l_pData, l_cfamAddresses, l_scomAddresses, + i_childOffset); - FAPI_DBG("size info i_ffdcId = %d, l_pBuf = %p, l_ffdcSize=%d", i_ffdcId, l_pBuf, l_ffdcSize); - // Create a ErrorInfoFfdc object and add it to the Error Information - // object of the FFDC class - o_errorInfoFfdc.push_back(std::shared_ptr<fapi2::ErrorInfoFfdc>(new ErrorInfoFfdc(i_ffdcId, l_pBuf, l_ffdcSize))); + FAPI_DBG("size info i_ffdcId = %d, l_pBuf = %p, l_ffdcSize=%d", i_ffdcId, l_pBuf, l_ffdcSize); + // Create a ErrorInfoFfdc object and add it to the Error Information + // object of the FFDC class + o_errorInfoFfdc.push_back(std::shared_ptr<fapi2::ErrorInfoFfdc>(new ErrorInfoFfdc(i_ffdcId, l_pBuf, l_ffdcSize))); - FAPI_INF("collectRegFfdc. SCOM address count: %d", (uint32_t)(l_scomAddresses.size())); - FAPI_INF("collectRegFfdc. CFAM address count: %d", (uint32_t)(l_cfamAddresses.size())); + FAPI_INF("collectRegFfdc. SCOM address count: %d", (uint32_t)(l_scomAddresses.size())); + FAPI_INF("collectRegFfdc. CFAM address count: %d", (uint32_t)(l_cfamAddresses.size())); + } FAPI_INF("collectRegFfdc() - exit"); } diff --git a/src/import/hwpf/fapi2/include/error_info_defs.H b/src/import/hwpf/fapi2/include/error_info_defs.H index 12198e499..c4264d107 100644 --- a/src/import/hwpf/fapi2/include/error_info_defs.H +++ b/src/import/hwpf/fapi2/include/error_info_defs.H @@ -254,30 +254,56 @@ enum CollectTrace // NOTE - this assumes no buffer_t or variable_buffers are passed // data is converted to a uint64_t when placed into the sbe ffdc // buffer -inline fapi2::ffdc_t getFfdcData( sbeFfdc_t& i_sbeFfdc ) +inline fapi2::ffdc_t getFfdcData( sbeFfdc_t& i_sbeFfdc, bool& invalid_data ) { - fapi2::ffdc_t temp; + fapi2::ffdc_t l_ffdc; - temp.size() = static_cast<size_t>(i_sbeFfdc.size); + l_ffdc.size() = static_cast<size_t>(i_sbeFfdc.size); - if(temp.size() == EI_FFDC_SIZE_TARGET) + if(l_ffdc.size() == EI_FFDC_SIZE_TARGET) { #ifdef FAPI2_ENABLE_PLATFORM_GET_TARGET uint64_t targetData = i_sbeFfdc.data; fapi2::TargetType type = static_cast<fapi2::TargetType>(targetData >> 32); uint8_t instance = static_cast<uint8_t>(targetData & 0xFFFFFFFF); // call hostboot to get the fapi2 target reference - temp.ptr() = static_cast<void*>(getTarget<TARGET_TYPE_ALL>(type, instance)); + l_ffdc.ptr() = static_cast<void*>(getTarget<TARGET_TYPE_ALL>(type, instance)); + + if(l_ffdc.ptr() == nullptr ) + { + invalid_data = true; + } + #endif } else { - // adjust the pointer based on the data size. - temp.ptr() = static_cast<void*>(reinterpret_cast<uint8_t*>(&i_sbeFfdc.data) + - (sizeof(uint64_t) - i_sbeFfdc.size)); + // validate the size in the buffer - assumes no buffers are returned + // from sbe - + switch( i_sbeFfdc.size ) + { + // valid sizes are 1,2,4 and 8 bytes only. + case 1: + case 2: + case 4: + case 8: + // data is at least a reasonable size + break; + + default: + FAPI_ERR("Invalid data size in SBE FFDC buffer"); + invalid_data = true; + } + + if(!invalid_data) + { + // adjust the pointer based on the data size. + l_ffdc.ptr() = static_cast<void*>(reinterpret_cast<uint8_t*>(&i_sbeFfdc.data) + + (sizeof(uint64_t) - i_sbeFfdc.size)); + } } - return temp; + return l_ffdc; } #endif /// diff --git a/src/import/hwpf/fapi2/tools/parseErrorInfo.pl b/src/import/hwpf/fapi2/tools/parseErrorInfo.pl index fb6f17548..662e7889a 100755 --- a/src/import/hwpf/fapi2/tools/parseErrorInfo.pl +++ b/src/import/hwpf/fapi2/tools/parseErrorInfo.pl @@ -301,8 +301,9 @@ sub addFfdcMethod { $method_body = " {\n $ffdc_uc.ptr() = &i_value;\n $ffdc_uc.size() ="; $method_body .= " fapi2::getErrorInfoFfdcSize(i_value);\n return *this;\n }\n\n"; - $methods->{$key}{member} = "$ffdc_type $ffdc_uc;"; - $methods->{$objectNumber}{localvar} = "$ffdc_type $ffdc_uc = getFfdcData(FFDC_BUFFER[$objectNumber]);"; + $methods->{$key}{member} = "$ffdc_type $ffdc_uc;"; + $methods->{$objectNumber}{localvar} = + "$ffdc_type $ffdc_uc = getFfdcData(FFDC_BUFFER[$objectNumber],invalid_data);"; $methods->{$objectNumber}{assignment_string} = "l_obj.$ffdc_uc = $ffdc_uc;"; } else @@ -333,8 +334,9 @@ sub addFfdcMethod $method_body .= " $ffdc_uc.size() = $param.template getLength<uint8_t>();\n"; $method_body .= " return *this;\n"; $method_body .= " }\n\n"; - $methods->{$key}{member} = "$ffdc_type $ffdc_uc;"; - $methods->{$objectNumber}{localvar} = "$buffer_ffdc_type $ffdc_uc = getFfdcData(FFDC_BUFFER[$objectNumber]);"; + $methods->{$key}{member} = "$ffdc_type $ffdc_uc;"; + $methods->{$objectNumber}{localvar} = + "$buffer_ffdc_type $ffdc_uc = getFfdcData(FFDC_BUFFER[$objectNumber],invalid_data);"; $methods->{$objectNumber}{assignment_string} = "l_obj.$ffdc_uc = $ffdc_uc;"; } @@ -369,15 +371,16 @@ sub addFfdcMethod . " return *this;\n }\n\n"; } - $methods->{$key}{member} = "$ffdc_type $ffdc_uc;"; - $methods->{$objectNumber}{localvar} = "$ffdc_type $ffdc_uc = getFfdcData(FFDC_BUFFER[$objectNumber]);"; + $methods->{$key}{member} = "$ffdc_type $ffdc_uc;"; + $methods->{$objectNumber}{localvar} = + "$ffdc_type $ffdc_uc = getFfdcData(FFDC_BUFFER[$objectNumber],invalid_data);"; $methods->{$objectNumber}{assignment_string} = "l_obj.$ffdc_uc=$ffdc_uc;"; } elsif ( $type eq $scom_addr_type ) { if ( $arg_local_ffdc eq undef ) { - $method = "\n static $type $ffdc_uc(const sbeFfdc_t *ffdc)\n"; + $method = "\n static $type $ffdc_uc(const sbeFfdc_t *ffdc)\n"; $method_body = " {\n return ffdc[$objectNumber].data;\n }\n\n"; } } @@ -389,8 +392,9 @@ sub addFfdcMethod { $method_body = " { $ffdc_uc = i_value; "; $method_body .= " return *this;}\n\n"; - $methods->{$key}{member} = "$type $ffdc_uc;"; - $methods->{$objectNumber}{localvar} = "$type $ffdc_uc = getFfdcData(FFDC_BUFFER[$objectNumber]);"; + $methods->{$key}{member} = "$type $ffdc_uc;"; + $methods->{$objectNumber}{localvar} = + "$type $ffdc_uc = getFfdcData(FFDC_BUFFER[$objectNumber],invalid_data);"; $methods->{$objectNumber}{assignment_string} = "l_obj.$ffdc_uc = $ffdc_uc;"; } else @@ -548,6 +552,7 @@ print SBFILE "#ifndef FAPI2_SETSBEERROR_H_\n"; print SBFILE "#define FAPI2_SETSBEERROR_H_\n\n"; print SBFILE "#define FAPI_SET_SBE_ERROR(RC,ERRVAL,FFDC_BUFFER,SBE_INSTANCE)\\\n"; print SBFILE "{\\\n"; +print SBFILE "bool invalid_data = false;\\\n"; print SBFILE "switch (ERRVAL)\\\n"; print SBFILE "{\\\n"; @@ -1610,7 +1615,10 @@ foreach my $argnum ( 0 .. $#ARGV ) { print SBFILE "$objectStr"; } - print SBFILE " l_obj.execute(); \\\n"; + print SBFILE " if(!invalid_data) \\\n"; + print SBFILE " { \\\n"; + print SBFILE " l_obj.execute(); \\\n"; + print SBFILE " } \\\n"; print SBFILE " break; \\\n } \\\n"; } @@ -1750,9 +1758,19 @@ print ECFILE "\n\n#endif\n"; #------------------------------------------------------------------------------ print SBFILE " default:\\\n"; -#print SBFILE " FAPI_SET_HWP_ERROR(RC, RC_SBE_UNKNOWN_ERROR,0);\\\n"; +print SBFILE " invalid_data = true;\\\n"; print SBFILE " break;\\\n"; print SBFILE "}\\\n"; +print SBFILE "if(invalid_data)\\\n"; +print SBFILE "{\\\n"; +print SBFILE " /* create a new rc and capture invalid ffdc buffer */\\\n"; +print SBFILE " /* FFDC buffer size is 20 sbeFfdc_t entries */\\\n"; +print SBFILE " /* variable buffer needs size in uint32_t, and the resulting bit count */\\\n"; +print SBFILE " const uint32_t size_bytes = (sizeof(sbeFfdc_t)*20);\\\n"; +print SBFILE " fapi2::variable_buffer l_buffer((uint32_t*)FFDC_BUFFER, size_bytes/4, size_bytes*8);\\\n"; +print SBFILE " fapi2::INVALID_SBE_FFDC_PACKET(fapi2::FAPI2_ERRL_SEV_UNRECOVERABLE,RC)."; +print SBFILE "set_FFDC_BUFFER(l_buffer).execute();\\\n"; +print SBFILE "}\\\n"; print SBFILE "}\n\n"; print SBFILE "#endif\n"; |