diff options
| author | Glenn Miles <milesg@ibm.com> | 2019-02-25 10:27:35 -0600 |
|---|---|---|
| committer | Daniel M. Crowell <dcrowell@us.ibm.com> | 2019-03-06 09:44:56 -0600 |
| commit | 0af9610f18a1d8979046617744c2c8e9ada33ad8 (patch) | |
| tree | 2e11baac18ac6461737d38246189df562df448e2 /src | |
| parent | e70d216f8e2b9dea8c8f89e13a4ac9d8f56caa3b (diff) | |
| download | blackbird-hostboot-0af9610f18a1d8979046617744c2c8e9ada33ad8.tar.gz blackbird-hostboot-0af9610f18a1d8979046617744c2c8e9ada33ad8.zip | |
Make access to iv_overridePtr threadsafe
iv_overridePtr uses std::map, which is known to not be threadsafe.
This change uses a mutex to prevent concurrent access.
Change-Id: I9a670925d191cf4f62c7cabc4f08bf83e61ff023
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/72648
Reviewed-by: Christian R. Geddes <crgeddes@us.ibm.com>
Reviewed-by: Matthew Raybuck <matthew.raybuck@ibm.com>
Reviewed-by: Ilya Smirnov <ismirno@us.ibm.com>
Reviewed-by: Nicholas E. Bofferding <bofferdn@us.ibm.com>
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/usr/vpd/cvpd.C | 8 | ||||
| -rw-r--r-- | src/usr/vpd/dvpd.C | 8 | ||||
| -rw-r--r-- | src/usr/vpd/ipvpd.C | 22 |
3 files changed, 36 insertions, 2 deletions
diff --git a/src/usr/vpd/cvpd.C b/src/usr/vpd/cvpd.C index fe203dd50..354e76ab9 100644 --- a/src/usr/vpd/cvpd.C +++ b/src/usr/vpd/cvpd.C @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2013,2018 */ +/* Contributors Listed Below - COPYRIGHT 2013,2019 */ /* [+] Google Inc. */ /* [+] International Business Machines Corp. */ /* */ @@ -341,7 +341,9 @@ errlHndl_t CvpdFacade::checkForRecordOverride( const char* i_record, if( strcmp( i_record, "SPDX" ) ) { TRACFCOMP(g_trac_vpd,"Record %s has no override", i_record); + mutex_lock(&iv_mutex); //iv_overridePtr is not threadsafe iv_overridePtr[l_recTarg] = nullptr; + mutex_unlock(&iv_mutex); break; } @@ -361,6 +363,7 @@ errlHndl_t CvpdFacade::checkForRecordOverride( const char* i_record, // For any error, we should reset the override map so that we'll // attempt everything again the next time we want VPD + mutex_lock(&iv_mutex); //iv_overridePtr is not threadsafe if( l_errl ) { iv_overridePtr.erase(l_recTarg); @@ -369,6 +372,7 @@ errlHndl_t CvpdFacade::checkForRecordOverride( const char* i_record, { o_ptr = iv_overridePtr[l_recTarg]; } + mutex_unlock(&iv_mutex); return l_errl; } @@ -403,7 +407,9 @@ errlHndl_t CvpdFacade::loadUnloadSecureSection( input_args_t i_args, // Jump out if we don't have an override VPD::RecordTargetPair_t l_recTarg = VPD::makeRecordTargetPair(l_record,i_target); + mutex_lock(&iv_mutex); //iv_overridePtr is not threadsafe VPD::OverrideMap_t::iterator l_overItr = iv_overridePtr.find(l_recTarg); + mutex_unlock(&iv_mutex); if( l_overItr == iv_overridePtr.end() ) { return nullptr; diff --git a/src/usr/vpd/dvpd.C b/src/usr/vpd/dvpd.C index 9e5e7fbf4..d0238b997 100644 --- a/src/usr/vpd/dvpd.C +++ b/src/usr/vpd/dvpd.C @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2013,2018 */ +/* Contributors Listed Below - COPYRIGHT 2013,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -426,7 +426,9 @@ errlHndl_t DvpdFacade::checkForRecordOverride( const char* i_record, if( strcmp( i_record, "MEMD" ) ) { TRACFCOMP(g_trac_vpd,"Record %s has no override", i_record); + mutex_lock(&iv_mutex); //iv_overridePtr is not threadsafe iv_overridePtr[l_recTarg] = nullptr; + mutex_unlock(&iv_mutex); break; } @@ -446,6 +448,7 @@ errlHndl_t DvpdFacade::checkForRecordOverride( const char* i_record, // For any error, we should reset the override map so that we'll // attempt everything again the next time we want VPD + mutex_lock(&iv_mutex); //iv_overridePtr is not threadsafe if( l_errl ) { iv_overridePtr.erase(l_recTarg); @@ -454,6 +457,7 @@ errlHndl_t DvpdFacade::checkForRecordOverride( const char* i_record, { o_ptr = iv_overridePtr[l_recTarg]; } + mutex_unlock(&iv_mutex); return l_errl; } @@ -488,7 +492,9 @@ errlHndl_t DvpdFacade::loadUnloadSecureSection( input_args_t i_args, // Jump out if we don't have an override VPD::RecordTargetPair_t l_recTarg = VPD::makeRecordTargetPair(l_record,i_target); + mutex_lock(&iv_mutex); //iv_overridePtr is not threadsafe VPD::OverrideMap_t::iterator l_overItr = iv_overridePtr.find(l_recTarg); + mutex_unlock(&iv_mutex); if( l_overItr == iv_overridePtr.end() ) { return nullptr; diff --git a/src/usr/vpd/ipvpd.C b/src/usr/vpd/ipvpd.C index 241c8e7cf..168bc5d36 100644 --- a/src/usr/vpd/ipvpd.C +++ b/src/usr/vpd/ipvpd.C @@ -865,13 +865,16 @@ errlHndl_t IpVpdFacade::findRecordOffset ( const char * i_record, VPD::makeRecordTargetPair(i_record,i_target); // Check if we already figured out where to get this record from + mutex_lock(&iv_mutex); //iv_overridePtr is not threadsafe VPD::OverrideMap_t::iterator l_overItr = iv_overridePtr.find(l_recTarg); if( l_overItr != iv_overridePtr.end() ) { l_overridePtr = l_overItr->second; + mutex_unlock(&iv_mutex); } else { + mutex_unlock(&iv_mutex); // Now go see if we should be using the override and if so // where we find the right copy err = checkForRecordOverride(i_record,i_target,l_overridePtr); @@ -1646,6 +1649,7 @@ errlHndl_t IpVpdFacade::fetchData ( uint64_t i_byteAddr, // At this point we can assume that the pointer is set into our // map if we need it + mutex_lock(&iv_mutex); //iv_overridePtr is not threadsafe VPD::OverrideMap_t::iterator l_overItr = iv_overridePtr.find(l_recTarg); if( l_overItr != iv_overridePtr.end() ) { @@ -1680,6 +1684,7 @@ errlHndl_t IpVpdFacade::fetchData ( uint64_t i_byteAddr, assert( false, "iv_overridePtr is not set inside IpVpdFacade::fetchData" ); } + mutex_unlock(&iv_mutex); } // Get the data @@ -2142,9 +2147,12 @@ errlHndl_t IpVpdFacade::writeKeyword ( const char * i_keywordName, // At this point we can assume that the pointer is set into our // map if we need it + mutex_lock(&iv_mutex); //iv_overridePtr is not threadsafe VPD::OverrideMap_t::iterator l_overItr = iv_overridePtr.find(l_recTarg); if( l_overItr != iv_overridePtr.end() ) { + l_overridePtr = l_overItr->second; + // If we are using an override, we can't write to it if( l_overridePtr != nullptr ) { @@ -2174,9 +2182,13 @@ errlHndl_t IpVpdFacade::writeKeyword ( const char * i_keywordName, l_kw), ERRORLOG::ErrlEntry::ADD_SW_CALLOUT ); err->collectTrace( "VPD", 256 ); + + mutex_unlock(&iv_mutex); + break; } } + mutex_unlock(&iv_mutex); } // Write the data @@ -2407,7 +2419,9 @@ errlHndl_t IpVpdFacade::checkForRecordOverride( const char* i_record, TRACDCOMP( g_trac_vpd, "No override for %s on %.8X", i_record, TARGETING::get_huid(i_target) ); VPD::RecordTargetPair_t l_recTarg = VPD::makeRecordTargetPair(i_record,i_target); + mutex_lock(&iv_mutex); //iv_overridePtr is not threadsafe iv_overridePtr[l_recTarg] = nullptr; + mutex_unlock(&iv_mutex); return nullptr; } @@ -2488,7 +2502,9 @@ errlHndl_t IpVpdFacade::getMEMDFromPNOR( input_args_t i_recKw, TRACFCOMP(g_trac_vpd,"Optional MEMD section not found in PNOR."); delete l_errl; l_errl = nullptr; + mutex_lock(&iv_mutex); //iv_overridePtr is not threadsafe iv_overridePtr[l_recTarg] = nullptr; + mutex_unlock(&iv_mutex); break; } @@ -2512,7 +2528,9 @@ errlHndl_t IpVpdFacade::getMEMDFromPNOR( input_args_t i_recKw, if( !l_valid_memd ) { TRACFCOMP(g_trac_vpd,"MEMD is not valid, ignoring it"); + mutex_lock(&iv_mutex); //iv_overridePtr is not threadsafe iv_overridePtr[l_recTarg] = nullptr; + mutex_unlock(&iv_mutex); break; } @@ -2554,7 +2572,9 @@ errlHndl_t IpVpdFacade::getMEMDFromPNOR( input_args_t i_recKw, // Set the ptr in the map to allow the lookups inside // IpVpdFacade to work + mutex_lock(&iv_mutex); //iv_overridePtr is not threadsafe iv_overridePtr[l_recTarg] = l_memd_vaddr + l_memd_offset; + mutex_unlock(&iv_mutex); uint32_t l_memd_vm = 0; l_errl = retrieveKeyword( l_keyword, l_record, @@ -2599,7 +2619,9 @@ errlHndl_t IpVpdFacade::getMEMDFromPNOR( input_args_t i_recKw, // If we did not find a match, set our map back to a nullptr if( !l_found_match ) { + mutex_lock(&iv_mutex); //iv_overridePtr is not threadsafe iv_overridePtr[l_recTarg] = nullptr; + mutex_unlock(&iv_mutex); } } while(0); |

