Skip to content

Commit

Permalink
Reset Host-mode Processor I2C Masters connected to the TPMs
Browse files Browse the repository at this point in the history
This commit resets the I2C buses connected to the TPMs early in
the IPL since the FSP can't do the reset for us as they lack a
FSI I2C connection to the TPMs.

Change-Id: I4b4893da447f3c567c04a8d0c2b647f2927ec0ab
RTC:188956
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/56188
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: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
  • Loading branch information
mabaiocchi authored and dcrowell77 committed Mar 30, 2018
1 parent bca54fb commit 55f0053
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 35 deletions.
2 changes: 2 additions & 0 deletions src/include/usr/i2c/i2cif.H
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ enum i2cEngineSelect : uint8_t
I2C_ENGINE_SELECT_ONLY_1 |
I2C_ENGINE_SELECT_ONLY_2 |
I2C_ENGINE_SELECT_ONLY_3,

I2C_ENGINE_SELECT_NONE = 0x00,
};

/**
Expand Down
10 changes: 6 additions & 4 deletions src/usr/i2c/i2c.C
Original file line number Diff line number Diff line change
Expand Up @@ -3346,16 +3346,18 @@ errlHndl_t i2cProcessActiveMasters ( i2cProcessType i_processType,
{
TRACUCOMP( g_trac_i2c,INFO_MRK
"i2cProcessActiveMasters: skipping tgt=0x%X "
"due to FSI::isSlavePresent returned=%d",
TARGETING::get_huid(tgt), check );
"due to FSI::isSlavePresent returned=%s (%d)",
TARGETING::get_huid(tgt),
check ? "true" : "false", check );
continue;
}
else
{
TRACUCOMP( g_trac_i2c,INFO_MRK
"i2cProcessActiveMasters: keeping tgt=0x%X due "
"to FSI::isSlavePresent returned=%d",
TARGETING::get_huid(tgt), check );
"to FSI::isSlavePresent returned=%s (%d)",
TARGETING::get_huid(tgt),
check ? "true" : "false", check );
}
}

Expand Down
91 changes: 88 additions & 3 deletions src/usr/isteps/istep06/host_init_fsi.C
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2015,2016 */
/* Contributors Listed Below - COPYRIGHT 2015,2018 */
/* [+] International Business Machines Corp. */
/* */
/* */
Expand All @@ -30,14 +30,84 @@
#include <errl/errlmanager.H>
#include <fsi/fsiif.H>
#include <i2c/i2cif.H>
#include <i2c/tpmddif.H>
#include <initservice/taskargs.H>
#include <initservice/isteps_trace.H>
#include <initservice/initserviceif.H>
#include <isteps/hwpisteperror.H>
#include <attributeenums.H>
#include <secureboot/trustedbootif.H>
#include <config.h>

//Targeting
#include <targeting/common/commontargeting.H>
#include <targeting/common/util.H>
#include <targeting/common/utilFilter.H>
#include <targeting/common/target.H>

using namespace TARGETING;
using namespace I2C;
using namespace TRUSTEDBOOT;

namespace ISTEP_06
{

/* @brief Find Processor I2C Engines Connected to TPMs
*
* This helper function loops through all of the TPMs in the system
* blueprint and finds all of the Processors that serve as their I2C
* Masters. It then keeps track of which processor I2C engine(s) are
* used.
*
* @return i2cEngineSelect - bit-wise enum indicating which processor engine(s)
* were found
*/
i2cEngineSelect find_proc_i2c_engines_for_tpm ( void )
{
int engineSelect = static_cast<int>(I2C_ENGINE_SELECT_NONE);

#ifdef CONFIG_TPMDD
// Get all TPMs to setup our array
TargetHandleList tpmList;
getTPMs(tpmList,TPM_FILTER::ALL_IN_BLUEPRINT);

TPMDD::tpm_info_t tpmData;
for (auto tpm : tpmList)
{
memset(&tpmData, 0, sizeof(tpmData));
errlHndl_t readErr = tpmReadAttributes(tpm,
tpmData,
TPMDD::TPM_LOCALITY_0);

if (nullptr != readErr)
{
// We are just looking for configured TPMs here
// so we ignore any errors
delete readErr;
readErr = nullptr;
}
else
{
// If TPM is connected to a processor then keep track
// of what engine needs to be reset
if (tpmData.i2cTarget->getAttr<ATTR_TYPE>() == TYPE_PROC)
{
engineSelect |= static_cast<int>(i2cEngineToEngineSelect(tpmData.engine));
}
}
}

// There should only be 1 such bus per processor. So if we found multiple
// engines then we know that there are different proc/engine combinations
// and we'd need a I2C reset intferace to support that. This check here
// makes sure we add that support when its necessary.
assert(__builtin_popcount(engineSelect)==1, "find_proc_i2c_engines_for_tpm: Only one engine should be found");

#endif
return static_cast<i2cEngineSelect>(engineSelect);
}


void* host_init_fsi( void *io_pArgs )
{
errlHndl_t l_err = NULL;
Expand All @@ -55,10 +125,25 @@ void* host_init_fsi( void *io_pArgs )
break;
}

// Only reset the I2C Masters if FSP is not running
// Reset all I2C Masters if FSP is not running
if ( !INITSERVICE::spBaseServicesEnabled() )
{
l_err = I2C::i2cResetActiveMasters(I2C::I2C_ALL, false);
l_err = i2cResetActiveMasters(I2C_ALL, false);
if (l_err)
{
// Commit this error
errlCommit( l_err, ISTEP_COMP_ID );
}
}
// FSP cannot access I2C buses where the TPMs and PCIe Hot Plug
// devices are due to a lack of a FSI connection to this bus.
// Therefore, reset all host-mode I2C engines connected to these buses
else
{
l_err = i2cResetActiveMasters(
I2C_PROC_HOST,
false,
find_proc_i2c_engines_for_tpm());
if (l_err)
{
// Commit this error
Expand Down
28 changes: 0 additions & 28 deletions src/usr/secureboot/trusted/trustedboot.C
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
#include <config.h>
#include <devicefw/driverif.H>
#include <i2c/tpmddif.H>
#include <i2c/i2cif.H>
#include "trustedboot.H"
#include "trustedTypes.H"
#include "trustedbootCmds.H"
Expand Down Expand Up @@ -275,33 +274,6 @@ void* host_update_master_tpm( void *io_pArgs )
if( hwasState.present
&& hwasState.functional)
{
// If MPIPL do I2C Reset to any processor's I2C engine that is
// driving the TPMs
TARGETING::Target* sys = nullptr;
(void) tS.getTopLevelTarget( sys );
assert(sys, "host_update_master_tpm() system target is nullptr");

if (sys->getAttr<TARGETING::ATTR_IS_MPIPL_HB>())
{
err = I2C::i2cResetActiveMasters(
I2C::I2C_PROC_HOST,
true,
I2C::i2cEngineToEngineSelect(tpmData.engine));

if (nullptr != err)
{
// Commit log and continue
TRACFCOMP(g_trac_trustedboot,ERR_MRK
"host_update_master_tpm(): Committing I2C "
"Reset Fail plid=0x%X but continuing",
err->plid());
err->collectTrace(TRBOOT_COMP_NAME);
errlCommit(err, TRBOOT_COMP_ID);
err = nullptr;
}

}

// API call will set TPM init attempted appropriately
tpmInitialize(pPrimaryTpm);
}
Expand Down

0 comments on commit 55f0053

Please sign in to comment.