linux-user: Add AArch64 support
PATCH v2 10/12 linux-user: Add AArch64 support
From: Alexander Graf <[email protected]>
This patch adds support for AArch64 in all the small corners of linux-user and beyond.
Signed-off-by Alexander Graf <[email protected]>
--- default-configs/aarch64-linux-user.mak | 3 +++ linux-user/arm/syscall.h | 46 +++++++++++++++++++++++++++----- linux-user/elfload.c | 15 +++++++++-- linux-user/main.c | 9 +++++++ target-arm/cpu.h | 20 +++++++++++--- 5 files changed, 81 insertions(+), 12 deletions(-) create mode 100644 default-configs/aarch64-linux-user.mak
default-configs/aarch64-linux-user.mak new file +3 -0
@@ -0,0 +1,3 @@ +# Default configuration for arm-linux-user + +CONFIG_GDBSTUB_XML=y
linux-user/arm/syscall.h +40 -6
59 lines not on this page · raw message
linux-user/elfload.c +13 -2
@@ -267,16 +267,26 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUX86State *en#define ELF_START_MMAP 0x80000000 -#define elf_check_arch (x) ( (x) == EM_ARM ) +#define elf_check_arch (x) ( (x) == ELF_MACHINE ) +#define ELF_ARCH ELF_MACHINE + +#ifdef TARGET_AARCH64 +#define ELF_CLASS ELFCLASS64 +#else #define ELF_CLASS ELFCLASS32 -#define ELF_ARCH EM_ARM +#endif static inline void init_thread (struct target_pt_regs *regs,struct image_info *infop) {abi_long stack = infop->start_stack;memset (regs,0 ,sizeof (*regs)); + +#ifdef TARGET_AARCH64 + regs->pc = infop->entry & ~0x3ULL ; + regs->sp = stack; +#else regs->ARM_cpsr =0x10 ;if (infop->entry &1 ) regs->ARM_cpsr |=CPSR_T ;
@@ -290,6 +300,7 @@ static inline void init_thread(struct target_pt_regs *regs,/* For uClinux PIC binaries. */ /* XXX: Linux does this only on ARM with no MMU (do we care ?) */ regs->ARM_r10 = infop->start_data; +#endif }#define ELF_NREG 18
linux-user/main.c +9 -0
@@ -3890,6 +3890,15 @@ int main(int argc, char **argv, char **envp)cpu_x86_load_seg (env,R_FS ,0 );cpu_x86_load_seg (env,R_GS ,0 );#endif +#elif defined(TARGET_AARCH64) + { +int i; +for (i =0 ; i <31 ; i++) { + env->xregs[i] = regs->regs[i]; + } + env->pc = regs->pc; + env->sp = regs->sp; + }#elif defined(TARGET_ARM) {int i;
target-arm/cpu.h +16 -4
@@ -288,7 +288,11 @@ int cpu_arm_handle_mmu_fault (CPUARMState *env, target_ulong address, int rw,static inline void cpu_set_tls (CPUARMState *env,target_ulong newtls) { - env->cp15.c13_tls2 = newtls; +if (is_a64 (env)) { + env->sr.tpidr_el0 = newtls; + }else { + env->cp15.c13_tls2 = newtls; + } }#define CPSR_M (0x1f)
@@ -694,9 +698,17 @@ static inline int cpu_mmu_index (CPUARMState *env)#if defined(CONFIG_USER_ONLY )static inline void cpu_clone_regs (CPUARMState *env,target_ulong newsp) { -if (newsp) - env->regs[13 ] = newsp; - env->regs[0 ] =0 ; +if (is_a64 (env)) { +if (newsp) { + env->sp = newsp; + } + env->xregs[0 ] =0 ; + }else { +if (newsp) { + env->regs[13 ] = newsp; + } + env->regs[0 ] =0 ; + } }#endif
Signature · 1 line
1.7.9.5