summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/include/usr/runtime/runtime.H24
-rw-r--r--src/usr/isteps/istep21/call_host_runtime_setup.C16
-rw-r--r--src/usr/runtime/hdatservice.C31
-rw-r--r--src/usr/runtime/hdatstructs.H22
-rw-r--r--src/usr/runtime/populate_hbruntime.C105
5 files changed, 192 insertions, 6 deletions
diff --git a/src/include/usr/runtime/runtime.H b/src/include/usr/runtime/runtime.H
index d8d22a8d5..f82bf63fe 100644
--- a/src/include/usr/runtime/runtime.H
+++ b/src/include/usr/runtime/runtime.H
@@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
-/* Contributors Listed Below - COPYRIGHT 2012,2017 */
+/* Contributors Listed Below - COPYRIGHT 2012,2018 */
/* [+] International Business Machines Corp. */
/* */
/* */
@@ -163,7 +163,17 @@ enum SectionId
RESERVED_MEM, //< Hostboot's Reserved Mainstore Memory
HRMOR_STASH, //< Pointer to address in reserved memory
// where PHYP can write HRMOR
- LAST_SECTION = HRMOR_STASH //< Placeholder for arrays
+ CPU_CTRL, // Spira-H CPU controls area
+ LAST_SECTION = CPU_CTRL //< Placeholder for arrays
+};
+
+/**
+ * Range of SBE unsecure memory region to open
+ */
+enum SbeUnsecureMemoryRegions
+{
+ SP_HOST_UNTRUSTED_COMM_AREA_ADDR = 0,
+ SP_HOST_UNTRUSTED_COMM_AREA_SIZE = 64*MEGABYTE,
};
/**
@@ -249,6 +259,16 @@ void setPayloadBaseAddress(uint64_t i_payloadAddress);
*/
void rediscover_hdat( void );
+/**
+ * @brief Open necessary unsecure SBE windows for SP -> host communication
+ * Currently opens two windows
+ * 1. CPU controls SP ATTN areas
+ * 2. SP_HOST_UNTRUSTED_COMM_AREA_ADDR
+ *
+ * @return errlHndl_t Returns nullptr on success; otherwise errlog
+ */
+errlHndl_t openUntrustedSpCommArea();
+
}
#endif
diff --git a/src/usr/isteps/istep21/call_host_runtime_setup.C b/src/usr/isteps/istep21/call_host_runtime_setup.C
index 8edc60801..38a67ab50 100644
--- a/src/usr/isteps/istep21/call_host_runtime_setup.C
+++ b/src/usr/isteps/istep21/call_host_runtime_setup.C
@@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
-/* Contributors Listed Below - COPYRIGHT 2015,2017 */
+/* Contributors Listed Below - COPYRIGHT 2015,2018 */
/* [+] International Business Machines Corp. */
/* */
/* */
@@ -665,6 +665,7 @@ void* call_host_runtime_setup (void *io_pArgs)
}
}
+
// Fill in Hostboot runtime data for all nodes
// (adjunct partition)
// Write the HB runtime data into mainstore
@@ -677,6 +678,19 @@ void* call_host_runtime_setup (void *io_pArgs)
break;
}
+ // Open untrusted SP communication area if there is a PAYLOAD
+ // NOTE: Must be after all HDAT processing
+ if( !(TARGETING::is_no_load()) )
+ {
+ l_err = RUNTIME::openUntrustedSpCommArea();
+ if (l_err)
+ {
+ TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
+ "Failed openUntrustedSpCommArea" );
+ break;
+ }
+ }
+
} while(0);
if( l_err )
diff --git a/src/usr/runtime/hdatservice.C b/src/usr/runtime/hdatservice.C
index 721e9ccc9..3986efce6 100644
--- a/src/usr/runtime/hdatservice.C
+++ b/src/usr/runtime/hdatservice.C
@@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
-/* Contributors Listed Below - COPYRIGHT 2012,2017 */
+/* Contributors Listed Below - COPYRIGHT 2012,2018 */
/* [+] International Business Machines Corp. */
/* */
/* */
@@ -927,6 +927,31 @@ errlHndl_t hdatService::getHostDataSection( SectionId i_section,
o_dataSize = MDT_MAINSTORE_ADDR_SECTION_HYP_HB_COMM_ADDR_SIZE; // 8 bytes
}
+ // SPIRA-H CPU Controls
+ else if ( RUNTIME::CPU_CTRL == i_section )
+ {
+ // Find the right tuple and verify it makes sense
+ errhdl = getAndCheckTuple(i_section, tuple);
+ if( errhdl )
+ {
+ break;
+ }
+ TRACDCOMP( g_trac_runtime, "CPU_CTRL tuple=%p", tuple );
+
+ uint64_t base_addr = 0;
+ errhdl = getSpiraTupleVA(tuple, base_addr);
+ if( errhdl )
+ {
+ break;
+ }
+
+ TRACDCOMP( g_trac_runtime, "cpu_ctrl_data=%p", base_addr );
+
+ // set the base address and size for the section
+ record_size = tuple->hdatActualSize;
+ o_dataSize = record_size;
+ o_dataAddr = base_addr;
+ }
// Not sure how we could get here...
else
{
@@ -1506,6 +1531,10 @@ errlHndl_t hdatService::getAndCheckTuple(const SectionId i_section,
l_spiraS = SPIRAS_MDT;
l_spiraL = SPIRAL_MDT;
break;
+ case RUNTIME::CPU_CTRL:
+ l_spiraH = SPIRAH_CPU_CTRL;
+ l_spiraL = SPIRAL_CPU_CTRL;
+ break;
default:
TRACFCOMP(g_trac_runtime, ERR_MRK"getAndCheckTuple> section %d not supported",
i_section );
diff --git a/src/usr/runtime/hdatstructs.H b/src/usr/runtime/hdatstructs.H
index 78c057fde..29f23eac8 100644
--- a/src/usr/runtime/hdatstructs.H
+++ b/src/usr/runtime/hdatstructs.H
@@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
-/* Contributors Listed Below - COPYRIGHT 2012,2017 */
+/* Contributors Listed Below - COPYRIGHT 2012,2018 */
/* [+] International Business Machines Corp. */
/* */
/* */
@@ -418,4 +418,24 @@ struct hbHypCommArea_t
}
} PACKED;
+/** @brief The fields in the CPU Controls Legacy structure are a set of
+ * address / length pairs as shown below
+ */
+struct hdatCpuCtrlPair_t
+{
+ uint64_t address; // 0x0000 Absolute main store adress relative to HRMOR
+ uint64_t size; // 0x0008 Data structure size in bytes
+}__attribute__ ((packed));
+
+/** @brief CPU Controls Legacy Structure pointed to by the CPU Controls Header
+ * Area pointer in the CPU Controls
+ */
+struct hdatCpuCtrlInfo_t
+{
+ hdatCpuCtrlPair_t spAddrTable; // SP Address Table (SPAT)
+ hdatCpuCtrlPair_t spAttnArea1; // SP Attention Area 1
+ hdatCpuCtrlPair_t spAttnArea2; // SP Attention Area 2
+ hdatCpuCtrlPair_t servRoutineData; // Service Routines Data Area
+} __attribute__ ((packed));
+
#endif
diff --git a/src/usr/runtime/populate_hbruntime.C b/src/usr/runtime/populate_hbruntime.C
index f4d69694c..afd0a6b10 100644
--- a/src/usr/runtime/populate_hbruntime.C
+++ b/src/usr/runtime/populate_hbruntime.C
@@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
-/* Contributors Listed Below - COPYRIGHT 2016,2017 */
+/* Contributors Listed Below - COPYRIGHT 2016,2018 */
/* [+] International Business Machines Corp. */
/* */
/* */
@@ -75,6 +75,7 @@
#include <util/utilmclmgr.H>
#include <pnor/pnor_reasoncodes.H>
#include <runtime/common/runtime_utils.H>
+#include <limits.h>
namespace RUNTIME
{
@@ -2327,5 +2328,107 @@ errlHndl_t persistent_rwAttrRuntimeCheck( void )
return l_err;
} // end persistent_rwAttrRuntimeCheck
+errlHndl_t openUntrustedSpCommArea()
+{
+ TRACFCOMP( g_trac_runtime, ENTER_MRK "openUntrustedSpCommArea()");
+ errlHndl_t l_err = nullptr;
+
+ do {
+ TARGETING::Target * l_sys = nullptr;
+ TARGETING::targetService().getTopLevelTarget(l_sys);
+ assert(l_sys != nullptr, "openUntrustedSpCommArea: top level target nullptr");
+
+ // Get Payload HRMOR
+ uint64_t l_hrmor = l_sys->getAttr<TARGETING::ATTR_PAYLOAD_BASE>() * MEGABYTE;
+
+ // pass 0 since there is only one record
+ const uint64_t l_instance = 0;
+ uint64_t l_cpuCtrlDataAddr = 0;
+ size_t l_cpuCtrlDataSizeMax = 0;
+
+ // Get the address of the Spira-H CPU control section
+ l_err = RUNTIME::get_host_data_section( RUNTIME::CPU_CTRL,
+ l_instance,
+ l_cpuCtrlDataAddr,
+ l_cpuCtrlDataSizeMax);
+ if(l_err != nullptr)
+ {
+ TRACFCOMP( g_trac_runtime, ERR_MRK "openUntrustedSpCommArea(): get_host_data_section() failed for CPU_CTRL HDAT section");
+ break;
+ }
+
+ // Traverse CPU Controls Header Area pointer to find CPU Controls Structure
+ auto const l_pCpuCtrlHdr =
+ reinterpret_cast<hdatHDIF_t*>(l_cpuCtrlDataAddr);
+ auto const l_pCpuDataPointer =
+ reinterpret_cast<hdatHDIFDataHdr_t*>(l_cpuCtrlDataAddr +
+ l_pCpuCtrlHdr->hdatDataPtrOffset);
+ auto const l_pCpuCtrlInfo =
+ reinterpret_cast<hdatCpuCtrlInfo_t*>(l_cpuCtrlDataAddr +
+ l_pCpuDataPointer->hdatOffset);
+
+ // Get Address of First SP ATTN area and size of both SP ATTN areas
+ // Add HRMOR to address as it's relative to the HRMOR
+ uint64_t l_spAttnStartAddr = l_pCpuCtrlInfo->spAttnArea1.address + l_hrmor;
+ size_t l_spAttnCombinedSize = l_pCpuCtrlInfo->spAttnArea1.size +
+ l_pCpuCtrlInfo->spAttnArea2.size;
+
+ TRACFCOMP( g_trac_runtime, "openUntrustedSpCommArea() SP ATTN addr = 0x%016llx combined size 0x%X",
+ l_spAttnStartAddr,
+ l_spAttnCombinedSize);
+
+ // Open unsecure SBE memory regions
+ // Loop through all functional Procs
+ TARGETING::TargetHandleList l_procChips;
+ getAllChips(l_procChips, TARGETING::TYPE_PROC);
+ for (const auto & l_procChip : l_procChips)
+ {
+ // Get Instance ID of proc for trace
+ uint32_t l_id = l_procChip->getAttr<TARGETING::ATTR_HBRT_HYP_ID>();
+
+ // Open SP ATTN region
+ l_err = SBEIO::openUnsecureMemRegion(l_spAttnStartAddr,
+ l_spAttnCombinedSize,
+ true, //true=Read-Write
+ 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_spAttnStartAddr,
+ l_spAttnCombinedSize);
+ break;
+ }
+
+ // Only open additional SBE window in PHYP mode
+ if(TARGETING::is_phyp_load())
+ {
+ l_err = SBEIO::openUnsecureMemRegion(
+ RUNTIME::SP_HOST_UNTRUSTED_COMM_AREA_ADDR,
+ RUNTIME::SP_HOST_UNTRUSTED_COMM_AREA_SIZE,
+ true, //true=Read-Write
+ 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,
+ RUNTIME::SP_HOST_UNTRUSTED_COMM_AREA_ADDR,
+ RUNTIME::SP_HOST_UNTRUSTED_COMM_AREA_SIZE);
+ break;
+ }
+ }
+ }
+ if(l_err)
+ {
+ break;
+ }
+
+ } while(0);
+
+ TRACFCOMP( g_trac_runtime, EXIT_MRK"openUntrustedSpCommArea()");
+
+ return l_err;
+}
+
} //namespace RUNTIME
OpenPOWER on IntegriCloud