From f77b89e3527e40da04b9889f64562e20b620cc12 Mon Sep 17 00:00:00 2001 From: Benjamin Weisenbeck Date: Mon, 30 Oct 2017 11:26:14 -0500 Subject: Adjust ATTR_PEER_TARGET values for runtime At runtime init, translate ATTR_PEER_TARGET target addresses to runtime values. Change-Id: I4f04aabd0c5939cd0a9d80c6c0528e5a7828f5ab CQ:SW404028 Backport: op910 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/48997 Tested-by: Jenkins Server Tested-by: Jenkins OP Build CI Tested-by: Jenkins OP HW Tested-by: FSP CI Jenkins Reviewed-by: Daniel M. Crowell --- src/usr/targeting/runtime/start_rt.C | 74 +++++++++++++++++++++++++++++++++++- 1 file changed, 73 insertions(+), 1 deletion(-) (limited to 'src/usr') diff --git a/src/usr/targeting/runtime/start_rt.C b/src/usr/targeting/runtime/start_rt.C index d2c3d7ffa..7693b93e5 100644 --- a/src/usr/targeting/runtime/start_rt.C +++ b/src/usr/targeting/runtime/start_rt.C @@ -26,9 +26,15 @@ #include #include #include +#include +#include -namespace TARGETING +using namespace TARGETING; + +namespace RT_TARG { + void adjustTargeting4Runtime(); + static void initTargeting() __attribute__((constructor)); static void initTargeting() { @@ -44,7 +50,73 @@ namespace TARGETING TargetService& l_targetService = targetService(); (void)l_targetService.init(); + adjustTargeting4Runtime(); + // set global that TARG is ready Util::setIsTargetingLoaded(); } + + // Make any adjustments needed to targeting for runtime + void adjustTargeting4Runtime() + { + TRACDCOMP(g_trac_targeting,"adjustTargeting4Runtime"); + + // Loop through all targets and fix those with ATTR_PEER_TARGETs. + // + // ATTR_PEER_TARGET is the only attribute using the Target_t type. + // The value of a Target_t attribute is a Target * "pointer" to + // another target. The value is set up by the targeting scripts at + // build time. Targeting uses a translate function to nagivate through + // the targeting binary. There is a runtime translation function used + // at run time to account for the location of the targeting binary + // being at a different spot at runtime. The Target_t * value of + // the attribute remains pointing into where the targeting binary + // was at IPL. Using this "old" address would seg fault at run time. + // The value of the ATTR_PEER_TARGET attributes must be translated + // for run time. + // The _trySetAttr is used directly to avoid the trySetAttr template + // error check that ATTR_PEER_TARGET is only readable, not writable. + // adjustTargeting4Runtime has been included as a friend to allow + // access to the private target class methods. + const Target* l_pUnused = NULL; + size_t l_xlateCnt = 0; + for (TargetIterator target = targetService().begin(); + target != targetService().end(); + ++target) + { + const TARGETING::Target * l_target = *target; + TARGETING::Target * l_peer = static_cast(NULL); + bool l_hasPeer = l_target->tryGetAttr(l_peer); + if (l_hasPeer) + { + TRACDCOMP(g_trac_targeting, + "translate peer target for=%p %x", + l_target, get_huid(l_target)); + + ATTR_PEER_TARGET_type l_xlated = (TARGETING::Target *) + Singleton::instance(). + AttrRP::translateAddr(l_peer,l_pUnused); + bool l_fixed = false; + l_fixed = l_target->_trySetAttr(ATTR_PEER_TARGET, + sizeof(l_xlated), + &l_xlated); + if (l_fixed) + { + TRACDCOMP(g_trac_targeting, " to=%p", l_xlated); + l_xlateCnt++; + } + // Not good if could not be fixed. But might not be referenced. + // A segment fault will occur if used. + else + { + TRACFCOMP(g_trac_targeting, + "failed to translate peer target HUID=0x%x", + get_huid(l_target)); + } + } + } + TRACFCOMP(g_trac_targeting, + "adjustTargeting4Runtime: %d peer target addresses translated", + l_xlateCnt); + } } -- cgit v1.2.1