path: root/src/runtime
diff options
authorChristian Geddes <>2019-03-20 17:41:45 -0500
committerDaniel M. Crowell <>2019-03-26 16:57:44 -0500
commit1c5f03e47872183ec9c29f75a724b73279b4a3da (patch)
tree423e9751d07877ab626dcfb04761dbb927110ec8 /src/runtime
parent17930bb348b5e6aa0a93627b52b5f4e3556c5520 (diff)
Fix bug that was scrambling traces in errorlogs during HBRT
There was a bug in how HB was interpreting the clock time that PHYP returned in response to a get_clocktime request. The nsec member of the struct returned was getting the first 32bits filled in and Hostboot was expecting the value to be in the last 32bits. This change will shift the nsec value down 4 bytes if we find the back half of the nsec value to be all 0's. I believe the reason the wrong bits were filled in is because PHYP is returning a packed struct whose 2nd member is a 32 bit value so it does not get filled in correctly. Change-Id: I71f1c2cb672b9979e0b6bdc8b1852544f230b885 CQ: SW448397 Reviewed-on: Reviewed-by: Matt Derksen <> Reviewed-by: Corey V. Swenson <> Tested-by: Jenkins OP HW <> Tested-by: FSP CI Jenkins <> Reviewed-by: Daniel M. Crowell <>
Diffstat (limited to 'src/runtime')
1 files changed, 12 insertions, 0 deletions
diff --git a/src/runtime/rt_time.C b/src/runtime/rt_time.C
index e222a3718..66032586a 100644
--- a/src/runtime/rt_time.C
+++ b/src/runtime/rt_time.C
@@ -25,6 +25,8 @@
#include <sys/time.h>
#include <runtime/interface.h>
+#define BITS_32_TO_63_MASK 0x00000000FFFFFFFF
void nanosleep(uint64_t sec, uint64_t nsec)
if (g_hostInterfaces && g_hostInterfaces->nanosleep)
@@ -36,9 +38,19 @@ void nanosleep(uint64_t sec, uint64_t nsec)
int clock_gettime(clockid_t i_clkId, timespec_t* o_tp)
int l_rc = -1;
if (g_hostInterfaces && g_hostInterfaces->clock_gettime)
l_rc = g_hostInterfaces->clock_gettime(i_clkId, o_tp);
+ // If the back-half (bits 32:63) are all 0's then the
+ // nanoseconds are stored in the first 32 bits of the tv_nsec
+ // member of the timespec_t struct. We must shift over so later
+ // hostboot code interprets this correctly
+ if( (o_tp->tv_nsec & BITS_32_TO_63_MASK) == 0x0)
+ {
+ o_tp->tv_nsec = o_tp->tv_nsec >> 32;
+ }
return l_rc;
OpenPOWER on IntegriCloud