Unverified Commit 9667e28e authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!3026 Backport ARM64-ILP32 patches

Merge Pull Request from: @ci-robot 
 
PR sync from: Jinjie Ruan <ruanjinjie@huawei.com>
https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/CRH6J6UKFIG4ZTR3UE6RNSGNTLXZYYMB/ 
Backport ILP32 for ARM64 patches to OLK6.6 form openEuler-23.09.

Andrew Pinski (3):
  arm64: rename COMPAT to AARCH32_EL0
  arm64: uapi: set __BITS_PER_LONG correctly for ILP32 and LP64
  arm64:ilp32: add ARM64_ILP32 to Kconfig

Chen Jiahao (4):
  arm64: fix AUDIT_ARCH_AARCH64ILP32 bug on audit subsystem
  arm64: fix address limit problem with TASK_SIZE_MAX
  arm64: set 32-bit compatible TASK_SIZE_MAX to fix U32 libc_write_01
    error
  arm64: fix image size inflation with CONFIG_COMPAT_TASK_SIZE

Dave Martin (1):
  arm64: signal: Make parse_user_sigframe() independent of rt_sigframe
    layout

James Morse (1):
  ptrace: Add compat PTRACE_{G,S}ETSIGMASK handlers

Philipp Tomsich (1):
  arm64:ilp32: add vdso-ilp32 and use for signal return

Xiongfeng Wang (6):
  arm64: rename functions that reference compat term
  ilp32: avoid clearing upper 32 bits of syscall return value for ilp32
  ilp32: skip ARM erratum 1418040 for ilp32 application
  arm64: fix abi change caused by ILP32
  ilp32: fix compile problem when ARM64_ILP32 and UBSAN are both enabled

Yury Norov (14):
  thread: move thread bits accessors to separated file
  arm64: ilp32: add documentation on the ILP32 ABI for ARM64
  arm64: introduce is_a32_compat_{task,thread} for AArch32 compat
  arm64: ilp32: add is_ilp32_compat_{task,thread} and TIF_32BIT_AARCH64
  arm64: introduce AUDIT_ARCH_AARCH64ILP32 for ilp32
  arm64: introduce binfmt_elf32.c
  arm64: change compat_elf_hwcap and compat_elf_hwcap2 prefix to a32
  arm64: ilp32: introduce binfmt_ilp32.c
  arm64: ilp32: share aarch32 syscall handlers
  arm64: ilp32: introduce syscall table for ILP32
  arm64: signal: share lp64 signal structures and routines to ilp32
  arm64: signal32: move ilp32 and aarch32 common code to separated file
  arm64: ilp32: introduce ilp32-specific sigframe and ucontext
  arm64: ptrace: handle ptrace_request differently for aarch32 and ilp32

Zhen Lei (1):
  arm64: replace is_compat_task() with is_ilp32_compat_task() in
    TASK_SIZE_MAX


-- 
2.34.1
 
https://gitee.com/openeuler/kernel/issues/I8JVJ3 
 
Link:https://gitee.com/openeuler/kernel/pulls/3026

 

Reviewed-by: default avatarZhang Jianhua <chris.zjh@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parents 25d100f4 983fdfeb
Loading
Loading
Loading
Loading
+52 −0
Original line number Diff line number Diff line
ILP32 AARCH64 SYSCALL ABI
=========================

This document describes the ILP32 syscall ABI and where it differs
from the generic compat linux syscall interface.

ILP32 is acronym for memory model which stands for "Integers, Longs and
Pointers are 32-bit". The main purpose of ILP32 in Linux kernel is providing
compatibility with 32-bit legacy code. Also, ILP32 binaries look better in some
performance tests. ARM has AN490 document which coves ILP32 details for ARM64
platform:
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dai0490a/ar01s01.html

AARCH64/ILP32 userspace may pass garbage in the top halve of w0-w7 registers
(syscall arguments). So top 32 bits are zeroed for them.

Comparing to AARCH32, AARCH64/ILP32 has 64-bit length of following types:
ino_t       is u64 type.
off_t       is s64 type.
blkcnt_t    is s64 type.
fsblkcnt_t  is u64 type.
fsfilcnt_t  is u64 type.
rlim_t      is u64 type.

AARCH64/ILP32 ABI uses standard syscall table which can be found at
include/uapi/asm-generic/unistd.h, with the exceptions listed below.

Syscalls which pass 64-bit values are handled by the code shared from
AARCH32 and pass that value as a pair. Following syscalls are affected:
fadvise64_64()
fallocate()
ftruncate64()
pread64()
pwrite64()
readahead()
sync_file_range()
truncate64()

ptrace() syscall is handled by compat version.

shmat() syscall is handled by non-compat handler as aarch64/ilp32 has no
limitation on 4-pages alignment for shared memory.

statfs() and fstatfs() take the size of struct statfs as an argument.
It is calculated differently in kernel and user spaces. So AARCH32 handlers
are taken to handle it.

struct rt_sigframe is redefined and contains struct compat_siginfo,
as compat syscalls expect, and struct ilp32_ucontext, to handle
AARCH64 register set and 32-bit userspace register representation.

elf_gregset_t is taken from lp64 to handle registers properly.
+23 −3
Original line number Diff line number Diff line
@@ -583,7 +583,7 @@ config ARM64_ERRATUM_1742098

config ARM64_ERRATUM_845719
	bool "Cortex-A53: 845719: a load might read incorrect data"
	depends on COMPAT
	depends on AARCH32_EL0
	default y
	help
	  This option adds an alternative code sequence to work around ARM
@@ -1597,7 +1597,15 @@ config ARM64_TAGGED_ADDR_ABI
	  to system calls as pointer arguments. For details, see
	  Documentation/arch/arm64/tagged-address-abi.rst.

menuconfig COMPAT
config ARM64_ILP32
	bool "Kernel support for ILP32"
	depends on !ARM64_PTR_AUTH
	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.

menuconfig AARCH32_EL0
	bool "Kernel support for 32-bit EL0"
	depends on ARM64_4K_PAGES || EXPERT
	select HAVE_UID16
@@ -1615,7 +1623,7 @@ menuconfig COMPAT

	  If you want to execute 32-bit userspace applications, say Y.

if COMPAT
if AARCH32_EL0

config KUSER_HELPERS
	bool "Enable kuser helpers page for 32-bit applications"
@@ -1669,8 +1677,16 @@ config THUMB2_COMPAT_VDSO
config COMPAT_ALIGNMENT_FIXUPS
	bool "Fix up misaligned multi-word loads and stores in user space"

config COMPAT_TASK_SIZE
	bool "Set 32-bit compatible task size"
	default n
	help
	  Set the task size with 32-bit limit, to be compatible with
	  32-bit EL0 tasks.

menuconfig ARMV8_DEPRECATED
	bool "Emulate deprecated/obsolete ARMv8 instructions"
	depends on AARCH32_EL0
	depends on SYSCTL
	help
	  Legacy software support may require certain instructions
@@ -2287,6 +2303,10 @@ config DMI

endmenu # "Boot options"

config COMPAT
	def_bool y
	depends on AARCH32_EL0 || ARM64_ILP32

menu "Power management options"

source "kernel/power/Kconfig"
+3 −0
Original line number Diff line number Diff line
@@ -203,6 +203,9 @@ ifdef CONFIG_COMPAT_VDSO
	$(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso32 \
	include/generated/vdso32-offsets.h arch/arm64/kernel/vdso32/vdso.so
endif
ifeq ($(CONFIG_ARM64_ILP32), y)
	$(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso-ilp32 include/generated/vdso-ilp32-offsets.h
endif
endif

include $(srctree)/scripts/Makefile.defconf
+2 −2
Original line number Diff line number Diff line
@@ -217,8 +217,8 @@ static inline int arch_timer_arch_init(void)
static inline void arch_timer_set_evtstrm_feature(void)
{
	cpu_set_named_feature(EVTSTRM);
#ifdef CONFIG_COMPAT
	compat_elf_hwcap |= COMPAT_HWCAP_EVTSTRM;
#ifdef CONFIG_AARCH32_EL0
	a32_elf_hwcap |= COMPAT_HWCAP_EVTSTRM;
#endif
}

+1 −17
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ typedef u16 compat_ipc_pid_t;
#include <linux/types.h>
#include <linux/sched.h>
#include <linux/sched/task_stack.h>
#include <asm/is_compat.h>

#ifdef __AARCH64EB__
#define COMPAT_UTS_MACHINE	"armv8b\0\0"
@@ -86,24 +87,7 @@ struct compat_statfs {
#define compat_user_stack_pointer() (user_stack_pointer(task_pt_regs(current)))
#define COMPAT_MINSIGSTKSZ	2048

static inline int is_compat_task(void)
{
	return test_thread_flag(TIF_32BIT);
}

static inline int is_compat_thread(struct thread_info *thread)
{
	return test_ti_thread_flag(thread, TIF_32BIT);
}

long compat_arm_syscall(struct pt_regs *regs, int scno);

#else /* !CONFIG_COMPAT */

static inline int is_compat_thread(struct thread_info *thread)
{
	return 0;
}

#endif /* CONFIG_COMPAT */
#endif /* __ASM_COMPAT_H */
Loading