On Tue, Dec 11, 2018 at 12:37:42PM +0100, Florian Weimer wrote: > * Catalin Marinas: > > On Tue, Dec 11, 2018 at 10:02:45AM +0100, Arnd Bergmann wrote: > >> On Tue, Dec 11, 2018 at 6:35 AM Andy Lutomirski <luto@xxxxxxxxxx> wrote: > >> > I tried to understand what's going on. As far as I can tell, most of > >> > the magic is the fact that __kernel_long_t and __kernel_ulong_t are > >> > 64-bit as seen by x32 user code. This means that a decent number of > >> > uapi structures are the same on x32 and x86_64. Syscalls that only > >> > use structures like this should route to the x86_64 entry points. But > >> > the implementation is still highly dubious -- in_compat_syscall() will > >> > be *true* in such system calls, > >> > >> I think the fundamental issue was that the intention had always been > >> to use only the 64-bit entry points for system calls, but the most > >> complex one we have -- ioctl() -- has to use the compat entry point > >> because device drivers define their own data structures using 'long' > >> and pointer members and they need translation, as well as > >> matching in_compat_syscall() checks. This in turn breaks down > >> again whenever a driver defines an ioctl command that takes > >> a __kernel_long_t or a derived type like timespec as its argument. > > > > With arm64 ILP32 we tried to avoid the ioctl() problem by having > > __kernel_long_t 32-bit, IOW mimicking the arm32 ABI (compat). The > > biggest pain point is signals where the state is completely different > > from arm32 (more, wider registers) and can't be dealt with by the compat > > layer. > > I would expect to approach this from the opposite direction: use 64-bit > types in places where the 64-bit kernel interface uses 64-bit types. > After all, not everyone who is interested in ILP32 has a companion > 32-bit architecture which could serve as a model for the application > ABI. I fully agree with you that if someone wants ILP32 for a 64-bit only architecture, they should use the 64-bit kernel interface and ensure POSIX is adjusted. In the arm64 context, both options were discussed with the libc community complaining that a partial 64-bit syscall ABI breaks POSIX while the potential users were just asking for a 32-bit ABI to run their existing software stack on ARMv8 machines without native 32-bit support (until they complete the migration to 64-bit). > (If there are conflicts with POSIX, then POSIX needs to be fixed to > support this.) This would have been nice but no-one volunteered and, more importantly, there was no conclusive argument that ARM ILP32 is better than LP64 (well, apart from a minority of benchmarks) and something that people would want to migrate to. Given that the only credible case made was about legacy code, we decided to go ahead with a (mostly) compat 32-bit ABI. -- Catalin