Message ID | 20190613151145.22243-2-raoni@linux.ibm.com |
---|---|
State | Superseded |
Delegated to: | Adhemerval Zanella Netto |
Headers |
Received: (qmail 43407 invoked by alias); 13 Jun 2019 15:11:58 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: <libc-alpha.sourceware.org> List-Unsubscribe: <mailto:libc-alpha-unsubscribe-##L=##H@sourceware.org> List-Subscribe: <mailto:libc-alpha-subscribe@sourceware.org> List-Archive: <http://sourceware.org/ml/libc-alpha/> List-Post: <mailto:libc-alpha@sourceware.org> List-Help: <mailto:libc-alpha-help@sourceware.org>, <http://sourceware.org/ml/#faqs> Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 43333 invoked by uid 89); 13 Jun 2019 15:11:57 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy=2019-05 X-HELO: mx0a-001b2d01.pphosted.com From: Raoni Fassina Firmino <raoni@linux.ibm.com> To: libc-alpha@sourceware.org Subject: [PATCH 1/4] powerpc: Fix static-linked version of __ppc_get_timebase_freq [BZ #24640] Date: Thu, 13 Jun 2019 12:11:42 -0300 In-Reply-To: <20190613151145.22243-1-raoni@linux.ibm.com> References: <20190613151145.22243-1-raoni@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit x-cbid: 19061315-0016-0000-0000-000009C2288F X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011255; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000286; SDB=6.01217420; UDB=6.00640188; IPR=6.00998531; MB=3.00027295; MTD=3.00000008; XFM=3.00000015; UTC=2019-06-13 15:11:50 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19061315-0017-0000-0000-000043A3A561 Message-Id: <20190613151145.22243-2-raoni@linux.ibm.com> |
Commit Message
Raoni Fassina Firmino
June 13, 2019, 3:11 p.m. UTC
From: Stan Shebs <stanshebs@google.com>
__ppc_get_timebase_freq() always return 0 when using static linked
glibc.
This is a minimal example.c to reproduce:
/******************************/
#include <inttypes.h>
#include <stdint.h>
#include <stdio.h>
#include <sys/platform/ppc.h>
int main() {
uint64_t freq = __ppc_get_timebase_freq();
printf("Time Base frequency = %"PRIu64" Hz\n", freq);
if (freq == 0)
return -1;
return 0;
}
/******************************/
Compile command: gcc -static example.c
This bug has been reproduced, fixed and tested on all powerpc platforms
(ppc32, ppc64 and ppc64le).
The underlying code of __ppc_get_timebase_freq uses __get_timebase_freq
that has a different implementation for shared and static version of
glibc. In the static version, there is an incorrect sense in the if
check for the fd returned when opening /proc/cpuinfo.
This solution is mostly a cherry-pick from:
commit 4791e4f773d060c1a37b27aac5b03cdfa9327afc
Author: Stan Shebs <stanshebs@google.com>
Date: Fri May 17 12:25:19 2019 -0700
Subject: Fix sense of a test in the static-linking version of ppc get_clockfreq
That is in branch glibc/google/grte/v5-2.27/master and was mentioned for
inclusion on master here:
https://www.sourceware.org/ml/libc-alpha/2019-05/msg00409.html
Adapted from original fix for get_clockfreq. That code was moved to
get_timebase_freq.
ChangeLog:
2019-06-13 Stan Shebs <stanshebs@google.com>
Raoni Fassina Firmino <raoni@linux.ibm.com>
[BZ #24640]
* sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c
[!SHARED] (__get_timebase_freq): Fix sense of a test in the
static-linking version.
---
sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On 13/06/2019 12:11, Raoni Fassina Firmino wrote: > From: Stan Shebs <stanshebs@google.com> > > __ppc_get_timebase_freq() always return 0 when using static linked > glibc. > > This is a minimal example.c to reproduce: > > /******************************/ > #include <inttypes.h> > #include <stdint.h> > #include <stdio.h> > #include <sys/platform/ppc.h> > > int main() { > uint64_t freq = __ppc_get_timebase_freq(); > printf("Time Base frequency = %"PRIu64" Hz\n", freq); > if (freq == 0) > return -1; > return 0; > } > /******************************/ > > Compile command: gcc -static example.c > > This bug has been reproduced, fixed and tested on all powerpc platforms > (ppc32, ppc64 and ppc64le). > > The underlying code of __ppc_get_timebase_freq uses __get_timebase_freq > that has a different implementation for shared and static version of > glibc. In the static version, there is an incorrect sense in the if > check for the fd returned when opening /proc/cpuinfo. > > This solution is mostly a cherry-pick from: > > commit 4791e4f773d060c1a37b27aac5b03cdfa9327afc > Author: Stan Shebs <stanshebs@google.com> > Date: Fri May 17 12:25:19 2019 -0700 > Subject: Fix sense of a test in the static-linking version of ppc get_clockfreq > > That is in branch glibc/google/grte/v5-2.27/master and was mentioned for > inclusion on master here: > > https://www.sourceware.org/ml/libc-alpha/2019-05/msg00409.html > > Adapted from original fix for get_clockfreq. That code was moved to > get_timebase_freq. > > ChangeLog: > > 2019-06-13 Stan Shebs <stanshebs@google.com> > Raoni Fassina Firmino <raoni@linux.ibm.com> > > [BZ #24640] > * sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c > [!SHARED] (__get_timebase_freq): Fix sense of a test in the > static-linking version. Please include the testcase [1] on this patch. LGTM with this change. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> [1] https://sourceware.org/ml/libc-alpha/2019-06/msg00285.html > --- > sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c b/sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c > index 23e7694d87..c245e97526 100644 > --- a/sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c > +++ b/sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c > @@ -39,7 +39,7 @@ __get_timebase_freq (void) > timebase : 33333333 > We search for this line and convert the number into an integer. */ > int fd = __open_nocancel ("/proc/cpuinfo", O_RDONLY); > - if (__glibc_likely (fd != -1)) > + if (__glibc_unlikely (fd == -1)) > return result; > > /* The timebase will be in the 1st 1024 bytes for systems with up >
diff --git a/sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c b/sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c index 23e7694d87..c245e97526 100644 --- a/sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c +++ b/sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c @@ -39,7 +39,7 @@ __get_timebase_freq (void) timebase : 33333333 We search for this line and convert the number into an integer. */ int fd = __open_nocancel ("/proc/cpuinfo", O_RDONLY); - if (__glibc_likely (fd != -1)) + if (__glibc_unlikely (fd == -1)) return result; /* The timebase will be in the 1st 1024 bytes for systems with up