Re: new architectures, time_t __kernel_long_t

From: Arnd Bergmann
Date: Thu Nov 15 2012 - 04:14:39 EST


On Wednesday 14 November 2012, H. Peter Anvin wrote:
> On 11/14/2012 04:18 AM, Arnd Bergmann wrote:
> > Since we are in the review phase for two new architectures that we
> > should be merging into the mainline kernel, I think we need to
> > come up with a solution for making them use a proper 64-bit time_t.
> >
> > Right now, the only 32-bit user space interface we have to use 64-bit
> > time_t is the x32 side of x86-64, and that works by overriding all
> > "long" sized types to be 64 bit at the ABI level, which we don't
> > want for pure 32 bit architectures.
>
> Sort of. Either way, the kernel headers aren't really x32-clean yet, so
> we have an opportunity to do things more cleanly as we are implementing
> this.

Ah, I didn't know that. How does one build an x32 libc then?

> > I would suggest we make 64-bit time_t, clock_t and suseconds_t the
> > default in include/asm-generic/posix_types.h and change all existing
> > 32 bit users of that file to provide an override to define these
> > as "long".
>
> We also need snseconds_t: POSIX stupidly enough demands that the
> nanosecond field in struct timespec is "long", but that is really not
> appropriate. Unfortunately there are existing architectures (e.g.
> SPARC) where we can't use suseconds_t either, so we are trying to push a
> new snseconds_t type into POSIX.

Right.

> > The other types that are used as 64 bit on x32 are ino_t, nlink_t,
> > size_t, ssize_t, ptrdiff_t, and off_t.
>
> ptrdiff_t obviously not... although __kernel_ptrdiff_t is (as the
> pointers are 64 bits in kernel space.) Similarly, size_t and ssize_t
> are only 32 bits in user space and we override them for compatibility
> with the native kernel.

For ARC and Meta, the pointers in kernel space are never 64 bit. For x32,
they could in theory be 32 bit if one was to do a native x32 kernel port
(which I hope nobody will do).

The __kernel_* types are never about what the kernel actually has (user space
should not care), they are about what the ABI defines that are are using.

We could in theory define all the above (and __kernel_ulong_t) to be 64 bit
wide on all new architectures, which would allow doing 64 bit port later
without a compat layer, but that benefit would be far outweighed by the
complexity and cost of passing 64-bit arguments in two registers for a lot
of syscalls.

Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/