public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: Rich Felker <dalias@libc.org>
Cc: "H.J. Lu via Libc-alpha" <libc-alpha@sourceware.org>
Subject: Re: [PATCH v2] linux: Use 'long int' for timespec tv_nsec on x32 (BZ #16437)
Date: Sat, 11 Dec 2021 19:50:06 +0100	[thread overview]
Message-ID: <87bl1n2cyp.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <20211211000844.GB7074@brightrain.aerifal.cx> (Rich Felker's message of "Fri, 10 Dec 2021 19:08:45 -0500")

* Rich Felker:

> On Fri, Dec 10, 2021 at 04:44:46PM +0100, Florian Weimer via Libc-alpha wrote:
>> * H. J. Lu via Libc-alpha:
>> 
>> > On Fri, Dec 10, 2021 at 3:03 AM Adhemerval Zanella via Libc-alpha
>> > <libc-alpha@sourceware.org> wrote:
>> >>
>> >> Although the kernel ABI uses 64-bit (so it can re-use the syscall
>> >> logic from x86_64), POSIX states the type to be 'long int'.  It
>> >> requires to explicit signal extend the value on syscalls that
>> >> take the value to avoid requiring bumping the minimum kernel version
>> >> (ea2ce8f3514e ("time: Fix get_timespec64() for y2038 safe compat
>> >> interfaces") got merged into v4.18, futex and recvmsg followed in v5.1,
>> >> but v5.6 is considered 'complete').
>> >>
>> >> The fix uses 'long long int' array to represent 'struct timespec',
>> >> since it allows a simpler code than define a kernel specific timespec.
>> >>
>> >> There is no need to compat symbol, the now high-bits are not used
>> >> to represent the nanoseconds and for some syscalls it only issues
>> >> an error (which hardly indicates the need of compat symbol).
>> >>
>> >> Checked on x86_64-linux-gnu-x32 with kernel 4.4.0 and 5.13.
>> >
>> > Isn't it an ABI change for x32?
>> 
>> I agree.  I said so repeatedly.
>
> Can you clarify the sense in which it's an "ABI change"? I don't think
> it's a change at all in the "mechanical" ABI linkage between libc and
> the libc consumer. Of course it is a change in the types at the high
> level language level.

If struct timespec is passed as a register pair, the old type guarantees
that the callee sees a sign-extended value for the nanoseconds in the
register.  With the new type, the upper 32 bits of the register are
either undefined or zero (not sure which).  Existing compiler practice
favors zero extension, I think.  This may cause an observable difference
if only part of the link is upgraded to the new type, which I think
qualifies the change as an ABI break.

> If this were just an enhancement request, I'd be inclined to say just
> drop it, but this is a bug fix for a serious conformance problem
> that's going to have people writing wacky code to work around x32 (if
> anyone even actually cares about x32) and that keeps coming up in
> messy ways like the request to change tv_nsec to snseconds_t. From my
> perspective there is very high value in getting rid of this exception
> to the specification so that stuff doesn't get built around it.

If the kernel view and the userspace view differ, that also causes
practical problems.  Low-level C programmers do not expect a managed
run-time that uses different types, locks around system calls etc., even
though the resulting C implementation is not really POSIX-compliant.

Thanks,
Florian


  parent reply	other threads:[~2021-12-11 18:50 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-10 11:02 Adhemerval Zanella
2021-12-10 15:36 ` H.J. Lu
2021-12-10 15:44   ` Florian Weimer
2021-12-10 19:28     ` Adhemerval Zanella
2021-12-11  0:08     ` Rich Felker
2021-12-11  0:47       ` Paul Eggert
2021-12-11 11:26         ` Arnd Bergmann
2021-12-11 12:51           ` Florian Weimer
2021-12-11 16:32             ` Arnd Bergmann
2021-12-11 14:49           ` Rich Felker
2021-12-11 22:30             ` Arnd Bergmann
2021-12-11 18:50       ` Florian Weimer [this message]
2021-12-11 19:22         ` Andreas Schwab
2021-12-11 20:33           ` Rich Felker
2021-12-11 20:57             ` Andreas Schwab
2021-12-10 15:47   ` Adhemerval Zanella

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=87bl1n2cyp.fsf@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=dalias@libc.org \
    --cc=libc-alpha@sourceware.org \
    /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).