From 1c5f03e47872183ec9c29f75a724b73279b4a3da Mon Sep 17 00:00:00 2001 From: Christian Geddes Date: Wed, 20 Mar 2019 17:41:45 -0500 Subject: 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: http://rchgit01.rchland.ibm.com/gerrit1/74823 Reviewed-by: Matt Derksen Reviewed-by: Corey V. Swenson Tested-by: Jenkins OP HW Tested-by: FSP CI Jenkins Reviewed-by: Daniel M. Crowell --- src/runtime/rt_time.C | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/runtime') 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 #include +#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; } -- cgit v1.2.1