Skip to content

Commit

Permalink
untrusted SBE reserved memory region to Rsvd Mem Trace Buf Section
Browse files Browse the repository at this point in the history
Opens an untrusted SBE reserved memory region with read-only
permissions to the Rsvd Mem Trace Buf Section.so that tools/debug
can come in and read those traces in secure mode. Establishes the
window across -all- chips.

Change-Id: Ied9852455d7c412915871328976a9204e1f5247f
RTC:191303
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/58637
Reviewed-by: Prachi Gupta <pragupta@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Tested-by: Daniel M. Crowell <dcrowell@us.ibm.com>
  • Loading branch information
sakethan authored and dcrowell77 committed Jun 19, 2018
1 parent b3e359b commit 34d086e
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/include/usr/runtime/runtime.H
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,17 @@ void findHdatLocation(uint64_t payloadBase_va,
uint64_t& o_hdat_offset,
size_t& o_hdat_size);

/**
* @brief Finds the Rsvd Mem Trace Buffer section and returns the address and
* size of the section
*
* @param[out] o_RsvdMemAddress - tarting address of the Rsvd Mem Trace Buffer section
* @param[out] o_size - Size of the Rsvd Mem Trace Buffer section
* @return errlHndl_t Returns nullptr on success; otherwise errlog
*/
errlHndl_t getRsvdMemTraceBuf(uint64_t& o_RsvdMemAddress, uint64_t& o_size);

}

#endif

107 changes: 107 additions & 0 deletions src/usr/runtime/populate_hbruntime.C
Original file line number Diff line number Diff line change
Expand Up @@ -3463,6 +3463,40 @@ errlHndl_t openUntrustedSpCommArea(const uint64_t i_commBase)
}
}

// Open Unsecure Memory Region for HBRT Rsvd Mem Trace Section
uint64_t l_RsvdMemRtTraceAddr = 0;
uint64_t l_RsvdMemRtTraceSize = 0;

//get the HBRT Rsvd Mem Trace Section addr and size
l_err = getRsvdMemTraceBuf(l_RsvdMemRtTraceAddr,l_RsvdMemRtTraceSize);

if(l_err)
{
TRACFCOMP( g_trac_runtime, ERR_MRK "openUntrustedSpCommArea(): getRsvdMemTraceBuf() failed proc = 0x%X",
l_id);

break;
}

if((l_RsvdMemRtTraceAddr != 0) && (l_RsvdMemRtTraceSize != 0))
{
// Open Unsecure Memory Region for HBRT Rsvd Mem Trace Section
l_err = SBEIO::openUnsecureMemRegion(l_RsvdMemRtTraceAddr,
l_RsvdMemRtTraceSize,
false, //Read-Only
l_procChip);
if(l_err)
{
TRACFCOMP( g_trac_runtime, ERR_MRK "openUntrustedSpCommArea(): openUnsecureMemRegion() failed proc = 0x%X addr = 0x%016llx size = 0x%X",
l_id,
l_RsvdMemRtTraceAddr,
l_RsvdMemRtTraceSize);

break;
}

}

}
if(l_err)
{
Expand All @@ -3483,5 +3517,78 @@ void setPayloadBaseAddress(uint64_t i_payloadAddress)
sys->setAttr<TARGETING::ATTR_PAYLOAD_BASE>(i_payloadAddress);
}

errlHndl_t getRsvdMemTraceBuf(uint64_t& o_RsvdMemAddress, uint64_t& o_size)
{
errlHndl_t l_elog = nullptr;
uint64_t l_rsvMemDataAddr = 0;
uint64_t l_rsvMemDataSize = 0;
hdatMsVpdRhbAddrRange_t* l_rngPtr = nullptr;
Util::hbrtTableOfContents_t * l_hbTOC = nullptr;

do{
// We have only one HBRT_MEM_LABEL_TRACEBUF section across the system.
// Loop through all RESERVED_MEM sections in the system (of all nodes),
// and find out the section with label HBRT_MEM_LABEL_TRACEBUF
uint64_t l_StartInstance = 0; //start from 0
uint64_t l_EndInstance = 0;

l_elog = RUNTIME::get_instance_count(RUNTIME::RESERVED_MEM,l_EndInstance);
if(l_elog != nullptr)
{
TRACFCOMP( g_trac_runtime,
"getRsvdMemTraceBuf() fail get_instance_count");
break;
}


for (uint64_t l_instance = l_StartInstance ; l_instance < l_EndInstance; l_instance++)
{

// Get the address of the section
l_elog = RUNTIME::get_host_data_section( RUNTIME::RESERVED_MEM,
l_instance,
l_rsvMemDataAddr,
l_rsvMemDataSize );
if(l_elog != nullptr)
{
TRACFCOMP( g_trac_runtime,
"getRsvdMemTraceBuf fail get_host_data_section instance = %d",
l_instance);
break;
}

l_rngPtr = reinterpret_cast<hdatMsVpdRhbAddrRange_t *>(l_rsvMemDataAddr);

assert(l_rngPtr != nullptr, "get_host_data_section returned nullptr");

const char* l_region = reinterpret_cast<const char *>(l_rngPtr->hdatRhbLabelString);

if (strcmp(l_region,"HBRT_RSVD_MEM__DATA")== 0)
{
TRACFCOMP( g_trac_runtime,
"getRsvdMemTraceBuf() Found HBRT_RSVD_MEM__DATA section");

l_hbTOC = reinterpret_cast<Util::hbrtTableOfContents_t *>(
l_rngPtr->hdatRhbAddrRngStrAddr);
o_RsvdMemAddress = Util::hb_find_rsvd_mem_label(Util::HBRT_MEM_LABEL_TRACEBUF,
l_hbTOC,
o_size);
if((o_RsvdMemAddress != 0) && (o_size != 0))
{
TRACFCOMP( g_trac_runtime,
"getRsvdMemTraceBuf() Found HBRT_MEM_LABEL_TRACEBUF section 0x%016llx size = 0x%X",
o_RsvdMemAddress,o_size);
break;
}
}

}

}while(0);

return l_elog;

}

} //namespace RUNTIME

0 comments on commit 34d086e

Please sign in to comment.