diff options
-rw-r--r-- | src/include/usr/runtime/runtime.H | 12 | ||||
-rw-r--r-- | src/usr/isteps/istep21/call_host_runtime_setup.C | 33 | ||||
-rw-r--r-- | src/usr/runtime/hdatservice.C | 34 |
3 files changed, 68 insertions, 11 deletions
diff --git a/src/include/usr/runtime/runtime.H b/src/include/usr/runtime/runtime.H index 798b15807..855ef86ac 100644 --- a/src/include/usr/runtime/runtime.H +++ b/src/include/usr/runtime/runtime.H @@ -264,6 +264,18 @@ void rediscover_hdat( void ); */ errlHndl_t openUntrustedSpCommArea(); +/** + * @brief Locates the offset of the HDAT structure as directed by the PAYLOAD + * + * Walks the NACA in the PAYLOAD to find the SpiraH structure. The SpiraH + * structure contains the offset to the SpiraS structure which is where the + * PAYLOAD expects the HDAT structure to be placed. + * + * @param[in] payloadBase_va - Virtual Address pointing to start of PAYLOAD + * @param[out] o_hdat_offset - Offset of HDAT Location from start of PAYLOAD + */ +void findHdatLocation(uint64_t payloadBase_va, uint64_t& o_hdat_offset); + } #endif diff --git a/src/usr/isteps/istep21/call_host_runtime_setup.C b/src/usr/isteps/istep21/call_host_runtime_setup.C index b91e83fd3..056de3191 100644 --- a/src/usr/isteps/istep21/call_host_runtime_setup.C +++ b/src/usr/isteps/istep21/call_host_runtime_setup.C @@ -258,18 +258,9 @@ errlHndl_t verifyAndMovePayload(void) payload_tmp_virt_addr, payload_size); - // Move HDAT temporarily put into HDAT_TMP_ADDR (HDAT_TMP_SIZE) into - // its proper place - // @TODO RTC 168745 - Update hdatservices calls to return Spira-S offset - // Currently just using this known offset 80MB=0x5000000 used in current - // PHYP images and then adding 1 PAGESIZE since our virtual address starts - // at the secure header of PAYLOAD before PAYLOAD_BASE - size_t hdat_cpy_offset = 0x5001000; - if (!is_phyp) - { - hdat_cpy_offset = 0x31200000; - } + // Move HDAT into its proper place after it was temporarily put into + // HDAT_TMP_ADDR (HDAT_TMP_SIZE) by the FSP via TCEs hdat_tmp_virt_addr = mm_block_map( reinterpret_cast<void*>(HDAT_TMP_ADDR), HDAT_TMP_SIZE); @@ -286,6 +277,26 @@ errlHndl_t verifyAndMovePayload(void) break; } + // Determine location of HDAT from NACA section of PAYLOAD + uint64_t hdat_cpy_offset = 0; + + // 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 ); + + RUNTIME::findHdatLocation(payloadBase_va, hdat_cpy_offset); + + // 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", + hdat_cpy_offset); + hdat_final_virt_addr = mm_block_map( reinterpret_cast<void*>(payloadBase + hdat_cpy_offset), diff --git a/src/usr/runtime/hdatservice.C b/src/usr/runtime/hdatservice.C index 3986efce6..4fd752653 100644 --- a/src/usr/runtime/hdatservice.C +++ b/src/usr/runtime/hdatservice.C @@ -1772,6 +1772,40 @@ errlHndl_t clear_host_data_section(const RUNTIME::SectionId i_section) return Singleton<hdatService>::instance().clearHostDataSection(i_section); } + +void findHdatLocation(const uint64_t i_payloadBase_va, uint64_t& o_hdat_offset) +{ + + TRACFCOMP( g_trac_runtime, ENTER_MRK"findHdatLocation> i_payloadBase_va = 0x%.16llX", i_payloadBase_va); + + do { + + // Everything starts at the NACA + // The NACA is part of the platform dependent LID which + // is loaded at relative memory address 0x0 + const hdatNaca_t* naca = reinterpret_cast<const hdatNaca_t*> + (HDAT_NACA_OFFSET + i_payloadBase_va); + TRACFCOMP( g_trac_runtime, "findHdatLocation> NACA=0x%.X->0x%p", HDAT_NACA_OFFSET, naca ); + + // Find SpiraH information in NACA + const hdatSpira_t* spiraH = reinterpret_cast<const hdatSpira_t*> + (naca->spiraH + i_payloadBase_va); + TRACFCOMP( g_trac_runtime, "findHdatLocation> SPIRA-H=0x%X->0x%p", naca->spiraH, spiraH ); + + // SPIRA-S is at the beginning of the Host Data Area Tuple of SpiraH + const hdat5Tuple_t* tuple = reinterpret_cast<const hdat5Tuple_t*> + (&(spiraH->hdatDataArea[SPIRAH_HOST_DATA_AREAS])); + TRACFCOMP( g_trac_runtime, "findHdatLocation> SPIRA-S tuple at 0x%p, tuple->hdatAbsAddr=0x%X", tuple, tuple->hdatAbsAddr ); + + o_hdat_offset = tuple->hdatAbsAddr; + + } while (0); + + TRACFCOMP( g_trac_runtime, EXIT_MRK"findHdatLocation> o_hdat_offset = 0x%X", o_hdat_offset); + +} + + }; void hdatMsVpdRhbAddrRange_t::set(const HDAT::hdatMsVpdRhbAddrRangeType i_type, |