unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Joseph Myers <joseph@codesourcery.com>
To: Lukasz Majewski <lukma@denx.de>
Cc: <libc-alpha@sourceware.org>,
	Stepan Golosunov <stepan@golosunov.pp.ru>,
	Arnd Bergmann <arnd@arndb.de>, Paul Eggert <eggert@cs.ucla.edu>
Subject: Re: [PATCH v2 2/7] y2038: Introduce __ASSUME_64BIT_TIME define
Date: Thu, 2 May 2019 15:04:18 +0000	[thread overview]
Message-ID: <alpine.DEB.2.21.1905021431060.4027@digraph.polyomino.org.uk> (raw)
In-Reply-To: <20190430110505.2a0c7d1a@jawa>

On Tue, 30 Apr 2019, Lukasz Majewski wrote:

>  - The need for explicit clearing padding when calling syscalls (as to
>    be better safe than sorry in the future - there was related
>    discussion started by Stepan).

This really isn't a difficult question.  What it comes down to is whether 
the Linux kernel, in the first release version with these syscalls (we 
don't care about old -rc versions; what matters is the actual 5.1 
release), ignores the padding.

If 5.1 *release* ignores the padding, that is part of the kernel/userspace 
ABI, in accordance with the kernel principle of not breaking userspace.  
Thus, it is something userspace can rely on, now and in the future.

If 5.1 release does not ignore the padding, syscall presence does not mean 
the padding is ignored by the kernel and so glibc needs to clear padding.  
Of course, it needs to clear padding in a *copy* of the value provided by 
the user unless the glibc API in question requires the timespec value in 
question to be in writable memory.

So, which is (or will be) the case in 5.1 release?  Padding ignored or 
not?  If more complicated (ignored for some architectures / ABIs but not 
for others, or depending on whether compat syscalls are in use), then say 
so - give a precise description of the exact circumstances under which the 
padding around a 32-bit tv_nsec will or will not be ignored by the kernel 
on input from userspace.

(x32 is a separate matter, as it already has 64-bit times, and a 
non-POSIX-conforming tv_nsec, so this patch series just needs to avoid 
breaking anything that currently works there.  Any fix for bug 16437 would 
need to involve clearing padding in userspace, unless not only the kernel 
changes to ignore that padding but all kernel versions without such a 
change cease to be supported by glibc for x32.)

> You are right here - the 
> 
> #if __TIMESIZE != 64
> # if __LINUX_KERNEL_VERSION >= 0x050100
> #  define __ASSUME_64BIT_TIME 1
> # endif
> #endif
> 
> would do the trick.

But that wouldn't be right for *future* configurations where the kernel 
"long" is 32-bit but only 64-bit time is supported in the kernel and glibc 
(so __TIMESIZE is 64, and only the new syscalls and not the old ones are 
supported).  That is, the right abstraction here is not really __TIMESIZE.

It's possible it's __SYSCALL_WORDSIZE, except that's only defined for 
x86_64, so would need to be made more generally available if it's to be 
used here.  And if made more generally available, it would need a careful 
comment explaining exactly what it means.

> 1. The __ASSUME_64BIT_TIME is _never_ defined for 64 bit native systems
> 
> 2. It is defined by default in:
> sysdeps/unix/sysv/linux/kernel-features.h for 32 bit systems (and the

It would be best to avoid descriptions such as "64 bit native systems" and 
"32 bit systems" when defining the relevant abstractions, because they are 
simply too ambiguous in this context, where one of the key thing to do is 
to make the semantics obvious in cases that have some attributes of 32-bit 
systems and other attributes of 64-bit systems.

We have configurations such as x32 and MIPS n32 which have 64-bit 
registers but 32-bit "long" and pointers.  Are those 64-bit or 32-bit?  As 
far as glibc's definition of __WORDSIZE is concerned, they are 32-bit; 
__WORDSIZE is the size in bits of long and pointers.  As far as optimized 
code working one word at a time is concerned (libm functions, string 
functions, etc.), they are best considered 64-bit, because of the 64-bit 
registers.  For the present issue, they are *different* from each other: 
x32 does not have the new syscalls (it already had 64-bit times), n32 does 
have the new syscalls (it previously had 32-bit times).

Again, I think the size of __syscall_slong_t is probably what's relevant.  
Note that "size of long for syscalls" (which is 64-bit for x32 but 32-bit 
for n32) is *not* the same thing as "size passed in a single register for 
syscalls" (n32 passes 64-bits values in a single register to syscalls, on 
the principle of keeping the ABI for those similar to that for normal 
function calls; but there have been more recent suggestions in the kernel 
context - I don't know the conclusion from them - of whether future such 
ILP32 ABIs with 64-bit registers should be more similar to the ABIs using 
32-bit registers, to allow compat syscall code to be used for them more 
consistently).

> As those syscalls are provided on almost every 32 bit system now
> (5.1-rc6):
> git grep -n "clock_settime64"
> 
> gives support for: arm, arm64 (compat mode), m68k, microblaze, mips,
> parisc, powerpc, s390, sh, sparc, x86, xtensa
> 
> So it would be reasonable to just add this __ASSUME definition code to
> sysdeps/unix/sysv/linux/kernel-features.h and #undef it for
> architectures not supporting it (i.e. c-sky and riscv).

No, that's not accurate.  Newer architectures (such as csky and riscv) use 
the asm-generic syscall table and so get these syscalls automatically if 
__BITS_PER_LONG == 32.  So it would be wrong to #undef in those cases.

When checking each glibc architecture / ABI combination, to see if the 
syscalls are present in the kernel, you need to allow for some 
architectures using asm-generic (which means that for such architectures 
you only need to check the generic logic, then look at any compat syscall 
tables, such as for arm on arm64).  For architectures not using 
asm-generic you need to check the per-architecture syscalls tables for 
each relevant ABI.

-- 
Joseph S. Myers
joseph@codesourcery.com

  parent reply	other threads:[~2019-05-02 15:04 UTC|newest]

Thread overview: 111+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-14 22:08 [PATCH 0/6] y2038: Linux: Provide __clock_* functions supporting 64 bit time Lukasz Majewski
2019-04-14 22:08 ` [PATCH 1/6] y2038: Introduce internal for glibc struct __timespec64 Lukasz Majewski
2019-04-14 22:08 ` [PATCH 2/6] y2038: Provide conversion helpers for " Lukasz Majewski
2019-04-14 22:08 ` [PATCH 3/6] y2038: linux: Provide __clock_settime64 implementation Lukasz Majewski
2019-04-17 22:08   ` Joseph Myers
2019-04-18  6:46     ` Lukasz Majewski
2019-04-20  0:20   ` Stepan Golosunov
2019-04-20 11:21     ` Lukasz Majewski
2019-04-22  9:07       ` Stepan Golosunov
2019-04-22 21:45         ` Arnd Bergmann
2019-04-23 15:45           ` Lukasz Majewski
2019-04-14 22:08 ` [PATCH 4/6] y2038: linux: Provide __clock_getres64 implementation Lukasz Majewski
2019-04-14 22:08 ` [PATCH 5/6] y2038: linux: Provide __clock_gettime64 implementation Lukasz Majewski
2019-04-14 22:08 ` [PATCH 6/6] y2038: linux: Provide __clock_nanosleep64 implementation Lukasz Majewski
2019-04-17 22:11   ` Joseph Myers
2019-04-18  5:54     ` Lukasz Majewski
2019-04-29 10:46 ` [PATCH v2 0/7] y2038: Linux: Provide __clock_* functions supporting 64 bit time Lukasz Majewski
2019-04-29 10:46   ` [PATCH v2 1/7] y2038: Introduce internal for glibc struct __timespec64 Lukasz Majewski
2019-04-29 10:46   ` [PATCH v2 2/7] y2038: Introduce __ASSUME_64BIT_TIME define Lukasz Majewski
2019-04-29 21:50     ` Joseph Myers
2019-04-30  9:05       ` Lukasz Majewski
2019-04-30 21:47         ` Stepan Golosunov
2019-05-02  8:51           ` Lukasz Majewski
2019-05-02 11:54             ` Stepan Golosunov
2019-05-02 13:55               ` Lukasz Majewski
2019-05-06 13:38                 ` Lukasz Majewski
2019-05-06 14:26                   ` Lukasz Majewski
2019-05-06 19:36                     ` Stepan Golosunov
2019-05-06 21:14                       ` Lukasz Majewski
2019-05-07 20:03                         ` Stepan Golosunov
2019-05-07 20:44                           ` Joseph Myers
2019-05-08  7:51                           ` Lukasz Majewski
2019-05-08 19:48                             ` Stepan Golosunov
2019-05-09 16:12                               ` Joseph Myers
2019-05-16  4:00                               ` Arnd Bergmann
2019-05-16 19:54                                 ` Stepan Golosunov
2019-05-16 19:59                                 ` Joseph Myers
2019-05-17  7:23                                   ` Florian Weimer
2019-05-17  8:34                                     ` Arnd Bergmann
2019-05-07 15:43                       ` Joseph Myers
2019-05-02 15:04         ` Joseph Myers [this message]
2019-05-05 14:10           ` Stepan Golosunov
2019-05-05 20:46             ` Lukasz Majewski
2019-05-06 14:56           ` Lukasz Majewski
2019-05-07 15:35             ` Joseph Myers
2019-05-08 10:18               ` Lukasz Majewski
2019-05-09 15:46                 ` Joseph Myers
2019-05-15 15:39                   ` Lukasz Majewski
2019-05-16  3:57                     ` Arnd Bergmann
2019-05-16  6:58                       ` Lukasz Majewski
2019-05-31 11:37                 ` Stepan Golosunov
2019-06-05 16:35                   ` Lukasz Majewski
2019-06-06  6:50                     ` Stepan Golosunov
2019-04-29 10:46   ` [PATCH v2 3/7] y2038: Provide conversion helpers for struct __timespec64 Lukasz Majewski
2019-05-02 11:56     ` Stepan Golosunov
2019-05-02 14:17       ` Lukasz Majewski
2019-05-02 15:59         ` Joseph Myers
2019-05-02 16:19           ` Lukasz Majewski
2019-04-29 10:46   ` [PATCH v2 4/7] y2038: linux: Provide __clock_settime64 implementation Lukasz Majewski
2019-04-29 10:46   ` [PATCH v2 5/7] y2038: linux: Provide __clock_getres64 implementation Lukasz Majewski
2019-04-29 10:46   ` [PATCH v2 6/7] y2038: linux: Provide __clock_gettime64 implementation Lukasz Majewski
2019-04-29 10:46   ` [PATCH v2 7/7] y2038: linux: Provide __clock_nanosleep64 implementation Lukasz Majewski
2019-05-07 13:18 ` [PATCH v3 0/5] y2038: Linux: Provide __clock_settime function supporting 64 bit time Lukasz Majewski
2019-05-07 13:18   ` [PATCH v3 1/5] y2038: Introduce __ASSUME_TIME64_SYSCALLS define Lukasz Majewski
2019-05-07 16:04     ` Joseph Myers
2019-05-07 13:18   ` [PATCH v3 2/5] y2038: Introduce internal for glibc struct __timespec64 Lukasz Majewski
2019-05-07 13:30     ` Andreas Schwab
2019-05-07 14:07       ` Lukasz Majewski
2019-05-07 14:13         ` Andreas Schwab
2019-05-08  8:32           ` Lukasz Majewski
2019-05-08  8:38             ` Andreas Schwab
2019-05-08  9:10               ` Lukasz Majewski
2019-05-08  9:12                 ` Andreas Schwab
2019-05-08  9:37                   ` Lukasz Majewski
2019-05-07 13:18   ` [PATCH v3 3/5] y2038: Provide conversion helpers for " Lukasz Majewski
2019-05-07 13:18   ` [PATCH v3 4/5] y2038: linux: Provide __clock_settime64 implementation Lukasz Majewski
2019-05-07 16:40     ` Joseph Myers
2019-05-07 13:18   ` [PATCH v3 5/5] y2038: Support for Y2038 safe time on 32 bit systems Lukasz Majewski
2019-05-07 16:37     ` Joseph Myers
2019-05-08 10:27       ` Lukasz Majewski
2019-05-07 13:18   ` [PATCH v3 0/5] y2038: Linux: Provide __clock_settime function supporting 64 bit time Lukasz Majewski
2019-05-07 13:18   ` [PATCH v3 1/5] y2038: Introduce __ASSUME_TIME64_SYSCALLS define Lukasz Majewski
2019-05-07 13:18   ` [PATCH v3 2/5] y2038: Introduce internal for glibc struct __timespec64 Lukasz Majewski
2019-05-07 13:18   ` [PATCH v3 3/5] y2038: Provide conversion helpers for " Lukasz Majewski
2019-05-07 13:18   ` [PATCH v3 4/5] y2038: linux: Provide __clock_settime64 implementation Lukasz Majewski
2019-05-07 13:18   ` [PATCH v3 5/5] y2038: Support for Y2038 safe time on 32 bit systems Lukasz Majewski
2019-05-07 13:34     ` Andreas Schwab
2019-05-08 15:56 ` [PATCH] y2038: Introduce __ASSUME_TIME64_SYSCALLS define Lukasz Majewski
2019-05-09 15:58   ` Joseph Myers
2019-05-09 16:18     ` Stepan Golosunov
2019-05-15 14:27 ` [PATCH v5] " Lukasz Majewski
2019-05-21 15:15   ` Lukasz Majewski
2019-05-23  7:34   ` Stepan Golosunov
2019-05-23  9:35     ` Lukasz Majewski
2019-05-25 16:19       ` Lukasz Majewski
2019-05-25 19:45       ` Stepan Golosunov
2019-05-26 12:39         ` Lukasz Majewski
2019-05-28 16:00           ` Lukasz Majewski
2019-05-28 19:53           ` Joseph Myers
2019-05-28 22:46             ` Lukasz Majewski
2019-05-28 22:50               ` Joseph Myers
2019-05-28 19:47         ` Joseph Myers
2019-05-28 22:09           ` Lukasz Majewski
2019-05-28 22:43             ` Joseph Myers
2019-05-23 21:17     ` Joseph Myers
2019-05-20 10:27 ` [PATCH v4 0/3] y2038: Linux: Provide __clock_settime64 function supporting 64 bit time Lukasz Majewski
2019-05-20 10:27   ` [PATCH v4 1/3] y2038: Introduce internal for glibc struct __timespec64 Lukasz Majewski
2019-05-20 10:27   ` [PATCH v4 2/3] y2038: Provide conversion helpers for " Lukasz Majewski
2019-05-20 10:27   ` [PATCH v4 3/3] y2038: linux: Provide __clock_settime64 implementation Lukasz Majewski
2019-05-23  7:08     ` Stepan Golosunov
2019-05-23  9:28       ` 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

  List information: https://www.gnu.org/software/libc/involved.html

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

  git send-email \
    --in-reply-to=alpine.DEB.2.21.1905021431060.4027@digraph.polyomino.org.uk \
    --to=joseph@codesourcery.com \
    --cc=arnd@arndb.de \
    --cc=eggert@cs.ucla.edu \
    --cc=libc-alpha@sourceware.org \
    --cc=lukma@denx.de \
    --cc=stepan@golosunov.pp.ru \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).