Skip to content

Commit

Permalink
Initialize backup TPM in MPIPL
Browse files Browse the repository at this point in the history
Update the boot flow to call the istep to initialize the backup TPM during an
MPIPL and carry over the backup present/functional state as they were from
runtime, prior to the MPIPL.

Change-Id: Ic402e37cf2f465686770ff22d4f2296332b0f3f7
CQ: SW456951
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/75163
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: Ilya Smirnov <ismirno@us.ibm.com>
Reviewed-by: Michael Baiocchi <mbaiocch@us.ibm.com>
Reviewed-by: Matthew Raybuck <matthew.raybuck@ibm.com>
Reviewed-by: William G. Hoffa <wghoffa@us.ibm.com>
  • Loading branch information
Nick Bofferding authored and wghoffa committed Apr 1, 2019
1 parent de2312a commit ca03643
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 49 deletions.
2 changes: 1 addition & 1 deletion src/include/usr/isteps/istep10list.H
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ const TaskInfo g_istep10[] = {
{
ISTEPNAME(10,14,"host_update_redundant_tpm"),
ISTEP_10::call_host_update_redundant_tpm,
{ START_FN, EXT_IMAGE, NORMAL_IPL_OP, true }
{ START_FN, EXT_IMAGE, NORMAL_IPL_OP | MPIPL_OP, true }
},
};

Expand Down
18 changes: 18 additions & 0 deletions src/usr/secureboot/trusted/base/trustedboot_base.C
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,24 @@ void getTPMs(
TARGETING::TYPE_TPM,
(i_filter == TPM_FILTER::ALL_IN_BLUEPRINT) ? false : true);

if(i_filter == TPM_FILTER::ALL_FUNCTIONAL)
{
// From functional TPMs, remove any TPMs that are not actually
// initialized. This prevents Hostboot from using the backup TPM
// in an MPIPL when it's considered "functional" but hasn't been
// initialized yet.
o_tpmList.erase(
std::remove_if(
o_tpmList.begin(),
o_tpmList.end(),
[](TARGETING::Target* i_pTpm)
{
return !i_pTpm->getAttr<
TARGETING::ATTR_HB_TPM_INIT_ATTEMPTED>();
}),
o_tpmList.end());
}

TRACUCOMP(g_trac_trustedboot,EXIT_MRK "getTPMs(): Found %d TPMs",
o_tpmList.size());
}
Expand Down
83 changes: 35 additions & 48 deletions src/usr/secureboot/trusted/trustedboot.C
Original file line number Diff line number Diff line change
Expand Up @@ -406,39 +406,6 @@ void* host_update_master_tpm( void *io_pArgs )
"Backup TPM unavailable "
"since it's not in the system blueprint.");
}
else
{
auto l_backupHwasState = pBackupTpm->getAttr<
TARGETING::ATTR_HWAS_STATE>();
TPMDD::tpm_info_t tpmInfo;
memset(&tpmInfo, 0, sizeof(tpmInfo));
errlHndl_t tmpErr = TPMDD::tpmReadAttributes(
pBackupTpm,
tpmInfo,
TPM_LOCALITY_0);
if (nullptr != tmpErr || !tpmInfo.tpmEnabled ||
(l_backupHwasState.functional && l_backupHwasState.present))
// If the backup state is functional and present then we are
// in MPIPL scenario and we need to reset the states
{
TRACFCOMP( g_trac_trustedboot,INFO_MRK
"host_update_master_tpm() "
"Marking backup TPM unavailable until "
"powerbus is available.");

l_backupHwasState.present = false;
l_backupHwasState.functional = false;
pBackupTpm->setAttr<
TARGETING::ATTR_HWAS_STATE>(l_backupHwasState);

if (nullptr != tmpErr)
{
// Ignore attribute read failure
delete tmpErr;
tmpErr = nullptr;
}
}
}

} while ( 0 );

Expand Down Expand Up @@ -1411,26 +1378,46 @@ void doInitBackupTpm()
TARGETING::ATTR_HWAS_STATE>();
// Presence-detect the secondary TPM
TARGETING::TargetHandleList l_targetList;
l_targetList.push_back(l_backupTpm);
l_errl = HWAS::platPresenceDetect(l_targetList);
if(l_errl)
{
errlCommit(l_errl, SECURE_COMP_ID);
break;
}

// The TPM target would have been deleted from the list if it's
// not present.
if(l_targetList.size())
TARGETING::Target* pSysTarget = nullptr;
TARGETING::targetService().getTopLevelTarget(pSysTarget);
assert(pSysTarget, "doInitBackupTpm(): System target was nullptr");
const auto mpipl = pSysTarget->getAttr<
TARGETING::ATTR_IS_MPIPL_HB>();
if(mpipl)
{
l_backupHwasState.present = true;
l_backupTpm->setAttr<TARGETING::ATTR_HWAS_STATE>(l_backupHwasState);
// If previously determined not to be available, nothing to do
if( (!l_backupHwasState.present)
|| (!l_backupHwasState.functional) )
{
break;
}
}
else
{
l_backupHwasState.present = false;
l_backupTpm->setAttr<TARGETING::ATTR_HWAS_STATE>(l_backupHwasState);
break;
l_targetList.push_back(l_backupTpm);
l_errl = HWAS::platPresenceDetect(l_targetList);
if(l_errl)
{
errlCommit(l_errl, SECURE_COMP_ID);
break;
}

// The TPM target would have been deleted from the list if it's
// not present.
if(l_targetList.size())
{
l_backupHwasState.present = true;
l_backupTpm->setAttr<TARGETING::ATTR_HWAS_STATE>(
l_backupHwasState);
}
else
{
l_backupHwasState.present = false;
l_backupTpm->setAttr<TARGETING::ATTR_HWAS_STATE>(
l_backupHwasState);
break;
}
}

mutex_lock(l_backupTpm->getHbMutexAttr<TARGETING::ATTR_HB_TPM_MUTEX>());
Expand Down

0 comments on commit ca03643

Please sign in to comment.