unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Alistair Francis <alistair23@gmail.com>
To: Arnd Bergmann <arnd@arndb.de>, GNU C Library <libc-alpha@sourceware.org>
Cc: Alistair Francis <alistair.francis@wdc.com>,
	Lukasz Majewski <lukma@denx.de>
Subject: 32-bit time_t inside itimerval
Date: Fri, 20 Dec 2019 14:28:46 -0800	[thread overview]
Message-ID: <CAKmqyKPki9K3JwYT4zn7JaAZHFW8UO7ztS2D=US3ccnTd-KAwA@mail.gmail.com> (raw)

Hey,

I just noticed something strange.

The setitimer syscall is not different for 32/64-bit time_t. So we use
this syscall for both 32/64 time_t [1]

SYSCALL_DEFINE3(setitimer, int, which, struct itimerval __user *, value,
        struct itimerval __user *, ovalue)

Where struct itimerval __user *, value looks like this [2]:

struct itimerval {
    struct timeval it_interval;    /* timer interval */
    struct timeval it_value;    /* current value */
};

Which then uses this structure for timeval [3]:

struct timeval {
    __kernel_old_time_t    tv_sec;        /* seconds */
    __kernel_suseconds_t    tv_usec;    /* microseconds */
};

And __kernel_old_time_t is defined [4] as:

typedef __kernel_long_t    __kernel_old_time_t;
typedef __kernel_long_t    __kernel_time_t;


So __kernel_old_time_t and __kernel_time_t are both 32-bit values
inside the kernel. and the setiimer syscall expects a 32-bit time_t
for the values inside it.

This is different to the current glibc implementation where all time_t
values are treated as 64-bit for RISC-V [5].

What should we do here?

1. Change glibc to use a 32-bit time_t for some structures, such as
the timeval inside itimerval?
2. Convert the kernel time_t to be 64-bit for RV32?

Alistair

1: https://github.com/torvalds/linux/blob/ceb307474506f888e8f16dab183405ff01dffa08/kernel/time/itimer.c#L336
2: https://github.com/torvalds/linux/blob/b01d7cb41ff51b7779977de601a984406e2a5ba9/include/uapi/linux/time.h#L39
3: https://github.com/torvalds/linux/blob/b01d7cb41ff51b7779977de601a984406e2a5ba9/include/uapi/linux/time.h#L16
4: https://github.com/torvalds/linux/blob/b01d7cb41ff51b7779977de601a984406e2a5ba9/include/uapi/asm-generic/posix_types.h#L89
5: https://github.com/alistair23/glibc/commit/71faeb322c4f4a163d138893b6855920dad45e07

             reply	other threads:[~2019-12-20 22:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-20 22:28 Alistair Francis [this message]
2019-12-21 13:31 ` 32-bit time_t inside itimerval Arnd Bergmann
2019-12-21 17:18   ` Alistair Francis
2019-12-30 10:02     ` Arnd Bergmann
2019-12-30 19:51       ` Alistair Francis
2019-12-30 20:11         ` Arnd Bergmann
2019-12-30 21:16           ` Alistair Francis
2019-12-30 22:11             ` Arnd Bergmann
2020-01-02 12:08               ` Lukasz Majewski
2020-01-02 12:28                 ` Arnd Bergmann
2020-01-04 18:03                   ` Alistair Francis
2020-01-05 16:07                     ` 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='CAKmqyKPki9K3JwYT4zn7JaAZHFW8UO7ztS2D=US3ccnTd-KAwA@mail.gmail.com' \
    --to=alistair23@gmail.com \
    --cc=alistair.francis@wdc.com \
    --cc=arnd@arndb.de \
    --cc=libc-alpha@sourceware.org \
    --cc=lukma@denx.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).