summaryrefslogtreecommitdiffstats
path: root/src/usr
diff options
context:
space:
mode:
authorBenjamin Weisenbeck <bweisenb@us.ibm.com>2017-10-30 11:26:14 -0500
committerDaniel M. Crowell <dcrowell@us.ibm.com>2017-10-31 12:50:39 -0400
commitf77b89e3527e40da04b9889f64562e20b620cc12 (patch)
treec2fc9adc281d0f25184f4d9e5039c90e06a47868 /src/usr
parent69b2391ad8854f1103653b8473cd2aad5ddab099 (diff)
downloadtalos-hostboot-f77b89e3527e40da04b9889f64562e20b620cc12.tar.gz
talos-hostboot-f77b89e3527e40da04b9889f64562e20b620cc12.zip
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 <pfd-jenkins+hostboot@us.ibm.com> Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com> Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com> Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com> Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src/usr')
-rw-r--r--src/usr/targeting/runtime/start_rt.C74
1 files changed, 73 insertions, 1 deletions
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 <targeting/common/targetservice.H>
#include <targeting/attrrp.H>
#include <util/misc.H>
+#include <targeting/common/trace.H>
+#include <targeting/common/utilFilter.H>
-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<Target*>(NULL);
+ bool l_hasPeer = l_target->tryGetAttr<ATTR_PEER_TARGET>(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<AttrRP>::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);
+ }
}
OpenPOWER on IntegriCloud