public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Lukasz Majewski <lukma@denx.de>
To: Stepan Golosunov <stepan@golosunov.pp.ru>
Cc: Arnd Bergmann <arnd@arndb.de>,
	Deepa Dinamani <deepa.kernel@gmail.com>,
	libc-alpha@sourceware.org, Paul Eggert <eggert@cs.ucla.edu>,
	Joseph Myers <joseph@codesourcery.com>,
	John Stultz <john.stultz@linaro.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/6] y2038: linux: Provide __clock_settime64 implementation
Date: Sat, 20 Apr 2019 13:21:12 +0200	[thread overview]
Message-ID: <20190420132112.131f449b@jawa> (raw)
In-Reply-To: <20190420002009.l65upn2t3qqoj5uy@sghpc.golosunov.pp.ru>

[-- Attachment #1: Type: text/plain, Size: 2312 bytes --]

Hi Stepan,

> 15.04.2019 в 00:08:38 +0200 Lukasz Majewski написал:
> > +# if defined __NR_clock_settime64
> > +  /* Make sure that passed __timespec64 struct pad is 0.  */
> > +  struct __timespec64 ts = *tp;
> > +  ts.tv_pad = 0;
> > +  return INLINE_SYSCALL_CALL (clock_settime64, clock_id, &ts);  
> 
> Isn't kernel supposed to zero out padding on its own?
> At least comment in kernel's get_timespec64 says so:
> 
> 	/* Zero out the padding for 32 bit systems or in compat mode
> */ if (IS_ENABLED(CONFIG_64BIT_TIME) && in_compat_syscall())
> 		kts.tv_nsec &= 0xFFFFFFFFUL;
> 

For ARM (and x86) 32 bit machines I do use following syscalls (like
clock_settime64):
https://elixir.bootlin.com/linux/v5.1-rc4/source/arch/arm/tools/syscall.tbl#L420

which are providing 64 bit time support on 32 bit systems.

Yes. In those systems the upper part (32 bits) of tv_nsec is cleared up
with mask in the kernel. However, I would prefer not to pass random data
to the kernel, and hence I do clear it up explicitly in glibc.

> The code looks buggy though. It fails to zero out the padding in
> 32-bit kernels.

For the 32 bit systems without Y2038 support enabled in glibc - the
clock_settime would be used, which corresponds to sys_clock_settime32()
in the kernel.

> That part is probably broken since
> 98f76206b3350 ("compat: Cleanup in_compat_syscall() callers").
> 
> And, hmm, is CONFIG_64BIT_TIME enabled anywhere?

When I do use clock_settime64 on the glibc side (with _TIME_BITS=64), I
do not need to enable such config in the kernel. 

If the kernel supports this call (5.1+), then use it, otherwise
fallback to clock_settime().

For 64 bit systems, I do not change the execution path.

If you are interested, please look on the following repo (which has
some more commits than those posted to the mailing list):
https://github.com/lmajewski/y2038_glibc/commits/Y2038-2.29-glibc-__clock-internal-struct-timespec-v1

And meta layer for testing.

https://github.com/lmajewski/meta-y2038

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

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2019-04-20 11:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20190414220841.20243-1-lukma@denx.de>
     [not found] ` <20190414220841.20243-4-lukma@denx.de>
2019-04-20  0:20   ` [PATCH 3/6] y2038: linux: Provide __clock_settime64 implementation Stepan Golosunov
2019-04-20 11:21     ` Lukasz Majewski [this message]
2019-04-22  9:07       ` Stepan Golosunov
2019-04-22 21:45         ` Arnd Bergmann
2019-04-23 15:45           ` Lukasz Majewski
     [not found] ` <20190429104613.16209-1-lukma@denx.de>
     [not found]   ` <20190429104613.16209-3-lukma@denx.de>
     [not found]     ` <alpine.DEB.2.21.1904292138430.21580@digraph.polyomino.org.uk>
     [not found]       ` <20190430110505.2a0c7d1a@jawa>
     [not found]         ` <alpine.DEB.2.21.1905021431060.4027@digraph.polyomino.org.uk>
2019-05-05 14:10           ` [PATCH v2 2/7] y2038: Introduce __ASSUME_64BIT_TIME define Stepan Golosunov
2019-05-05 20:46             ` Lukasz Majewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190420132112.131f449b@jawa \
    --to=lukma@denx.de \
    --cc=arnd@arndb.de \
    --cc=deepa.kernel@gmail.com \
    --cc=eggert@cs.ucla.edu \
    --cc=john.stultz@linaro.org \
    --cc=joseph@codesourcery.com \
    --cc=libc-alpha@sourceware.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stepan@golosunov.pp.ru \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox