summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/include/usr/runtime/preverifiedlidmgr.H44
-rw-r--r--src/include/usr/util/utilmclmgr.H28
-rw-r--r--src/usr/isteps/istep21/call_host_runtime_setup.C35
-rw-r--r--src/usr/runtime/populate_hbruntime.C5
-rw-r--r--src/usr/runtime/preverifiedlidmgr.C64
-rw-r--r--src/usr/util/utilmclmgr.C3
6 files changed, 111 insertions, 68 deletions
diff --git a/src/include/usr/runtime/preverifiedlidmgr.H b/src/include/usr/runtime/preverifiedlidmgr.H
index 4b087e102..c5c335ce0 100644
--- a/src/include/usr/runtime/preverifiedlidmgr.H
+++ b/src/include/usr/runtime/preverifiedlidmgr.H
@@ -67,22 +67,26 @@ class PreVerifiedLidMgr
const size_t i_size);
/**
- * @brief Load PNOR section into HB reserved memory
+ * @brief Load LID into HB reserved memory
*
- * @param[in] i_sec - PNOR section ID
- * @param[in] i_addr - Virtual Address of PNOR section
- * @param[in] i_size - Size of PNOR section
- * @param[in] i_isPhypComp - Indicates if PHYP lids
- * NOTE: PHYP lids go to address HRMOR - 4K
- * @param[out] o_resvMemAddr - Mainstore address Lid was put in
+ * @param[in] i_lidId ID of LID to load
+ * @param[in] i_addr Virtual address of LID data
+ * @param[in] i_size Size of LID data
+ * @param[in] i_isPhypComp Whether LID is part of the PHyp component
+ * NOTE: PHYP LIDs (other than signature LID) will be loaded to
+ * an area anchored at PHyp's HRMOR
+ * @param[in] i_firstLid Whether this is the first LID of a component
+ * @param[out] o_resvMemAddr Mainstore address LID was loaded to
*
- * @return Error handle if error
+ * @return errlHndl_t Error log handle on failure, else nullptr
*/
- static errlHndl_t loadFromMCL(const uint32_t i_lidId,
- const uint64_t i_addr,
- const size_t i_size,
- const bool i_isPhypComp,
- uint64_t &o_resvMemAddr);
+ static errlHndl_t loadFromMCL(
+ uint32_t i_lidId,
+ uint64_t i_addr,
+ size_t i_size,
+ bool i_isPhypComp,
+ bool i_firstLid,
+ uint64_t& o_resvMemAddr);
protected:
@@ -127,11 +131,13 @@ class PreVerifiedLidMgr
/**
* @brief Internal implementation of loadFromMCL function.
*/
- errlHndl_t _loadFromMCL(const uint32_t i_lidId,
- const uint64_t i_addr,
- const size_t i_size,
- const bool i_isPhypComp,
- uint64_t &o_resvMemAddr);
+ errlHndl_t _loadFromMCL(
+ uint32_t i_lidId,
+ uint64_t i_addr,
+ size_t i_size,
+ bool i_isPhypComp,
+ bool i_firstLid,
+ uint64_t& o_resvMemAddr);
// Private Members/Variables
@@ -233,4 +239,4 @@ class PreVerifiedLidMgr
};
-#endif \ No newline at end of file
+#endif
diff --git a/src/include/usr/util/utilmclmgr.H b/src/include/usr/util/utilmclmgr.H
index 82ef6f2ed..5ce5e089f 100644
--- a/src/include/usr/util/utilmclmgr.H
+++ b/src/include/usr/util/utilmclmgr.H
@@ -31,6 +31,7 @@
#include <errl/errlentry.H>
#include <usr/vmmconst.h>
#include <securerom/ROM.H>
+#include <limits.h>
// Forward declarations
class MasterContainerLidMgrTest;
@@ -267,6 +268,30 @@ class MasterContainerLidMgr
static errlHndl_t tpmExtend(const ComponentID& i_compId,
const SECUREBOOT::ContainerHeader& i_conHdr);
+ /**
+ * @brief Caches a copy of the PHyp secure header
+ *
+ * @param[in] i_pHeader Pointer to PHyp secure header;
+ * Must not be nullptr or API will assert. Input header must be
+ * exactly PAGESIZE bytes
+ */
+ static void cachePhypHeader(const uint8_t* i_pHeader)
+ {
+ assert(i_pHeader != nullptr,
+ "Bug! PHyp header pointer was nullptr");
+ memcpy(cv_pPhypHeader,i_pHeader,PAGESIZE);
+ }
+
+ /**
+ * @brief Returns pointer to the cached PHyp secure header
+ *
+ * @return const uint8_t* Pointer to cached Phyp secure header
+ */
+ static const uint8_t* getPhypHeader()
+ {
+ return cv_pPhypHeader;
+ };
+
protected:
/**
@@ -403,6 +428,9 @@ class MasterContainerLidMgr
// Cache current comp id string for easy tracing
CompIdString iv_curCompIdStr;
+ // Cached PHyp header
+ static uint8_t cv_pPhypHeader[PAGE_SIZE];
+
// Allow test cases to call custom constructors and have direct access
friend class ::MasterContainerLidMgrTest;
};
diff --git a/src/usr/isteps/istep21/call_host_runtime_setup.C b/src/usr/isteps/istep21/call_host_runtime_setup.C
index 461ca5c31..57a5ed790 100644
--- a/src/usr/isteps/istep21/call_host_runtime_setup.C
+++ b/src/usr/isteps/istep21/call_host_runtime_setup.C
@@ -314,6 +314,12 @@ errlHndl_t verifyAndMovePayload(void)
}
}
+ if(is_phyp)
+ {
+ MCL::MasterContainerLidMgr::cachePhypHeader(
+ reinterpret_cast<uint8_t*>(payload_tmp_virt_addr));
+ }
+
// Extend PAYLOAD
l_err = MCL::MasterContainerLidMgr::tpmExtend(l_compId, l_conHdr);
if (l_err)
@@ -335,20 +341,12 @@ errlHndl_t verifyAndMovePayload(void)
payloadBase = payloadBase * MEGABYTE;
- if (is_phyp)
- {
- // Put header before PAYLOAD_BASE for PHYP/POWERVM
- payloadBase -= PAGESIZE;
- }
- else
- {
- // Move virtual address past OPAL header for memcpy below
- payload_tmp_virt_addr = reinterpret_cast<void*>(
- reinterpret_cast<uint64_t>(
- payload_tmp_virt_addr) +
- PAGESIZE);
- payload_size -= PAGESIZE;
- }
+ // Move virtual address past payload header for memcpy below
+ payload_tmp_virt_addr = reinterpret_cast<void*>(
+ reinterpret_cast<uint64_t>(
+ payload_tmp_virt_addr) +
+ PAGESIZE);
+ payload_size -= PAGESIZE;
payloadBase_virt_addr = mm_block_map(
reinterpret_cast<void*>(payloadBase),
@@ -376,9 +374,7 @@ errlHndl_t verifyAndMovePayload(void)
payload_tmp_virt_addr,
payload_size);
- // Convert the move payloadBase_va to after secure header for PHYP
uint64_t payloadBase_va = reinterpret_cast<uint64_t>(payloadBase_virt_addr);
- payloadBase_va += (is_phyp ? PAGESIZE : 0 );
// Move HDAT into its proper place after it was temporarily put into
// HDAT_TMP_ADDR-relative-to-HRMOR (HDAT_TMP_SIZE) by the FSP via TCEs
@@ -438,13 +434,6 @@ errlHndl_t verifyAndMovePayload(void)
break;
}
- // PHYP images require adding 1 PAGESIZE since our virtual address starts
- // at the secure header of PAYLOAD before PAYLOAD_BASE
- if (is_phyp)
- {
- hdat_cpy_offset += PAGESIZE;
- }
-
TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
"verifyAndMovePayload(): hdat_copy_offset = 0x%X and size=0x%X",
hdat_cpy_offset, hdat_cpy_size);
diff --git a/src/usr/runtime/populate_hbruntime.C b/src/usr/runtime/populate_hbruntime.C
index 42f3fc50b..4d26bce26 100644
--- a/src/usr/runtime/populate_hbruntime.C
+++ b/src/usr/runtime/populate_hbruntime.C
@@ -92,9 +92,8 @@ const uint8_t BITS_PER_BYTE = 8;
const uint8_t HDAT_INVALID_NODE = 0xFF;
// The upper limit of the hostboot reserved memory. Only applies to PHYP.
-// The lower limit is Hostboot HRMOR + 64MB; 4KB is the PHYP component's
-// secure header.
-const uint64_t HB_RES_MEM_UPPER_LIMIT = 256*MEGABYTE - 4*KILOBYTE;
+// The lower limit is Hostboot HRMOR + 64MB;
+const uint64_t HB_RES_MEM_UPPER_LIMIT = 256*MEGABYTE;
// The lower limit of the hostboot reserved memory. Do not allow to reserve
// any memory below this limit.
diff --git a/src/usr/runtime/preverifiedlidmgr.C b/src/usr/runtime/preverifiedlidmgr.C
index 2362e1fc0..95d122fee 100644
--- a/src/usr/runtime/preverifiedlidmgr.C
+++ b/src/usr/runtime/preverifiedlidmgr.C
@@ -39,6 +39,7 @@
#include <secureboot/containerheader.H>
#include <runtime/common/runtime_utils.H>
#include <runtime/runtime_reasoncodes.H>
+#include <util/utilmclmgr.H>
extern trace_desc_t *g_trac_runtime;
@@ -81,17 +82,22 @@ errlHndl_t PreVerifiedLidMgr::loadFromPnor(const PNOR::SectionId i_sec,
i_size);
}
-errlHndl_t PreVerifiedLidMgr::loadFromMCL(const uint32_t i_lidId,
- const uint64_t i_addr,
- const size_t i_size,
- const bool i_isPhypComp,
- uint64_t &o_resvMemAddr)
+errlHndl_t PreVerifiedLidMgr::loadFromMCL(
+ const uint32_t i_lidId,
+ const uint64_t i_addr,
+ const size_t i_size,
+ const bool i_isPhypComp,
+ const bool i_firstLid,
+ uint64_t& o_resvMemAddr)
{
- return Singleton<PreVerifiedLidMgr>::instance()._loadFromMCL(i_lidId,
- i_addr,
- i_size,
- i_isPhypComp,
- o_resvMemAddr);
+ return Singleton<PreVerifiedLidMgr>::instance().
+ _loadFromMCL(
+ i_lidId,
+ i_addr,
+ i_size,
+ i_isPhypComp,
+ i_firstLid,
+ o_resvMemAddr);
}
/********************
@@ -113,15 +119,15 @@ void PreVerifiedLidMgr::_initLock(const uint64_t i_prevAddr,
// PHYP Reserved Memory Information
cv_phypResvMemInfo.rangeId = i_rangeId;
- // PHYP lids loaded at HRMOR - 4K (Header)
+ // PHYP lids loaded at HRMOR
// Get Target Service, and the system target.
TARGETING::Target* l_sys = nullptr;
TARGETING::targetService().getTopLevelTarget(l_sys);
assert(l_sys!=nullptr,"Top Level Target is nullptr");
cv_phypResvMemInfo.curAddr = (l_sys->getAttr<TARGETING::ATTR_PAYLOAD_BASE>()
- * MEGABYTE) - PAGE_SIZE;
+ * MEGABYTE);
- // PHYP should be placed starting exactly at HRMOR - 4K, so make prevSize 0
+ // PHYP should be placed starting exactly at HRMOR, so make prevSize 0
cv_phypResvMemInfo.prevSize = 0;
// Refer to default reserved memory
@@ -342,11 +348,13 @@ errlHndl_t PreVerifiedLidMgr::_loadFromPnor(const PNOR::SectionId i_sec,
return l_errl;
}
-errlHndl_t PreVerifiedLidMgr::_loadFromMCL(const uint32_t i_lidId,
- const uint64_t i_addr,
- const size_t i_size,
- const bool i_isPhypComp,
- uint64_t &o_resvMemAddr)
+errlHndl_t PreVerifiedLidMgr::_loadFromMCL(
+ const uint32_t i_lidId,
+ const uint64_t i_addr,
+ const size_t i_size,
+ const bool i_isPhypComp,
+ const bool i_firstLid,
+ uint64_t& o_resvMemAddr)
{
mutex_lock(&cv_loadImageMutex);
@@ -359,7 +367,8 @@ errlHndl_t PreVerifiedLidMgr::_loadFromMCL(const uint32_t i_lidId,
errlHndl_t l_errl = nullptr;
// Switch to Different Memory Info for PHYP component
- if (i_isPhypComp)
+ // Exception: put the PHyp signature LID in the normal reserved memory area
+ if (i_isPhypComp && !i_firstLid)
{
cv_pResvMemInfo = &cv_phypResvMemInfo;
}
@@ -402,16 +411,25 @@ errlHndl_t PreVerifiedLidMgr::_loadFromMCL(const uint32_t i_lidId,
// Phyp component has already been loaded and verified before MCL mgr
// Simply update HB reserved prev size in Phyp component case
- if (i_isPhypComp)
+ // Special case: If it's the PHyp signature LID, handle below
+ if (i_isPhypComp && !i_firstLid)
{
- // align previous size to page size to ensure starting addresses are
- // page aligned.
+ // align previous size to page size to ensure starting addresses
+ // are page aligned.
cv_pResvMemInfo->prevSize = ALIGN_PAGE(i_size);
}
else
{
// Load image into HB reserved memory
- l_errl = loadImage(i_addr, i_size);
+ // Special case: If it's the PHyp signature LID, pull the
+ // data from the cached PHyp header, instead of the
+ // scratch area
+ uint64_t addr = (i_isPhypComp && i_firstLid) ?
+ reinterpret_cast<uint64_t>(
+ const_cast<uint8_t*>(
+ ::MCL::MasterContainerLidMgr::getPhypHeader()))
+ : i_addr;
+ l_errl = loadImage(addr, i_size);
if(l_errl)
{
TRACFCOMP( g_trac_runtime, ERR_MRK"PreVerifiedLidMgr::_loadFromMCL - Load Image failed");
diff --git a/src/usr/util/utilmclmgr.C b/src/usr/util/utilmclmgr.C
index 5df056299..a201e6905 100644
--- a/src/usr/util/utilmclmgr.C
+++ b/src/usr/util/utilmclmgr.C
@@ -39,6 +39,8 @@
namespace MCL
{
+uint8_t MasterContainerLidMgr::cv_pPhypHeader[PAGESIZE] = {0};
+
const size_t MclCompSectionPadSize = 16;
const ComponentID g_MclCompId {"MSTCONT"};
@@ -506,6 +508,7 @@ errlHndl_t MasterContainerLidMgr::processComponent(const ComponentID& i_compId,
l_curAddr,
lidInfo.size,
isPhypComp,
+ l_firstLid,
l_addr);
if(l_errl)
{
OpenPOWER on IntegriCloud