Skip to content

Commit a795a38

Browse files
wildea01ctmarinas
authored andcommitted
arm64: compat: add support for big-endian (BE8) AArch32 binaries
This patch adds support for BE8 AArch32 tasks to the compat layer. Signed-off-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent 94ed1f2 commit a795a38

4 files changed

Lines changed: 25 additions & 0 deletions

File tree

‎arch/arm64/include/asm/compat.h‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@
2626
#include <linux/ptrace.h>
2727

2828
#define COMPAT_USER_HZ 100
29+
#ifdef __AARCH64EB__
30+
#define COMPAT_UTS_MACHINE "armv8b\0\0"
31+
#else
2932
#define COMPAT_UTS_MACHINE "armv8l\0\0"
33+
#endif
3034

3135
typedef u32 compat_size_t;
3236
typedef s32 compat_ssize_t;
@@ -73,13 +77,23 @@ struct compat_timeval {
7377
};
7478

7579
struct compat_stat {
80+
#ifdef __AARCH64EB__
81+
short st_dev;
82+
short __pad1;
83+
#else
7684
compat_dev_t st_dev;
85+
#endif
7786
compat_ino_t st_ino;
7887
compat_mode_t st_mode;
7988
compat_ushort_t st_nlink;
8089
__compat_uid16_t st_uid;
8190
__compat_gid16_t st_gid;
91+
#ifdef __AARCH64EB__
92+
short st_rdev;
93+
short __pad2;
94+
#else
8295
compat_dev_t st_rdev;
96+
#endif
8397
compat_off_t st_size;
8498
compat_off_t st_blksize;
8599
compat_off_t st_blocks;

‎arch/arm64/include/asm/elf.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,12 @@ extern unsigned long arch_randomize_brk(struct mm_struct *mm);
162162
#define arch_randomize_brk arch_randomize_brk
163163

164164
#ifdef CONFIG_COMPAT
165+
166+
#ifdef __AARCH64EB__
167+
#define COMPAT_ELF_PLATFORM ("v8b")
168+
#else
165169
#define COMPAT_ELF_PLATFORM ("v8l")
170+
#endif
166171

167172
#define COMPAT_ELF_ET_DYN_BASE (randomize_et_dyn(2 * TASK_SIZE_32 / 3))
168173

‎arch/arm64/include/asm/processor.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ static inline void compat_start_thread(struct pt_regs *regs, unsigned long pc,
107107
regs->pstate = COMPAT_PSR_MODE_USR;
108108
if (pc & 1)
109109
regs->pstate |= COMPAT_PSR_T_BIT;
110+
111+
#ifdef __AARCH64EB__
112+
regs->pstate |= COMPAT_PSR_E_BIT;
113+
#endif
114+
110115
regs->compat_sp = sp;
111116
}
112117
#endif

‎arch/arm64/include/asm/ptrace.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#define COMPAT_PSR_MODE_UND 0x0000001b
4343
#define COMPAT_PSR_MODE_SYS 0x0000001f
4444
#define COMPAT_PSR_T_BIT 0x00000020
45+
#define COMPAT_PSR_E_BIT 0x00000200
4546
#define COMPAT_PSR_F_BIT 0x00000040
4647
#define COMPAT_PSR_I_BIT 0x00000080
4748
#define COMPAT_PSR_A_BIT 0x00000100

0 commit comments

Comments
 (0)