All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v5 00/23] ILP32 for ARM64
@ 2015-09-29 22:13 ` Yury Norov
  0 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-09-29 22:13 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel, catalin.marinas, arnd, agraf,
	bamvor.zhangjian
  Cc: yury.norov, philipp.tomsich, apinski, christoph.muellner,
	klimov.linux, Yury Norov

V5 reincarnation for ILP32.

This is mostly the same code as Andrew suggested in v3:
	https://lkml.org/lkml/2014/9/3/704.

V4 series and discussion:
	https://lkml.org/lkml/2015/4/13/691

Discussion on v3 and v4 raised questions and some disagreement in community,
and therefore patches are not accepted till now. In this v5 I tried to avoid any
changes that are not about obvious fixes, so all interface and implementation
questions are still here.

In v5:
 - rebased on top of 4.3.0-rc3;
 - build fixed if ILP32 enabled without AARCH32;
 - PATCH v4 22/24 (use compat for stack_t) dropped because it confuses
   debug tools like gdb and strace;
 - PATCH v4 20/24 (use compat-syscalls for msgsnd and msgrcv for ILP32)
   dropped as breaking tests;
 - PATCH v5 22/23 (msgrcv, msgsnd handlers) introduced for proper 
   handling of msgrcv, msgsnd;
 - other minor fixes.

Questions under discussion:
 - What for ILP32 on ARM64?
	See https://lkml.org/lkml/2015/4/13/814
	and http://permalink.gmane.org/gmane.comp.lib.uclibc.buildroot/121100
	Briefly,
	 - for compatibility;
	 - for performance;
	 - for memory saving.

 - ABI questions: time_t and so on;
	I think we are out of choice now. Patches to GCC and Glibc are
	upstreamed more than a year ago, and there already might be a code compiled
	against existing ABI. At the end, there is no major disagreement, and final
	word is after ABI users. And I found no objections from that side.

 - Implementation questions: use ILP32 separated table or not, and others;
	Code proposed by Andrew works just fine for more than a year,
	and it even shows slightly better performance comparing to LP64:
	http://permalink.gmane.org/gmane.comp.lib.uclibc.buildroot/121100
	So I see no reason to change something except obvious bugs, if found.

Andrew Pinski (18):
  arm64: ensure the kernel is compiled for LP64
  arm64: rename COMPAT to AARCH32_EL0 in Kconfig
  arm64: change some CONFIG_COMPAT over to use CONFIG_AARCH32_EL0
    instead
  arm64:ilp32: expose 'kernel_long' as 'long long' for ILP32
  arm64:uapi: set __BITS_PER_LONG correctly for ILP32 and LP64
  arm64:ilp32: share signal structures between ILP32 and LP64 ABIs
  arm64:ilp32: use 64bit syscall-names for ILP32 when passing 64bit
    registers
  arm64:ilp32: use non-compat syscall names for ILP32 as for LP64
  arm64: introduce is_a32_task and is_a32_thread (for AArch32 compat)
  arm64:ilp32: add is_ilp32_compat_{task,thread} and TIF_32BIT_AARCH64
  arm64:ilp32: share HWCAP between LP64 and ILP32
  arm64:ilp32 use the native LP64 'start_thread' for ILP32 threads
  arm64:ilp32: support core dump generation for ILP32
  arm64: add support for starting ILP32 (ELFCLASS32) binaries
  ptrace: Allow compat to use the native siginfo
  arm64:ilp32: add sys_ilp32.c and a separate table (in entry.S) to use
    it
  arm64:ilp32: use the native siginfo instead of the compat siginfo
  arm64:ilp32: add ARM64_ILP32 to Kconfig

Philipp Tomsich (4):
  arm64:ilp32: add documentation on the ILP32 ABI for ARM64
  arm64:ilp32: COMPAT_USE_64BIT_TIME is true for ILP32 tasks
  arm64:ilp32: add vdso-ilp32 and use for signal return
  arm64:ilp32: change COMPAT_ELF_PLATFORM to report a a subplatform for
    ILP32

Yury Norov (1):
  aarch64: ilp32: msgrcv, msgsnd handlers

 Documentation/arm64/ilp32.txt                      |  64 ++++++
 arch/arm64/Kconfig                                 |  14 +-
 arch/arm64/Makefile                                |   6 +-
 arch/arm64/include/asm/compat.h                    |  65 +++++-
 arch/arm64/include/asm/elf.h                       | 105 ++++++++--
 arch/arm64/include/asm/fpsimd.h                    |   2 +-
 arch/arm64/include/asm/hwcap.h                     |  12 +-
 arch/arm64/include/asm/memory.h                    |   2 +-
 arch/arm64/include/asm/processor.h                 |  12 +-
 arch/arm64/include/asm/ptrace.h                    |   2 +-
 arch/arm64/include/asm/signal32.h                  |   2 +
 arch/arm64/include/asm/stat.h                      |   2 +
 arch/arm64/include/asm/thread_info.h               |   3 +-
 arch/arm64/include/asm/unistd.h                    |   8 +-
 arch/arm64/include/asm/vdso.h                      |   4 +
 arch/arm64/include/uapi/asm/bitsperlong.h          |   9 +-
 arch/arm64/include/uapi/asm/posix_types.h          |  12 +-
 arch/arm64/include/uapi/asm/siginfo.h              |  21 ++
 arch/arm64/include/uapi/asm/signal.h               |  32 +++
 arch/arm64/include/uapi/asm/unistd.h               |   7 +
 arch/arm64/kernel/Makefile                         |   8 +-
 arch/arm64/kernel/asm-offsets.c                    |   2 +-
 arch/arm64/kernel/entry.S                          |  18 +-
 arch/arm64/kernel/head.S                           |   2 +-
 arch/arm64/kernel/hw_breakpoint.c                  |   6 +-
 arch/arm64/kernel/process.c                        |   4 +-
 arch/arm64/kernel/ptrace.c                         |  51 +++--
 arch/arm64/kernel/signal.c                         |  23 ++-
 arch/arm64/kernel/sys_ilp32.c                      | 223 +++++++++++++++++++++
 arch/arm64/kernel/traps.c                          |   4 +-
 arch/arm64/kernel/vdso-ilp32/.gitignore            |   2 +
 arch/arm64/kernel/vdso-ilp32/Makefile              |  72 +++++++
 .../siginfo.h => kernel/vdso-ilp32/vdso-ilp32.S}   |  22 +-
 arch/arm64/kernel/vdso-ilp32/vdso-ilp32.lds.S      |  98 +++++++++
 arch/arm64/kernel/vdso.c                           |  73 +++++--
 include/linux/compat.h                             |   4 +
 include/uapi/asm-generic/siginfo.h                 |  17 +-
 include/uapi/asm-generic/signal.h                  |  27 ++-
 include/uapi/asm-generic/unistd.h                  |   5 +-
 kernel/ptrace.c                                    |  24 ++-
 40 files changed, 973 insertions(+), 96 deletions(-)
 create mode 100644 Documentation/arm64/ilp32.txt
 create mode 100644 arch/arm64/kernel/sys_ilp32.c
 create mode 100644 arch/arm64/kernel/vdso-ilp32/.gitignore
 create mode 100644 arch/arm64/kernel/vdso-ilp32/Makefile
 copy arch/arm64/{include/uapi/asm/siginfo.h => kernel/vdso-ilp32/vdso-ilp32.S} (60%)
 create mode 100644 arch/arm64/kernel/vdso-ilp32/vdso-ilp32.lds.S

-- 
2.1.4


^ permalink raw reply	[flat|nested] 96+ messages in thread

* [PATCH v5 00/23] ILP32 for ARM64
@ 2015-09-29 22:13 ` Yury Norov
  0 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-09-29 22:13 UTC (permalink / raw)
  To: linux-arm-kernel

V5 reincarnation for ILP32.

This is mostly the same code as Andrew suggested in v3:
	https://lkml.org/lkml/2014/9/3/704.

V4 series and discussion:
	https://lkml.org/lkml/2015/4/13/691

Discussion on v3 and v4 raised questions and some disagreement in community,
and therefore patches are not accepted till now. In this v5 I tried to avoid any
changes that are not about obvious fixes, so all interface and implementation
questions are still here.

In v5:
 - rebased on top of 4.3.0-rc3;
 - build fixed if ILP32 enabled without AARCH32;
 - PATCH v4 22/24 (use compat for stack_t) dropped because it confuses
   debug tools like gdb and strace;
 - PATCH v4 20/24 (use compat-syscalls for msgsnd and msgrcv for ILP32)
   dropped as breaking tests;
 - PATCH v5 22/23 (msgrcv, msgsnd handlers) introduced for proper 
   handling of msgrcv, msgsnd;
 - other minor fixes.

Questions under discussion:
 - What for ILP32 on ARM64?
	See https://lkml.org/lkml/2015/4/13/814
	and http://permalink.gmane.org/gmane.comp.lib.uclibc.buildroot/121100
	Briefly,
	 - for compatibility;
	 - for performance;
	 - for memory saving.

 - ABI questions: time_t and so on;
	I think we are out of choice now. Patches to GCC and Glibc are
	upstreamed more than a year ago, and there already might be a code compiled
	against existing ABI. At the end, there is no major disagreement, and final
	word is after ABI users. And I found no objections from that side.

 - Implementation questions: use ILP32 separated table or not, and others;
	Code proposed by Andrew works just fine for more than a year,
	and it even shows slightly better performance comparing to LP64:
	http://permalink.gmane.org/gmane.comp.lib.uclibc.buildroot/121100
	So I see no reason to change something except obvious bugs, if found.

Andrew Pinski (18):
  arm64: ensure the kernel is compiled for LP64
  arm64: rename COMPAT to AARCH32_EL0 in Kconfig
  arm64: change some CONFIG_COMPAT over to use CONFIG_AARCH32_EL0
    instead
  arm64:ilp32: expose 'kernel_long' as 'long long' for ILP32
  arm64:uapi: set __BITS_PER_LONG correctly for ILP32 and LP64
  arm64:ilp32: share signal structures between ILP32 and LP64 ABIs
  arm64:ilp32: use 64bit syscall-names for ILP32 when passing 64bit
    registers
  arm64:ilp32: use non-compat syscall names for ILP32 as for LP64
  arm64: introduce is_a32_task and is_a32_thread (for AArch32 compat)
  arm64:ilp32: add is_ilp32_compat_{task,thread} and TIF_32BIT_AARCH64
  arm64:ilp32: share HWCAP between LP64 and ILP32
  arm64:ilp32 use the native LP64 'start_thread' for ILP32 threads
  arm64:ilp32: support core dump generation for ILP32
  arm64: add support for starting ILP32 (ELFCLASS32) binaries
  ptrace: Allow compat to use the native siginfo
  arm64:ilp32: add sys_ilp32.c and a separate table (in entry.S) to use
    it
  arm64:ilp32: use the native siginfo instead of the compat siginfo
  arm64:ilp32: add ARM64_ILP32 to Kconfig

Philipp Tomsich (4):
  arm64:ilp32: add documentation on the ILP32 ABI for ARM64
  arm64:ilp32: COMPAT_USE_64BIT_TIME is true for ILP32 tasks
  arm64:ilp32: add vdso-ilp32 and use for signal return
  arm64:ilp32: change COMPAT_ELF_PLATFORM to report a a subplatform for
    ILP32

Yury Norov (1):
  aarch64: ilp32: msgrcv, msgsnd handlers

 Documentation/arm64/ilp32.txt                      |  64 ++++++
 arch/arm64/Kconfig                                 |  14 +-
 arch/arm64/Makefile                                |   6 +-
 arch/arm64/include/asm/compat.h                    |  65 +++++-
 arch/arm64/include/asm/elf.h                       | 105 ++++++++--
 arch/arm64/include/asm/fpsimd.h                    |   2 +-
 arch/arm64/include/asm/hwcap.h                     |  12 +-
 arch/arm64/include/asm/memory.h                    |   2 +-
 arch/arm64/include/asm/processor.h                 |  12 +-
 arch/arm64/include/asm/ptrace.h                    |   2 +-
 arch/arm64/include/asm/signal32.h                  |   2 +
 arch/arm64/include/asm/stat.h                      |   2 +
 arch/arm64/include/asm/thread_info.h               |   3 +-
 arch/arm64/include/asm/unistd.h                    |   8 +-
 arch/arm64/include/asm/vdso.h                      |   4 +
 arch/arm64/include/uapi/asm/bitsperlong.h          |   9 +-
 arch/arm64/include/uapi/asm/posix_types.h          |  12 +-
 arch/arm64/include/uapi/asm/siginfo.h              |  21 ++
 arch/arm64/include/uapi/asm/signal.h               |  32 +++
 arch/arm64/include/uapi/asm/unistd.h               |   7 +
 arch/arm64/kernel/Makefile                         |   8 +-
 arch/arm64/kernel/asm-offsets.c                    |   2 +-
 arch/arm64/kernel/entry.S                          |  18 +-
 arch/arm64/kernel/head.S                           |   2 +-
 arch/arm64/kernel/hw_breakpoint.c                  |   6 +-
 arch/arm64/kernel/process.c                        |   4 +-
 arch/arm64/kernel/ptrace.c                         |  51 +++--
 arch/arm64/kernel/signal.c                         |  23 ++-
 arch/arm64/kernel/sys_ilp32.c                      | 223 +++++++++++++++++++++
 arch/arm64/kernel/traps.c                          |   4 +-
 arch/arm64/kernel/vdso-ilp32/.gitignore            |   2 +
 arch/arm64/kernel/vdso-ilp32/Makefile              |  72 +++++++
 .../siginfo.h => kernel/vdso-ilp32/vdso-ilp32.S}   |  22 +-
 arch/arm64/kernel/vdso-ilp32/vdso-ilp32.lds.S      |  98 +++++++++
 arch/arm64/kernel/vdso.c                           |  73 +++++--
 include/linux/compat.h                             |   4 +
 include/uapi/asm-generic/siginfo.h                 |  17 +-
 include/uapi/asm-generic/signal.h                  |  27 ++-
 include/uapi/asm-generic/unistd.h                  |   5 +-
 kernel/ptrace.c                                    |  24 ++-
 40 files changed, 973 insertions(+), 96 deletions(-)
 create mode 100644 Documentation/arm64/ilp32.txt
 create mode 100644 arch/arm64/kernel/sys_ilp32.c
 create mode 100644 arch/arm64/kernel/vdso-ilp32/.gitignore
 create mode 100644 arch/arm64/kernel/vdso-ilp32/Makefile
 copy arch/arm64/{include/uapi/asm/siginfo.h => kernel/vdso-ilp32/vdso-ilp32.S} (60%)
 create mode 100644 arch/arm64/kernel/vdso-ilp32/vdso-ilp32.lds.S

-- 
2.1.4

^ permalink raw reply	[flat|nested] 96+ messages in thread

* [PATCH v5 01/23] arm64:ilp32: add documentation on the ILP32 ABI for ARM64
  2015-09-29 22:13 ` Yury Norov
@ 2015-09-29 22:13   ` Yury Norov
  -1 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-09-29 22:13 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel, catalin.marinas, arnd, agraf,
	bamvor.zhangjian
  Cc: yury.norov, philipp.tomsich, apinski, christoph.muellner,
	klimov.linux, Yury Norov

From: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>

Based on Andrew Pinski's original patch-series and adapted with changes
to reduce the duplication of code-paths and resolve issue found during
LTP testing.

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>

 create mode 100644 Documentation/arm64/ilp32.txt

diff --git a/Documentation/arm64/ilp32.txt b/Documentation/arm64/ilp32.txt
new file mode 100644
index 0000000..1049510
--- /dev/null
+++ b/Documentation/arm64/ilp32.txt
@@ -0,0 +1,64 @@
+ILP32 AARCH64 SYSCALL ABI
+=========================
+Written by Andrew Pinski <apinski@cavium.com>
+Updated by Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
+
+
+This document describes the ILP32 syscall ABI and where it differs
+from the generic linux syscall interface.
+
+ILP32 sets __kernel_long_t and __kernel_ulong_t both to 64bit.  This
+affects the following type definitions for ILP32 client programs:
+ * time_t          unsigned long long
+ * clock_t         unsigned long long
+ * fsword_t        long long
+ * suseconds_t     long long
+ * swblk_t         long long
+ * fd_mask_t       long long
+
+Some structures are changed to reduce the difference in the code path
+for both ILP32 and LP64 ABIs for signal handling.
+
+The following structures have been changed so the layout of the
+structures are the same between ILP32 and LP64 ABIs, including:
+ * timespec        uses time_t and suseconds_t
+ * timeval         uses time_t and suseconds_t
+ * stat            uses timespec/time_t
+ * semid64_ds      uses time_t.
+ * msqid64_ds      uses time_t.
+ * shmid64_ds      uses time_t.
+ * rt_sigframe     uses siginfo and ucontext.
+ * siginfo_t       uses clock_t and sigval_t
+ * ucontext        uses stack_t and sigset_t
+ * sigval_t        contains pointers
+ * sigevent        Uses sigval_t which causes it to be the same.  Special
+                   handing is needed for reading; in the mq_notify syscall
+ * sigaction       Conversion is handled in the userland (glibc), as the
+		    userland data structures are defined in glibc anyway.
+ * fd_set          This is done to avoid endian issues between ILP32 and
+		   LP64. Syscalls consuming fd_set use timespec.
+
+A number of structures differ between ILP32 and LP64, including:
+ * struct msgbuf   The specification of 'struct msgbuf' defines the 'mtype'
+                   field as a 'long' (i.e. 32bit for ILP32, but 64bit for
+		   LP64).  Functions that operate on 'struct msgbuf' need
+		   to be passed through the compat-syscalls to resolve
+		   this.
+ * stack_t         contains pointers (handled in the compatibility layer)
+
+Also the syscalls which normally would pass 64bit values as two arguments;
+now pass the 64bit value as one argument.  Also they have been renamed
+(removing the 64 from the name) to avoid confusion.
+The list of these LP64 syscalls reused by ILP32 clients is:
+ * fcntl
+ * statfs
+ * fstatfs
+ * truncate
+ * ftruncate
+ * lseek
+ * sendfile
+ * newfstatat
+ * fstat
+ * mmap
+ * fadvise64
+
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [PATCH v5 01/23] arm64:ilp32: add documentation on the ILP32 ABI for ARM64
@ 2015-09-29 22:13   ` Yury Norov
  0 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-09-29 22:13 UTC (permalink / raw)
  To: linux-arm-kernel

From: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>

Based on Andrew Pinski's original patch-series and adapted with changes
to reduce the duplication of code-paths and resolve issue found during
LTP testing.

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>

 create mode 100644 Documentation/arm64/ilp32.txt

diff --git a/Documentation/arm64/ilp32.txt b/Documentation/arm64/ilp32.txt
new file mode 100644
index 0000000..1049510
--- /dev/null
+++ b/Documentation/arm64/ilp32.txt
@@ -0,0 +1,64 @@
+ILP32 AARCH64 SYSCALL ABI
+=========================
+Written by Andrew Pinski <apinski@cavium.com>
+Updated by Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
+
+
+This document describes the ILP32 syscall ABI and where it differs
+from the generic linux syscall interface.
+
+ILP32 sets __kernel_long_t and __kernel_ulong_t both to 64bit.  This
+affects the following type definitions for ILP32 client programs:
+ * time_t          unsigned long long
+ * clock_t         unsigned long long
+ * fsword_t        long long
+ * suseconds_t     long long
+ * swblk_t         long long
+ * fd_mask_t       long long
+
+Some structures are changed to reduce the difference in the code path
+for both ILP32 and LP64 ABIs for signal handling.
+
+The following structures have been changed so the layout of the
+structures are the same between ILP32 and LP64 ABIs, including:
+ * timespec        uses time_t and suseconds_t
+ * timeval         uses time_t and suseconds_t
+ * stat            uses timespec/time_t
+ * semid64_ds      uses time_t.
+ * msqid64_ds      uses time_t.
+ * shmid64_ds      uses time_t.
+ * rt_sigframe     uses siginfo and ucontext.
+ * siginfo_t       uses clock_t and sigval_t
+ * ucontext        uses stack_t and sigset_t
+ * sigval_t        contains pointers
+ * sigevent        Uses sigval_t which causes it to be the same.  Special
+                   handing is needed for reading; in the mq_notify syscall
+ * sigaction       Conversion is handled in the userland (glibc), as the
+		    userland data structures are defined in glibc anyway.
+ * fd_set          This is done to avoid endian issues between ILP32 and
+		   LP64. Syscalls consuming fd_set use timespec.
+
+A number of structures differ between ILP32 and LP64, including:
+ * struct msgbuf   The specification of 'struct msgbuf' defines the 'mtype'
+                   field as a 'long' (i.e. 32bit for ILP32, but 64bit for
+		   LP64).  Functions that operate on 'struct msgbuf' need
+		   to be passed through the compat-syscalls to resolve
+		   this.
+ * stack_t         contains pointers (handled in the compatibility layer)
+
+Also the syscalls which normally would pass 64bit values as two arguments;
+now pass the 64bit value as one argument.  Also they have been renamed
+(removing the 64 from the name) to avoid confusion.
+The list of these LP64 syscalls reused by ILP32 clients is:
+ * fcntl
+ * statfs
+ * fstatfs
+ * truncate
+ * ftruncate
+ * lseek
+ * sendfile
+ * newfstatat
+ * fstat
+ * mmap
+ * fadvise64
+
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [PATCH v5 02/23] arm64: ensure the kernel is compiled for LP64
  2015-09-29 22:13 ` Yury Norov
@ 2015-09-29 22:13   ` Yury Norov
  -1 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-09-29 22:13 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel, catalin.marinas, arnd, agraf,
	bamvor.zhangjian
  Cc: yury.norov, philipp.tomsich, apinski, christoph.muellner,
	klimov.linux, Yury Norov

From: Andrew Pinski <apinski@cavium.com>

The kernel needs to be compiled as a LP64 binary for ARM64, even when
using a compiler that defaults to code-generation for the ILP32 ABI.
Consequently, we need to explicitly pass '-mabi=lp64' (supported on
gcc-4.9 and newer).

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>

diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
index f9914d7..d7a13ce 100644
--- a/arch/arm64/Makefile
+++ b/arch/arm64/Makefile
@@ -15,7 +15,6 @@ CPPFLAGS_vmlinux.lds = -DTEXT_OFFSET=$(TEXT_OFFSET)
 OBJCOPYFLAGS	:=-O binary -R .note -R .note.gnu.build-id -R .comment -S
 GZFLAGS		:=-9
 
-KBUILD_DEFCONFIG := defconfig
 
 # Check for binutils support for specific extensions
 lseinstr := $(call as-instr,.arch_extension lse,-DCONFIG_AS_LSE=1)
@@ -29,14 +28,19 @@ endif
 KBUILD_CFLAGS	+= -mgeneral-regs-only $(lseinstr)
 KBUILD_AFLAGS	+= $(lseinstr)
 
+KBUILD_CFLAGS	+= $(call cc-option,-mabi=lp64)
+KBUILD_AFLAGS	+= $(call cc-option,-mabi=lp64)
+
 ifeq ($(CONFIG_CPU_BIG_ENDIAN), y)
 KBUILD_CPPFLAGS	+= -mbig-endian
 AS		+= -EB
 LD		+= -EB
+LDFLAGS		+= -maarch64linuxb
 else
 KBUILD_CPPFLAGS	+= -mlittle-endian
 AS		+= -EL
 LD		+= -EL
+LDFLAGS		+= -maarch64linux
 endif
 
 CHECKFLAGS	+= -D__aarch64__
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [PATCH v5 02/23] arm64: ensure the kernel is compiled for LP64
@ 2015-09-29 22:13   ` Yury Norov
  0 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-09-29 22:13 UTC (permalink / raw)
  To: linux-arm-kernel

From: Andrew Pinski <apinski@cavium.com>

The kernel needs to be compiled as a LP64 binary for ARM64, even when
using a compiler that defaults to code-generation for the ILP32 ABI.
Consequently, we need to explicitly pass '-mabi=lp64' (supported on
gcc-4.9 and newer).

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>

diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
index f9914d7..d7a13ce 100644
--- a/arch/arm64/Makefile
+++ b/arch/arm64/Makefile
@@ -15,7 +15,6 @@ CPPFLAGS_vmlinux.lds = -DTEXT_OFFSET=$(TEXT_OFFSET)
 OBJCOPYFLAGS	:=-O binary -R .note -R .note.gnu.build-id -R .comment -S
 GZFLAGS		:=-9
 
-KBUILD_DEFCONFIG := defconfig
 
 # Check for binutils support for specific extensions
 lseinstr := $(call as-instr,.arch_extension lse,-DCONFIG_AS_LSE=1)
@@ -29,14 +28,19 @@ endif
 KBUILD_CFLAGS	+= -mgeneral-regs-only $(lseinstr)
 KBUILD_AFLAGS	+= $(lseinstr)
 
+KBUILD_CFLAGS	+= $(call cc-option,-mabi=lp64)
+KBUILD_AFLAGS	+= $(call cc-option,-mabi=lp64)
+
 ifeq ($(CONFIG_CPU_BIG_ENDIAN), y)
 KBUILD_CPPFLAGS	+= -mbig-endian
 AS		+= -EB
 LD		+= -EB
+LDFLAGS		+= -maarch64linuxb
 else
 KBUILD_CPPFLAGS	+= -mlittle-endian
 AS		+= -EL
 LD		+= -EL
+LDFLAGS		+= -maarch64linux
 endif
 
 CHECKFLAGS	+= -D__aarch64__
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [PATCH v5 03/23] arm64: rename COMPAT to AARCH32_EL0 in Kconfig
  2015-09-29 22:13 ` Yury Norov
@ 2015-09-29 22:14   ` Yury Norov
  -1 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-09-29 22:14 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel, catalin.marinas, arnd, agraf,
	bamvor.zhangjian
  Cc: yury.norov, philipp.tomsich, apinski, christoph.muellner,
	klimov.linux, Yury Norov

From: Andrew Pinski <apinski@cavium.com>

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 07d1811..d1dc605 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -679,6 +679,11 @@ menu "Userspace binary formats"
 source "fs/Kconfig.binfmt"
 
 config COMPAT
+	def_bool y
+	depends on AARCH32_EL0
+	select COMPAT_BINFMT_ELF
+
+config AARCH32_EL0
 	bool "Kernel support for 32-bit EL0"
 	depends on !ARM64_64K_PAGES || EXPERT
 	select COMPAT_BINFMT_ELF
@@ -699,7 +704,7 @@ config COMPAT
 
 config SYSVIPC_COMPAT
 	def_bool y
-	depends on COMPAT && SYSVIPC
+	depends on AARCH32_EL0 && SYSVIPC
 
 endmenu
 
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [PATCH v5 03/23] arm64: rename COMPAT to AARCH32_EL0 in Kconfig
@ 2015-09-29 22:14   ` Yury Norov
  0 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-09-29 22:14 UTC (permalink / raw)
  To: linux-arm-kernel

From: Andrew Pinski <apinski@cavium.com>

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 07d1811..d1dc605 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -679,6 +679,11 @@ menu "Userspace binary formats"
 source "fs/Kconfig.binfmt"
 
 config COMPAT
+	def_bool y
+	depends on AARCH32_EL0
+	select COMPAT_BINFMT_ELF
+
+config AARCH32_EL0
 	bool "Kernel support for 32-bit EL0"
 	depends on !ARM64_64K_PAGES || EXPERT
 	select COMPAT_BINFMT_ELF
@@ -699,7 +704,7 @@ config COMPAT
 
 config SYSVIPC_COMPAT
 	def_bool y
-	depends on COMPAT && SYSVIPC
+	depends on AARCH32_EL0 && SYSVIPC
 
 endmenu
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [PATCH v5 04/23] arm64: change some CONFIG_COMPAT over to use CONFIG_AARCH32_EL0 instead
  2015-09-29 22:13 ` Yury Norov
@ 2015-09-29 22:14   ` Yury Norov
  -1 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-09-29 22:14 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel, catalin.marinas, arnd, agraf,
	bamvor.zhangjian
  Cc: yury.norov, philipp.tomsich, apinski, christoph.muellner,
	klimov.linux, Yury Norov

From: Andrew Pinski <apinski@cavium.com>

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>

diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h
index faad6df..f40c51b 100644
--- a/arch/arm64/include/asm/elf.h
+++ b/arch/arm64/include/asm/elf.h
@@ -166,10 +166,13 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
 
 #define COMPAT_ELF_ET_DYN_BASE		(2 * TASK_SIZE_32 / 3)
 
+
+#ifdef CONFIG_AARCH32_EL0
+
 /* AArch32 registers. */
-#define COMPAT_ELF_NGREG		18
+#define COMPAT_A32_ELF_NGREG		18
 typedef unsigned int			compat_elf_greg_t;
-typedef compat_elf_greg_t		compat_elf_gregset_t[COMPAT_ELF_NGREG];
+typedef compat_elf_greg_t		compat_elf_gregset_t[COMPAT_A32_ELF_NGREG];
 
 /* AArch32 EABI. */
 #define EF_ARM_EABI_MASK		0xff000000
@@ -179,11 +182,25 @@ typedef compat_elf_greg_t		compat_elf_gregset_t[COMPAT_ELF_NGREG];
 #define compat_start_thread		compat_start_thread
 #define COMPAT_SET_PERSONALITY(ex)	set_thread_flag(TIF_32BIT);
 #define COMPAT_ARCH_DLINFO
+
+
 extern int aarch32_setup_vectors_page(struct linux_binprm *bprm,
 				      int uses_interp);
 #define compat_arch_setup_additional_pages \
 					aarch32_setup_vectors_page
 
+#else
+
+typedef elf_greg_t			compat_elf_greg_t;
+typedef elf_gregset_t			compat_elf_gregset_t;
+#define compat_a32_elf_check_arch(x)	0
+#define COMPAT_SET_PERSONALITY(ex)
+#define COMPAT_ARCH_DLINFO
+
+#endif
+
+#define compat_elf_check_arch(x)	compat_a32_elf_check_arch(x)
+
 #endif /* CONFIG_COMPAT */
 
 #endif
diff --git a/arch/arm64/include/asm/fpsimd.h b/arch/arm64/include/asm/fpsimd.h
index 50f559f..63b19f1 100644
--- a/arch/arm64/include/asm/fpsimd.h
+++ b/arch/arm64/include/asm/fpsimd.h
@@ -52,7 +52,7 @@ struct fpsimd_partial_state {
 };
 
 
-#if defined(__KERNEL__) && defined(CONFIG_COMPAT)
+#if defined(__KERNEL__) && defined(CONFIG_AARCH32_EL0)
 /* Masks for extracting the FPSR and FPCR from the FPSCR */
 #define VFP_FPSCR_STAT_MASK	0xf800009f
 #define VFP_FPSCR_CTRL_MASK	0x07f79f00
diff --git a/arch/arm64/include/asm/ptrace.h b/arch/arm64/include/asm/ptrace.h
index 536274e..1059b3f 100644
--- a/arch/arm64/include/asm/ptrace.h
+++ b/arch/arm64/include/asm/ptrace.h
@@ -120,7 +120,7 @@ struct pt_regs {
 
 #define arch_has_single_step()	(1)
 
-#ifdef CONFIG_COMPAT
+#ifdef CONFIG_AARCH32_EL0
 #define compat_thumb_mode(regs) \
 	(((regs)->pstate & COMPAT_PSR_T_BIT))
 #else
diff --git a/arch/arm64/include/asm/signal32.h b/arch/arm64/include/asm/signal32.h
index eeaa975..4302909 100644
--- a/arch/arm64/include/asm/signal32.h
+++ b/arch/arm64/include/asm/signal32.h
@@ -20,6 +20,7 @@
 #ifdef CONFIG_COMPAT
 #include <linux/compat.h>
 
+#ifdef CONFIG_AARCH32_EL0
 #define AARCH32_KERN_SIGRET_CODE_OFFSET	0x500
 
 extern const compat_ulong_t aarch32_sigret_code[6];
@@ -47,6 +48,7 @@ static inline int compat_setup_rt_frame(int usig, struct ksignal *ksig, sigset_t
 static inline void compat_setup_restart_syscall(struct pt_regs *regs)
 {
 }
+#endif /* CONFIG_AARCH32_EL0 */
 #endif /* CONFIG_COMPAT */
 #endif /* __KERNEL__ */
 #endif /* __ASM_SIGNAL32_H */
diff --git a/arch/arm64/include/asm/stat.h b/arch/arm64/include/asm/stat.h
index 15e3559..af04276 100644
--- a/arch/arm64/include/asm/stat.h
+++ b/arch/arm64/include/asm/stat.h
@@ -22,6 +22,7 @@
 
 #include <asm/compat.h>
 
+#ifdef CONFIG_AARCH32_EL0
 /*
  * struct stat64 is needed for compat tasks only. Its definition is different
  * from the generic struct stat64.
@@ -59,3 +60,4 @@ struct stat64 {
 
 #endif
 #endif
+#endif
diff --git a/arch/arm64/include/asm/unistd.h b/arch/arm64/include/asm/unistd.h
index 3bc498c..759c433 100644
--- a/arch/arm64/include/asm/unistd.h
+++ b/arch/arm64/include/asm/unistd.h
@@ -13,7 +13,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
-#ifdef CONFIG_COMPAT
+#ifdef CONFIG_AARCH32_EL0
 #define __ARCH_WANT_COMPAT_SYS_GETDENTS64
 #define __ARCH_WANT_COMPAT_STAT64
 #define __ARCH_WANT_SYS_GETHOSTNAME
@@ -26,7 +26,9 @@
 #define __ARCH_WANT_COMPAT_SYS_SENDFILE
 #define __ARCH_WANT_SYS_FORK
 #define __ARCH_WANT_SYS_VFORK
+#endif
 
+#ifdef CONFIG_COMPAT
 /*
  * Compat syscall numbers used by the AArch64 kernel.
  */
diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile
index 22dc9bc..1470332 100644
--- a/arch/arm64/kernel/Makefile
+++ b/arch/arm64/kernel/Makefile
@@ -20,7 +20,7 @@ arm64-obj-y		:= debug-monitors.o entry.o irq.o fpsimd.o		\
 			   cpufeature.o alternative.o cacheinfo.o		\
 			   smp.o smp_spin_table.o topology.o
 
-arm64-obj-$(CONFIG_COMPAT)		+= sys32.o kuser32.o signal32.o 	\
+arm64-obj-$(CONFIG_AARCH32_EL0)		+= sys32.o kuser32.o signal32.o 	\
 					   sys_compat.o entry32.o		\
 					   ../../arm/kernel/opcodes.o
 arm64-obj-$(CONFIG_FUNCTION_TRACER)	+= ftrace.o entry-ftrace.o
diff --git a/arch/arm64/kernel/asm-offsets.c b/arch/arm64/kernel/asm-offsets.c
index 8d89cf8..e3bcf77 100644
--- a/arch/arm64/kernel/asm-offsets.c
+++ b/arch/arm64/kernel/asm-offsets.c
@@ -51,7 +51,7 @@ int main(void)
   DEFINE(S_X7,			offsetof(struct pt_regs, regs[7]));
   DEFINE(S_LR,			offsetof(struct pt_regs, regs[30]));
   DEFINE(S_SP,			offsetof(struct pt_regs, sp));
-#ifdef CONFIG_COMPAT
+#ifdef CONFIG_AARCH32_EL0
   DEFINE(S_COMPAT_SP,		offsetof(struct pt_regs, compat_sp));
 #endif
   DEFINE(S_PSTATE,		offsetof(struct pt_regs, pstate));
diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S
index 4306c93..52be5c8 100644
--- a/arch/arm64/kernel/entry.S
+++ b/arch/arm64/kernel/entry.S
@@ -212,7 +212,7 @@ ENTRY(vectors)
 	ventry	el0_fiq_invalid			// FIQ 64-bit EL0
 	ventry	el0_error_invalid		// Error 64-bit EL0
 
-#ifdef CONFIG_COMPAT
+#ifdef CONFIG_AARCH32_EL0
 	ventry	el0_sync_compat			// Synchronous 32-bit EL0
 	ventry	el0_irq_compat			// IRQ 32-bit EL0
 	ventry	el0_fiq_invalid_compat		// FIQ 32-bit EL0
@@ -252,7 +252,7 @@ el0_error_invalid:
 	inv_entry 0, BAD_ERROR
 ENDPROC(el0_error_invalid)
 
-#ifdef CONFIG_COMPAT
+#ifdef CONFIG_AARCH32_EL0
 el0_fiq_invalid_compat:
 	inv_entry 0, BAD_FIQ, 32
 ENDPROC(el0_fiq_invalid_compat)
@@ -414,7 +414,7 @@ el0_sync:
 	b.ge	el0_dbg
 	b	el0_inv
 
-#ifdef CONFIG_COMPAT
+#ifdef CONFIG_AARCH32_EL0
 	.align	6
 el0_sync_compat:
 	kernel_entry 0, 32
diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S
index 90d09ed..d11d0b2 100644
--- a/arch/arm64/kernel/head.S
+++ b/arch/arm64/kernel/head.S
@@ -519,7 +519,7 @@ CPU_LE(	movk	x0, #0x30d0, lsl #16	)	// Clear EE and E0E on LE systems
 	mov	x0, #0x33ff
 	msr	cptr_el2, x0			// Disable copro. traps to EL2
 
-#ifdef CONFIG_COMPAT
+#ifdef CONFIG_AARCH32_EL0
 	msr	hstr_el2, xzr			// Disable CP15 traps to EL2
 #endif
 
diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c
index 1971f49..04b4972 100644
--- a/arch/arm64/kernel/ptrace.c
+++ b/arch/arm64/kernel/ptrace.c
@@ -76,7 +76,7 @@ static void ptrace_hbptriggered(struct perf_event *bp,
 		.si_addr	= (void __user *)(bkpt->trigger),
 	};
 
-#ifdef CONFIG_COMPAT
+#ifdef CONFIG_AARCH32_EL0
 	int i;
 
 	if (!is_compat_task())
@@ -651,7 +651,7 @@ static const struct user_regset_view user_aarch64_view = {
 	.regsets = aarch64_regsets, .n = ARRAY_SIZE(aarch64_regsets)
 };
 
-#ifdef CONFIG_COMPAT
+#ifdef CONFIG_AARCH32_EL0
 #include <linux/compat.h>
 
 enum compat_regset {
@@ -853,7 +853,7 @@ static int compat_tls_set(struct task_struct *target,
 static const struct user_regset aarch32_regsets[] = {
 	[REGSET_COMPAT_GPR] = {
 		.core_note_type = NT_PRSTATUS,
-		.n = COMPAT_ELF_NGREG,
+		.n = COMPAT_A32_ELF_NGREG,
 		.size = sizeof(compat_elf_greg_t),
 		.align = sizeof(compat_elf_greg_t),
 		.get = compat_gpr_get,
@@ -1109,8 +1109,8 @@ static int compat_ptrace_sethbpregs(struct task_struct *tsk, compat_long_t num,
 }
 #endif	/* CONFIG_HAVE_HW_BREAKPOINT */
 
-long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
-			compat_ulong_t caddr, compat_ulong_t cdata)
+long compat_a32_arch_ptrace(struct task_struct *child, compat_long_t request,
+			    compat_ulong_t caddr, compat_ulong_t cdata)
 {
 	unsigned long addr = caddr;
 	unsigned long data = cdata;
@@ -1186,11 +1186,28 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
 
 	return ret;
 }
-#endif /* CONFIG_COMPAT */
+#else /* !CONFIG_AARCH32_EL0 */
+long compat_a32_arch_ptrace(struct task_struct *child, compat_long_t request,
+			    compat_ulong_t caddr, compat_ulong_t cdata)
+{
+	return -1;
+}
+#endif /* !CONFIG_AARCH32_EL0 */
+
+#ifdef CONFIG_COMPAT
+long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
+			compat_ulong_t caddr, compat_ulong_t cdata)
+{
+	if (is_compat_task())
+		return compat_a32_arch_ptrace(child, request, caddr, cdata);
+	return compat_ptrace_request(child, request, caddr, cdata);
+}
+#endif
+
 
 const struct user_regset_view *task_user_regset_view(struct task_struct *task)
 {
-#ifdef CONFIG_COMPAT
+#ifdef CONFIG_AARCH32_EL0
 	/*
 	 * Core dumping of 32-bit tasks or compat ptrace requests must use the
 	 * user_aarch32_view compatible with arm32. Native ptrace requests on
diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c
index e18c48c..964a2a4 100644
--- a/arch/arm64/kernel/signal.c
+++ b/arch/arm64/kernel/signal.c
@@ -414,3 +414,18 @@ asmlinkage void do_notify_resume(struct pt_regs *regs,
 		fpsimd_restore_current_state();
 
 }
+
+/*
+ * Some functions are needed for compat ptrace but we don't define
+ * them if we don't have AARCH32 support compiled in
+ */
+#if defined CONFIG_COMPAT && !defined CONFIG_AARCH32_EL0
+int copy_siginfo_to_user32(compat_siginfo_t __user *to, const siginfo_t *from)
+{
+	return -EFAULT;
+}
+int copy_siginfo_from_user32(siginfo_t *to, compat_siginfo_t __user *from)
+{
+	return -EFAULT;
+}
+#endif
diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c
index f93aae5..9ce9894 100644
--- a/arch/arm64/kernel/traps.c
+++ b/arch/arm64/kernel/traps.c
@@ -363,7 +363,7 @@ long compat_arm_syscall(struct pt_regs *regs);
 
 asmlinkage long do_ni_syscall(struct pt_regs *regs)
 {
-#ifdef CONFIG_COMPAT
+#ifdef CONFIG_AARCH32_EL0
 	long ret;
 	if (is_compat_task()) {
 		ret = compat_arm_syscall(regs);
diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c
index 97bc68f..26352a6 100644
--- a/arch/arm64/kernel/vdso.c
+++ b/arch/arm64/kernel/vdso.c
@@ -49,7 +49,7 @@ static union {
 } vdso_data_store __page_aligned_data;
 struct vdso_data *vdso_data = &vdso_data_store.data;
 
-#ifdef CONFIG_COMPAT
+#ifdef CONFIG_AARCH32_EL0
 /*
  * Create and map the vectors page for AArch32 tasks.
  */
@@ -107,7 +107,7 @@ int aarch32_setup_vectors_page(struct linux_binprm *bprm, int uses_interp)
 
 	return PTR_ERR_OR_ZERO(ret);
 }
-#endif /* CONFIG_COMPAT */
+#endif /* CONFIG_AARCH32_EL0 */
 
 static struct vm_special_mapping vdso_spec[2];
 
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [PATCH v5 04/23] arm64: change some CONFIG_COMPAT over to use CONFIG_AARCH32_EL0 instead
@ 2015-09-29 22:14   ` Yury Norov
  0 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-09-29 22:14 UTC (permalink / raw)
  To: linux-arm-kernel

From: Andrew Pinski <apinski@cavium.com>

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>

diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h
index faad6df..f40c51b 100644
--- a/arch/arm64/include/asm/elf.h
+++ b/arch/arm64/include/asm/elf.h
@@ -166,10 +166,13 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
 
 #define COMPAT_ELF_ET_DYN_BASE		(2 * TASK_SIZE_32 / 3)
 
+
+#ifdef CONFIG_AARCH32_EL0
+
 /* AArch32 registers. */
-#define COMPAT_ELF_NGREG		18
+#define COMPAT_A32_ELF_NGREG		18
 typedef unsigned int			compat_elf_greg_t;
-typedef compat_elf_greg_t		compat_elf_gregset_t[COMPAT_ELF_NGREG];
+typedef compat_elf_greg_t		compat_elf_gregset_t[COMPAT_A32_ELF_NGREG];
 
 /* AArch32 EABI. */
 #define EF_ARM_EABI_MASK		0xff000000
@@ -179,11 +182,25 @@ typedef compat_elf_greg_t		compat_elf_gregset_t[COMPAT_ELF_NGREG];
 #define compat_start_thread		compat_start_thread
 #define COMPAT_SET_PERSONALITY(ex)	set_thread_flag(TIF_32BIT);
 #define COMPAT_ARCH_DLINFO
+
+
 extern int aarch32_setup_vectors_page(struct linux_binprm *bprm,
 				      int uses_interp);
 #define compat_arch_setup_additional_pages \
 					aarch32_setup_vectors_page
 
+#else
+
+typedef elf_greg_t			compat_elf_greg_t;
+typedef elf_gregset_t			compat_elf_gregset_t;
+#define compat_a32_elf_check_arch(x)	0
+#define COMPAT_SET_PERSONALITY(ex)
+#define COMPAT_ARCH_DLINFO
+
+#endif
+
+#define compat_elf_check_arch(x)	compat_a32_elf_check_arch(x)
+
 #endif /* CONFIG_COMPAT */
 
 #endif
diff --git a/arch/arm64/include/asm/fpsimd.h b/arch/arm64/include/asm/fpsimd.h
index 50f559f..63b19f1 100644
--- a/arch/arm64/include/asm/fpsimd.h
+++ b/arch/arm64/include/asm/fpsimd.h
@@ -52,7 +52,7 @@ struct fpsimd_partial_state {
 };
 
 
-#if defined(__KERNEL__) && defined(CONFIG_COMPAT)
+#if defined(__KERNEL__) && defined(CONFIG_AARCH32_EL0)
 /* Masks for extracting the FPSR and FPCR from the FPSCR */
 #define VFP_FPSCR_STAT_MASK	0xf800009f
 #define VFP_FPSCR_CTRL_MASK	0x07f79f00
diff --git a/arch/arm64/include/asm/ptrace.h b/arch/arm64/include/asm/ptrace.h
index 536274e..1059b3f 100644
--- a/arch/arm64/include/asm/ptrace.h
+++ b/arch/arm64/include/asm/ptrace.h
@@ -120,7 +120,7 @@ struct pt_regs {
 
 #define arch_has_single_step()	(1)
 
-#ifdef CONFIG_COMPAT
+#ifdef CONFIG_AARCH32_EL0
 #define compat_thumb_mode(regs) \
 	(((regs)->pstate & COMPAT_PSR_T_BIT))
 #else
diff --git a/arch/arm64/include/asm/signal32.h b/arch/arm64/include/asm/signal32.h
index eeaa975..4302909 100644
--- a/arch/arm64/include/asm/signal32.h
+++ b/arch/arm64/include/asm/signal32.h
@@ -20,6 +20,7 @@
 #ifdef CONFIG_COMPAT
 #include <linux/compat.h>
 
+#ifdef CONFIG_AARCH32_EL0
 #define AARCH32_KERN_SIGRET_CODE_OFFSET	0x500
 
 extern const compat_ulong_t aarch32_sigret_code[6];
@@ -47,6 +48,7 @@ static inline int compat_setup_rt_frame(int usig, struct ksignal *ksig, sigset_t
 static inline void compat_setup_restart_syscall(struct pt_regs *regs)
 {
 }
+#endif /* CONFIG_AARCH32_EL0 */
 #endif /* CONFIG_COMPAT */
 #endif /* __KERNEL__ */
 #endif /* __ASM_SIGNAL32_H */
diff --git a/arch/arm64/include/asm/stat.h b/arch/arm64/include/asm/stat.h
index 15e3559..af04276 100644
--- a/arch/arm64/include/asm/stat.h
+++ b/arch/arm64/include/asm/stat.h
@@ -22,6 +22,7 @@
 
 #include <asm/compat.h>
 
+#ifdef CONFIG_AARCH32_EL0
 /*
  * struct stat64 is needed for compat tasks only. Its definition is different
  * from the generic struct stat64.
@@ -59,3 +60,4 @@ struct stat64 {
 
 #endif
 #endif
+#endif
diff --git a/arch/arm64/include/asm/unistd.h b/arch/arm64/include/asm/unistd.h
index 3bc498c..759c433 100644
--- a/arch/arm64/include/asm/unistd.h
+++ b/arch/arm64/include/asm/unistd.h
@@ -13,7 +13,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
-#ifdef CONFIG_COMPAT
+#ifdef CONFIG_AARCH32_EL0
 #define __ARCH_WANT_COMPAT_SYS_GETDENTS64
 #define __ARCH_WANT_COMPAT_STAT64
 #define __ARCH_WANT_SYS_GETHOSTNAME
@@ -26,7 +26,9 @@
 #define __ARCH_WANT_COMPAT_SYS_SENDFILE
 #define __ARCH_WANT_SYS_FORK
 #define __ARCH_WANT_SYS_VFORK
+#endif
 
+#ifdef CONFIG_COMPAT
 /*
  * Compat syscall numbers used by the AArch64 kernel.
  */
diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile
index 22dc9bc..1470332 100644
--- a/arch/arm64/kernel/Makefile
+++ b/arch/arm64/kernel/Makefile
@@ -20,7 +20,7 @@ arm64-obj-y		:= debug-monitors.o entry.o irq.o fpsimd.o		\
 			   cpufeature.o alternative.o cacheinfo.o		\
 			   smp.o smp_spin_table.o topology.o
 
-arm64-obj-$(CONFIG_COMPAT)		+= sys32.o kuser32.o signal32.o 	\
+arm64-obj-$(CONFIG_AARCH32_EL0)		+= sys32.o kuser32.o signal32.o 	\
 					   sys_compat.o entry32.o		\
 					   ../../arm/kernel/opcodes.o
 arm64-obj-$(CONFIG_FUNCTION_TRACER)	+= ftrace.o entry-ftrace.o
diff --git a/arch/arm64/kernel/asm-offsets.c b/arch/arm64/kernel/asm-offsets.c
index 8d89cf8..e3bcf77 100644
--- a/arch/arm64/kernel/asm-offsets.c
+++ b/arch/arm64/kernel/asm-offsets.c
@@ -51,7 +51,7 @@ int main(void)
   DEFINE(S_X7,			offsetof(struct pt_regs, regs[7]));
   DEFINE(S_LR,			offsetof(struct pt_regs, regs[30]));
   DEFINE(S_SP,			offsetof(struct pt_regs, sp));
-#ifdef CONFIG_COMPAT
+#ifdef CONFIG_AARCH32_EL0
   DEFINE(S_COMPAT_SP,		offsetof(struct pt_regs, compat_sp));
 #endif
   DEFINE(S_PSTATE,		offsetof(struct pt_regs, pstate));
diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S
index 4306c93..52be5c8 100644
--- a/arch/arm64/kernel/entry.S
+++ b/arch/arm64/kernel/entry.S
@@ -212,7 +212,7 @@ ENTRY(vectors)
 	ventry	el0_fiq_invalid			// FIQ 64-bit EL0
 	ventry	el0_error_invalid		// Error 64-bit EL0
 
-#ifdef CONFIG_COMPAT
+#ifdef CONFIG_AARCH32_EL0
 	ventry	el0_sync_compat			// Synchronous 32-bit EL0
 	ventry	el0_irq_compat			// IRQ 32-bit EL0
 	ventry	el0_fiq_invalid_compat		// FIQ 32-bit EL0
@@ -252,7 +252,7 @@ el0_error_invalid:
 	inv_entry 0, BAD_ERROR
 ENDPROC(el0_error_invalid)
 
-#ifdef CONFIG_COMPAT
+#ifdef CONFIG_AARCH32_EL0
 el0_fiq_invalid_compat:
 	inv_entry 0, BAD_FIQ, 32
 ENDPROC(el0_fiq_invalid_compat)
@@ -414,7 +414,7 @@ el0_sync:
 	b.ge	el0_dbg
 	b	el0_inv
 
-#ifdef CONFIG_COMPAT
+#ifdef CONFIG_AARCH32_EL0
 	.align	6
 el0_sync_compat:
 	kernel_entry 0, 32
diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S
index 90d09ed..d11d0b2 100644
--- a/arch/arm64/kernel/head.S
+++ b/arch/arm64/kernel/head.S
@@ -519,7 +519,7 @@ CPU_LE(	movk	x0, #0x30d0, lsl #16	)	// Clear EE and E0E on LE systems
 	mov	x0, #0x33ff
 	msr	cptr_el2, x0			// Disable copro. traps to EL2
 
-#ifdef CONFIG_COMPAT
+#ifdef CONFIG_AARCH32_EL0
 	msr	hstr_el2, xzr			// Disable CP15 traps to EL2
 #endif
 
diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c
index 1971f49..04b4972 100644
--- a/arch/arm64/kernel/ptrace.c
+++ b/arch/arm64/kernel/ptrace.c
@@ -76,7 +76,7 @@ static void ptrace_hbptriggered(struct perf_event *bp,
 		.si_addr	= (void __user *)(bkpt->trigger),
 	};
 
-#ifdef CONFIG_COMPAT
+#ifdef CONFIG_AARCH32_EL0
 	int i;
 
 	if (!is_compat_task())
@@ -651,7 +651,7 @@ static const struct user_regset_view user_aarch64_view = {
 	.regsets = aarch64_regsets, .n = ARRAY_SIZE(aarch64_regsets)
 };
 
-#ifdef CONFIG_COMPAT
+#ifdef CONFIG_AARCH32_EL0
 #include <linux/compat.h>
 
 enum compat_regset {
@@ -853,7 +853,7 @@ static int compat_tls_set(struct task_struct *target,
 static const struct user_regset aarch32_regsets[] = {
 	[REGSET_COMPAT_GPR] = {
 		.core_note_type = NT_PRSTATUS,
-		.n = COMPAT_ELF_NGREG,
+		.n = COMPAT_A32_ELF_NGREG,
 		.size = sizeof(compat_elf_greg_t),
 		.align = sizeof(compat_elf_greg_t),
 		.get = compat_gpr_get,
@@ -1109,8 +1109,8 @@ static int compat_ptrace_sethbpregs(struct task_struct *tsk, compat_long_t num,
 }
 #endif	/* CONFIG_HAVE_HW_BREAKPOINT */
 
-long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
-			compat_ulong_t caddr, compat_ulong_t cdata)
+long compat_a32_arch_ptrace(struct task_struct *child, compat_long_t request,
+			    compat_ulong_t caddr, compat_ulong_t cdata)
 {
 	unsigned long addr = caddr;
 	unsigned long data = cdata;
@@ -1186,11 +1186,28 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
 
 	return ret;
 }
-#endif /* CONFIG_COMPAT */
+#else /* !CONFIG_AARCH32_EL0 */
+long compat_a32_arch_ptrace(struct task_struct *child, compat_long_t request,
+			    compat_ulong_t caddr, compat_ulong_t cdata)
+{
+	return -1;
+}
+#endif /* !CONFIG_AARCH32_EL0 */
+
+#ifdef CONFIG_COMPAT
+long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
+			compat_ulong_t caddr, compat_ulong_t cdata)
+{
+	if (is_compat_task())
+		return compat_a32_arch_ptrace(child, request, caddr, cdata);
+	return compat_ptrace_request(child, request, caddr, cdata);
+}
+#endif
+
 
 const struct user_regset_view *task_user_regset_view(struct task_struct *task)
 {
-#ifdef CONFIG_COMPAT
+#ifdef CONFIG_AARCH32_EL0
 	/*
 	 * Core dumping of 32-bit tasks or compat ptrace requests must use the
 	 * user_aarch32_view compatible with arm32. Native ptrace requests on
diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c
index e18c48c..964a2a4 100644
--- a/arch/arm64/kernel/signal.c
+++ b/arch/arm64/kernel/signal.c
@@ -414,3 +414,18 @@ asmlinkage void do_notify_resume(struct pt_regs *regs,
 		fpsimd_restore_current_state();
 
 }
+
+/*
+ * Some functions are needed for compat ptrace but we don't define
+ * them if we don't have AARCH32 support compiled in
+ */
+#if defined CONFIG_COMPAT && !defined CONFIG_AARCH32_EL0
+int copy_siginfo_to_user32(compat_siginfo_t __user *to, const siginfo_t *from)
+{
+	return -EFAULT;
+}
+int copy_siginfo_from_user32(siginfo_t *to, compat_siginfo_t __user *from)
+{
+	return -EFAULT;
+}
+#endif
diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c
index f93aae5..9ce9894 100644
--- a/arch/arm64/kernel/traps.c
+++ b/arch/arm64/kernel/traps.c
@@ -363,7 +363,7 @@ long compat_arm_syscall(struct pt_regs *regs);
 
 asmlinkage long do_ni_syscall(struct pt_regs *regs)
 {
-#ifdef CONFIG_COMPAT
+#ifdef CONFIG_AARCH32_EL0
 	long ret;
 	if (is_compat_task()) {
 		ret = compat_arm_syscall(regs);
diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c
index 97bc68f..26352a6 100644
--- a/arch/arm64/kernel/vdso.c
+++ b/arch/arm64/kernel/vdso.c
@@ -49,7 +49,7 @@ static union {
 } vdso_data_store __page_aligned_data;
 struct vdso_data *vdso_data = &vdso_data_store.data;
 
-#ifdef CONFIG_COMPAT
+#ifdef CONFIG_AARCH32_EL0
 /*
  * Create and map the vectors page for AArch32 tasks.
  */
@@ -107,7 +107,7 @@ int aarch32_setup_vectors_page(struct linux_binprm *bprm, int uses_interp)
 
 	return PTR_ERR_OR_ZERO(ret);
 }
-#endif /* CONFIG_COMPAT */
+#endif /* CONFIG_AARCH32_EL0 */
 
 static struct vm_special_mapping vdso_spec[2];
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [PATCH v5 05/23] arm64:ilp32: expose 'kernel_long' as 'long long' for ILP32
  2015-09-29 22:13 ` Yury Norov
@ 2015-09-29 22:14   ` Yury Norov
  -1 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-09-29 22:14 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel, catalin.marinas, arnd, agraf,
	bamvor.zhangjian
  Cc: yury.norov, philipp.tomsich, apinski, christoph.muellner,
	klimov.linux, Yury Norov

From: Andrew Pinski <apinski@cavium.com>

Since we want time_t and some other userland types to be the same
between ILP32 and LP64, we define __kernel_long_t to be long long.

To reuse the bulk of LP64 system calls (and data structures), the LP64
kernel data types ('kernel_long', 'kernel_ulong') are exposed as their
ILP32 'long long' and 'unsigned long long' equivalents to allow glibc
to correctly interpret most data-structures used in the kernel ABI
(i.el with the exception of those, that include pointers).

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>

diff --git a/arch/arm64/include/uapi/asm/posix_types.h b/arch/arm64/include/uapi/asm/posix_types.h
index 7985ff6..d6a7cb5 100644
--- a/arch/arm64/include/uapi/asm/posix_types.h
+++ b/arch/arm64/include/uapi/asm/posix_types.h
@@ -5,6 +5,16 @@ typedef unsigned short __kernel_old_uid_t;
 typedef unsigned short __kernel_old_gid_t;
 #define __kernel_old_uid_t __kernel_old_uid_t
 
+#if defined(__ILP32__)
+/* The ILP32 kernel ABI reuses LP64 system calls where possible; to
+   this end, the equivalent ILP32 type definitions are used (a 64bit
+   'long'-type in LP64 corresponds to a 'long long' in LP64).  */
+
+typedef long long           __kernel_long_t;
+typedef unsigned long long  __kernel_ulong_t;
+#define __kernel_long_t     __kernel_long_t
+#endif /* defined(__ILP32__) */
+
 #include <asm-generic/posix_types.h>
 
-#endif /*  __ASM_POSIX_TYPES_H */
+#endif /* __ASM_POSIX_TYPES_H */
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [PATCH v5 05/23] arm64:ilp32: expose 'kernel_long' as 'long long' for ILP32
@ 2015-09-29 22:14   ` Yury Norov
  0 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-09-29 22:14 UTC (permalink / raw)
  To: linux-arm-kernel

From: Andrew Pinski <apinski@cavium.com>

Since we want time_t and some other userland types to be the same
between ILP32 and LP64, we define __kernel_long_t to be long long.

To reuse the bulk of LP64 system calls (and data structures), the LP64
kernel data types ('kernel_long', 'kernel_ulong') are exposed as their
ILP32 'long long' and 'unsigned long long' equivalents to allow glibc
to correctly interpret most data-structures used in the kernel ABI
(i.el with the exception of those, that include pointers).

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>

diff --git a/arch/arm64/include/uapi/asm/posix_types.h b/arch/arm64/include/uapi/asm/posix_types.h
index 7985ff6..d6a7cb5 100644
--- a/arch/arm64/include/uapi/asm/posix_types.h
+++ b/arch/arm64/include/uapi/asm/posix_types.h
@@ -5,6 +5,16 @@ typedef unsigned short __kernel_old_uid_t;
 typedef unsigned short __kernel_old_gid_t;
 #define __kernel_old_uid_t __kernel_old_uid_t
 
+#if defined(__ILP32__)
+/* The ILP32 kernel ABI reuses LP64 system calls where possible; to
+   this end, the equivalent ILP32 type definitions are used (a 64bit
+   'long'-type in LP64 corresponds to a 'long long' in LP64).  */
+
+typedef long long           __kernel_long_t;
+typedef unsigned long long  __kernel_ulong_t;
+#define __kernel_long_t     __kernel_long_t
+#endif /* defined(__ILP32__) */
+
 #include <asm-generic/posix_types.h>
 
-#endif /*  __ASM_POSIX_TYPES_H */
+#endif /* __ASM_POSIX_TYPES_H */
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [PATCH v5 06/23] arm64:uapi: set __BITS_PER_LONG correctly for ILP32 and LP64
  2015-09-29 22:13 ` Yury Norov
@ 2015-09-29 22:14   ` Yury Norov
  -1 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-09-29 22:14 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel, catalin.marinas, arnd, agraf,
	bamvor.zhangjian
  Cc: yury.norov, philipp.tomsich, apinski, christoph.muellner,
	klimov.linux, Yury Norov

From: Andrew Pinski <apinski@cavium.com>

Define __BITS_PER_LONG depending on the ABI used (i.e. check whether
__ILP32__ or __LP64__ is defined).  This is necessary for glibc to
determine the appropriate type definitions for the system call interface.

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>

diff --git a/arch/arm64/include/uapi/asm/bitsperlong.h b/arch/arm64/include/uapi/asm/bitsperlong.h
index fce9c29..4265243 100644
--- a/arch/arm64/include/uapi/asm/bitsperlong.h
+++ b/arch/arm64/include/uapi/asm/bitsperlong.h
@@ -16,7 +16,14 @@
 #ifndef __ASM_BITSPERLONG_H
 #define __ASM_BITSPERLONG_H
 
-#define __BITS_PER_LONG 64
+#if defined(__LP64__)
+/* Assuming __LP64__ will be defined for native ELF64's and not for ILP32. */
+#  define __BITS_PER_LONG 64
+#elif defined(__ILP32__)
+#  define __BITS_PER_LONG 32
+#else
+#  error "Neither LP64 nor ILP32: unsupported ABI in asm/bitsperlong.h"
+#endif
 
 #include <asm-generic/bitsperlong.h>
 
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [PATCH v5 06/23] arm64:uapi: set __BITS_PER_LONG correctly for ILP32 and LP64
@ 2015-09-29 22:14   ` Yury Norov
  0 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-09-29 22:14 UTC (permalink / raw)
  To: linux-arm-kernel

From: Andrew Pinski <apinski@cavium.com>

Define __BITS_PER_LONG depending on the ABI used (i.e. check whether
__ILP32__ or __LP64__ is defined).  This is necessary for glibc to
determine the appropriate type definitions for the system call interface.

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>

diff --git a/arch/arm64/include/uapi/asm/bitsperlong.h b/arch/arm64/include/uapi/asm/bitsperlong.h
index fce9c29..4265243 100644
--- a/arch/arm64/include/uapi/asm/bitsperlong.h
+++ b/arch/arm64/include/uapi/asm/bitsperlong.h
@@ -16,7 +16,14 @@
 #ifndef __ASM_BITSPERLONG_H
 #define __ASM_BITSPERLONG_H
 
-#define __BITS_PER_LONG 64
+#if defined(__LP64__)
+/* Assuming __LP64__ will be defined for native ELF64's and not for ILP32. */
+#  define __BITS_PER_LONG 64
+#elif defined(__ILP32__)
+#  define __BITS_PER_LONG 32
+#else
+#  error "Neither LP64 nor ILP32: unsupported ABI in asm/bitsperlong.h"
+#endif
 
 #include <asm-generic/bitsperlong.h>
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [PATCH v5 07/23] arm64:ilp32: share signal structures between ILP32 and LP64 ABIs
  2015-09-29 22:13 ` Yury Norov
@ 2015-09-29 22:14   ` Yury Norov
  -1 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-09-29 22:14 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel, catalin.marinas, arnd, agraf,
	bamvor.zhangjian
  Cc: yury.norov, philipp.tomsich, apinski, christoph.muellner,
	klimov.linux, Yury Norov

From: Andrew Pinski <apinski@cavium.com>

Defines the macros which allow the signal structures to be the same between
ILP32 and LP64.

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>

diff --git a/arch/arm64/include/uapi/asm/siginfo.h b/arch/arm64/include/uapi/asm/siginfo.h
index 5a74a08..1a6aa32 100644
--- a/arch/arm64/include/uapi/asm/siginfo.h
+++ b/arch/arm64/include/uapi/asm/siginfo.h
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2012 ARM Ltd.
+ * Copyright (C) 2014 Cavium Inc.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -18,6 +19,26 @@
 
 #define __ARCH_SI_PREAMBLE_SIZE	(4 * sizeof(int))
 
+#ifdef __ILP32__
+# ifdef __AARCH64EB__
+#  define __SIGINFO_INNER(type, field)		\
+		int __pad#field;		\
+		type field
+# else
+#  define __SIGINFO_INNER(type, field)		\
+		type field;			\
+		int __pad#field
+# endif
+
+# undef __SIGINFO_VOIDPOINTER
+# define __SIGINFO_VOIDPOINTER(field)		\
+		__SIGINFO_INNER(void __user*, field)
+# undef __SIGINFO_BAND
+
+# define __SIGINFO_BAND(field)			\
+	__SIGINFO_INNER(long, field)
+#endif
+
 #include <asm-generic/siginfo.h>
 
 #endif
diff --git a/arch/arm64/include/uapi/asm/signal.h b/arch/arm64/include/uapi/asm/signal.h
index 8d1e723..d90d53b 100644
--- a/arch/arm64/include/uapi/asm/signal.h
+++ b/arch/arm64/include/uapi/asm/signal.h
@@ -19,6 +19,38 @@
 /* Required for AArch32 compatibility. */
 #define SA_RESTORER	0x04000000
 
+/* For ILP32, sigset should be the same size fields as LP64 so use
+   unsigned long long. */
+#ifdef __ILP32__
+#define __SIGSET_INNER_TYPE __extension__ unsigned long long
+#define _NSIG_BPW 64
+
+# ifdef __AARCH64EB__
+#  define __SIGNAL_INNER(type, field)		\
+	__extension__ struct {			\
+		int __pad_##field;		\
+		type field;			\
+	} __attribute__((aligned(8)))
+# else
+#  define __SIGNAL_INNER(type, field)		\
+	__extension__ struct {			\
+		type field;			\
+		int __pad_##field;		\
+	} __attribute__((aligned(8)))
+# endif
+
+# define __SIGACTION_HANDLER(field)		\
+	__SIGNAL_INNER(__sighandler_t, field)
+
+
+#define __SIGACTION_FLAGS(field)		\
+	__extension__ unsigned long long field
+
+#define __SIGACTION_RESTORER(field)		\
+	__SIGNAL_INNER(__sigrestore_t, field)
+
+#endif
+
 #include <asm-generic/signal.h>
 
 #endif
diff --git a/include/uapi/asm-generic/siginfo.h b/include/uapi/asm-generic/siginfo.h
index 1e35520..be640a9 100644
--- a/include/uapi/asm-generic/siginfo.h
+++ b/include/uapi/asm-generic/siginfo.h
@@ -4,9 +4,17 @@
 #include <linux/compiler.h>
 #include <linux/types.h>
 
+#ifndef __SIGINFO_VOIDPOINTER
+#define __SIGINFO_VOIDPOINTER(field) void __user *field
+#endif
+
+#ifndef __SIGINFO_BAND
+#define __SIGINFO_BAND(field) __ARCH_SI_BAND_T field
+#endif
+
 typedef union sigval {
 	int sival_int;
-	void __user *sival_ptr;
+	__SIGINFO_VOIDPOINTER(sival_ptr);
 } sigval_t;
 
 /*
@@ -86,7 +94,7 @@ typedef struct siginfo {
 
 		/* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
 		struct {
-			void __user *_addr; /* faulting insn/memory ref. */
+			__SIGINFO_VOIDPOINTER(_addr); /* faulting insn/memory ref. */
 #ifdef __ARCH_SI_TRAPNO
 			int _trapno;	/* TRAP # which caused the signal */
 #endif
@@ -99,13 +107,13 @@ typedef struct siginfo {
 
 		/* SIGPOLL */
 		struct {
-			__ARCH_SI_BAND_T _band;	/* POLL_IN, POLL_OUT, POLL_MSG */
+			__SIGINFO_BAND(_band);	/* POLL_IN, POLL_OUT, POLL_MSG */
 			int _fd;
 		} _sigpoll;
 
 		/* SIGSYS */
 		struct {
-			void __user *_call_addr; /* calling user insn */
+			__SIGINFO_VOIDPOINTER(_call_addr); /* calling user insn */
 			int _syscall;	/* triggering system call number */
 			unsigned int _arch;	/* AUDIT_ARCH_* of syscall */
 		} _sigsys;
@@ -290,6 +298,7 @@ typedef struct sigevent {
 		int _pad[SIGEV_PAD_SIZE];
 		 int _tid;
 
+		/* Note these two are handled only in userspace */
 		struct {
 			void (*_function)(sigval_t);
 			void *_attribute;	/* really pthread_attr_t */
diff --git a/include/uapi/asm-generic/signal.h b/include/uapi/asm-generic/signal.h
index 9df61f1..c4ce238 100644
--- a/include/uapi/asm-generic/signal.h
+++ b/include/uapi/asm-generic/signal.h
@@ -4,7 +4,9 @@
 #include <linux/types.h>
 
 #define _NSIG		64
+#ifndef _NSIG_BPW
 #define _NSIG_BPW	__BITS_PER_LONG
+#endif
 #define _NSIG_WORDS	(_NSIG / _NSIG_BPW)
 
 #define SIGHUP		 1
@@ -83,9 +85,13 @@
 #define MINSIGSTKSZ	2048
 #define SIGSTKSZ	8192
 
+#ifndef __SIGSET_INNER_TYPE
+#define __SIGSET_INNER_TYPE unsigned long
+#endif
+
 #ifndef __ASSEMBLY__
 typedef struct {
-	unsigned long sig[_NSIG_WORDS];
+	__SIGSET_INNER_TYPE sig[_NSIG_WORDS];
 } sigset_t;
 
 /* not actually used, but required for linux/syscalls.h */
@@ -98,11 +104,24 @@ typedef unsigned long old_sigset_t;
 #endif
 
 #ifndef __KERNEL__
+
+#ifndef __SIGACTION_HANDLER
+#define __SIGACTION_HANDLER(field)	__sighandler_t field
+#endif
+
+#ifndef __SIGACTION_FLAGS
+#define __SIGACTION_FLAGS(field)	unsigned long field
+#endif
+
+#ifndef __SIGACTION_RESTORER
+#define __SIGACTION_RESTORER(field)	__sigrestore_t field
+#endif
+
 struct sigaction {
-	__sighandler_t sa_handler;
-	unsigned long sa_flags;
+	__SIGACTION_HANDLER(sa_handler);
+	__SIGACTION_FLAGS(sa_flags);
 #ifdef SA_RESTORER
-	__sigrestore_t sa_restorer;
+	__SIGACTION_RESTORER(sa_restorer);
 #endif
 	sigset_t sa_mask;		/* mask last for extensibility */
 };
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [PATCH v5 07/23] arm64:ilp32: share signal structures between ILP32 and LP64 ABIs
@ 2015-09-29 22:14   ` Yury Norov
  0 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-09-29 22:14 UTC (permalink / raw)
  To: linux-arm-kernel

From: Andrew Pinski <apinski@cavium.com>

Defines the macros which allow the signal structures to be the same between
ILP32 and LP64.

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>

diff --git a/arch/arm64/include/uapi/asm/siginfo.h b/arch/arm64/include/uapi/asm/siginfo.h
index 5a74a08..1a6aa32 100644
--- a/arch/arm64/include/uapi/asm/siginfo.h
+++ b/arch/arm64/include/uapi/asm/siginfo.h
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2012 ARM Ltd.
+ * Copyright (C) 2014 Cavium Inc.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -18,6 +19,26 @@
 
 #define __ARCH_SI_PREAMBLE_SIZE	(4 * sizeof(int))
 
+#ifdef __ILP32__
+# ifdef __AARCH64EB__
+#  define __SIGINFO_INNER(type, field)		\
+		int __pad#field;		\
+		type field
+# else
+#  define __SIGINFO_INNER(type, field)		\
+		type field;			\
+		int __pad#field
+# endif
+
+# undef __SIGINFO_VOIDPOINTER
+# define __SIGINFO_VOIDPOINTER(field)		\
+		__SIGINFO_INNER(void __user*, field)
+# undef __SIGINFO_BAND
+
+# define __SIGINFO_BAND(field)			\
+	__SIGINFO_INNER(long, field)
+#endif
+
 #include <asm-generic/siginfo.h>
 
 #endif
diff --git a/arch/arm64/include/uapi/asm/signal.h b/arch/arm64/include/uapi/asm/signal.h
index 8d1e723..d90d53b 100644
--- a/arch/arm64/include/uapi/asm/signal.h
+++ b/arch/arm64/include/uapi/asm/signal.h
@@ -19,6 +19,38 @@
 /* Required for AArch32 compatibility. */
 #define SA_RESTORER	0x04000000
 
+/* For ILP32, sigset should be the same size fields as LP64 so use
+   unsigned long long. */
+#ifdef __ILP32__
+#define __SIGSET_INNER_TYPE __extension__ unsigned long long
+#define _NSIG_BPW 64
+
+# ifdef __AARCH64EB__
+#  define __SIGNAL_INNER(type, field)		\
+	__extension__ struct {			\
+		int __pad_##field;		\
+		type field;			\
+	} __attribute__((aligned(8)))
+# else
+#  define __SIGNAL_INNER(type, field)		\
+	__extension__ struct {			\
+		type field;			\
+		int __pad_##field;		\
+	} __attribute__((aligned(8)))
+# endif
+
+# define __SIGACTION_HANDLER(field)		\
+	__SIGNAL_INNER(__sighandler_t, field)
+
+
+#define __SIGACTION_FLAGS(field)		\
+	__extension__ unsigned long long field
+
+#define __SIGACTION_RESTORER(field)		\
+	__SIGNAL_INNER(__sigrestore_t, field)
+
+#endif
+
 #include <asm-generic/signal.h>
 
 #endif
diff --git a/include/uapi/asm-generic/siginfo.h b/include/uapi/asm-generic/siginfo.h
index 1e35520..be640a9 100644
--- a/include/uapi/asm-generic/siginfo.h
+++ b/include/uapi/asm-generic/siginfo.h
@@ -4,9 +4,17 @@
 #include <linux/compiler.h>
 #include <linux/types.h>
 
+#ifndef __SIGINFO_VOIDPOINTER
+#define __SIGINFO_VOIDPOINTER(field) void __user *field
+#endif
+
+#ifndef __SIGINFO_BAND
+#define __SIGINFO_BAND(field) __ARCH_SI_BAND_T field
+#endif
+
 typedef union sigval {
 	int sival_int;
-	void __user *sival_ptr;
+	__SIGINFO_VOIDPOINTER(sival_ptr);
 } sigval_t;
 
 /*
@@ -86,7 +94,7 @@ typedef struct siginfo {
 
 		/* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
 		struct {
-			void __user *_addr; /* faulting insn/memory ref. */
+			__SIGINFO_VOIDPOINTER(_addr); /* faulting insn/memory ref. */
 #ifdef __ARCH_SI_TRAPNO
 			int _trapno;	/* TRAP # which caused the signal */
 #endif
@@ -99,13 +107,13 @@ typedef struct siginfo {
 
 		/* SIGPOLL */
 		struct {
-			__ARCH_SI_BAND_T _band;	/* POLL_IN, POLL_OUT, POLL_MSG */
+			__SIGINFO_BAND(_band);	/* POLL_IN, POLL_OUT, POLL_MSG */
 			int _fd;
 		} _sigpoll;
 
 		/* SIGSYS */
 		struct {
-			void __user *_call_addr; /* calling user insn */
+			__SIGINFO_VOIDPOINTER(_call_addr); /* calling user insn */
 			int _syscall;	/* triggering system call number */
 			unsigned int _arch;	/* AUDIT_ARCH_* of syscall */
 		} _sigsys;
@@ -290,6 +298,7 @@ typedef struct sigevent {
 		int _pad[SIGEV_PAD_SIZE];
 		 int _tid;
 
+		/* Note these two are handled only in userspace */
 		struct {
 			void (*_function)(sigval_t);
 			void *_attribute;	/* really pthread_attr_t */
diff --git a/include/uapi/asm-generic/signal.h b/include/uapi/asm-generic/signal.h
index 9df61f1..c4ce238 100644
--- a/include/uapi/asm-generic/signal.h
+++ b/include/uapi/asm-generic/signal.h
@@ -4,7 +4,9 @@
 #include <linux/types.h>
 
 #define _NSIG		64
+#ifndef _NSIG_BPW
 #define _NSIG_BPW	__BITS_PER_LONG
+#endif
 #define _NSIG_WORDS	(_NSIG / _NSIG_BPW)
 
 #define SIGHUP		 1
@@ -83,9 +85,13 @@
 #define MINSIGSTKSZ	2048
 #define SIGSTKSZ	8192
 
+#ifndef __SIGSET_INNER_TYPE
+#define __SIGSET_INNER_TYPE unsigned long
+#endif
+
 #ifndef __ASSEMBLY__
 typedef struct {
-	unsigned long sig[_NSIG_WORDS];
+	__SIGSET_INNER_TYPE sig[_NSIG_WORDS];
 } sigset_t;
 
 /* not actually used, but required for linux/syscalls.h */
@@ -98,11 +104,24 @@ typedef unsigned long old_sigset_t;
 #endif
 
 #ifndef __KERNEL__
+
+#ifndef __SIGACTION_HANDLER
+#define __SIGACTION_HANDLER(field)	__sighandler_t field
+#endif
+
+#ifndef __SIGACTION_FLAGS
+#define __SIGACTION_FLAGS(field)	unsigned long field
+#endif
+
+#ifndef __SIGACTION_RESTORER
+#define __SIGACTION_RESTORER(field)	__sigrestore_t field
+#endif
+
 struct sigaction {
-	__sighandler_t sa_handler;
-	unsigned long sa_flags;
+	__SIGACTION_HANDLER(sa_handler);
+	__SIGACTION_FLAGS(sa_flags);
 #ifdef SA_RESTORER
-	__sigrestore_t sa_restorer;
+	__SIGACTION_RESTORER(sa_restorer);
 #endif
 	sigset_t sa_mask;		/* mask last for extensibility */
 };
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [PATCH v5 08/23] arm64:ilp32: use 64bit syscall-names for ILP32 when passing 64bit registers
  2015-09-29 22:13 ` Yury Norov
@ 2015-09-29 22:14   ` Yury Norov
  -1 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-09-29 22:14 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel, catalin.marinas, arnd, agraf,
	bamvor.zhangjian
  Cc: yury.norov, philipp.tomsich, apinski, christoph.muellner,
	klimov.linux, Yury Norov

From: Andrew Pinski <apinski@cavium.com>

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: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>

diff --git a/include/uapi/asm-generic/unistd.h b/include/uapi/asm-generic/unistd.h
index ee12400..97b0438 100644
--- a/include/uapi/asm-generic/unistd.h
+++ b/include/uapi/asm-generic/unistd.h
@@ -889,8 +889,11 @@ __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(__SYSCALL_NONCOMPAT)
 #define __NR_fcntl __NR3264_fcntl
 #define __NR_statfs __NR3264_statfs
 #define __NR_fstatfs __NR3264_fstatfs
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [PATCH v5 08/23] arm64:ilp32: use 64bit syscall-names for ILP32 when passing 64bit registers
@ 2015-09-29 22:14   ` Yury Norov
  0 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-09-29 22:14 UTC (permalink / raw)
  To: linux-arm-kernel

From: Andrew Pinski <apinski@cavium.com>

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: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>

diff --git a/include/uapi/asm-generic/unistd.h b/include/uapi/asm-generic/unistd.h
index ee12400..97b0438 100644
--- a/include/uapi/asm-generic/unistd.h
+++ b/include/uapi/asm-generic/unistd.h
@@ -889,8 +889,11 @@ __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(__SYSCALL_NONCOMPAT)
 #define __NR_fcntl __NR3264_fcntl
 #define __NR_statfs __NR3264_statfs
 #define __NR_fstatfs __NR3264_fstatfs
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [PATCH v5 09/23] arm64:ilp32: use non-compat syscall names for ILP32 as for LP64
  2015-09-29 22:13 ` Yury Norov
@ 2015-09-29 22:14   ` Yury Norov
  -1 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-09-29 22:14 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel, catalin.marinas, arnd, agraf,
	bamvor.zhangjian
  Cc: yury.norov, philipp.tomsich, apinski, christoph.muellner,
	klimov.linux, Yury Norov

From: Andrew Pinski <apinski@cavium.com>

Define __ARCH_WANT_64BIT_SYSCALLS for ILP32, so we (can) use the 64bit
syscall names for ILP32.

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>

diff --git a/arch/arm64/include/uapi/asm/unistd.h b/arch/arm64/include/uapi/asm/unistd.h
index 1caadc2..067eab0 100644
--- a/arch/arm64/include/uapi/asm/unistd.h
+++ b/arch/arm64/include/uapi/asm/unistd.h
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2012 ARM Ltd.
+ * Copyright (C) 2015 Cavium Inc.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -13,4 +14,10 @@
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
+
+/* For ILP32 AARCH64, we want to use the non compat names. */
+#if defined(__aarch64__) && defined(__ILP32__)
+#define __SYSCALL_NONCOMPAT
+#endif
+
 #include <asm-generic/unistd.h>
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [PATCH v5 09/23] arm64:ilp32: use non-compat syscall names for ILP32 as for LP64
@ 2015-09-29 22:14   ` Yury Norov
  0 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-09-29 22:14 UTC (permalink / raw)
  To: linux-arm-kernel

From: Andrew Pinski <apinski@cavium.com>

Define __ARCH_WANT_64BIT_SYSCALLS for ILP32, so we (can) use the 64bit
syscall names for ILP32.

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>

diff --git a/arch/arm64/include/uapi/asm/unistd.h b/arch/arm64/include/uapi/asm/unistd.h
index 1caadc2..067eab0 100644
--- a/arch/arm64/include/uapi/asm/unistd.h
+++ b/arch/arm64/include/uapi/asm/unistd.h
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2012 ARM Ltd.
+ * Copyright (C) 2015 Cavium Inc.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -13,4 +14,10 @@
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
+
+/* For ILP32 AARCH64, we want to use the non compat names. */
+#if defined(__aarch64__) && defined(__ILP32__)
+#define __SYSCALL_NONCOMPAT
+#endif
+
 #include <asm-generic/unistd.h>
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [PATCH v5 10/23] arm64: introduce is_a32_task and is_a32_thread (for AArch32 compat)
  2015-09-29 22:13 ` Yury Norov
@ 2015-09-29 22:14   ` Yury Norov
  -1 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-09-29 22:14 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel, catalin.marinas, arnd, agraf,
	bamvor.zhangjian
  Cc: yury.norov, philipp.tomsich, apinski, christoph.muellner,
	klimov.linux, Yury Norov

From: Andrew Pinski <apinski@cavium.com>

This patch introduces is_a32_compat_task and is_a32_thread so it is
easier
to say this is a a32 specific thread or a generic compat thread/task.

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>

diff --git a/arch/arm64/include/asm/compat.h b/arch/arm64/include/asm/compat.h
index 7fbed69..3a2976d 100644
--- a/arch/arm64/include/asm/compat.h
+++ b/arch/arm64/include/asm/compat.h
@@ -299,15 +299,25 @@ struct compat_shmid64_ds {
 	compat_ulong_t __unused5;
 };
 
-static inline int is_compat_task(void)
+#ifdef CONFIG_AARCH32_EL0
+static inline int is_a32_compat_task(void)
 {
 	return test_thread_flag(TIF_32BIT);
 }
-
-static inline int is_compat_thread(struct thread_info *thread)
+static inline int is_a32_compat_thread(struct thread_info *thread)
 {
 	return test_ti_thread_flag(thread, TIF_32BIT);
 }
+#else
+static inline int is_a32_compat_task(void)
+{
+	return 0;
+}
+static inline int is_a32_compat_thread(struct thread_info *thread)
+{
+	return 0;
+}
+#endif
 
 #else /* !CONFIG_COMPAT */
 
@@ -316,6 +326,21 @@ static inline int is_compat_thread(struct thread_info *thread)
 	return 0;
 }
 
+static inline int is_a32_compat_task(void)
+{
+	return 0;
+}
+
 #endif /* CONFIG_COMPAT */
+
+static inline int is_compat_task(void)
+{
+	return is_a32_compat_task();
+}
+
+static inline int is_compat_thread(struct thread_info *thread)
+{
+	return is_a32_compat_thread(thread);
+}
 #endif /* __KERNEL__ */
 #endif /* __ASM_COMPAT_H */
diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h
index f40c51b..9ecbaf2 100644
--- a/arch/arm64/include/asm/elf.h
+++ b/arch/arm64/include/asm/elf.h
@@ -149,7 +149,7 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
 
 /* 1GB of VA */
 #ifdef CONFIG_COMPAT
-#define STACK_RND_MASK			(test_thread_flag(TIF_32BIT) ? \
+#define STACK_RND_MASK			(is_compat_task() ? \
 						0x7ff >> (PAGE_SHIFT - 12) : \
 						0x3ffff >> (PAGE_SHIFT - 12))
 #else
diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
index 6b4c3ad..337f8e1 100644
--- a/arch/arm64/include/asm/memory.h
+++ b/arch/arm64/include/asm/memory.h
@@ -58,7 +58,7 @@
 
 #ifdef CONFIG_COMPAT
 #define TASK_SIZE_32		UL(0x100000000)
-#define TASK_SIZE		(test_thread_flag(TIF_32BIT) ? \
+#define TASK_SIZE		(is_compat_task() ?		\
 				TASK_SIZE_32 : TASK_SIZE_64)
 #define TASK_SIZE_OF(tsk)	(test_tsk_thread_flag(tsk, TIF_32BIT) ? \
 				TASK_SIZE_32 : TASK_SIZE_64)
diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h
index 98f3235..f1bba0c 100644
--- a/arch/arm64/include/asm/processor.h
+++ b/arch/arm64/include/asm/processor.h
@@ -39,7 +39,7 @@
 #define STACK_TOP_MAX		TASK_SIZE_64
 #ifdef CONFIG_COMPAT
 #define AARCH32_VECTORS_BASE	0xffff0000
-#define STACK_TOP		(test_thread_flag(TIF_32BIT) ? \
+#define STACK_TOP		(is_compat_task() ? \
 				AARCH32_VECTORS_BASE : STACK_TOP_MAX)
 #else
 #define STACK_TOP		STACK_TOP_MAX
diff --git a/arch/arm64/include/asm/thread_info.h b/arch/arm64/include/asm/thread_info.h
index dcd06d1..7d03565 100644
--- a/arch/arm64/include/asm/thread_info.h
+++ b/arch/arm64/include/asm/thread_info.h
@@ -110,7 +110,7 @@ static inline struct thread_info *current_thread_info(void)
 #define TIF_FREEZE		19
 #define TIF_RESTORE_SIGMASK	20
 #define TIF_SINGLESTEP		21
-#define TIF_32BIT		22	/* 32bit process */
+#define TIF_32BIT		22	/* AARCH32 process */
 #define TIF_SWITCH_MM		23	/* deferred switch_mm */
 
 #define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
diff --git a/arch/arm64/kernel/hw_breakpoint.c b/arch/arm64/kernel/hw_breakpoint.c
index bba85c8..917f6e1 100644
--- a/arch/arm64/kernel/hw_breakpoint.c
+++ b/arch/arm64/kernel/hw_breakpoint.c
@@ -420,7 +420,7 @@ static int arch_build_bp_info(struct perf_event *bp)
 	 * Watchpoints can be of length 1, 2, 4 or 8 bytes.
 	 */
 	if (info->ctrl.type == ARM_BREAKPOINT_EXECUTE) {
-		if (is_compat_task()) {
+		if (is_a32_compat_task()) {
 			if (info->ctrl.len != ARM_BREAKPOINT_LEN_2 &&
 			    info->ctrl.len != ARM_BREAKPOINT_LEN_4)
 				return -EINVAL;
@@ -477,7 +477,7 @@ int arch_validate_hwbkpt_settings(struct perf_event *bp)
 	 * AArch32 tasks expect some simple alignment fixups, so emulate
 	 * that here.
 	 */
-	if (is_compat_task()) {
+	if (is_a32_compat_task()) {
 		if (info->ctrl.len == ARM_BREAKPOINT_LEN_8)
 			alignment_mask = 0x7;
 		else
@@ -664,7 +664,7 @@ static int watchpoint_handler(unsigned long addr, unsigned int esr,
 
 		info = counter_arch_bp(wp);
 		/* AArch32 watchpoints are either 4 or 8 bytes aligned. */
-		if (is_compat_task()) {
+		if (is_a32_compat_task()) {
 			if (info->ctrl.len == ARM_BREAKPOINT_LEN_8)
 				alignment_mask = 0x7;
 			else
diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c
index 223b093..a6b0251 100644
--- a/arch/arm64/kernel/process.c
+++ b/arch/arm64/kernel/process.c
@@ -259,7 +259,7 @@ int copy_thread(unsigned long clone_flags, unsigned long stack_start,
 		asm("mrs %0, tpidr_el0" : "=r" (*task_user_tls(p)));
 
 		if (stack_start) {
-			if (is_compat_thread(task_thread_info(p)))
+			if (is_a32_compat_thread(task_thread_info(p)))
 				childregs->compat_sp = stack_start;
 			/* 16-byte aligned stack mandatory on AArch64 */
 			else if (stack_start & 15)
@@ -296,7 +296,7 @@ static void tls_thread_switch(struct task_struct *next)
 	*task_user_tls(current) = tpidr;
 
 	tpidr = *task_user_tls(next);
-	tpidrro = is_compat_thread(task_thread_info(next)) ?
+	tpidrro = is_a32_compat_thread(task_thread_info(next)) ?
 		  next->thread.tp_value : 0;
 
 	asm(
diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c
index 04b4972..8cd1eb7 100644
--- a/arch/arm64/kernel/ptrace.c
+++ b/arch/arm64/kernel/ptrace.c
@@ -79,7 +79,7 @@ static void ptrace_hbptriggered(struct perf_event *bp,
 #ifdef CONFIG_AARCH32_EL0
 	int i;
 
-	if (!is_compat_task())
+	if (!is_a32_compat_task())
 		goto send_sig;
 
 	for (i = 0; i < ARM_MAX_BRP; ++i) {
@@ -1198,7 +1198,7 @@ long compat_a32_arch_ptrace(struct task_struct *child, compat_long_t request,
 long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
 			compat_ulong_t caddr, compat_ulong_t cdata)
 {
-	if (is_compat_task())
+	if (is_a32_compat_task())
 		return compat_a32_arch_ptrace(child, request, caddr, cdata);
 	return compat_ptrace_request(child, request, caddr, cdata);
 }
@@ -1214,9 +1214,9 @@ const struct user_regset_view *task_user_regset_view(struct task_struct *task)
 	 * 32-bit children use an extended user_aarch32_ptrace_view to allow
 	 * access to the TLS register.
 	 */
-	if (is_compat_task())
+	if (is_a32_compat_task())
 		return &user_aarch32_view;
-	else if (is_compat_thread(task_thread_info(task)))
+	else if (is_a32_compat_thread(task_thread_info(task)))
 		return &user_aarch32_ptrace_view;
 #endif
 	return &user_aarch64_view;
@@ -1243,7 +1243,7 @@ static void tracehook_report_syscall(struct pt_regs *regs,
 	 * A scratch register (ip(r12) on AArch32, x7 on AArch64) is
 	 * used to denote syscall entry/exit:
 	 */
-	regno = (is_compat_task() ? 12 : 7);
+	regno = (is_a32_compat_task() ? 12 : 7);
 	saved_reg = regs->regs[regno];
 	regs->regs[regno] = dir;
 
diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c
index 964a2a4..2e00531 100644
--- a/arch/arm64/kernel/signal.c
+++ b/arch/arm64/kernel/signal.c
@@ -276,7 +276,7 @@ static int setup_rt_frame(int usig, struct ksignal *ksig, sigset_t *set,
 
 static void setup_restart_syscall(struct pt_regs *regs)
 {
-	if (is_compat_task())
+	if (is_a32_compat_task())
 		compat_setup_restart_syscall(regs);
 	else
 		regs->regs[8] = __NR_restart_syscall;
@@ -295,7 +295,7 @@ static void handle_signal(struct ksignal *ksig, struct pt_regs *regs)
 	/*
 	 * Set up the stack frame
 	 */
-	if (is_compat_task()) {
+	if (is_a32_compat_task()) {
 		if (ksig->ka.sa.sa_flags & SA_SIGINFO)
 			ret = compat_setup_rt_frame(usig, ksig, oldset, regs);
 		else
diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c
index 9ce9894..bc973d0 100644
--- a/arch/arm64/kernel/traps.c
+++ b/arch/arm64/kernel/traps.c
@@ -365,7 +365,7 @@ asmlinkage long do_ni_syscall(struct pt_regs *regs)
 {
 #ifdef CONFIG_AARCH32_EL0
 	long ret;
-	if (is_compat_task()) {
+	if (is_a32_compat_task()) {
 		ret = compat_arm_syscall(regs);
 		if (ret != -ENOSYS)
 			return ret;
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [PATCH v5 10/23] arm64: introduce is_a32_task and is_a32_thread (for AArch32 compat)
@ 2015-09-29 22:14   ` Yury Norov
  0 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-09-29 22:14 UTC (permalink / raw)
  To: linux-arm-kernel

From: Andrew Pinski <apinski@cavium.com>

This patch introduces is_a32_compat_task and is_a32_thread so it is
easier
to say this is a a32 specific thread or a generic compat thread/task.

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>

diff --git a/arch/arm64/include/asm/compat.h b/arch/arm64/include/asm/compat.h
index 7fbed69..3a2976d 100644
--- a/arch/arm64/include/asm/compat.h
+++ b/arch/arm64/include/asm/compat.h
@@ -299,15 +299,25 @@ struct compat_shmid64_ds {
 	compat_ulong_t __unused5;
 };
 
-static inline int is_compat_task(void)
+#ifdef CONFIG_AARCH32_EL0
+static inline int is_a32_compat_task(void)
 {
 	return test_thread_flag(TIF_32BIT);
 }
-
-static inline int is_compat_thread(struct thread_info *thread)
+static inline int is_a32_compat_thread(struct thread_info *thread)
 {
 	return test_ti_thread_flag(thread, TIF_32BIT);
 }
+#else
+static inline int is_a32_compat_task(void)
+{
+	return 0;
+}
+static inline int is_a32_compat_thread(struct thread_info *thread)
+{
+	return 0;
+}
+#endif
 
 #else /* !CONFIG_COMPAT */
 
@@ -316,6 +326,21 @@ static inline int is_compat_thread(struct thread_info *thread)
 	return 0;
 }
 
+static inline int is_a32_compat_task(void)
+{
+	return 0;
+}
+
 #endif /* CONFIG_COMPAT */
+
+static inline int is_compat_task(void)
+{
+	return is_a32_compat_task();
+}
+
+static inline int is_compat_thread(struct thread_info *thread)
+{
+	return is_a32_compat_thread(thread);
+}
 #endif /* __KERNEL__ */
 #endif /* __ASM_COMPAT_H */
diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h
index f40c51b..9ecbaf2 100644
--- a/arch/arm64/include/asm/elf.h
+++ b/arch/arm64/include/asm/elf.h
@@ -149,7 +149,7 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
 
 /* 1GB of VA */
 #ifdef CONFIG_COMPAT
-#define STACK_RND_MASK			(test_thread_flag(TIF_32BIT) ? \
+#define STACK_RND_MASK			(is_compat_task() ? \
 						0x7ff >> (PAGE_SHIFT - 12) : \
 						0x3ffff >> (PAGE_SHIFT - 12))
 #else
diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
index 6b4c3ad..337f8e1 100644
--- a/arch/arm64/include/asm/memory.h
+++ b/arch/arm64/include/asm/memory.h
@@ -58,7 +58,7 @@
 
 #ifdef CONFIG_COMPAT
 #define TASK_SIZE_32		UL(0x100000000)
-#define TASK_SIZE		(test_thread_flag(TIF_32BIT) ? \
+#define TASK_SIZE		(is_compat_task() ?		\
 				TASK_SIZE_32 : TASK_SIZE_64)
 #define TASK_SIZE_OF(tsk)	(test_tsk_thread_flag(tsk, TIF_32BIT) ? \
 				TASK_SIZE_32 : TASK_SIZE_64)
diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h
index 98f3235..f1bba0c 100644
--- a/arch/arm64/include/asm/processor.h
+++ b/arch/arm64/include/asm/processor.h
@@ -39,7 +39,7 @@
 #define STACK_TOP_MAX		TASK_SIZE_64
 #ifdef CONFIG_COMPAT
 #define AARCH32_VECTORS_BASE	0xffff0000
-#define STACK_TOP		(test_thread_flag(TIF_32BIT) ? \
+#define STACK_TOP		(is_compat_task() ? \
 				AARCH32_VECTORS_BASE : STACK_TOP_MAX)
 #else
 #define STACK_TOP		STACK_TOP_MAX
diff --git a/arch/arm64/include/asm/thread_info.h b/arch/arm64/include/asm/thread_info.h
index dcd06d1..7d03565 100644
--- a/arch/arm64/include/asm/thread_info.h
+++ b/arch/arm64/include/asm/thread_info.h
@@ -110,7 +110,7 @@ static inline struct thread_info *current_thread_info(void)
 #define TIF_FREEZE		19
 #define TIF_RESTORE_SIGMASK	20
 #define TIF_SINGLESTEP		21
-#define TIF_32BIT		22	/* 32bit process */
+#define TIF_32BIT		22	/* AARCH32 process */
 #define TIF_SWITCH_MM		23	/* deferred switch_mm */
 
 #define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
diff --git a/arch/arm64/kernel/hw_breakpoint.c b/arch/arm64/kernel/hw_breakpoint.c
index bba85c8..917f6e1 100644
--- a/arch/arm64/kernel/hw_breakpoint.c
+++ b/arch/arm64/kernel/hw_breakpoint.c
@@ -420,7 +420,7 @@ static int arch_build_bp_info(struct perf_event *bp)
 	 * Watchpoints can be of length 1, 2, 4 or 8 bytes.
 	 */
 	if (info->ctrl.type == ARM_BREAKPOINT_EXECUTE) {
-		if (is_compat_task()) {
+		if (is_a32_compat_task()) {
 			if (info->ctrl.len != ARM_BREAKPOINT_LEN_2 &&
 			    info->ctrl.len != ARM_BREAKPOINT_LEN_4)
 				return -EINVAL;
@@ -477,7 +477,7 @@ int arch_validate_hwbkpt_settings(struct perf_event *bp)
 	 * AArch32 tasks expect some simple alignment fixups, so emulate
 	 * that here.
 	 */
-	if (is_compat_task()) {
+	if (is_a32_compat_task()) {
 		if (info->ctrl.len == ARM_BREAKPOINT_LEN_8)
 			alignment_mask = 0x7;
 		else
@@ -664,7 +664,7 @@ static int watchpoint_handler(unsigned long addr, unsigned int esr,
 
 		info = counter_arch_bp(wp);
 		/* AArch32 watchpoints are either 4 or 8 bytes aligned. */
-		if (is_compat_task()) {
+		if (is_a32_compat_task()) {
 			if (info->ctrl.len == ARM_BREAKPOINT_LEN_8)
 				alignment_mask = 0x7;
 			else
diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c
index 223b093..a6b0251 100644
--- a/arch/arm64/kernel/process.c
+++ b/arch/arm64/kernel/process.c
@@ -259,7 +259,7 @@ int copy_thread(unsigned long clone_flags, unsigned long stack_start,
 		asm("mrs %0, tpidr_el0" : "=r" (*task_user_tls(p)));
 
 		if (stack_start) {
-			if (is_compat_thread(task_thread_info(p)))
+			if (is_a32_compat_thread(task_thread_info(p)))
 				childregs->compat_sp = stack_start;
 			/* 16-byte aligned stack mandatory on AArch64 */
 			else if (stack_start & 15)
@@ -296,7 +296,7 @@ static void tls_thread_switch(struct task_struct *next)
 	*task_user_tls(current) = tpidr;
 
 	tpidr = *task_user_tls(next);
-	tpidrro = is_compat_thread(task_thread_info(next)) ?
+	tpidrro = is_a32_compat_thread(task_thread_info(next)) ?
 		  next->thread.tp_value : 0;
 
 	asm(
diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c
index 04b4972..8cd1eb7 100644
--- a/arch/arm64/kernel/ptrace.c
+++ b/arch/arm64/kernel/ptrace.c
@@ -79,7 +79,7 @@ static void ptrace_hbptriggered(struct perf_event *bp,
 #ifdef CONFIG_AARCH32_EL0
 	int i;
 
-	if (!is_compat_task())
+	if (!is_a32_compat_task())
 		goto send_sig;
 
 	for (i = 0; i < ARM_MAX_BRP; ++i) {
@@ -1198,7 +1198,7 @@ long compat_a32_arch_ptrace(struct task_struct *child, compat_long_t request,
 long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
 			compat_ulong_t caddr, compat_ulong_t cdata)
 {
-	if (is_compat_task())
+	if (is_a32_compat_task())
 		return compat_a32_arch_ptrace(child, request, caddr, cdata);
 	return compat_ptrace_request(child, request, caddr, cdata);
 }
@@ -1214,9 +1214,9 @@ const struct user_regset_view *task_user_regset_view(struct task_struct *task)
 	 * 32-bit children use an extended user_aarch32_ptrace_view to allow
 	 * access to the TLS register.
 	 */
-	if (is_compat_task())
+	if (is_a32_compat_task())
 		return &user_aarch32_view;
-	else if (is_compat_thread(task_thread_info(task)))
+	else if (is_a32_compat_thread(task_thread_info(task)))
 		return &user_aarch32_ptrace_view;
 #endif
 	return &user_aarch64_view;
@@ -1243,7 +1243,7 @@ static void tracehook_report_syscall(struct pt_regs *regs,
 	 * A scratch register (ip(r12) on AArch32, x7 on AArch64) is
 	 * used to denote syscall entry/exit:
 	 */
-	regno = (is_compat_task() ? 12 : 7);
+	regno = (is_a32_compat_task() ? 12 : 7);
 	saved_reg = regs->regs[regno];
 	regs->regs[regno] = dir;
 
diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c
index 964a2a4..2e00531 100644
--- a/arch/arm64/kernel/signal.c
+++ b/arch/arm64/kernel/signal.c
@@ -276,7 +276,7 @@ static int setup_rt_frame(int usig, struct ksignal *ksig, sigset_t *set,
 
 static void setup_restart_syscall(struct pt_regs *regs)
 {
-	if (is_compat_task())
+	if (is_a32_compat_task())
 		compat_setup_restart_syscall(regs);
 	else
 		regs->regs[8] = __NR_restart_syscall;
@@ -295,7 +295,7 @@ static void handle_signal(struct ksignal *ksig, struct pt_regs *regs)
 	/*
 	 * Set up the stack frame
 	 */
-	if (is_compat_task()) {
+	if (is_a32_compat_task()) {
 		if (ksig->ka.sa.sa_flags & SA_SIGINFO)
 			ret = compat_setup_rt_frame(usig, ksig, oldset, regs);
 		else
diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c
index 9ce9894..bc973d0 100644
--- a/arch/arm64/kernel/traps.c
+++ b/arch/arm64/kernel/traps.c
@@ -365,7 +365,7 @@ asmlinkage long do_ni_syscall(struct pt_regs *regs)
 {
 #ifdef CONFIG_AARCH32_EL0
 	long ret;
-	if (is_compat_task()) {
+	if (is_a32_compat_task()) {
 		ret = compat_arm_syscall(regs);
 		if (ret != -ENOSYS)
 			return ret;
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [PATCH v5 11/23] arm64:ilp32: add is_ilp32_compat_{task,thread} and TIF_32BIT_AARCH64
  2015-09-29 22:13 ` Yury Norov
@ 2015-09-29 22:14   ` Yury Norov
  -1 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-09-29 22:14 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel, catalin.marinas, arnd, agraf,
	bamvor.zhangjian
  Cc: yury.norov, philipp.tomsich, apinski, christoph.muellner,
	klimov.linux, Yury Norov

From: Andrew Pinski <apinski@cavium.com>

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>

diff --git a/arch/arm64/include/asm/compat.h b/arch/arm64/include/asm/compat.h
index 3a2976d..f53c4e6 100644
--- a/arch/arm64/include/asm/compat.h
+++ b/arch/arm64/include/asm/compat.h
@@ -319,6 +319,26 @@ static inline int is_a32_compat_thread(struct thread_info *thread)
 }
 #endif
 
+#ifdef CONFIG_ARM64_ILP32
+static inline int is_ilp32_compat_task(void)
+{
+	return test_thread_flag(TIF_32BIT_AARCH64);
+}
+static inline int is_ilp32_compat_thread(struct thread_info *thread)
+{
+	return test_ti_thread_flag(thread, TIF_32BIT_AARCH64);
+}
+#else
+static inline int is_ilp32_compat_task(void)
+{
+	return 0;
+}
+static inline int is_ilp32_compat_thread(struct thread_info *thread)
+{
+	return 0;
+}
+#endif
+
 #else /* !CONFIG_COMPAT */
 
 static inline int is_compat_thread(struct thread_info *thread)
@@ -330,17 +350,25 @@ static inline int is_a32_compat_task(void)
 {
 	return 0;
 }
+static inline int is_ilp32_compat_task(void)
+{
+	return 0;
+}
+static inline int is_ilp32_compat_thread(struct thread_info *thread)
+{
+	return 0;
+}
 
 #endif /* CONFIG_COMPAT */
 
 static inline int is_compat_task(void)
 {
-	return is_a32_compat_task();
+	return is_a32_compat_task() || is_ilp32_compat_task();
 }
 
 static inline int is_compat_thread(struct thread_info *thread)
 {
-	return is_a32_compat_thread(thread);
+	return is_a32_compat_thread(thread) || is_ilp32_compat_thread(thread);
 }
 #endif /* __KERNEL__ */
 #endif /* __ASM_COMPAT_H */
diff --git a/arch/arm64/include/asm/thread_info.h b/arch/arm64/include/asm/thread_info.h
index 7d03565..e72de74 100644
--- a/arch/arm64/include/asm/thread_info.h
+++ b/arch/arm64/include/asm/thread_info.h
@@ -112,6 +112,7 @@ static inline struct thread_info *current_thread_info(void)
 #define TIF_SINGLESTEP		21
 #define TIF_32BIT		22	/* AARCH32 process */
 #define TIF_SWITCH_MM		23	/* deferred switch_mm */
+#define TIF_32BIT_AARCH64	24	/* 32 bit process on AArch64(ILP32) */
 
 #define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1 << TIF_NEED_RESCHED)
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [PATCH v5 11/23] arm64:ilp32: add is_ilp32_compat_{task, thread} and TIF_32BIT_AARCH64
@ 2015-09-29 22:14   ` Yury Norov
  0 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-09-29 22:14 UTC (permalink / raw)
  To: linux-arm-kernel

From: Andrew Pinski <apinski@cavium.com>

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>

diff --git a/arch/arm64/include/asm/compat.h b/arch/arm64/include/asm/compat.h
index 3a2976d..f53c4e6 100644
--- a/arch/arm64/include/asm/compat.h
+++ b/arch/arm64/include/asm/compat.h
@@ -319,6 +319,26 @@ static inline int is_a32_compat_thread(struct thread_info *thread)
 }
 #endif
 
+#ifdef CONFIG_ARM64_ILP32
+static inline int is_ilp32_compat_task(void)
+{
+	return test_thread_flag(TIF_32BIT_AARCH64);
+}
+static inline int is_ilp32_compat_thread(struct thread_info *thread)
+{
+	return test_ti_thread_flag(thread, TIF_32BIT_AARCH64);
+}
+#else
+static inline int is_ilp32_compat_task(void)
+{
+	return 0;
+}
+static inline int is_ilp32_compat_thread(struct thread_info *thread)
+{
+	return 0;
+}
+#endif
+
 #else /* !CONFIG_COMPAT */
 
 static inline int is_compat_thread(struct thread_info *thread)
@@ -330,17 +350,25 @@ static inline int is_a32_compat_task(void)
 {
 	return 0;
 }
+static inline int is_ilp32_compat_task(void)
+{
+	return 0;
+}
+static inline int is_ilp32_compat_thread(struct thread_info *thread)
+{
+	return 0;
+}
 
 #endif /* CONFIG_COMPAT */
 
 static inline int is_compat_task(void)
 {
-	return is_a32_compat_task();
+	return is_a32_compat_task() || is_ilp32_compat_task();
 }
 
 static inline int is_compat_thread(struct thread_info *thread)
 {
-	return is_a32_compat_thread(thread);
+	return is_a32_compat_thread(thread) || is_ilp32_compat_thread(thread);
 }
 #endif /* __KERNEL__ */
 #endif /* __ASM_COMPAT_H */
diff --git a/arch/arm64/include/asm/thread_info.h b/arch/arm64/include/asm/thread_info.h
index 7d03565..e72de74 100644
--- a/arch/arm64/include/asm/thread_info.h
+++ b/arch/arm64/include/asm/thread_info.h
@@ -112,6 +112,7 @@ static inline struct thread_info *current_thread_info(void)
 #define TIF_SINGLESTEP		21
 #define TIF_32BIT		22	/* AARCH32 process */
 #define TIF_SWITCH_MM		23	/* deferred switch_mm */
+#define TIF_32BIT_AARCH64	24	/* 32 bit process on AArch64(ILP32) */
 
 #define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1 << TIF_NEED_RESCHED)
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [PATCH v5 12/23] arm64:ilp32: COMPAT_USE_64BIT_TIME is true for ILP32 tasks
  2015-09-29 22:13 ` Yury Norov
@ 2015-09-29 22:14   ` Yury Norov
  -1 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-09-29 22:14 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel, catalin.marinas, arnd, agraf,
	bamvor.zhangjian
  Cc: yury.norov, philipp.tomsich, apinski, christoph.muellner,
	klimov.linux, Yury Norov

From: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>

Since __kernel_long_t (time_t) is long long, we need to tell the rest of
kernel that we use 64bit time_t for compat when the task is not an
AARCH32 task.  The reason why we check AARCH32 rather than ILP32 here is
because if we don't have AARCH32 compiled in (which is going to be the
common case due to AARCH32 requiring 4k pages).

Stricly speaking, a 'long long' time_t is not standards-compliant
(refer to https://sourceware.org/bugzilla/show_bug.cgi?id=16437 for
details), but there is precedent (i.e. x32) for such an implementation both
in the kernel and in glibc.

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>

diff --git a/arch/arm64/include/asm/compat.h b/arch/arm64/include/asm/compat.h
index f53c4e6..4b717df 100644
--- a/arch/arm64/include/asm/compat.h
+++ b/arch/arm64/include/asm/compat.h
@@ -76,6 +76,9 @@ struct compat_timeval {
 	s32		tv_usec;
 };
 
+/* ILP32 uses 64bit time_t and not the above compat structures */
+#define COMPAT_USE_64BIT_TIME !is_a32_compat_task()
+
 struct compat_stat {
 #ifdef __AARCH64EB__
 	short		st_dev;
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [PATCH v5 12/23] arm64:ilp32: COMPAT_USE_64BIT_TIME is true for ILP32 tasks
@ 2015-09-29 22:14   ` Yury Norov
  0 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-09-29 22:14 UTC (permalink / raw)
  To: linux-arm-kernel

From: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>

Since __kernel_long_t (time_t) is long long, we need to tell the rest of
kernel that we use 64bit time_t for compat when the task is not an
AARCH32 task.  The reason why we check AARCH32 rather than ILP32 here is
because if we don't have AARCH32 compiled in (which is going to be the
common case due to AARCH32 requiring 4k pages).

Stricly speaking, a 'long long' time_t is not standards-compliant
(refer to https://sourceware.org/bugzilla/show_bug.cgi?id=16437 for
details), but there is precedent (i.e. x32) for such an implementation both
in the kernel and in glibc.

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>

diff --git a/arch/arm64/include/asm/compat.h b/arch/arm64/include/asm/compat.h
index f53c4e6..4b717df 100644
--- a/arch/arm64/include/asm/compat.h
+++ b/arch/arm64/include/asm/compat.h
@@ -76,6 +76,9 @@ struct compat_timeval {
 	s32		tv_usec;
 };
 
+/* ILP32 uses 64bit time_t and not the above compat structures */
+#define COMPAT_USE_64BIT_TIME !is_a32_compat_task()
+
 struct compat_stat {
 #ifdef __AARCH64EB__
 	short		st_dev;
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [PATCH v5 13/23] arm64:ilp32: share HWCAP between LP64 and ILP32
  2015-09-29 22:13 ` Yury Norov
@ 2015-09-29 22:14   ` Yury Norov
  -1 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-09-29 22:14 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel, catalin.marinas, arnd, agraf,
	bamvor.zhangjian
  Cc: yury.norov, philipp.tomsich, apinski, christoph.muellner,
	klimov.linux, Yury Norov

From: Andrew Pinski <apinski@cavium.com>

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>

diff --git a/arch/arm64/include/asm/hwcap.h b/arch/arm64/include/asm/hwcap.h
index 0ad7351..1e5361e 100644
--- a/arch/arm64/include/asm/hwcap.h
+++ b/arch/arm64/include/asm/hwcap.h
@@ -47,9 +47,17 @@
 #define ELF_HWCAP		(elf_hwcap)
 
 #ifdef CONFIG_COMPAT
-#define COMPAT_ELF_HWCAP	(compat_elf_hwcap)
-#define COMPAT_ELF_HWCAP2	(compat_elf_hwcap2)
 extern unsigned int compat_elf_hwcap, compat_elf_hwcap2;
+#define COMPAT_ELF_HWCAP	\
+	(is_a32_compat_task()	\
+	  ? compat_elf_hwcap	\
+	  : elf_hwcap)
+
+#define COMPAT_ELF_HWCAP2	\
+	(is_a32_compat_task()	\
+	  ? compat_elf_hwcap2	\
+	  : 0)
+
 #endif
 
 extern unsigned long elf_hwcap;
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [PATCH v5 13/23] arm64:ilp32: share HWCAP between LP64 and ILP32
@ 2015-09-29 22:14   ` Yury Norov
  0 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-09-29 22:14 UTC (permalink / raw)
  To: linux-arm-kernel

From: Andrew Pinski <apinski@cavium.com>

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>

diff --git a/arch/arm64/include/asm/hwcap.h b/arch/arm64/include/asm/hwcap.h
index 0ad7351..1e5361e 100644
--- a/arch/arm64/include/asm/hwcap.h
+++ b/arch/arm64/include/asm/hwcap.h
@@ -47,9 +47,17 @@
 #define ELF_HWCAP		(elf_hwcap)
 
 #ifdef CONFIG_COMPAT
-#define COMPAT_ELF_HWCAP	(compat_elf_hwcap)
-#define COMPAT_ELF_HWCAP2	(compat_elf_hwcap2)
 extern unsigned int compat_elf_hwcap, compat_elf_hwcap2;
+#define COMPAT_ELF_HWCAP	\
+	(is_a32_compat_task()	\
+	  ? compat_elf_hwcap	\
+	  : elf_hwcap)
+
+#define COMPAT_ELF_HWCAP2	\
+	(is_a32_compat_task()	\
+	  ? compat_elf_hwcap2	\
+	  : 0)
+
 #endif
 
 extern unsigned long elf_hwcap;
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [PATCH v5 14/23] arm64:ilp32 use the native LP64 'start_thread' for ILP32 threads
  2015-09-29 22:13 ` Yury Norov
@ 2015-09-29 22:14   ` Yury Norov
  -1 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-09-29 22:14 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel, catalin.marinas, arnd, agraf,
	bamvor.zhangjian
  Cc: yury.norov, philipp.tomsich, apinski, christoph.muellner,
	klimov.linux, Yury Norov

From: Andrew Pinski <apinski@cavium.com>

If we have both ILP32 and AARCH32 compiled in, we need use the non compat start
thread for ILP32.

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>

diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h
index f1bba0c..d766f29 100644
--- a/arch/arm64/include/asm/processor.h
+++ b/arch/arm64/include/asm/processor.h
@@ -28,6 +28,7 @@
 #ifdef __KERNEL__
 
 #include <linux/string.h>
+#include <linux/thread_info.h>
 
 #include <asm/fpsimd.h>
 #include <asm/hw_breakpoint.h>
@@ -123,6 +124,15 @@ static inline void start_thread(struct pt_regs *regs, unsigned long pc,
 static inline void compat_start_thread(struct pt_regs *regs, unsigned long pc,
 				       unsigned long sp)
 {
+#ifdef CONFIG_ARM64_ILP32
+	/* ILP32 thread are started the same way as LP64 threads.
+	   Note we cannot use is_ilp32_compat_task here as that
+	   would introduce a header depency issue.  */
+	if (test_thread_flag(TIF_32BIT_AARCH64)) {
+		start_thread(regs, pc, sp);
+		return;
+	}
+#endif
 	start_thread_common(regs, pc);
 	regs->pstate = COMPAT_PSR_MODE_USR;
 	if (pc & 1)
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [PATCH v5 14/23] arm64:ilp32 use the native LP64 'start_thread' for ILP32 threads
@ 2015-09-29 22:14   ` Yury Norov
  0 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-09-29 22:14 UTC (permalink / raw)
  To: linux-arm-kernel

From: Andrew Pinski <apinski@cavium.com>

If we have both ILP32 and AARCH32 compiled in, we need use the non compat start
thread for ILP32.

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>

diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h
index f1bba0c..d766f29 100644
--- a/arch/arm64/include/asm/processor.h
+++ b/arch/arm64/include/asm/processor.h
@@ -28,6 +28,7 @@
 #ifdef __KERNEL__
 
 #include <linux/string.h>
+#include <linux/thread_info.h>
 
 #include <asm/fpsimd.h>
 #include <asm/hw_breakpoint.h>
@@ -123,6 +124,15 @@ static inline void start_thread(struct pt_regs *regs, unsigned long pc,
 static inline void compat_start_thread(struct pt_regs *regs, unsigned long pc,
 				       unsigned long sp)
 {
+#ifdef CONFIG_ARM64_ILP32
+	/* ILP32 thread are started the same way as LP64 threads.
+	   Note we cannot use is_ilp32_compat_task here as that
+	   would introduce a header depency issue.  */
+	if (test_thread_flag(TIF_32BIT_AARCH64)) {
+		start_thread(regs, pc, sp);
+		return;
+	}
+#endif
 	start_thread_common(regs, pc);
 	regs->pstate = COMPAT_PSR_MODE_USR;
 	if (pc & 1)
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [PATCH v5 15/23] arm64:ilp32: support core dump generation for ILP32
  2015-09-29 22:13 ` Yury Norov
@ 2015-09-29 22:14   ` Yury Norov
  -1 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-09-29 22:14 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel, catalin.marinas, arnd, agraf,
	bamvor.zhangjian
  Cc: yury.norov, philipp.tomsich, apinski, christoph.muellner,
	klimov.linux, Yury Norov

From: Andrew Pinski <apinski@cavium.com>

This patch supports core dumping on ILP32.
We need a few extra macros (COMPAT_PR_REG_SIZE and COMPAT_PRSTATUS_SIZE) due
to size differences of the register sets.

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>

diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h
index 9ecbaf2..d4d53c91a 100644
--- a/arch/arm64/include/asm/elf.h
+++ b/arch/arm64/include/asm/elf.h
@@ -171,8 +171,8 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
 
 /* AArch32 registers. */
 #define COMPAT_A32_ELF_NGREG		18
-typedef unsigned int			compat_elf_greg_t;
-typedef compat_elf_greg_t		compat_elf_gregset_t[COMPAT_A32_ELF_NGREG];
+typedef unsigned int			compat_a32_elf_greg_t;
+typedef compat_a32_elf_greg_t		compat_a32_elf_gregset_t[COMPAT_A32_ELF_NGREG];
 
 /* AArch32 EABI. */
 #define EF_ARM_EABI_MASK		0xff000000
@@ -199,6 +199,24 @@ typedef elf_gregset_t			compat_elf_gregset_t;
 
 #endif
 
+/* If ILP32 is turned on, we want to define the compat_elf_greg_t to the non compat
+   one and define PR_REG_SIZE/PRSTATUS_SIZE/SET_PR_FPVALID so we pick up the correct
+   ones for AARCH32. Note also the definition of the macros have to be correct for
+   LP64 as this file is included in the standard binfmt_elf.c. */
+#ifdef CONFIG_ARM64_ILP32
+typedef elf_greg_t			compat_elf_greg_t;
+typedef elf_gregset_t			compat_elf_gregset_t;
+#define PR_REG_SIZE(S)			(is_a32_compat_task() ? 72 : 272)
+#define PRSTATUS_SIZE(S)		(is_a32_compat_task() ? 124 : (is_ilp32_compat_task() ? 352 : 392))
+#define SET_PR_FPVALID(S, V)							\
+do {										\
+	*(int *) (((void *) &((S)->pr_reg)) + PR_REG_SIZE((S)->pr_reg)) = (V);	\
+} while (0)
+#else
+typedef compat_a32_elf_greg_t compat_elf_greg_t;
+typedef compat_a32_elf_gregset_t compat_elf_gregset_t;
+#endif
+
 #define compat_elf_check_arch(x)	compat_a32_elf_check_arch(x)
 
 #endif /* CONFIG_COMPAT */
diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c
index 8cd1eb7..1f5c38c 100644
--- a/arch/arm64/kernel/ptrace.c
+++ b/arch/arm64/kernel/ptrace.c
@@ -854,8 +854,8 @@ static const struct user_regset aarch32_regsets[] = {
 	[REGSET_COMPAT_GPR] = {
 		.core_note_type = NT_PRSTATUS,
 		.n = COMPAT_A32_ELF_NGREG,
-		.size = sizeof(compat_elf_greg_t),
-		.align = sizeof(compat_elf_greg_t),
+		.size = sizeof(compat_a32_elf_greg_t),
+		.align = sizeof(compat_a32_elf_greg_t),
 		.get = compat_gpr_get,
 		.set = compat_gpr_set
 	},
@@ -946,7 +946,7 @@ static int compat_ptrace_read_user(struct task_struct *tsk, compat_ulong_t off,
 		tmp = tsk->mm->start_data;
 	else if (off == COMPAT_PT_TEXT_END_ADDR)
 		tmp = tsk->mm->end_code;
-	else if (off < sizeof(compat_elf_gregset_t))
+	else if (off < sizeof(compat_a32_elf_gregset_t))
 		return copy_regset_to_user(tsk, &user_aarch32_view,
 					   REGSET_COMPAT_GPR, off,
 					   sizeof(compat_ulong_t), ret);
@@ -967,7 +967,7 @@ static int compat_ptrace_write_user(struct task_struct *tsk, compat_ulong_t off,
 	if (off & 3 || off >= COMPAT_USER_SZ)
 		return -EIO;
 
-	if (off >= sizeof(compat_elf_gregset_t))
+	if (off >= sizeof(compat_a32_elf_gregset_t))
 		return 0;
 
 	set_fs(KERNEL_DS);
@@ -1130,7 +1130,7 @@ long compat_a32_arch_ptrace(struct task_struct *child, compat_long_t request,
 			ret = copy_regset_to_user(child,
 						  &user_aarch32_view,
 						  REGSET_COMPAT_GPR,
-						  0, sizeof(compat_elf_gregset_t),
+						  0, sizeof(compat_a32_elf_gregset_t),
 						  datap);
 			break;
 
@@ -1138,7 +1138,7 @@ long compat_a32_arch_ptrace(struct task_struct *child, compat_long_t request,
 			ret = copy_regset_from_user(child,
 						    &user_aarch32_view,
 						    REGSET_COMPAT_GPR,
-						    0, sizeof(compat_elf_gregset_t),
+						    0, sizeof(compat_a32_elf_gregset_t),
 						    datap);
 			break;
 
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [PATCH v5 15/23] arm64:ilp32: support core dump generation for ILP32
@ 2015-09-29 22:14   ` Yury Norov
  0 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-09-29 22:14 UTC (permalink / raw)
  To: linux-arm-kernel

From: Andrew Pinski <apinski@cavium.com>

This patch supports core dumping on ILP32.
We need a few extra macros (COMPAT_PR_REG_SIZE and COMPAT_PRSTATUS_SIZE) due
to size differences of the register sets.

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>

diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h
index 9ecbaf2..d4d53c91a 100644
--- a/arch/arm64/include/asm/elf.h
+++ b/arch/arm64/include/asm/elf.h
@@ -171,8 +171,8 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
 
 /* AArch32 registers. */
 #define COMPAT_A32_ELF_NGREG		18
-typedef unsigned int			compat_elf_greg_t;
-typedef compat_elf_greg_t		compat_elf_gregset_t[COMPAT_A32_ELF_NGREG];
+typedef unsigned int			compat_a32_elf_greg_t;
+typedef compat_a32_elf_greg_t		compat_a32_elf_gregset_t[COMPAT_A32_ELF_NGREG];
 
 /* AArch32 EABI. */
 #define EF_ARM_EABI_MASK		0xff000000
@@ -199,6 +199,24 @@ typedef elf_gregset_t			compat_elf_gregset_t;
 
 #endif
 
+/* If ILP32 is turned on, we want to define the compat_elf_greg_t to the non compat
+   one and define PR_REG_SIZE/PRSTATUS_SIZE/SET_PR_FPVALID so we pick up the correct
+   ones for AARCH32. Note also the definition of the macros have to be correct for
+   LP64 as this file is included in the standard binfmt_elf.c. */
+#ifdef CONFIG_ARM64_ILP32
+typedef elf_greg_t			compat_elf_greg_t;
+typedef elf_gregset_t			compat_elf_gregset_t;
+#define PR_REG_SIZE(S)			(is_a32_compat_task() ? 72 : 272)
+#define PRSTATUS_SIZE(S)		(is_a32_compat_task() ? 124 : (is_ilp32_compat_task() ? 352 : 392))
+#define SET_PR_FPVALID(S, V)							\
+do {										\
+	*(int *) (((void *) &((S)->pr_reg)) + PR_REG_SIZE((S)->pr_reg)) = (V);	\
+} while (0)
+#else
+typedef compat_a32_elf_greg_t compat_elf_greg_t;
+typedef compat_a32_elf_gregset_t compat_elf_gregset_t;
+#endif
+
 #define compat_elf_check_arch(x)	compat_a32_elf_check_arch(x)
 
 #endif /* CONFIG_COMPAT */
diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c
index 8cd1eb7..1f5c38c 100644
--- a/arch/arm64/kernel/ptrace.c
+++ b/arch/arm64/kernel/ptrace.c
@@ -854,8 +854,8 @@ static const struct user_regset aarch32_regsets[] = {
 	[REGSET_COMPAT_GPR] = {
 		.core_note_type = NT_PRSTATUS,
 		.n = COMPAT_A32_ELF_NGREG,
-		.size = sizeof(compat_elf_greg_t),
-		.align = sizeof(compat_elf_greg_t),
+		.size = sizeof(compat_a32_elf_greg_t),
+		.align = sizeof(compat_a32_elf_greg_t),
 		.get = compat_gpr_get,
 		.set = compat_gpr_set
 	},
@@ -946,7 +946,7 @@ static int compat_ptrace_read_user(struct task_struct *tsk, compat_ulong_t off,
 		tmp = tsk->mm->start_data;
 	else if (off == COMPAT_PT_TEXT_END_ADDR)
 		tmp = tsk->mm->end_code;
-	else if (off < sizeof(compat_elf_gregset_t))
+	else if (off < sizeof(compat_a32_elf_gregset_t))
 		return copy_regset_to_user(tsk, &user_aarch32_view,
 					   REGSET_COMPAT_GPR, off,
 					   sizeof(compat_ulong_t), ret);
@@ -967,7 +967,7 @@ static int compat_ptrace_write_user(struct task_struct *tsk, compat_ulong_t off,
 	if (off & 3 || off >= COMPAT_USER_SZ)
 		return -EIO;
 
-	if (off >= sizeof(compat_elf_gregset_t))
+	if (off >= sizeof(compat_a32_elf_gregset_t))
 		return 0;
 
 	set_fs(KERNEL_DS);
@@ -1130,7 +1130,7 @@ long compat_a32_arch_ptrace(struct task_struct *child, compat_long_t request,
 			ret = copy_regset_to_user(child,
 						  &user_aarch32_view,
 						  REGSET_COMPAT_GPR,
-						  0, sizeof(compat_elf_gregset_t),
+						  0, sizeof(compat_a32_elf_gregset_t),
 						  datap);
 			break;
 
@@ -1138,7 +1138,7 @@ long compat_a32_arch_ptrace(struct task_struct *child, compat_long_t request,
 			ret = copy_regset_from_user(child,
 						    &user_aarch32_view,
 						    REGSET_COMPAT_GPR,
-						    0, sizeof(compat_elf_gregset_t),
+						    0, sizeof(compat_a32_elf_gregset_t),
 						    datap);
 			break;
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [PATCH v5 16/23] arm64: add support for starting ILP32 (ELFCLASS32) binaries
  2015-09-29 22:13 ` Yury Norov
@ 2015-09-29 22:14   ` Yury Norov
  -1 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-09-29 22:14 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel, catalin.marinas, arnd, agraf,
	bamvor.zhangjian
  Cc: yury.norov, philipp.tomsich, apinski, christoph.muellner,
	klimov.linux, Yury Norov

From: Andrew Pinski <apinski@cavium.com>

Handle ILP32 (AArch64, but ELFCLASS32) binaries on ARM64.

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>

diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h
index d4d53c91a..9a854f9 100644
--- a/arch/arm64/include/asm/elf.h
+++ b/arch/arm64/include/asm/elf.h
@@ -134,7 +134,11 @@ typedef struct user_fpsimd_state elf_fpregset_t;
  */
 #define ELF_PLAT_INIT(_r, load_addr)	(_r)->regs[0] = 0
 
-#define SET_PERSONALITY(ex)		clear_thread_flag(TIF_32BIT);
+#define SET_PERSONALITY(ex)			\
+do {						\
+	clear_thread_flag(TIF_32BIT_AARCH64);	\
+	clear_thread_flag(TIF_32BIT);		\
+} while (0)
 
 #define ARCH_DLINFO							\
 do {									\
@@ -167,6 +171,9 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
 #define COMPAT_ELF_ET_DYN_BASE		(2 * TASK_SIZE_32 / 3)
 
 
+extern int aarch32_setup_vectors_page(struct linux_binprm *bprm,
+				      int uses_interp);
+
 #ifdef CONFIG_AARCH32_EL0
 
 /* AArch32 registers. */
@@ -176,27 +183,23 @@ typedef compat_a32_elf_greg_t		compat_a32_elf_gregset_t[COMPAT_A32_ELF_NGREG];
 
 /* AArch32 EABI. */
 #define EF_ARM_EABI_MASK		0xff000000
-#define compat_elf_check_arch(x)	(((x)->e_machine == EM_ARM) && \
+#define compat_a32_elf_check_arch(x)	(((x)->e_machine == EM_ARM) && \
 					 ((x)->e_flags & EF_ARM_EABI_MASK))
 
 #define compat_start_thread		compat_start_thread
-#define COMPAT_SET_PERSONALITY(ex)	set_thread_flag(TIF_32BIT);
-#define COMPAT_ARCH_DLINFO
-
-
-extern int aarch32_setup_vectors_page(struct linux_binprm *bprm,
-				      int uses_interp);
-#define compat_arch_setup_additional_pages \
-					aarch32_setup_vectors_page
+#define COMPAT_A32_SET_PERSONALITY(ex)		\
+do {						\
+	clear_thread_flag(TIF_32BIT_AARCH64);	\
+	set_thread_flag(TIF_32BIT);		\
+} while (0)
+#define COMPAT_A32_ARCH_DLINFO		do {} while (0)
 
 #else
-
 typedef elf_greg_t			compat_elf_greg_t;
 typedef elf_gregset_t			compat_elf_gregset_t;
 #define compat_a32_elf_check_arch(x)	0
-#define COMPAT_SET_PERSONALITY(ex)
-#define COMPAT_ARCH_DLINFO
-
+#define COMPAT_A32_SET_PERSONALITY(ex)	do {} while (0)
+#define COMPAT_A32_ARCH_DLINFO		do {} while (0)
 #endif
 
 /* If ILP32 is turned on, we want to define the compat_elf_greg_t to the non compat
@@ -217,7 +220,46 @@ typedef compat_a32_elf_greg_t compat_elf_greg_t;
 typedef compat_a32_elf_gregset_t compat_elf_gregset_t;
 #endif
 
-#define compat_elf_check_arch(x)	compat_a32_elf_check_arch(x)
+#ifdef CONFIG_ARM64_ILP32
+#define compat_ilp32_elf_check_arch(x) ((x)->e_machine == EM_AARCH64)
+#define COMPAT_ILP32_SET_PERSONALITY(ex)	\
+do {						\
+	set_thread_flag(TIF_32BIT_AARCH64);	\
+	clear_thread_flag(TIF_32BIT);		\
+} while (0)
+#define COMPAT_ILP32_ARCH_DLINFO					\
+do {									\
+	NEW_AUX_ENT(AT_SYSINFO_EHDR,					\
+		    (elf_addr_t)(long)current->mm->context.vdso);	\
+} while (0)
+#else
+#define compat_ilp32_elf_check_arch(x) 0
+#define COMPAT_ILP32_SET_PERSONALITY(ex)	do {} while (0)
+#define COMPAT_ILP32_ARCH_DLINFO		do {} while (0)
+#endif
+
+#define compat_elf_check_arch(x)	(compat_a32_elf_check_arch(x) || compat_ilp32_elf_check_arch(x))
+#define COMPAT_SET_PERSONALITY(ex)			\
+do {							\
+	if (compat_a32_elf_check_arch(&ex))		\
+		COMPAT_A32_SET_PERSONALITY(ex);		\
+	else						\
+		COMPAT_ILP32_SET_PERSONALITY(ex);	\
+} while (0)
+
+/* ILP32 uses the "LP64-like" vdso pages */
+#define compat_arch_setup_additional_pages	\
+	(is_a32_compat_task()			\
+	 ? &aarch32_setup_vectors_page		\
+	 : &(arch_setup_additional_pages))
+
+#define COMPAT_ARCH_DLINFO			\
+do {						\
+	if (is_a32_compat_task())		\
+		COMPAT_A32_ARCH_DLINFO;		\
+	else					\
+		COMPAT_ILP32_ARCH_DLINFO;	\
+} while (0)
 
 #endif /* CONFIG_COMPAT */
 
diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c
index 26352a6..b239b9b 100644
--- a/arch/arm64/kernel/vdso.c
+++ b/arch/arm64/kernel/vdso.c
@@ -107,6 +107,14 @@ int aarch32_setup_vectors_page(struct linux_binprm *bprm, int uses_interp)
 
 	return PTR_ERR_OR_ZERO(ret);
 }
+#else
+int aarch32_setup_vectors_page(struct linux_binprm *bprm, int uses_interp)
+{
+	(void) bprm;
+	(void) uses_interp;
+
+	return -EINVAL;
+}
 #endif /* CONFIG_AARCH32_EL0 */
 
 static struct vm_special_mapping vdso_spec[2];
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [PATCH v5 16/23] arm64: add support for starting ILP32 (ELFCLASS32) binaries
@ 2015-09-29 22:14   ` Yury Norov
  0 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-09-29 22:14 UTC (permalink / raw)
  To: linux-arm-kernel

From: Andrew Pinski <apinski@cavium.com>

Handle ILP32 (AArch64, but ELFCLASS32) binaries on ARM64.

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>

diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h
index d4d53c91a..9a854f9 100644
--- a/arch/arm64/include/asm/elf.h
+++ b/arch/arm64/include/asm/elf.h
@@ -134,7 +134,11 @@ typedef struct user_fpsimd_state elf_fpregset_t;
  */
 #define ELF_PLAT_INIT(_r, load_addr)	(_r)->regs[0] = 0
 
-#define SET_PERSONALITY(ex)		clear_thread_flag(TIF_32BIT);
+#define SET_PERSONALITY(ex)			\
+do {						\
+	clear_thread_flag(TIF_32BIT_AARCH64);	\
+	clear_thread_flag(TIF_32BIT);		\
+} while (0)
 
 #define ARCH_DLINFO							\
 do {									\
@@ -167,6 +171,9 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
 #define COMPAT_ELF_ET_DYN_BASE		(2 * TASK_SIZE_32 / 3)
 
 
+extern int aarch32_setup_vectors_page(struct linux_binprm *bprm,
+				      int uses_interp);
+
 #ifdef CONFIG_AARCH32_EL0
 
 /* AArch32 registers. */
@@ -176,27 +183,23 @@ typedef compat_a32_elf_greg_t		compat_a32_elf_gregset_t[COMPAT_A32_ELF_NGREG];
 
 /* AArch32 EABI. */
 #define EF_ARM_EABI_MASK		0xff000000
-#define compat_elf_check_arch(x)	(((x)->e_machine == EM_ARM) && \
+#define compat_a32_elf_check_arch(x)	(((x)->e_machine == EM_ARM) && \
 					 ((x)->e_flags & EF_ARM_EABI_MASK))
 
 #define compat_start_thread		compat_start_thread
-#define COMPAT_SET_PERSONALITY(ex)	set_thread_flag(TIF_32BIT);
-#define COMPAT_ARCH_DLINFO
-
-
-extern int aarch32_setup_vectors_page(struct linux_binprm *bprm,
-				      int uses_interp);
-#define compat_arch_setup_additional_pages \
-					aarch32_setup_vectors_page
+#define COMPAT_A32_SET_PERSONALITY(ex)		\
+do {						\
+	clear_thread_flag(TIF_32BIT_AARCH64);	\
+	set_thread_flag(TIF_32BIT);		\
+} while (0)
+#define COMPAT_A32_ARCH_DLINFO		do {} while (0)
 
 #else
-
 typedef elf_greg_t			compat_elf_greg_t;
 typedef elf_gregset_t			compat_elf_gregset_t;
 #define compat_a32_elf_check_arch(x)	0
-#define COMPAT_SET_PERSONALITY(ex)
-#define COMPAT_ARCH_DLINFO
-
+#define COMPAT_A32_SET_PERSONALITY(ex)	do {} while (0)
+#define COMPAT_A32_ARCH_DLINFO		do {} while (0)
 #endif
 
 /* If ILP32 is turned on, we want to define the compat_elf_greg_t to the non compat
@@ -217,7 +220,46 @@ typedef compat_a32_elf_greg_t compat_elf_greg_t;
 typedef compat_a32_elf_gregset_t compat_elf_gregset_t;
 #endif
 
-#define compat_elf_check_arch(x)	compat_a32_elf_check_arch(x)
+#ifdef CONFIG_ARM64_ILP32
+#define compat_ilp32_elf_check_arch(x) ((x)->e_machine == EM_AARCH64)
+#define COMPAT_ILP32_SET_PERSONALITY(ex)	\
+do {						\
+	set_thread_flag(TIF_32BIT_AARCH64);	\
+	clear_thread_flag(TIF_32BIT);		\
+} while (0)
+#define COMPAT_ILP32_ARCH_DLINFO					\
+do {									\
+	NEW_AUX_ENT(AT_SYSINFO_EHDR,					\
+		    (elf_addr_t)(long)current->mm->context.vdso);	\
+} while (0)
+#else
+#define compat_ilp32_elf_check_arch(x) 0
+#define COMPAT_ILP32_SET_PERSONALITY(ex)	do {} while (0)
+#define COMPAT_ILP32_ARCH_DLINFO		do {} while (0)
+#endif
+
+#define compat_elf_check_arch(x)	(compat_a32_elf_check_arch(x) || compat_ilp32_elf_check_arch(x))
+#define COMPAT_SET_PERSONALITY(ex)			\
+do {							\
+	if (compat_a32_elf_check_arch(&ex))		\
+		COMPAT_A32_SET_PERSONALITY(ex);		\
+	else						\
+		COMPAT_ILP32_SET_PERSONALITY(ex);	\
+} while (0)
+
+/* ILP32 uses the "LP64-like" vdso pages */
+#define compat_arch_setup_additional_pages	\
+	(is_a32_compat_task()			\
+	 ? &aarch32_setup_vectors_page		\
+	 : &(arch_setup_additional_pages))
+
+#define COMPAT_ARCH_DLINFO			\
+do {						\
+	if (is_a32_compat_task())		\
+		COMPAT_A32_ARCH_DLINFO;		\
+	else					\
+		COMPAT_ILP32_ARCH_DLINFO;	\
+} while (0)
 
 #endif /* CONFIG_COMPAT */
 
diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c
index 26352a6..b239b9b 100644
--- a/arch/arm64/kernel/vdso.c
+++ b/arch/arm64/kernel/vdso.c
@@ -107,6 +107,14 @@ int aarch32_setup_vectors_page(struct linux_binprm *bprm, int uses_interp)
 
 	return PTR_ERR_OR_ZERO(ret);
 }
+#else
+int aarch32_setup_vectors_page(struct linux_binprm *bprm, int uses_interp)
+{
+	(void) bprm;
+	(void) uses_interp;
+
+	return -EINVAL;
+}
 #endif /* CONFIG_AARCH32_EL0 */
 
 static struct vm_special_mapping vdso_spec[2];
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [PATCH v5 17/23] arm64:ilp32: add vdso-ilp32 and use for signal return
  2015-09-29 22:13 ` Yury Norov
@ 2015-09-29 22:14   ` Yury Norov
  -1 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-09-29 22:14 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel, catalin.marinas, arnd, agraf,
	bamvor.zhangjian
  Cc: yury.norov, philipp.tomsich, apinski, christoph.muellner,
	klimov.linux, Yury Norov

From: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>

Adjusted to move the move data page before code pages in sync with
commit 601255ae3c98fdeeee3a8bb4696425e4f868b4f1

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>

 create mode 100644 arch/arm64/kernel/vdso-ilp32/.gitignore
 create mode 100644 arch/arm64/kernel/vdso-ilp32/Makefile
 copy arch/arm64/{include/asm/vdso.h => kernel/vdso-ilp32/vdso-ilp32.S} (56%)
 create mode 100644 arch/arm64/kernel/vdso-ilp32/vdso-ilp32.lds.S

diff --git a/arch/arm64/include/asm/vdso.h b/arch/arm64/include/asm/vdso.h
index 839ce00..84050c6 100644
--- a/arch/arm64/include/asm/vdso.h
+++ b/arch/arm64/include/asm/vdso.h
@@ -29,6 +29,10 @@
 
 #include <generated/vdso-offsets.h>
 
+#ifdef CONFIG_ARM64_ILP32
+#include <generated/vdso-ilp32-offsets.h>
+#endif
+
 #define VDSO_SYMBOL(base, name)						   \
 ({									   \
 	(void *)(vdso_offset_##name - VDSO_LBASE + (unsigned long)(base)); \
diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile
index 1470332..ff60c2f 100644
--- a/arch/arm64/kernel/Makefile
+++ b/arch/arm64/kernel/Makefile
@@ -38,6 +38,7 @@ arm64-obj-$(CONFIG_ARMV8_DEPRECATED)	+= armv8_deprecated.o
 arm64-obj-$(CONFIG_ACPI)		+= acpi.o
 
 obj-y					+= $(arm64-obj-y) vdso/
+obj-$(CONFIG_ARM64_ILP32)		+= vdso-ilp32/
 obj-m					+= $(arm64-obj-m)
 head-y					:= head.o
 extra-y					:= $(head-y) vmlinux.lds
@@ -45,3 +46,7 @@ extra-y					:= $(head-y) vmlinux.lds
 # vDSO - this must be built first to generate the symbol offsets
 $(call objectify,$(arm64-obj-y)): $(obj)/vdso/vdso-offsets.h
 $(obj)/vdso/vdso-offsets.h: $(obj)/vdso
+
+# vDSO - this must be built first to generate the symbol offsets
+$(call objectify,$(arm64-obj-y)): $(obj)/vdso-ilp32/vdso-ilp32-offsets.h
+$(obj)/vdso-ilp32/vdso-ilp32-offsets.h: $(obj)/vdso-ilp32
diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c
index 2e00531..8eb8ed9 100644
--- a/arch/arm64/kernel/signal.c
+++ b/arch/arm64/kernel/signal.c
@@ -241,6 +241,10 @@ static void setup_return(struct pt_regs *regs, struct k_sigaction *ka,
 
 	if (ka->sa.sa_flags & SA_RESTORER)
 		sigtramp = ka->sa.sa_restorer;
+#ifdef CONFIG_ARM64_ILP32
+	else if (is_ilp32_compat_task())
+		sigtramp = VDSO_SYMBOL(current->mm->context.vdso, sigtramp_ilp32);
+#endif
 	else
 		sigtramp = VDSO_SYMBOL(current->mm->context.vdso, sigtramp);
 
diff --git a/arch/arm64/kernel/vdso-ilp32/.gitignore b/arch/arm64/kernel/vdso-ilp32/.gitignore
new file mode 100644
index 0000000..61806c3
--- /dev/null
+++ b/arch/arm64/kernel/vdso-ilp32/.gitignore
@@ -0,0 +1,2 @@
+vdso-ilp32.lds
+vdso-ilp32-offsets.h
diff --git a/arch/arm64/kernel/vdso-ilp32/Makefile b/arch/arm64/kernel/vdso-ilp32/Makefile
new file mode 100644
index 0000000..c8f5472
--- /dev/null
+++ b/arch/arm64/kernel/vdso-ilp32/Makefile
@@ -0,0 +1,72 @@
+#
+# Building a vDSO image for AArch64.
+#
+# Author: Will Deacon <will.deacon@arm.com>
+# Heavily based on the vDSO Makefiles for other archs.
+#
+
+obj-ilp32-vdso := gettimeofday-ilp32.o note-ilp32.o sigreturn-ilp32.o
+
+# Build rules
+targets := $(obj-ilp32-vdso) vdso-ilp32.so vdso-ilp32.so.dbg
+obj-ilp32-vdso := $(addprefix $(obj)/, $(obj-ilp32-vdso))
+
+ccflags-y := -shared -fno-common -fno-builtin
+ccflags-y += -nostdlib -Wl,-soname=linux-ilp32-vdso.so.1 \
+		$(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
+
+obj-y += vdso-ilp32.o
+extra-y += vdso-ilp32.lds vdso-ilp32-offsets.h
+CPPFLAGS_vdso-ilp32.lds += -P -C -U$(ARCH) -mabi=ilp32
+
+# Force dependency (incbin is bad)
+$(obj)/vdso-ilp32.o : $(obj)/vdso-ilp32.so
+
+# Link rule for the .so file, .lds has to be first
+$(obj)/vdso-ilp32.so.dbg: $(src)/vdso-ilp32.lds $(obj-ilp32-vdso)
+	$(call if_changed,vdso-ilp32ld)
+
+# Strip rule for the .so file
+$(obj)/%.so: OBJCOPYFLAGS := -S
+$(obj)/%.so: $(obj)/%.so.dbg FORCE
+	$(call if_changed,objcopy)
+
+# Generate VDSO offsets using helper script
+gen-vdsosym := $(srctree)/$(src)/../vdso/gen_vdso_offsets.sh
+quiet_cmd_vdsosym = VDSOSYM $@
+define cmd_vdsosym
+	$(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@ && \
+	cp $@ include/generated/
+endef
+
+$(obj)/vdso-ilp32-offsets.h: $(obj)/vdso-ilp32.so.dbg FORCE
+	$(call if_changed,vdsosym)
+
+# Assembly rules for the .S files
+#$(obj-ilp32-vdso): %.o: $(src)/../vdso/$(subst -ilp32,,%.S)
+#	$(call if_changed_dep,vdso-ilp32as)
+
+$(obj)/gettimeofday-ilp32.o: $(src)/../vdso/gettimeofday.S
+	$(call if_changed_dep,vdso-ilp32as)
+
+$(obj)/note-ilp32.o: $(src)/../vdso/note.S
+	$(call if_changed_dep,vdso-ilp32as)
+
+$(obj)/sigreturn-ilp32.o: $(src)/../vdso/sigreturn.S
+	$(call if_changed_dep,vdso-ilp32as)
+
+# Actual build commands
+quiet_cmd_vdso-ilp32ld = VDSOILP32L $@
+      cmd_vdso-ilp32ld = $(CC) $(c_flags) -mabi=ilp32  -Wl,-n -Wl,-T $^ -o $@
+quiet_cmd_vdso-ilp32as = VDSOILP32A $@
+      cmd_vdso-ilp32as = $(CC) $(a_flags) -mabi=ilp32 -c -o $@ $<
+
+# Install commands for the unstripped file
+quiet_cmd_vdso_install = INSTALL $@
+      cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
+
+vdso-ilp32.so: $(obj)/vdso-ilp32.so.dbg
+	@mkdir -p $(MODLIB)/vdso
+	$(call cmd,vdso_install)
+
+vdso_install: vdso-ilp32.so
diff --git a/arch/arm64/include/asm/vdso.h b/arch/arm64/kernel/vdso-ilp32/vdso-ilp32.S
similarity index 56%
copy from arch/arm64/include/asm/vdso.h
copy to arch/arm64/kernel/vdso-ilp32/vdso-ilp32.S
index 839ce00..46ac072 100644
--- a/arch/arm64/include/asm/vdso.h
+++ b/arch/arm64/kernel/vdso-ilp32/vdso-ilp32.S
@@ -12,30 +12,22 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Will Deacon <will.deacon@arm.com>
  */
-#ifndef __ASM_VDSO_H
-#define __ASM_VDSO_H
-
-#ifdef __KERNEL__
-
-/*
- * Default link address for the vDSO.
- * Since we randomise the VDSO mapping, there's little point in trying
- * to prelink this.
- */
-#define VDSO_LBASE	0x0
-
-#ifndef __ASSEMBLY__
-
-#include <generated/vdso-offsets.h>
 
-#define VDSO_SYMBOL(base, name)						   \
-({									   \
-	(void *)(vdso_offset_##name - VDSO_LBASE + (unsigned long)(base)); \
-})
+#include <linux/init.h>
+#include <linux/linkage.h>
+#include <linux/const.h>
+#include <asm/page.h>
 
-#endif /* !__ASSEMBLY__ */
+	__PAGE_ALIGNED_DATA
 
-#endif /* __KERNEL__ */
+	.globl vdso_ilp32_start, vdso_ilp32_end
+	.balign PAGE_SIZE
+vdso_ilp32_start:
+	.incbin "arch/arm64/kernel/vdso-ilp32/vdso-ilp32.so"
+	.balign PAGE_SIZE
+vdso_ilp32_end:
 
-#endif /* __ASM_VDSO_H */
+	.previous
diff --git a/arch/arm64/kernel/vdso-ilp32/vdso-ilp32.lds.S b/arch/arm64/kernel/vdso-ilp32/vdso-ilp32.lds.S
new file mode 100644
index 0000000..ac8029b
--- /dev/null
+++ b/arch/arm64/kernel/vdso-ilp32/vdso-ilp32.lds.S
@@ -0,0 +1,98 @@
+/*
+ * GNU linker script for the VDSO library.
+ *
+ * Copyright (C) 2012 ARM Limited
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Will Deacon <will.deacon@arm.com>
+ * Heavily based on the vDSO linker scripts for other archs.
+ */
+
+#include <linux/const.h>
+#include <asm/page.h>
+#include <asm/vdso.h>
+
+/*OUTPUT_FORMAT("elf32-littleaarch64", "elf32-bigaarch64", "elf32-littleaarch64")
+OUTPUT_ARCH(aarch64)
+*/
+SECTIONS
+{
+	PROVIDE(_vdso_data = . - PAGE_SIZE);
+	. = VDSO_LBASE + SIZEOF_HEADERS;
+
+	.hash		: { *(.hash) }			:text
+	.gnu.hash	: { *(.gnu.hash) }
+	.dynsym		: { *(.dynsym) }
+	.dynstr		: { *(.dynstr) }
+	.gnu.version	: { *(.gnu.version) }
+	.gnu.version_d	: { *(.gnu.version_d) }
+	.gnu.version_r	: { *(.gnu.version_r) }
+
+	.note		: { *(.note.*) }		:text	:note
+
+	. = ALIGN(16);
+
+	.text		: { *(.text*) }			:text	=0xd503201f
+	PROVIDE (__etext = .);
+	PROVIDE (_etext = .);
+	PROVIDE (etext = .);
+
+	.eh_frame_hdr	: { *(.eh_frame_hdr) }		:text	:eh_frame_hdr
+	.eh_frame	: { KEEP (*(.eh_frame)) }	:text
+
+	.dynamic	: { *(.dynamic) }		:text	:dynamic
+
+	.rodata		: { *(.rodata*) }		:text
+
+	_end = .;
+	PROVIDE(end = .);
+
+	/DISCARD/	: {
+		*(.note.GNU-stack)
+		*(.data .data.* .gnu.linkonce.d.* .sdata*)
+		*(.bss .sbss .dynbss .dynsbss)
+	}
+}
+
+/*
+ * We must supply the ELF program headers explicitly to get just one
+ * PT_LOAD segment, and set the flags explicitly to make segments read-only.
+ */
+PHDRS
+{
+	text		PT_LOAD		FLAGS(5) FILEHDR PHDRS; /* PF_R|PF_X */
+	dynamic		PT_DYNAMIC	FLAGS(4);		/* PF_R */
+	note		PT_NOTE		FLAGS(4);		/* PF_R */
+	eh_frame_hdr	PT_GNU_EH_FRAME;
+}
+
+/*
+ * This controls what symbols we export from the DSO.
+ */
+VERSION
+{
+	LINUX_2.6.39 {
+	global:
+		__kernel_rt_sigreturn;
+		__kernel_gettimeofday;
+		__kernel_clock_gettime;
+		__kernel_clock_getres;
+	local: *;
+	};
+}
+
+/*
+ * Make the sigreturn code visible to the kernel.
+ */
+VDSO_sigtramp_ilp32		= __kernel_rt_sigreturn;
diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c
index b239b9b..bed6cf1 100644
--- a/arch/arm64/kernel/vdso.c
+++ b/arch/arm64/kernel/vdso.c
@@ -40,6 +40,12 @@ extern char vdso_start, vdso_end;
 static unsigned long vdso_pages;
 static struct page **vdso_pagelist;
 
+#ifdef CONFIG_ARM64_ILP32
+extern char vdso_ilp32_start, vdso_ilp32_end;
+static unsigned long vdso_ilp32_pages;
+static struct page **vdso_ilp32_pagelist;
+#endif
+
 /*
  * The vDSO data page.
  */
@@ -117,24 +123,29 @@ int aarch32_setup_vectors_page(struct linux_binprm *bprm, int uses_interp)
 }
 #endif /* CONFIG_AARCH32_EL0 */
 
-static struct vm_special_mapping vdso_spec[2];
-
-static int __init vdso_init(void)
+static inline int __init vdso_init_common(char *vdso_start, char *vdso_end,
+					  unsigned long *vdso_pagesp,
+					  struct page ***vdso_pagelistp,
+					  struct vm_special_mapping* vdso_spec)
 {
 	int i;
+	unsigned long vdso_pages;
+	struct page **vdso_pagelist;
 
-	if (memcmp(&vdso_start, "\177ELF", 4)) {
+	if (memcmp(vdso_start, "\177ELF", 4)) {
 		pr_err("vDSO is not a valid ELF object!\n");
 		return -EINVAL;
 	}
 
-	vdso_pages = (&vdso_end - &vdso_start) >> PAGE_SHIFT;
+	vdso_pages = (vdso_end - vdso_start) >> PAGE_SHIFT;
+	*vdso_pagesp = vdso_pages;
 	pr_info("vdso: %ld pages (%ld code @ %p, %ld data @ %p)\n",
-		vdso_pages + 1, vdso_pages, &vdso_start, 1L, vdso_data);
+		vdso_pages + 1, vdso_pages, vdso_start, 1L, vdso_data);
 
 	/* Allocate the vDSO pagelist, plus a page for the data. */
 	vdso_pagelist = kcalloc(vdso_pages + 1, sizeof(struct page *),
 				GFP_KERNEL);
+	*vdso_pagelistp = vdso_pagelist;
 	if (vdso_pagelist == NULL)
 		return -ENOMEM;
 
@@ -143,7 +154,7 @@ static int __init vdso_init(void)
 
 	/* Grab the vDSO code pages. */
 	for (i = 0; i < vdso_pages; i++)
-		vdso_pagelist[i + 1] = virt_to_page(&vdso_start + i * PAGE_SIZE);
+		vdso_pagelist[i + 1] = virt_to_page(vdso_start + i * PAGE_SIZE);
 
 	/* Populate the special mapping structures */
 	vdso_spec[0] = (struct vm_special_mapping) {
@@ -158,16 +169,46 @@ static int __init vdso_init(void)
 
 	return 0;
 }
+
+static struct vm_special_mapping vdso_spec[2];
+
+static int __init vdso_init(void)
+{
+	return vdso_init_common(&vdso_start, &vdso_end,
+				&vdso_pages, &vdso_pagelist,
+				vdso_spec);
+}
 arch_initcall(vdso_init);
 
+#ifdef CONFIG_ARM64_ILP32
+static struct vm_special_mapping vdso_ilp32_spec[2];
+
+static int __init vdso_ilp32_init(void)
+{
+	return vdso_init_common(&vdso_ilp32_start, &vdso_ilp32_end,
+				&vdso_ilp32_pages, &vdso_ilp32_pagelist,
+				vdso_ilp32_spec);
+}
+arch_initcall(vdso_ilp32_init);
+#endif
+
 int arch_setup_additional_pages(struct linux_binprm *bprm,
 				int uses_interp)
 {
 	struct mm_struct *mm = current->mm;
 	unsigned long vdso_base, vdso_text_len, vdso_mapping_len;
-	void *ret;
+	void* ret;
+	unsigned long pages = vdso_pages;
+	struct vm_special_mapping* spec = vdso_spec;
+
+#ifdef CONFIG_ARM64_ILP32
+	if (is_ilp32_compat_task()) {
+	        pages = vdso_ilp32_pages;
+	        spec = vdso_ilp32_spec;
+	}
+#endif
 
-	vdso_text_len = vdso_pages << PAGE_SHIFT;
+	vdso_text_len = pages << PAGE_SHIFT;
 	/* Be sure to map the data page */
 	vdso_mapping_len = vdso_text_len + PAGE_SIZE;
 
@@ -179,7 +220,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm,
 	}
 	ret = _install_special_mapping(mm, vdso_base, PAGE_SIZE,
 				       VM_READ|VM_MAYREAD,
-				       &vdso_spec[0]);
+				       &spec[0]);
 	if (IS_ERR(ret))
 		goto up_fail;
 
@@ -188,7 +229,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm,
 	ret = _install_special_mapping(mm, vdso_base, vdso_text_len,
 				       VM_READ|VM_EXEC|
 				       VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
-				       &vdso_spec[1]);
+				       &spec[1]);
 	if (IS_ERR(ret))
 		goto up_fail;
 
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [PATCH v5 17/23] arm64:ilp32: add vdso-ilp32 and use for signal return
@ 2015-09-29 22:14   ` Yury Norov
  0 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-09-29 22:14 UTC (permalink / raw)
  To: linux-arm-kernel

From: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>

Adjusted to move the move data page before code pages in sync with
commit 601255ae3c98fdeeee3a8bb4696425e4f868b4f1

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>

 create mode 100644 arch/arm64/kernel/vdso-ilp32/.gitignore
 create mode 100644 arch/arm64/kernel/vdso-ilp32/Makefile
 copy arch/arm64/{include/asm/vdso.h => kernel/vdso-ilp32/vdso-ilp32.S} (56%)
 create mode 100644 arch/arm64/kernel/vdso-ilp32/vdso-ilp32.lds.S

diff --git a/arch/arm64/include/asm/vdso.h b/arch/arm64/include/asm/vdso.h
index 839ce00..84050c6 100644
--- a/arch/arm64/include/asm/vdso.h
+++ b/arch/arm64/include/asm/vdso.h
@@ -29,6 +29,10 @@
 
 #include <generated/vdso-offsets.h>
 
+#ifdef CONFIG_ARM64_ILP32
+#include <generated/vdso-ilp32-offsets.h>
+#endif
+
 #define VDSO_SYMBOL(base, name)						   \
 ({									   \
 	(void *)(vdso_offset_##name - VDSO_LBASE + (unsigned long)(base)); \
diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile
index 1470332..ff60c2f 100644
--- a/arch/arm64/kernel/Makefile
+++ b/arch/arm64/kernel/Makefile
@@ -38,6 +38,7 @@ arm64-obj-$(CONFIG_ARMV8_DEPRECATED)	+= armv8_deprecated.o
 arm64-obj-$(CONFIG_ACPI)		+= acpi.o
 
 obj-y					+= $(arm64-obj-y) vdso/
+obj-$(CONFIG_ARM64_ILP32)		+= vdso-ilp32/
 obj-m					+= $(arm64-obj-m)
 head-y					:= head.o
 extra-y					:= $(head-y) vmlinux.lds
@@ -45,3 +46,7 @@ extra-y					:= $(head-y) vmlinux.lds
 # vDSO - this must be built first to generate the symbol offsets
 $(call objectify,$(arm64-obj-y)): $(obj)/vdso/vdso-offsets.h
 $(obj)/vdso/vdso-offsets.h: $(obj)/vdso
+
+# vDSO - this must be built first to generate the symbol offsets
+$(call objectify,$(arm64-obj-y)): $(obj)/vdso-ilp32/vdso-ilp32-offsets.h
+$(obj)/vdso-ilp32/vdso-ilp32-offsets.h: $(obj)/vdso-ilp32
diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c
index 2e00531..8eb8ed9 100644
--- a/arch/arm64/kernel/signal.c
+++ b/arch/arm64/kernel/signal.c
@@ -241,6 +241,10 @@ static void setup_return(struct pt_regs *regs, struct k_sigaction *ka,
 
 	if (ka->sa.sa_flags & SA_RESTORER)
 		sigtramp = ka->sa.sa_restorer;
+#ifdef CONFIG_ARM64_ILP32
+	else if (is_ilp32_compat_task())
+		sigtramp = VDSO_SYMBOL(current->mm->context.vdso, sigtramp_ilp32);
+#endif
 	else
 		sigtramp = VDSO_SYMBOL(current->mm->context.vdso, sigtramp);
 
diff --git a/arch/arm64/kernel/vdso-ilp32/.gitignore b/arch/arm64/kernel/vdso-ilp32/.gitignore
new file mode 100644
index 0000000..61806c3
--- /dev/null
+++ b/arch/arm64/kernel/vdso-ilp32/.gitignore
@@ -0,0 +1,2 @@
+vdso-ilp32.lds
+vdso-ilp32-offsets.h
diff --git a/arch/arm64/kernel/vdso-ilp32/Makefile b/arch/arm64/kernel/vdso-ilp32/Makefile
new file mode 100644
index 0000000..c8f5472
--- /dev/null
+++ b/arch/arm64/kernel/vdso-ilp32/Makefile
@@ -0,0 +1,72 @@
+#
+# Building a vDSO image for AArch64.
+#
+# Author: Will Deacon <will.deacon@arm.com>
+# Heavily based on the vDSO Makefiles for other archs.
+#
+
+obj-ilp32-vdso := gettimeofday-ilp32.o note-ilp32.o sigreturn-ilp32.o
+
+# Build rules
+targets := $(obj-ilp32-vdso) vdso-ilp32.so vdso-ilp32.so.dbg
+obj-ilp32-vdso := $(addprefix $(obj)/, $(obj-ilp32-vdso))
+
+ccflags-y := -shared -fno-common -fno-builtin
+ccflags-y += -nostdlib -Wl,-soname=linux-ilp32-vdso.so.1 \
+		$(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
+
+obj-y += vdso-ilp32.o
+extra-y += vdso-ilp32.lds vdso-ilp32-offsets.h
+CPPFLAGS_vdso-ilp32.lds += -P -C -U$(ARCH) -mabi=ilp32
+
+# Force dependency (incbin is bad)
+$(obj)/vdso-ilp32.o : $(obj)/vdso-ilp32.so
+
+# Link rule for the .so file, .lds has to be first
+$(obj)/vdso-ilp32.so.dbg: $(src)/vdso-ilp32.lds $(obj-ilp32-vdso)
+	$(call if_changed,vdso-ilp32ld)
+
+# Strip rule for the .so file
+$(obj)/%.so: OBJCOPYFLAGS := -S
+$(obj)/%.so: $(obj)/%.so.dbg FORCE
+	$(call if_changed,objcopy)
+
+# Generate VDSO offsets using helper script
+gen-vdsosym := $(srctree)/$(src)/../vdso/gen_vdso_offsets.sh
+quiet_cmd_vdsosym = VDSOSYM $@
+define cmd_vdsosym
+	$(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@ && \
+	cp $@ include/generated/
+endef
+
+$(obj)/vdso-ilp32-offsets.h: $(obj)/vdso-ilp32.so.dbg FORCE
+	$(call if_changed,vdsosym)
+
+# Assembly rules for the .S files
+#$(obj-ilp32-vdso): %.o: $(src)/../vdso/$(subst -ilp32,,%.S)
+#	$(call if_changed_dep,vdso-ilp32as)
+
+$(obj)/gettimeofday-ilp32.o: $(src)/../vdso/gettimeofday.S
+	$(call if_changed_dep,vdso-ilp32as)
+
+$(obj)/note-ilp32.o: $(src)/../vdso/note.S
+	$(call if_changed_dep,vdso-ilp32as)
+
+$(obj)/sigreturn-ilp32.o: $(src)/../vdso/sigreturn.S
+	$(call if_changed_dep,vdso-ilp32as)
+
+# Actual build commands
+quiet_cmd_vdso-ilp32ld = VDSOILP32L $@
+      cmd_vdso-ilp32ld = $(CC) $(c_flags) -mabi=ilp32  -Wl,-n -Wl,-T $^ -o $@
+quiet_cmd_vdso-ilp32as = VDSOILP32A $@
+      cmd_vdso-ilp32as = $(CC) $(a_flags) -mabi=ilp32 -c -o $@ $<
+
+# Install commands for the unstripped file
+quiet_cmd_vdso_install = INSTALL $@
+      cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
+
+vdso-ilp32.so: $(obj)/vdso-ilp32.so.dbg
+	@mkdir -p $(MODLIB)/vdso
+	$(call cmd,vdso_install)
+
+vdso_install: vdso-ilp32.so
diff --git a/arch/arm64/include/asm/vdso.h b/arch/arm64/kernel/vdso-ilp32/vdso-ilp32.S
similarity index 56%
copy from arch/arm64/include/asm/vdso.h
copy to arch/arm64/kernel/vdso-ilp32/vdso-ilp32.S
index 839ce00..46ac072 100644
--- a/arch/arm64/include/asm/vdso.h
+++ b/arch/arm64/kernel/vdso-ilp32/vdso-ilp32.S
@@ -12,30 +12,22 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Will Deacon <will.deacon@arm.com>
  */
-#ifndef __ASM_VDSO_H
-#define __ASM_VDSO_H
-
-#ifdef __KERNEL__
-
-/*
- * Default link address for the vDSO.
- * Since we randomise the VDSO mapping, there's little point in trying
- * to prelink this.
- */
-#define VDSO_LBASE	0x0
-
-#ifndef __ASSEMBLY__
-
-#include <generated/vdso-offsets.h>
 
-#define VDSO_SYMBOL(base, name)						   \
-({									   \
-	(void *)(vdso_offset_##name - VDSO_LBASE + (unsigned long)(base)); \
-})
+#include <linux/init.h>
+#include <linux/linkage.h>
+#include <linux/const.h>
+#include <asm/page.h>
 
-#endif /* !__ASSEMBLY__ */
+	__PAGE_ALIGNED_DATA
 
-#endif /* __KERNEL__ */
+	.globl vdso_ilp32_start, vdso_ilp32_end
+	.balign PAGE_SIZE
+vdso_ilp32_start:
+	.incbin "arch/arm64/kernel/vdso-ilp32/vdso-ilp32.so"
+	.balign PAGE_SIZE
+vdso_ilp32_end:
 
-#endif /* __ASM_VDSO_H */
+	.previous
diff --git a/arch/arm64/kernel/vdso-ilp32/vdso-ilp32.lds.S b/arch/arm64/kernel/vdso-ilp32/vdso-ilp32.lds.S
new file mode 100644
index 0000000..ac8029b
--- /dev/null
+++ b/arch/arm64/kernel/vdso-ilp32/vdso-ilp32.lds.S
@@ -0,0 +1,98 @@
+/*
+ * GNU linker script for the VDSO library.
+ *
+ * Copyright (C) 2012 ARM Limited
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Will Deacon <will.deacon@arm.com>
+ * Heavily based on the vDSO linker scripts for other archs.
+ */
+
+#include <linux/const.h>
+#include <asm/page.h>
+#include <asm/vdso.h>
+
+/*OUTPUT_FORMAT("elf32-littleaarch64", "elf32-bigaarch64", "elf32-littleaarch64")
+OUTPUT_ARCH(aarch64)
+*/
+SECTIONS
+{
+	PROVIDE(_vdso_data = . - PAGE_SIZE);
+	. = VDSO_LBASE + SIZEOF_HEADERS;
+
+	.hash		: { *(.hash) }			:text
+	.gnu.hash	: { *(.gnu.hash) }
+	.dynsym		: { *(.dynsym) }
+	.dynstr		: { *(.dynstr) }
+	.gnu.version	: { *(.gnu.version) }
+	.gnu.version_d	: { *(.gnu.version_d) }
+	.gnu.version_r	: { *(.gnu.version_r) }
+
+	.note		: { *(.note.*) }		:text	:note
+
+	. = ALIGN(16);
+
+	.text		: { *(.text*) }			:text	=0xd503201f
+	PROVIDE (__etext = .);
+	PROVIDE (_etext = .);
+	PROVIDE (etext = .);
+
+	.eh_frame_hdr	: { *(.eh_frame_hdr) }		:text	:eh_frame_hdr
+	.eh_frame	: { KEEP (*(.eh_frame)) }	:text
+
+	.dynamic	: { *(.dynamic) }		:text	:dynamic
+
+	.rodata		: { *(.rodata*) }		:text
+
+	_end = .;
+	PROVIDE(end = .);
+
+	/DISCARD/	: {
+		*(.note.GNU-stack)
+		*(.data .data.* .gnu.linkonce.d.* .sdata*)
+		*(.bss .sbss .dynbss .dynsbss)
+	}
+}
+
+/*
+ * We must supply the ELF program headers explicitly to get just one
+ * PT_LOAD segment, and set the flags explicitly to make segments read-only.
+ */
+PHDRS
+{
+	text		PT_LOAD		FLAGS(5) FILEHDR PHDRS; /* PF_R|PF_X */
+	dynamic		PT_DYNAMIC	FLAGS(4);		/* PF_R */
+	note		PT_NOTE		FLAGS(4);		/* PF_R */
+	eh_frame_hdr	PT_GNU_EH_FRAME;
+}
+
+/*
+ * This controls what symbols we export from the DSO.
+ */
+VERSION
+{
+	LINUX_2.6.39 {
+	global:
+		__kernel_rt_sigreturn;
+		__kernel_gettimeofday;
+		__kernel_clock_gettime;
+		__kernel_clock_getres;
+	local: *;
+	};
+}
+
+/*
+ * Make the sigreturn code visible to the kernel.
+ */
+VDSO_sigtramp_ilp32		= __kernel_rt_sigreturn;
diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c
index b239b9b..bed6cf1 100644
--- a/arch/arm64/kernel/vdso.c
+++ b/arch/arm64/kernel/vdso.c
@@ -40,6 +40,12 @@ extern char vdso_start, vdso_end;
 static unsigned long vdso_pages;
 static struct page **vdso_pagelist;
 
+#ifdef CONFIG_ARM64_ILP32
+extern char vdso_ilp32_start, vdso_ilp32_end;
+static unsigned long vdso_ilp32_pages;
+static struct page **vdso_ilp32_pagelist;
+#endif
+
 /*
  * The vDSO data page.
  */
@@ -117,24 +123,29 @@ int aarch32_setup_vectors_page(struct linux_binprm *bprm, int uses_interp)
 }
 #endif /* CONFIG_AARCH32_EL0 */
 
-static struct vm_special_mapping vdso_spec[2];
-
-static int __init vdso_init(void)
+static inline int __init vdso_init_common(char *vdso_start, char *vdso_end,
+					  unsigned long *vdso_pagesp,
+					  struct page ***vdso_pagelistp,
+					  struct vm_special_mapping* vdso_spec)
 {
 	int i;
+	unsigned long vdso_pages;
+	struct page **vdso_pagelist;
 
-	if (memcmp(&vdso_start, "\177ELF", 4)) {
+	if (memcmp(vdso_start, "\177ELF", 4)) {
 		pr_err("vDSO is not a valid ELF object!\n");
 		return -EINVAL;
 	}
 
-	vdso_pages = (&vdso_end - &vdso_start) >> PAGE_SHIFT;
+	vdso_pages = (vdso_end - vdso_start) >> PAGE_SHIFT;
+	*vdso_pagesp = vdso_pages;
 	pr_info("vdso: %ld pages (%ld code @ %p, %ld data @ %p)\n",
-		vdso_pages + 1, vdso_pages, &vdso_start, 1L, vdso_data);
+		vdso_pages + 1, vdso_pages, vdso_start, 1L, vdso_data);
 
 	/* Allocate the vDSO pagelist, plus a page for the data. */
 	vdso_pagelist = kcalloc(vdso_pages + 1, sizeof(struct page *),
 				GFP_KERNEL);
+	*vdso_pagelistp = vdso_pagelist;
 	if (vdso_pagelist == NULL)
 		return -ENOMEM;
 
@@ -143,7 +154,7 @@ static int __init vdso_init(void)
 
 	/* Grab the vDSO code pages. */
 	for (i = 0; i < vdso_pages; i++)
-		vdso_pagelist[i + 1] = virt_to_page(&vdso_start + i * PAGE_SIZE);
+		vdso_pagelist[i + 1] = virt_to_page(vdso_start + i * PAGE_SIZE);
 
 	/* Populate the special mapping structures */
 	vdso_spec[0] = (struct vm_special_mapping) {
@@ -158,16 +169,46 @@ static int __init vdso_init(void)
 
 	return 0;
 }
+
+static struct vm_special_mapping vdso_spec[2];
+
+static int __init vdso_init(void)
+{
+	return vdso_init_common(&vdso_start, &vdso_end,
+				&vdso_pages, &vdso_pagelist,
+				vdso_spec);
+}
 arch_initcall(vdso_init);
 
+#ifdef CONFIG_ARM64_ILP32
+static struct vm_special_mapping vdso_ilp32_spec[2];
+
+static int __init vdso_ilp32_init(void)
+{
+	return vdso_init_common(&vdso_ilp32_start, &vdso_ilp32_end,
+				&vdso_ilp32_pages, &vdso_ilp32_pagelist,
+				vdso_ilp32_spec);
+}
+arch_initcall(vdso_ilp32_init);
+#endif
+
 int arch_setup_additional_pages(struct linux_binprm *bprm,
 				int uses_interp)
 {
 	struct mm_struct *mm = current->mm;
 	unsigned long vdso_base, vdso_text_len, vdso_mapping_len;
-	void *ret;
+	void* ret;
+	unsigned long pages = vdso_pages;
+	struct vm_special_mapping* spec = vdso_spec;
+
+#ifdef CONFIG_ARM64_ILP32
+	if (is_ilp32_compat_task()) {
+	        pages = vdso_ilp32_pages;
+	        spec = vdso_ilp32_spec;
+	}
+#endif
 
-	vdso_text_len = vdso_pages << PAGE_SHIFT;
+	vdso_text_len = pages << PAGE_SHIFT;
 	/* Be sure to map the data page */
 	vdso_mapping_len = vdso_text_len + PAGE_SIZE;
 
@@ -179,7 +220,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm,
 	}
 	ret = _install_special_mapping(mm, vdso_base, PAGE_SIZE,
 				       VM_READ|VM_MAYREAD,
-				       &vdso_spec[0]);
+				       &spec[0]);
 	if (IS_ERR(ret))
 		goto up_fail;
 
@@ -188,7 +229,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm,
 	ret = _install_special_mapping(mm, vdso_base, vdso_text_len,
 				       VM_READ|VM_EXEC|
 				       VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
-				       &vdso_spec[1]);
+				       &spec[1]);
 	if (IS_ERR(ret))
 		goto up_fail;
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [PATCH v5 18/23] ptrace: Allow compat to use the native siginfo
  2015-09-29 22:13 ` Yury Norov
@ 2015-09-29 22:14   ` Yury Norov
  -1 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-09-29 22:14 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel, catalin.marinas, arnd, agraf,
	bamvor.zhangjian
  Cc: yury.norov, philipp.tomsich, apinski, christoph.muellner,
	klimov.linux, Yury Norov

From: Andrew Pinski <apinski@cavium.com>

Set COMPAT_USE_NATIVE_SIGINFO to be true for non AARCH32 tasks.

With ARM64 ILP32 ABI, we want to use the non-compat
siginfo as we want to simplify signal handling for this new ABI.
This patch just adds a new define COMPAT_USE_NATIVE_SIGINFO and
if it is true then read/write in the compat case as it was the
non-compat case.

Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>

diff --git a/include/linux/compat.h b/include/linux/compat.h
index a76c917..0a25d90 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -24,6 +24,10 @@
 #define COMPAT_USE_64BIT_TIME 0
 #endif
 
+#ifndef COMPAT_USE_NATIVE_SIGINFO
+#define COMPAT_USE_NATIVE_SIGINFO 0
+#endif
+
 #ifndef __SC_DELOUSE
 #define __SC_DELOUSE(t,v) ((t)(unsigned long)(v))
 #endif
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index 787320d..04799aa 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -652,7 +652,7 @@ static int ptrace_peek_siginfo(struct task_struct *child,
 			break;
 
 #ifdef CONFIG_COMPAT
-		if (unlikely(is_compat_task())) {
+		if (unlikely(is_compat_task() && !COMPAT_USE_NATIVE_SIGINFO)) {
 			compat_siginfo_t __user *uinfo = compat_ptr(data);
 
 			if (copy_siginfo_to_user32(uinfo, &info) ||
@@ -1140,16 +1140,26 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
 
 	case PTRACE_GETSIGINFO:
 		ret = ptrace_getsiginfo(child, &siginfo);
-		if (!ret)
-			ret = copy_siginfo_to_user32(
-				(struct compat_siginfo __user *) datap,
-				&siginfo);
+		if (!ret) {
+			if (COMPAT_USE_NATIVE_SIGINFO)
+				ret = copy_siginfo_to_user(
+					(struct siginfo __user *) datap,
+					&siginfo);
+			else
+				ret = copy_siginfo_to_user32(
+					(struct compat_siginfo __user *) datap,
+					&siginfo);
+		}
 		break;
 
 	case PTRACE_SETSIGINFO:
 		memset(&siginfo, 0, sizeof siginfo);
-		if (copy_siginfo_from_user32(
-			    &siginfo, (struct compat_siginfo __user *) datap))
+		if (COMPAT_USE_NATIVE_SIGINFO)
+			ret = copy_from_user(&siginfo, datap, sizeof(siginfo));
+		else
+			ret = copy_siginfo_from_user32(
+				 &siginfo, (struct compat_siginfo __user *) datap);
+		if (ret)
 			ret = -EFAULT;
 		else
 			ret = ptrace_setsiginfo(child, &siginfo);
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [PATCH v5 18/23] ptrace: Allow compat to use the native siginfo
@ 2015-09-29 22:14   ` Yury Norov
  0 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-09-29 22:14 UTC (permalink / raw)
  To: linux-arm-kernel

From: Andrew Pinski <apinski@cavium.com>

Set COMPAT_USE_NATIVE_SIGINFO to be true for non AARCH32 tasks.

With ARM64 ILP32 ABI, we want to use the non-compat
siginfo as we want to simplify signal handling for this new ABI.
This patch just adds a new define COMPAT_USE_NATIVE_SIGINFO and
if it is true then read/write in the compat case as it was the
non-compat case.

Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>

diff --git a/include/linux/compat.h b/include/linux/compat.h
index a76c917..0a25d90 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -24,6 +24,10 @@
 #define COMPAT_USE_64BIT_TIME 0
 #endif
 
+#ifndef COMPAT_USE_NATIVE_SIGINFO
+#define COMPAT_USE_NATIVE_SIGINFO 0
+#endif
+
 #ifndef __SC_DELOUSE
 #define __SC_DELOUSE(t,v) ((t)(unsigned long)(v))
 #endif
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index 787320d..04799aa 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -652,7 +652,7 @@ static int ptrace_peek_siginfo(struct task_struct *child,
 			break;
 
 #ifdef CONFIG_COMPAT
-		if (unlikely(is_compat_task())) {
+		if (unlikely(is_compat_task() && !COMPAT_USE_NATIVE_SIGINFO)) {
 			compat_siginfo_t __user *uinfo = compat_ptr(data);
 
 			if (copy_siginfo_to_user32(uinfo, &info) ||
@@ -1140,16 +1140,26 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
 
 	case PTRACE_GETSIGINFO:
 		ret = ptrace_getsiginfo(child, &siginfo);
-		if (!ret)
-			ret = copy_siginfo_to_user32(
-				(struct compat_siginfo __user *) datap,
-				&siginfo);
+		if (!ret) {
+			if (COMPAT_USE_NATIVE_SIGINFO)
+				ret = copy_siginfo_to_user(
+					(struct siginfo __user *) datap,
+					&siginfo);
+			else
+				ret = copy_siginfo_to_user32(
+					(struct compat_siginfo __user *) datap,
+					&siginfo);
+		}
 		break;
 
 	case PTRACE_SETSIGINFO:
 		memset(&siginfo, 0, sizeof siginfo);
-		if (copy_siginfo_from_user32(
-			    &siginfo, (struct compat_siginfo __user *) datap))
+		if (COMPAT_USE_NATIVE_SIGINFO)
+			ret = copy_from_user(&siginfo, datap, sizeof(siginfo));
+		else
+			ret = copy_siginfo_from_user32(
+				 &siginfo, (struct compat_siginfo __user *) datap);
+		if (ret)
 			ret = -EFAULT;
 		else
 			ret = ptrace_setsiginfo(child, &siginfo);
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [PATCH v5 19/23] arm64:ilp32: add sys_ilp32.c and a separate table (in entry.S) to use it
  2015-09-29 22:13 ` Yury Norov
@ 2015-09-29 22:14   ` Yury Norov
  -1 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-09-29 22:14 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel, catalin.marinas, arnd, agraf,
	bamvor.zhangjian
  Cc: yury.norov, philipp.tomsich, apinski, christoph.muellner,
	klimov.linux, Yury Norov

From: Andrew Pinski <apinski@cavium.com>

Add a separate syscall-table for ILP32, which dispatches either to native
LP64 system call implementation or to compat-syscalls, as appropriate.

This revision of the patch now addresses Catalin's comment regarding the
duplicate reading of the task-flags in the el0_svc-handler and simply
relies on the flags having been read by the kernel_entry macro.

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>

 create mode 100644 arch/arm64/kernel/sys_ilp32.c

diff --git a/arch/arm64/include/asm/unistd.h b/arch/arm64/include/asm/unistd.h
index 759c433..31eabf1 100644
--- a/arch/arm64/include/asm/unistd.h
+++ b/arch/arm64/include/asm/unistd.h
@@ -13,6 +13,10 @@
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
+#ifdef CONFIG_ARM64_ILP32
+#define __ARCH_WANT_COMPAT_SYS_PREADV64
+#define __ARCH_WANT_COMPAT_SYS_PWRITEV64
+#endif
 #ifdef CONFIG_AARCH32_EL0
 #define __ARCH_WANT_COMPAT_SYS_GETDENTS64
 #define __ARCH_WANT_COMPAT_STAT64
diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile
index ff60c2f..a1cbb11 100644
--- a/arch/arm64/kernel/Makefile
+++ b/arch/arm64/kernel/Makefile
@@ -24,6 +24,7 @@ arm64-obj-$(CONFIG_AARCH32_EL0)		+= sys32.o kuser32.o signal32.o 	\
 					   sys_compat.o entry32.o		\
 					   ../../arm/kernel/opcodes.o
 arm64-obj-$(CONFIG_FUNCTION_TRACER)	+= ftrace.o entry-ftrace.o
+arm64-obj-$(CONFIG_ARM64_ILP32)		+= sys_ilp32.o
 arm64-obj-$(CONFIG_MODULES)		+= arm64ksyms.o module.o
 arm64-obj-$(CONFIG_PERF_EVENTS)		+= perf_regs.o perf_callchain.o
 arm64-obj-$(CONFIG_HW_PERF_EVENTS)	+= perf_event.o
diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S
index 52be5c8..bcd921a 100644
--- a/arch/arm64/kernel/entry.S
+++ b/arch/arm64/kernel/entry.S
@@ -664,9 +664,13 @@ ENDPROC(ret_from_fork)
  */
 	.align	6
 el0_svc:
-	adrp	stbl, sys_call_table		// load syscall table pointer
 	uxtw	scno, w8			// syscall number in w8
 	mov	sc_nr, #__NR_syscalls
+#ifdef CONFIG_ARM64_ILP32
+	ldr	x16, [tsk, #TI_FLAGS]
+	tbnz	x16, #TIF_32BIT_AARCH64, el0_ilp32_svc // We are using ILP32
+#endif
+	adrp	stbl, sys_call_table		// load syscall table pointer
 el0_svc_naked:					// compat entry point
 	stp	x0, scno, [sp, #S_ORIG_X0]	// save the original x0 and syscall number
 	enable_dbg_and_irq
@@ -686,6 +690,12 @@ ni_sys:
 	b	ret_fast_syscall
 ENDPROC(el0_svc)
 
+#ifdef CONFIG_ARM64_ILP32
+el0_ilp32_svc:
+	adrp	stbl, sys_call_ilp32_table // load syscall table pointer
+	b el0_svc_naked
+#endif
+
 	/*
 	 * This is the really slow path.  We're going to be doing context
 	 * switches, and waiting for our parent to respond.
diff --git a/arch/arm64/kernel/sys_ilp32.c b/arch/arm64/kernel/sys_ilp32.c
new file mode 100644
index 0000000..623191a
--- /dev/null
+++ b/arch/arm64/kernel/sys_ilp32.c
@@ -0,0 +1,178 @@
+/*
+ * AArch64- ILP32 specific system calls implementation
+ *
+ * Copyright (C) 2013 Cavium Inc.
+ * Author: Andrew Pinski <apinski@cavium.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <linux/compiler.h>
+#include <linux/errno.h>
+#include <linux/fs.h>
+#include <linux/mm.h>
+#include <linux/export.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/syscalls.h>
+#include <linux/compat.h>
+
+/*
+ * Wrappers to pass the pt_regs argument.
+ */
+asmlinkage long sys_rt_sigreturn_wrapper(void);
+#define sys_rt_sigreturn        sys_rt_sigreturn_wrapper
+
+/* Using Compat syscalls where necessary */
+#define sys_ioctl		compat_sys_ioctl
+/* iovec */
+#define sys_readv		compat_sys_readv
+#define sys_writev		compat_sys_writev
+#define sys_preadv		compat_sys_preadv64
+#define sys_pwritev		compat_sys_pwritev64
+#define sys_vmsplice		compat_sys_vmsplice
+/* robust_list_head */
+#define sys_set_robust_list	compat_sys_set_robust_list
+#define sys_get_robust_list	compat_sys_get_robust_list
+
+/* kexec_segment */
+#define sys_kexec_load		compat_sys_kexec_load
+
+/* Ptrace has some structures which are different between ILP32 and LP64 */
+#define sys_ptrace		compat_sys_ptrace
+
+/* struct msghdr */
+#define sys_recvfrom		compat_sys_recvfrom
+#define sys_recvmmsg		compat_sys_recvmmsg
+#define sys_sendmmsg		compat_sys_sendmmsg
+#define sys_sendmsg		compat_sys_sendmsg
+#define sys_recvmsg		compat_sys_recvmsg
+
+#define sys_setsockopt		compat_sys_setsockopt
+#define sys_getsockopt		compat_sys_getsockopt
+
+/* Array of pointers */
+#define sys_execve		compat_sys_execve
+#define sys_move_pages		compat_sys_move_pages
+
+/* iovec */
+#define sys_process_vm_readv	compat_sys_process_vm_readv
+#define sys_process_vm_writev	compat_sys_process_vm_writev
+
+/* Pointer in struct */
+#define sys_mount               compat_sys_mount
+
+/* NUMA */
+/* unsigned long bitmaps */
+#define sys_get_mempolicy       compat_sys_get_mempolicy
+#define sys_set_mempolicy       compat_sys_set_mempolicy
+#define sys_mbind               compat_sys_mbind
+/* array of pointers */
+/* unsigned long bitmaps */
+#define sys_migrate_pages       compat_sys_migrate_pages
+
+/* Scheduler */
+/* unsigned long bitmaps */
+#define sys_sched_setaffinity   compat_sys_sched_setaffinity
+#define sys_sched_getaffinity   compat_sys_sched_getaffinity
+
+/* iov usage */
+#define sys_keyctl              compat_sys_keyctl
+
+/* aio */
+/* Pointer to Pointer  */
+#define sys_io_setup		compat_sys_io_setup
+/* Array of pointers */
+#define sys_io_submit           compat_sys_io_submit
+
+/* We need to make sure the pointer gets copied correctly. */
+asmlinkage long ilp32_sys_mq_notify(mqd_t mqdes, const struct sigevent __user *u_notification)
+{
+	struct sigevent __user *p = NULL;
+	if (u_notification) {
+		struct sigevent n;
+		p = compat_alloc_user_space(sizeof(*p));
+		if (copy_from_user(&n, u_notification, sizeof(*p)))
+			return -EFAULT;
+		if (n.sigev_notify == SIGEV_THREAD)
+			n.sigev_value.sival_ptr = compat_ptr((uintptr_t)n.sigev_value.sival_ptr);
+		if (copy_to_user(p, &n, sizeof(*p)))
+			return -EFAULT;
+	}
+	return sys_mq_notify(mqdes, p);
+}
+
+/* sigevent contains sigval_t which is now 64bit always
+   but need special handling due to padding for SIGEV_THREAD.  */
+#define sys_mq_notify		ilp32_sys_mq_notify
+
+
+/* sigaltstack needs some special handling as the
+   padding for stack_t might not be non-zero. */
+long ilp32_sys_sigaltstack(const stack_t __user *uss_ptr,
+			   stack_t __user *uoss_ptr)
+{
+	stack_t uss, uoss;
+	int ret;
+	mm_segment_t seg;
+
+	if (uss_ptr) {
+		if (!access_ok(VERIFY_READ, uss_ptr, sizeof(*uss_ptr)))
+			return -EFAULT;
+		if (__get_user(uss.ss_sp, &uss_ptr->ss_sp) |
+			__get_user(uss.ss_flags, &uss_ptr->ss_flags) |
+			__get_user(uss.ss_size, &uss_ptr->ss_size))
+			return -EFAULT;
+		/* Zero extend the sp address and the size. */
+		uss.ss_sp = (void *)(uintptr_t)(unsigned int)(uintptr_t)uss.ss_sp;
+		uss.ss_size = (size_t)(unsigned int)uss.ss_size;
+	}
+	seg = get_fs();
+	set_fs(KERNEL_DS);
+	/* Note we need to use uoss as we have changed the segment to the
+	   kernel one so passing an user one around is wrong. */
+	ret = sys_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
+			      (stack_t __force __user *) &uoss);
+	set_fs(seg);
+	if (ret >= 0 && uoss_ptr)  {
+		if (!access_ok(VERIFY_WRITE, uoss_ptr, sizeof(stack_t)) ||
+		    __put_user(uoss.ss_sp, &uoss_ptr->ss_sp) ||
+		    __put_user(uoss.ss_flags, &uoss_ptr->ss_flags) ||
+		    __put_user(uoss.ss_size, &uoss_ptr->ss_size))
+			ret = -EFAULT;
+	}
+	return ret;
+}
+
+/* sigaltstack needs some special handling as the padding
+   for stack_t might not be non-zero. */
+#define sys_sigaltstack		ilp32_sys_sigaltstack
+
+
+#include <asm/syscall.h>
+
+#undef __SYSCALL
+#define __SYSCALL(nr, sym)	[nr] = sym,
+
+asmlinkage long sys_mmap(unsigned long addr, unsigned long len,
+			 unsigned long prot, unsigned long flags,
+			 unsigned long fd, off_t off);
+
+/*
+ * The sys_call_ilp32_table array must be 4K aligned to be accessible from
+ * kernel/entry.S.
+ */
+void *sys_call_ilp32_table[__NR_syscalls] __aligned(4096) = {
+	[0 ... __NR_syscalls - 1] = sys_ni_syscall,
+#include <asm/unistd.h>
+};
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [PATCH v5 19/23] arm64:ilp32: add sys_ilp32.c and a separate table (in entry.S) to use it
@ 2015-09-29 22:14   ` Yury Norov
  0 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-09-29 22:14 UTC (permalink / raw)
  To: linux-arm-kernel

From: Andrew Pinski <apinski@cavium.com>

Add a separate syscall-table for ILP32, which dispatches either to native
LP64 system call implementation or to compat-syscalls, as appropriate.

This revision of the patch now addresses Catalin's comment regarding the
duplicate reading of the task-flags in the el0_svc-handler and simply
relies on the flags having been read by the kernel_entry macro.

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>

 create mode 100644 arch/arm64/kernel/sys_ilp32.c

diff --git a/arch/arm64/include/asm/unistd.h b/arch/arm64/include/asm/unistd.h
index 759c433..31eabf1 100644
--- a/arch/arm64/include/asm/unistd.h
+++ b/arch/arm64/include/asm/unistd.h
@@ -13,6 +13,10 @@
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
+#ifdef CONFIG_ARM64_ILP32
+#define __ARCH_WANT_COMPAT_SYS_PREADV64
+#define __ARCH_WANT_COMPAT_SYS_PWRITEV64
+#endif
 #ifdef CONFIG_AARCH32_EL0
 #define __ARCH_WANT_COMPAT_SYS_GETDENTS64
 #define __ARCH_WANT_COMPAT_STAT64
diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile
index ff60c2f..a1cbb11 100644
--- a/arch/arm64/kernel/Makefile
+++ b/arch/arm64/kernel/Makefile
@@ -24,6 +24,7 @@ arm64-obj-$(CONFIG_AARCH32_EL0)		+= sys32.o kuser32.o signal32.o 	\
 					   sys_compat.o entry32.o		\
 					   ../../arm/kernel/opcodes.o
 arm64-obj-$(CONFIG_FUNCTION_TRACER)	+= ftrace.o entry-ftrace.o
+arm64-obj-$(CONFIG_ARM64_ILP32)		+= sys_ilp32.o
 arm64-obj-$(CONFIG_MODULES)		+= arm64ksyms.o module.o
 arm64-obj-$(CONFIG_PERF_EVENTS)		+= perf_regs.o perf_callchain.o
 arm64-obj-$(CONFIG_HW_PERF_EVENTS)	+= perf_event.o
diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S
index 52be5c8..bcd921a 100644
--- a/arch/arm64/kernel/entry.S
+++ b/arch/arm64/kernel/entry.S
@@ -664,9 +664,13 @@ ENDPROC(ret_from_fork)
  */
 	.align	6
 el0_svc:
-	adrp	stbl, sys_call_table		// load syscall table pointer
 	uxtw	scno, w8			// syscall number in w8
 	mov	sc_nr, #__NR_syscalls
+#ifdef CONFIG_ARM64_ILP32
+	ldr	x16, [tsk, #TI_FLAGS]
+	tbnz	x16, #TIF_32BIT_AARCH64, el0_ilp32_svc // We are using ILP32
+#endif
+	adrp	stbl, sys_call_table		// load syscall table pointer
 el0_svc_naked:					// compat entry point
 	stp	x0, scno, [sp, #S_ORIG_X0]	// save the original x0 and syscall number
 	enable_dbg_and_irq
@@ -686,6 +690,12 @@ ni_sys:
 	b	ret_fast_syscall
 ENDPROC(el0_svc)
 
+#ifdef CONFIG_ARM64_ILP32
+el0_ilp32_svc:
+	adrp	stbl, sys_call_ilp32_table // load syscall table pointer
+	b el0_svc_naked
+#endif
+
 	/*
 	 * This is the really slow path.  We're going to be doing context
 	 * switches, and waiting for our parent to respond.
diff --git a/arch/arm64/kernel/sys_ilp32.c b/arch/arm64/kernel/sys_ilp32.c
new file mode 100644
index 0000000..623191a
--- /dev/null
+++ b/arch/arm64/kernel/sys_ilp32.c
@@ -0,0 +1,178 @@
+/*
+ * AArch64- ILP32 specific system calls implementation
+ *
+ * Copyright (C) 2013 Cavium Inc.
+ * Author: Andrew Pinski <apinski@cavium.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <linux/compiler.h>
+#include <linux/errno.h>
+#include <linux/fs.h>
+#include <linux/mm.h>
+#include <linux/export.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/syscalls.h>
+#include <linux/compat.h>
+
+/*
+ * Wrappers to pass the pt_regs argument.
+ */
+asmlinkage long sys_rt_sigreturn_wrapper(void);
+#define sys_rt_sigreturn        sys_rt_sigreturn_wrapper
+
+/* Using Compat syscalls where necessary */
+#define sys_ioctl		compat_sys_ioctl
+/* iovec */
+#define sys_readv		compat_sys_readv
+#define sys_writev		compat_sys_writev
+#define sys_preadv		compat_sys_preadv64
+#define sys_pwritev		compat_sys_pwritev64
+#define sys_vmsplice		compat_sys_vmsplice
+/* robust_list_head */
+#define sys_set_robust_list	compat_sys_set_robust_list
+#define sys_get_robust_list	compat_sys_get_robust_list
+
+/* kexec_segment */
+#define sys_kexec_load		compat_sys_kexec_load
+
+/* Ptrace has some structures which are different between ILP32 and LP64 */
+#define sys_ptrace		compat_sys_ptrace
+
+/* struct msghdr */
+#define sys_recvfrom		compat_sys_recvfrom
+#define sys_recvmmsg		compat_sys_recvmmsg
+#define sys_sendmmsg		compat_sys_sendmmsg
+#define sys_sendmsg		compat_sys_sendmsg
+#define sys_recvmsg		compat_sys_recvmsg
+
+#define sys_setsockopt		compat_sys_setsockopt
+#define sys_getsockopt		compat_sys_getsockopt
+
+/* Array of pointers */
+#define sys_execve		compat_sys_execve
+#define sys_move_pages		compat_sys_move_pages
+
+/* iovec */
+#define sys_process_vm_readv	compat_sys_process_vm_readv
+#define sys_process_vm_writev	compat_sys_process_vm_writev
+
+/* Pointer in struct */
+#define sys_mount               compat_sys_mount
+
+/* NUMA */
+/* unsigned long bitmaps */
+#define sys_get_mempolicy       compat_sys_get_mempolicy
+#define sys_set_mempolicy       compat_sys_set_mempolicy
+#define sys_mbind               compat_sys_mbind
+/* array of pointers */
+/* unsigned long bitmaps */
+#define sys_migrate_pages       compat_sys_migrate_pages
+
+/* Scheduler */
+/* unsigned long bitmaps */
+#define sys_sched_setaffinity   compat_sys_sched_setaffinity
+#define sys_sched_getaffinity   compat_sys_sched_getaffinity
+
+/* iov usage */
+#define sys_keyctl              compat_sys_keyctl
+
+/* aio */
+/* Pointer to Pointer  */
+#define sys_io_setup		compat_sys_io_setup
+/* Array of pointers */
+#define sys_io_submit           compat_sys_io_submit
+
+/* We need to make sure the pointer gets copied correctly. */
+asmlinkage long ilp32_sys_mq_notify(mqd_t mqdes, const struct sigevent __user *u_notification)
+{
+	struct sigevent __user *p = NULL;
+	if (u_notification) {
+		struct sigevent n;
+		p = compat_alloc_user_space(sizeof(*p));
+		if (copy_from_user(&n, u_notification, sizeof(*p)))
+			return -EFAULT;
+		if (n.sigev_notify == SIGEV_THREAD)
+			n.sigev_value.sival_ptr = compat_ptr((uintptr_t)n.sigev_value.sival_ptr);
+		if (copy_to_user(p, &n, sizeof(*p)))
+			return -EFAULT;
+	}
+	return sys_mq_notify(mqdes, p);
+}
+
+/* sigevent contains sigval_t which is now 64bit always
+   but need special handling due to padding for SIGEV_THREAD.  */
+#define sys_mq_notify		ilp32_sys_mq_notify
+
+
+/* sigaltstack needs some special handling as the
+   padding for stack_t might not be non-zero. */
+long ilp32_sys_sigaltstack(const stack_t __user *uss_ptr,
+			   stack_t __user *uoss_ptr)
+{
+	stack_t uss, uoss;
+	int ret;
+	mm_segment_t seg;
+
+	if (uss_ptr) {
+		if (!access_ok(VERIFY_READ, uss_ptr, sizeof(*uss_ptr)))
+			return -EFAULT;
+		if (__get_user(uss.ss_sp, &uss_ptr->ss_sp) |
+			__get_user(uss.ss_flags, &uss_ptr->ss_flags) |
+			__get_user(uss.ss_size, &uss_ptr->ss_size))
+			return -EFAULT;
+		/* Zero extend the sp address and the size. */
+		uss.ss_sp = (void *)(uintptr_t)(unsigned int)(uintptr_t)uss.ss_sp;
+		uss.ss_size = (size_t)(unsigned int)uss.ss_size;
+	}
+	seg = get_fs();
+	set_fs(KERNEL_DS);
+	/* Note we need to use uoss as we have changed the segment to the
+	   kernel one so passing an user one around is wrong. */
+	ret = sys_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
+			      (stack_t __force __user *) &uoss);
+	set_fs(seg);
+	if (ret >= 0 && uoss_ptr)  {
+		if (!access_ok(VERIFY_WRITE, uoss_ptr, sizeof(stack_t)) ||
+		    __put_user(uoss.ss_sp, &uoss_ptr->ss_sp) ||
+		    __put_user(uoss.ss_flags, &uoss_ptr->ss_flags) ||
+		    __put_user(uoss.ss_size, &uoss_ptr->ss_size))
+			ret = -EFAULT;
+	}
+	return ret;
+}
+
+/* sigaltstack needs some special handling as the padding
+   for stack_t might not be non-zero. */
+#define sys_sigaltstack		ilp32_sys_sigaltstack
+
+
+#include <asm/syscall.h>
+
+#undef __SYSCALL
+#define __SYSCALL(nr, sym)	[nr] = sym,
+
+asmlinkage long sys_mmap(unsigned long addr, unsigned long len,
+			 unsigned long prot, unsigned long flags,
+			 unsigned long fd, off_t off);
+
+/*
+ * The sys_call_ilp32_table array must be 4K aligned to be accessible from
+ * kernel/entry.S.
+ */
+void *sys_call_ilp32_table[__NR_syscalls] __aligned(4096) = {
+	[0 ... __NR_syscalls - 1] = sys_ni_syscall,
+#include <asm/unistd.h>
+};
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [PATCH v5 20/23] arm64:ilp32: use the native siginfo instead of the compat siginfo
  2015-09-29 22:13 ` Yury Norov
@ 2015-09-29 22:14   ` Yury Norov
  -1 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-09-29 22:14 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel, catalin.marinas, arnd, agraf,
	bamvor.zhangjian
  Cc: yury.norov, philipp.tomsich, apinski, christoph.muellner,
	klimov.linux, Yury Norov

From: Andrew Pinski <apinski@cavium.com>

Set COMPAT_USE_NATIVE_SIGINFO to be true for non AARCH32 tasks.

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>

diff --git a/arch/arm64/include/asm/compat.h b/arch/arm64/include/asm/compat.h
index 4b717df..47f2b7a 100644
--- a/arch/arm64/include/asm/compat.h
+++ b/arch/arm64/include/asm/compat.h
@@ -217,6 +217,9 @@ typedef struct compat_siginfo {
 	} _sifields;
 } compat_siginfo_t;
 
+/* ILP32 uses the native siginfo and not the compat struct */
+#define COMPAT_USE_NATIVE_SIGINFO	!is_a32_compat_task()
+
 #define COMPAT_OFF_T_MAX	0x7fffffff
 #define COMPAT_LOFF_T_MAX	0x7fffffffffffffffL
 
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [PATCH v5 20/23] arm64:ilp32: use the native siginfo instead of the compat siginfo
@ 2015-09-29 22:14   ` Yury Norov
  0 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-09-29 22:14 UTC (permalink / raw)
  To: linux-arm-kernel

From: Andrew Pinski <apinski@cavium.com>

Set COMPAT_USE_NATIVE_SIGINFO to be true for non AARCH32 tasks.

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>

diff --git a/arch/arm64/include/asm/compat.h b/arch/arm64/include/asm/compat.h
index 4b717df..47f2b7a 100644
--- a/arch/arm64/include/asm/compat.h
+++ b/arch/arm64/include/asm/compat.h
@@ -217,6 +217,9 @@ typedef struct compat_siginfo {
 	} _sifields;
 } compat_siginfo_t;
 
+/* ILP32 uses the native siginfo and not the compat struct */
+#define COMPAT_USE_NATIVE_SIGINFO	!is_a32_compat_task()
+
 #define COMPAT_OFF_T_MAX	0x7fffffff
 #define COMPAT_LOFF_T_MAX	0x7fffffffffffffffL
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [PATCH v5 21/23] arm64:ilp32: change COMPAT_ELF_PLATFORM to report a a subplatform for ILP32
  2015-09-29 22:13 ` Yury Norov
@ 2015-09-29 22:14   ` Yury Norov
  -1 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-09-29 22:14 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel, catalin.marinas, arnd, agraf,
	bamvor.zhangjian
  Cc: yury.norov, philipp.tomsich, apinski, christoph.muellner,
	klimov.linux, Yury Norov

From: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>

To make life for tools (such as gdb) easier when dealing with ILP32 processes,
we report a proper subarchitecture for ILP32 in the ELF auxiliary vectors.

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>

diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h
index 9a854f9..8ef8fc5 100644
--- a/arch/arm64/include/asm/elf.h
+++ b/arch/arm64/include/asm/elf.h
@@ -163,9 +163,9 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
 #ifdef CONFIG_COMPAT
 
 #ifdef __AARCH64EB__
-#define COMPAT_ELF_PLATFORM		("v8b")
+#define COMPAT_ELF_PLATFORM		(is_ilp32_compat_task() ? "aarch64_be:ilp32" : "v8b")
 #else
-#define COMPAT_ELF_PLATFORM		("v8l")
+#define COMPAT_ELF_PLATFORM		(is_ilp32_compat_task() ? "aarch64:ilp32" : "v8l")
 #endif
 
 #define COMPAT_ELF_ET_DYN_BASE		(2 * TASK_SIZE_32 / 3)
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [PATCH v5 21/23] arm64:ilp32: change COMPAT_ELF_PLATFORM to report a a subplatform for ILP32
@ 2015-09-29 22:14   ` Yury Norov
  0 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-09-29 22:14 UTC (permalink / raw)
  To: linux-arm-kernel

From: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>

To make life for tools (such as gdb) easier when dealing with ILP32 processes,
we report a proper subarchitecture for ILP32 in the ELF auxiliary vectors.

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>

diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h
index 9a854f9..8ef8fc5 100644
--- a/arch/arm64/include/asm/elf.h
+++ b/arch/arm64/include/asm/elf.h
@@ -163,9 +163,9 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
 #ifdef CONFIG_COMPAT
 
 #ifdef __AARCH64EB__
-#define COMPAT_ELF_PLATFORM		("v8b")
+#define COMPAT_ELF_PLATFORM		(is_ilp32_compat_task() ? "aarch64_be:ilp32" : "v8b")
 #else
-#define COMPAT_ELF_PLATFORM		("v8l")
+#define COMPAT_ELF_PLATFORM		(is_ilp32_compat_task() ? "aarch64:ilp32" : "v8l")
 #endif
 
 #define COMPAT_ELF_ET_DYN_BASE		(2 * TASK_SIZE_32 / 3)
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [PATCH v5 22/23] aarch64: ilp32: msgrcv, msgsnd handlers
  2015-09-29 22:13 ` Yury Norov
@ 2015-09-29 22:14   ` Yury Norov
  -1 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-09-29 22:14 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel, catalin.marinas, arnd, agraf,
	bamvor.zhangjian
  Cc: yury.norov, philipp.tomsich, apinski, christoph.muellner,
	klimov.linux, Yury Norov

msgsnd and msgrcv syscall arguments are different in
lp64 and ilp32 ABIs. In this patch, ilp32-specific
handlers introduced to take it into account.

Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>

diff --git a/arch/arm64/kernel/sys_ilp32.c b/arch/arm64/kernel/sys_ilp32.c
index 623191a..09605be 100644
--- a/arch/arm64/kernel/sys_ilp32.c
+++ b/arch/arm64/kernel/sys_ilp32.c
@@ -21,6 +21,7 @@
 #include <linux/errno.h>
 #include <linux/fs.h>
 #include <linux/mm.h>
+#include <linux/msg.h>
 #include <linux/export.h>
 #include <linux/sched.h>
 #include <linux/slab.h>
@@ -158,6 +159,50 @@ long ilp32_sys_sigaltstack(const stack_t __user *uss_ptr,
    for stack_t might not be non-zero. */
 #define sys_sigaltstack		ilp32_sys_sigaltstack
 
+struct ilp32_msgbuf {
+	s32 mtype;	/* type of message */
+	char mtext[1];	/* message text */
+};
+
+long ilp32_sys_msgsnd(s32 msqid, struct ilp32_msgbuf __user *msgp, s32 msgsz, s32 msgflg)
+{
+	long mtype;
+
+	if (msgsz < 0)
+		return -EINVAL;
+
+	if (get_user(mtype, &msgp->mtype))
+		return -EFAULT;
+	return do_msgsnd(msqid, mtype, msgp->mtext, msgsz, msgflg);
+}
+
+#define sys_msgsnd		ilp32_sys_msgsnd
+
+extern int store_msg(void __user *dest, struct msg_msg *msg, size_t len);
+static long ilp32_do_msg_fill(void __user *dest, struct msg_msg *msg, size_t bufsz)
+{
+	struct ilp32_msgbuf __user *msgp = dest;
+	size_t msgsz;
+
+	if (put_user(msg->m_type, &msgp->mtype))
+		return -EFAULT;
+
+	msgsz = (bufsz > msg->m_ts) ? msg->m_ts : bufsz;
+	if (store_msg(msgp->mtext, msg, msgsz))
+		return -EFAULT;
+	return msgsz;
+}
+
+long ilp32_sys_msgrcv(s32 msqid, struct ilp32_msgbuf __user *msgp, s32 msgsz,
+		s32 msgtyp, s32 msgflg)
+{
+	if (msgsz < 0)
+		return -EINVAL;
+
+	return do_msgrcv(msqid, msgp, msgsz, msgtyp, msgflg, ilp32_do_msg_fill);
+}
+
+#define sys_msgrcv		ilp32_sys_msgrcv
 
 #include <asm/syscall.h>
 
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [PATCH v5 22/23] aarch64: ilp32: msgrcv, msgsnd handlers
@ 2015-09-29 22:14   ` Yury Norov
  0 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-09-29 22:14 UTC (permalink / raw)
  To: linux-arm-kernel

msgsnd and msgrcv syscall arguments are different in
lp64 and ilp32 ABIs. In this patch, ilp32-specific
handlers introduced to take it into account.

Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>

diff --git a/arch/arm64/kernel/sys_ilp32.c b/arch/arm64/kernel/sys_ilp32.c
index 623191a..09605be 100644
--- a/arch/arm64/kernel/sys_ilp32.c
+++ b/arch/arm64/kernel/sys_ilp32.c
@@ -21,6 +21,7 @@
 #include <linux/errno.h>
 #include <linux/fs.h>
 #include <linux/mm.h>
+#include <linux/msg.h>
 #include <linux/export.h>
 #include <linux/sched.h>
 #include <linux/slab.h>
@@ -158,6 +159,50 @@ long ilp32_sys_sigaltstack(const stack_t __user *uss_ptr,
    for stack_t might not be non-zero. */
 #define sys_sigaltstack		ilp32_sys_sigaltstack
 
+struct ilp32_msgbuf {
+	s32 mtype;	/* type of message */
+	char mtext[1];	/* message text */
+};
+
+long ilp32_sys_msgsnd(s32 msqid, struct ilp32_msgbuf __user *msgp, s32 msgsz, s32 msgflg)
+{
+	long mtype;
+
+	if (msgsz < 0)
+		return -EINVAL;
+
+	if (get_user(mtype, &msgp->mtype))
+		return -EFAULT;
+	return do_msgsnd(msqid, mtype, msgp->mtext, msgsz, msgflg);
+}
+
+#define sys_msgsnd		ilp32_sys_msgsnd
+
+extern int store_msg(void __user *dest, struct msg_msg *msg, size_t len);
+static long ilp32_do_msg_fill(void __user *dest, struct msg_msg *msg, size_t bufsz)
+{
+	struct ilp32_msgbuf __user *msgp = dest;
+	size_t msgsz;
+
+	if (put_user(msg->m_type, &msgp->mtype))
+		return -EFAULT;
+
+	msgsz = (bufsz > msg->m_ts) ? msg->m_ts : bufsz;
+	if (store_msg(msgp->mtext, msg, msgsz))
+		return -EFAULT;
+	return msgsz;
+}
+
+long ilp32_sys_msgrcv(s32 msqid, struct ilp32_msgbuf __user *msgp, s32 msgsz,
+		s32 msgtyp, s32 msgflg)
+{
+	if (msgsz < 0)
+		return -EINVAL;
+
+	return do_msgrcv(msqid, msgp, msgsz, msgtyp, msgflg, ilp32_do_msg_fill);
+}
+
+#define sys_msgrcv		ilp32_sys_msgrcv
 
 #include <asm/syscall.h>
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [PATCH v5 23/23] arm64:ilp32: add ARM64_ILP32 to Kconfig
  2015-09-29 22:13 ` Yury Norov
@ 2015-09-29 22:14   ` Yury Norov
  -1 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-09-29 22:14 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel, catalin.marinas, arnd, agraf,
	bamvor.zhangjian
  Cc: yury.norov, philipp.tomsich, apinski, christoph.muellner,
	klimov.linux, Yury Norov

From: Andrew Pinski <apinski@cavium.com>

This patch adds the config option for ILP32.

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index d1dc605..afbde9c 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -680,7 +680,7 @@ source "fs/Kconfig.binfmt"
 
 config COMPAT
 	def_bool y
-	depends on AARCH32_EL0
+	depends on AARCH32_EL0 || ARM64_ILP32
 	select COMPAT_BINFMT_ELF
 
 config AARCH32_EL0
@@ -702,6 +702,13 @@ config AARCH32_EL0
 
 	  If you want to execute 32-bit userspace applications, say Y.
 
+config ARM64_ILP32
+	bool "Kernel support for ILP32"
+	help
+	  This option enables support for AArch64 ILP32 user space.  ILP32
+	  is an ABI where long and pointers are 32bits but it uses the AARCH64
+	  instruction set.
+
 config SYSVIPC_COMPAT
 	def_bool y
 	depends on AARCH32_EL0 && SYSVIPC
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [PATCH v5 23/23] arm64:ilp32: add ARM64_ILP32 to Kconfig
@ 2015-09-29 22:14   ` Yury Norov
  0 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-09-29 22:14 UTC (permalink / raw)
  To: linux-arm-kernel

From: Andrew Pinski <apinski@cavium.com>

This patch adds the config option for ILP32.

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index d1dc605..afbde9c 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -680,7 +680,7 @@ source "fs/Kconfig.binfmt"
 
 config COMPAT
 	def_bool y
-	depends on AARCH32_EL0
+	depends on AARCH32_EL0 || ARM64_ILP32
 	select COMPAT_BINFMT_ELF
 
 config AARCH32_EL0
@@ -702,6 +702,13 @@ config AARCH32_EL0
 
 	  If you want to execute 32-bit userspace applications, say Y.
 
+config ARM64_ILP32
+	bool "Kernel support for ILP32"
+	help
+	  This option enables support for AArch64 ILP32 user space.  ILP32
+	  is an ABI where long and pointers are 32bits but it uses the AARCH64
+	  instruction set.
+
 config SYSVIPC_COMPAT
 	def_bool y
 	depends on AARCH32_EL0 && SYSVIPC
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 96+ messages in thread

* Re: [PATCH v5 04/23] arm64: change some CONFIG_COMPAT over to use CONFIG_AARCH32_EL0 instead
  2015-09-29 22:14   ` Yury Norov
@ 2015-09-30  3:36     ` kbuild test robot
  -1 siblings, 0 replies; 96+ messages in thread
From: kbuild test robot @ 2015-09-30  3:36 UTC (permalink / raw)
  To: Yury Norov
  Cc: kbuild-all, linux-arm-kernel, linux-kernel, catalin.marinas,
	arnd, agraf, bamvor.zhangjian, yury.norov, philipp.tomsich,
	apinski, christoph.muellner, klimov.linux, Yury Norov

[-- Attachment #1: Type: text/plain, Size: 2308 bytes --]

Hi Andrew,

[auto build test results on v4.3-rc3 -- if it's inappropriate base, please ignore]

config: arm64-allnoconfig (attached as .config)
reproduce:
  wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
  chmod +x ~/bin/make.cross
  git checkout 4035143523cbf0106ee81f3ea585b363110c1ab6
  # save the attached .config to linux build tree
  make.cross ARCH=arm64 

All error/warnings (new ones prefixed by >>):

>> arch/arm64/kernel/ptrace.c:1190:56: error: unknown type name 'compat_long_t'
    long compat_a32_arch_ptrace(struct task_struct *child, compat_long_t request,
                                                           ^
>> arch/arm64/kernel/ptrace.c:1191:8: error: unknown type name 'compat_ulong_t'
           compat_ulong_t caddr, compat_ulong_t cdata)
           ^
   arch/arm64/kernel/ptrace.c:1191:30: error: unknown type name 'compat_ulong_t'
           compat_ulong_t caddr, compat_ulong_t cdata)
                                 ^
--
   arch/arm64/kernel/signal.c: In function 'setup_restart_syscall':
>> arch/arm64/kernel/signal.c:280:3: error: implicit declaration of function 'compat_setup_restart_syscall' [-Werror=implicit-function-declaration]
      compat_setup_restart_syscall(regs);
      ^
   arch/arm64/kernel/signal.c: In function 'handle_signal':
>> arch/arm64/kernel/signal.c:300:4: error: implicit declaration of function 'compat_setup_rt_frame' [-Werror=implicit-function-declaration]
       ret = compat_setup_rt_frame(usig, ksig, oldset, regs);
       ^
>> arch/arm64/kernel/signal.c:302:4: error: implicit declaration of function 'compat_setup_frame' [-Werror=implicit-function-declaration]
       ret = compat_setup_frame(usig, ksig, oldset, regs);
       ^
   cc1: some warnings being treated as errors

vim +/compat_long_t +1190 arch/arm64/kernel/ptrace.c

  1184				break;
  1185		}
  1186	
  1187		return ret;
  1188	}
  1189	#else /* !CONFIG_AARCH32_EL0 */
> 1190	long compat_a32_arch_ptrace(struct task_struct *child, compat_long_t request,
> 1191				    compat_ulong_t caddr, compat_ulong_t cdata)
  1192	{
  1193		return -1;
  1194	}

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 5480 bytes --]

^ permalink raw reply	[flat|nested] 96+ messages in thread

* [PATCH v5 04/23] arm64: change some CONFIG_COMPAT over to use CONFIG_AARCH32_EL0 instead
@ 2015-09-30  3:36     ` kbuild test robot
  0 siblings, 0 replies; 96+ messages in thread
From: kbuild test robot @ 2015-09-30  3:36 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Andrew,

[auto build test results on v4.3-rc3 -- if it's inappropriate base, please ignore]

config: arm64-allnoconfig (attached as .config)
reproduce:
  wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
  chmod +x ~/bin/make.cross
  git checkout 4035143523cbf0106ee81f3ea585b363110c1ab6
  # save the attached .config to linux build tree
  make.cross ARCH=arm64 

All error/warnings (new ones prefixed by >>):

>> arch/arm64/kernel/ptrace.c:1190:56: error: unknown type name 'compat_long_t'
    long compat_a32_arch_ptrace(struct task_struct *child, compat_long_t request,
                                                           ^
>> arch/arm64/kernel/ptrace.c:1191:8: error: unknown type name 'compat_ulong_t'
           compat_ulong_t caddr, compat_ulong_t cdata)
           ^
   arch/arm64/kernel/ptrace.c:1191:30: error: unknown type name 'compat_ulong_t'
           compat_ulong_t caddr, compat_ulong_t cdata)
                                 ^
--
   arch/arm64/kernel/signal.c: In function 'setup_restart_syscall':
>> arch/arm64/kernel/signal.c:280:3: error: implicit declaration of function 'compat_setup_restart_syscall' [-Werror=implicit-function-declaration]
      compat_setup_restart_syscall(regs);
      ^
   arch/arm64/kernel/signal.c: In function 'handle_signal':
>> arch/arm64/kernel/signal.c:300:4: error: implicit declaration of function 'compat_setup_rt_frame' [-Werror=implicit-function-declaration]
       ret = compat_setup_rt_frame(usig, ksig, oldset, regs);
       ^
>> arch/arm64/kernel/signal.c:302:4: error: implicit declaration of function 'compat_setup_frame' [-Werror=implicit-function-declaration]
       ret = compat_setup_frame(usig, ksig, oldset, regs);
       ^
   cc1: some warnings being treated as errors

vim +/compat_long_t +1190 arch/arm64/kernel/ptrace.c

  1184				break;
  1185		}
  1186	
  1187		return ret;
  1188	}
  1189	#else /* !CONFIG_AARCH32_EL0 */
> 1190	long compat_a32_arch_ptrace(struct task_struct *child, compat_long_t request,
> 1191				    compat_ulong_t caddr, compat_ulong_t cdata)
  1192	{
  1193		return -1;
  1194	}

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/octet-stream
Size: 5480 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150930/cc7d2551/attachment.obj>

^ permalink raw reply	[flat|nested] 96+ messages in thread

* Re: [PATCH v5 10/23] arm64: introduce is_a32_task and is_a32_thread (for AArch32 compat)
  2015-09-29 22:14   ` Yury Norov
@ 2015-09-30  3:48     ` kbuild test robot
  -1 siblings, 0 replies; 96+ messages in thread
From: kbuild test robot @ 2015-09-30  3:48 UTC (permalink / raw)
  To: Yury Norov
  Cc: kbuild-all, linux-arm-kernel, linux-kernel, catalin.marinas,
	arnd, agraf, bamvor.zhangjian, yury.norov, philipp.tomsich,
	apinski, christoph.muellner, klimov.linux, Yury Norov

[-- Attachment #1: Type: text/plain, Size: 4761 bytes --]

Hi Andrew,

[auto build test results on v4.3-rc3 -- if it's inappropriate base, please ignore]

config: arm64-allnoconfig (attached as .config)
reproduce:
  wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
  chmod +x ~/bin/make.cross
  git checkout fe86f28ac31c45961e8b7bedb02c1836ddc91860
  # save the attached .config to linux build tree
  make.cross ARCH=arm64 

All error/warnings (new ones prefixed by >>):

   In file included from arch/arm64/kernel/process.c:48:0:
>> arch/arm64/include/asm/compat.h:336:38: error: macro "is_compat_task" passed 1 arguments, but takes just 0
    static inline int is_compat_task(void)
                                         ^
>> arch/arm64/include/asm/compat.h:337:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
    {
    ^
>> arch/arm64/include/asm/compat.h:341:19: error: redefinition of 'is_compat_thread'
    static inline int is_compat_thread(struct thread_info *thread)
                      ^
   arch/arm64/include/asm/compat.h:324:19: note: previous definition of 'is_compat_thread' was here
    static inline int is_compat_thread(struct thread_info *thread)
                      ^
   arch/arm64/include/asm/compat.h: In function 'is_compat_thread':
>> arch/arm64/include/asm/compat.h:343:2: error: implicit declaration of function 'is_a32_compat_thread' [-Werror=implicit-function-declaration]
     return is_a32_compat_thread(thread);
     ^
   cc1: some warnings being treated as errors
--
   In file included from arch/arm64/kernel/ptrace.c:41:0:
>> arch/arm64/include/asm/compat.h:336:38: error: macro "is_compat_task" passed 1 arguments, but takes just 0
    static inline int is_compat_task(void)
                                         ^
>> arch/arm64/include/asm/compat.h:337:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
    {
    ^
>> arch/arm64/include/asm/compat.h:341:19: error: redefinition of 'is_compat_thread'
    static inline int is_compat_thread(struct thread_info *thread)
                      ^
   arch/arm64/include/asm/compat.h:324:19: note: previous definition of 'is_compat_thread' was here
    static inline int is_compat_thread(struct thread_info *thread)
                      ^
   arch/arm64/include/asm/compat.h: In function 'is_compat_thread':
>> arch/arm64/include/asm/compat.h:343:2: error: implicit declaration of function 'is_a32_compat_thread' [-Werror=implicit-function-declaration]
     return is_a32_compat_thread(thread);
     ^
   arch/arm64/kernel/ptrace.c: At top level:
   arch/arm64/kernel/ptrace.c:1190:56: error: unknown type name 'compat_long_t'
    long compat_a32_arch_ptrace(struct task_struct *child, compat_long_t request,
                                                           ^
   arch/arm64/kernel/ptrace.c:1191:8: error: unknown type name 'compat_ulong_t'
           compat_ulong_t caddr, compat_ulong_t cdata)
           ^
   arch/arm64/kernel/ptrace.c:1191:30: error: unknown type name 'compat_ulong_t'
           compat_ulong_t caddr, compat_ulong_t cdata)
                                 ^
   cc1: some warnings being treated as errors
--
   arch/arm64/kernel/signal.c: In function 'setup_restart_syscall':
>> arch/arm64/kernel/signal.c:279:2: error: implicit declaration of function 'is_a32_compat_task' [-Werror=implicit-function-declaration]
     if (is_a32_compat_task())
     ^
   arch/arm64/kernel/signal.c:280:3: error: implicit declaration of function 'compat_setup_restart_syscall' [-Werror=implicit-function-declaration]
      compat_setup_restart_syscall(regs);
      ^
   arch/arm64/kernel/signal.c: In function 'handle_signal':
   arch/arm64/kernel/signal.c:300:4: error: implicit declaration of function 'compat_setup_rt_frame' [-Werror=implicit-function-declaration]
       ret = compat_setup_rt_frame(usig, ksig, oldset, regs);
       ^
   arch/arm64/kernel/signal.c:302:4: error: implicit declaration of function 'compat_setup_frame' [-Werror=implicit-function-declaration]
       ret = compat_setup_frame(usig, ksig, oldset, regs);
       ^
   cc1: some warnings being treated as errors

vim +/is_compat_task +336 arch/arm64/include/asm/compat.h

   330	{
   331		return 0;
   332	}
   333	
   334	#endif /* CONFIG_COMPAT */
   335	
 > 336	static inline int is_compat_task(void)
 > 337	{
   338		return is_a32_compat_task();
   339	}
   340	
 > 341	static inline int is_compat_thread(struct thread_info *thread)
   342	{
 > 343		return is_a32_compat_thread(thread);
   344	}
   345	#endif /* __KERNEL__ */
   346	#endif /* __ASM_COMPAT_H */

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 5480 bytes --]

^ permalink raw reply	[flat|nested] 96+ messages in thread

* [PATCH v5 10/23] arm64: introduce is_a32_task and is_a32_thread (for AArch32 compat)
@ 2015-09-30  3:48     ` kbuild test robot
  0 siblings, 0 replies; 96+ messages in thread
From: kbuild test robot @ 2015-09-30  3:48 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Andrew,

[auto build test results on v4.3-rc3 -- if it's inappropriate base, please ignore]

config: arm64-allnoconfig (attached as .config)
reproduce:
  wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
  chmod +x ~/bin/make.cross
  git checkout fe86f28ac31c45961e8b7bedb02c1836ddc91860
  # save the attached .config to linux build tree
  make.cross ARCH=arm64 

All error/warnings (new ones prefixed by >>):

   In file included from arch/arm64/kernel/process.c:48:0:
>> arch/arm64/include/asm/compat.h:336:38: error: macro "is_compat_task" passed 1 arguments, but takes just 0
    static inline int is_compat_task(void)
                                         ^
>> arch/arm64/include/asm/compat.h:337:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
    {
    ^
>> arch/arm64/include/asm/compat.h:341:19: error: redefinition of 'is_compat_thread'
    static inline int is_compat_thread(struct thread_info *thread)
                      ^
   arch/arm64/include/asm/compat.h:324:19: note: previous definition of 'is_compat_thread' was here
    static inline int is_compat_thread(struct thread_info *thread)
                      ^
   arch/arm64/include/asm/compat.h: In function 'is_compat_thread':
>> arch/arm64/include/asm/compat.h:343:2: error: implicit declaration of function 'is_a32_compat_thread' [-Werror=implicit-function-declaration]
     return is_a32_compat_thread(thread);
     ^
   cc1: some warnings being treated as errors
--
   In file included from arch/arm64/kernel/ptrace.c:41:0:
>> arch/arm64/include/asm/compat.h:336:38: error: macro "is_compat_task" passed 1 arguments, but takes just 0
    static inline int is_compat_task(void)
                                         ^
>> arch/arm64/include/asm/compat.h:337:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
    {
    ^
>> arch/arm64/include/asm/compat.h:341:19: error: redefinition of 'is_compat_thread'
    static inline int is_compat_thread(struct thread_info *thread)
                      ^
   arch/arm64/include/asm/compat.h:324:19: note: previous definition of 'is_compat_thread' was here
    static inline int is_compat_thread(struct thread_info *thread)
                      ^
   arch/arm64/include/asm/compat.h: In function 'is_compat_thread':
>> arch/arm64/include/asm/compat.h:343:2: error: implicit declaration of function 'is_a32_compat_thread' [-Werror=implicit-function-declaration]
     return is_a32_compat_thread(thread);
     ^
   arch/arm64/kernel/ptrace.c: At top level:
   arch/arm64/kernel/ptrace.c:1190:56: error: unknown type name 'compat_long_t'
    long compat_a32_arch_ptrace(struct task_struct *child, compat_long_t request,
                                                           ^
   arch/arm64/kernel/ptrace.c:1191:8: error: unknown type name 'compat_ulong_t'
           compat_ulong_t caddr, compat_ulong_t cdata)
           ^
   arch/arm64/kernel/ptrace.c:1191:30: error: unknown type name 'compat_ulong_t'
           compat_ulong_t caddr, compat_ulong_t cdata)
                                 ^
   cc1: some warnings being treated as errors
--
   arch/arm64/kernel/signal.c: In function 'setup_restart_syscall':
>> arch/arm64/kernel/signal.c:279:2: error: implicit declaration of function 'is_a32_compat_task' [-Werror=implicit-function-declaration]
     if (is_a32_compat_task())
     ^
   arch/arm64/kernel/signal.c:280:3: error: implicit declaration of function 'compat_setup_restart_syscall' [-Werror=implicit-function-declaration]
      compat_setup_restart_syscall(regs);
      ^
   arch/arm64/kernel/signal.c: In function 'handle_signal':
   arch/arm64/kernel/signal.c:300:4: error: implicit declaration of function 'compat_setup_rt_frame' [-Werror=implicit-function-declaration]
       ret = compat_setup_rt_frame(usig, ksig, oldset, regs);
       ^
   arch/arm64/kernel/signal.c:302:4: error: implicit declaration of function 'compat_setup_frame' [-Werror=implicit-function-declaration]
       ret = compat_setup_frame(usig, ksig, oldset, regs);
       ^
   cc1: some warnings being treated as errors

vim +/is_compat_task +336 arch/arm64/include/asm/compat.h

   330	{
   331		return 0;
   332	}
   333	
   334	#endif /* CONFIG_COMPAT */
   335	
 > 336	static inline int is_compat_task(void)
 > 337	{
   338		return is_a32_compat_task();
   339	}
   340	
 > 341	static inline int is_compat_thread(struct thread_info *thread)
   342	{
 > 343		return is_a32_compat_thread(thread);
   344	}
   345	#endif /* __KERNEL__ */
   346	#endif /* __ASM_COMPAT_H */

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/octet-stream
Size: 5480 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150930/706e9e2d/attachment-0001.obj>

^ permalink raw reply	[flat|nested] 96+ messages in thread

* Re: [PATCH v5 17/23] arm64:ilp32: add vdso-ilp32 and use for signal return
  2015-09-29 22:14   ` Yury Norov
@ 2015-09-30  4:06     ` Nathan Lynch
  -1 siblings, 0 replies; 96+ messages in thread
From: Nathan Lynch @ 2015-09-30  4:06 UTC (permalink / raw)
  To: Yury Norov
  Cc: linux-arm-kernel, linux-kernel, catalin.marinas, arnd, agraf,
	bamvor.zhangjian, yury.norov, klimov.linux, apinski,
	philipp.tomsich, christoph.muellner

On 09/29/2015 05:14 PM, Yury Norov wrote:
> From: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
> 
> Adjusted to move the move data page before code pages in sync with
> commit 601255ae3c98fdeeee3a8bb4696425e4f868b4f1

This commit message needs more information about how the ilp32 VDSO uses
the existing arm64 code.  I had to really hunt through the Makefile to
figure out what's going on.

The commit message should also identify the APIs that are supported.
The subject line mentions signal return, but gettimeofday, clock_gettime
and clock_getres are being added here too, and it is not obvious.


> Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
> Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
> Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>
> 
>  create mode 100644 arch/arm64/kernel/vdso-ilp32/.gitignore
>  create mode 100644 arch/arm64/kernel/vdso-ilp32/Makefile
>  copy arch/arm64/{include/asm/vdso.h => kernel/vdso-ilp32/vdso-ilp32.S} (56%)
>  create mode 100644 arch/arm64/kernel/vdso-ilp32/vdso-ilp32.lds.S

How are you invoking git-format-patch?  The copy detection in this case
is not conducive to review.

It looks like the existing arm64 vdso Makefile has been copied to
vdso-ilp32/ and adjusted for paths and naming.  While the gettimeofday
assembly implementation is reused, the build logic is duplicated.  x86
produces VDSOs for multiple ABIs with a single Makefile; is a similar
approach not appropriate for arm64?


> diff --git a/arch/arm64/kernel/vdso-ilp32/vdso-ilp32.lds.S b/arch/arm64/kernel/vdso-ilp32/vdso-ilp32.lds.S
> new file mode 100644
> index 0000000..ac8029b
> --- /dev/null
> +++ b/arch/arm64/kernel/vdso-ilp32/vdso-ilp32.lds.S
> @@ -0,0 +1,98 @@

[...]

> +#include <linux/const.h>
> +#include <asm/page.h>
> +#include <asm/vdso.h>
> +
> +/*OUTPUT_FORMAT("elf32-littleaarch64", "elf32-bigaarch64", "elf32-littleaarch64")
> +OUTPUT_ARCH(aarch64)
> +*/

If these lines aren't needed then omit them.

[...]


> +/*
> + * This controls what symbols we export from the DSO.
> + */
> +VERSION
> +{
> +	LINUX_2.6.39 {
> +	global:
> +		__kernel_rt_sigreturn;
> +		__kernel_gettimeofday;
> +		__kernel_clock_gettime;
> +		__kernel_clock_getres;
> +	local: *;
> +	};
> +}

Something that came up during review of arch/arm's VDSO code: consider
using version and names that match x86, i.e. LINUX_2.6, __vdso_gettimeofday.

http://lists.infradead.org/pipermail/linux-arm-kernel/2014-June/267940.html

Using LINUX_2.6.39 for this code is nonsensical.


> diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c
> index b239b9b..bed6cf1 100644
> --- a/arch/arm64/kernel/vdso.c
> +++ b/arch/arm64/kernel/vdso.c
> @@ -40,6 +40,12 @@ extern char vdso_start, vdso_end;
>  static unsigned long vdso_pages;
>  static struct page **vdso_pagelist;
>  
> +#ifdef CONFIG_ARM64_ILP32
> +extern char vdso_ilp32_start, vdso_ilp32_end;
> +static unsigned long vdso_ilp32_pages;
> +static struct page **vdso_ilp32_pagelist;
> +#endif
> +
>  /*
>   * The vDSO data page.
>   */
> @@ -117,24 +123,29 @@ int aarch32_setup_vectors_page(struct linux_binprm *bprm, int uses_interp)
>  }
>  #endif /* CONFIG_AARCH32_EL0 */
>  
> -static struct vm_special_mapping vdso_spec[2];
> -
> -static int __init vdso_init(void)
> +static inline int __init vdso_init_common(char *vdso_start, char *vdso_end,

No inline please.


> +					  unsigned long *vdso_pagesp,
> +					  struct page ***vdso_pagelistp,
> +					  struct vm_special_mapping* vdso_spec)
>  {

[...]

>  int arch_setup_additional_pages(struct linux_binprm *bprm,
>  				int uses_interp)
>  {
>  	struct mm_struct *mm = current->mm;
>  	unsigned long vdso_base, vdso_text_len, vdso_mapping_len;
> -	void *ret;
> +	void* ret;

Gratuitous (and incorrect) style change.


> +	unsigned long pages = vdso_pages;
> +	struct vm_special_mapping* spec = vdso_spec;

Incorrect style:                  *spec


^ permalink raw reply	[flat|nested] 96+ messages in thread

* [PATCH v5 17/23] arm64:ilp32: add vdso-ilp32 and use for signal return
@ 2015-09-30  4:06     ` Nathan Lynch
  0 siblings, 0 replies; 96+ messages in thread
From: Nathan Lynch @ 2015-09-30  4:06 UTC (permalink / raw)
  To: linux-arm-kernel

On 09/29/2015 05:14 PM, Yury Norov wrote:
> From: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
> 
> Adjusted to move the move data page before code pages in sync with
> commit 601255ae3c98fdeeee3a8bb4696425e4f868b4f1

This commit message needs more information about how the ilp32 VDSO uses
the existing arm64 code.  I had to really hunt through the Makefile to
figure out what's going on.

The commit message should also identify the APIs that are supported.
The subject line mentions signal return, but gettimeofday, clock_gettime
and clock_getres are being added here too, and it is not obvious.


> Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
> Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
> Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>
> 
>  create mode 100644 arch/arm64/kernel/vdso-ilp32/.gitignore
>  create mode 100644 arch/arm64/kernel/vdso-ilp32/Makefile
>  copy arch/arm64/{include/asm/vdso.h => kernel/vdso-ilp32/vdso-ilp32.S} (56%)
>  create mode 100644 arch/arm64/kernel/vdso-ilp32/vdso-ilp32.lds.S

How are you invoking git-format-patch?  The copy detection in this case
is not conducive to review.

It looks like the existing arm64 vdso Makefile has been copied to
vdso-ilp32/ and adjusted for paths and naming.  While the gettimeofday
assembly implementation is reused, the build logic is duplicated.  x86
produces VDSOs for multiple ABIs with a single Makefile; is a similar
approach not appropriate for arm64?


> diff --git a/arch/arm64/kernel/vdso-ilp32/vdso-ilp32.lds.S b/arch/arm64/kernel/vdso-ilp32/vdso-ilp32.lds.S
> new file mode 100644
> index 0000000..ac8029b
> --- /dev/null
> +++ b/arch/arm64/kernel/vdso-ilp32/vdso-ilp32.lds.S
> @@ -0,0 +1,98 @@

[...]

> +#include <linux/const.h>
> +#include <asm/page.h>
> +#include <asm/vdso.h>
> +
> +/*OUTPUT_FORMAT("elf32-littleaarch64", "elf32-bigaarch64", "elf32-littleaarch64")
> +OUTPUT_ARCH(aarch64)
> +*/

If these lines aren't needed then omit them.

[...]


> +/*
> + * This controls what symbols we export from the DSO.
> + */
> +VERSION
> +{
> +	LINUX_2.6.39 {
> +	global:
> +		__kernel_rt_sigreturn;
> +		__kernel_gettimeofday;
> +		__kernel_clock_gettime;
> +		__kernel_clock_getres;
> +	local: *;
> +	};
> +}

Something that came up during review of arch/arm's VDSO code: consider
using version and names that match x86, i.e. LINUX_2.6, __vdso_gettimeofday.

http://lists.infradead.org/pipermail/linux-arm-kernel/2014-June/267940.html

Using LINUX_2.6.39 for this code is nonsensical.


> diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c
> index b239b9b..bed6cf1 100644
> --- a/arch/arm64/kernel/vdso.c
> +++ b/arch/arm64/kernel/vdso.c
> @@ -40,6 +40,12 @@ extern char vdso_start, vdso_end;
>  static unsigned long vdso_pages;
>  static struct page **vdso_pagelist;
>  
> +#ifdef CONFIG_ARM64_ILP32
> +extern char vdso_ilp32_start, vdso_ilp32_end;
> +static unsigned long vdso_ilp32_pages;
> +static struct page **vdso_ilp32_pagelist;
> +#endif
> +
>  /*
>   * The vDSO data page.
>   */
> @@ -117,24 +123,29 @@ int aarch32_setup_vectors_page(struct linux_binprm *bprm, int uses_interp)
>  }
>  #endif /* CONFIG_AARCH32_EL0 */
>  
> -static struct vm_special_mapping vdso_spec[2];
> -
> -static int __init vdso_init(void)
> +static inline int __init vdso_init_common(char *vdso_start, char *vdso_end,

No inline please.


> +					  unsigned long *vdso_pagesp,
> +					  struct page ***vdso_pagelistp,
> +					  struct vm_special_mapping* vdso_spec)
>  {

[...]

>  int arch_setup_additional_pages(struct linux_binprm *bprm,
>  				int uses_interp)
>  {
>  	struct mm_struct *mm = current->mm;
>  	unsigned long vdso_base, vdso_text_len, vdso_mapping_len;
> -	void *ret;
> +	void* ret;

Gratuitous (and incorrect) style change.


> +	unsigned long pages = vdso_pages;
> +	struct vm_special_mapping* spec = vdso_spec;

Incorrect style:                  *spec

^ permalink raw reply	[flat|nested] 96+ messages in thread

* Re: [PATCH v5 04/23] arm64: change some CONFIG_COMPAT over to use CONFIG_AARCH32_EL0 instead
  2015-09-29 22:14   ` Yury Norov
@ 2015-09-30  5:35     ` kbuild test robot
  -1 siblings, 0 replies; 96+ messages in thread
From: kbuild test robot @ 2015-09-30  5:35 UTC (permalink / raw)
  To: Yury Norov
  Cc: kbuild-all, linux-arm-kernel, linux-kernel, catalin.marinas,
	arnd, agraf, bamvor.zhangjian, yury.norov, philipp.tomsich,
	apinski, christoph.muellner, klimov.linux, Yury Norov

[-- Attachment #1: Type: text/plain, Size: 4655 bytes --]

Hi Andrew,

[auto build test results on v4.3-rc3 -- if it's inappropriate base, please ignore]

config: arm64-allmodconfig (attached as .config)
reproduce:
  wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
  chmod +x ~/bin/make.cross
  git checkout 4035143523cbf0106ee81f3ea585b363110c1ab6
  # save the attached .config to linux build tree
  make.cross ARCH=arm64 

Note: the linux-review/Yury-Norov/ILP32-for-ARM64 HEAD 3dd1a64760c74c774056fb5635ff933762dd6453 builds fine.
      It only hurts bisectibility.

All error/warnings (new ones prefixed by >>):

   In file included from include/linux/elf.h:4:0,
                    from include/linux/module.h:15,
                    from fs/ocfs2/dlm/dlmdomain.c:27:
>> arch/arm64/include/asm/elf.h:202:0: warning: "compat_elf_check_arch" redefined
    #define compat_elf_check_arch(x) compat_a32_elf_check_arch(x)
    ^
   arch/arm64/include/asm/elf.h:179:0: note: this is the location of the previous definition
    #define compat_elf_check_arch(x) (((x)->e_machine == EM_ARM) && \
    ^
   In file included from include/linux/elf.h:4:0,
                    from include/linux/module.h:15,
                    from fs/ocfs2/dlm/dlmdomain.c:27:
>> arch/arm64/include/asm/elf.h:202:0: warning: "compat_elf_check_arch" redefined
    #define compat_elf_check_arch(x) compat_a32_elf_check_arch(x)
    ^
   arch/arm64/include/asm/elf.h:179:0: note: this is the location of the previous definition
    #define compat_elf_check_arch(x) (((x)->e_machine == EM_ARM) && \
    ^
--
   In file included from include/linux/elf.h:4:0,
                    from include/linux/module.h:15,
                    from fs/ocfs2/dlm/dlmthread.c:28:
>> arch/arm64/include/asm/elf.h:202:0: warning: "compat_elf_check_arch" redefined
    #define compat_elf_check_arch(x) compat_a32_elf_check_arch(x)
    ^
   arch/arm64/include/asm/elf.h:179:0: note: this is the location of the previous definition
    #define compat_elf_check_arch(x) (((x)->e_machine == EM_ARM) && \
    ^
--
   In file included from include/linux/elf.h:4:0,
                    from arch/arm64/kernel/ptrace.c:39:
>> arch/arm64/include/asm/elf.h:202:0: warning: "compat_elf_check_arch" redefined
    #define compat_elf_check_arch(x) compat_a32_elf_check_arch(x)
    ^
   arch/arm64/include/asm/elf.h:179:0: note: this is the location of the previous definition
    #define compat_elf_check_arch(x) (((x)->e_machine == EM_ARM) && \
    ^
>> arch/arm64/kernel/ptrace.c:880:8: error: 'COMPAT_ELF_NGREG' undeclared here (not in a function)
      .n = COMPAT_ELF_NGREG,
           ^
--
   In file included from include/linux/elf.h:4:0,
                    from include/linux/elfcore-compat.h:4,
                    from fs/compat_binfmt_elf.c:20:
>> arch/arm64/include/asm/elf.h:202:0: warning: "compat_elf_check_arch" redefined
    #define compat_elf_check_arch(x) compat_a32_elf_check_arch(x)
    ^
   arch/arm64/include/asm/elf.h:179:0: note: this is the location of the previous definition
    #define compat_elf_check_arch(x) (((x)->e_machine == EM_ARM) && \
    ^
   In file included from fs/compat_binfmt_elf.c:145:0:
   fs/binfmt_elf.c: In function 'load_elf_interp':
>> fs/binfmt_elf.c:533:2: error: implicit declaration of function 'compat_a32_elf_check_arch' [-Werror=implicit-function-declaration]
     if (!elf_check_arch(interp_elf_ex))
     ^
   cc1: some warnings being treated as errors

vim +/COMPAT_ELF_NGREG +880 arch/arm64/kernel/ptrace.c

478fcb2c Will Deacon     2012-03-05  874  	.regsets = aarch32_regsets, .n = ARRAY_SIZE(aarch32_regsets)
478fcb2c Will Deacon     2012-03-05  875  };
478fcb2c Will Deacon     2012-03-05  876  
5d220ff9 Catalin Marinas 2015-07-14  877  static const struct user_regset aarch32_ptrace_regsets[] = {
5d220ff9 Catalin Marinas 2015-07-14  878  	[REGSET_GPR] = {
5d220ff9 Catalin Marinas 2015-07-14  879  		.core_note_type = NT_PRSTATUS,
5d220ff9 Catalin Marinas 2015-07-14 @880  		.n = COMPAT_ELF_NGREG,
5d220ff9 Catalin Marinas 2015-07-14  881  		.size = sizeof(compat_elf_greg_t),
5d220ff9 Catalin Marinas 2015-07-14  882  		.align = sizeof(compat_elf_greg_t),
5d220ff9 Catalin Marinas 2015-07-14  883  		.get = compat_gpr_get,

:::::: The code at line 880 was first introduced by commit
:::::: 5d220ff9420f8b1689805ba2d938bedf9e0860a4 arm64: Better native ptrace support for compat tasks

:::::: TO: Catalin Marinas <catalin.marinas@arm.com>
:::::: CC: Will Deacon <will.deacon@arm.com>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 45533 bytes --]

^ permalink raw reply	[flat|nested] 96+ messages in thread

* [PATCH v5 04/23] arm64: change some CONFIG_COMPAT over to use CONFIG_AARCH32_EL0 instead
@ 2015-09-30  5:35     ` kbuild test robot
  0 siblings, 0 replies; 96+ messages in thread
From: kbuild test robot @ 2015-09-30  5:35 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Andrew,

[auto build test results on v4.3-rc3 -- if it's inappropriate base, please ignore]

config: arm64-allmodconfig (attached as .config)
reproduce:
  wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
  chmod +x ~/bin/make.cross
  git checkout 4035143523cbf0106ee81f3ea585b363110c1ab6
  # save the attached .config to linux build tree
  make.cross ARCH=arm64 

Note: the linux-review/Yury-Norov/ILP32-for-ARM64 HEAD 3dd1a64760c74c774056fb5635ff933762dd6453 builds fine.
      It only hurts bisectibility.

All error/warnings (new ones prefixed by >>):

   In file included from include/linux/elf.h:4:0,
                    from include/linux/module.h:15,
                    from fs/ocfs2/dlm/dlmdomain.c:27:
>> arch/arm64/include/asm/elf.h:202:0: warning: "compat_elf_check_arch" redefined
    #define compat_elf_check_arch(x) compat_a32_elf_check_arch(x)
    ^
   arch/arm64/include/asm/elf.h:179:0: note: this is the location of the previous definition
    #define compat_elf_check_arch(x) (((x)->e_machine == EM_ARM) && \
    ^
   In file included from include/linux/elf.h:4:0,
                    from include/linux/module.h:15,
                    from fs/ocfs2/dlm/dlmdomain.c:27:
>> arch/arm64/include/asm/elf.h:202:0: warning: "compat_elf_check_arch" redefined
    #define compat_elf_check_arch(x) compat_a32_elf_check_arch(x)
    ^
   arch/arm64/include/asm/elf.h:179:0: note: this is the location of the previous definition
    #define compat_elf_check_arch(x) (((x)->e_machine == EM_ARM) && \
    ^
--
   In file included from include/linux/elf.h:4:0,
                    from include/linux/module.h:15,
                    from fs/ocfs2/dlm/dlmthread.c:28:
>> arch/arm64/include/asm/elf.h:202:0: warning: "compat_elf_check_arch" redefined
    #define compat_elf_check_arch(x) compat_a32_elf_check_arch(x)
    ^
   arch/arm64/include/asm/elf.h:179:0: note: this is the location of the previous definition
    #define compat_elf_check_arch(x) (((x)->e_machine == EM_ARM) && \
    ^
--
   In file included from include/linux/elf.h:4:0,
                    from arch/arm64/kernel/ptrace.c:39:
>> arch/arm64/include/asm/elf.h:202:0: warning: "compat_elf_check_arch" redefined
    #define compat_elf_check_arch(x) compat_a32_elf_check_arch(x)
    ^
   arch/arm64/include/asm/elf.h:179:0: note: this is the location of the previous definition
    #define compat_elf_check_arch(x) (((x)->e_machine == EM_ARM) && \
    ^
>> arch/arm64/kernel/ptrace.c:880:8: error: 'COMPAT_ELF_NGREG' undeclared here (not in a function)
      .n = COMPAT_ELF_NGREG,
           ^
--
   In file included from include/linux/elf.h:4:0,
                    from include/linux/elfcore-compat.h:4,
                    from fs/compat_binfmt_elf.c:20:
>> arch/arm64/include/asm/elf.h:202:0: warning: "compat_elf_check_arch" redefined
    #define compat_elf_check_arch(x) compat_a32_elf_check_arch(x)
    ^
   arch/arm64/include/asm/elf.h:179:0: note: this is the location of the previous definition
    #define compat_elf_check_arch(x) (((x)->e_machine == EM_ARM) && \
    ^
   In file included from fs/compat_binfmt_elf.c:145:0:
   fs/binfmt_elf.c: In function 'load_elf_interp':
>> fs/binfmt_elf.c:533:2: error: implicit declaration of function 'compat_a32_elf_check_arch' [-Werror=implicit-function-declaration]
     if (!elf_check_arch(interp_elf_ex))
     ^
   cc1: some warnings being treated as errors

vim +/COMPAT_ELF_NGREG +880 arch/arm64/kernel/ptrace.c

478fcb2c Will Deacon     2012-03-05  874  	.regsets = aarch32_regsets, .n = ARRAY_SIZE(aarch32_regsets)
478fcb2c Will Deacon     2012-03-05  875  };
478fcb2c Will Deacon     2012-03-05  876  
5d220ff9 Catalin Marinas 2015-07-14  877  static const struct user_regset aarch32_ptrace_regsets[] = {
5d220ff9 Catalin Marinas 2015-07-14  878  	[REGSET_GPR] = {
5d220ff9 Catalin Marinas 2015-07-14  879  		.core_note_type = NT_PRSTATUS,
5d220ff9 Catalin Marinas 2015-07-14 @880  		.n = COMPAT_ELF_NGREG,
5d220ff9 Catalin Marinas 2015-07-14  881  		.size = sizeof(compat_elf_greg_t),
5d220ff9 Catalin Marinas 2015-07-14  882  		.align = sizeof(compat_elf_greg_t),
5d220ff9 Catalin Marinas 2015-07-14  883  		.get = compat_gpr_get,

:::::: The code at line 880 was first introduced by commit
:::::: 5d220ff9420f8b1689805ba2d938bedf9e0860a4 arm64: Better native ptrace support for compat tasks

:::::: TO: Catalin Marinas <catalin.marinas@arm.com>
:::::: CC: Will Deacon <will.deacon@arm.com>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/octet-stream
Size: 45533 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150930/e787fdb2/attachment-0001.obj>

^ permalink raw reply	[flat|nested] 96+ messages in thread

* Re: [PATCH v5 00/23] ILP32 for ARM64
  2015-09-29 22:13 ` Yury Norov
@ 2015-09-30 10:19   ` Catalin Marinas
  -1 siblings, 0 replies; 96+ messages in thread
From: Catalin Marinas @ 2015-09-30 10:19 UTC (permalink / raw)
  To: Yury Norov
  Cc: linux-arm-kernel, linux-kernel, arnd, agraf, bamvor.zhangjian,
	yury.norov, klimov.linux, apinski, philipp.tomsich,
	christoph.muellner

On Wed, Sep 30, 2015 at 01:13:57AM +0300, Yury Norov wrote:
> V5 reincarnation for ILP32.
> 
> This is mostly the same code as Andrew suggested in v3:
> 	https://lkml.org/lkml/2014/9/3/704.
> 
> V4 series and discussion:
> 	https://lkml.org/lkml/2015/4/13/691
> 
> Discussion on v3 and v4 raised questions and some disagreement in community,
> and therefore patches are not accepted till now. In this v5 I tried to avoid any
> changes that are not about obvious fixes, so all interface and implementation
> questions are still here.

This thing comes roughly every 5-6 months, so I don't think it's worth
reviewing it again and forgetting about it until sometime next year. We
also had discussions on the v4 and IIRC we agreed that the ABI should be
closer to AArch32/compat in terms of __kernel_size_t, time_t but with
the canonical set of system calls from the asm-generic/unistd.h.

> In v5:
>  - rebased on top of 4.3.0-rc3;
>  - build fixed if ILP32 enabled without AARCH32;
>  - PATCH v4 22/24 (use compat for stack_t) dropped because it confuses
>    debug tools like gdb and strace;
>  - PATCH v4 20/24 (use compat-syscalls for msgsnd and msgrcv for ILP32)
>    dropped as breaking tests;
>  - PATCH v5 22/23 (msgrcv, msgsnd handlers) introduced for proper 
>    handling of msgrcv, msgsnd;
>  - other minor fixes.

So apart from rebasing, there are no ABI changes. I don't think it's
worth re-discussing the points raised during v4.

> Questions under discussion:
>  - What for ILP32 on ARM64?
> 	See https://lkml.org/lkml/2015/4/13/814
> 	and http://permalink.gmane.org/gmane.comp.lib.uclibc.buildroot/121100
> 	Briefly,
> 	 - for compatibility;
> 	 - for performance;
> 	 - for memory saving.

Does anyone actually need this ABI? And by "need" I don't mean a
tick-box on product fliers but actually someone going to use it on real
systems in the field. Because I'm not keen on maintaining an ABI in the
kernel just as a PR exercise. I have yet to see conclusive benchmarks
that ILP32 is a real win vs LP64 but happy to be proven wrong.

That said, I'm fine with agreeing on an ABI and see whether it takes off
before any merging decisions.

>  - ABI questions: time_t and so on;
> 	I think we are out of choice now. Patches to GCC and Glibc are
> 	upstreamed more than a year ago, and there already might be a code compiled
> 	against existing ABI. At the end, there is no major disagreement, and final
> 	word is after ABI users. And I found no objections from that side.

CORRECTION: patches for gcc have been upstreamed, that's the ELF and PCS
AArch64 ILP32 ABI. The syscall ABI which goes in glibc hasn't been
merged because we did not reach an agreement on the kernel ABI (it would
be rather silly to push something into mainline glibc that's not
officially supported by Linux).

I really don't care if there is compiled code out there using out of
tree patches for glibc and the kernel.

>  - Implementation questions: use ILP32 separated table or not, and others;
> 	Code proposed by Andrew works just fine for more than a year,
> 	and it even shows slightly better performance comparing to LP64:
> 	http://permalink.gmane.org/gmane.comp.lib.uclibc.buildroot/121100
> 	So I see no reason to change something except obvious bugs, if found.

As I said, with patches twice a year, I don't remember the past
discussions. So normally you should start with v4 and address the
comments there. But you seem to have refreshed v3.

Anyway, if by table you mean the syscall table, I think on v4 we agreed
on a separate ILP32 syscall table using the generic syscall numbering
but with some compat syscall pointers where applicable.

-- 
Catalin

^ permalink raw reply	[flat|nested] 96+ messages in thread

* [PATCH v5 00/23] ILP32 for ARM64
@ 2015-09-30 10:19   ` Catalin Marinas
  0 siblings, 0 replies; 96+ messages in thread
From: Catalin Marinas @ 2015-09-30 10:19 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Sep 30, 2015 at 01:13:57AM +0300, Yury Norov wrote:
> V5 reincarnation for ILP32.
> 
> This is mostly the same code as Andrew suggested in v3:
> 	https://lkml.org/lkml/2014/9/3/704.
> 
> V4 series and discussion:
> 	https://lkml.org/lkml/2015/4/13/691
> 
> Discussion on v3 and v4 raised questions and some disagreement in community,
> and therefore patches are not accepted till now. In this v5 I tried to avoid any
> changes that are not about obvious fixes, so all interface and implementation
> questions are still here.

This thing comes roughly every 5-6 months, so I don't think it's worth
reviewing it again and forgetting about it until sometime next year. We
also had discussions on the v4 and IIRC we agreed that the ABI should be
closer to AArch32/compat in terms of __kernel_size_t, time_t but with
the canonical set of system calls from the asm-generic/unistd.h.

> In v5:
>  - rebased on top of 4.3.0-rc3;
>  - build fixed if ILP32 enabled without AARCH32;
>  - PATCH v4 22/24 (use compat for stack_t) dropped because it confuses
>    debug tools like gdb and strace;
>  - PATCH v4 20/24 (use compat-syscalls for msgsnd and msgrcv for ILP32)
>    dropped as breaking tests;
>  - PATCH v5 22/23 (msgrcv, msgsnd handlers) introduced for proper 
>    handling of msgrcv, msgsnd;
>  - other minor fixes.

So apart from rebasing, there are no ABI changes. I don't think it's
worth re-discussing the points raised during v4.

> Questions under discussion:
>  - What for ILP32 on ARM64?
> 	See https://lkml.org/lkml/2015/4/13/814
> 	and http://permalink.gmane.org/gmane.comp.lib.uclibc.buildroot/121100
> 	Briefly,
> 	 - for compatibility;
> 	 - for performance;
> 	 - for memory saving.

Does anyone actually need this ABI? And by "need" I don't mean a
tick-box on product fliers but actually someone going to use it on real
systems in the field. Because I'm not keen on maintaining an ABI in the
kernel just as a PR exercise. I have yet to see conclusive benchmarks
that ILP32 is a real win vs LP64 but happy to be proven wrong.

That said, I'm fine with agreeing on an ABI and see whether it takes off
before any merging decisions.

>  - ABI questions: time_t and so on;
> 	I think we are out of choice now. Patches to GCC and Glibc are
> 	upstreamed more than a year ago, and there already might be a code compiled
> 	against existing ABI. At the end, there is no major disagreement, and final
> 	word is after ABI users. And I found no objections from that side.

CORRECTION: patches for gcc have been upstreamed, that's the ELF and PCS
AArch64 ILP32 ABI. The syscall ABI which goes in glibc hasn't been
merged because we did not reach an agreement on the kernel ABI (it would
be rather silly to push something into mainline glibc that's not
officially supported by Linux).

I really don't care if there is compiled code out there using out of
tree patches for glibc and the kernel.

>  - Implementation questions: use ILP32 separated table or not, and others;
> 	Code proposed by Andrew works just fine for more than a year,
> 	and it even shows slightly better performance comparing to LP64:
> 	http://permalink.gmane.org/gmane.comp.lib.uclibc.buildroot/121100
> 	So I see no reason to change something except obvious bugs, if found.

As I said, with patches twice a year, I don't remember the past
discussions. So normally you should start with v4 and address the
comments there. But you seem to have refreshed v3.

Anyway, if by table you mean the syscall table, I think on v4 we agreed
on a separate ILP32 syscall table using the generic syscall numbering
but with some compat syscall pointers where applicable.

-- 
Catalin

^ permalink raw reply	[flat|nested] 96+ messages in thread

* Re: [PATCH v5 00/23] ILP32 for ARM64
  2015-09-30 10:19   ` Catalin Marinas
@ 2015-09-30 16:41     ` Mark Brown
  -1 siblings, 0 replies; 96+ messages in thread
From: Mark Brown @ 2015-09-30 16:41 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: Yury Norov, arnd, yury.norov, linux-kernel, agraf, klimov.linux,
	bamvor.zhangjian, apinski, philipp.tomsich, linux-arm-kernel,
	christoph.muellner

[-- Attachment #1: Type: text/plain, Size: 1175 bytes --]

On Wed, Sep 30, 2015 at 11:19:19AM +0100, Catalin Marinas wrote:
> On Wed, Sep 30, 2015 at 01:13:57AM +0300, Yury Norov wrote:

> >  - What for ILP32 on ARM64?
> > 	See https://lkml.org/lkml/2015/4/13/814
> > 	and http://permalink.gmane.org/gmane.comp.lib.uclibc.buildroot/121100
> > 	Briefly,
> > 	 - for compatibility;
> > 	 - for performance;
> > 	 - for memory saving.

> Does anyone actually need this ABI? And by "need" I don't mean a
> tick-box on product fliers but actually someone going to use it on real
> systems in the field. Because I'm not keen on maintaining an ABI in the
> kernel just as a PR exercise. I have yet to see conclusive benchmarks
> that ILP32 is a real win vs LP64 but happy to be proven wrong.

Indeed.  On that subject there was some discussion at Linaro Connect
last week about work (being done outside Linaro, not sure how public it
is at this point) to pull together the current state of the art into a
Docker container image which people can use for benchmarking and as a
reference for how to pull things together.  That should help with the
analysis, it'll at least make it easier for other people to reproduce
any benchmarking results.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 96+ messages in thread

* [PATCH v5 00/23] ILP32 for ARM64
@ 2015-09-30 16:41     ` Mark Brown
  0 siblings, 0 replies; 96+ messages in thread
From: Mark Brown @ 2015-09-30 16:41 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Sep 30, 2015 at 11:19:19AM +0100, Catalin Marinas wrote:
> On Wed, Sep 30, 2015 at 01:13:57AM +0300, Yury Norov wrote:

> >  - What for ILP32 on ARM64?
> > 	See https://lkml.org/lkml/2015/4/13/814
> > 	and http://permalink.gmane.org/gmane.comp.lib.uclibc.buildroot/121100
> > 	Briefly,
> > 	 - for compatibility;
> > 	 - for performance;
> > 	 - for memory saving.

> Does anyone actually need this ABI? And by "need" I don't mean a
> tick-box on product fliers but actually someone going to use it on real
> systems in the field. Because I'm not keen on maintaining an ABI in the
> kernel just as a PR exercise. I have yet to see conclusive benchmarks
> that ILP32 is a real win vs LP64 but happy to be proven wrong.

Indeed.  On that subject there was some discussion at Linaro Connect
last week about work (being done outside Linaro, not sure how public it
is at this point) to pull together the current state of the art into a
Docker container image which people can use for benchmarking and as a
reference for how to pull things together.  That should help with the
analysis, it'll at least make it easier for other people to reproduce
any benchmarking results.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150930/4a1d93cd/attachment.sig>

^ permalink raw reply	[flat|nested] 96+ messages in thread

* Re: [PATCH v5 00/23] ILP32 for ARM64
  2015-09-30 16:41     ` Mark Brown
@ 2015-10-01 11:19       ` Catalin Marinas
  -1 siblings, 0 replies; 96+ messages in thread
From: Catalin Marinas @ 2015-10-01 11:19 UTC (permalink / raw)
  To: Mark Brown
  Cc: arnd, yury.norov, agraf, linux-kernel, klimov.linux, Yury Norov,
	bamvor.zhangjian, apinski, philipp.tomsich, linux-arm-kernel,
	christoph.muellner

On Wed, Sep 30, 2015 at 05:41:03PM +0100, Mark Brown wrote:
> On Wed, Sep 30, 2015 at 11:19:19AM +0100, Catalin Marinas wrote:
> > On Wed, Sep 30, 2015 at 01:13:57AM +0300, Yury Norov wrote:
> 
> > >  - What for ILP32 on ARM64?
> > > 	See https://lkml.org/lkml/2015/4/13/814
> > > 	and http://permalink.gmane.org/gmane.comp.lib.uclibc.buildroot/121100
> > > 	Briefly,
> > > 	 - for compatibility;
> > > 	 - for performance;
> > > 	 - for memory saving.
> 
> > Does anyone actually need this ABI? And by "need" I don't mean a
> > tick-box on product fliers but actually someone going to use it on real
> > systems in the field. Because I'm not keen on maintaining an ABI in the
> > kernel just as a PR exercise. I have yet to see conclusive benchmarks
> > that ILP32 is a real win vs LP64 but happy to be proven wrong.
> 
> Indeed.  On that subject there was some discussion at Linaro Connect
> last week about work (being done outside Linaro, not sure how public it
> is at this point) to pull together the current state of the art into a
> Docker container image which people can use for benchmarking and as a
> reference for how to pull things together.  That should help with the
> analysis, it'll at least make it easier for other people to reproduce
> any benchmarking results.

That's fine and I would welcome it. However, I'm definitely against
using non-agreed ABI and further spreading such toolchains (or kernel
patches; Linaro's tracking kernel has kept these patches for a long
time, even though the ABI has been NAK'ed).

-- 
Catalin

^ permalink raw reply	[flat|nested] 96+ messages in thread

* [PATCH v5 00/23] ILP32 for ARM64
@ 2015-10-01 11:19       ` Catalin Marinas
  0 siblings, 0 replies; 96+ messages in thread
From: Catalin Marinas @ 2015-10-01 11:19 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Sep 30, 2015 at 05:41:03PM +0100, Mark Brown wrote:
> On Wed, Sep 30, 2015 at 11:19:19AM +0100, Catalin Marinas wrote:
> > On Wed, Sep 30, 2015 at 01:13:57AM +0300, Yury Norov wrote:
> 
> > >  - What for ILP32 on ARM64?
> > > 	See https://lkml.org/lkml/2015/4/13/814
> > > 	and http://permalink.gmane.org/gmane.comp.lib.uclibc.buildroot/121100
> > > 	Briefly,
> > > 	 - for compatibility;
> > > 	 - for performance;
> > > 	 - for memory saving.
> 
> > Does anyone actually need this ABI? And by "need" I don't mean a
> > tick-box on product fliers but actually someone going to use it on real
> > systems in the field. Because I'm not keen on maintaining an ABI in the
> > kernel just as a PR exercise. I have yet to see conclusive benchmarks
> > that ILP32 is a real win vs LP64 but happy to be proven wrong.
> 
> Indeed.  On that subject there was some discussion at Linaro Connect
> last week about work (being done outside Linaro, not sure how public it
> is at this point) to pull together the current state of the art into a
> Docker container image which people can use for benchmarking and as a
> reference for how to pull things together.  That should help with the
> analysis, it'll at least make it easier for other people to reproduce
> any benchmarking results.

That's fine and I would welcome it. However, I'm definitely against
using non-agreed ABI and further spreading such toolchains (or kernel
patches; Linaro's tracking kernel has kept these patches for a long
time, even though the ABI has been NAK'ed).

-- 
Catalin

^ permalink raw reply	[flat|nested] 96+ messages in thread

* Re: [PATCH v5 00/23] ILP32 for ARM64
  2015-10-01 11:19       ` Catalin Marinas
@ 2015-10-01 11:36         ` Mark Brown
  -1 siblings, 0 replies; 96+ messages in thread
From: Mark Brown @ 2015-10-01 11:36 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: arnd, yury.norov, agraf, linux-kernel, klimov.linux, Yury Norov,
	bamvor.zhangjian, apinski, philipp.tomsich, linux-arm-kernel,
	christoph.muellner

[-- Attachment #1: Type: text/plain, Size: 1164 bytes --]

On Thu, Oct 01, 2015 at 12:19:31PM +0100, Catalin Marinas wrote:
> On Wed, Sep 30, 2015 at 05:41:03PM +0100, Mark Brown wrote:

> > Indeed.  On that subject there was some discussion at Linaro Connect
> > last week about work (being done outside Linaro, not sure how public it
> > is at this point) to pull together the current state of the art into a
> > Docker container image which people can use for benchmarking and as a
> > reference for how to pull things together.  That should help with the
> > analysis, it'll at least make it easier for other people to reproduce
> > any benchmarking results.

> That's fine and I would welcome it. However, I'm definitely against
> using non-agreed ABI and further spreading such toolchains (or kernel

You might want to speak to some of your colleagues about that...  in any
case I'll reply off list later today with information on the third party
working on this so you can get in touch, like I say I'm not sure how
public that work is at this point.

> patches; Linaro's tracking kernel has kept these patches for a long
> time, even though the ABI has been NAK'ed).

I know, I'm not thrilled about that either.  :/

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 96+ messages in thread

* [PATCH v5 00/23] ILP32 for ARM64
@ 2015-10-01 11:36         ` Mark Brown
  0 siblings, 0 replies; 96+ messages in thread
From: Mark Brown @ 2015-10-01 11:36 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Oct 01, 2015 at 12:19:31PM +0100, Catalin Marinas wrote:
> On Wed, Sep 30, 2015 at 05:41:03PM +0100, Mark Brown wrote:

> > Indeed.  On that subject there was some discussion at Linaro Connect
> > last week about work (being done outside Linaro, not sure how public it
> > is at this point) to pull together the current state of the art into a
> > Docker container image which people can use for benchmarking and as a
> > reference for how to pull things together.  That should help with the
> > analysis, it'll at least make it easier for other people to reproduce
> > any benchmarking results.

> That's fine and I would welcome it. However, I'm definitely against
> using non-agreed ABI and further spreading such toolchains (or kernel

You might want to speak to some of your colleagues about that...  in any
case I'll reply off list later today with information on the third party
working on this so you can get in touch, like I say I'm not sure how
public that work is at this point.

> patches; Linaro's tracking kernel has kept these patches for a long
> time, even though the ABI has been NAK'ed).

I know, I'm not thrilled about that either.  :/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20151001/fc22bf42/attachment.sig>

^ permalink raw reply	[flat|nested] 96+ messages in thread

* Re: [PATCH v5 00/23] ILP32 for ARM64
  2015-10-01 11:36         ` Mark Brown
@ 2015-10-01 16:42           ` Andrey Konovalov
  -1 siblings, 0 replies; 96+ messages in thread
From: Andrey Konovalov @ 2015-10-01 16:42 UTC (permalink / raw)
  To: Mark Brown, Catalin Marinas
  Cc: arnd, yury.norov, linux-kernel, agraf, klimov.linux, Yury Norov,
	bamvor.zhangjian, apinski, philipp.tomsich, linux-arm-kernel,
	christoph.muellner

On 10/01/2015 02:36 PM, Mark Brown wrote:
> On Thu, Oct 01, 2015 at 12:19:31PM +0100, Catalin Marinas wrote:
>> On Wed, Sep 30, 2015 at 05:41:03PM +0100, Mark Brown wrote:
>
>>> Indeed.  On that subject there was some discussion at Linaro Connect
>>> last week about work (being done outside Linaro, not sure how public it
>>> is at this point) to pull together the current state of the art into a
>>> Docker container image which people can use for benchmarking and as a
>>> reference for how to pull things together.  That should help with the
>>> analysis, it'll at least make it easier for other people to reproduce
>>> any benchmarking results.

Using Docker image sounds like a great idea.

>> That's fine and I would welcome it. However, I'm definitely against
>> using non-agreed ABI and further spreading such toolchains (or kernel
>
> You might want to speak to some of your colleagues about that...  in any
> case I'll reply off list later today with information on the third party
> working on this so you can get in touch, like I say I'm not sure how
> public that work is at this point.
>
>> patches; Linaro's tracking kernel has kept these patches for a long
>> time, even though the ABI has been NAK'ed).
>
> I know, I'm not thrilled about that either.  :/

Same for me.
As you have noticed, ILP32 was removed from Linaro's tracking kernel recently.
The thing is that we (builds&baselines team in Linaro) have been requested
to have a CI loop for ILP32. So I'll continue running it, but will use a
separate git branch for ILP32. The linux-linaro branch will not have ILP32
any more (or at least until ILP32 ABI is agreed on).

Thanks,
Andrey

>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>


^ permalink raw reply	[flat|nested] 96+ messages in thread

* [PATCH v5 00/23] ILP32 for ARM64
@ 2015-10-01 16:42           ` Andrey Konovalov
  0 siblings, 0 replies; 96+ messages in thread
From: Andrey Konovalov @ 2015-10-01 16:42 UTC (permalink / raw)
  To: linux-arm-kernel

On 10/01/2015 02:36 PM, Mark Brown wrote:
> On Thu, Oct 01, 2015 at 12:19:31PM +0100, Catalin Marinas wrote:
>> On Wed, Sep 30, 2015 at 05:41:03PM +0100, Mark Brown wrote:
>
>>> Indeed.  On that subject there was some discussion at Linaro Connect
>>> last week about work (being done outside Linaro, not sure how public it
>>> is at this point) to pull together the current state of the art into a
>>> Docker container image which people can use for benchmarking and as a
>>> reference for how to pull things together.  That should help with the
>>> analysis, it'll at least make it easier for other people to reproduce
>>> any benchmarking results.

Using Docker image sounds like a great idea.

>> That's fine and I would welcome it. However, I'm definitely against
>> using non-agreed ABI and further spreading such toolchains (or kernel
>
> You might want to speak to some of your colleagues about that...  in any
> case I'll reply off list later today with information on the third party
> working on this so you can get in touch, like I say I'm not sure how
> public that work is at this point.
>
>> patches; Linaro's tracking kernel has kept these patches for a long
>> time, even though the ABI has been NAK'ed).
>
> I know, I'm not thrilled about that either.  :/

Same for me.
As you have noticed, ILP32 was removed from Linaro's tracking kernel recently.
The thing is that we (builds&baselines team in Linaro) have been requested
to have a CI loop for ILP32. So I'll continue running it, but will use a
separate git branch for ILP32. The linux-linaro branch will not have ILP32
any more (or at least until ILP32 ABI is agreed on).

Thanks,
Andrey

>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>

^ permalink raw reply	[flat|nested] 96+ messages in thread

* Re: [PATCH v5 00/23] ILP32 for ARM64
  2015-09-30 10:19   ` Catalin Marinas
@ 2015-10-01 19:15     ` Yury Norov
  -1 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-10-01 19:15 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: linux-arm-kernel, linux-kernel, arnd, agraf, bamvor.zhangjian,
	yury.norov, klimov.linux, apinski, philipp.tomsich,
	christoph.muellner, Prasun.Kapoor

On Wed, Sep 30, 2015 at 11:19:19AM +0100, Catalin Marinas wrote:
> On Wed, Sep 30, 2015 at 01:13:57AM +0300, Yury Norov wrote:
> > V5 reincarnation for ILP32.
> > 
> > This is mostly the same code as Andrew suggested in v3:
> > 	https://lkml.org/lkml/2014/9/3/704.
> > 
> > V4 series and discussion:
> > 	https://lkml.org/lkml/2015/4/13/691
> > 
> > Discussion on v3 and v4 raised questions and some disagreement in community,
> > and therefore patches are not accepted till now. In this v5 I tried to avoid any
> > changes that are not about obvious fixes, so all interface and implementation
> > questions are still here.
> 
> This thing comes roughly every 5-6 months, so I don't think it's worth
> reviewing it again and forgetting about it until sometime next year. We
> also had discussions on the v4 and IIRC we agreed that the ABI should be
> closer to AArch32/compat in terms of __kernel_size_t, time_t but with
> the canonical set of system calls from the asm-generic/unistd.h.
> 
> > In v5:
> >  - rebased on top of 4.3.0-rc3;
> >  - build fixed if ILP32 enabled without AARCH32;
> >  - PATCH v4 22/24 (use compat for stack_t) dropped because it confuses
> >    debug tools like gdb and strace;
> >  - PATCH v4 20/24 (use compat-syscalls for msgsnd and msgrcv for ILP32)
> >    dropped as breaking tests;
> >  - PATCH v5 22/23 (msgrcv, msgsnd handlers) introduced for proper 
> >    handling of msgrcv, msgsnd;
> >  - other minor fixes.
> 
> So apart from rebasing, there are no ABI changes. I don't think it's
> worth re-discussing the points raised during v4.
> 
> > Questions under discussion:
> >  - What for ILP32 on ARM64?
> > 	See https://lkml.org/lkml/2015/4/13/814
> > 	and http://permalink.gmane.org/gmane.comp.lib.uclibc.buildroot/121100
> > 	Briefly,
> > 	 - for compatibility;
> > 	 - for performance;
> > 	 - for memory saving.
> 
> Does anyone actually need this ABI? And by "need" I don't mean a
> tick-box on product fliers but actually someone going to use it on real
> systems in the field. Because I'm not keen on maintaining an ABI in the
> kernel just as a PR exercise. I have yet to see conclusive benchmarks
> that ILP32 is a real win vs LP64 but happy to be proven wrong.
> 

Adding Prasun Capoor <Prasun.Kapoor@caviumnetworks.com>

I'm not familar with details. I know that ARM32 compatibility is the main
concern now. I think, in long run compatibility doesn't mean much.
The performance does instead. Bamvor Jian Zhang reports 10%
performance gain, and I think noone will miss the chance to became 10%
faster, if speed is a real concern, just after rebuilding the application.

> That said, I'm fine with agreeing on an ABI and see whether it takes off
> before any merging decisions.
> 
> >  - ABI questions: time_t and so on;
> > 	I think we are out of choice now. Patches to GCC and Glibc are
> > 	upstreamed more than a year ago, and there already might be a code compiled
> > 	against existing ABI. At the end, there is no major disagreement, and final
> > 	word is after ABI users. And I found no objections from that side.
> 
> CORRECTION: patches for gcc have been upstreamed, that's the ELF and PCS
> AArch64 ILP32 ABI. The syscall ABI which goes in glibc hasn't been
> merged because we did not reach an agreement on the kernel ABI (it would
> be rather silly to push something into mainline glibc that's not
> officially supported by Linux).
> 
> I really don't care if there is compiled code out there using out of
> tree patches for glibc and the kernel.

You right, they are out of tree. Sorry.

> 
> >  - Implementation questions: use ILP32 separated table or not, and others;
> > 	Code proposed by Andrew works just fine for more than a year,
> > 	and it even shows slightly better performance comparing to LP64:
> > 	http://permalink.gmane.org/gmane.comp.lib.uclibc.buildroot/121100
> > 	So I see no reason to change something except obvious bugs, if found.
> 
> As I said, with patches twice a year, I don't remember the past
> discussions. So normally you should start with v4 and address the
> comments there. But you seem to have refreshed v3.
> 
> Anyway, if by table you mean the syscall table, I think on v4 we agreed
> on a separate ILP32 syscall table using the generic syscall numbering
> but with some compat syscall pointers where applicable.
> 

We already have separated ILP32 syscall table, see patch 19 in this
patchset. This is in fact the option e), suggested by Arnd as best
option for him. https://lkml.org/lkml/2015/4/17/237

Regarding time_t, it, of course, doesn't takes much time to make it
32-bit, but I think 64 bit is better because of Y2038. X32 and mips
n32 has time_t 64-bit (and ppc, not sure), and that's OK for them.
That's OK for BSD as well. The objection may come from users of ABI,
complaining portability problems, but I found no such complains in
public discussions.

Nevertheless, as I told, I do not see any problem to rework time_t.
But some arguments supporting this decision are appreciated.

The downside of 32 bit time_t is that we still face Y2038 problem,
but that's the other story fixing it.

__kernel_long_t is the same. Now it's 64 bits length. Compatibility
may suffer, but, again, there're no complains, and in long run it
looks better.

That's what Andrew says, and I'm gonna to agree:
> There are only a few places where long should be 32bit rather than 64bit.
> The non-time_t field of timespec is the only one I can think of. The rest
> are valid and good idea to stay as 64bit. Including the limits.

BR,
Yury

> -- 
> Catalin

^ permalink raw reply	[flat|nested] 96+ messages in thread

* [PATCH v5 00/23] ILP32 for ARM64
@ 2015-10-01 19:15     ` Yury Norov
  0 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-10-01 19:15 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Sep 30, 2015 at 11:19:19AM +0100, Catalin Marinas wrote:
> On Wed, Sep 30, 2015 at 01:13:57AM +0300, Yury Norov wrote:
> > V5 reincarnation for ILP32.
> > 
> > This is mostly the same code as Andrew suggested in v3:
> > 	https://lkml.org/lkml/2014/9/3/704.
> > 
> > V4 series and discussion:
> > 	https://lkml.org/lkml/2015/4/13/691
> > 
> > Discussion on v3 and v4 raised questions and some disagreement in community,
> > and therefore patches are not accepted till now. In this v5 I tried to avoid any
> > changes that are not about obvious fixes, so all interface and implementation
> > questions are still here.
> 
> This thing comes roughly every 5-6 months, so I don't think it's worth
> reviewing it again and forgetting about it until sometime next year. We
> also had discussions on the v4 and IIRC we agreed that the ABI should be
> closer to AArch32/compat in terms of __kernel_size_t, time_t but with
> the canonical set of system calls from the asm-generic/unistd.h.
> 
> > In v5:
> >  - rebased on top of 4.3.0-rc3;
> >  - build fixed if ILP32 enabled without AARCH32;
> >  - PATCH v4 22/24 (use compat for stack_t) dropped because it confuses
> >    debug tools like gdb and strace;
> >  - PATCH v4 20/24 (use compat-syscalls for msgsnd and msgrcv for ILP32)
> >    dropped as breaking tests;
> >  - PATCH v5 22/23 (msgrcv, msgsnd handlers) introduced for proper 
> >    handling of msgrcv, msgsnd;
> >  - other minor fixes.
> 
> So apart from rebasing, there are no ABI changes. I don't think it's
> worth re-discussing the points raised during v4.
> 
> > Questions under discussion:
> >  - What for ILP32 on ARM64?
> > 	See https://lkml.org/lkml/2015/4/13/814
> > 	and http://permalink.gmane.org/gmane.comp.lib.uclibc.buildroot/121100
> > 	Briefly,
> > 	 - for compatibility;
> > 	 - for performance;
> > 	 - for memory saving.
> 
> Does anyone actually need this ABI? And by "need" I don't mean a
> tick-box on product fliers but actually someone going to use it on real
> systems in the field. Because I'm not keen on maintaining an ABI in the
> kernel just as a PR exercise. I have yet to see conclusive benchmarks
> that ILP32 is a real win vs LP64 but happy to be proven wrong.
> 

Adding Prasun Capoor <Prasun.Kapoor@caviumnetworks.com>

I'm not familar with details. I know that ARM32 compatibility is the main
concern now. I think, in long run compatibility doesn't mean much.
The performance does instead. Bamvor Jian Zhang reports 10%
performance gain, and I think noone will miss the chance to became 10%
faster, if speed is a real concern, just after rebuilding the application.

> That said, I'm fine with agreeing on an ABI and see whether it takes off
> before any merging decisions.
> 
> >  - ABI questions: time_t and so on;
> > 	I think we are out of choice now. Patches to GCC and Glibc are
> > 	upstreamed more than a year ago, and there already might be a code compiled
> > 	against existing ABI. At the end, there is no major disagreement, and final
> > 	word is after ABI users. And I found no objections from that side.
> 
> CORRECTION: patches for gcc have been upstreamed, that's the ELF and PCS
> AArch64 ILP32 ABI. The syscall ABI which goes in glibc hasn't been
> merged because we did not reach an agreement on the kernel ABI (it would
> be rather silly to push something into mainline glibc that's not
> officially supported by Linux).
> 
> I really don't care if there is compiled code out there using out of
> tree patches for glibc and the kernel.

You right, they are out of tree. Sorry.

> 
> >  - Implementation questions: use ILP32 separated table or not, and others;
> > 	Code proposed by Andrew works just fine for more than a year,
> > 	and it even shows slightly better performance comparing to LP64:
> > 	http://permalink.gmane.org/gmane.comp.lib.uclibc.buildroot/121100
> > 	So I see no reason to change something except obvious bugs, if found.
> 
> As I said, with patches twice a year, I don't remember the past
> discussions. So normally you should start with v4 and address the
> comments there. But you seem to have refreshed v3.
> 
> Anyway, if by table you mean the syscall table, I think on v4 we agreed
> on a separate ILP32 syscall table using the generic syscall numbering
> but with some compat syscall pointers where applicable.
> 

We already have separated ILP32 syscall table, see patch 19 in this
patchset. This is in fact the option e), suggested by Arnd as best
option for him. https://lkml.org/lkml/2015/4/17/237

Regarding time_t, it, of course, doesn't takes much time to make it
32-bit, but I think 64 bit is better because of Y2038. X32 and mips
n32 has time_t 64-bit (and ppc, not sure), and that's OK for them.
That's OK for BSD as well. The objection may come from users of ABI,
complaining portability problems, but I found no such complains in
public discussions.

Nevertheless, as I told, I do not see any problem to rework time_t.
But some arguments supporting this decision are appreciated.

The downside of 32 bit time_t is that we still face Y2038 problem,
but that's the other story fixing it.

__kernel_long_t is the same. Now it's 64 bits length. Compatibility
may suffer, but, again, there're no complains, and in long run it
looks better.

That's what Andrew says, and I'm gonna to agree:
> There are only a few places where long should be 32bit rather than 64bit.
> The non-time_t field of timespec is the only one I can think of. The rest
> are valid and good idea to stay as 64bit. Including the limits.

BR,
Yury

> -- 
> Catalin

^ permalink raw reply	[flat|nested] 96+ messages in thread

* Re: [PATCH v5 00/23] ILP32 for ARM64
  2015-09-30 16:41     ` Mark Brown
@ 2015-10-01 19:33       ` Yury Norov
  -1 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-10-01 19:33 UTC (permalink / raw)
  To: Mark Brown
  Cc: Catalin Marinas, arnd, yury.norov, linux-kernel, agraf,
	klimov.linux, bamvor.zhangjian, apinski, philipp.tomsich,
	linux-arm-kernel, christoph.muellner

On Wed, Sep 30, 2015 at 05:41:03PM +0100, Mark Brown wrote:
> On Wed, Sep 30, 2015 at 11:19:19AM +0100, Catalin Marinas wrote:
> > On Wed, Sep 30, 2015 at 01:13:57AM +0300, Yury Norov wrote:
> 
> > >  - What for ILP32 on ARM64?
> > > 	See https://lkml.org/lkml/2015/4/13/814
> > > 	and http://permalink.gmane.org/gmane.comp.lib.uclibc.buildroot/121100
> > > 	Briefly,
> > > 	 - for compatibility;
> > > 	 - for performance;
> > > 	 - for memory saving.
> 
> > Does anyone actually need this ABI? And by "need" I don't mean a
> > tick-box on product fliers but actually someone going to use it on real
> > systems in the field. Because I'm not keen on maintaining an ABI in the
> > kernel just as a PR exercise. I have yet to see conclusive benchmarks
> > that ILP32 is a real win vs LP64 but happy to be proven wrong.
> 
> Indeed.  On that subject there was some discussion at Linaro Connect
> last week about work (being done outside Linaro, not sure how public it
> is at this point) to pull together the current state of the art into a
> Docker container image which people can use for benchmarking and as a
> reference for how to pull things together.  That should help with the
> analysis, it'll at least make it easier for other people to reproduce
> any benchmarking results.

Hi, Mark,

>From you, I got more on what happens with ILP32 than from my company.
Thank you. I know people participated Linaro Connect, and will ask
them for details. And, if possible, will share it here.

BR,
Yury.

^ permalink raw reply	[flat|nested] 96+ messages in thread

* [PATCH v5 00/23] ILP32 for ARM64
@ 2015-10-01 19:33       ` Yury Norov
  0 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-10-01 19:33 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Sep 30, 2015 at 05:41:03PM +0100, Mark Brown wrote:
> On Wed, Sep 30, 2015 at 11:19:19AM +0100, Catalin Marinas wrote:
> > On Wed, Sep 30, 2015 at 01:13:57AM +0300, Yury Norov wrote:
> 
> > >  - What for ILP32 on ARM64?
> > > 	See https://lkml.org/lkml/2015/4/13/814
> > > 	and http://permalink.gmane.org/gmane.comp.lib.uclibc.buildroot/121100
> > > 	Briefly,
> > > 	 - for compatibility;
> > > 	 - for performance;
> > > 	 - for memory saving.
> 
> > Does anyone actually need this ABI? And by "need" I don't mean a
> > tick-box on product fliers but actually someone going to use it on real
> > systems in the field. Because I'm not keen on maintaining an ABI in the
> > kernel just as a PR exercise. I have yet to see conclusive benchmarks
> > that ILP32 is a real win vs LP64 but happy to be proven wrong.
> 
> Indeed.  On that subject there was some discussion at Linaro Connect
> last week about work (being done outside Linaro, not sure how public it
> is at this point) to pull together the current state of the art into a
> Docker container image which people can use for benchmarking and as a
> reference for how to pull things together.  That should help with the
> analysis, it'll at least make it easier for other people to reproduce
> any benchmarking results.

Hi, Mark,

>From you, I got more on what happens with ILP32 than from my company.
Thank you. I know people participated Linaro Connect, and will ask
them for details. And, if possible, will share it here.

BR,
Yury.

^ permalink raw reply	[flat|nested] 96+ messages in thread

* Re: [PATCH v5 17/23] arm64:ilp32: add vdso-ilp32 and use for signal return
  2015-09-30  4:06     ` Nathan Lynch
@ 2015-10-01 19:44       ` Yury Norov
  -1 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-10-01 19:44 UTC (permalink / raw)
  To: Nathan Lynch
  Cc: linux-arm-kernel, linux-kernel, catalin.marinas, arnd, agraf,
	bamvor.zhangjian, yury.norov, klimov.linux, apinski,
	philipp.tomsich, christoph.muellner

On Tue, Sep 29, 2015 at 11:06:13PM -0500, Nathan Lynch wrote:
> On 09/29/2015 05:14 PM, Yury Norov wrote:
> > From: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
> > 
> > Adjusted to move the move data page before code pages in sync with
> > commit 601255ae3c98fdeeee3a8bb4696425e4f868b4f1
> 
> This commit message needs more information about how the ilp32 VDSO uses
> the existing arm64 code.  I had to really hunt through the Makefile to
> figure out what's going on.
> 
> The commit message should also identify the APIs that are supported.
> The subject line mentions signal return, but gettimeofday, clock_gettime
> and clock_getres are being added here too, and it is not obvious.
> 
> 
> > Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
> > Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
> > Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>
> > 
> >  create mode 100644 arch/arm64/kernel/vdso-ilp32/.gitignore
> >  create mode 100644 arch/arm64/kernel/vdso-ilp32/Makefile
> >  copy arch/arm64/{include/asm/vdso.h => kernel/vdso-ilp32/vdso-ilp32.S} (56%)
> >  create mode 100644 arch/arm64/kernel/vdso-ilp32/vdso-ilp32.lds.S
> 
> How are you invoking git-format-patch?  The copy detection in this case
> is not conducive to review.
> 
> It looks like the existing arm64 vdso Makefile has been copied to
> vdso-ilp32/ and adjusted for paths and naming.  While the gettimeofday
> assembly implementation is reused, the build logic is duplicated.  x86
> produces VDSOs for multiple ABIs with a single Makefile; is a similar
> approach not appropriate for arm64?
> 
> 
> > diff --git a/arch/arm64/kernel/vdso-ilp32/vdso-ilp32.lds.S b/arch/arm64/kernel/vdso-ilp32/vdso-ilp32.lds.S
> > new file mode 100644
> > index 0000000..ac8029b
> > --- /dev/null
> > +++ b/arch/arm64/kernel/vdso-ilp32/vdso-ilp32.lds.S
> > @@ -0,0 +1,98 @@
> 
> [...]
> 
> > +#include <linux/const.h>
> > +#include <asm/page.h>
> > +#include <asm/vdso.h>
> > +
> > +/*OUTPUT_FORMAT("elf32-littleaarch64", "elf32-bigaarch64", "elf32-littleaarch64")
> > +OUTPUT_ARCH(aarch64)
> > +*/
> 
> If these lines aren't needed then omit them.
> 
> [...]
> 
> 
> > +/*
> > + * This controls what symbols we export from the DSO.
> > + */
> > +VERSION
> > +{
> > +	LINUX_2.6.39 {
> > +	global:
> > +		__kernel_rt_sigreturn;
> > +		__kernel_gettimeofday;
> > +		__kernel_clock_gettime;
> > +		__kernel_clock_getres;
> > +	local: *;
> > +	};
> > +}
> 
> Something that came up during review of arch/arm's VDSO code: consider
> using version and names that match x86, i.e. LINUX_2.6, __vdso_gettimeofday.
> 
> http://lists.infradead.org/pipermail/linux-arm-kernel/2014-June/267940.html
> 
> Using LINUX_2.6.39 for this code is nonsensical.
> 
> 
> > diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c
> > index b239b9b..bed6cf1 100644
> > --- a/arch/arm64/kernel/vdso.c
> > +++ b/arch/arm64/kernel/vdso.c
> > @@ -40,6 +40,12 @@ extern char vdso_start, vdso_end;
> >  static unsigned long vdso_pages;
> >  static struct page **vdso_pagelist;
> >  
> > +#ifdef CONFIG_ARM64_ILP32
> > +extern char vdso_ilp32_start, vdso_ilp32_end;
> > +static unsigned long vdso_ilp32_pages;
> > +static struct page **vdso_ilp32_pagelist;
> > +#endif
> > +
> >  /*
> >   * The vDSO data page.
> >   */
> > @@ -117,24 +123,29 @@ int aarch32_setup_vectors_page(struct linux_binprm *bprm, int uses_interp)
> >  }
> >  #endif /* CONFIG_AARCH32_EL0 */
> >  
> > -static struct vm_special_mapping vdso_spec[2];
> > -
> > -static int __init vdso_init(void)
> > +static inline int __init vdso_init_common(char *vdso_start, char *vdso_end,
> 
> No inline please.
> 
> 
> > +					  unsigned long *vdso_pagesp,
> > +					  struct page ***vdso_pagelistp,
> > +					  struct vm_special_mapping* vdso_spec)
> >  {
> 
> [...]
> 
> >  int arch_setup_additional_pages(struct linux_binprm *bprm,
> >  				int uses_interp)
> >  {
> >  	struct mm_struct *mm = current->mm;
> >  	unsigned long vdso_base, vdso_text_len, vdso_mapping_len;
> > -	void *ret;
> > +	void* ret;
> 
> Gratuitous (and incorrect) style change.
> 
> 
> > +	unsigned long pages = vdso_pages;
> > +	struct vm_special_mapping* spec = vdso_spec;
> 
> Incorrect style:                  *spec

Hi Nathan,

If Philipp Philipp Tomsich will not answer soon, I'll fix all this.

BR,
Yury.

^ permalink raw reply	[flat|nested] 96+ messages in thread

* [PATCH v5 17/23] arm64:ilp32: add vdso-ilp32 and use for signal return
@ 2015-10-01 19:44       ` Yury Norov
  0 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-10-01 19:44 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Sep 29, 2015 at 11:06:13PM -0500, Nathan Lynch wrote:
> On 09/29/2015 05:14 PM, Yury Norov wrote:
> > From: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
> > 
> > Adjusted to move the move data page before code pages in sync with
> > commit 601255ae3c98fdeeee3a8bb4696425e4f868b4f1
> 
> This commit message needs more information about how the ilp32 VDSO uses
> the existing arm64 code.  I had to really hunt through the Makefile to
> figure out what's going on.
> 
> The commit message should also identify the APIs that are supported.
> The subject line mentions signal return, but gettimeofday, clock_gettime
> and clock_getres are being added here too, and it is not obvious.
> 
> 
> > Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
> > Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
> > Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>
> > 
> >  create mode 100644 arch/arm64/kernel/vdso-ilp32/.gitignore
> >  create mode 100644 arch/arm64/kernel/vdso-ilp32/Makefile
> >  copy arch/arm64/{include/asm/vdso.h => kernel/vdso-ilp32/vdso-ilp32.S} (56%)
> >  create mode 100644 arch/arm64/kernel/vdso-ilp32/vdso-ilp32.lds.S
> 
> How are you invoking git-format-patch?  The copy detection in this case
> is not conducive to review.
> 
> It looks like the existing arm64 vdso Makefile has been copied to
> vdso-ilp32/ and adjusted for paths and naming.  While the gettimeofday
> assembly implementation is reused, the build logic is duplicated.  x86
> produces VDSOs for multiple ABIs with a single Makefile; is a similar
> approach not appropriate for arm64?
> 
> 
> > diff --git a/arch/arm64/kernel/vdso-ilp32/vdso-ilp32.lds.S b/arch/arm64/kernel/vdso-ilp32/vdso-ilp32.lds.S
> > new file mode 100644
> > index 0000000..ac8029b
> > --- /dev/null
> > +++ b/arch/arm64/kernel/vdso-ilp32/vdso-ilp32.lds.S
> > @@ -0,0 +1,98 @@
> 
> [...]
> 
> > +#include <linux/const.h>
> > +#include <asm/page.h>
> > +#include <asm/vdso.h>
> > +
> > +/*OUTPUT_FORMAT("elf32-littleaarch64", "elf32-bigaarch64", "elf32-littleaarch64")
> > +OUTPUT_ARCH(aarch64)
> > +*/
> 
> If these lines aren't needed then omit them.
> 
> [...]
> 
> 
> > +/*
> > + * This controls what symbols we export from the DSO.
> > + */
> > +VERSION
> > +{
> > +	LINUX_2.6.39 {
> > +	global:
> > +		__kernel_rt_sigreturn;
> > +		__kernel_gettimeofday;
> > +		__kernel_clock_gettime;
> > +		__kernel_clock_getres;
> > +	local: *;
> > +	};
> > +}
> 
> Something that came up during review of arch/arm's VDSO code: consider
> using version and names that match x86, i.e. LINUX_2.6, __vdso_gettimeofday.
> 
> http://lists.infradead.org/pipermail/linux-arm-kernel/2014-June/267940.html
> 
> Using LINUX_2.6.39 for this code is nonsensical.
> 
> 
> > diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c
> > index b239b9b..bed6cf1 100644
> > --- a/arch/arm64/kernel/vdso.c
> > +++ b/arch/arm64/kernel/vdso.c
> > @@ -40,6 +40,12 @@ extern char vdso_start, vdso_end;
> >  static unsigned long vdso_pages;
> >  static struct page **vdso_pagelist;
> >  
> > +#ifdef CONFIG_ARM64_ILP32
> > +extern char vdso_ilp32_start, vdso_ilp32_end;
> > +static unsigned long vdso_ilp32_pages;
> > +static struct page **vdso_ilp32_pagelist;
> > +#endif
> > +
> >  /*
> >   * The vDSO data page.
> >   */
> > @@ -117,24 +123,29 @@ int aarch32_setup_vectors_page(struct linux_binprm *bprm, int uses_interp)
> >  }
> >  #endif /* CONFIG_AARCH32_EL0 */
> >  
> > -static struct vm_special_mapping vdso_spec[2];
> > -
> > -static int __init vdso_init(void)
> > +static inline int __init vdso_init_common(char *vdso_start, char *vdso_end,
> 
> No inline please.
> 
> 
> > +					  unsigned long *vdso_pagesp,
> > +					  struct page ***vdso_pagelistp,
> > +					  struct vm_special_mapping* vdso_spec)
> >  {
> 
> [...]
> 
> >  int arch_setup_additional_pages(struct linux_binprm *bprm,
> >  				int uses_interp)
> >  {
> >  	struct mm_struct *mm = current->mm;
> >  	unsigned long vdso_base, vdso_text_len, vdso_mapping_len;
> > -	void *ret;
> > +	void* ret;
> 
> Gratuitous (and incorrect) style change.
> 
> 
> > +	unsigned long pages = vdso_pages;
> > +	struct vm_special_mapping* spec = vdso_spec;
> 
> Incorrect style:                  *spec

Hi Nathan,

If Philipp Philipp Tomsich will not answer soon, I'll fix all this.

BR,
Yury.

^ permalink raw reply	[flat|nested] 96+ messages in thread

* Re: [PATCH v5 17/23] arm64:ilp32: add vdso-ilp32 and use for signal return
  2015-10-01 19:44       ` Yury Norov
@ 2015-10-01 19:54         ` Dr. Philipp Tomsich
  -1 siblings, 0 replies; 96+ messages in thread
From: Dr. Philipp Tomsich @ 2015-10-01 19:54 UTC (permalink / raw)
  To: Yury Norov
  Cc: Nathan Lynch, linux-arm-kernel, linux-kernel, Catalin Marinas,
	Arnd Bergmann, Alexander Graf, bamvor.zhangjian, Yury Norov,
	klimov.linux, Andrew Pinski, christoph.muellner

Yury,

this patch has been based on an earlier version of vdso and mainly adjusted to match
the requirements of commit 601255ae3c98fdeeee3a8bb4696425e4f868b4f1.

As these are mainly style-changes, please feel free to revise and adjust as needed.

Regards,
Philipp.

> On 01 Oct 2015, at 21:44, Yury Norov <ynorov@caviumnetworks.com> wrote:
> 
> On Tue, Sep 29, 2015 at 11:06:13PM -0500, Nathan Lynch wrote:
>> On 09/29/2015 05:14 PM, Yury Norov wrote:
>>> From: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
>>> 
>>> Adjusted to move the move data page before code pages in sync with
>>> commit 601255ae3c98fdeeee3a8bb4696425e4f868b4f1
>> 
>> This commit message needs more information about how the ilp32 VDSO uses
>> the existing arm64 code.  I had to really hunt through the Makefile to
>> figure out what's going on.
>> 
>> The commit message should also identify the APIs that are supported.
>> The subject line mentions signal return, but gettimeofday, clock_gettime
>> and clock_getres are being added here too, and it is not obvious.
>> 
>> 
>>> Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
>>> Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
>>> Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>
>>> 
>>> create mode 100644 arch/arm64/kernel/vdso-ilp32/.gitignore
>>> create mode 100644 arch/arm64/kernel/vdso-ilp32/Makefile
>>> copy arch/arm64/{include/asm/vdso.h => kernel/vdso-ilp32/vdso-ilp32.S} (56%)
>>> create mode 100644 arch/arm64/kernel/vdso-ilp32/vdso-ilp32.lds.S
>> 
>> How are you invoking git-format-patch?  The copy detection in this case
>> is not conducive to review.
>> 
>> It looks like the existing arm64 vdso Makefile has been copied to
>> vdso-ilp32/ and adjusted for paths and naming.  While the gettimeofday
>> assembly implementation is reused, the build logic is duplicated.  x86
>> produces VDSOs for multiple ABIs with a single Makefile; is a similar
>> approach not appropriate for arm64?
>> 
>> 
>>> diff --git a/arch/arm64/kernel/vdso-ilp32/vdso-ilp32.lds.S b/arch/arm64/kernel/vdso-ilp32/vdso-ilp32.lds.S
>>> new file mode 100644
>>> index 0000000..ac8029b
>>> --- /dev/null
>>> +++ b/arch/arm64/kernel/vdso-ilp32/vdso-ilp32.lds.S
>>> @@ -0,0 +1,98 @@
>> 
>> [...]
>> 
>>> +#include <linux/const.h>
>>> +#include <asm/page.h>
>>> +#include <asm/vdso.h>
>>> +
>>> +/*OUTPUT_FORMAT("elf32-littleaarch64", "elf32-bigaarch64", "elf32-littleaarch64")
>>> +OUTPUT_ARCH(aarch64)
>>> +*/
>> 
>> If these lines aren't needed then omit them.
>> 
>> [...]
>> 
>> 
>>> +/*
>>> + * This controls what symbols we export from the DSO.
>>> + */
>>> +VERSION
>>> +{
>>> +	LINUX_2.6.39 {
>>> +	global:
>>> +		__kernel_rt_sigreturn;
>>> +		__kernel_gettimeofday;
>>> +		__kernel_clock_gettime;
>>> +		__kernel_clock_getres;
>>> +	local: *;
>>> +	};
>>> +}
>> 
>> Something that came up during review of arch/arm's VDSO code: consider
>> using version and names that match x86, i.e. LINUX_2.6, __vdso_gettimeofday.
>> 
>> http://lists.infradead.org/pipermail/linux-arm-kernel/2014-June/267940.html
>> 
>> Using LINUX_2.6.39 for this code is nonsensical.
>> 
>> 
>>> diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c
>>> index b239b9b..bed6cf1 100644
>>> --- a/arch/arm64/kernel/vdso.c
>>> +++ b/arch/arm64/kernel/vdso.c
>>> @@ -40,6 +40,12 @@ extern char vdso_start, vdso_end;
>>> static unsigned long vdso_pages;
>>> static struct page **vdso_pagelist;
>>> 
>>> +#ifdef CONFIG_ARM64_ILP32
>>> +extern char vdso_ilp32_start, vdso_ilp32_end;
>>> +static unsigned long vdso_ilp32_pages;
>>> +static struct page **vdso_ilp32_pagelist;
>>> +#endif
>>> +
>>> /*
>>>  * The vDSO data page.
>>>  */
>>> @@ -117,24 +123,29 @@ int aarch32_setup_vectors_page(struct linux_binprm *bprm, int uses_interp)
>>> }
>>> #endif /* CONFIG_AARCH32_EL0 */
>>> 
>>> -static struct vm_special_mapping vdso_spec[2];
>>> -
>>> -static int __init vdso_init(void)
>>> +static inline int __init vdso_init_common(char *vdso_start, char *vdso_end,
>> 
>> No inline please.
>> 
>> 
>>> +					  unsigned long *vdso_pagesp,
>>> +					  struct page ***vdso_pagelistp,
>>> +					  struct vm_special_mapping* vdso_spec)
>>> {
>> 
>> [...]
>> 
>>> int arch_setup_additional_pages(struct linux_binprm *bprm,
>>> 				int uses_interp)
>>> {
>>> 	struct mm_struct *mm = current->mm;
>>> 	unsigned long vdso_base, vdso_text_len, vdso_mapping_len;
>>> -	void *ret;
>>> +	void* ret;
>> 
>> Gratuitous (and incorrect) style change.
>> 
>> 
>>> +	unsigned long pages = vdso_pages;
>>> +	struct vm_special_mapping* spec = vdso_spec;
>> 
>> Incorrect style:                  *spec
> 
> Hi Nathan,
> 
> If Philipp Philipp Tomsich will not answer soon, I'll fix all this.
> 
> BR,
> Yury.


^ permalink raw reply	[flat|nested] 96+ messages in thread

* [PATCH v5 17/23] arm64:ilp32: add vdso-ilp32 and use for signal return
@ 2015-10-01 19:54         ` Dr. Philipp Tomsich
  0 siblings, 0 replies; 96+ messages in thread
From: Dr. Philipp Tomsich @ 2015-10-01 19:54 UTC (permalink / raw)
  To: linux-arm-kernel

Yury,

this patch has been based on an earlier version of vdso and mainly adjusted to match
the requirements of commit 601255ae3c98fdeeee3a8bb4696425e4f868b4f1.

As these are mainly style-changes, please feel free to revise and adjust as needed.

Regards,
Philipp.

> On 01 Oct 2015, at 21:44, Yury Norov <ynorov@caviumnetworks.com> wrote:
> 
> On Tue, Sep 29, 2015 at 11:06:13PM -0500, Nathan Lynch wrote:
>> On 09/29/2015 05:14 PM, Yury Norov wrote:
>>> From: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
>>> 
>>> Adjusted to move the move data page before code pages in sync with
>>> commit 601255ae3c98fdeeee3a8bb4696425e4f868b4f1
>> 
>> This commit message needs more information about how the ilp32 VDSO uses
>> the existing arm64 code.  I had to really hunt through the Makefile to
>> figure out what's going on.
>> 
>> The commit message should also identify the APIs that are supported.
>> The subject line mentions signal return, but gettimeofday, clock_gettime
>> and clock_getres are being added here too, and it is not obvious.
>> 
>> 
>>> Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
>>> Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
>>> Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>
>>> 
>>> create mode 100644 arch/arm64/kernel/vdso-ilp32/.gitignore
>>> create mode 100644 arch/arm64/kernel/vdso-ilp32/Makefile
>>> copy arch/arm64/{include/asm/vdso.h => kernel/vdso-ilp32/vdso-ilp32.S} (56%)
>>> create mode 100644 arch/arm64/kernel/vdso-ilp32/vdso-ilp32.lds.S
>> 
>> How are you invoking git-format-patch?  The copy detection in this case
>> is not conducive to review.
>> 
>> It looks like the existing arm64 vdso Makefile has been copied to
>> vdso-ilp32/ and adjusted for paths and naming.  While the gettimeofday
>> assembly implementation is reused, the build logic is duplicated.  x86
>> produces VDSOs for multiple ABIs with a single Makefile; is a similar
>> approach not appropriate for arm64?
>> 
>> 
>>> diff --git a/arch/arm64/kernel/vdso-ilp32/vdso-ilp32.lds.S b/arch/arm64/kernel/vdso-ilp32/vdso-ilp32.lds.S
>>> new file mode 100644
>>> index 0000000..ac8029b
>>> --- /dev/null
>>> +++ b/arch/arm64/kernel/vdso-ilp32/vdso-ilp32.lds.S
>>> @@ -0,0 +1,98 @@
>> 
>> [...]
>> 
>>> +#include <linux/const.h>
>>> +#include <asm/page.h>
>>> +#include <asm/vdso.h>
>>> +
>>> +/*OUTPUT_FORMAT("elf32-littleaarch64", "elf32-bigaarch64", "elf32-littleaarch64")
>>> +OUTPUT_ARCH(aarch64)
>>> +*/
>> 
>> If these lines aren't needed then omit them.
>> 
>> [...]
>> 
>> 
>>> +/*
>>> + * This controls what symbols we export from the DSO.
>>> + */
>>> +VERSION
>>> +{
>>> +	LINUX_2.6.39 {
>>> +	global:
>>> +		__kernel_rt_sigreturn;
>>> +		__kernel_gettimeofday;
>>> +		__kernel_clock_gettime;
>>> +		__kernel_clock_getres;
>>> +	local: *;
>>> +	};
>>> +}
>> 
>> Something that came up during review of arch/arm's VDSO code: consider
>> using version and names that match x86, i.e. LINUX_2.6, __vdso_gettimeofday.
>> 
>> http://lists.infradead.org/pipermail/linux-arm-kernel/2014-June/267940.html
>> 
>> Using LINUX_2.6.39 for this code is nonsensical.
>> 
>> 
>>> diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c
>>> index b239b9b..bed6cf1 100644
>>> --- a/arch/arm64/kernel/vdso.c
>>> +++ b/arch/arm64/kernel/vdso.c
>>> @@ -40,6 +40,12 @@ extern char vdso_start, vdso_end;
>>> static unsigned long vdso_pages;
>>> static struct page **vdso_pagelist;
>>> 
>>> +#ifdef CONFIG_ARM64_ILP32
>>> +extern char vdso_ilp32_start, vdso_ilp32_end;
>>> +static unsigned long vdso_ilp32_pages;
>>> +static struct page **vdso_ilp32_pagelist;
>>> +#endif
>>> +
>>> /*
>>>  * The vDSO data page.
>>>  */
>>> @@ -117,24 +123,29 @@ int aarch32_setup_vectors_page(struct linux_binprm *bprm, int uses_interp)
>>> }
>>> #endif /* CONFIG_AARCH32_EL0 */
>>> 
>>> -static struct vm_special_mapping vdso_spec[2];
>>> -
>>> -static int __init vdso_init(void)
>>> +static inline int __init vdso_init_common(char *vdso_start, char *vdso_end,
>> 
>> No inline please.
>> 
>> 
>>> +					  unsigned long *vdso_pagesp,
>>> +					  struct page ***vdso_pagelistp,
>>> +					  struct vm_special_mapping* vdso_spec)
>>> {
>> 
>> [...]
>> 
>>> int arch_setup_additional_pages(struct linux_binprm *bprm,
>>> 				int uses_interp)
>>> {
>>> 	struct mm_struct *mm = current->mm;
>>> 	unsigned long vdso_base, vdso_text_len, vdso_mapping_len;
>>> -	void *ret;
>>> +	void* ret;
>> 
>> Gratuitous (and incorrect) style change.
>> 
>> 
>>> +	unsigned long pages = vdso_pages;
>>> +	struct vm_special_mapping* spec = vdso_spec;
>> 
>> Incorrect style:                  *spec
> 
> Hi Nathan,
> 
> If Philipp Philipp Tomsich will not answer soon, I'll fix all this.
> 
> BR,
> Yury.

^ permalink raw reply	[flat|nested] 96+ messages in thread

* Re: [PATCH v5 00/23] ILP32 for ARM64
  2015-10-01 19:15     ` Yury Norov
@ 2015-10-01 21:28       ` Arnd Bergmann
  -1 siblings, 0 replies; 96+ messages in thread
From: Arnd Bergmann @ 2015-10-01 21:28 UTC (permalink / raw)
  To: Yury Norov
  Cc: Catalin Marinas, linux-arm-kernel, linux-kernel, agraf,
	bamvor.zhangjian, yury.norov, klimov.linux, apinski,
	philipp.tomsich, christoph.muellner, Prasun.Kapoor

On Thursday 01 October 2015 22:15:20 Yury Norov wrote:

> Regarding time_t, it, of course, doesn't takes much time to make it
> 32-bit, but I think 64 bit is better because of Y2038. X32 and mips
> n32 has time_t 64-bit (and ppc, not sure), and that's OK for them.

I'm pretty sure that n32 has 32-bit time_t, and we know that it still
causes real-world problems on x32: socket timestamps, v4l, alsa and
other subsystems all have bugs in this area that are hard to fix.

> That's OK for BSD as well. The objection may come from users of ABI,
> complaining portability problems, but I found no such complains in
> public discussions.
>
> Nevertheless, as I told, I do not see any problem to rework time_t.
> But some arguments supporting this decision are appreciated.
> 
> The downside of 32 bit time_t is that we still face Y2038 problem,
> but that's the other story fixing it.

The main reason for 32-bit time_t is compatibility with existing
ioctls (also getsockopts and some others), and having a sane way
for fixing them. We cannot change compat_time_t to be 64-bit
without breaking arm32 compat mode, and we can't use the native
64-bit ioctl implementation on ARM64/ILP32 because that breaks
all interfaces that pass 'long' or a pointer.

This means drivers that currently pass a time_t (or timeval, timespec
etc) need to not only have a compat_ioctl handler to convert it,
they also need to check whether which of the two compat modes they
are talking to. This is a mess to add (I know, because I'm working
on this for y2038 compliance for normal 32-bit mode), and making
the two behave differently makes it even harder to get right for
all cases.

> __kernel_long_t is the same. Now it's 64 bits length. Compatibility
> may suffer, but, again, there're no complains, and in long run it
> looks better.

__kernel_long_t isn't actually used that much, and rarely used in
places where it matters. The idea was to be able to reuse the
native syscalls rather than the compat syscall calls, but that
comes with the downside of defining the ABI in a way that is
incompatible with all other 32-bit user space.

Having a 64-bit __kernel_off_t is similar to the 64-bit time_t:
a good idea in principle, but it breaks device drivers that
expect user space to pass 32-bit arguments. For any interface
that really needs 64-bit data, we have to fix it for all
32-bit architectures, and we're better off avoiding special
cases.

	Arnd

^ permalink raw reply	[flat|nested] 96+ messages in thread

* [PATCH v5 00/23] ILP32 for ARM64
@ 2015-10-01 21:28       ` Arnd Bergmann
  0 siblings, 0 replies; 96+ messages in thread
From: Arnd Bergmann @ 2015-10-01 21:28 UTC (permalink / raw)
  To: linux-arm-kernel

On Thursday 01 October 2015 22:15:20 Yury Norov wrote:

> Regarding time_t, it, of course, doesn't takes much time to make it
> 32-bit, but I think 64 bit is better because of Y2038. X32 and mips
> n32 has time_t 64-bit (and ppc, not sure), and that's OK for them.

I'm pretty sure that n32 has 32-bit time_t, and we know that it still
causes real-world problems on x32: socket timestamps, v4l, alsa and
other subsystems all have bugs in this area that are hard to fix.

> That's OK for BSD as well. The objection may come from users of ABI,
> complaining portability problems, but I found no such complains in
> public discussions.
>
> Nevertheless, as I told, I do not see any problem to rework time_t.
> But some arguments supporting this decision are appreciated.
> 
> The downside of 32 bit time_t is that we still face Y2038 problem,
> but that's the other story fixing it.

The main reason for 32-bit time_t is compatibility with existing
ioctls (also getsockopts and some others), and having a sane way
for fixing them. We cannot change compat_time_t to be 64-bit
without breaking arm32 compat mode, and we can't use the native
64-bit ioctl implementation on ARM64/ILP32 because that breaks
all interfaces that pass 'long' or a pointer.

This means drivers that currently pass a time_t (or timeval, timespec
etc) need to not only have a compat_ioctl handler to convert it,
they also need to check whether which of the two compat modes they
are talking to. This is a mess to add (I know, because I'm working
on this for y2038 compliance for normal 32-bit mode), and making
the two behave differently makes it even harder to get right for
all cases.

> __kernel_long_t is the same. Now it's 64 bits length. Compatibility
> may suffer, but, again, there're no complains, and in long run it
> looks better.

__kernel_long_t isn't actually used that much, and rarely used in
places where it matters. The idea was to be able to reuse the
native syscalls rather than the compat syscall calls, but that
comes with the downside of defining the ABI in a way that is
incompatible with all other 32-bit user space.

Having a 64-bit __kernel_off_t is similar to the 64-bit time_t:
a good idea in principle, but it breaks device drivers that
expect user space to pass 32-bit arguments. For any interface
that really needs 64-bit data, we have to fix it for all
32-bit architectures, and we're better off avoiding special
cases.

	Arnd

^ permalink raw reply	[flat|nested] 96+ messages in thread

* Re: [PATCH v5 00/23] ILP32 for ARM64
  2015-10-01 21:28       ` Arnd Bergmann
@ 2015-10-01 21:49         ` Pinski, Andrew
  -1 siblings, 0 replies; 96+ messages in thread
From: Pinski, Andrew @ 2015-10-01 21:49 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Norov, Yuri, Catalin Marinas, linux-arm-kernel, linux-kernel,
	agraf, bamvor.zhangjian, yury.norov, klimov.linux, apinski,
	philipp.tomsich, christoph.muellner, Kapoor, Prasun


> On Oct 1, 2015, at 2:29 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> 
>> On Thursday 01 October 2015 22:15:20 Yury Norov wrote:
>> 
>> Regarding time_t, it, of course, doesn't takes much time to make it
>> 32-bit, but I think 64 bit is better because of Y2038. X32 and mips
>> n32 has time_t 64-bit (and ppc, not sure), and that's OK for them.
> 
> I'm pretty sure that n32 has 32-bit time_t, and we know that it still
> causes real-world problems on x32: socket timestamps, v4l, alsa and
> other subsystems all have bugs in this area that are hard to fix.
> 
>> That's OK for BSD as well. The objection may come from users of ABI,
>> complaining portability problems, but I found no such complains in
>> public discussions.
>> 
>> Nevertheless, as I told, I do not see any problem to rework time_t.
>> But some arguments supporting this decision are appreciated.
>> 
>> The downside of 32 bit time_t is that we still face Y2038 problem,
>> but that's the other story fixing it.
> 
> The main reason for 32-bit time_t is compatibility with existing
> ioctls (also getsockopts and some others), and having a sane way
> for fixing them. We cannot change compat_time_t to be 64-bit
> without breaking arm32 compat mode, and we can't use the native
> 64-bit ioctl implementation on ARM64/ILP32 because that breaks
> all interfaces that pass 'long' or a pointer.
> 
> This means drivers that currently pass a time_t (or timeval, timespec
> etc) need to not only have a compat_ioctl handler to convert it,
> they also need to check whether which of the two compat modes they
> are talking to. This is a mess to add (I know, because I'm working
> on this for y2038 compliance for normal 32-bit mode), and making
> the two behave differently makes it even harder to get right for
> all cases.
> 
>> __kernel_long_t is the same. Now it's 64 bits length. Compatibility
>> may suffer, but, again, there're no complains, and in long run it
>> looks better.
> 
> __kernel_long_t isn't actually used that much, and rarely used in
> places where it matters. The idea was to be able to reuse the
> native syscalls rather than the compat syscall calls, but that
> comes with the downside of defining the ABI in a way that is
> incompatible with all other 32-bit user space.
> 
> Having a 64-bit __kernel_off_t is similar to the 64-bit time_t:
> a good idea in principle, but it breaks device drivers that
> expect user space to pass 32-bit arguments. For any interface
> that really needs 64-bit data, we have to fix it for all
> 32-bit architectures, and we're better off avoiding special
> cases.

Ok, we will rewrite these patches using 32bit time_t and 32bit off_t and redo the toolchain support for them.  Note this is going back to the abi I had originally done when I submitted my original version when it was asked to change time_t to be 64bit. 

Thanks,
Andrew


> 
>    Arnd

^ permalink raw reply	[flat|nested] 96+ messages in thread

* [PATCH v5 00/23] ILP32 for ARM64
@ 2015-10-01 21:49         ` Pinski, Andrew
  0 siblings, 0 replies; 96+ messages in thread
From: Pinski, Andrew @ 2015-10-01 21:49 UTC (permalink / raw)
  To: linux-arm-kernel


> On Oct 1, 2015, at 2:29 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> 
>> On Thursday 01 October 2015 22:15:20 Yury Norov wrote:
>> 
>> Regarding time_t, it, of course, doesn't takes much time to make it
>> 32-bit, but I think 64 bit is better because of Y2038. X32 and mips
>> n32 has time_t 64-bit (and ppc, not sure), and that's OK for them.
> 
> I'm pretty sure that n32 has 32-bit time_t, and we know that it still
> causes real-world problems on x32: socket timestamps, v4l, alsa and
> other subsystems all have bugs in this area that are hard to fix.
> 
>> That's OK for BSD as well. The objection may come from users of ABI,
>> complaining portability problems, but I found no such complains in
>> public discussions.
>> 
>> Nevertheless, as I told, I do not see any problem to rework time_t.
>> But some arguments supporting this decision are appreciated.
>> 
>> The downside of 32 bit time_t is that we still face Y2038 problem,
>> but that's the other story fixing it.
> 
> The main reason for 32-bit time_t is compatibility with existing
> ioctls (also getsockopts and some others), and having a sane way
> for fixing them. We cannot change compat_time_t to be 64-bit
> without breaking arm32 compat mode, and we can't use the native
> 64-bit ioctl implementation on ARM64/ILP32 because that breaks
> all interfaces that pass 'long' or a pointer.
> 
> This means drivers that currently pass a time_t (or timeval, timespec
> etc) need to not only have a compat_ioctl handler to convert it,
> they also need to check whether which of the two compat modes they
> are talking to. This is a mess to add (I know, because I'm working
> on this for y2038 compliance for normal 32-bit mode), and making
> the two behave differently makes it even harder to get right for
> all cases.
> 
>> __kernel_long_t is the same. Now it's 64 bits length. Compatibility
>> may suffer, but, again, there're no complains, and in long run it
>> looks better.
> 
> __kernel_long_t isn't actually used that much, and rarely used in
> places where it matters. The idea was to be able to reuse the
> native syscalls rather than the compat syscall calls, but that
> comes with the downside of defining the ABI in a way that is
> incompatible with all other 32-bit user space.
> 
> Having a 64-bit __kernel_off_t is similar to the 64-bit time_t:
> a good idea in principle, but it breaks device drivers that
> expect user space to pass 32-bit arguments. For any interface
> that really needs 64-bit data, we have to fix it for all
> 32-bit architectures, and we're better off avoiding special
> cases.

Ok, we will rewrite these patches using 32bit time_t and 32bit off_t and redo the toolchain support for them.  Note this is going back to the abi I had originally done when I submitted my original version when it was asked to change time_t to be 64bit. 

Thanks,
Andrew


> 
>    Arnd

^ permalink raw reply	[flat|nested] 96+ messages in thread

* Re: [PATCH v5 00/23] ILP32 for ARM64
  2015-10-01 21:49         ` Pinski, Andrew
@ 2015-10-02  9:37           ` Catalin Marinas
  -1 siblings, 0 replies; 96+ messages in thread
From: Catalin Marinas @ 2015-10-02  9:37 UTC (permalink / raw)
  To: Pinski, Andrew
  Cc: Arnd Bergmann, yury.norov, Kapoor, Prasun, Norov, Yuri,
	linux-kernel, agraf, klimov.linux, bamvor.zhangjian, apinski,
	philipp.tomsich, linux-arm-kernel, christoph.muellner

On Thu, Oct 01, 2015 at 09:49:46PM +0000, Pinski, Andrew wrote:
> Ok, we will rewrite these patches using 32bit time_t and 32bit off_t
> and redo the toolchain support for them.  Note this is going back to
> the abi I had originally done when I submitted my original version
> when it was asked to change time_t to be 64bit. 

One of the key aspects of kernel development is the ability to adapt
quickly to new requests/insights. This implies releasing early and often
rather than a new version roughly twice a year (IIRC, v1 was posted
September 2013). Moreover, the success of the kernel is partly based on
not getting stuck on old decisions (well, unless it breaks accepted user
ABI).

So, at the time, following x32 discussions, we thought of using the
native ABI as much as possible. However, two important things happened
since:

1. libc community didn't like breaking the POSIX compliance
2. No-one seems desperate for ILP32 on AArch64

(1) is a fair point and I would rather be careful as we don't know the
extent of the code affected. In the meantime, we've also had ongoing
work for addressing the 2038 issue on 32-bit architectures.

The second point is equally important. The benchmarks I've seen didn't
show a significant improvement and the messages I got on various
channels pretty much labeled ILP32 as a transitional stage to full LP64.
In this case, we need to balance the benefits of a close to native ABI
(future proof, slightly higher performance) vs. the cost of maintaining
such ABI in the kernel on the long term, especially if it's not widely
used/tested.

We've seen the kernel patches and, following discussions on the lists,
decided to change the original recommendation. IIRC, the main ideas (but
you need to read various threads as I can't remember the details from
6-7 months ago):

a) separate syscall table for ILP32
b) close to compat ABI with 32-bit time_t, off_t
c) asm-generic/unistd.h rather than asm/unistd32.h (that's where it
   would differ from compat, together with places where pointers are
   passed)

As I said previously, I'm not going to pay any attention to the patches
in this series, it's nothing more than a rebase of a version I already
reviewed.

-- 
Catalin

^ permalink raw reply	[flat|nested] 96+ messages in thread

* [PATCH v5 00/23] ILP32 for ARM64
@ 2015-10-02  9:37           ` Catalin Marinas
  0 siblings, 0 replies; 96+ messages in thread
From: Catalin Marinas @ 2015-10-02  9:37 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Oct 01, 2015 at 09:49:46PM +0000, Pinski, Andrew wrote:
> Ok, we will rewrite these patches using 32bit time_t and 32bit off_t
> and redo the toolchain support for them.  Note this is going back to
> the abi I had originally done when I submitted my original version
> when it was asked to change time_t to be 64bit. 

One of the key aspects of kernel development is the ability to adapt
quickly to new requests/insights. This implies releasing early and often
rather than a new version roughly twice a year (IIRC, v1 was posted
September 2013). Moreover, the success of the kernel is partly based on
not getting stuck on old decisions (well, unless it breaks accepted user
ABI).

So, at the time, following x32 discussions, we thought of using the
native ABI as much as possible. However, two important things happened
since:

1. libc community didn't like breaking the POSIX compliance
2. No-one seems desperate for ILP32 on AArch64

(1) is a fair point and I would rather be careful as we don't know the
extent of the code affected. In the meantime, we've also had ongoing
work for addressing the 2038 issue on 32-bit architectures.

The second point is equally important. The benchmarks I've seen didn't
show a significant improvement and the messages I got on various
channels pretty much labeled ILP32 as a transitional stage to full LP64.
In this case, we need to balance the benefits of a close to native ABI
(future proof, slightly higher performance) vs. the cost of maintaining
such ABI in the kernel on the long term, especially if it's not widely
used/tested.

We've seen the kernel patches and, following discussions on the lists,
decided to change the original recommendation. IIRC, the main ideas (but
you need to read various threads as I can't remember the details from
6-7 months ago):

a) separate syscall table for ILP32
b) close to compat ABI with 32-bit time_t, off_t
c) asm-generic/unistd.h rather than asm/unistd32.h (that's where it
   would differ from compat, together with places where pointers are
   passed)

As I said previously, I'm not going to pay any attention to the patches
in this series, it's nothing more than a rebase of a version I already
reviewed.

-- 
Catalin

^ permalink raw reply	[flat|nested] 96+ messages in thread

* Re: [PATCH v5 00/23] ILP32 for ARM64
  2015-10-02  9:37           ` Catalin Marinas
@ 2015-10-03  2:18             ` Kapoor, Prasun
  -1 siblings, 0 replies; 96+ messages in thread
From: Kapoor, Prasun @ 2015-10-03  2:18 UTC (permalink / raw)
  To: Catalin Marinas, Pinski, Andrew
  Cc: Arnd Bergmann, yury.norov, Kapoor, Prasun, Norov, Yuri,
	linux-kernel, agraf, klimov.linux, bamvor.zhangjian, apinski,
	philipp.tomsich, linux-arm-kernel, christoph.muellner



On 10/2/15, 2:37 AM, "Catalin Marinas" <catalin.marinas@arm.com> wrote:

>On Thu, Oct 01, 2015 at 09:49:46PM +0000, Pinski, Andrew wrote:
>> Ok, we will rewrite these patches using 32bit time_t and 32bit off_t
>> and redo the toolchain support for them.  Note this is going back to
>> the abi I had originally done when I submitted my original version
>> when it was asked to change time_t to be 64bit.
>
>One of the key aspects of kernel development is the ability to adapt
>quickly to new requests/insights. This implies releasing early and often
>rather than a new version roughly twice a year (IIRC, v1 was posted
>September 2013). Moreover, the success of the kernel is partly based on
>not getting stuck on old decisions (well, unless it breaks accepted user
>ABI).
>
>So, at the time, following x32 discussions, we thought of using the
>native ABI as much as possible. However, two important things happened
>since:
>
>1. libc community didn't like breaking the POSIX compliance
>2. No-one seems desperate for ILP32 on AArch64
>
>(1) is a fair point and I would rather be careful as we don't know the
>extent of the code affected. In the meantime, we've also had ongoing
>work for addressing the 2038 issue on 32-bit architectures.
>
>The second point is equally important. The benchmarks I've seen didn't
>show a significant improvement and the messages I got on various
>channels pretty much labeled ILP32 as a transitional stage to full LP64.
>In this case, we need to balance the benefits of a close to native ABI
>(future proof, slightly higher performance) vs. the cost of maintaining
>such ABI in the kernel on the long term, especially if it's not widely
>used/tested.


For us ILP32  is not about putting this into our product flier at all, it
is about supporting real applications. We have an existing product line of
MIPS based SoCs where a large number of N32 (an exact equivalent of ILP32)
applications are currently in production. Our customers are looking to
bring those applications (mostly in Networking and Telecom space) over to
ARMv8. 

We think its an extremely risky strategy to say either future processors
should incur the additional cost (power and complexity) of implementing
Aarch32 instruction set or have no way of  supporting 32 bit applications
at all.

Apart from there being an installed base of 32 bit networking and telecom
applications, we have also seen non-trivial performance gains with ILP32
(for example, our SPECINT score goes up by 7% with ILP32 compared to
LP64).  



>
>We've seen the kernel patches and, following discussions on the lists,
>decided to change the original recommendation. IIRC, the main ideas (but
>you need to read various threads as I can't remember the details from
>6-7 months ago):
>
>a) separate syscall table for ILP32
>b) close to compat ABI with 32-bit time_t, off_t
>c) asm-generic/unistd.h rather than asm/unistd32.h (that's where it
>   would differ from compat, together with places where pointers are
>   passed)
>
>As I said previously, I'm not going to pay any attention to the patches
>in this series, it's nothing more than a rebase of a version I already
>reviewed.
>
>-- 
>Catalin


^ permalink raw reply	[flat|nested] 96+ messages in thread

* [PATCH v5 00/23] ILP32 for ARM64
@ 2015-10-03  2:18             ` Kapoor, Prasun
  0 siblings, 0 replies; 96+ messages in thread
From: Kapoor, Prasun @ 2015-10-03  2:18 UTC (permalink / raw)
  To: linux-arm-kernel



On 10/2/15, 2:37 AM, "Catalin Marinas" <catalin.marinas@arm.com> wrote:

>On Thu, Oct 01, 2015 at 09:49:46PM +0000, Pinski, Andrew wrote:
>> Ok, we will rewrite these patches using 32bit time_t and 32bit off_t
>> and redo the toolchain support for them.  Note this is going back to
>> the abi I had originally done when I submitted my original version
>> when it was asked to change time_t to be 64bit.
>
>One of the key aspects of kernel development is the ability to adapt
>quickly to new requests/insights. This implies releasing early and often
>rather than a new version roughly twice a year (IIRC, v1 was posted
>September 2013). Moreover, the success of the kernel is partly based on
>not getting stuck on old decisions (well, unless it breaks accepted user
>ABI).
>
>So, at the time, following x32 discussions, we thought of using the
>native ABI as much as possible. However, two important things happened
>since:
>
>1. libc community didn't like breaking the POSIX compliance
>2. No-one seems desperate for ILP32 on AArch64
>
>(1) is a fair point and I would rather be careful as we don't know the
>extent of the code affected. In the meantime, we've also had ongoing
>work for addressing the 2038 issue on 32-bit architectures.
>
>The second point is equally important. The benchmarks I've seen didn't
>show a significant improvement and the messages I got on various
>channels pretty much labeled ILP32 as a transitional stage to full LP64.
>In this case, we need to balance the benefits of a close to native ABI
>(future proof, slightly higher performance) vs. the cost of maintaining
>such ABI in the kernel on the long term, especially if it's not widely
>used/tested.


For us ILP32  is not about putting this into our product flier at all, it
is about supporting real applications. We have an existing product line of
MIPS based SoCs where a large number of N32 (an exact equivalent of ILP32)
applications are currently in production. Our customers are looking to
bring those applications (mostly in Networking and Telecom space) over to
ARMv8. 

We think its an extremely risky strategy to say either future processors
should incur the additional cost (power and complexity) of implementing
Aarch32 instruction set or have no way of  supporting 32 bit applications
at all.

Apart from there being an installed base of 32 bit networking and telecom
applications, we have also seen non-trivial performance gains with ILP32
(for example, our SPECINT score goes up by 7% with ILP32 compared to
LP64).  



>
>We've seen the kernel patches and, following discussions on the lists,
>decided to change the original recommendation. IIRC, the main ideas (but
>you need to read various threads as I can't remember the details from
>6-7 months ago):
>
>a) separate syscall table for ILP32
>b) close to compat ABI with 32-bit time_t, off_t
>c) asm-generic/unistd.h rather than asm/unistd32.h (that's where it
>   would differ from compat, together with places where pointers are
>   passed)
>
>As I said previously, I'm not going to pay any attention to the patches
>in this series, it's nothing more than a rebase of a version I already
>reviewed.
>
>-- 
>Catalin

^ permalink raw reply	[flat|nested] 96+ messages in thread

* Re: [PATCH v5 00/23] ILP32 for ARM64
  2015-10-03  2:18             ` Kapoor, Prasun
@ 2015-10-05 15:58               ` Catalin Marinas
  -1 siblings, 0 replies; 96+ messages in thread
From: Catalin Marinas @ 2015-10-05 15:58 UTC (permalink / raw)
  To: Kapoor, Prasun
  Cc: Pinski, Andrew, Arnd Bergmann, yury.norov, Norov, Yuri, agraf,
	linux-kernel, klimov.linux, bamvor.zhangjian, apinski,
	philipp.tomsich, linux-arm-kernel, christoph.muellner

On Sat, Oct 03, 2015 at 02:18:57AM +0000, Kapoor, Prasun wrote:
> On 10/2/15, 2:37 AM, "Catalin Marinas" <catalin.marinas@arm.com> wrote:
> >So, at the time, following x32 discussions, we thought of using the
> >native ABI as much as possible. However, two important things happened
> >since:
> >
> >1. libc community didn't like breaking the POSIX compliance
> >2. No-one seems desperate for ILP32 on AArch64
> >
> >(1) is a fair point and I would rather be careful as we don't know the
> >extent of the code affected. In the meantime, we've also had ongoing
> >work for addressing the 2038 issue on 32-bit architectures.
> >
> >The second point is equally important. The benchmarks I've seen didn't
> >show a significant improvement and the messages I got on various
> >channels pretty much labeled ILP32 as a transitional stage to full LP64.
> >In this case, we need to balance the benefits of a close to native ABI
> >(future proof, slightly higher performance) vs. the cost of maintaining
> >such ABI in the kernel on the long term, especially if it's not widely
> >used/tested.
> 
> For us ILP32  is not about putting this into our product flier at all, it
> is about supporting real applications. We have an existing product line of
> MIPS based SoCs where a large number of N32 (an exact equivalent of ILP32)
> applications are currently in production. Our customers are looking to
> bring those applications (mostly in Networking and Telecom space) over to
> ARMv8. 
> 
> We think its an extremely risky strategy to say either future processors
> should incur the additional cost (power and complexity) of implementing
> Aarch32 instruction set or have no way of  supporting 32 bit applications
> at all.

Well, given that Cavium posted only 3 versions of this series since
September 2013, it doesn't seem critical at all.

> Apart from there being an installed base of 32 bit networking and telecom
> applications, we have also seen non-trivial performance gains with ILP32
> (for example, our SPECINT score goes up by 7% with ILP32 compared to
> LP64).

It would be good to re-run the benchmarks with the latest gcc since
LP64/AArch64 support has evolved in the meantime.

-- 
Catalin

^ permalink raw reply	[flat|nested] 96+ messages in thread

* [PATCH v5 00/23] ILP32 for ARM64
@ 2015-10-05 15:58               ` Catalin Marinas
  0 siblings, 0 replies; 96+ messages in thread
From: Catalin Marinas @ 2015-10-05 15:58 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat, Oct 03, 2015 at 02:18:57AM +0000, Kapoor, Prasun wrote:
> On 10/2/15, 2:37 AM, "Catalin Marinas" <catalin.marinas@arm.com> wrote:
> >So, at the time, following x32 discussions, we thought of using the
> >native ABI as much as possible. However, two important things happened
> >since:
> >
> >1. libc community didn't like breaking the POSIX compliance
> >2. No-one seems desperate for ILP32 on AArch64
> >
> >(1) is a fair point and I would rather be careful as we don't know the
> >extent of the code affected. In the meantime, we've also had ongoing
> >work for addressing the 2038 issue on 32-bit architectures.
> >
> >The second point is equally important. The benchmarks I've seen didn't
> >show a significant improvement and the messages I got on various
> >channels pretty much labeled ILP32 as a transitional stage to full LP64.
> >In this case, we need to balance the benefits of a close to native ABI
> >(future proof, slightly higher performance) vs. the cost of maintaining
> >such ABI in the kernel on the long term, especially if it's not widely
> >used/tested.
> 
> For us ILP32  is not about putting this into our product flier at all, it
> is about supporting real applications. We have an existing product line of
> MIPS based SoCs where a large number of N32 (an exact equivalent of ILP32)
> applications are currently in production. Our customers are looking to
> bring those applications (mostly in Networking and Telecom space) over to
> ARMv8. 
> 
> We think its an extremely risky strategy to say either future processors
> should incur the additional cost (power and complexity) of implementing
> Aarch32 instruction set or have no way of  supporting 32 bit applications
> at all.

Well, given that Cavium posted only 3 versions of this series since
September 2013, it doesn't seem critical at all.

> Apart from there being an installed base of 32 bit networking and telecom
> applications, we have also seen non-trivial performance gains with ILP32
> (for example, our SPECINT score goes up by 7% with ILP32 compared to
> LP64).

It would be good to re-run the benchmarks with the latest gcc since
LP64/AArch64 support has evolved in the meantime.

-- 
Catalin

^ permalink raw reply	[flat|nested] 96+ messages in thread

* Re: [PATCH v5 00/23] ILP32 for ARM64
  2015-10-01 21:49         ` Pinski, Andrew
@ 2015-10-05 19:10           ` Yury Norov
  -1 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-10-05 19:10 UTC (permalink / raw)
  To: Pinski, Andrew
  Cc: Arnd Bergmann, Norov, Yuri, Catalin Marinas, linux-arm-kernel,
	linux-kernel, agraf, bamvor.zhangjian, yury.norov, klimov.linux,
	apinski, philipp.tomsich, christoph.muellner, Kapoor, Prasun

On Fri, Oct 02, 2015 at 12:49:46AM +0300, Pinski, Andrew wrote:

[...]

> Ok, we will rewrite these patches using 32bit time_t and 32bit off_t and
> redo the toolchain support for them.  Note this is going back to the abi
> I had originally done when I submitted my original version when it was
> asked to change time_t to be 64bit. 
> 
> Thanks,
> Andrew

Hi Andrew,

I try to apply your glibc ILP32 patchset on current glibc master, but
there're many merge failures.
        https://sourceware.org/ml/libc-alpha/2014-10/msg00596.html

Could you share more fresh version of it, if you have one?

Are there any special commands or configure options needed 
to enable ILP32 properly?

BR,
Yury.

^ permalink raw reply	[flat|nested] 96+ messages in thread

* [PATCH v5 00/23] ILP32 for ARM64
@ 2015-10-05 19:10           ` Yury Norov
  0 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-10-05 19:10 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Oct 02, 2015 at 12:49:46AM +0300, Pinski, Andrew wrote:

[...]

> Ok, we will rewrite these patches using 32bit time_t and 32bit off_t and
> redo the toolchain support for them.  Note this is going back to the abi
> I had originally done when I submitted my original version when it was
> asked to change time_t to be 64bit. 
> 
> Thanks,
> Andrew

Hi Andrew,

I try to apply your glibc ILP32 patchset on current glibc master, but
there're many merge failures.
        https://sourceware.org/ml/libc-alpha/2014-10/msg00596.html

Could you share more fresh version of it, if you have one?

Are there any special commands or configure options needed 
to enable ILP32 properly?

BR,
Yury.

^ permalink raw reply	[flat|nested] 96+ messages in thread

* Re: [PATCH v5 00/23] ILP32 for ARM64
  2015-10-05 15:58               ` Catalin Marinas
@ 2015-10-05 21:00                 ` Pinski, Andrew
  -1 siblings, 0 replies; 96+ messages in thread
From: Pinski, Andrew @ 2015-10-05 21:00 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: Kapoor, Prasun, Arnd Bergmann, yury.norov, Norov, Yuri, agraf,
	linux-kernel, klimov.linux, bamvor.zhangjian, apinski,
	philipp.tomsich, linux-arm-kernel, christoph.muellner, pinskia



> On Oct 5, 2015, at 8:59 AM, Catalin Marinas <catalin.marinas@arm.com> wrote:
> 
>> On Sat, Oct 03, 2015 at 02:18:57AM +0000, Kapoor, Prasun wrote:
>>> On 10/2/15, 2:37 AM, "Catalin Marinas" <catalin.marinas@arm.com> wrote:
>>> So, at the time, following x32 discussions, we thought of using the
>>> native ABI as much as possible. However, two important things happened
>>> since:
>>> 
>>> 1. libc community didn't like breaking the POSIX compliance
>>> 2. No-one seems desperate for ILP32 on AArch64
>>> 
>>> (1) is a fair point and I would rather be careful as we don't know the
>>> extent of the code affected. In the meantime, we've also had ongoing
>>> work for addressing the 2038 issue on 32-bit architectures.
>>> 
>>> The second point is equally important. The benchmarks I've seen didn't
>>> show a significant improvement and the messages I got on various
>>> channels pretty much labeled ILP32 as a transitional stage to full LP64.
>>> In this case, we need to balance the benefits of a close to native ABI
>>> (future proof, slightly higher performance) vs. the cost of maintaining
>>> such ABI in the kernel on the long term, especially if it's not widely
>>> used/tested.
>> 
>> For us ILP32  is not about putting this into our product flier at all, it
>> is about supporting real applications. We have an existing product line of
>> MIPS based SoCs where a large number of N32 (an exact equivalent of ILP32)
>> applications are currently in production. Our customers are looking to
>> bring those applications (mostly in Networking and Telecom space) over to
>> ARMv8. 
>> 
>> We think its an extremely risky strategy to say either future processors
>> should incur the additional cost (power and complexity) of implementing
>> Aarch32 instruction set or have no way of  supporting 32 bit applications
>> at all.
> 
> Well, given that Cavium posted only 3 versions of this series since
> September 2013, it doesn't seem critical at all.

We are going to post another version as soon as we finish the changes that you requested this time around. I am working on the glibc and yury (with my help) will doing the kernel side. 


> 
>> Apart from there being an installed base of 32 bit networking and telecom
>> applications, we have also seen non-trivial performance gains with ILP32
>> (for example, our SPECINT score goes up by 7% with ILP32 compared to
>> LP64).
> 
> It would be good to re-run the benchmarks with the latest gcc since
> LP64/AArch64 support has evolved in the meantime.

We are also rerunning the numbers with the latest released gcc (5.2) and will report results when we submit the next version of the patch set.  

Thanks,
Andrew

> 
> -- 
> Catalin

^ permalink raw reply	[flat|nested] 96+ messages in thread

* [PATCH v5 00/23] ILP32 for ARM64
@ 2015-10-05 21:00                 ` Pinski, Andrew
  0 siblings, 0 replies; 96+ messages in thread
From: Pinski, Andrew @ 2015-10-05 21:00 UTC (permalink / raw)
  To: linux-arm-kernel



> On Oct 5, 2015, at 8:59 AM, Catalin Marinas <catalin.marinas@arm.com> wrote:
> 
>> On Sat, Oct 03, 2015 at 02:18:57AM +0000, Kapoor, Prasun wrote:
>>> On 10/2/15, 2:37 AM, "Catalin Marinas" <catalin.marinas@arm.com> wrote:
>>> So, at the time, following x32 discussions, we thought of using the
>>> native ABI as much as possible. However, two important things happened
>>> since:
>>> 
>>> 1. libc community didn't like breaking the POSIX compliance
>>> 2. No-one seems desperate for ILP32 on AArch64
>>> 
>>> (1) is a fair point and I would rather be careful as we don't know the
>>> extent of the code affected. In the meantime, we've also had ongoing
>>> work for addressing the 2038 issue on 32-bit architectures.
>>> 
>>> The second point is equally important. The benchmarks I've seen didn't
>>> show a significant improvement and the messages I got on various
>>> channels pretty much labeled ILP32 as a transitional stage to full LP64.
>>> In this case, we need to balance the benefits of a close to native ABI
>>> (future proof, slightly higher performance) vs. the cost of maintaining
>>> such ABI in the kernel on the long term, especially if it's not widely
>>> used/tested.
>> 
>> For us ILP32  is not about putting this into our product flier at all, it
>> is about supporting real applications. We have an existing product line of
>> MIPS based SoCs where a large number of N32 (an exact equivalent of ILP32)
>> applications are currently in production. Our customers are looking to
>> bring those applications (mostly in Networking and Telecom space) over to
>> ARMv8. 
>> 
>> We think its an extremely risky strategy to say either future processors
>> should incur the additional cost (power and complexity) of implementing
>> Aarch32 instruction set or have no way of  supporting 32 bit applications
>> at all.
> 
> Well, given that Cavium posted only 3 versions of this series since
> September 2013, it doesn't seem critical at all.

We are going to post another version as soon as we finish the changes that you requested this time around. I am working on the glibc and yury (with my help) will doing the kernel side. 


> 
>> Apart from there being an installed base of 32 bit networking and telecom
>> applications, we have also seen non-trivial performance gains with ILP32
>> (for example, our SPECINT score goes up by 7% with ILP32 compared to
>> LP64).
> 
> It would be good to re-run the benchmarks with the latest gcc since
> LP64/AArch64 support has evolved in the meantime.

We are also rerunning the numbers with the latest released gcc (5.2) and will report results when we submit the next version of the patch set.  

Thanks,
Andrew

> 
> -- 
> Catalin

^ permalink raw reply	[flat|nested] 96+ messages in thread

* Re: [PATCH v5 04/23] arm64: change some CONFIG_COMPAT over to use CONFIG_AARCH32_EL0 instead
  2015-09-29 22:14   ` Yury Norov
@ 2015-10-06  9:21     ` Andrey Konovalov
  -1 siblings, 0 replies; 96+ messages in thread
From: Andrey Konovalov @ 2015-10-06  9:21 UTC (permalink / raw)
  To: Yury Norov, linux-arm-kernel, linux-kernel, catalin.marinas,
	arnd, agraf, bamvor.zhangjian
  Cc: yury.norov, klimov.linux, apinski, philipp.tomsich, christoph.muellner

Hi Yury,

With this patch set 4.3 kernel fails to build with both arch/arm64/configs/defconfig,
and with arch/arm64/configs/defconfig plus CONFIG_AARCH32_EL0=y and CONFIG_ARM64_ILP32=y.
See the details below.

Thanks,
Andrey

On 09/30/2015 01:14 AM, Yury Norov wrote:
> From: Andrew Pinski <apinski@cavium.com>
>
> Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
> Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
> Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>
>
> diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h
> index faad6df..f40c51b 100644
> --- a/arch/arm64/include/asm/elf.h
> +++ b/arch/arm64/include/asm/elf.h
> @@ -166,10 +166,13 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
>
>   #define COMPAT_ELF_ET_DYN_BASE		(2 * TASK_SIZE_32 / 3)
>
> +
> +#ifdef CONFIG_AARCH32_EL0
> +
>   /* AArch32 registers. */
> -#define COMPAT_ELF_NGREG		18
> +#define COMPAT_A32_ELF_NGREG		18
>   typedef unsigned int			compat_elf_greg_t;
> -typedef compat_elf_greg_t		compat_elf_gregset_t[COMPAT_ELF_NGREG];
> +typedef compat_elf_greg_t		compat_elf_gregset_t[COMPAT_A32_ELF_NGREG];
>
>   /* AArch32 EABI. */
>   #define EF_ARM_EABI_MASK		0xff000000
> @@ -179,11 +182,25 @@ typedef compat_elf_greg_t		compat_elf_gregset_t[COMPAT_ELF_NGREG];
>   #define compat_start_thread		compat_start_thread
>   #define COMPAT_SET_PERSONALITY(ex)	set_thread_flag(TIF_32BIT);
>   #define COMPAT_ARCH_DLINFO
> +
> +
>   extern int aarch32_setup_vectors_page(struct linux_binprm *bprm,
>   				      int uses_interp);
>   #define compat_arch_setup_additional_pages \
>   					aarch32_setup_vectors_page
>
> +#else
> +
> +typedef elf_greg_t			compat_elf_greg_t;
> +typedef elf_gregset_t			compat_elf_gregset_t;
> +#define compat_a32_elf_check_arch(x)	0
> +#define COMPAT_SET_PERSONALITY(ex)
> +#define COMPAT_ARCH_DLINFO
> +
> +#endif
> +
> +#define compat_elf_check_arch(x)	compat_a32_elf_check_arch(x)
> +
>   #endif /* CONFIG_COMPAT */
>
>   #endif
> diff --git a/arch/arm64/include/asm/fpsimd.h b/arch/arm64/include/asm/fpsimd.h
> index 50f559f..63b19f1 100644
> --- a/arch/arm64/include/asm/fpsimd.h
> +++ b/arch/arm64/include/asm/fpsimd.h
> @@ -52,7 +52,7 @@ struct fpsimd_partial_state {
>   };
>
>
> -#if defined(__KERNEL__) && defined(CONFIG_COMPAT)
> +#if defined(__KERNEL__) && defined(CONFIG_AARCH32_EL0)
>   /* Masks for extracting the FPSR and FPCR from the FPSCR */
>   #define VFP_FPSCR_STAT_MASK	0xf800009f
>   #define VFP_FPSCR_CTRL_MASK	0x07f79f00
> diff --git a/arch/arm64/include/asm/ptrace.h b/arch/arm64/include/asm/ptrace.h
> index 536274e..1059b3f 100644
> --- a/arch/arm64/include/asm/ptrace.h
> +++ b/arch/arm64/include/asm/ptrace.h
> @@ -120,7 +120,7 @@ struct pt_regs {
>
>   #define arch_has_single_step()	(1)
>
> -#ifdef CONFIG_COMPAT
> +#ifdef CONFIG_AARCH32_EL0
>   #define compat_thumb_mode(regs) \
>   	(((regs)->pstate & COMPAT_PSR_T_BIT))
>   #else
> diff --git a/arch/arm64/include/asm/signal32.h b/arch/arm64/include/asm/signal32.h
> index eeaa975..4302909 100644
> --- a/arch/arm64/include/asm/signal32.h
> +++ b/arch/arm64/include/asm/signal32.h
> @@ -20,6 +20,7 @@
>   #ifdef CONFIG_COMPAT
>   #include <linux/compat.h>
>
> +#ifdef CONFIG_AARCH32_EL0
>   #define AARCH32_KERN_SIGRET_CODE_OFFSET	0x500
>
>   extern const compat_ulong_t aarch32_sigret_code[6];
> @@ -47,6 +48,7 @@ static inline int compat_setup_rt_frame(int usig, struct ksignal *ksig, sigset_t
>   static inline void compat_setup_restart_syscall(struct pt_regs *regs)
>   {
>   }
> +#endif /* CONFIG_AARCH32_EL0 */
>   #endif /* CONFIG_COMPAT */
>   #endif /* __KERNEL__ */
>   #endif /* __ASM_SIGNAL32_H */
> diff --git a/arch/arm64/include/asm/stat.h b/arch/arm64/include/asm/stat.h
> index 15e3559..af04276 100644
> --- a/arch/arm64/include/asm/stat.h
> +++ b/arch/arm64/include/asm/stat.h
> @@ -22,6 +22,7 @@
>
>   #include <asm/compat.h>
>
> +#ifdef CONFIG_AARCH32_EL0
>   /*
>    * struct stat64 is needed for compat tasks only. Its definition is different
>    * from the generic struct stat64.
> @@ -59,3 +60,4 @@ struct stat64 {
>
>   #endif
>   #endif
> +#endif
> diff --git a/arch/arm64/include/asm/unistd.h b/arch/arm64/include/asm/unistd.h
> index 3bc498c..759c433 100644
> --- a/arch/arm64/include/asm/unistd.h
> +++ b/arch/arm64/include/asm/unistd.h
> @@ -13,7 +13,7 @@
>    * You should have received a copy of the GNU General Public License
>    * along with this program.  If not, see <http://www.gnu.org/licenses/>.
>    */
> -#ifdef CONFIG_COMPAT
> +#ifdef CONFIG_AARCH32_EL0
>   #define __ARCH_WANT_COMPAT_SYS_GETDENTS64
>   #define __ARCH_WANT_COMPAT_STAT64
>   #define __ARCH_WANT_SYS_GETHOSTNAME
> @@ -26,7 +26,9 @@
>   #define __ARCH_WANT_COMPAT_SYS_SENDFILE
>   #define __ARCH_WANT_SYS_FORK
>   #define __ARCH_WANT_SYS_VFORK
> +#endif
>
> +#ifdef CONFIG_COMPAT
>   /*
>    * Compat syscall numbers used by the AArch64 kernel.
>    */
> diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile
> index 22dc9bc..1470332 100644
> --- a/arch/arm64/kernel/Makefile
> +++ b/arch/arm64/kernel/Makefile
> @@ -20,7 +20,7 @@ arm64-obj-y		:= debug-monitors.o entry.o irq.o fpsimd.o		\
>   			   cpufeature.o alternative.o cacheinfo.o		\
>   			   smp.o smp_spin_table.o topology.o
>
> -arm64-obj-$(CONFIG_COMPAT)		+= sys32.o kuser32.o signal32.o 	\
> +arm64-obj-$(CONFIG_AARCH32_EL0)		+= sys32.o kuser32.o signal32.o 	\
>   					   sys_compat.o entry32.o		\
>   					   ../../arm/kernel/opcodes.o
>   arm64-obj-$(CONFIG_FUNCTION_TRACER)	+= ftrace.o entry-ftrace.o
> diff --git a/arch/arm64/kernel/asm-offsets.c b/arch/arm64/kernel/asm-offsets.c
> index 8d89cf8..e3bcf77 100644
> --- a/arch/arm64/kernel/asm-offsets.c
> +++ b/arch/arm64/kernel/asm-offsets.c
> @@ -51,7 +51,7 @@ int main(void)
>     DEFINE(S_X7,			offsetof(struct pt_regs, regs[7]));
>     DEFINE(S_LR,			offsetof(struct pt_regs, regs[30]));
>     DEFINE(S_SP,			offsetof(struct pt_regs, sp));
> -#ifdef CONFIG_COMPAT
> +#ifdef CONFIG_AARCH32_EL0
>     DEFINE(S_COMPAT_SP,		offsetof(struct pt_regs, compat_sp));
>   #endif
>     DEFINE(S_PSTATE,		offsetof(struct pt_regs, pstate));
> diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S
> index 4306c93..52be5c8 100644
> --- a/arch/arm64/kernel/entry.S
> +++ b/arch/arm64/kernel/entry.S
> @@ -212,7 +212,7 @@ ENTRY(vectors)
>   	ventry	el0_fiq_invalid			// FIQ 64-bit EL0
>   	ventry	el0_error_invalid		// Error 64-bit EL0
>
> -#ifdef CONFIG_COMPAT
> +#ifdef CONFIG_AARCH32_EL0
>   	ventry	el0_sync_compat			// Synchronous 32-bit EL0
>   	ventry	el0_irq_compat			// IRQ 32-bit EL0
>   	ventry	el0_fiq_invalid_compat		// FIQ 32-bit EL0
> @@ -252,7 +252,7 @@ el0_error_invalid:
>   	inv_entry 0, BAD_ERROR
>   ENDPROC(el0_error_invalid)
>
> -#ifdef CONFIG_COMPAT
> +#ifdef CONFIG_AARCH32_EL0
>   el0_fiq_invalid_compat:
>   	inv_entry 0, BAD_FIQ, 32
>   ENDPROC(el0_fiq_invalid_compat)
> @@ -414,7 +414,7 @@ el0_sync:
>   	b.ge	el0_dbg
>   	b	el0_inv
>
> -#ifdef CONFIG_COMPAT
> +#ifdef CONFIG_AARCH32_EL0
>   	.align	6
>   el0_sync_compat:
>   	kernel_entry 0, 32
> diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S
> index 90d09ed..d11d0b2 100644
> --- a/arch/arm64/kernel/head.S
> +++ b/arch/arm64/kernel/head.S
> @@ -519,7 +519,7 @@ CPU_LE(	movk	x0, #0x30d0, lsl #16	)	// Clear EE and E0E on LE systems
>   	mov	x0, #0x33ff
>   	msr	cptr_el2, x0			// Disable copro. traps to EL2
>
> -#ifdef CONFIG_COMPAT
> +#ifdef CONFIG_AARCH32_EL0
>   	msr	hstr_el2, xzr			// Disable CP15 traps to EL2
>   #endif
>
> diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c
> index 1971f49..04b4972 100644
> --- a/arch/arm64/kernel/ptrace.c
> +++ b/arch/arm64/kernel/ptrace.c
> @@ -76,7 +76,7 @@ static void ptrace_hbptriggered(struct perf_event *bp,
>   		.si_addr	= (void __user *)(bkpt->trigger),
>   	};
>
> -#ifdef CONFIG_COMPAT
> +#ifdef CONFIG_AARCH32_EL0
>   	int i;
>
>   	if (!is_compat_task())
> @@ -651,7 +651,7 @@ static const struct user_regset_view user_aarch64_view = {
>   	.regsets = aarch64_regsets, .n = ARRAY_SIZE(aarch64_regsets)
>   };
>
> -#ifdef CONFIG_COMPAT
> +#ifdef CONFIG_AARCH32_EL0
>   #include <linux/compat.h>
>
>   enum compat_regset {
> @@ -853,7 +853,7 @@ static int compat_tls_set(struct task_struct *target,
>   static const struct user_regset aarch32_regsets[] = {
>   	[REGSET_COMPAT_GPR] = {
>   		.core_note_type = NT_PRSTATUS,
> -		.n = COMPAT_ELF_NGREG,
> +		.n = COMPAT_A32_ELF_NGREG,

Commit 5d220ff9 "arm64: Better native ptrace support for compat tasks" added
struct user_regset aarch32_ptrace_regsets[]
and hence one more COMPAT_ELF_NGREG, which is not handled by this patch.
This resulted in the following build failure in my ILP32 configuration (arch/arm64/configs/defconfig
plus CONFIG_AARCH32_EL0=y and CONFIG_ARM64_ILP32=y):
-----8<-----
  ../arch/arm64/kernel/ptrace.c:880:8: error: 'COMPAT_ELF_NGREG' undeclared here (not in a function)
     .n = COMPAT_ELF_NGREG,
          ^
-----8<-----

>   		.size = sizeof(compat_elf_greg_t),
>   		.align = sizeof(compat_elf_greg_t),
>   		.get = compat_gpr_get,
> @@ -1109,8 +1109,8 @@ static int compat_ptrace_sethbpregs(struct task_struct *tsk, compat_long_t num,
>   }
>   #endif	/* CONFIG_HAVE_HW_BREAKPOINT */
>
> -long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
> -			compat_ulong_t caddr, compat_ulong_t cdata)
> +long compat_a32_arch_ptrace(struct task_struct *child, compat_long_t request,
> +			    compat_ulong_t caddr, compat_ulong_t cdata)
>   {
>   	unsigned long addr = caddr;
>   	unsigned long data = cdata;
> @@ -1186,11 +1186,28 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
>
>   	return ret;
>   }
> -#endif /* CONFIG_COMPAT */
> +#else /* !CONFIG_AARCH32_EL0 */
> +long compat_a32_arch_ptrace(struct task_struct *child, compat_long_t request,
> +			    compat_ulong_t caddr, compat_ulong_t cdata)
> +{
> +	return -1;
> +}
> +#endif /* !CONFIG_AARCH32_EL0 */

Building with arm64's defconfig (CONFIG_AARCH32_EL0, CONFIG_COMPAT, and CONFIG_ARM64_ILP32 aren't set)
fails this way - due to compat_[u]long_t not being defined in !CONFIG_COMPAT case:

-----8<-----
../arch/arm64/kernel/ptrace.c:1190:56: error: unknown type name 'compat_long_t'
  long compat_a32_arch_ptrace(struct task_struct *child, compat_long_t request,
                                                         ^
../arch/arm64/kernel/ptrace.c:1191:8: error: unknown type name 'compat_ulong_t'
         compat_ulong_t caddr, compat_ulong_t cdata)
         ^
../arch/arm64/kernel/ptrace.c:1191:30: error: unknown type name 'compat_ulong_t'
         compat_ulong_t caddr, compat_ulong_t cdata)
                               ^
-----8<-----

> +#ifdef CONFIG_COMPAT
> +long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
> +			compat_ulong_t caddr, compat_ulong_t cdata)
> +{
> +	if (is_compat_task())
> +		return compat_a32_arch_ptrace(child, request, caddr, cdata);
> +	return compat_ptrace_request(child, request, caddr, cdata);
> +}
> +#endif
> +
>
>   const struct user_regset_view *task_user_regset_view(struct task_struct *task)
>   {
> -#ifdef CONFIG_COMPAT
> +#ifdef CONFIG_AARCH32_EL0
>   	/*
>   	 * Core dumping of 32-bit tasks or compat ptrace requests must use the
>   	 * user_aarch32_view compatible with arm32. Native ptrace requests on
> diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c
> index e18c48c..964a2a4 100644
> --- a/arch/arm64/kernel/signal.c
> +++ b/arch/arm64/kernel/signal.c
> @@ -414,3 +414,18 @@ asmlinkage void do_notify_resume(struct pt_regs *regs,
>   		fpsimd_restore_current_state();
>
>   }
> +
> +/*
> + * Some functions are needed for compat ptrace but we don't define
> + * them if we don't have AARCH32 support compiled in
> + */
> +#if defined CONFIG_COMPAT && !defined CONFIG_AARCH32_EL0
> +int copy_siginfo_to_user32(compat_siginfo_t __user *to, const siginfo_t *from)
> +{
> +	return -EFAULT;
> +}
> +int copy_siginfo_from_user32(siginfo_t *to, compat_siginfo_t __user *from)
> +{
> +	return -EFAULT;
> +}
> +#endif
> diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c
> index f93aae5..9ce9894 100644
> --- a/arch/arm64/kernel/traps.c
> +++ b/arch/arm64/kernel/traps.c
> @@ -363,7 +363,7 @@ long compat_arm_syscall(struct pt_regs *regs);
>
>   asmlinkage long do_ni_syscall(struct pt_regs *regs)
>   {
> -#ifdef CONFIG_COMPAT
> +#ifdef CONFIG_AARCH32_EL0
>   	long ret;
>   	if (is_compat_task()) {
>   		ret = compat_arm_syscall(regs);
> diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c
> index 97bc68f..26352a6 100644
> --- a/arch/arm64/kernel/vdso.c
> +++ b/arch/arm64/kernel/vdso.c
> @@ -49,7 +49,7 @@ static union {
>   } vdso_data_store __page_aligned_data;
>   struct vdso_data *vdso_data = &vdso_data_store.data;
>
> -#ifdef CONFIG_COMPAT
> +#ifdef CONFIG_AARCH32_EL0
>   /*
>    * Create and map the vectors page for AArch32 tasks.
>    */
> @@ -107,7 +107,7 @@ int aarch32_setup_vectors_page(struct linux_binprm *bprm, int uses_interp)
>
>   	return PTR_ERR_OR_ZERO(ret);
>   }
> -#endif /* CONFIG_COMPAT */
> +#endif /* CONFIG_AARCH32_EL0 */
>
>   static struct vm_special_mapping vdso_spec[2];
>
>


^ permalink raw reply	[flat|nested] 96+ messages in thread

* [PATCH v5 04/23] arm64: change some CONFIG_COMPAT over to use CONFIG_AARCH32_EL0 instead
@ 2015-10-06  9:21     ` Andrey Konovalov
  0 siblings, 0 replies; 96+ messages in thread
From: Andrey Konovalov @ 2015-10-06  9:21 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Yury,

With this patch set 4.3 kernel fails to build with both arch/arm64/configs/defconfig,
and with arch/arm64/configs/defconfig plus CONFIG_AARCH32_EL0=y and CONFIG_ARM64_ILP32=y.
See the details below.

Thanks,
Andrey

On 09/30/2015 01:14 AM, Yury Norov wrote:
> From: Andrew Pinski <apinski@cavium.com>
>
> Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
> Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
> Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>
>
> diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h
> index faad6df..f40c51b 100644
> --- a/arch/arm64/include/asm/elf.h
> +++ b/arch/arm64/include/asm/elf.h
> @@ -166,10 +166,13 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
>
>   #define COMPAT_ELF_ET_DYN_BASE		(2 * TASK_SIZE_32 / 3)
>
> +
> +#ifdef CONFIG_AARCH32_EL0
> +
>   /* AArch32 registers. */
> -#define COMPAT_ELF_NGREG		18
> +#define COMPAT_A32_ELF_NGREG		18
>   typedef unsigned int			compat_elf_greg_t;
> -typedef compat_elf_greg_t		compat_elf_gregset_t[COMPAT_ELF_NGREG];
> +typedef compat_elf_greg_t		compat_elf_gregset_t[COMPAT_A32_ELF_NGREG];
>
>   /* AArch32 EABI. */
>   #define EF_ARM_EABI_MASK		0xff000000
> @@ -179,11 +182,25 @@ typedef compat_elf_greg_t		compat_elf_gregset_t[COMPAT_ELF_NGREG];
>   #define compat_start_thread		compat_start_thread
>   #define COMPAT_SET_PERSONALITY(ex)	set_thread_flag(TIF_32BIT);
>   #define COMPAT_ARCH_DLINFO
> +
> +
>   extern int aarch32_setup_vectors_page(struct linux_binprm *bprm,
>   				      int uses_interp);
>   #define compat_arch_setup_additional_pages \
>   					aarch32_setup_vectors_page
>
> +#else
> +
> +typedef elf_greg_t			compat_elf_greg_t;
> +typedef elf_gregset_t			compat_elf_gregset_t;
> +#define compat_a32_elf_check_arch(x)	0
> +#define COMPAT_SET_PERSONALITY(ex)
> +#define COMPAT_ARCH_DLINFO
> +
> +#endif
> +
> +#define compat_elf_check_arch(x)	compat_a32_elf_check_arch(x)
> +
>   #endif /* CONFIG_COMPAT */
>
>   #endif
> diff --git a/arch/arm64/include/asm/fpsimd.h b/arch/arm64/include/asm/fpsimd.h
> index 50f559f..63b19f1 100644
> --- a/arch/arm64/include/asm/fpsimd.h
> +++ b/arch/arm64/include/asm/fpsimd.h
> @@ -52,7 +52,7 @@ struct fpsimd_partial_state {
>   };
>
>
> -#if defined(__KERNEL__) && defined(CONFIG_COMPAT)
> +#if defined(__KERNEL__) && defined(CONFIG_AARCH32_EL0)
>   /* Masks for extracting the FPSR and FPCR from the FPSCR */
>   #define VFP_FPSCR_STAT_MASK	0xf800009f
>   #define VFP_FPSCR_CTRL_MASK	0x07f79f00
> diff --git a/arch/arm64/include/asm/ptrace.h b/arch/arm64/include/asm/ptrace.h
> index 536274e..1059b3f 100644
> --- a/arch/arm64/include/asm/ptrace.h
> +++ b/arch/arm64/include/asm/ptrace.h
> @@ -120,7 +120,7 @@ struct pt_regs {
>
>   #define arch_has_single_step()	(1)
>
> -#ifdef CONFIG_COMPAT
> +#ifdef CONFIG_AARCH32_EL0
>   #define compat_thumb_mode(regs) \
>   	(((regs)->pstate & COMPAT_PSR_T_BIT))
>   #else
> diff --git a/arch/arm64/include/asm/signal32.h b/arch/arm64/include/asm/signal32.h
> index eeaa975..4302909 100644
> --- a/arch/arm64/include/asm/signal32.h
> +++ b/arch/arm64/include/asm/signal32.h
> @@ -20,6 +20,7 @@
>   #ifdef CONFIG_COMPAT
>   #include <linux/compat.h>
>
> +#ifdef CONFIG_AARCH32_EL0
>   #define AARCH32_KERN_SIGRET_CODE_OFFSET	0x500
>
>   extern const compat_ulong_t aarch32_sigret_code[6];
> @@ -47,6 +48,7 @@ static inline int compat_setup_rt_frame(int usig, struct ksignal *ksig, sigset_t
>   static inline void compat_setup_restart_syscall(struct pt_regs *regs)
>   {
>   }
> +#endif /* CONFIG_AARCH32_EL0 */
>   #endif /* CONFIG_COMPAT */
>   #endif /* __KERNEL__ */
>   #endif /* __ASM_SIGNAL32_H */
> diff --git a/arch/arm64/include/asm/stat.h b/arch/arm64/include/asm/stat.h
> index 15e3559..af04276 100644
> --- a/arch/arm64/include/asm/stat.h
> +++ b/arch/arm64/include/asm/stat.h
> @@ -22,6 +22,7 @@
>
>   #include <asm/compat.h>
>
> +#ifdef CONFIG_AARCH32_EL0
>   /*
>    * struct stat64 is needed for compat tasks only. Its definition is different
>    * from the generic struct stat64.
> @@ -59,3 +60,4 @@ struct stat64 {
>
>   #endif
>   #endif
> +#endif
> diff --git a/arch/arm64/include/asm/unistd.h b/arch/arm64/include/asm/unistd.h
> index 3bc498c..759c433 100644
> --- a/arch/arm64/include/asm/unistd.h
> +++ b/arch/arm64/include/asm/unistd.h
> @@ -13,7 +13,7 @@
>    * You should have received a copy of the GNU General Public License
>    * along with this program.  If not, see <http://www.gnu.org/licenses/>.
>    */
> -#ifdef CONFIG_COMPAT
> +#ifdef CONFIG_AARCH32_EL0
>   #define __ARCH_WANT_COMPAT_SYS_GETDENTS64
>   #define __ARCH_WANT_COMPAT_STAT64
>   #define __ARCH_WANT_SYS_GETHOSTNAME
> @@ -26,7 +26,9 @@
>   #define __ARCH_WANT_COMPAT_SYS_SENDFILE
>   #define __ARCH_WANT_SYS_FORK
>   #define __ARCH_WANT_SYS_VFORK
> +#endif
>
> +#ifdef CONFIG_COMPAT
>   /*
>    * Compat syscall numbers used by the AArch64 kernel.
>    */
> diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile
> index 22dc9bc..1470332 100644
> --- a/arch/arm64/kernel/Makefile
> +++ b/arch/arm64/kernel/Makefile
> @@ -20,7 +20,7 @@ arm64-obj-y		:= debug-monitors.o entry.o irq.o fpsimd.o		\
>   			   cpufeature.o alternative.o cacheinfo.o		\
>   			   smp.o smp_spin_table.o topology.o
>
> -arm64-obj-$(CONFIG_COMPAT)		+= sys32.o kuser32.o signal32.o 	\
> +arm64-obj-$(CONFIG_AARCH32_EL0)		+= sys32.o kuser32.o signal32.o 	\
>   					   sys_compat.o entry32.o		\
>   					   ../../arm/kernel/opcodes.o
>   arm64-obj-$(CONFIG_FUNCTION_TRACER)	+= ftrace.o entry-ftrace.o
> diff --git a/arch/arm64/kernel/asm-offsets.c b/arch/arm64/kernel/asm-offsets.c
> index 8d89cf8..e3bcf77 100644
> --- a/arch/arm64/kernel/asm-offsets.c
> +++ b/arch/arm64/kernel/asm-offsets.c
> @@ -51,7 +51,7 @@ int main(void)
>     DEFINE(S_X7,			offsetof(struct pt_regs, regs[7]));
>     DEFINE(S_LR,			offsetof(struct pt_regs, regs[30]));
>     DEFINE(S_SP,			offsetof(struct pt_regs, sp));
> -#ifdef CONFIG_COMPAT
> +#ifdef CONFIG_AARCH32_EL0
>     DEFINE(S_COMPAT_SP,		offsetof(struct pt_regs, compat_sp));
>   #endif
>     DEFINE(S_PSTATE,		offsetof(struct pt_regs, pstate));
> diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S
> index 4306c93..52be5c8 100644
> --- a/arch/arm64/kernel/entry.S
> +++ b/arch/arm64/kernel/entry.S
> @@ -212,7 +212,7 @@ ENTRY(vectors)
>   	ventry	el0_fiq_invalid			// FIQ 64-bit EL0
>   	ventry	el0_error_invalid		// Error 64-bit EL0
>
> -#ifdef CONFIG_COMPAT
> +#ifdef CONFIG_AARCH32_EL0
>   	ventry	el0_sync_compat			// Synchronous 32-bit EL0
>   	ventry	el0_irq_compat			// IRQ 32-bit EL0
>   	ventry	el0_fiq_invalid_compat		// FIQ 32-bit EL0
> @@ -252,7 +252,7 @@ el0_error_invalid:
>   	inv_entry 0, BAD_ERROR
>   ENDPROC(el0_error_invalid)
>
> -#ifdef CONFIG_COMPAT
> +#ifdef CONFIG_AARCH32_EL0
>   el0_fiq_invalid_compat:
>   	inv_entry 0, BAD_FIQ, 32
>   ENDPROC(el0_fiq_invalid_compat)
> @@ -414,7 +414,7 @@ el0_sync:
>   	b.ge	el0_dbg
>   	b	el0_inv
>
> -#ifdef CONFIG_COMPAT
> +#ifdef CONFIG_AARCH32_EL0
>   	.align	6
>   el0_sync_compat:
>   	kernel_entry 0, 32
> diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S
> index 90d09ed..d11d0b2 100644
> --- a/arch/arm64/kernel/head.S
> +++ b/arch/arm64/kernel/head.S
> @@ -519,7 +519,7 @@ CPU_LE(	movk	x0, #0x30d0, lsl #16	)	// Clear EE and E0E on LE systems
>   	mov	x0, #0x33ff
>   	msr	cptr_el2, x0			// Disable copro. traps to EL2
>
> -#ifdef CONFIG_COMPAT
> +#ifdef CONFIG_AARCH32_EL0
>   	msr	hstr_el2, xzr			// Disable CP15 traps to EL2
>   #endif
>
> diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c
> index 1971f49..04b4972 100644
> --- a/arch/arm64/kernel/ptrace.c
> +++ b/arch/arm64/kernel/ptrace.c
> @@ -76,7 +76,7 @@ static void ptrace_hbptriggered(struct perf_event *bp,
>   		.si_addr	= (void __user *)(bkpt->trigger),
>   	};
>
> -#ifdef CONFIG_COMPAT
> +#ifdef CONFIG_AARCH32_EL0
>   	int i;
>
>   	if (!is_compat_task())
> @@ -651,7 +651,7 @@ static const struct user_regset_view user_aarch64_view = {
>   	.regsets = aarch64_regsets, .n = ARRAY_SIZE(aarch64_regsets)
>   };
>
> -#ifdef CONFIG_COMPAT
> +#ifdef CONFIG_AARCH32_EL0
>   #include <linux/compat.h>
>
>   enum compat_regset {
> @@ -853,7 +853,7 @@ static int compat_tls_set(struct task_struct *target,
>   static const struct user_regset aarch32_regsets[] = {
>   	[REGSET_COMPAT_GPR] = {
>   		.core_note_type = NT_PRSTATUS,
> -		.n = COMPAT_ELF_NGREG,
> +		.n = COMPAT_A32_ELF_NGREG,

Commit 5d220ff9 "arm64: Better native ptrace support for compat tasks" added
struct user_regset aarch32_ptrace_regsets[]
and hence one more COMPAT_ELF_NGREG, which is not handled by this patch.
This resulted in the following build failure in my ILP32 configuration (arch/arm64/configs/defconfig
plus CONFIG_AARCH32_EL0=y and CONFIG_ARM64_ILP32=y):
-----8<-----
  ../arch/arm64/kernel/ptrace.c:880:8: error: 'COMPAT_ELF_NGREG' undeclared here (not in a function)
     .n = COMPAT_ELF_NGREG,
          ^
-----8<-----

>   		.size = sizeof(compat_elf_greg_t),
>   		.align = sizeof(compat_elf_greg_t),
>   		.get = compat_gpr_get,
> @@ -1109,8 +1109,8 @@ static int compat_ptrace_sethbpregs(struct task_struct *tsk, compat_long_t num,
>   }
>   #endif	/* CONFIG_HAVE_HW_BREAKPOINT */
>
> -long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
> -			compat_ulong_t caddr, compat_ulong_t cdata)
> +long compat_a32_arch_ptrace(struct task_struct *child, compat_long_t request,
> +			    compat_ulong_t caddr, compat_ulong_t cdata)
>   {
>   	unsigned long addr = caddr;
>   	unsigned long data = cdata;
> @@ -1186,11 +1186,28 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
>
>   	return ret;
>   }
> -#endif /* CONFIG_COMPAT */
> +#else /* !CONFIG_AARCH32_EL0 */
> +long compat_a32_arch_ptrace(struct task_struct *child, compat_long_t request,
> +			    compat_ulong_t caddr, compat_ulong_t cdata)
> +{
> +	return -1;
> +}
> +#endif /* !CONFIG_AARCH32_EL0 */

Building with arm64's defconfig (CONFIG_AARCH32_EL0, CONFIG_COMPAT, and CONFIG_ARM64_ILP32 aren't set)
fails this way - due to compat_[u]long_t not being defined in !CONFIG_COMPAT case:

-----8<-----
../arch/arm64/kernel/ptrace.c:1190:56: error: unknown type name 'compat_long_t'
  long compat_a32_arch_ptrace(struct task_struct *child, compat_long_t request,
                                                         ^
../arch/arm64/kernel/ptrace.c:1191:8: error: unknown type name 'compat_ulong_t'
         compat_ulong_t caddr, compat_ulong_t cdata)
         ^
../arch/arm64/kernel/ptrace.c:1191:30: error: unknown type name 'compat_ulong_t'
         compat_ulong_t caddr, compat_ulong_t cdata)
                               ^
-----8<-----

> +#ifdef CONFIG_COMPAT
> +long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
> +			compat_ulong_t caddr, compat_ulong_t cdata)
> +{
> +	if (is_compat_task())
> +		return compat_a32_arch_ptrace(child, request, caddr, cdata);
> +	return compat_ptrace_request(child, request, caddr, cdata);
> +}
> +#endif
> +
>
>   const struct user_regset_view *task_user_regset_view(struct task_struct *task)
>   {
> -#ifdef CONFIG_COMPAT
> +#ifdef CONFIG_AARCH32_EL0
>   	/*
>   	 * Core dumping of 32-bit tasks or compat ptrace requests must use the
>   	 * user_aarch32_view compatible with arm32. Native ptrace requests on
> diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c
> index e18c48c..964a2a4 100644
> --- a/arch/arm64/kernel/signal.c
> +++ b/arch/arm64/kernel/signal.c
> @@ -414,3 +414,18 @@ asmlinkage void do_notify_resume(struct pt_regs *regs,
>   		fpsimd_restore_current_state();
>
>   }
> +
> +/*
> + * Some functions are needed for compat ptrace but we don't define
> + * them if we don't have AARCH32 support compiled in
> + */
> +#if defined CONFIG_COMPAT && !defined CONFIG_AARCH32_EL0
> +int copy_siginfo_to_user32(compat_siginfo_t __user *to, const siginfo_t *from)
> +{
> +	return -EFAULT;
> +}
> +int copy_siginfo_from_user32(siginfo_t *to, compat_siginfo_t __user *from)
> +{
> +	return -EFAULT;
> +}
> +#endif
> diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c
> index f93aae5..9ce9894 100644
> --- a/arch/arm64/kernel/traps.c
> +++ b/arch/arm64/kernel/traps.c
> @@ -363,7 +363,7 @@ long compat_arm_syscall(struct pt_regs *regs);
>
>   asmlinkage long do_ni_syscall(struct pt_regs *regs)
>   {
> -#ifdef CONFIG_COMPAT
> +#ifdef CONFIG_AARCH32_EL0
>   	long ret;
>   	if (is_compat_task()) {
>   		ret = compat_arm_syscall(regs);
> diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c
> index 97bc68f..26352a6 100644
> --- a/arch/arm64/kernel/vdso.c
> +++ b/arch/arm64/kernel/vdso.c
> @@ -49,7 +49,7 @@ static union {
>   } vdso_data_store __page_aligned_data;
>   struct vdso_data *vdso_data = &vdso_data_store.data;
>
> -#ifdef CONFIG_COMPAT
> +#ifdef CONFIG_AARCH32_EL0
>   /*
>    * Create and map the vectors page for AArch32 tasks.
>    */
> @@ -107,7 +107,7 @@ int aarch32_setup_vectors_page(struct linux_binprm *bprm, int uses_interp)
>
>   	return PTR_ERR_OR_ZERO(ret);
>   }
> -#endif /* CONFIG_COMPAT */
> +#endif /* CONFIG_AARCH32_EL0 */
>
>   static struct vm_special_mapping vdso_spec[2];
>
>

^ permalink raw reply	[flat|nested] 96+ messages in thread

* Re: [PATCH v5 10/23] arm64: introduce is_a32_task and is_a32_thread (for AArch32 compat)
  2015-09-29 22:14   ` Yury Norov
@ 2015-10-06  9:21     ` Andrey Konovalov
  -1 siblings, 0 replies; 96+ messages in thread
From: Andrey Konovalov @ 2015-10-06  9:21 UTC (permalink / raw)
  To: Yury Norov, linux-arm-kernel, linux-kernel, catalin.marinas,
	arnd, agraf, bamvor.zhangjian
  Cc: yury.norov, klimov.linux, apinski, philipp.tomsich, christoph.muellner

Hi Yury,

With this patch set 4.3 kernel fails to build with arch/arm64/configs/defconfig plus CONFIG_AARCH32_EL0=y
and CONFIG_ARM64_ILP32=y giving the following three errors (the 3d one is warning actually):

-----8<-----
13:21:16 In file included from ../arch/arm64/kernel/process.c:48:0:
13:21:16 ../arch/arm64/include/asm/compat.h:370:38: error: macro "is_compat_task" passed 1 arguments, but takes just 0
13:21:16  static inline int is_compat_task(void)
13:21:16                                       ^
13:21:16 ../arch/arm64/include/asm/compat.h:371:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
13:21:16  {
13:21:16  ^
13:21:16 ../arch/arm64/include/asm/compat.h:375:19: error: redefinition of 'is_compat_thread'
13:21:16  static inline int is_compat_thread(struct thread_info *thread)
13:21:16                    ^
13:21:16 ../arch/arm64/include/asm/compat.h:350:19: note: previous definition of 'is_compat_thread' was here
13:21:16  static inline int is_compat_thread(struct thread_info *thread)
13:21:16                    ^
13:21:16 ../arch/arm64/include/asm/compat.h: In function 'is_compat_thread':
13:21:16 ../arch/arm64/include/asm/compat.h:377:2: error: implicit declaration of function 'is_a32_compat_thread' 
[-Werror=implicit-function-declaration]
13:21:16   return is_a32_compat_thread(thread) || is_ilp32_compat_thread(thread);
13:21:16   ^
13:21:16 cc1: some warnings being treated as errors
-----8<-----

See more details below.

Thanks,
Andrey

On 09/30/2015 01:14 AM, Yury Norov wrote:
> From: Andrew Pinski <apinski@cavium.com>
>
> This patch introduces is_a32_compat_task and is_a32_thread so it is
> easier
> to say this is a a32 specific thread or a generic compat thread/task.
>
> Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
> Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
> Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>
>
> diff --git a/arch/arm64/include/asm/compat.h b/arch/arm64/include/asm/compat.h
> index 7fbed69..3a2976d 100644
> --- a/arch/arm64/include/asm/compat.h
> +++ b/arch/arm64/include/asm/compat.h
> @@ -299,15 +299,25 @@ struct compat_shmid64_ds {
>   	compat_ulong_t __unused5;
>   };
>
> -static inline int is_compat_task(void)
> +#ifdef CONFIG_AARCH32_EL0
> +static inline int is_a32_compat_task(void)
>   {
>   	return test_thread_flag(TIF_32BIT);
>   }
> -
> -static inline int is_compat_thread(struct thread_info *thread)
> +static inline int is_a32_compat_thread(struct thread_info *thread)
>   {
>   	return test_ti_thread_flag(thread, TIF_32BIT);
>   }
> +#else
> +static inline int is_a32_compat_task(void)
> +{
> +	return 0;
> +}
> +static inline int is_a32_compat_thread(struct thread_info *thread)
> +{
> +	return 0;
> +}
> +#endif
>
>   #else /* !CONFIG_COMPAT */
>
> @@ -316,6 +326,21 @@ static inline int is_compat_thread(struct thread_info *thread)

- this misprint is the reason for the last two errors. That is_compat_thread above
should be is_a32_compat_thread.

>   	return 0;
>   }
>
> +static inline int is_a32_compat_task(void)
> +{
> +	return 0;
> +}
> +
>   #endif /* CONFIG_COMPAT */
> +
> +static inline int is_compat_task(void)
> +{
> +	return is_a32_compat_task();
> +}

- the above definition causes the 1st of the errors as in the !CONFIG_COMPAT case
include/linux/compat.h has:

-----8<-----
#define is_compat_task() (0)
-----8<-----

is_compat_task() should not be defined outside #ifdef CONFIG_COMPAT.

> +static inline int is_compat_thread(struct thread_info *thread)
> +{
> +	return is_a32_compat_thread(thread);
> +}
>   #endif /* __KERNEL__ */
>   #endif /* __ASM_COMPAT_H */
<snip>


^ permalink raw reply	[flat|nested] 96+ messages in thread

* [PATCH v5 10/23] arm64: introduce is_a32_task and is_a32_thread (for AArch32 compat)
@ 2015-10-06  9:21     ` Andrey Konovalov
  0 siblings, 0 replies; 96+ messages in thread
From: Andrey Konovalov @ 2015-10-06  9:21 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Yury,

With this patch set 4.3 kernel fails to build with arch/arm64/configs/defconfig plus CONFIG_AARCH32_EL0=y
and CONFIG_ARM64_ILP32=y giving the following three errors (the 3d one is warning actually):

-----8<-----
13:21:16 In file included from ../arch/arm64/kernel/process.c:48:0:
13:21:16 ../arch/arm64/include/asm/compat.h:370:38: error: macro "is_compat_task" passed 1 arguments, but takes just 0
13:21:16  static inline int is_compat_task(void)
13:21:16                                       ^
13:21:16 ../arch/arm64/include/asm/compat.h:371:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
13:21:16  {
13:21:16  ^
13:21:16 ../arch/arm64/include/asm/compat.h:375:19: error: redefinition of 'is_compat_thread'
13:21:16  static inline int is_compat_thread(struct thread_info *thread)
13:21:16                    ^
13:21:16 ../arch/arm64/include/asm/compat.h:350:19: note: previous definition of 'is_compat_thread' was here
13:21:16  static inline int is_compat_thread(struct thread_info *thread)
13:21:16                    ^
13:21:16 ../arch/arm64/include/asm/compat.h: In function 'is_compat_thread':
13:21:16 ../arch/arm64/include/asm/compat.h:377:2: error: implicit declaration of function 'is_a32_compat_thread' 
[-Werror=implicit-function-declaration]
13:21:16   return is_a32_compat_thread(thread) || is_ilp32_compat_thread(thread);
13:21:16   ^
13:21:16 cc1: some warnings being treated as errors
-----8<-----

See more details below.

Thanks,
Andrey

On 09/30/2015 01:14 AM, Yury Norov wrote:
> From: Andrew Pinski <apinski@cavium.com>
>
> This patch introduces is_a32_compat_task and is_a32_thread so it is
> easier
> to say this is a a32 specific thread or a generic compat thread/task.
>
> Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
> Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
> Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>
>
> diff --git a/arch/arm64/include/asm/compat.h b/arch/arm64/include/asm/compat.h
> index 7fbed69..3a2976d 100644
> --- a/arch/arm64/include/asm/compat.h
> +++ b/arch/arm64/include/asm/compat.h
> @@ -299,15 +299,25 @@ struct compat_shmid64_ds {
>   	compat_ulong_t __unused5;
>   };
>
> -static inline int is_compat_task(void)
> +#ifdef CONFIG_AARCH32_EL0
> +static inline int is_a32_compat_task(void)
>   {
>   	return test_thread_flag(TIF_32BIT);
>   }
> -
> -static inline int is_compat_thread(struct thread_info *thread)
> +static inline int is_a32_compat_thread(struct thread_info *thread)
>   {
>   	return test_ti_thread_flag(thread, TIF_32BIT);
>   }
> +#else
> +static inline int is_a32_compat_task(void)
> +{
> +	return 0;
> +}
> +static inline int is_a32_compat_thread(struct thread_info *thread)
> +{
> +	return 0;
> +}
> +#endif
>
>   #else /* !CONFIG_COMPAT */
>
> @@ -316,6 +326,21 @@ static inline int is_compat_thread(struct thread_info *thread)

- this misprint is the reason for the last two errors. That is_compat_thread above
should be is_a32_compat_thread.

>   	return 0;
>   }
>
> +static inline int is_a32_compat_task(void)
> +{
> +	return 0;
> +}
> +
>   #endif /* CONFIG_COMPAT */
> +
> +static inline int is_compat_task(void)
> +{
> +	return is_a32_compat_task();
> +}

- the above definition causes the 1st of the errors as in the !CONFIG_COMPAT case
include/linux/compat.h has:

-----8<-----
#define is_compat_task() (0)
-----8<-----

is_compat_task() should not be defined outside #ifdef CONFIG_COMPAT.

> +static inline int is_compat_thread(struct thread_info *thread)
> +{
> +	return is_a32_compat_thread(thread);
> +}
>   #endif /* __KERNEL__ */
>   #endif /* __ASM_COMPAT_H */
<snip>

^ permalink raw reply	[flat|nested] 96+ messages in thread

* Re: [PATCH v5 03/23] arm64: rename COMPAT to AARCH32_EL0 in Kconfig
  2015-09-29 22:14   ` Yury Norov
@ 2015-10-06  9:21     ` Andrey Konovalov
  -1 siblings, 0 replies; 96+ messages in thread
From: Andrey Konovalov @ 2015-10-06  9:21 UTC (permalink / raw)
  To: Yury Norov, linux-arm-kernel, linux-kernel, catalin.marinas,
	arnd, agraf, bamvor.zhangjian
  Cc: yury.norov, klimov.linux, apinski, philipp.tomsich, christoph.muellner

On 09/30/2015 01:14 AM, Yury Norov wrote:
> From: Andrew Pinski <apinski@cavium.com>
>
> Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
> Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
> Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>
>
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index 07d1811..d1dc605 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -679,6 +679,11 @@ menu "Userspace binary formats"
>   source "fs/Kconfig.binfmt"
>
>   config COMPAT
> +	def_bool y
> +	depends on AARCH32_EL0
> +	select COMPAT_BINFMT_ELF

- this is already selected by AARCH32_EL0 below?

> +
> +config AARCH32_EL0
>   	bool "Kernel support for 32-bit EL0"
>   	depends on !ARM64_64K_PAGES || EXPERT
>   	select COMPAT_BINFMT_ELF

- ...here

> @@ -699,7 +704,7 @@ config COMPAT
>
>   config SYSVIPC_COMPAT
>   	def_bool y
> -	depends on COMPAT && SYSVIPC
> +	depends on AARCH32_EL0 && SYSVIPC
>
>   endmenu
>
>


^ permalink raw reply	[flat|nested] 96+ messages in thread

* [PATCH v5 03/23] arm64: rename COMPAT to AARCH32_EL0 in Kconfig
@ 2015-10-06  9:21     ` Andrey Konovalov
  0 siblings, 0 replies; 96+ messages in thread
From: Andrey Konovalov @ 2015-10-06  9:21 UTC (permalink / raw)
  To: linux-arm-kernel

On 09/30/2015 01:14 AM, Yury Norov wrote:
> From: Andrew Pinski <apinski@cavium.com>
>
> Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
> Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
> Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>
>
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index 07d1811..d1dc605 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -679,6 +679,11 @@ menu "Userspace binary formats"
>   source "fs/Kconfig.binfmt"
>
>   config COMPAT
> +	def_bool y
> +	depends on AARCH32_EL0
> +	select COMPAT_BINFMT_ELF

- this is already selected by AARCH32_EL0 below?

> +
> +config AARCH32_EL0
>   	bool "Kernel support for 32-bit EL0"
>   	depends on !ARM64_64K_PAGES || EXPERT
>   	select COMPAT_BINFMT_ELF

- ...here

> @@ -699,7 +704,7 @@ config COMPAT
>
>   config SYSVIPC_COMPAT
>   	def_bool y
> -	depends on COMPAT && SYSVIPC
> +	depends on AARCH32_EL0 && SYSVIPC
>
>   endmenu
>
>

^ permalink raw reply	[flat|nested] 96+ messages in thread

* Re: [PATCH v5 10/23] arm64: introduce is_a32_task and is_a32_thread (for AArch32 compat)
  2015-10-06  9:21     ` Andrey Konovalov
@ 2015-10-07 16:13       ` Yury Norov
  -1 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-10-07 16:13 UTC (permalink / raw)
  To: Andrey Konovalov
  Cc: linux-arm-kernel, linux-kernel, catalin.marinas, arnd, agraf,
	bamvor.zhangjian, yury.norov, klimov.linux, apinski,
	philipp.tomsich, christoph.muellner, Kapoor, Prasun

On Tue, Oct 06, 2015 at 12:21:33PM +0300, Andrey Konovalov wrote:
> Hi Yury,
> 
> With this patch set 4.3 kernel fails to build with arch/arm64/configs/defconfig plus CONFIG_AARCH32_EL0=y
> and CONFIG_ARM64_ILP32=y giving the following three errors (the 3d one is warning actually):

[...]

> Thanks,
> Andrey

Hi, Andrey,

Thank you. If you're interested in early testing, you can pull
my working branch here:

https://github.com/norov/linux/tree/ilp

There, build for all combinations of CONFIG_AARCH32_EL0 and
CONFIG_ARM64_ILP32 is fixed.

I can also share my testing tools, if needed.

BR,
Yury.

^ permalink raw reply	[flat|nested] 96+ messages in thread

* [PATCH v5 10/23] arm64: introduce is_a32_task and is_a32_thread (for AArch32 compat)
@ 2015-10-07 16:13       ` Yury Norov
  0 siblings, 0 replies; 96+ messages in thread
From: Yury Norov @ 2015-10-07 16:13 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Oct 06, 2015 at 12:21:33PM +0300, Andrey Konovalov wrote:
> Hi Yury,
> 
> With this patch set 4.3 kernel fails to build with arch/arm64/configs/defconfig plus CONFIG_AARCH32_EL0=y
> and CONFIG_ARM64_ILP32=y giving the following three errors (the 3d one is warning actually):

[...]

> Thanks,
> Andrey

Hi, Andrey,

Thank you. If you're interested in early testing, you can pull
my working branch here:

https://github.com/norov/linux/tree/ilp

There, build for all combinations of CONFIG_AARCH32_EL0 and
CONFIG_ARM64_ILP32 is fixed.

I can also share my testing tools, if needed.

BR,
Yury.

^ permalink raw reply	[flat|nested] 96+ messages in thread

end of thread, other threads:[~2015-10-07 16:14 UTC | newest]

Thread overview: 96+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-29 22:13 [PATCH v5 00/23] ILP32 for ARM64 Yury Norov
2015-09-29 22:13 ` Yury Norov
2015-09-29 22:13 ` [PATCH v5 01/23] arm64:ilp32: add documentation on the ILP32 ABI " Yury Norov
2015-09-29 22:13   ` Yury Norov
2015-09-29 22:13 ` [PATCH v5 02/23] arm64: ensure the kernel is compiled for LP64 Yury Norov
2015-09-29 22:13   ` Yury Norov
2015-09-29 22:14 ` [PATCH v5 03/23] arm64: rename COMPAT to AARCH32_EL0 in Kconfig Yury Norov
2015-09-29 22:14   ` Yury Norov
2015-10-06  9:21   ` Andrey Konovalov
2015-10-06  9:21     ` Andrey Konovalov
2015-09-29 22:14 ` [PATCH v5 04/23] arm64: change some CONFIG_COMPAT over to use CONFIG_AARCH32_EL0 instead Yury Norov
2015-09-29 22:14   ` Yury Norov
2015-09-30  3:36   ` kbuild test robot
2015-09-30  3:36     ` kbuild test robot
2015-09-30  5:35   ` kbuild test robot
2015-09-30  5:35     ` kbuild test robot
2015-10-06  9:21   ` Andrey Konovalov
2015-10-06  9:21     ` Andrey Konovalov
2015-09-29 22:14 ` [PATCH v5 05/23] arm64:ilp32: expose 'kernel_long' as 'long long' for ILP32 Yury Norov
2015-09-29 22:14   ` Yury Norov
2015-09-29 22:14 ` [PATCH v5 06/23] arm64:uapi: set __BITS_PER_LONG correctly for ILP32 and LP64 Yury Norov
2015-09-29 22:14   ` Yury Norov
2015-09-29 22:14 ` [PATCH v5 07/23] arm64:ilp32: share signal structures between ILP32 and LP64 ABIs Yury Norov
2015-09-29 22:14   ` Yury Norov
2015-09-29 22:14 ` [PATCH v5 08/23] arm64:ilp32: use 64bit syscall-names for ILP32 when passing 64bit registers Yury Norov
2015-09-29 22:14   ` Yury Norov
2015-09-29 22:14 ` [PATCH v5 09/23] arm64:ilp32: use non-compat syscall names for ILP32 as for LP64 Yury Norov
2015-09-29 22:14   ` Yury Norov
2015-09-29 22:14 ` [PATCH v5 10/23] arm64: introduce is_a32_task and is_a32_thread (for AArch32 compat) Yury Norov
2015-09-29 22:14   ` Yury Norov
2015-09-30  3:48   ` kbuild test robot
2015-09-30  3:48     ` kbuild test robot
2015-10-06  9:21   ` Andrey Konovalov
2015-10-06  9:21     ` Andrey Konovalov
2015-10-07 16:13     ` Yury Norov
2015-10-07 16:13       ` Yury Norov
2015-09-29 22:14 ` [PATCH v5 11/23] arm64:ilp32: add is_ilp32_compat_{task,thread} and TIF_32BIT_AARCH64 Yury Norov
2015-09-29 22:14   ` [PATCH v5 11/23] arm64:ilp32: add is_ilp32_compat_{task, thread} " Yury Norov
2015-09-29 22:14 ` [PATCH v5 12/23] arm64:ilp32: COMPAT_USE_64BIT_TIME is true for ILP32 tasks Yury Norov
2015-09-29 22:14   ` Yury Norov
2015-09-29 22:14 ` [PATCH v5 13/23] arm64:ilp32: share HWCAP between LP64 and ILP32 Yury Norov
2015-09-29 22:14   ` Yury Norov
2015-09-29 22:14 ` [PATCH v5 14/23] arm64:ilp32 use the native LP64 'start_thread' for ILP32 threads Yury Norov
2015-09-29 22:14   ` Yury Norov
2015-09-29 22:14 ` [PATCH v5 15/23] arm64:ilp32: support core dump generation for ILP32 Yury Norov
2015-09-29 22:14   ` Yury Norov
2015-09-29 22:14 ` [PATCH v5 16/23] arm64: add support for starting ILP32 (ELFCLASS32) binaries Yury Norov
2015-09-29 22:14   ` Yury Norov
2015-09-29 22:14 ` [PATCH v5 17/23] arm64:ilp32: add vdso-ilp32 and use for signal return Yury Norov
2015-09-29 22:14   ` Yury Norov
2015-09-30  4:06   ` Nathan Lynch
2015-09-30  4:06     ` Nathan Lynch
2015-10-01 19:44     ` Yury Norov
2015-10-01 19:44       ` Yury Norov
2015-10-01 19:54       ` Dr. Philipp Tomsich
2015-10-01 19:54         ` Dr. Philipp Tomsich
2015-09-29 22:14 ` [PATCH v5 18/23] ptrace: Allow compat to use the native siginfo Yury Norov
2015-09-29 22:14   ` Yury Norov
2015-09-29 22:14 ` [PATCH v5 19/23] arm64:ilp32: add sys_ilp32.c and a separate table (in entry.S) to use it Yury Norov
2015-09-29 22:14   ` Yury Norov
2015-09-29 22:14 ` [PATCH v5 20/23] arm64:ilp32: use the native siginfo instead of the compat siginfo Yury Norov
2015-09-29 22:14   ` Yury Norov
2015-09-29 22:14 ` [PATCH v5 21/23] arm64:ilp32: change COMPAT_ELF_PLATFORM to report a a subplatform for ILP32 Yury Norov
2015-09-29 22:14   ` Yury Norov
2015-09-29 22:14 ` [PATCH v5 22/23] aarch64: ilp32: msgrcv, msgsnd handlers Yury Norov
2015-09-29 22:14   ` Yury Norov
2015-09-29 22:14 ` [PATCH v5 23/23] arm64:ilp32: add ARM64_ILP32 to Kconfig Yury Norov
2015-09-29 22:14   ` Yury Norov
2015-09-30 10:19 ` [PATCH v5 00/23] ILP32 for ARM64 Catalin Marinas
2015-09-30 10:19   ` Catalin Marinas
2015-09-30 16:41   ` Mark Brown
2015-09-30 16:41     ` Mark Brown
2015-10-01 11:19     ` Catalin Marinas
2015-10-01 11:19       ` Catalin Marinas
2015-10-01 11:36       ` Mark Brown
2015-10-01 11:36         ` Mark Brown
2015-10-01 16:42         ` Andrey Konovalov
2015-10-01 16:42           ` Andrey Konovalov
2015-10-01 19:33     ` Yury Norov
2015-10-01 19:33       ` Yury Norov
2015-10-01 19:15   ` Yury Norov
2015-10-01 19:15     ` Yury Norov
2015-10-01 21:28     ` Arnd Bergmann
2015-10-01 21:28       ` Arnd Bergmann
2015-10-01 21:49       ` Pinski, Andrew
2015-10-01 21:49         ` Pinski, Andrew
2015-10-02  9:37         ` Catalin Marinas
2015-10-02  9:37           ` Catalin Marinas
2015-10-03  2:18           ` Kapoor, Prasun
2015-10-03  2:18             ` Kapoor, Prasun
2015-10-05 15:58             ` Catalin Marinas
2015-10-05 15:58               ` Catalin Marinas
2015-10-05 21:00               ` Pinski, Andrew
2015-10-05 21:00                 ` Pinski, Andrew
2015-10-05 19:10         ` Yury Norov
2015-10-05 19:10           ` Yury Norov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.