From patchwork Tue Aug 12 23:45:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 2377 Received: (qmail 8858 invoked by alias); 12 Aug 2014 23:45:57 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 8848 invoked by uid 89); 12 Aug 2014 23:45:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Date: Tue, 12 Aug 2014 23:45:47 +0000 From: "Joseph S. Myers" To: CC: Adhemerval Zanella Subject: Fix powerpc32 __get_clockfreq for non-power4 (bug 17263) Message-ID: MIME-Version: 1.0 In my powerpc32 testing I've observed misc/test-gettimebasefreq failing. This is a glibc build (soft-float, though that's not relevant here) without any --with-cpu and without any special configuration of the default CPU for GCC either. In particular, it's one not using sysdeps/powerpc/powerpc32/power4/hp-timing.h (although in fact the processor I'm using for testing is POWER4-based), so hp_timing_t is 32-bit not 64-bit. But the VDSO call being used by INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK is generating a 64-bit result (high part in r3, low part in r4). The code extracting that result, however, expects a result of the type hp_timing_t as passed to INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK, meaning that only r3 (= 0) is used and the value in r4 is ignored. This patch fixes this by always using uint64_t as the type in INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK - reflecting the actual ABI (unconditional in the kernel) of that VDSO call. This is the minimal change for this issue - no check for overflow, no change of the type of the timebase_freq variable or the return type of __get_clockfreq to something other than hp_timing_t (such a change would simply move the implicit conversions to the over callers of that function), no change to hp_timing_t itself. Tested for powerpc32 soft float. 2014-08-12 Joseph Myers [BZ #17263] * sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c: Include . (__get_clockfreq): Use uint64_t instead of hp_timing_t in INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK call. diff --git a/sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c b/sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c index 8b37943..62217b1 100644 --- a/sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c +++ b/sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -42,7 +43,7 @@ __get_clockfreq (void) #ifdef SHARED INTERNAL_SYSCALL_DECL (err); timebase_freq = - INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK (get_tbfreq, err, hp_timing_t, 0); + INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK (get_tbfreq, err, uint64_t, 0); if (INTERNAL_SYSCALL_ERROR_P (timebase_freq, err) && INTERNAL_SYSCALL_ERRNO (timebase_freq, err) == ENOSYS) #endif