diff options
Diffstat (limited to 'src/usr/pnor')
-rw-r--r-- | src/usr/pnor/ast_mboxdd.C | 3 | ||||
-rw-r--r-- | src/usr/pnor/ast_mboxdd.H | 3 | ||||
-rw-r--r-- | src/usr/pnor/norflash.H | 3 | ||||
-rw-r--r-- | src/usr/pnor/pnor_common.C | 90 | ||||
-rw-r--r-- | src/usr/pnor/pnor_ipmidd.C | 3 | ||||
-rw-r--r-- | src/usr/pnor/pnor_ipmidd.H | 3 | ||||
-rw-r--r-- | src/usr/pnor/pnor_mboxdd.C | 3 | ||||
-rw-r--r-- | src/usr/pnor/pnor_mboxdd.H | 3 | ||||
-rw-r--r-- | src/usr/pnor/pnor_sfcdd.C | 5 | ||||
-rw-r--r-- | src/usr/pnor/pnor_sfcdd.H | 3 | ||||
-rw-r--r-- | src/usr/pnor/pnor_utils.C | 31 | ||||
-rw-r--r-- | src/usr/pnor/pnor_utils.H | 3 | ||||
-rw-r--r-- | src/usr/pnor/pnorrp.C | 22 | ||||
-rw-r--r-- | src/usr/pnor/pnorrp.H | 1 | ||||
-rw-r--r-- | src/usr/pnor/runtime/rt_pnor.C | 7 | ||||
-rw-r--r-- | src/usr/pnor/sfc_ast2400.H | 3 | ||||
-rw-r--r-- | src/usr/pnor/sfc_ast2500.H | 3 | ||||
-rw-r--r-- | src/usr/pnor/sfc_ast2X00.H | 3 | ||||
-rw-r--r-- | src/usr/pnor/spnorrp.C | 218 | ||||
-rw-r--r-- | src/usr/pnor/spnorrp.H | 14 | ||||
-rw-r--r-- | src/usr/pnor/test/pnorrptest.H | 7 | ||||
-rw-r--r-- | src/usr/pnor/test/pnorutilsTest.H | 43 |
22 files changed, 325 insertions, 149 deletions
diff --git a/src/usr/pnor/ast_mboxdd.C b/src/usr/pnor/ast_mboxdd.C index 5b6e58300..9a7c45e9b 100644 --- a/src/usr/pnor/ast_mboxdd.C +++ b/src/usr/pnor/ast_mboxdd.C @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2011,2018 */ +/* Contributors Listed Below - COPYRIGHT 2011,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -51,7 +51,6 @@ #include <initservice/initserviceif.H> #include <util/align.H> #include <lpc/lpcif.H> -#include <config.h> // Initialized in pnorrp.C extern trace_desc_t* g_trac_pnor; diff --git a/src/usr/pnor/ast_mboxdd.H b/src/usr/pnor/ast_mboxdd.H index 2d1aa48ad..44c745cab 100644 --- a/src/usr/pnor/ast_mboxdd.H +++ b/src/usr/pnor/ast_mboxdd.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2011,2017 */ +/* Contributors Listed Below - COPYRIGHT 2011,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -26,7 +26,6 @@ #define __AST_MBOXDD_H #include <limits.h> -#include <config.h> /** @file ast_mboxdd.H * @brief Provides the interfaces Aspeed MBOX hardware diff --git a/src/usr/pnor/norflash.H b/src/usr/pnor/norflash.H index 29ac2f8f0..e7e61f389 100644 --- a/src/usr/pnor/norflash.H +++ b/src/usr/pnor/norflash.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2014,2016 */ +/* Contributors Listed Below - COPYRIGHT 2014,2019 */ /* [+] Google Inc. */ /* [+] International Business Machines Corp. */ /* */ @@ -25,7 +25,6 @@ /* IBM_PROLOG_END_TAG */ #ifndef __PNOR_NORFLASH_H #define __PNOR_NORFLASH_H -#include <config.h> #include <errl/errlentry.H> class SfcDD; diff --git a/src/usr/pnor/pnor_common.C b/src/usr/pnor/pnor_common.C index 3b642a6e6..41f17ff7e 100644 --- a/src/usr/pnor/pnor_common.C +++ b/src/usr/pnor/pnor_common.C @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2014,2018 */ +/* Contributors Listed Below - COPYRIGHT 2014,2019 */ /* [+] Google Inc. */ /* [+] International Business Machines Corp. */ /* */ @@ -34,7 +34,6 @@ #include <initservice/initserviceif.H> #include <util/align.H> #include <errl/errlmanager.H> -#include <config.h> // @FIXME RTC 132398 #include <secureboot/trustedbootif.H> #include <devicefw/driverif.H> @@ -144,12 +143,16 @@ errlHndl_t PNOR::parseTOC( uint8_t* i_tocBuffer,SectionData_t * o_TOC, // Zero out my table PNOR::initializeSections(o_TOC); - uint32_t l_errCode = 0; - ffs_hdr* l_ffs_hdr = NULL; + uint32_t l_errCode(0); + ffs_hdr* l_ffs_hdr(reinterpret_cast<ffs_hdr*>(i_tocBuffer)); TRACDCOMP(g_trac_pnor, "PNOR::parseTOC verifying TOC"); + if (!l_ffs_hdr) + { + l_errCode = PNOR::BUFF_IS_NULL; + l_ffs_hdr = nullptr; + } - PNOR::checkForNullBuffer(i_tocBuffer, l_errCode, l_ffs_hdr); //Check if the buffer is null if(l_errCode != NO_ERROR) { @@ -160,16 +163,16 @@ errlHndl_t PNOR::parseTOC( uint8_t* i_tocBuffer,SectionData_t * o_TOC, "Null TOC Buffer found while checking TOC" " during pnor initialization"); /*@ - * @errortype - * @moduleid PNOR::MOD_PNORRP_READTOC - * @reasoncode PNOR::RC_NULL_TOC_BUFFER - * @userdata1 Address of toc buffer - * @userdata2 Error code - * @devdesc Expected buffer to have contents of TOC, - * instead was NULL - * @custdesc A problem occurred while reading - * Processor NOR flash partition table - */ + * @errortype + * @moduleid PNOR::MOD_PNORRP_READTOC + * @reasoncode PNOR::RC_NULL_TOC_BUFFER + * @userdata1 Address of toc buffer + * @userdata2 Error code + * @devdesc Expected buffer to have contents of TOC, + * instead was NULL + * @custdesc A problem occurred while reading + * Processor NOR flash partition table + */ l_errhdl = new ERRORLOG::ErrlEntry( ERRORLOG::ERRL_SEV_UNRECOVERABLE, PNOR::MOD_PNORRP_READTOC, @@ -197,15 +200,16 @@ errlHndl_t PNOR::parseTOC( uint8_t* i_tocBuffer,SectionData_t * o_TOC, "PNOR::parseTOC Found checksum error in TOC's header" " during pnor initialization"); - /* @errortype - * @moduleid PNOR::MOD_PNORRP_READTOC - * @reasoncode PNOR::RC_TOC_HDR_CHECKSUM_ERR - * @userdata1 Address of toc buffer - * @userdata2 Error Code - * @devdesc Hdr of TOC of PNOR failed checksum - * @custdesc A problem occurred while reading - * Processor NOR flash partition table - */ + /*@ + * @errortype + * @moduleid PNOR::MOD_PNORRP_READTOC + * @reasoncode PNOR::RC_TOC_HDR_CHECKSUM_ERR + * @userdata1 Address of toc buffer + * @userdata2 Error Code + * @devdesc Hdr of TOC of PNOR failed checksum + * @custdesc A problem occurred while reading + * Processor NOR flash partition table + */ l_errhdl = new ERRORLOG::ErrlEntry( ERRORLOG::ERRL_SEV_UNRECOVERABLE, PNOR::MOD_PNORRP_READTOC, @@ -230,15 +234,16 @@ errlHndl_t PNOR::parseTOC( uint8_t* i_tocBuffer,SectionData_t * o_TOC, assert(i_pnorInitialized, "PNOR::parseTOC Error found parsing hdr of TOC" " during pnor initialization"); - /* @errortype - * @moduleid PNOR::MOD_PNORRP_READTOC - * @reasoncode PNOR::RC_BAD_TOC_HEADER - * @userdata1 Address of toc buffer - * @userdata2 Error Code - * @devdesc Hdr of TOC of PNOR failed series of tests - * @custdesc A problem occurred while reading - * Processor NOR flash partition table - */ + /*@ + * @errortype + * @moduleid PNOR::MOD_PNORRP_READTOC + * @reasoncode PNOR::RC_BAD_TOC_HEADER + * @userdata1 Address of toc buffer + * @userdata2 Error Code + * @devdesc Hdr of TOC of PNOR failed series of tests + * @custdesc A problem occurred while reading + * Processor NOR flash partition table + */ l_errhdl = new ERRORLOG::ErrlEntry( ERRORLOG::ERRL_SEV_UNRECOVERABLE, PNOR::MOD_PNORRP_READTOC, @@ -276,15 +281,16 @@ errlHndl_t PNOR::parseTOC( uint8_t* i_tocBuffer,SectionData_t * o_TOC, "PNOR::parseTOC parseEntries returned an error code" " during pnor initialization"); - /* @errortype - * @moduleid PNOR::MOD_PNORRP_READTOC - * @reasoncode PNOR::RC_PNOR_PARSE_ENTRIES_ERR - * @userdata1 Address of toc buffer - * @userdata2 Error Code - * @devdesc Error while parsing pnor TOC entries - * @custdesc A problem occurred while reading - * Processor NOR flash partition table - */ + /*@ + * @errortype + * @moduleid PNOR::MOD_PNORRP_READTOC + * @reasoncode PNOR::RC_PNOR_PARSE_ENTRIES_ERR + * @userdata1 Address of toc buffer + * @userdata2 Error Code + * @devdesc Error while parsing pnor TOC entries + * @custdesc A problem occurred while reading + * Processor NOR flash partition table + */ l_errhdl = new ERRORLOG::ErrlEntry( ERRORLOG::ERRL_SEV_UNRECOVERABLE, PNOR::MOD_PNORRP_READTOC, diff --git a/src/usr/pnor/pnor_ipmidd.C b/src/usr/pnor/pnor_ipmidd.C index 078195dad..43df5adfe 100644 --- a/src/usr/pnor/pnor_ipmidd.C +++ b/src/usr/pnor/pnor_ipmidd.C @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2018 */ +/* Contributors Listed Below - COPYRIGHT 2018,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -58,7 +58,6 @@ #include <initservice/initserviceif.H> #include <util/align.H> #include <lpc/lpcif.H> -#include <config.h> #include "sfcdd.H" #include <ipmi/ipmiif.H> diff --git a/src/usr/pnor/pnor_ipmidd.H b/src/usr/pnor/pnor_ipmidd.H index fc843db6a..5c99607fe 100644 --- a/src/usr/pnor/pnor_ipmidd.H +++ b/src/usr/pnor/pnor_ipmidd.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2018 */ +/* Contributors Listed Below - COPYRIGHT 2018,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -31,7 +31,6 @@ */ #include <limits.h> -#include <config.h> #include "pnorif.H" diff --git a/src/usr/pnor/pnor_mboxdd.C b/src/usr/pnor/pnor_mboxdd.C index a156ffb8f..92819143d 100644 --- a/src/usr/pnor/pnor_mboxdd.C +++ b/src/usr/pnor/pnor_mboxdd.C @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2011,2018 */ +/* Contributors Listed Below - COPYRIGHT 2011,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -54,7 +54,6 @@ #include <initservice/initserviceif.H> #include <util/align.H> #include <lpc/lpcif.H> -#include <config.h> #include "sfcdd.H" // Initialized in pnorrp.C diff --git a/src/usr/pnor/pnor_mboxdd.H b/src/usr/pnor/pnor_mboxdd.H index 16105efe2..6095dce35 100644 --- a/src/usr/pnor/pnor_mboxdd.H +++ b/src/usr/pnor/pnor_mboxdd.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2011,2018 */ +/* Contributors Listed Below - COPYRIGHT 2011,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -26,7 +26,6 @@ #define __PNOR_MBOXDD_H #include <limits.h> -#include <config.h> #include "pnorif.H" namespace PNOR diff --git a/src/usr/pnor/pnor_sfcdd.C b/src/usr/pnor/pnor_sfcdd.C index fe3f0cbae..9acea977b 100644 --- a/src/usr/pnor/pnor_sfcdd.C +++ b/src/usr/pnor/pnor_sfcdd.C @@ -53,7 +53,6 @@ #include <initservice/initserviceif.H> #include <util/align.H> #include <lpc/lpcif.H> -#include <config.h> #include "sfcdd.H" /*****************************************************************************/ @@ -251,7 +250,7 @@ errlHndl_t PnorSfcDD::writeFlash(void* i_buffer, size_t& io_buflen, uint64_t i_address) { - TRACFCOMP(g_trac_pnor, ENTER_MRK"PnorSfcDD::writeFlash(i_address=0x%llx)> ", i_address); + TRACDCOMP(g_trac_pnor, ENTER_MRK"PnorSfcDD::writeFlash(i_address=0x%llx)> ", i_address); errlHndl_t l_err = NULL; do{ @@ -339,7 +338,7 @@ errlHndl_t PnorSfcDD::writeFlash(void* i_buffer, { io_buflen = 0; } - TRACFCOMP(g_trac_pnor,EXIT_MRK"PnorSfcDD::writeFlash(i_address=0x%llx)> io_buflen=%.8X", i_address, io_buflen); + TRACDCOMP(g_trac_pnor,EXIT_MRK"PnorSfcDD::writeFlash(i_address=0x%llx)> io_buflen=%.8X", i_address, io_buflen); return l_err; } diff --git a/src/usr/pnor/pnor_sfcdd.H b/src/usr/pnor/pnor_sfcdd.H index bfd3140a7..ba7f0aa0d 100644 --- a/src/usr/pnor/pnor_sfcdd.H +++ b/src/usr/pnor/pnor_sfcdd.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2011,2018 */ +/* Contributors Listed Below - COPYRIGHT 2011,2019 */ /* [+] Google Inc. */ /* [+] International Business Machines Corp. */ /* */ @@ -27,7 +27,6 @@ #define __PNOR_PNORDD_H #include <limits.h> -#include <config.h> #include <pnor/pnor_const.H> namespace PNOR { class UdPnorDDParms; } diff --git a/src/usr/pnor/pnor_utils.C b/src/usr/pnor/pnor_utils.C index cd7c9f98f..83ff90450 100644 --- a/src/usr/pnor/pnor_utils.C +++ b/src/usr/pnor/pnor_utils.C @@ -53,7 +53,6 @@ extern trace_desc_t* g_trac_pnor; #include "common/ffs_hb.H" #include <util/align.H> -#include <config.h> #include <securerom/ROM.H> #include <pnor/pnorif.H> @@ -110,30 +109,6 @@ void PNOR::initializeSections(PNOR::SectionData_t io_toc[NUM_SECTIONS]) } } - - -/** - * @brief Ensure the buffer is not NULL, if it is, then return - * the appropriate err code from the o_errCode param. - * if the buffer is not NULL then cast it to a ffs_hdr - * and return that out through the respective o_param - */ -void PNOR::checkForNullBuffer(uint8_t* i_tocBuffer, - uint32_t& o_errCode, - ffs_hdr*& o_ffs_hdr) -{ - if(!i_tocBuffer) - { - o_errCode |= BUFF_IS_NULL; - o_ffs_hdr = NULL; - } - else - { - o_ffs_hdr = (ffs_hdr*)i_tocBuffer; - } -} - - /** * @brief Perform a series of checks on the header of the table of contents * These checks include: looking for valid magic #, valid block size, @@ -369,6 +344,7 @@ bool PNOR::isEnforcedSecureSection(const uint32_t i_section) i_section == HB_DATA || i_section == SBE_IPL || i_section == PAYLOAD || + i_section == BOOTKERNEL || i_section == SBKT || i_section == OCC || i_section == HCODE || @@ -378,7 +354,8 @@ bool PNOR::isEnforcedSecureSection(const uint32_t i_section) i_section == MEMD || i_section == CAPP || i_section == TESTLOAD || - i_section == VERSION; + i_section == VERSION || + i_section == OCMBFW; #endif #else return false; @@ -415,7 +392,6 @@ const char * PNOR::SectionIdToString( uint32_t i_secIdIndex ) "part", /**< PNOR::TOC : Table of Contents */ #ifndef BOOTLOADER "HBI", /**< PNOR::HB_EXT_CODE : Hostboot Extended Image */ - "GLOBAL", /**< PNOR::GLOBAL_DATA : Global Data */ #endif "HBB", /**< PNOR::HB_BASE_CODE : Hostboot Base Image */ #ifndef BOOTLOADER @@ -451,6 +427,7 @@ const char * PNOR::SectionIdToString( uint32_t i_secIdIndex ) "HDAT", /**< PNOR::HDAT : Hdat Data */ "EECACHE", /**< PNOR::EECACHE : Cached data from various EEPROMs */ "OCMBFW", /**< PNOR::OCMBFW : OCMB image */ + "BOOTKERNEL", /**< PNOR::BOOTKERNEL : OPAL == petitboot,PHYP == PowerVM */ #endif }; diff --git a/src/usr/pnor/pnor_utils.H b/src/usr/pnor/pnor_utils.H index 53a402f97..d529c8c6c 100644 --- a/src/usr/pnor/pnor_utils.H +++ b/src/usr/pnor/pnor_utils.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2011,2018 */ +/* Contributors Listed Below - COPYRIGHT 2011,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -29,7 +29,6 @@ #include <pnor/pnor_const.H> #include "limits.h" #include "ffs.h" -#include <config.h> #ifndef BOOTLOADER #include <errl/errlentry.H> diff --git a/src/usr/pnor/pnorrp.C b/src/usr/pnor/pnorrp.C index af6ccf3fa..fa35be627 100644 --- a/src/usr/pnor/pnorrp.C +++ b/src/usr/pnor/pnorrp.C @@ -44,7 +44,6 @@ #include <kernel/console.H> #include <endian.h> #include <util/align.H> -#include <config.h> #include <pnor/pnorif.H> #include "pnor_common.H" #include <hwas/common/hwasCallout.H> @@ -214,6 +213,13 @@ void PnorRP::init( errlHndl_t &io_rtaskRetErrl ) #ifdef CONFIG_SECUREBOOT // Extend the base image to the TPM, regardless of how it was obtained l_errl = TRUSTEDBOOT::extendBaseImage(); + + // Cache the VERSION partition data for future use by the errl commit + // code. + if(!l_errl) + { + l_errl = ERRORLOG::cacheVersionPartition(); + } #endif #endif } @@ -522,6 +528,7 @@ errlHndl_t PnorRP::getSectionInfo( PNOR::SectionId i_section, #ifdef CONFIG_SECUREBOOT o_info.secure = iv_TOC[id].secure; + o_info.size = iv_TOC[id].size; o_info.secureProtectedPayloadSize = 0; // for non secure sections // the protected payload size // defaults to zero @@ -591,6 +598,17 @@ errlHndl_t PnorRP::getSectionInfo( PNOR::SectionId i_section, // was done previously in pnor_common.C o_info.size -= PAGESIZE; + // Need to change size to accommodate for hash table + if (l_conHdr.sb_flags()->sw_hash) + { + o_info.vaddr += payloadTextSize; + // Hash page table needs to use containerSize as the base + // and subtract off header and hash table size + o_info.size = l_conHdr.totalContainerSize() - PAGE_SIZE - + payloadTextSize; + o_info.hasHashTable = true; + } + // cache the value in SectionInfo struct so that we can // parse the container header less often o_info.secureProtectedPayloadSize = payloadTextSize; @@ -598,11 +616,11 @@ errlHndl_t PnorRP::getSectionInfo( PNOR::SectionId i_section, else #endif { + o_info.size = iv_TOC[id].size; o_info.vaddr = iv_TOC[id].virtAddr; } o_info.flashAddr = iv_TOC[id].flashAddr; - o_info.size = iv_TOC[id].size; o_info.eccProtected = ((iv_TOC[id].integrity & FFS_INTEG_ECC_PROTECT) != 0) ? true : false; o_info.sha512Version = ((iv_TOC[id].version & FFS_VERS_SHA512) diff --git a/src/usr/pnor/pnorrp.H b/src/usr/pnor/pnorrp.H index 1fe3c088c..650b62126 100644 --- a/src/usr/pnor/pnorrp.H +++ b/src/usr/pnor/pnorrp.H @@ -34,7 +34,6 @@ #include <map> #include "pnor_common.H" #include "ffs.h" -#include <config.h> #include "pnor_utils.H" /** diff --git a/src/usr/pnor/runtime/rt_pnor.C b/src/usr/pnor/runtime/rt_pnor.C index f3e969f2e..0d40a60c3 100644 --- a/src/usr/pnor/runtime/rt_pnor.C +++ b/src/usr/pnor/runtime/rt_pnor.C @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2014,2018 */ +/* Contributors Listed Below - COPYRIGHT 2014,2020 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -29,7 +29,7 @@ #include <initservice/taskargs.H> #include <initservice/initserviceif.H> -#include <runtime/rt_targeting.H> +#include <targeting/runtime/rt_targeting.H> #include <runtime/interface.h> // g_hostInterfaces, postInitCalls_t #include <pnor/pnorif.H> @@ -42,7 +42,6 @@ #include <util/align.H> #include <runtime/customize_attrs_for_payload.H> #include <securerom/ROM.H> -#include <config.h> #include "../pnor_utils.H" #include <runtime/common/runtime_utils.H> @@ -924,7 +923,7 @@ errlHndl_t RtPnor::getMasterProcId() TRACFCOMP(g_trac_pnor, "RtPnor::getMasterProcId: queryMasterProcChipTargetHandle failed"); break; } - l_err = RT_TARG::getRtTarget(l_masterProc, iv_masterProcId); + l_err = TARGETING::getRtTarget(l_masterProc, iv_masterProcId); if (l_err) { TRACFCOMP(g_trac_pnor, "RtPnor::getMasterProcId: getRtTarget failed for master proc"); diff --git a/src/usr/pnor/sfc_ast2400.H b/src/usr/pnor/sfc_ast2400.H index c83db94c0..937435332 100644 --- a/src/usr/pnor/sfc_ast2400.H +++ b/src/usr/pnor/sfc_ast2400.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2014,2016 */ +/* Contributors Listed Below - COPYRIGHT 2014,2019 */ /* [+] Google Inc. */ /* [+] International Business Machines Corp. */ /* */ @@ -31,7 +31,6 @@ #include <errl/errlentry.H> #include "sfcdd.H" #include "sfc_ast2X00.H" -#include <config.h> /** @file sfc_ast2400.H * @brief Provides the logic to access and configure the diff --git a/src/usr/pnor/sfc_ast2500.H b/src/usr/pnor/sfc_ast2500.H index 73f07c58a..83607a5b9 100644 --- a/src/usr/pnor/sfc_ast2500.H +++ b/src/usr/pnor/sfc_ast2500.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2016 */ +/* Contributors Listed Below - COPYRIGHT 2016,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -30,7 +30,6 @@ #include <errl/errlentry.H> #include "sfcdd.H" #include "sfc_ast2X00.H" -#include <config.h> /** @file sfc_ast2500.H * @brief Provides the logic to access and configure the diff --git a/src/usr/pnor/sfc_ast2X00.H b/src/usr/pnor/sfc_ast2X00.H index 2847b75d3..aceed1c30 100644 --- a/src/usr/pnor/sfc_ast2X00.H +++ b/src/usr/pnor/sfc_ast2X00.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2016 */ +/* Contributors Listed Below - COPYRIGHT 2016,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -29,7 +29,6 @@ #include <targeting/common/targetservice.H> #include <errl/errlentry.H> #include "sfcdd.H" -#include <config.h> /** @file sfc_ast2X00.H * @brief Provides the base logic to access and configure the diff --git a/src/usr/pnor/spnorrp.C b/src/usr/pnor/spnorrp.C index 5b1ef5b03..fe2998756 100644 --- a/src/usr/pnor/spnorrp.C +++ b/src/usr/pnor/spnorrp.C @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2011,2018 */ +/* Contributors Listed Below - COPYRIGHT 2011,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -33,7 +33,6 @@ #include <sys/mm.h> #include <errno.h> #include <util/align.H> -#include <config.h> #include "pnor_common.H" #include <console/consoleif.H> #include <secureboot/service.H> @@ -41,6 +40,7 @@ #include <secureboot/trustedbootif.H> #include <secureboot/header.H> #include <sys/task.h> +#include <arch/ppc.H> extern trace_desc_t* g_trac_pnor; @@ -363,6 +363,15 @@ uint64_t SPnorRP::verifySections(SectionId i_id, PNOR::SectionIdToString(i_id)); } + // If hash table exists, need to adjust sizes + if (l_info.hasHashTable) + { + io_rec->hasHashTable = true; + l_info.vaddr -= l_info.secureProtectedPayloadSize; + l_info.size += l_info.secureProtectedPayloadSize; + io_rec->hashTableVaddr = l_info.vaddr; + } + l_info.vaddr -= PAGESIZE; // back up a page to expose the secure header l_info.size += PAGESIZE; // add a page to size to account for the header @@ -643,13 +652,23 @@ uint64_t SPnorRP::verifySections(SectionId i_id, SHA512_DIGEST_LENGTH); } - // set permissions on the secured pages to writable + // set permissions to be writable + // in the case of HPT this is the header + HPT + // in the case of no HPT this is the header + text region l_errhdl = setPermission(io_rec->secAddr, l_protectedSizeWithHdr, WRITABLE); - if(l_errhdl) + if (l_errhdl) { - TRACFCOMP(g_trac_pnor,"SPnorRP::verifySections set permissions " - "failed on text section"); + if (l_info.hasHashTable) + { + TRACFCOMP(g_trac_pnor, ERR_MRK"SPnorRP::verifySections set permissions " + "failed on header + hash page table"); + } + else + { + TRACFCOMP(g_trac_pnor, ERR_MRK"SPnorRP::verifySections set permissions " + "failed on header + text section"); + } break; } @@ -691,10 +710,18 @@ uint64_t SPnorRP::verifySections(SectionId i_id, break; } - - l_errhdl = setPermission(io_rec->secAddr + l_protectedSizeWithHdr, - unprotectedPayloadSize, - WRITABLE | WRITE_TRACKED); + if (l_info.hasHashTable) + { + l_errhdl = setPermission(io_rec->secAddr + l_protectedSizeWithHdr, + unprotectedPayloadSize, + READ_ONLY); + } + else + { + l_errhdl = setPermission(io_rec->secAddr + l_protectedSizeWithHdr, + unprotectedPayloadSize, + WRITABLE | WRITE_TRACKED); + } if(l_errhdl) { TRACFCOMP(g_trac_pnor,"SPnorRP::verifySections set permissions " @@ -704,8 +731,11 @@ uint64_t SPnorRP::verifySections(SectionId i_id, // Register the write tracked memory range to be flushed on // shutdown. - INITSERVICE::registerBlock(io_rec->secAddr + l_protectedSizeWithHdr, - unprotectedPayloadSize, SPNOR_PRIORITY); + if (!l_info.hasHashTable) + { + INITSERVICE::registerBlock(io_rec->secAddr + l_protectedSizeWithHdr, + unprotectedPayloadSize, SPNOR_PRIORITY); + } } else { @@ -738,6 +768,83 @@ uint64_t SPnorRP::verifySections(SectionId i_id, return l_rc; } +int64_t getHashPageTableIndex(const int64_t i_vaddr) +{ + return (i_vaddr / static_cast<int64_t>(PAGE_SIZE)) + 1; +} + + +PAGE_TABLE_ENTRY_t* getHashPageTableEntry(const int64_t i_vaddr, + const uint64_t i_hash_vaddr) +{ + int64_t l_index = getHashPageTableIndex(i_vaddr); + int64_t l_offset = l_index * HASH_PAGE_TABLE_ENTRY_SIZE; + + // l_offset is the offset for the start of the hash page table + // i_hash_vaddr is the vaddr for the start of the hash in SECURE + // subtract off DELTA of 3GB to get into TEMP space + return reinterpret_cast<PAGE_TABLE_ENTRY_t*>(l_offset + i_hash_vaddr - + VMM_VADDR_SPNOR_DELTA); +} + +errlHndl_t verify_page(const int64_t i_offset_vaddr, const uint64_t i_hash_vaddr, + const uint64_t i_hash_size) +{ + errlHndl_t l_errl = nullptr; + + // Get current hash page table entry in TEMP space + PAGE_TABLE_ENTRY_t* l_pageTableEntry = + getHashPageTableEntry(i_offset_vaddr, i_hash_vaddr); + + // Get previous hash page table entry in TEMP space + PAGE_TABLE_ENTRY_t* l_prevPageTableEntry = + getHashPageTableEntry(i_offset_vaddr - PAGE_SIZE, i_hash_vaddr); + + // Concatenate previous hash with current page data + std::vector< std::pair<void*,size_t> > l_blobs; + l_blobs.push_back(std::make_pair<void*,size_t>(l_prevPageTableEntry, + HASH_PAGE_TABLE_ENTRY_SIZE)); + + // To get to PNOR space, we have the address of the hash in SECURE space and + // we add hash table size to get passed the hash page table. Then we add + // i_offset_vaddr, the offset of the requested vaddr, to end up at the + // requested vaddr in SECURE space. Finally we subtract off 2 DELTAS of + // 3GB each to get to the requested vaddr in PNOR space + l_blobs.push_back(std::make_pair<void*,size_t>( + reinterpret_cast<void*>(i_offset_vaddr + + i_hash_vaddr + i_hash_size - + 2 * VMM_VADDR_SPNOR_DELTA), + PAGE_SIZE)); + SHA512_t l_curPageHash = {0}; + SECUREBOOT::hashConcatBlobs(l_blobs, l_curPageHash); + + // Compare existing hash page table entry with the derived one. + if (memcmp(l_pageTableEntry,l_curPageHash,HASH_PAGE_TABLE_ENTRY_SIZE) != 0) + { + TRACFCOMP(g_trac_pnor, "ERROR:>PNOR::verify_page secureboot verify fail on vaddr 0x%016llX", + i_hash_vaddr + i_hash_size + i_offset_vaddr); + /*@ + * @severity ERRL_SEV_CRITICAL_SYS_TERM + * @moduleid MOD_SPNORRP_VERIFY_PAGE + * @reasoncode RC_VERIFY_PAGE_FAILED + * @userdata1 Kernel RC + * @userdata2 Virtual address accessed + * + * @devdesc Secureboot page verify failure + * @custdesc Corrupted flash image or firmware error during system boot + */ + l_errl = new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_CRITICAL_SYS_TERM, + MOD_SPNORRP_VERIFY_PAGE, + RC_VERIFY_PAGE_FAILED, + TO_UINT64(EACCES), + i_offset_vaddr, + ERRORLOG::ErrlEntry::ADD_SW_CALLOUT); + l_errl->collectTrace(PNOR_COMP_NAME); + l_errl->collectTrace(SECURE_COMP_NAME); + } + return l_errl; +} + /** @@ -769,6 +876,7 @@ void SPnorRP::waitForMessage() // data[0] = virtual address requested // data[1] = address to place contents + uint64_t requested_vaddr = message->data[0]; eff_addr = reinterpret_cast<uint8_t*>(message->data[0]); user_addr = reinterpret_cast<uint8_t*>(message->data[1]); @@ -819,10 +927,34 @@ void SPnorRP::waitForMessage() TRACDCOMP( g_trac_pnor, "SPnorRP::waitForMessage got a" " request to read from secure space - " "message : user_addr=%p, eff_addr=%p, msgtype=%d, " - "textSize=0x%.16llX secAddr0x%.16llX", user_addr, + "textSize=0x%.16llX secAddr=0x%.16llX", user_addr, eff_addr, message->type, l_rec.textSize, l_rec.secAddr); + // If record has an associated hash page table, then we + // want to verify the page with the hash table in temp + if (SECUREBOOT::enabled() && l_rec.hasHashTable) + { + // Pass in the offset of just the data + int64_t offset_vaddr = requested_vaddr - + l_rec.hashTableVaddr - l_rec.textSize; + + // There is no hash table entry when we try to + // verify the header + if (offset_vaddr >= 0) { + l_errhdl = verify_page(offset_vaddr, + l_rec.hashTableVaddr, + l_rec.textSize); + } + + if (l_errhdl) + { + SECUREBOOT::handleSecurebootFailure(l_errhdl, false, true); + status_rc = -EFAULT; + break; + } + } + // determine the source of the data depending on // whether it is part of the secure payload. // by the way, this if could be removed to make this @@ -843,8 +975,8 @@ void SPnorRP::waitForMessage() // if the page came from temp space then free up // the temp page now that we're done with it // NOTE: secAddr points to Secure Header - if (eff_addr < ( (l_rec.secAddr + PAGESIZE) + - l_rec.textSize)) + if (!l_rec.hasHashTable && (eff_addr < ( (l_rec.secAddr + PAGESIZE) + + l_rec.textSize))) { mm_remove_pages(RELEASE, eff_addr - delta, PAGESIZE); @@ -924,7 +1056,6 @@ void SPnorRP::waitForMessage() // cache the record to use fields later as hints l_rec = *l_record; - } while (0); } break; @@ -936,7 +1067,7 @@ void SPnorRP::waitForMessage() do { // Disallow unload of HBB, HBI and Targeting if (l_id == HB_BASE_CODE || - l_id == HB_EXT_CODE || + l_id == HB_EXT_CODE || l_id == HB_DATA) { TRACFCOMP( g_trac_pnor, ERR_MRK"SPnorRP::waitForMessage> Secure unload of HBB, HBI, and targeting is not allowed secId=%d", l_id); @@ -998,7 +1129,7 @@ void SPnorRP::waitForMessage() size_t l_sizeWithHdr = PAGESIZE + l_rec->textSize; // if the section has an unsecured portion - if (l_sizeWithHdr != l_rec->infoSize) + if (l_sizeWithHdr != l_rec->infoSize && !l_rec->hasHashTable) { TRACFCOMP( g_trac_pnor, ERR_MRK"SPnorRP::waitForMessage> Attempting to unload an unsupported section: 0x%X textsize+hdr: 0x%llX infosize: 0x%llX (the two sizes must be equal)", l_id, l_sizeWithHdr, l_rec->infoSize); /*@ @@ -1031,6 +1162,40 @@ void SPnorRP::waitForMessage() } TRACDCOMP(g_trac_pnor,"Completely unloading %s", PNOR::SectionIdToString(l_id)); + if (l_rec->hasHashTable) + { + // remove unprotected pages + l_errhdl = removePages(l_rec->secAddr + PAGE_SIZE + l_rec->textSize, + l_rec->infoSize - PAGE_SIZE - l_rec->textSize); + if (l_errhdl) + { + TRACFCOMP(g_trac_pnor, + ERR_MRK"SPnorRP::waitForMessage> " + "removePages failed for address " + "0x%11X of length 0x%11X", + l_rec->secAddr + PAGE_SIZE + l_rec->textSize, + l_rec->infoSize - PAGE_SIZE - l_rec->textSize); + status_rc = -EFAULT; + break; + } + + l_errhdl = setPermission(l_rec->secAddr + PAGE_SIZE + l_rec->textSize, + l_rec->infoSize - PAGE_SIZE - l_rec->textSize, + NO_ACCESS); + if (l_errhdl) + { + TRACFCOMP(g_trac_pnor, + ERR_MRK"SPnorRP::waitForMessage> " + "setPermission failed for address " + "0x%11X of length 0x%11X", + l_rec->secAddr + PAGE_SIZE + l_rec->textSize, + l_rec->infoSize - PAGE_SIZE - l_rec->textSize); + + status_rc = -EFAULT; + break; + } + } + l_errhdl = removePages(l_rec->secAddr, l_sizeWithHdr); if (l_errhdl) @@ -1039,21 +1204,21 @@ void SPnorRP::waitForMessage() ERR_MRK"SPnorRP::waitForMessage> " "removePages failed for address " "0x%llX of length 0x%llX", l_rec->secAddr, - l_sizeWithHdr); + l_sizeWithHdr); status_rc = -EFAULT; break; } l_errhdl = setPermission(l_rec->secAddr, - l_sizeWithHdr, - NO_ACCESS); + l_sizeWithHdr, + NO_ACCESS); if (l_errhdl) { TRACFCOMP( g_trac_pnor, ERR_MRK"SPnorRP::waitForMessage> " "setPermission failed for address " "0x%llX of length 0x%llX", l_rec->secAddr, - l_sizeWithHdr); + l_sizeWithHdr); status_rc = -EFAULT; break; @@ -1067,7 +1232,7 @@ void SPnorRP::waitForMessage() l_sizeWithHdr); if (l_errhdl) { - TRACFCOMP( g_trac_pnor, + TRACFCOMP(g_trac_pnor, ERR_MRK"SPnorRP::waitForMessage> " "removePages failed for address " "0x%llX of length 0x%llX", l_tempAddr, @@ -1083,16 +1248,15 @@ void SPnorRP::waitForMessage() l_sizeWithHdr); l_errhdl = setPermission(l_tempAddr, - l_sizeWithHdr, - NO_ACCESS); + l_sizeWithHdr, + NO_ACCESS); if (l_errhdl) { - TRACFCOMP( g_trac_pnor, + TRACFCOMP(g_trac_pnor, ERR_MRK"SPnorRP::waitForMessage> " "setPermission failed for address " "0x%llX of length 0x%llX", l_tempAddr, l_sizeWithHdr); - status_rc = -EFAULT; break; } diff --git a/src/usr/pnor/spnorrp.H b/src/usr/pnor/spnorrp.H index 11da539ef..daaa3ffb7 100644 --- a/src/usr/pnor/spnorrp.H +++ b/src/usr/pnor/spnorrp.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2011,2017 */ +/* Contributors Listed Below - COPYRIGHT 2011,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -33,7 +33,6 @@ #include <map> #include "pnor_common.H" #include "ffs.h" -#include <config.h> #include <securerom/ROM.H> namespace SECUREBOOT @@ -113,13 +112,16 @@ class SPnorRP * Keep track of secured payload size and secure section addresses */ struct LoadRecord{ - uint8_t* secAddr; - size_t textSize; - size_t infoSize; + uint8_t* secAddr; // virtual address of the start of the record + uint64_t hashTableVaddr; // virtual address of the hash table (if it exists) + size_t textSize; // size of the protected payload, not including header + size_t infoSize; // size of the entire partition size_t refCount; + bool hasHashTable; // indicates if the record has a hash table + SHA512_t payloadTextHash; LoadRecord() - :secAddr(nullptr), textSize(0), infoSize(0), refCount(0) + :secAddr(nullptr), hashTableVaddr(0), textSize(0), infoSize(0), refCount(0), hasHashTable(false) { memset(&payloadTextHash[0], 0, SHA512_DIGEST_LENGTH); } diff --git a/src/usr/pnor/test/pnorrptest.H b/src/usr/pnor/test/pnorrptest.H index 9d9dd95c1..54ed5f1cc 100644 --- a/src/usr/pnor/test/pnorrptest.H +++ b/src/usr/pnor/test/pnorrptest.H @@ -42,7 +42,6 @@ #include <sys/task.h> #include <targeting/common/targetservice.H> #include <devicefw/userif.H> -#include <config.h> #include <pnor/ecc.H> #include "../pnorrp.H" #include "../pnor_common.H" @@ -90,11 +89,13 @@ class PnorRpTest : public CxxTest::TestSuite continue; } - if(( testSections[idx] == PNOR::DIMM_JEDEC_VPD ) && + if(( testSections[idx] == PNOR::DIMM_JEDEC_VPD || + testSections[idx] == PNOR::MODULE_VPD) && ( TARGETING::MODEL_AXONE == TARGETING::targetService().getProcessorModel() )) { - TRACFCOMP(g_trac_pnor, "PnorRpTest::test_sectionInfo> Skipping non-existent DIMM_JEDEC_VPD section for Axone"); + TRACFCOMP(g_trac_pnor, "PnorRpTest::test_sectionInfo> " + "Skipping non-existent MODULE_VPD and DIMM_JEDEC_VPD section for Axone"); continue; } diff --git a/src/usr/pnor/test/pnorutilsTest.H b/src/usr/pnor/test/pnorutilsTest.H index a2258c622..b273665c7 100644 --- a/src/usr/pnor/test/pnorutilsTest.H +++ b/src/usr/pnor/test/pnorutilsTest.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2014,2017 */ +/* Contributors Listed Below - COPYRIGHT 2014,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -62,7 +62,7 @@ class pnorutilsTest : public CxxTest::TestSuite l_tocBuffer[17] = 0x41; ffs_hdr* l_ffs_hdr = NULL; - PNOR::checkForNullBuffer(l_tocBuffer, l_errCode, l_ffs_hdr); + checkForNullBuffer(l_tocBuffer, l_errCode, l_ffs_hdr); PNOR::checkHeader(l_ffs_hdr, l_errCode); if((l_errCode & PNOR::INVALID_MAGIC) == PNOR::INVALID_MAGIC) @@ -92,7 +92,7 @@ class pnorutilsTest : public CxxTest::TestSuite l_tocBuffer[7] = 0x0; ffs_hdr* l_ffs_hdr = NULL; - PNOR::checkForNullBuffer(l_tocBuffer, l_errCode, l_ffs_hdr); + checkForNullBuffer(l_tocBuffer, l_errCode, l_ffs_hdr); PNOR::checkHeader(l_ffs_hdr, l_errCode); @@ -122,7 +122,7 @@ class pnorutilsTest : public CxxTest::TestSuite l_tocBuffer[31] = 0x80; ffs_hdr* l_ffs_hdr = NULL; - PNOR::checkForNullBuffer(l_tocBuffer, l_errCode, l_ffs_hdr); + checkForNullBuffer(l_tocBuffer, l_errCode, l_ffs_hdr); PNOR::checkHeader(l_ffs_hdr, l_errCode); @@ -153,7 +153,7 @@ class pnorutilsTest : public CxxTest::TestSuite l_tocBuffer[35] = 0x12; ffs_hdr* l_ffs_hdr = NULL; - PNOR::checkForNullBuffer(l_tocBuffer, l_errCode, l_ffs_hdr); + checkForNullBuffer(l_tocBuffer, l_errCode, l_ffs_hdr); PNOR::checkHeader(l_ffs_hdr, l_errCode); @@ -183,7 +183,7 @@ class pnorutilsTest : public CxxTest::TestSuite l_tocBuffer[38] = 0x10; ffs_hdr* l_ffs_hdr = NULL; - PNOR::checkForNullBuffer(l_tocBuffer, l_errCode, l_ffs_hdr); + checkForNullBuffer(l_tocBuffer, l_errCode, l_ffs_hdr); PNOR::checkHeader(l_ffs_hdr, l_errCode); @@ -213,7 +213,7 @@ class pnorutilsTest : public CxxTest::TestSuite l_tocBuffer[42] = 0x40; ffs_hdr* l_ffs_hdr = NULL; - PNOR::checkForNullBuffer(l_tocBuffer, l_errCode, l_ffs_hdr); + checkForNullBuffer(l_tocBuffer, l_errCode, l_ffs_hdr); PNOR::checkHeader(l_ffs_hdr, l_errCode); @@ -246,7 +246,7 @@ class pnorutilsTest : public CxxTest::TestSuite l_tocBuffer[39] = 0x33; ffs_hdr* l_ffs_hdr = NULL; - PNOR::checkForNullBuffer(l_tocBuffer, l_errCode, l_ffs_hdr); + checkForNullBuffer(l_tocBuffer, l_errCode, l_ffs_hdr); PNOR::checkHeader(l_ffs_hdr, l_errCode); @@ -276,7 +276,7 @@ class pnorutilsTest : public CxxTest::TestSuite l_tocBuffer[208] = 0xFF; PNOR::SectionData_t l_TOC[PNOR::NUM_SECTIONS]; ffs_hdr* l_ffs_hdr = NULL; - PNOR::checkForNullBuffer(l_tocBuffer, l_errCode, l_ffs_hdr); + checkForNullBuffer(l_tocBuffer, l_errCode, l_ffs_hdr); PNOR::checkHeader(l_ffs_hdr, l_errCode); //parse through the entries and check for any errors ffs_entry* l_err_entry = NULL; @@ -317,7 +317,7 @@ class pnorutilsTest : public CxxTest::TestSuite PNOR::SectionData_t l_TOC[PNOR::NUM_SECTIONS]; ffs_hdr* l_ffs_hdr = NULL; - PNOR::checkForNullBuffer(l_tocBuffer, l_errCode, l_ffs_hdr); + checkForNullBuffer(l_tocBuffer, l_errCode, l_ffs_hdr); PNOR::checkHeader(l_ffs_hdr, l_errCode); //parse through the entries and check for any errors ffs_entry* l_err_entry = NULL; @@ -336,6 +336,29 @@ class pnorutilsTest : public CxxTest::TestSuite TRACFCOMP(g_trac_pnor, "pnorutilsTest::test_entryExtendsBeyondFlash: complete, Failed = %d", l_failed); } + + private: + + /** + * @brief Ensure the buffer is not NULL, if it is, then return + * the appropriate err code from the o_errCode param. + * If the buffer is not NULL then cast it to a ffs_hdr + * and return that out through the o_ffs_hdr param. + */ + void checkForNullBuffer(uint8_t* i_tocBuffer, + uint32_t& o_errCode, + ffs_hdr*& o_ffs_hdr) + { + if(!i_tocBuffer) + { + o_errCode |= PNOR::BUFF_IS_NULL; + o_ffs_hdr = NULL; + } + else + { + o_ffs_hdr = reinterpret_cast<ffs_hdr*>(i_tocBuffer); + } + } }; #endif |