From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 7176E1F55B for ; Tue, 19 May 2020 20:21:03 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 74AC5389546D; Tue, 19 May 2020 20:21:01 +0000 (GMT) Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.9]) by sourceware.org (Postfix) with ESMTPS id 41A793840C23 for ; Tue, 19 May 2020 20:20:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 41A793840C23 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: sourceware.org; spf=none smtp.mailfrom=lukma@denx.de Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 49RS211w94z1qs3p; Tue, 19 May 2020 22:20:57 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 49RS2118MBz1qtwr; Tue, 19 May 2020 22:20:57 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id rCmAj6w5Xhat; Tue, 19 May 2020 22:20:55 +0200 (CEST) X-Auth-Info: XLzV+4/ewaoCk354jskL7uQgYX8psJZo9hHT2N8o6Ic= Received: from jawa (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Tue, 19 May 2020 22:20:55 +0200 (CEST) Date: Tue, 19 May 2020 22:20:48 +0200 From: Lukasz Majewski To: Adhemerval Zanella Subject: Re: [PATCH v2 6/7] y2038: linux: Provide __ntp_gettime64 implementation Message-ID: <20200519222048.7e212556@jawa> In-Reply-To: <1cb96b4a-3e56-0b31-32f4-136be4d7ae10@linaro.org> References: <20200508145640.16336-1-lukma@denx.de> <20200508145640.16336-7-lukma@denx.de> <1cb96b4a-3e56-0b31-32f4-136be4d7ae10@linaro.org> Organization: denx.de X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; boundary="Sig_/+9mw7cjJ3K2Gu.G2Ux4Ecvm"; protocol="application/pgp-signature" X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Florian Weimer , GNU C Library , Andreas Schwab , Alistair Francis , Joseph Myers Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" --Sig_/+9mw7cjJ3K2Gu.G2Ux4Ecvm Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Hi Adhemerval, > On 08/05/2020 11:56, Lukasz Majewski wrote: > > This patch provides new __ntp_gettime64 explicit 64 bit function > > for getting time parameters via NTP interface. > >=20 > > Internally, the __clock_adjtime64 syscall is used instead of > > __adjtimex. This patch is necessary for having architectures with > > __WORDSIZE =3D=3D 32 Y2038 safe. > >=20 > > Moreover, a 32 bit version - __ntp_gettime has been refactored to > > internally use __ntp_gettime64. > >=20 > > The __ntp_gettime is now supposed to be used on systems still > > supporting 32 bit time (__TIMESIZE !=3D 64) - hence the necessary > > conversions between struct ntptimeval and 64 bit struct > > __ntptimeval64. > >=20 > > Build tests: > > ./src/scripts/build-many-glibcs.py glibcs > >=20 > > Run-time tests: > > - Run specific tests on ARM/x86 32bit systems (qemu): > > https://github.com/lmajewski/meta-y2038 and run tests: > > https://github.com/lmajewski/y2038-tests/commits/master > >=20 > > Above tests were performed with Y2038 redirection applied as well > > as without to test the proper usage of both __ntp_gettime64 and > > __ntp_gettime. =20 >=20 > Ok with a doubt below. >=20 > Reviewed-by: Adhemerval Zanella >=20 > > --- > > sysdeps/unix/sysv/linux/include/sys/timex.h | 4 ++++ > > sysdeps/unix/sysv/linux/ntp_gettime.c | 24 > > ++++++++++++++++++--- 2 files changed, 25 insertions(+), 3 > > deletions(-) > >=20 > > diff --git a/sysdeps/unix/sysv/linux/include/sys/timex.h > > b/sysdeps/unix/sysv/linux/include/sys/timex.h index > > e762e03230..ef53515803 100644 --- > > a/sysdeps/unix/sysv/linux/include/sys/timex.h +++ > > b/sysdeps/unix/sysv/linux/include/sys/timex.h @@ -33,6 +33,7 @@ > > libc_hidden_proto (__adjtimex) # define __clock_adjtime64 > > __clock_adjtime # define ___adjtimex64 ___adjtimex > > # define __ntptimeval64 ntptimeval > > +# define __ntp_gettime64 __ntp_gettime > > # else > > =20 > > struct __timex64 > > @@ -91,6 +92,9 @@ struct __ntptimeval64 > > long int __glibc_reserved3; > > long int __glibc_reserved4; > > }; > > +extern int __ntp_gettime64 (struct __ntptimeval64 *ntv); > > +libc_hidden_proto (__ntp_gettime64) > > + > > # endif > > =20 > > /* Convert a known valid struct timex into a struct __timex64. */ > > =20 >=20 > Ok. >=20 > > diff --git a/sysdeps/unix/sysv/linux/ntp_gettime.c > > b/sysdeps/unix/sysv/linux/ntp_gettime.c index > > c8d6a197dc..21aeffadeb 100644 --- > > a/sysdeps/unix/sysv/linux/ntp_gettime.c +++ > > b/sysdeps/unix/sysv/linux/ntp_gettime.c @@ -17,6 +17,7 @@ > > =20 > > #define ntp_gettime ntp_gettime_redirect > > =20 > > +#include > > #include > > =20 > > #undef ntp_gettime > > @@ -27,15 +28,32 @@ > > =20 > > =20 > > int > > -ntp_gettime (struct ntptimeval *ntv) > > +__ntp_gettime64 (struct __ntptimeval64 *ntv) > > { > > - struct timex tntx; > > + struct __timex64 tntx; > > int result; > > =20 > > tntx.modes =3D 0; > > - result =3D __adjtimex (&tntx); > > + result =3D __clock_adjtime64 (CLOCK_REALTIME, &tntx); > > ntv->time =3D tntx.time; > > ntv->maxerror =3D tntx.maxerror; > > ntv->esterror =3D tntx.esterror; > > return result; > > } =20 >=20 > Ok. Maybe add a comment stating that using CLOCK_REALTIME should > not make the function fail with EINVAL, ENODEV, or EOPNOTSUPP. > I am not sure about EPERM in this situation, should we check for > that and avoid seeting NTV in such situation? >=20 I will add following comment: /* Using the CLOCK_REALTIME with __clock_adjtime64 (as a replacement for Y2038 unsafe adjtimex) will not make the function fail with EINVAL, ENODEV, or EOPNOTSUPP. */ Regarding the EPERM: The adjtimex also could return EPERM: http://man7.org/linux/man-pages/man2/adjtimex.2.html which would be propagated to caller of ntp_gettime. In this case the ntv structure would get updated. If we want to preserve the same behavior, it would be correct to leave the code as is (and ntv would get updated anyway). > > + > > +#if __TIMESIZE !=3D 64 > > +libc_hidden_def (__ntp_gettime64) > > + > > +int > > +__ntp_gettime (struct ntptimeval *ntv) > > +{ > > + struct __ntptimeval64 ntv64; > > + int result; > > + > > + result =3D __ntp_gettime64 (&ntv64); > > + *ntv =3D valid_ntptimeval64_to_ntptimeval (ntv64); > > + > > + return result; > > +} > > +#endif > > +strong_alias (__ntp_gettime, ntp_gettime) > > =20 >=20 > Ok. Best regards, Lukasz Majewski -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de --Sig_/+9mw7cjJ3K2Gu.G2Ux4Ecvm Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEgAyFJ+N6uu6+XupJAR8vZIA0zr0FAl7EP6AACgkQAR8vZIA0 zr3dfwf9GfdOqfU+f45ZIKGJGoehkjFoxQzVvZ02t2GKOJkDwtd42RpU5yhpCTDd KBgjNTF7wMllSaDaGwhHoO1QhiIU1bu+S4cDDfzGYpKaijgGAeS7AsPSYSWRwB0e WACgVghcSdyjOnjC4jtxnZY0Ki6oubafKvhUb+H+5ME29wsIMeqAjfEtNvU5crz4 SRQn3I0sP4hJ3mad/nADKa/MHSwOsaskHL2Rc85JBcZ+22diuI/D2R8oPJGJT8bI wZ1Fe+WvLhi/z+Leb0cC4m6O4gG/F4SZE+dAzlI3n4//W74xGPk3JZJVHtFTUcLM jkJ8R9V+/u7k/yT+T4sefxAFqDXHCw== =CZak -----END PGP SIGNATURE----- --Sig_/+9mw7cjJ3K2Gu.G2Ux4Ecvm--