Skip to content

Commit

Permalink
Add PNOR SectionIdToString to replace direct access to cv_EYECATCHER
Browse files Browse the repository at this point in the history
This catches if the const array size does not match the number of
pnor sections and out of range index errors
Also it adds genErrlParsing for bootloader files

Change-Id: I0a90816a7620022dec16bc7358a68ffbdade0083
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/38159
Reviewed-by: Martin Gloff <mgloff@us.ibm.com>
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Reviewed-by: Michael Baiocchi <mbaiocch@us.ibm.com>
Reviewed-by: Nicholas E. Bofferding <bofferdn@us.ibm.com>
Reviewed-by: William G. Hoffa <wghoffa@us.ibm.com>
  • Loading branch information
Stephen Cprek authored and wghoffa committed Mar 23, 2017
1 parent 98de8e6 commit d87acea
Show file tree
Hide file tree
Showing 16 changed files with 166 additions and 107 deletions.
22 changes: 10 additions & 12 deletions src/bootloader/bl_pnorAccess.C
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
#define BOOTLOADER_TRACE_W_BRK(args) TRACFCOMP(g_trac_pnor,"##args")
#endif


extern const char* cv_EYECATCHER[];
/**
* @brief Takes in a buffer containing a ToC, as well as a base address
Returns out a boolean whether or not this toc was valid
Expand Down Expand Up @@ -66,8 +64,8 @@ void bl_pnorAccess::readTOC(uint8_t i_tocBuffer[PNOR::TOC_SIZE],
// Set TI information but caller decides to TI or not
/*@
* @errortype
* @moduleid MOD_PNORACC_READTOC
* @reasoncode RC_CHK_NULL_BUFFER
* @moduleid Bootloader::MOD_PNORACC_READTOC
* @reasoncode Bootloader::RC_CHK_NULL_BUFFER
* @userdata1[0:15] TI_WITH_SRC
* @userdata1[16:31] TI_BOOTLOADER
* @userdata1[32:63] Failing address = 0
Expand Down Expand Up @@ -103,8 +101,8 @@ void bl_pnorAccess::readTOC(uint8_t i_tocBuffer[PNOR::TOC_SIZE],
// Set TI information but caller decides to TI or not
/*@
* @errortype
* @moduleid MOD_PNORACC_READTOC
* @reasoncode RC_HDR_CHECKSUM_ERR
* @moduleid Bootloader::MOD_PNORACC_READTOC
* @reasoncode Bootloader::RC_HDR_CHECKSUM_ERR
* @userdata1[0:15] TI_WITH_SRC
* @userdata1[16:31] TI_BOOTLOADER
* @userdata1[32:63] Failing address = 0
Expand Down Expand Up @@ -133,8 +131,8 @@ void bl_pnorAccess::readTOC(uint8_t i_tocBuffer[PNOR::TOC_SIZE],
// Set TI information but caller decides to TI or not
/*@
* @errortype
* @moduleid MOD_PNORACC_READTOC
* @reasoncode RC_CHECK_HEADER_ERR
* @moduleid Bootloader::MOD_PNORACC_READTOC
* @reasoncode Bootloader::RC_CHECK_HEADER_ERR
* @userdata1[0:15] TI_WITH_SRC
* @userdata1[16:31] TI_BOOTLOADER
* @userdata1[32:63] Failing address = 0
Expand Down Expand Up @@ -168,8 +166,8 @@ void bl_pnorAccess::readTOC(uint8_t i_tocBuffer[PNOR::TOC_SIZE],
// Set TI information but caller decides to TI or not
/*@
* @errortype
* @moduleid MOD_PNORACC_READTOC
* @reasoncode RC_PARSE_ENTRIES_ERR
* @moduleid Bootloader::MOD_PNORACC_READTOC
* @reasoncode Bootloader::RC_PARSE_ENTRIES_ERR
* @userdata1[0:15] TI_WITH_SRC
* @userdata1[16:31] TI_BOOTLOADER
* @userdata1[32:63] Failing address = 0
Expand Down Expand Up @@ -277,8 +275,8 @@ void bl_pnorAccess::getHBBSection(uint64_t i_pnorEnd,
BOOTLOADER_TRACE_W_BRK(BTLDR_TRC_PA_GETHBBSECTION_FINDTOC_NOHBB);
/*@
* @errortype
* @moduleid MOD_PNORACC_GETHBBSECT
* @reasoncode RC_NO_HBB_IN_TOC
* @moduleid Bootloader::MOD_PNORACC_GETHBBSECT
* @reasoncode Bootloader::RC_NO_HBB_IN_TOC
* @userdata1[0:15] TI_WITH_SRC
* @userdata1[16:31] TI_BOOTLOADER
* @userdata1[32:63] Failing address = 0
Expand Down
16 changes: 8 additions & 8 deletions src/bootloader/bl_terminate.C
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ void kernel_std_exception()

/*@
* @errortype
* @moduleid MOD_BOOTLOADER_TERMINATE
* @reasoncode RC_STD_EXCEPTION
* @moduleid Bootloader::MOD_BOOTLOADER_TERMINATE
* @reasoncode Bootloader::RC_STD_EXCEPTION
* @userdata1[0:15] TI_WITH_SRC
* @userdata1[16:31] TI_BOOTLOADER
* @userdata1[32:63] Exception vector address
Expand All @@ -69,8 +69,8 @@ void kernel_std_exception_w_dsisr()

/*@
* @errortype
* @moduleid MOD_BOOTLOADER_TERMINATE
* @reasoncode RC_STD_EX_W_DSISR
* @moduleid Bootloader::MOD_BOOTLOADER_TERMINATE
* @reasoncode Bootloader::RC_STD_EX_W_DSISR
* @userdata1[0:15] TI_WITH_SRC
* @userdata1[16:31] TI_BOOTLOADER
* @userdata1[32:63] Exception vector address
Expand All @@ -97,8 +97,8 @@ void kernel_std_exception_w_srr1()

/*@
* @errortype
* @moduleid MOD_BOOTLOADER_TERMINATE
* @reasoncode RC_STD_EX_W_SRR1
* @moduleid Bootloader::MOD_BOOTLOADER_TERMINATE
* @reasoncode Bootloader::RC_STD_EX_W_SRR1
* @userdata1[0:15] TI_WITH_SRC
* @userdata1[16:31] TI_BOOTLOADER
* @userdata1[32:63] Exception vector address
Expand All @@ -124,8 +124,8 @@ void kernel_hype_exception()

/*@
* @errortype
* @moduleid MOD_BOOTLOADER_TERMINATE
* @reasoncode RC_HYPE_EXCEPTION
* @moduleid Bootloader::MOD_BOOTLOADER_TERMINATE
* @reasoncode Bootloader::RC_HYPE_EXCEPTION
* @userdata1[0:15] TI_WITH_SRC
* @userdata1[16:31] TI_BOOTLOADER
* @userdata1[32:63] Exception vector address
Expand Down
6 changes: 3 additions & 3 deletions src/bootloader/bootloader.C
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ namespace Bootloader{
BOOTLOADER_TRACE(BTLDR_TRC_MAIN_VERIFY_FAIL);
/*@
* @errortype
* @moduleid MOD_BOOTLOADER_VERIFY
* @moduleid Bootloader::MOD_BOOTLOADER_VERIFY
* @reasoncode SECUREBOOT::RC_ROM_VERIFY
* @userdata1 ROM return code
* @userdata2 ROM_hw_params log
Expand Down Expand Up @@ -351,8 +351,8 @@ namespace Bootloader{
BOOTLOADER_TRACE_W_BRK(BTLDR_TRC_MAIN_REMOVEECC_FAIL);
/*@
* @errortype
* @moduleid MOD_BOOTLOADER_MAIN
* @reasoncode RC_REMOVE_ECC_FAIL
* @moduleid Bootloader::MOD_BOOTLOADER_MAIN
* @reasoncode Bootloader::RC_REMOVE_ECC_FAIL
* @userdata1[0:15] TI_WITH_SRC
* @userdata1[16:31] TI_BOOTLOADER
* @userdata1[32:63] Failing address = 0
Expand Down
1 change: 1 addition & 0 deletions src/build/debug/Hostboot/BlTrace.pm
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ my %traceText = (
"E5" => "Utils checkHeader block count invalid",
"E6" => "Utils checkHeader header size invalid",
"E7" => "Utils parseEntries invalid section",
"E8" => "Utils SectionIdToString PNOR section id out of range",
"F0" => "Main getHBBSection returned",
"F1" => "Main removeECC returned error",
"F2" => "PNOR Access readTOC checkForNullBuffer null buffer",
Expand Down
3 changes: 3 additions & 0 deletions src/include/bootloader/bootloader_trace.H
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ enum BootloaderTraces
/** Bootloader Utils parseEntries invalid section */
BTLDR_TRC_UTILS_PARSE_INVALID_SECTION = 0xE7,

/** Bootloader Utils SectionIdToString PNOR section id out of range*/
BTLDR_TRC_UTILS_PARSE_PNOR_SECID_OUT_OF_RANGE = 0xE8,

/** Bootloader main getHBBSection returned error */
BTLDR_TRC_MAIN_GETHBBSECTION_FAIL = 0xF0,

Expand Down
38 changes: 20 additions & 18 deletions src/include/bootloader/hbblreasoncodes.H
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,13 @@ namespace Bootloader
*/
enum hbblModuleId
{
MOD_BOOTLOADER_INVALID = 0x00, /**< Zero is an invalid module id */
MOD_BOOTLOADER_TERMINATE = 0x01, /**< bl_terminate.C : save SRC */
MOD_BOOTLOADER_MAIN = 0x02, /**< bootloader.C : main */
MOD_PNORACC_READTOC = 0x03, /**< bl_pnorAccess.C : read TOC */
MOD_PNORACC_GETHBBSECT = 0x04, /**< bl_pnorAccess.C : get HBB sect */
MOD_BOOTLOADER_VERIFY = 0x05, /**< bootloader.C : verifyContainer */
MOD_BOOTLOADER_INVALID = 0x00, /**< Zero is an invalid module id */
MOD_BOOTLOADER_TERMINATE = 0x01, /**< bl_terminate.C : save SRC */
MOD_BOOTLOADER_MAIN = 0x02, /**< bootloader.C : main */
MOD_PNORACC_READTOC = 0x03, /**< bl_pnorAccess.C : read TOC */
MOD_PNORACC_GETHBBSECT = 0x04, /**< bl_pnorAccess.C : get HBB sect */
MOD_BOOTLOADER_VERIFY = 0x05, /**< bootloader.C : verifyContainer */
MOD_BOOTLOADER_PNOR_SECID_TO_STR = 0x06 /**< pnor_utils.C : SectionIdToString */

};

Expand All @@ -59,18 +60,19 @@ namespace Bootloader
*/
enum hbblReasonCode
{
RC_ASSERT = HBBL_COMP_ID | 0x01, /**< Assert */
RC_SHUTDOWN = HBBL_COMP_ID | 0x02, /**< Shutdown */
RC_STD_EXCEPTION = HBBL_COMP_ID | 0x03, /**< Standard Exception */
RC_STD_EX_W_DSISR = HBBL_COMP_ID | 0x04, /**< Std Except w/ DSISR */
RC_STD_EX_W_SRR1 = HBBL_COMP_ID | 0x05, /**< Std Except w/ SRR1 */
RC_HYPE_EXCEPTION = HBBL_COMP_ID | 0x06, /**< Hypervisor Exception */
RC_REMOVE_ECC_FAIL = HBBL_COMP_ID | 0x07, /**< Remove ECC Failed */
RC_CHK_NULL_BUFFER = HBBL_COMP_ID | 0x08, /**< Check for NULL Buffr */
RC_HDR_CHECKSUM_ERR = HBBL_COMP_ID | 0x09, /**< Hdr Checksum Error */
RC_CHECK_HEADER_ERR = HBBL_COMP_ID | 0x0A, /**< Check Header Error */
RC_PARSE_ENTRIES_ERR = HBBL_COMP_ID | 0x0B, /**< Parse Entries Error */
RC_NO_HBB_IN_TOC = HBBL_COMP_ID | 0x0C, /**< No HBB Sect in TOC */
RC_ASSERT = HBBL_COMP_ID | 0x01, /**< Assert */
RC_SHUTDOWN = HBBL_COMP_ID | 0x02, /**< Shutdown */
RC_STD_EXCEPTION = HBBL_COMP_ID | 0x03, /**< Standard Exception */
RC_STD_EX_W_DSISR = HBBL_COMP_ID | 0x04, /**< Std Except w/ DSISR */
RC_STD_EX_W_SRR1 = HBBL_COMP_ID | 0x05, /**< Std Except w/ SRR1 */
RC_HYPE_EXCEPTION = HBBL_COMP_ID | 0x06, /**< Hypervisor Exception */
RC_REMOVE_ECC_FAIL = HBBL_COMP_ID | 0x07, /**< Remove ECC Failed */
RC_CHK_NULL_BUFFER = HBBL_COMP_ID | 0x08, /**< Check for NULL Buffr */
RC_HDR_CHECKSUM_ERR = HBBL_COMP_ID | 0x09, /**< Hdr Checksum Error */
RC_CHECK_HEADER_ERR = HBBL_COMP_ID | 0x0A, /**< Check Header Error */
RC_PARSE_ENTRIES_ERR = HBBL_COMP_ID | 0x0B, /**< Parse Entries Error */
RC_NO_HBB_IN_TOC = HBBL_COMP_ID | 0x0C, /**< No HBB Sect in TOC */
RC_PNOR_SECID_OUT_OF_RANGE = HBBL_COMP_ID | 0x0D, /**< Requested PNOR SecId DNE in string array */
};

}; // end Bootloader
Expand Down
1 change: 1 addition & 0 deletions src/include/usr/pnor/pnor_const.H
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ enum SectionId
POWERVM, /**< Power VM data */
RINGOVD, /**< Ring override data */
WOFDATA, /**< VFRT data tables for WOF */
SBKT, /**< SecureBoot Key Transition */
NUM_SECTIONS, /**< Number of defined sections */

FIRST_SECTION = TOC, /**< First section (for looping) */
Expand Down
5 changes: 5 additions & 0 deletions src/usr/errl/parser/genErrlParsers.pl
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@
my $compIdFile = $base."/src/include/usr/hbotcompid.H";
my $compPath = $base."/src/usr";
my $compIncPath = $base."/src/include/usr";
my $compBlPath = $base."/src/bootloader";
my $compBlIncPath = $base."/src/include/bootloader";
my $genFilesPath = $base."/obj/genfiles";
my $hbfwTermRcFile = $genFilesPath."/hbfw_term_rc.H";
my $srcFileName = $genFilesPath."/srcListing";
Expand All @@ -91,9 +93,12 @@
my @filesToParse;
my @pluginDirsToParse;
getReasonCodeFiles($compIncPath);
getReasonCodeFiles($compBlIncPath);
getFilesToParse($compPath);
getFilesToParse($compIncPath);
getFilesToParse($genFilesPath);
getFilesToParse($compBlPath);
getFilesToParse($compBlIncPath);
getPluginDirsToParse($compPath);

#Add kernel/lib files for TI SRC descriptions
Expand Down
9 changes: 2 additions & 7 deletions src/usr/pnor/pnor_common.C
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ TRAC_INIT(&g_trac_pnor, PNOR_COMP_NAME, 4*KILOBYTE, TRACE::BUFFER_SLOW); //4K
//#define TRACUCOMP(args...) TRACFCOMP(args)
#define TRACUCOMP(args...)

/**
* Eyecatcher strings for PNOR TOC entries
*/
extern const char* cv_EYECATCHER[];


/*
* @brief determine the physical offset of the ffs entry
Expand Down Expand Up @@ -319,7 +314,7 @@ errlHndl_t PNOR::parseTOC( uint8_t* i_tocBuffer,SectionData_t * o_TOC)
addr -= headerSize;

l_errhdl = PNOR::extendHash(addr, headerSize,
cv_EYECATCHER[l_secId]);
PNOR::SectionIdToString(l_secId));
if (l_errhdl)
{
break;
Expand All @@ -333,7 +328,7 @@ errlHndl_t PNOR::parseTOC( uint8_t* i_tocBuffer,SectionData_t * o_TOC)
tmpId ++ )
{
TRACFCOMP(g_trac_pnor, "%s: size=0x%.8X flash=0x%.8X ",
cv_EYECATCHER[tmpId], o_TOC[tmpId].size,
PNOR::SectionIdToString(tmpId), o_TOC[tmpId].size,
o_TOC[tmpId].flashAddr);
}

Expand Down

0 comments on commit d87acea

Please sign in to comment.