diff options
author | Dan Crowell <dcrowell@us.ibm.com> | 2014-02-10 08:06:08 -0600 |
---|---|---|
committer | A. Patrick Williams III <iawillia@us.ibm.com> | 2014-02-13 12:58:36 -0600 |
commit | 472bc1848b9ec2e96759701c4c6ce30c7c7e1327 (patch) | |
tree | 0501ef16e8af75f13e3b64f2625fbad6cf0236c9 /src | |
parent | df21cebcb1957ebcecab51ee052b517af0ffeb29 (diff) | |
download | talos-hostboot-472bc1848b9ec2e96759701c4c6ce30c7c7e1327.tar.gz talos-hostboot-472bc1848b9ec2e96759701c4c6ce30c7c7e1327.zip |
Fix multi-node support for host services attributes
Change-Id: I88562e5c58c68c4de2989a0808171d88b6724c11
CQ: SW244988
Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/8725
Tested-by: Jenkins Server
Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/usr/runtime/hdatservice.C | 50 | ||||
-rw-r--r-- | src/usr/runtime/populate_attributes.C | 24 |
2 files changed, 50 insertions, 24 deletions
diff --git a/src/usr/runtime/hdatservice.C b/src/usr/runtime/hdatservice.C index d58ba041b..72e5babf1 100644 --- a/src/usr/runtime/hdatservice.C +++ b/src/usr/runtime/hdatservice.C @@ -52,7 +52,7 @@ namespace RUNTIME const hdatHeaderExp_t HSVC_NODE_DATA_HEADER = { 0xD1F0, // id "HS KID", // name - 0x0010 //version + 0x0020 //version }; const hdatHeaderExp_t HSVC_DATA_HEADER = { @@ -761,19 +761,18 @@ errlHndl_t hdatService::getHostDataSection( SectionId i_section, hdatHDIFChildHdr_t* node_header = reinterpret_cast<hdatHDIFChildHdr_t*> (hsvc_header->hdatChildStrOffset + base_addr); - TRACUCOMP( g_trac_runtime, "node_headers=%p", node_header ); + uint64_t first_node_header = + mm_virt_to_phys(reinterpret_cast<void*>(node_header)); + TRACUCOMP( g_trac_runtime, "first node_header=%X->%p", first_node_header, node_header ); + // Make sure the Child Header is pointing somewhere valid errhdl = verify_hdat_address( node_header, sizeof(hdatHDIFChildHdr_t) ); if( errhdl ) { break; } - hdatHDIF_t* node_data_headers = + hdatHDIF_t* node_data_header = reinterpret_cast<hdatHDIF_t*> (node_header->hdatOffset + base_addr); - // Make sure the headers are all in a valid range - errhdl = verify_hdat_address( node_data_headers, - sizeof(hdatHDIF_t)*(node_header->hdatCnt) ); - if( errhdl ) { break; } // Loop around all instances because the data // could be sparsely populated @@ -782,27 +781,39 @@ errlHndl_t hdatService::getHostDataSection( SectionId i_section, uint32_t found_instances = 0; for( uint8_t index = 0; index < node_header->hdatCnt; index++ ) { - TRACUCOMP( g_trac_runtime, "index=%d", index ); + // Make sure the headers are all in a valid range + errhdl = verify_hdat_address( node_data_header, + sizeof(hdatHDIF_t) ); + if( errhdl ) { break; } + + uint64_t phys_addr = + mm_virt_to_phys(reinterpret_cast<void*>(node_data_header)); + TRACFCOMP( g_trac_runtime, "index=%d, header=%p->%X", index, node_data_header, phys_addr ); // Check the headers and version info - errhdl = check_header( &(node_data_headers[index]), + errhdl = check_header( node_data_header, HSVC_NODE_DATA_HEADER ); if( errhdl ) { break; } - uint64_t node_base_addr = - reinterpret_cast<uint64_t>(&(node_data_headers[index])); - - TRACUCOMP( g_trac_runtime, "%d> hdatInstance=%d", index, node_data_headers[index].hdatInstance ); - if( node_data_headers[index].hdatInstance != i_instance ) + TRACFCOMP( g_trac_runtime, "%d> hdatInstance=%d, hdatSize=%d", index, node_data_header->hdatInstance, node_data_header->hdatSize ); + if( node_data_header->hdatInstance != i_instance ) { found_instances |= - (0x80000000 >> node_data_headers[index].hdatInstance); + (0x80000000 >> node_data_header->hdatInstance); + //increment to the next child section + node_data_header = + reinterpret_cast<hdatHDIF_t*> + (reinterpret_cast<uint64_t>(node_data_header) + + node_data_header->hdatSize); continue; } foundit = true; + uint64_t node_base_addr = + reinterpret_cast<uint64_t>(node_data_header); + hdatHDIFDataHdr_t* local_node_header = reinterpret_cast<hdatHDIFDataHdr_t*> - (node_data_headers[index].hdatDataPtrOffset + node_base_addr); + (node_data_header->hdatDataPtrOffset + node_base_addr); TRACUCOMP( g_trac_runtime, "local_node_header=%p", local_node_header ); // Make sure the header is pointing somewhere valid errhdl = verify_hdat_address( local_node_header, @@ -820,15 +831,12 @@ errlHndl_t hdatService::getHostDataSection( SectionId i_section, if( !foundit ) { TRACFCOMP( g_trac_runtime, "getHostDataSection> HSVC_NODE_DATA instance %d of section %d is unallocated", i_instance, i_section ); - // Go get the physical address we mapped in - uint64_t phys_addr = - mm_virt_to_phys(reinterpret_cast<void*>(node_data_headers)); /*@ * @errortype * @moduleid RUNTIME::MOD_HDATSERVICE_GETHOSTDATASECTION * @reasoncode RUNTIME::RC_NO_HSVC_NODE_DATA_FOUND - * @userdata1 Mainstore address of node_data_headers + * @userdata1 Mainstore address of first node_data_header * @userdata2[0:31] Requested Instance * @userdata2[32:63] Bitmask of discovered instances * @devdesc Requested instance of HSVC_NODE_DATA is @@ -838,7 +846,7 @@ errlHndl_t hdatService::getHostDataSection( SectionId i_section, ERRORLOG::ERRL_SEV_UNRECOVERABLE, RUNTIME::MOD_HDATSERVICE_GETHOSTDATASECTION, RUNTIME::RC_NO_HSVC_NODE_DATA_FOUND, - phys_addr, + first_node_header, TWO_UINT32_TO_UINT64(i_instance, found_instances)); errhdl->addProcedureCallout( HWAS::EPUB_PRC_HB_CODE, diff --git a/src/usr/runtime/populate_attributes.C b/src/usr/runtime/populate_attributes.C index 5d8e0a260..54b40669c 100644 --- a/src/usr/runtime/populate_attributes.C +++ b/src/usr/runtime/populate_attributes.C @@ -61,6 +61,11 @@ TRAC_INIT(&g_trac_runtime, RUNTIME_COMP_NAME, KILOBYTE); _cur_header->id = fapi::__fid; \ _cur_header->sizeBytes = sizeof(fapi::__fid##_Type); \ _cur_header->offset = (_output_ptr - _beginning); \ + if( _output_ptr + sizeof(fapi::__fid##_Type) > _end_of_area ) { \ + TRACFCOMP( g_trac_runtime, "Not enough space for 0x%X (%p + 0x%X > %p", fapi::__fid, _output_ptr, sizeof(fapi::__fid##_Type), _end_of_area ); \ + _failed_attribute = fapi::__fid; \ + break; \ + } \ memcpy( _output_ptr, &result_##__fid, sizeof(fapi::__fid##_Type) ); \ _output_ptr += sizeof(fapi::__fid##_Type); \ (*_num_attr)++; @@ -81,6 +86,11 @@ TRAC_INIT(&g_trac_runtime, RUNTIME_COMP_NAME, KILOBYTE); _cur_header->id = fapi::__fid; \ _cur_header->sizeBytes = sizeof(fapi::__fid##_Type); \ _cur_header->offset = (_output_ptr - _beginning); \ + if( _output_ptr + sizeof(fapi::__fid##_Type) > _end_of_area ) { \ + TRACFCOMP( g_trac_runtime, "Not enough space for 0x%X (%p + 0x%X > %p", fapi::__fid, _output_ptr, sizeof(fapi::__fid##_Type), _end_of_area ); \ + _failed_attribute = fapi::__fid; \ + break; \ + } \ memcpy( _output_ptr, &result_##__fid, sizeof(fapi::__fid##_Type) ); \ _output_ptr += sizeof(fapi::__fid##_Type); \ (*_num_attr)++; @@ -308,6 +318,8 @@ errlHndl_t populate_system_attributes( void ) fapi::Target* _target = NULL; //target for FAPI_ATTR_GET hsvc_attr_header_t* _cur_header = NULL; //temp variable uint32_t _huid_temp = 0; //temp variable + void* _end_of_area = reinterpret_cast<void*>(sys_data_addr + + sys_data_size); // Prepare the vars for the HSVC_LOAD_ATTR macros _beginning = reinterpret_cast<char*>(sys_data); @@ -337,12 +349,13 @@ errlHndl_t populate_system_attributes( void ) // Add an empty attribute header to signal the end EMPTY_ATTRIBUTE; - TRACFCOMP( g_trac_runtime, "populate_system_attributes> numAttr=%d", sys_data->hsvc.numAttr ); + size_t total_bytes = _output_ptr - sys_data->attributes; + TRACFCOMP( g_trac_runtime, "populate_system_attributes> numAttr=%d, bytes=%d", sys_data->hsvc.numAttr, total_bytes ); // Make sure we don't overrun our space assert( *_num_attr < system_data_t::MAX_ATTRIBUTES ); - TRACFCOMP( g_trac_runtime, "Run: system_cmp0.memory_ln4->image.save attributes.sys.bin 0x%X %d", sys_data, sizeof(system_data_t) ); + TRACDCOMP( g_trac_runtime, "Run: system_cmp0.memory_ln4->image.save attributes.sys.bin 0x%X %d", sys_data, total_bytes ); } while(0); // Handle any errors from FAPI_ATTR_GET @@ -454,6 +467,8 @@ errlHndl_t populate_node_attributes( uint64_t i_nodeNum ) fapi::Target* _target = NULL; //target for FAPI_ATTR_GET hsvc_attr_header_t* _cur_header = NULL; //temp variable uint32_t _huid_temp = 0; //temp variable + void* _end_of_area = reinterpret_cast<void*>(node_data_addr + + node_data_size); // Prepare the vars for the HSVC_LOAD_ATTR macros _beginning = reinterpret_cast<char*>(node_data); @@ -587,6 +602,9 @@ errlHndl_t populate_node_attributes( uint64_t i_nodeNum ) next_proc++; } + size_t total_bytes = _output_ptr - node_data->attributes; + TRACFCOMP( g_trac_runtime, "populate_node_attributes> Total bytes = %d", total_bytes ); + // Add an empty Proc marker at the end node_data->procs[next_proc].procid = hsvc_proc_header_t::NO_PROC; node_data->procs[next_proc].offset = 0; @@ -598,7 +616,7 @@ errlHndl_t populate_node_attributes( uint64_t i_nodeNum ) node_data->ex[next_ex].chiplet = hsvc_ex_header_t::NO_CHIPLET; node_data->ex[next_ex].numAttr = 0; - TRACFCOMP( g_trac_runtime, "Run: system_cmp0.memory_ln4->image.save attributes.node.bin 0x%X %d", node_data, sizeof(node_data_t) ); + TRACDCOMP( g_trac_runtime, "Run: system_cmp0.memory_ln4->image.save attributes.node.bin 0x%X %d", node_data, total_bytes ); } while(0); // Handle any errors from FAPI_ATTR_GET |