diff options
Diffstat (limited to 'src/import')
-rw-r--r-- | src/import/chips/p9/procedures/xml/error_info/p9_sbe_common_errors.xml | 9 | ||||
-rw-r--r-- | src/import/hwpf/fapi2/include/error_info_defs.H | 44 | ||||
-rwxr-xr-x | src/import/hwpf/fapi2/tools/parseErrorInfo.pl | 40 |
3 files changed, 72 insertions, 21 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 cc75612a..d2b2c8b4 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/error_info_defs.H b/src/import/hwpf/fapi2/include/error_info_defs.H index 7e1803d0..2f6db98c 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 ac584758..4171c0c0 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"; |