diff options
author | Chris Engel <cjengel@us.ibm.com> | 2016-04-13 13:32:43 -0500 |
---|---|---|
committer | William G. Hoffa <wghoffa@us.ibm.com> | 2016-07-27 12:22:07 -0400 |
commit | 3d565d0fd7f4f05803e53ab7274008fa448030f6 (patch) | |
tree | fd6ef511ac6281f1c041dc11956b934ffe43db12 /src/usr/secureboot/trusted/trustedboot.C | |
parent | c7ba6555103fb93d5c23b5b9faaff789098b93eb (diff) | |
download | talos-hostboot-3d565d0fd7f4f05803e53ab7274008fa448030f6.tar.gz talos-hostboot-3d565d0fd7f4f05803e53ab7274008fa448030f6.zip |
Support for TPM Required attribute to allow system to IPL without a TPM
Change-Id: I53e841036dfff75c6ed7d04ee55292b1285a6bee
RTC: 125287
ForwardPort: yes
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/27454
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Reviewed-by: Christopher J. Engel <cjengel@us.ibm.com>
Reviewed-by: William G. Hoffa <wghoffa@us.ibm.com>
Diffstat (limited to 'src/usr/secureboot/trusted/trustedboot.C')
-rw-r--r-- | src/usr/secureboot/trusted/trustedboot.C | 156 |
1 files changed, 112 insertions, 44 deletions
diff --git a/src/usr/secureboot/trusted/trustedboot.C b/src/usr/secureboot/trusted/trustedboot.C index 096bc1c57..06924a330 100644 --- a/src/usr/secureboot/trusted/trustedboot.C +++ b/src/usr/secureboot/trusted/trustedboot.C @@ -39,6 +39,7 @@ #include <errl/errludtarget.H> #include <errl/errludstring.H> #include <targeting/common/targetservice.H> +#include <secureboot/service.H> #include <secureboot/trustedbootif.H> #include <secureboot/trustedboot_reasoncodes.H> #include <sys/mmio.h> @@ -182,6 +183,8 @@ void* host_update_master_tpm( void *io_pArgs ) } else { + // TPM doesn't exist in the system + systemTpms.tpm[TPM_MASTER_INDEX].initAttempted = true; systemTpms.tpm[TPM_MASTER_INDEX].available = false; } @@ -209,43 +212,48 @@ void* host_update_master_tpm( void *io_pArgs ) TRACFCOMP( g_trac_trustedboot, "Master TPM Existence Fail"); - /*@ - * @errortype - * @reasoncode RC_TPM_EXISTENCE_FAIL - * @severity ERRL_SEV_UNRECOVERABLE - * @moduleid MOD_HOST_UPDATE_MASTER_TPM - * @userdata1 node - * @userdata2 0 - * @devdesc No TPMs found in system. - */ - err = new ERRORLOG::ErrlEntry( ERRORLOG::ERRL_SEV_UNRECOVERABLE, - MOD_HOST_UPDATE_MASTER_TPM, - RC_TPM_EXISTENCE_FAIL, - TARGETING::get_huid(nodeTarget), - 0, - true /*Add HB SW Callout*/ ); + systemTpms.failedTpmsPosted = true; + if (isTpmRequired()) + { + /*@ + * @errortype + * @reasoncode RC_TPM_EXISTENCE_FAIL + * @severity ERRL_SEV_UNRECOVERABLE + * @moduleid MOD_HOST_UPDATE_MASTER_TPM + * @userdata1 node + * @userdata2 0 + * @devdesc No TPMs found in system. + */ + err = new ERRORLOG::ErrlEntry( ERRORLOG::ERRL_SEV_UNRECOVERABLE, + MOD_HOST_UPDATE_MASTER_TPM, + RC_TPM_EXISTENCE_FAIL, + TARGETING::get_huid(nodeTarget), + 0, + true /*Add HB SW Callout*/ ); + + err->collectTrace( SECURE_COMP_NAME ); + } - err->collectTrace( SECURE_COMP_NAME ); - break; } // Lastly we will check on the backup TPM and see if it is enabled // in the attributes at least TPMDD::tpm_info_t tpmInfo; tpmInfo.chip = TPMDD::TPM_BACKUP; - err = TPMDD::tpmReadAttributes(nodeTarget, tpmInfo); - if (NULL != err) + errlHndl_t tmpErr = TPMDD::tpmReadAttributes(nodeTarget, tpmInfo); + if (NULL != tmpErr) { // We don't want to log this error we will just assume // the backup doesn't exist - delete err; - err = NULL; + delete tmpErr; + tmpErr = NULL; TRACUCOMP( g_trac_trustedboot, "host_update_master_tpm() tgt=0x%X " - "Marking backup TPM unavailable due to attribute fail", + "Marking backup TPM unavailable " + "due to attribute fail", TARGETING::get_huid(nodeTarget)); systemTpms.tpm[TPM_BACKUP_INDEX].available = false; - break; + systemTpms.tpm[TPM_BACKUP_INDEX].initAttempted = true; } else if (!tpmInfo.tpmEnabled) { @@ -254,6 +262,7 @@ void* host_update_master_tpm( void *io_pArgs ) "Marking backup TPM unavailable", TARGETING::get_huid(nodeTarget)); systemTpms.tpm[TPM_BACKUP_INDEX].available = false; + systemTpms.tpm[TPM_BACKUP_INDEX].initAttempted = true; } } while ( 0 ); @@ -275,6 +284,19 @@ void* host_update_master_tpm( void *io_pArgs ) err = tpmLogConfigEntries(systemTpms.tpm[TPM_MASTER_INDEX]); } + TRACUCOMP( g_trac_trustedboot, + EXIT_MRK"host_update_master_tpm() - " + "Master A:%d F:%d I:%d", + systemTpms.tpm[TPM_MASTER_INDEX].available, + systemTpms.tpm[TPM_MASTER_INDEX].failed, + systemTpms.tpm[TPM_MASTER_INDEX].initAttempted); + TRACUCOMP( g_trac_trustedboot, + EXIT_MRK"host_update_master_tpm() - " + "Backup A:%d F:%d I:%d", + systemTpms.tpm[TPM_BACKUP_INDEX].available, + systemTpms.tpm[TPM_BACKUP_INDEX].failed, + systemTpms.tpm[TPM_BACKUP_INDEX].initAttempted); + TRACDCOMP( g_trac_trustedboot, EXIT_MRK"host_update_master_tpm() - %s", ((NULL == err) ? "No Error" : "With Error") ); @@ -483,6 +505,27 @@ errlHndl_t tpmLogConfigEntries(TRUSTEDBOOT::TpmTarget & io_target) break; } + // TPM Required + memset(l_digest, 0, sizeof(uint64_t)); + bool l_tpmRequired = isTpmRequired(); + l_digest[0] = static_cast<uint8_t>(l_tpmRequired); + l_err = pcrExtend(PCR_1, l_digest, sizeof(l_tpmRequired), + "Tpm Required"); + if (l_err) + { + break; + } + + // HW Key Hash + sha2_hash_t l_hw_key_hash; + SECUREBOOT::getHwHashKeys(l_hw_key_hash); + l_err = pcrExtend(PCR_1, l_hw_key_hash, + sizeof(sha2_hash_t),"HW KEY HASH"); + if (l_err) + { + break; + } + } while(0); return l_err; @@ -559,7 +602,6 @@ void pcrExtendSingleTpm(TpmTarget & io_target, // Log this failure errlCommit(err, SECURE_COMP_ID); - err = NULL; } if (unlock) @@ -598,34 +640,41 @@ errlHndl_t tpmVerifyFunctionalTpmExists() } } - if (!foundFunctional) + if (!foundFunctional && !systemTpms.failedTpmsPosted) { + systemTpms.failedTpmsPosted = true; TRACFCOMP( g_trac_trustedboot, "NO FUNCTIONAL TPM FOUND"); + if (isTpmRequired()) + { + /*@ + * @errortype + * @reasoncode RC_TPM_NOFUNCTIONALTPM_FAIL + * @severity ERRL_SEV_UNRECOVERABLE + * @moduleid MOD_TPM_VERIFYFUNCTIONAL + * @userdata1 0 + * @userdata2 0 + * @devdesc No functional TPMs exist in the system + */ + err = new ERRORLOG::ErrlEntry( ERRORLOG::ERRL_SEV_UNRECOVERABLE, + MOD_TPM_VERIFYFUNCTIONAL, + RC_TPM_NOFUNCTIONALTPM_FAIL, + 0, 0, + true /*Add HB SW Callout*/ ); - /*@ - * @errortype - * @reasoncode RC_TPM_NOFUNCTIONALTPM_FAIL - * @severity ERRL_SEV_UNRECOVERABLE - * @moduleid MOD_TPM_VERIFYFUNCTIONAL - * @userdata1 0 - * @userdata2 0 - * @devdesc No functional TPMs exist in the system - */ - err = new ERRORLOG::ErrlEntry( ERRORLOG::ERRL_SEV_UNRECOVERABLE, - MOD_TPM_VERIFYFUNCTIONAL, - RC_TPM_NOFUNCTIONALTPM_FAIL, - 0, 0, - true /*Add HB SW Callout*/ ); - - err->collectTrace( SECURE_COMP_NAME ); + err->collectTrace( SECURE_COMP_NAME ); + } + else + { + TRACUCOMP( g_trac_trustedboot, + "No functional TPM's found but TPM not Required"); + } } return err; } - void* tpmDaemon(void* unused) { bool shutdownPending = false; @@ -659,6 +708,10 @@ void* tpmDaemon(void* unused) case TRUSTEDBOOT::MSG_TYPE_SHUTDOWN: { shutdownPending = true; + + // Un-register message queue from the shutdown + INITSERVICE::unregisterShutdownEvent(systemTpms.msgQ); + } break; case TRUSTEDBOOT::MSG_TYPE_PCREXTEND: @@ -746,10 +799,25 @@ void* tpmDaemon(void* unused) break; } } - // Daemon is shutting down we can't handle any requests after this - systemTpms.tpmDaemonShutdown = true; + TRACUCOMP( g_trac_trustedboot, EXIT_MRK "TpmDaemon Thread Terminate"); return NULL; } +bool isTpmRequired() +{ + + TARGETING::Target* pTopLevel = NULL; + (void)TARGETING::targetService().getTopLevelTarget(pTopLevel); + assert(pTopLevel != NULL, "Unable to get top level target"); + + TARGETING::ATTR_TPM_REQUIRED_type tpmRequired = + pTopLevel->getAttr<TARGETING::ATTR_TPM_REQUIRED>(); + TRACFCOMP( g_trac_trustedboot, + "Tpm Required: %s",(tpmRequired ? "Yes" : "No")); + + return tpmRequired; +} + + } // end TRUSTEDBOOT |