diff options
Diffstat (limited to 'src/usr/pnor')
-rw-r--r-- | src/usr/pnor/pnor_common.C | 52 | ||||
-rw-r--r-- | src/usr/pnor/pnor_common.H | 13 |
2 files changed, 64 insertions, 1 deletions
diff --git a/src/usr/pnor/pnor_common.C b/src/usr/pnor/pnor_common.C index d4dd7f498..22841b20c 100644 --- a/src/usr/pnor/pnor_common.C +++ b/src/usr/pnor/pnor_common.C @@ -34,6 +34,8 @@ #include <util/align.H> #include <errl/errlmanager.H> #include <config.h> // @FIXME RTC 132398 +#include <secureboot/trustedbootif.H> +#include <devicefw/driverif.H> // Trace definition trace_desc_t* g_trac_pnor = NULL; @@ -288,11 +290,26 @@ errlHndl_t PNOR::parseTOC( uint8_t* i_tocBuffer,SectionData_t * o_TOC) } - // TODO RTC:96009 handle version header w/secureboot if (o_TOC[l_secId].version == FFS_VERS_SHA512) { TRACFCOMP(g_trac_pnor, "PNOR::parseTOC: Incrementing" " Flash Address for SHA Header"); + uint32_t l_addr = o_TOC[l_secId].flashAddr; + size_t l_headerSize = 0; + if (o_TOC[l_secId].integrity == FFS_INTEG_ECC_PROTECT) + { + l_headerSize = PAGESIZE_PLUS_ECC; + } + else + { + l_headerSize = PAGESIZE; + } + l_errhdl = PNOR::extendHash(l_addr, l_headerSize, + cv_EYECATCHER[l_secId]); + if (l_errhdl) + { + break; + } } } for(int tmpId = 0; @@ -309,3 +326,36 @@ errlHndl_t PNOR::parseTOC( uint8_t* i_tocBuffer,SectionData_t * o_TOC) TRACUCOMP(g_trac_pnor, "< PNOR::parseTOC" ); return l_errhdl; } + +errlHndl_t PNOR::extendHash(uint64_t i_addr, size_t i_size, const char* i_name) +{ + errlHndl_t l_errhdl = NULL; + + do { + #ifndef __HOSTBOOT_RUNTIME + // Read data from the PNOR DD + uint8_t* l_buf = new uint8_t[i_size](); + TARGETING::Target* l_target = TARGETING::MASTER_PROCESSOR_CHIP_TARGET_SENTINEL; + l_errhdl = DeviceFW::deviceRead(l_target, l_buf, i_size, + DEVICE_PNOR_ADDRESS(0,i_addr)); + if (l_errhdl) + { + break; + } + + SHA512_t l_hash = {0}; + SECUREBOOT::hashBlob(l_buf, i_size, l_hash); + l_errhdl = TRUSTEDBOOT::pcrExtend(TRUSTEDBOOT::PCR_0, l_hash, + sizeof(SHA512_t), i_name); + delete[] l_buf; + + if (l_errhdl) + { + break; + } + #endif + } while(0); + + return l_errhdl; +} + diff --git a/src/usr/pnor/pnor_common.H b/src/usr/pnor/pnor_common.H index 3bf6022d7..e8b6bd4f8 100644 --- a/src/usr/pnor/pnor_common.H +++ b/src/usr/pnor/pnor_common.H @@ -28,6 +28,7 @@ #include <pnor/pnorif.H> #include "pnor_utils.H" #include "ffs.h" +#include <secureboot/service.H> /************************************************************ * Provides common functions for Hostboot IPL and runtime @@ -72,6 +73,18 @@ namespace PNOR { void physicalToMmioOffset(uint64_t i_hbbAddress, uint64_t& o_mmioOffset); + /** + * @brief Reads version header of section, hashes it, and extends to tpm + * buffer list. + * + * @parm i_addr Offset into flash to read + * @parm i_size Number of bytes to read + * @parm i_name Name of PNOR section + * + * @return Error from operation + */ + errlHndl_t extendHash(uint64_t i_addr, size_t i_size, const char* i_name); + } #endif |