Skip to content

Commit

Permalink
Add VERSION to all OpenPOWER HBRT error logs
Browse files Browse the repository at this point in the history
Now that the VERSION partition is a secure section, in order to have the
version info in all runtime error logs the VERSION section has been put
into reserved memory which can then be loaded and added to all HBRT
OpenPOWER error logs.

Change-Id: Iaf74d19270f8221710f30834097e131f4dadeeba
RTC:200439
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/68855
Reviewed-by: Ilya Smirnov <ismirno@us.ibm.com>
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com>
Reviewed-by: Nicholas E. Bofferding <bofferdn@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
  • Loading branch information
Matt Raybuck authored and dcrowell77 committed Nov 27, 2018
1 parent b08f9e7 commit 022f2d7
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/include/usr/util/utillidmgr.H
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2013,2017 */
/* Contributors Listed Below - COPYRIGHT 2013,2018 */
/* [+] International Business Machines Corp. */
/* */
/* */
Expand Down Expand Up @@ -48,6 +48,7 @@ namespace Util
enum LidId
{
TEST_LIDID = 0x00000111,
VERSION_LIDID = 0x0000FFFF,
OCC_LIDID = 0x81e00430,
OCC_CONTAINER_LIDID = 0x80d0000b,
MCL_LIDID = 0x80d00020,
Expand Down
96 changes: 94 additions & 2 deletions src/usr/errl/errlentry.C
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
#include <errl/errludsensor.H>
#endif

#include <util/utillidmgr.H>

// Hostboot Image ID string
extern char hbi_ImageId;

Expand Down Expand Up @@ -672,6 +674,8 @@ void ErrlEntry::addHbBuildId()
void ErrlEntry::addVersionInfo()
{

TRACDCOMP(g_trac_errl, ENTER_MRK"addVersionInfo()");

// Start of IPL only block; runtime does not support secure loading of
// partitions
#ifndef __HOSTBOOT_RUNTIME
Expand Down Expand Up @@ -732,7 +736,8 @@ void ErrlEntry::addVersionInfo()

size_t l_numberOfBytes = 0;

// Determine the size of the version data.
// Determine the size of the version data. The max size is the given
// size in the SectionInfo but can be less.
while ((static_cast<char>(l_versionData[l_numberOfBytes]) != '\0')
&& l_numberOfBytes < l_pnorVersionInfo.size)
{
Expand Down Expand Up @@ -768,7 +773,94 @@ void ErrlEntry::addVersionInfo()

}

#endif // End of IPL only block
// End of IPL only block
#else
// Start of runtime block. Since runtime doesn't support securing load of PNOR
// sections, we load the version info from reserved memory.

// Version section of PNOR is only available to OpenPOWER systems.
if (!INITSERVICE::spBaseServicesEnabled())
{
errlHndl_t l_errl = nullptr;

do
{

// Get PNOR Version
UtilLidMgr l_lidMgr(Util::VERSION_LIDID);
size_t l_lidSize = 0;
l_errl = l_lidMgr.getLidSize(l_lidSize);

if (l_errl)
{
TRACFCOMP( g_trac_errl,
"addVersionInfo: Failed to getLidSize() - error");
// Since an error occurred while attempting to add version info
// to another error log there is nothing that can be done with
// this error since attempting to commit it will lead to an
// infinite loop of committing the error and then recalling this
// function. If this error occurred then the VERSION partition
// is not added and the error log commit continues.
delete l_errl;
l_errl = nullptr;
break;
}

TRACDCOMP(g_trac_errl,
"addVersionInfo: l_lidSize = %d",
l_lidSize);

char* l_versionData = new char[l_lidSize]();
l_errl = l_lidMgr.getLid(l_versionData, l_lidSize);


if (l_errl)
{
TRACFCOMP( g_trac_errl,
"addVersionInfo: Failed to getLid() - error");
// Since an error occurred while attempting to add version info
// to another error log there is nothing that can be done with
// this error since attempting to commit it will lead to an
// infinite loop of committing the error and then recalling this
// function. If this error occurred then the VERSION partition
// is not added and the error log commit continues.
delete l_errl;
l_errl = nullptr;
delete[] l_versionData;
l_versionData = nullptr;
break;
}

size_t l_numberOfBytes = 0;

// Determine the size of the version data. The max size is the
// lidSize but can be less.
while ((static_cast<char>(l_versionData[l_numberOfBytes]) != '\0')
&& l_numberOfBytes < l_lidSize)
{
++l_numberOfBytes;
}

TRACDCOMP(g_trac_errl,
"addVersionInfo: l_numberOfBytes = %d",
l_numberOfBytes);

char l_pVersionString[l_numberOfBytes + 1]={0};

memcpy(l_pVersionString, l_versionData, l_numberOfBytes);

ErrlUserDetailsString(l_pVersionString).addToLog(this);

delete[] l_versionData;
l_versionData = nullptr;

} while(0);


}
#endif

TRACFCOMP(g_trac_errl, EXIT_MRK"addVersionInfo()");

}

Expand Down
3 changes: 2 additions & 1 deletion src/usr/runtime/common/runtime_utils.C
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const PreVerifyVector preVerifiedPnorSections {
{PNOR::OCC, true},
{PNOR::WOFDATA, true},
{PNOR::HCODE, true},
{PNOR::VERSION, true},
{PNOR::RINGOVD, false},
};

Expand Down Expand Up @@ -76,4 +77,4 @@ bool isPreVerifiedSectionSecure(const PNOR::SectionId i_section)
return l_result;
}

}
}
7 changes: 7 additions & 0 deletions src/usr/runtime/populate_hbruntime.C
Original file line number Diff line number Diff line change
Expand Up @@ -1658,6 +1658,13 @@ errlHndl_t populate_HbRsvMem(uint64_t i_nodeId, bool i_master_node)
continue;
}

// Skip VERSION section for non-BMC based systems.
if ((secIdPair.first == PNOR::VERSION)
&& INITSERVICE::spBaseServicesEnabled())
{
continue;
}

l_elog = hbResvLoadSecureSection(secIdPair.first,
secIdPair.second);
if (l_elog)
Expand Down
13 changes: 12 additions & 1 deletion src/usr/runtime/test/testpreverifiedlidmgr.H
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ class PreVerifiedLidMgrTest : public CxxTest::TestSuite
// Handle all Pre verified PNOR sections
for (const auto & secIdPair : RUNTIME::preVerifiedPnorSections)
{

// VERSION is not in standalone so ignore it here.
if (secIdPair.first == PNOR::VERSION)
{
continue;
}

l_errl = RUNTIME::hbResvLoadSecureSection(secIdPair.first,
secIdPair.second);
if (l_errl)
Expand Down Expand Up @@ -110,6 +117,10 @@ class PreVerifiedLidMgrTest : public CxxTest::TestSuite
// RINGOVD not permitted in secure mode. Meaning the Header and
// Content lid will be missing.
l_expectedLids -= 2;

// VERSION is only an OpenPOWER partition so we need to adjust for
// it here since it doesn't exist for standalone.
l_expectedLids -= 2;
}

// Ensure the expected number of lids were loaded.
Expand All @@ -129,4 +140,4 @@ class PreVerifiedLidMgrTest : public CxxTest::TestSuite
}
};

#endif
#endif
6 changes: 4 additions & 2 deletions src/usr/util/runtime/utillidmgr_rt.C
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,8 @@ const uint32_t * UtilLidMgr::getLidList(size_t * o_num)
Util::CUMULUS_HCODE_LIDID,
Util::HCODE_CONTAINER_LIDID,
Util::HWREFIMG_RINGOVD_LIDID,
Util::TARGETING_BINARY_LIDID
Util::TARGETING_BINARY_LIDID,
Util::VERSION_LIDID
};
*o_num = sizeof(lidlist)/sizeof(lidlist[0]);
TRACFCOMP(g_trac_hbrt, EXIT_MRK" get_lid_list");
Expand All @@ -371,7 +372,8 @@ bool UtilLidMgr::lidInHbResvMem(const uint32_t i_lidId) const
i_lidId == Util::CUMULUS_HCODE_LIDID ||
i_lidId == Util::HCODE_CONTAINER_LIDID ||
i_lidId == Util::HWREFIMG_RINGOVD_LIDID ||
i_lidId == Util::TARGETING_BINARY_LIDID;
i_lidId == Util::TARGETING_BINARY_LIDID ||
i_lidId == Util::VERSION_LIDID;
}

//------------------------------------------------------------------------
Expand Down
3 changes: 2 additions & 1 deletion src/usr/util/utillidpnor.C
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2014,2017 */
/* Contributors Listed Below - COPYRIGHT 2014,2018 */
/* [+] International Business Machines Corp. */
/* */
/* */
Expand Down Expand Up @@ -49,6 +49,7 @@ const size_t lidIdStrLength = 9;
static const PnorLidsMap PnorToLidsMap =
{
{ PNOR::TESTRO, LidAndContainerLid(TEST_LIDID, INVALID_LIDID)},
{ PNOR::VERSION, LidAndContainerLid(VERSION_LIDID, INVALID_LIDID)},
{ PNOR::OCC, LidAndContainerLid(OCC_LIDID, OCC_CONTAINER_LIDID)},
{ PNOR::WOFDATA, LidAndContainerLid(WOF_LIDID, WOF_CONTAINER_LIDID)},
{ PNOR::HCODE, LidAndContainerLid(NIMBUS_HCODE_LIDID, HCODE_CONTAINER_LIDID)},
Expand Down

0 comments on commit 022f2d7

Please sign in to comment.