Bug 386397 - valgrind truncates powerpc timebase to 32-bits
Summary: valgrind truncates powerpc timebase to 32-bits
Status: CLOSED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: vex (show other bugs)
Version: 3.14 SVN
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-10-31 18:38 UTC by Carl Love
Modified: 2017-10-31 19:12 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Fix for reading the time base register (5.03 KB, patch)
2017-10-31 19:10 UTC, Carl Love
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Carl Love 2017-10-31 18:38:04 UTC
---Problem Description---
Valgrind is incorrectly modeling the PowerPC timebase register as 32-bit.  Should be 64-bit.  
 
---uname output---
Linux c650f07p23 4.11.0-42.el7a.ppc64le #1 SMP Mon Oct 9 12:00:22 EDT 2017 ppc64le ppc64le ppc64le GNU/Linux
 
Machine Type = 8335-GTC 
 
---Debugger---
A debugger is not configured
 
---Steps to Reproduce---
 Compile the following example using "gcc -o tb tb.c" and execute.  Without Valgrind, program will display timebase as 64-bit values.  With Valgrind, timebase will be limited to 32-bit values and the 2nd timebase printf may appear to be lesser than the first timebase printf.

#include <stdio.h>
#include <sys/platform/ppc.h>

int main(int argc, char** argv)
{
    uint64_t tb = __ppc_get_timebase();
    printf("timebase = %lx\n", tb);
    sleep(15);
    tb = __ppc_get_timebase();
    printf("timebase = %lx\n", tb);

    return 0;
}

 
Contact Information = Tom Gooding / tgooding@us.ibm.com 
 
Userspace tool common name: valgrind 
 
The userspace tool has the following bit modes: 64-bit 

Userspace rpm: valgrind-3.12.0-9.el7_4.ppc64le 

Userspace tool obtained from project website:  na 
 
*Additional Instructions for Tom Gooding / tgooding@us.ibm.com:
-Attach ltrace and strace of userspace application.

[reply] [-]
Internal Only
Comment 1 Thomas M. Gooding 2017-10-30 22:48:33 CDT

output:

bash-4.2$ ./tb
timebase = 3be626e90262
timebase = 3be7f0ad4167




bash-4.2$ valgrind ./tb
==89099== Memcheck, a memory error detector
==89099== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==89099== Using Valgrind-3.12.0 and LibVEX; rerun with -h for copyright info
==89099== Command: ./tb
==89099== 
timebase = 8ab00ec0
timebase = 552cacc9
==89099== 
==89099== HEAP SUMMARY:
==89099==     in use at exit: 0 bytes in 0 blocks
==89099==   total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==89099== 
==89099== All heap blocks were freed -- no leaks are possible
==89099== 
==89099== For counts of detected and suppressed errors, rerun with: -v
==89099== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)


Issue reported by  Thomas M. Gooding
Comment 1 Carl Love 2017-10-31 19:10:06 UTC
Created attachment 108657 [details]
Fix for reading the time base register
Comment 2 Carl Love 2017-10-31 19:11:54 UTC
Patch committed.

commit 6a55b1e82ccda3f0d663d2cc89eb543ae2d096bf
Author: Carl Love <carll@us.ibm.com>
Date:   Tue Oct 31 13:45:28 2017 -0500

    Fix access to time base register to return 64-bits.