diff mbox

[08/24] Allow a 32bit ABI to use the naming of the 64bit ABI syscalls to avoid confusion of not splitting the registers

Message ID 1409779158-30963-9-git-send-email-apinski@cavium.com
State New
Headers show

Commit Message

Andrew Pinski Sept. 3, 2014, 9:19 p.m. UTC
In the ARM64 ILP32 case, we want to say the syscalls that normally would pass
64bit as two arguments are now passing as one so want to use the 64bit
naming scheme.

Signed-off-by: Andrew Pinski <apinski@cavium.com>
---
 include/uapi/asm-generic/unistd.h |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

Comments

Arnd Bergmann Sept. 4, 2014, 10:11 a.m. UTC | #1
On Wednesday 03 September 2014 14:19:02 Andrew Pinski wrote:
> + * For 32bit abis where 64bit can be passed via one
> + * register, use the same naming as the 64bit ones
> + * as they will only have a 64 bit off_t.
>   */
> -#if __BITS_PER_LONG == 64 && !defined(__SYSCALL_COMPAT)
> +#if (__BITS_PER_LONG == 64 && !defined(__SYSCALL_COMPAT)) || \
> +       defined(__ARCH_WANT_64BIT_SYSCALLS)
> 

I'm not sure if __ARCH_WANT_64BIT_SYSCALLS is the best name for
this, since it's really only about off_t. It took me a while
to understand what you are doing here.

	Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
Catalin Marinas Oct. 1, 2014, 12:42 p.m. UTC | #2
On Thu, Sep 04, 2014 at 11:11:04AM +0100, Arnd Bergmann wrote:
> On Wednesday 03 September 2014 14:19:02 Andrew Pinski wrote:
> > + * For 32bit abis where 64bit can be passed via one
> > + * register, use the same naming as the 64bit ones
> > + * as they will only have a 64 bit off_t.
> >   */
> > -#if __BITS_PER_LONG == 64 && !defined(__SYSCALL_COMPAT)
> > +#if (__BITS_PER_LONG == 64 && !defined(__SYSCALL_COMPAT)) || \
> > +       defined(__ARCH_WANT_64BIT_SYSCALLS)
> 
> I'm not sure if __ARCH_WANT_64BIT_SYSCALLS is the best name for
> this, since it's really only about off_t. It took me a while
> to understand what you are doing here.

I'm not sure I fully get it yet. So with this change, we avoid using
syscall numbers like __NR_ftruncate64 in favour of __NR_ftruncate. Why?
(maybe there's a valid reason, just not getting it).

Either way, ILP32 would still end up calling sys_ftruncate64() (rather
than the native sys_ftruncate()).
Arnd Bergmann Oct. 1, 2014, 2 p.m. UTC | #3
On Wednesday 01 October 2014 13:42:27 Catalin Marinas wrote:
> On Thu, Sep 04, 2014 at 11:11:04AM +0100, Arnd Bergmann wrote:
> > On Wednesday 03 September 2014 14:19:02 Andrew Pinski wrote:
> > > + * For 32bit abis where 64bit can be passed via one
> > > + * register, use the same naming as the 64bit ones
> > > + * as they will only have a 64 bit off_t.
> > >   */
> > > -#if __BITS_PER_LONG == 64 && !defined(__SYSCALL_COMPAT)
> > > +#if (__BITS_PER_LONG == 64 && !defined(__SYSCALL_COMPAT)) || \
> > > +       defined(__ARCH_WANT_64BIT_SYSCALLS)
> > 
> > I'm not sure if __ARCH_WANT_64BIT_SYSCALLS is the best name for
> > this, since it's really only about off_t. It took me a while
> > to understand what you are doing here.
> 
> I'm not sure I fully get it yet. So with this change, we avoid using
> syscall numbers like __NR_ftruncate64 in favour of __NR_ftruncate. Why?
> (maybe there's a valid reason, just not getting it).

glibc depends on the name to decide which calling conventions it
uses. I assume this is the same on IPL32 ARM.

The general rule is that on a 32-bit architecture, __NR_ftruncate refers
to the system call that takes a 32-bit off_t argument, while __NR_ftruncate64
refers to the syscall that takes a 64-bit loff_t.

I would assume that the new ABI does not actually allow using 32-bit off_t
in applications (that would be silly) and defaults to using 64-bit offsets,
but it still needs to generate the right system calls.

> Either way, ILP32 would still end up calling sys_ftruncate64() (rather
> than the native sys_ftruncate()).

sys_ftruncate64 does not exist in 64-bit kernels, it can either call
compat_sys_ftruncate64_wrapper or sys_ftruncate. I'd assume it would
call the latter and pass a single 64-bit register, but that is another
matter.

	Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
Catalin Marinas Oct. 2, 2014, 11:19 a.m. UTC | #4
On Wed, Oct 01, 2014 at 03:00:54PM +0100, Arnd Bergmann wrote:
> On Wednesday 01 October 2014 13:42:27 Catalin Marinas wrote:
> > On Thu, Sep 04, 2014 at 11:11:04AM +0100, Arnd Bergmann wrote:
> > > On Wednesday 03 September 2014 14:19:02 Andrew Pinski wrote:
> > > > + * For 32bit abis where 64bit can be passed via one
> > > > + * register, use the same naming as the 64bit ones
> > > > + * as they will only have a 64 bit off_t.
> > > >   */
> > > > -#if __BITS_PER_LONG == 64 && !defined(__SYSCALL_COMPAT)
> > > > +#if (__BITS_PER_LONG == 64 && !defined(__SYSCALL_COMPAT)) || \
> > > > +       defined(__ARCH_WANT_64BIT_SYSCALLS)
> > > 
> > > I'm not sure if __ARCH_WANT_64BIT_SYSCALLS is the best name for
> > > this, since it's really only about off_t. It took me a while
> > > to understand what you are doing here.
> > 
> > I'm not sure I fully get it yet. So with this change, we avoid using
> > syscall numbers like __NR_ftruncate64 in favour of __NR_ftruncate. Why?
> > (maybe there's a valid reason, just not getting it).
> 
> glibc depends on the name to decide which calling conventions it
> uses. I assume this is the same on IPL32 ARM.
> 
> The general rule is that on a 32-bit architecture, __NR_ftruncate refers
> to the system call that takes a 32-bit off_t argument, while __NR_ftruncate64
> refers to the syscall that takes a 64-bit loff_t.
> 
> I would assume that the new ABI does not actually allow using 32-bit off_t
> in applications (that would be silly) and defaults to using 64-bit offsets,
> but it still needs to generate the right system calls.

OK, so since ILP32 would have a 64-bit off_t, we want to use
__NR_ftruncate and sys_ftruncate with the off_t argument (rather than
loff_t).

> > Either way, ILP32 would still end up calling sys_ftruncate64() (rather
> > than the native sys_ftruncate()).
> 
> sys_ftruncate64 does not exist in 64-bit kernels, it can either call
> compat_sys_ftruncate64_wrapper or sys_ftruncate. I'd assume it would
> call the latter and pass a single 64-bit register, but that is another
> matter.

I think I get it now. Just for the record, we define __NR_ftruncate to
__NR3264_ftruncate. When we build the syscall table as per patch 21/24,
given that the kernel is built with __LP64__, we get the following
macros for the syscall function name:

#define __SC_3264(_nr, _32, _64) __SYSCALL(_nr, _64)
#define __SC_COMP_3264(_nr, _32, _64, _comp) __SC_3264(_nr, _32, _64)
...
__SC_COMP_3264(__NR3264_ftruncate, sys_ftruncate64, sys_ftruncate, \
	       compat_sys_ftruncate64)

Which would result in using sys_ftruncate rather than sys_ftruncate64.

I agree, maybe the name could be __ARCH_WANT_64BIT_OFF_T as that's the
only reason for these definitions.
diff mbox

Patch

diff --git a/include/uapi/asm-generic/unistd.h b/include/uapi/asm-generic/unistd.h
index 11d11bc..a7984a0 100644
--- a/include/uapi/asm-generic/unistd.h
+++ b/include/uapi/asm-generic/unistd.h
@@ -881,8 +881,12 @@  __SYSCALL(__NR_fork, sys_ni_syscall)
  * they take different names.
  * Here we map the numbers so that both versions
  * use the same syscall table layout.
+ * For 32bit abis where 64bit can be passed via one
+ * register, use the same naming as the 64bit ones
+ * as they will only have a 64 bit off_t.
  */
-#if __BITS_PER_LONG == 64 && !defined(__SYSCALL_COMPAT)
+#if (__BITS_PER_LONG == 64 && !defined(__SYSCALL_COMPAT)) || \
+	defined(__ARCH_WANT_64BIT_SYSCALLS)
 #define __NR_fcntl __NR3264_fcntl
 #define __NR_statfs __NR3264_statfs
 #define __NR_fstatfs __NR3264_fstatfs