linux-user: Split up elfload.c
Subsystems (2)
v2 cover linux-user: Split up elfload.c
The goal is to kill the massive target ifdef ladder in elfload.c.
The functions get moved to linux-user/target/elfload.c. The macros get moved to linux-user/target/target_elf.h. These are mostly use to parameterize include/elf.h or elfload.c.
The init_thread functions, storing into target_pt_regs, have been merged with target_cpu_copy_regs, copying out of target_pt_regs into CPUArchState. Merging these found a few bits of silliness where pt_regs fields were initialized but not used. To encourage this never to return, remove most target_pt_regs and hide the rest within the relevant signal.c.
Changes for v2:
- Cleanup semihosting user-only SYS_HEAPINFO.
- No more weak functions. Replaced with HAVE_* macros and strong fallback functions. If the HAVE_* macro is missing and the target provides its own function, we'll get a link error for duplicate symbols.
- No more target_coredump.c.inc. This required killing target_elf_gregset_t so that the function signatures could match for all targets.
- Misc other changes from review.
r~
Richard Henderson (95):
semihosting: Retrieve stack top from image_info
semihosting: Initialize heap once per process
linux-user: Create target/elfload.c files
linux-user: Move ppc uabi/asm/elf.h workaround to osdep.h
linux-user: Move get_elf_cpu_model to target/elfload.c
linux-user: Move get_elf_hwcap to {i386,x86_64}/elfload.c
linux-user: Move hwcap functions to {arm,aarch64}/elfload.c
linux-user: Move get_elf_hwcap to sparc/elfload.c
linux-user: Move hwcap functions to ppc/elfload.c
linux-user: Move get_elf_hwcap to loongarch64/elfload.c
linux-user: Move get_elf_hwcap to mips/elfload.c
linux-user: Move get_elf_hwcap to sh4/elfload.c
linux-user: Move hwcap functions to s390x/elfload.c
linux-user: Move get_elf_hwcap to riscv/elfload.c
linux-user: Remove ELF_HWCAP
linux-user: Remove ELF_HWCAP2
linux-user: Move get_elf_platform to {i386,x86_64}/elfload.c linux-user/i386: Return const data from get_elf_platform
linux-user: Move get_elf_platform to arm/elfload.c linux-user/loongarch64: Create get_elf_platform linux-user/hppa: Create get_elf_platform
linux-user: Remove ELF_PLATFORM
linux-user: Move get_elf_base_platform to mips/elfload.c
linux-user: Move target_cpu_copy_regs decl to qemu.h
linux-user: Create do_init_main_thread linux-user/i386: Create init_main_thread linux-user/arm: Create init_main_thread linux-user/arm: Remove a.out startup remenents linux-user/aarch64: Create init_main_thread linux-user/sparc: Create init_main_thread linux-user/ppc: Create init_main_thread linux-user/loongarch64: Create init_main_thread linux-user/mips: Create init_main_thread linux-user/microblaze: Create init_main_thread linux-user/openrisc: Create init_main_thread linux-user/sh4: Create init_main_thread linux-user/m68k: Create init_main_thread linux-user/alpha: Create init_main_thread linux-user/s390x: Create init_main_thread linux-user/riscv: Create init_main_thread linux-user/hppa: Create init_main_thread linux-user/xtensa: Create init_main_thread linux-user/hexagon: Create init_main_thread
linux-user: Remove do_init_main_thread
linux-user: Remove target_elf_greg_t
linux-user: Replace tswapreg with tswapl
linux-user: Unify elf_core_copy_regs signatures
linux-user: Declare elf_core_copy_regs in loader.h
linux-user: Remove USE_ELF_CORE_DUMP
linux-user: Move elf_core_copy_regs to {i386,x86_64}/elfload.c
linux-user: Move elf_core_copy_regs to arm/elfload.c
linux-user: Move elf_core_copy_regs to aarch64/elfload.c
linux-user: Move elf_core_copy_regs to ppc/elfload.c
linux-user: Move elf_core_copy_regs to loongarch64/elfload.c
linux-user: Move elf_core_copy_regs to mips/elfload.c
linux-user: Move elf_core_copy_regs to microblaze/elfload.c
linux-user: Move elf_core_copy_regs to openrisc/elfload.c
linux-user: Move elf_core_copy_regs to sh4/elfload.c
linux-user: Move elf_core_copy_regs to m68k/elfload.c
linux-user: Move elf_core_copy_regs to s390x/elfload.c
linux-user: Move elf_core_copy_regs to xtensa/elfload.c
linux-user: Move init_guest_commpage to x86_64/elfload.c
linux-user: Move init_guest_commpage to arm/elfload.c
linux-user: Move init_guest_commpage to hppa/elfload.c
linux-user: Replace init_guest_commpage macro with function
linux-user: Move get_vdso_image_info to arm/elfload.c
linux-user: Remove ELF_EXEC_PAGESIZE
linux-user: Remove redundant ELF_DATA definitons
linux-user: Move elf parameters to {i386,x86_64}/target_elf.h
linux-user: Move elf parameters to {arm,aarch64}/target_elf.h
linux-user: Move elf parameters to sparc/target_elf.h
linux-user: Move elf parameters to ppc/target_elf.h
linux-user: Move elf parameters to loongarch64/target_elf.h
linux-user: Move elf parameters to {mips,mips64}/target_elf.h
linux-user: Move elf parameters to microblaze/target_elf.h
linux-user: Move elf parameters to openrisc/target_elf.h
linux-user: Move elf parameters to sh4/target_elf.h
linux-user: Move elf parameters to m68k/target_elf.h
linux-user: Move elf parameters to alpha/target_elf.h
linux-user: Move elf parameters to s390x/target_elf.h
linux-user: Move elf parameters to riscv/target_elf.h
linux-user: Move elf parameters to hppa/target_elf.h
linux-user: Move elf parameters to xtensa/target_elf.h
linux-user: Move elf parameters to hexagon/target_elf.h
linux-user: Standardize on ELF_MACHINE not ELF_ARCH
linux-user: Rename elf_check_arch
linux-user: Remove ELIBBAD from elfload.c
linux-user: Remove MAP_DENYWRITE from elfload.c
linux-user: Move arch_parse_elf_property to aarch64/elfload.c
linux-user: Remove a.out declarations from elfload.c linux-user/sparc: Move target_pt_regs to signal.c linux-user/microblaze: Move target_pt_regs to signal.c linux-user/openrisc: Move target_pt_regs to signal.c linux-user/s390x: Move target_psw_t to signal.c
linux-user: Remove struct target_pt_regs from target_syscall.h
include/qemu/osdep.h | 8 + include/user/cpu_loop.h | 4 - linux-user/aarch64/target_elf.h | 21 +- linux-user/aarch64/target_syscall.h | 7 - linux-user/alpha/target_elf.h | 8 +- linux-user/alpha/target_syscall.h | 40 - linux-user/arm/target_elf.h | 17 +- linux-user/arm/target_proc.h | 4 +- linux-user/arm/target_syscall.h | 8 - linux-user/hexagon/target_elf.h | 30 +- linux-user/hexagon/target_syscall.h | 5 - linux-user/hppa/target_elf.h | 15 +- linux-user/hppa/target_syscall.h | 18 - linux-user/i386/target_elf.h | 38 +- linux-user/i386/target_syscall.h | 18 - linux-user/loader.h | 36 +- linux-user/loongarch64/target_elf.h | 16 +- linux-user/loongarch64/target_syscall.h | 23 - linux-user/m68k/target_elf.h | 15 +- linux-user/m68k/target_syscall.h | 16 - linux-user/microblaze/target_elf.h | 12 +- linux-user/microblaze/target_syscall.h | 44 - linux-user/mips/target_elf.h | 21 +- linux-user/mips/target_syscall.h | 19 - linux-user/mips64/target_elf.h | 43 +- linux-user/mips64/target_syscall.h | 16 - linux-user/openrisc/target_elf.h | 11 +- linux-user/openrisc/target_syscall.h | 11 - linux-user/ppc/target_elf.h | 50 +- linux-user/ppc/target_syscall.h | 28 - linux-user/qemu.h | 8 +- linux-user/riscv/target_elf.h | 17 +- linux-user/riscv/target_syscall.h | 35 - linux-user/s390x/target_elf.h | 14 +- linux-user/s390x/target_proc.h | 2 +- linux-user/s390x/target_syscall.h | 22 - linux-user/sh4/target_elf.h | 13 +- linux-user/sh4/target_syscall.h | 11 - linux-user/sparc/target_elf.h | 18 +- linux-user/sparc/target_syscall.h | 19 - linux-user/x86_64/target_elf.h | 21 +- linux-user/x86_64/target_syscall.h | 28 - linux-user/xtensa/target_elf.h | 9 +- linux-user/xtensa/target_syscall.h | 35 - hw/core/loader.c | 4 - linux-user/aarch64/cpu_loop.c | 22 +- linux-user/aarch64/elfload.c | 378 ++++ linux-user/alpha/cpu_loop.c | 11 +- linux-user/alpha/elfload.c | 11 + linux-user/arm/cpu_loop.c | 75 +- linux-user/arm/elfload.c | 276 +++ linux-user/elfload.c | 2159 +---------------------- linux-user/hexagon/cpu_loop.c | 8 +- linux-user/hexagon/elfload.c | 35 + linux-user/hppa/cpu_loop.c | 18 +- linux-user/hppa/elfload.c | 47 + linux-user/i386/cpu_loop.c | 48 +- linux-user/i386/elfload.c | 46 + linux-user/linuxload.c | 6 +- linux-user/loongarch64/cpu_loop.c | 11 +- linux-user/loongarch64/elfload.c | 83 + linux-user/m68k/cpu_loop.c | 32 +- linux-user/m68k/elfload.c | 42 + linux-user/main.c | 13 +- linux-user/microblaze/cpu_loop.c | 39 +- linux-user/microblaze/elfload.c | 28 + linux-user/microblaze/signal.c | 44 + linux-user/mips/cpu_loop.c | 16 +- linux-user/mips/elfload.c | 165 ++ linux-user/mips64/elfload.c | 1 + linux-user/openrisc/cpu_loop.c | 11 +- linux-user/openrisc/elfload.c | 22 + linux-user/openrisc/signal.c | 9 +- linux-user/ppc/cpu_loop.c | 26 +- linux-user/ppc/elfload.c | 150 ++ linux-user/riscv/cpu_loop.c | 15 +- linux-user/riscv/elfload.c | 23 + linux-user/s390x/cpu_loop.c | 15 +- linux-user/s390x/elfload.c | 93 + linux-user/s390x/signal.c | 5 + linux-user/sh4/cpu_loop.c | 10 +- linux-user/sh4/elfload.c | 66 + linux-user/sparc/cpu_loop.c | 16 +- linux-user/sparc/elfload.c | 42 + linux-user/sparc/signal.c | 20 + linux-user/x86_64/elfload.c | 72 + linux-user/xtensa/cpu_loop.c | 22 +- linux-user/xtensa/elfload.c | 43 + semihosting/arm-compat-semi.c | 28 +- meson.build | 6 +- 90 files changed, 2255 insertions(+), 2911 deletions(-) create mode 100644 linux-user/aarch64/elfload.c create mode 100644 linux-user/alpha/elfload.c create mode 100644 linux-user/arm/elfload.c create mode 100644 linux-user/hexagon/elfload.c create mode 100644 linux-user/hppa/elfload.c create mode 100644 linux-user/i386/elfload.c create mode 100644 linux-user/loongarch64/elfload.c create mode 100644 linux-user/m68k/elfload.c create mode 100644 linux-user/microblaze/elfload.c create mode 100644 linux-user/mips/elfload.c create mode 100644 linux-user/mips64/elfload.c create mode 100644 linux-user/openrisc/elfload.c create mode 100644 linux-user/ppc/elfload.c create mode 100644 linux-user/riscv/elfload.c create mode 100644 linux-user/s390x/elfload.c create mode 100644 linux-user/sh4/elfload.c create mode 100644 linux-user/sparc/elfload.c create mode 100644 linux-user/x86_64/elfload.c create mode 100644 linux-user/xtensa/elfload.c
Signature · 1 line
2.43.0
PATCH v2 1/95 semihosting: Retrieve stack top from image_info
Remove the write-once field TaskState.stack_base, and use the same value from struct image_info.
--- linux-user/qemu.h | 1 - linux-user/aarch64/cpu_loop.c | 1 - linux-user/arm/cpu_loop.c | 1 - linux-user/m68k/cpu_loop.c | 1 - linux-user/riscv/cpu_loop.c | 1 - semihosting/arm-compat-semi.c | 6 +++++- 6 files changed, 5 insertions(+), 6 deletions(-)
linux-user/qemu.h +0 -1
@@ -127,7 +127,6 @@ struct TaskState {abi_ulong heap_base;abi_ulong heap_limit;#endif -abi_ulong stack_base;int used;/* non zero if used */ struct image_info *info;struct linux_binprm *bprm;
linux-user/aarch64/cpu_loop.c +0 -1
@@ -168,7 +168,6 @@ void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs)qemu_guest_getrandom_nofail (&env->keys,sizeof (env->keys)); } - ts->stack_base = info->start_stack; ts->heap_base = info->brk;/* This will be filled in on the first SYS_HEAPINFO call. */ ts->heap_limit =0 ;
linux-user/arm/cpu_loop.c +0 -1
@@ -504,7 +504,6 @@ void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs)arm_rebuild_hflags (env);#endif - ts->stack_base = info->start_stack; ts->heap_base = info->brk;/* This will be filled in on the first SYS_HEAPINFO call. */ ts->heap_limit =0 ;
linux-user/m68k/cpu_loop.c +0 -1
@@ -117,7 +117,6 @@ void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs) env->aregs[7 ] = regs->usp; env->sr = regs->sr; - ts->stack_base = info->start_stack; ts->heap_base = info->brk;/* This will be filled in on the first SYS_HEAPINFO call. */ ts->heap_limit =0 ;
linux-user/riscv/cpu_loop.c +0 -1
@@ -109,7 +109,6 @@ void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs)exit (EXIT_FAILURE ); } - ts->stack_base = info->start_stack; ts->heap_base = info->brk;/* This will be filled in on the first SYS_HEAPINFO call. */ ts->heap_limit =0 ;
semihosting/arm-compat-semi.c +5 -1
@@ -696,7 +696,11 @@ void do_common_semihosting(CPUState *cs) retvals[0 ] = ts->heap_base; retvals[1 ] = ts->heap_limit; - retvals[2 ] = ts->stack_base; +/* +* Note that semihosting is *not* thread aware. +* Always return the stack base of the main thread. +*/ + retvals[2 ] = ts->info->start_stack; retvals[3 ] =0 ;/* Stack limit. */ #else retvals[0 ] = info.heapbase;/* Heap Base */
Signature · 1 line
2.43.0
Re: [PATCH v2 01/95] semihosting: Retrieve stack top from image_info
Quoted 5 lines · Richard Henderson
Remove the write-once field TaskState.stack_base, and use the same value from struct
image_info.Signed-off-by Richard Henderson <[email protected]>
thanks
-- PMM
PATCH v2 2/95 semihosting: Initialize heap once per process
In reply to Richard HendersonWhile semihosting isn't really thread aware, the current implementation allocates space for the heap per-thread.
Remove the heap_base and heap_limit fields from TaskState. Replace with static variables within do_common_semihosting.
--- linux-user/qemu.h | 5 ----- linux-user/aarch64/cpu_loop.c | 7 ------- linux-user/arm/cpu_loop.c | 32 +++++++++++++++----------------- linux-user/m68k/cpu_loop.c | 8 -------- linux-user/riscv/cpu_loop.c | 4 ---- semihosting/arm-compat-semi.c | 22 +++++++++------------- 6 files changed, 24 insertions(+), 54 deletions(-)
linux-user/qemu.h +0 -5
@@ -121,11 +121,6 @@ struct TaskState {abi_ulong child_tidptr;#ifdef TARGET_M68K abi_ulong tp_value; -#endif -#if defined(TARGET_ARM ) || defined(TARGET_M68K ) || defined(TARGET_RISCV ) -/* Extra fields for semihosted binaries. */ -abi_ulong heap_base; -abi_ulong heap_limit;#endif int used;/* non zero if used */ struct image_info *info;
linux-user/aarch64/cpu_loop.c +0 -7
@@ -140,9 +140,6 @@ void cpu_loop(CPUARMState *env)void target_cpu_copy_regs (CPUArchState *env,target_pt_regs *regs) {ARMCPU *cpu =env_archcpu (env); -CPUState *cs =env_cpu (env); -TaskState *ts =get_task_state (cs); -struct image_info *info = ts->info;int i;if (!(arm_feature (env,ARM_FEATURE_AARCH64 ))) {
@@ -167,8 +164,4 @@ void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs)if (cpu_isar_feature (aa64_pauth, cpu)) {qemu_guest_getrandom_nofail (&env->keys,sizeof (env->keys)); } - - ts->heap_base = info->brk; -/* This will be filled in on the first SYS_HEAPINFO call. */ - ts->heap_limit =0 ; }
linux-user/arm/cpu_loop.c +15 -17
@@ -482,9 +482,6 @@ void cpu_loop(CPUARMState *env)void target_cpu_copy_regs (CPUArchState *env,target_pt_regs *regs) { -CPUState *cpu =env_cpu (env); -TaskState *ts =get_task_state (cpu); -struct image_info *info = ts->info;int i; cpsr_write(env, regs->uregs[16], CPSR_USER | CPSR_EXEC,
@@ -492,19 +489,20 @@ void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs)for (i =0 ; i <16 ; i++) { env->regs[i] = regs->uregs[i]; } -#if TARGET_BIG_ENDIAN -/* Enable BE8. */ -if (EF_ARM_EABI_VERSION (info->elf_flags) >=EF_ARM_EABI_VER4 - && (info->elf_flags &EF_ARM_BE8 )) { - env->uncached_cpsr |=CPSR_E ; - env->cp15.sctlr_el[1 ] |=SCTLR_E0E ; - }else { - env->cp15.sctlr_el[1 ] |=SCTLR_B ; - } -arm_rebuild_hflags (env); -#endif - ts->heap_base = info->brk; -/* This will be filled in on the first SYS_HEAPINFO call. */ - ts->heap_limit =0 ; +if (TARGET_BIG_ENDIAN ) { +CPUState *cpu =env_cpu (env); +TaskState *ts =get_task_state (cpu); +struct image_info *info = ts->info; + +/* Enable BE8. */ +if (EF_ARM_EABI_VERSION (info->elf_flags) >=EF_ARM_EABI_VER4 + && (info->elf_flags &EF_ARM_BE8 )) { + env->uncached_cpsr |=CPSR_E ; + env->cp15.sctlr_el[1 ] |=SCTLR_E0E ; + }else { + env->cp15.sctlr_el[1 ] |=SCTLR_B ; + } +arm_rebuild_hflags (env); + } }
linux-user/m68k/cpu_loop.c +0 -8
@@ -94,10 +94,6 @@ void cpu_loop(CPUM68KState *env)void target_cpu_copy_regs (CPUArchState *env,target_pt_regs *regs) { -CPUState *cpu =env_cpu (env); -TaskState *ts =get_task_state (cpu); -struct image_info *info = ts->info; - env->pc = regs->pc; env->dregs[0 ] = regs->d0; env->dregs[1 ] = regs->d1;
@@ -116,8 +112,4 @@ void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs) env->aregs[6 ] = regs->a6; env->aregs[7 ] = regs->usp; env->sr = regs->sr; - - ts->heap_base = info->brk; -/* This will be filled in on the first SYS_HEAPINFO call. */ - ts->heap_limit =0 ; }
linux-user/riscv/cpu_loop.c +0 -4
@@ -108,8 +108,4 @@ void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs)error_report ("Incompatible ELF: RVE cpu requires RVE ABI binary" );exit (EXIT_FAILURE ); } - - ts->heap_base = info->brk; -/* This will be filled in on the first SYS_HEAPINFO call. */ - ts->heap_limit =0 ; }
semihosting/arm-compat-semi.c +9 -13
@@ -666,7 +666,7 @@ void do_common_semihosting(CPUState *cs)int i;#ifdef CONFIG_USER_ONLY TaskState *ts =get_task_state (cs); -target_ulong limit; +static abi_ulong heapbase, heaplimit;#else LayoutInfo info =common_semi_find_bases (cs);#endif
@@ -678,24 +678,20 @@ void do_common_semihosting(CPUState *cs)* Some C libraries assume the heap immediately follows .bss, so * allocate it using sbrk. */ -if (!ts->heap_limit) { -abi_ulong ret; - - ts->heap_base =do_brk (0 ); - limit = ts->heap_base +COMMON_SEMI_HEAP_SIZE ; +if (!heaplimit) { + heapbase =do_brk (0 );/* Try a big heap, and reduce the size if that fails. */ -for (;;) { - ret =do_brk (limit); +for (abi_ulong size =COMMON_SEMI_HEAP_SIZE ; ; size >>=1 ) { +abi_ulong limit = heapbase + size; +abi_ulong ret =do_brk (limit);if (ret >= limit) { + heaplimit = limit;break ; } - limit = (ts->heap_base >>1 ) + (limit >>1 ); } - ts->heap_limit = limit; } - - retvals[0 ] = ts->heap_base; - retvals[1 ] = ts->heap_limit; + retvals[0 ] = heapbase; + retvals[1 ] = heaplimit;/* * Note that semihosting is *not* thread aware. * Always return the stack base of the main thread.
Signature · 1 line
2.43.0
Re: [PATCH v2 02/95] semihosting: Initialize heap once per process
Quoted 33 lines · Richard Henderson
While semihosting isn't really thread aware, the current implementation allocates space for the heap per-thread.
Remove the
heap_baseandheap_limitfields from TaskState. Replace with static variables withindo_common_semihosting.Signed-off-by Richard Henderson <[email protected]>linux-user/arm/cpu_loop.c +5
-14@@ -492,19 +489,20 @@ void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs)for (i =0 ; i <16 ; i++) { env->regs[i] = regs->uregs[i]; } -#if TARGET_BIG_ENDIAN -/* Enable BE8. */ -if (EF_ARM_EABI_VERSION (info->elf_flags) >=EF_ARM_EABI_VER4 - && (info->elf_flags &EF_ARM_BE8 )) { - env->uncached_cpsr |=CPSR_E ; - env->cp15.sctlr_el[1 ] |=SCTLR_E0E ; - }else { - env->cp15.sctlr_el[1 ] |=SCTLR_B ; - } -arm_rebuild_hflags (env); -#endif - ts->heap_base = info->brk; -/* This will be filled in on the first SYS_HEAPINFO call. */ - ts->heap_limit =0 ; +if (TARGET_BIG_ENDIAN ) { +CPUState *cpu =env_cpu (env); +TaskState *ts =get_task_state (cpu); +struct image_info *info = ts->info; +
linux-user/arm/cpu_loop.c void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs) · line 507
Quoted 10 lines
linux-user/arm/cpu_loop.c +10
-0+/* Enable BE8. */ +if (EF_ARM_EABI_VERSION (info->elf_flags) >=EF_ARM_EABI_VER4 + && (info->elf_flags &EF_ARM_BE8 )) { + env->uncached_cpsr |=CPSR_E ; + env->cp15.sctlr_el[1 ] |=SCTLR_E0E ; + }else { + env->cp15.sctlr_el[1 ] |=SCTLR_B ; + } +arm_rebuild_hflags (env); + }
This change to the big-endian handling code seems unrelated.
Otherwise
Quoted 12 lines
semihosting/arm-compat-semi.c +2
-5@@ -678,24 +678,20 @@ void do_common_semihosting(CPUState *cs)* Some C libraries assume the heap immediately follows .bss, so * allocate it using sbrk. */ -if (!ts->heap_limit) { -abi_ulong ret; - - ts->heap_base =do_brk (0 ); - limit = ts->heap_base +COMMON_SEMI_HEAP_SIZE ; +if (!heaplimit) { + heapbase =do_brk (0 );/* Try a big heap, and reduce the size if that fails. */
semihosting/arm-compat-semi.c void do_common_semihosting(CPUState *cs) · line 692
Quoted 10 lines
semihosting/arm-compat-semi.c +4
-3-for (;;) { - ret =do_brk (limit); +for (abi_ulong size =COMMON_SEMI_HEAP_SIZE ; ; size >>=1 ) { +abi_ulong limit = heapbase + size; +abi_ulong ret =do_brk (limit);if (ret >= limit) { + heaplimit = limit;break ; } - limit = (ts->heap_base >>1 ) + (limit >>1 );
The old code was doing this in a very weird way; what you have here is much clearer...
semihosting/arm-compat-semi.c void do_common_semihosting(CPUState *cs) · line 692
Quoted 3 lines
semihosting/arm-compat-semi.c +0
-1} - ts->heap_limit = limit; }
-- PMM
Re: [PATCH v2 02/95] semihosting: Initialize heap once per process
Quoted 39 lines · Peter Maydell
Quoted 37 lines · Richard Henderson
While semihosting isn't really thread aware, the current implementation allocates space for the heap per-thread.
Remove the
heap_baseandheap_limitfields from TaskState. Replace with static variables withindo_common_semihosting.Signed-off-by Richard Henderson <[email protected]>linux-user/arm/cpu_loop.c +9
-14@@ -492,19 +489,20 @@ void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs)for (i =0 ; i <16 ; i++) { env->regs[i] = regs->uregs[i]; } -#if TARGET_BIG_ENDIAN -/* Enable BE8. */ -if (EF_ARM_EABI_VERSION (info->elf_flags) >=EF_ARM_EABI_VER4 - && (info->elf_flags &EF_ARM_BE8 )) { - env->uncached_cpsr |=CPSR_E ; - env->cp15.sctlr_el[1 ] |=SCTLR_E0E ; - }else { - env->cp15.sctlr_el[1 ] |=SCTLR_B ; - } -arm_rebuild_hflags (env); -#endif - ts->heap_base = info->brk; -/* This will be filled in on the first SYS_HEAPINFO call. */ - ts->heap_limit =0 ; +if (TARGET_BIG_ENDIAN ) { +CPUState *cpu =env_cpu (env); +TaskState *ts =get_task_state (cpu); +struct image_info *info = ts->info; + +/* Enable BE8. */ +if (EF_ARM_EABI_VERSION (info->elf_flags) >=EF_ARM_EABI_VER4 + && (info->elf_flags &EF_ARM_BE8 )) { + env->uncached_cpsr |=CPSR_E ;
Quoted 8 lines
linux-user/arm/cpu_loop.c void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs) · line 507
Quoted 6 lines
linux-user/arm/cpu_loop.c +6
-0+ env->cp15.sctlr_el[1 ] |=SCTLR_E0E ; + }else { + env->cp15.sctlr_el[1 ] |=SCTLR_B ; + } +arm_rebuild_hflags (env); + }This change to the big-endian handling code seems unrelated.
The ifdef caused unused variable Werrors for little-endian. The best solution seemed to be to convert to a C if.
r~
PATCH v2 3/95 linux-user: Create target/elfload.c files
In reply to Richard HendersonPrepare to split the main linux-user/elfload.c.
Create empty files for each target, and add the common build rule.
--- linux-user/aarch64/elfload.c | 1 + linux-user/alpha/elfload.c | 1 + linux-user/arm/elfload.c | 1 + linux-user/hexagon/elfload.c | 1 + linux-user/hppa/elfload.c | 1 + linux-user/i386/elfload.c | 1 + linux-user/loongarch64/elfload.c | 1 + linux-user/m68k/elfload.c | 1 + linux-user/microblaze/elfload.c | 1 + linux-user/mips/elfload.c | 1 + linux-user/mips64/elfload.c | 1 + linux-user/openrisc/elfload.c | 1 + linux-user/ppc/elfload.c | 1 + linux-user/riscv/elfload.c | 1 + linux-user/s390x/elfload.c | 1 + linux-user/sh4/elfload.c | 1 + linux-user/sparc/elfload.c | 1 + linux-user/x86_64/elfload.c | 1 + linux-user/xtensa/elfload.c | 1 + meson.build | 6 +++++- 20 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 linux-user/aarch64/elfload.c create mode 100644 linux-user/alpha/elfload.c create mode 100644 linux-user/arm/elfload.c create mode 100644 linux-user/hexagon/elfload.c create mode 100644 linux-user/hppa/elfload.c create mode 100644 linux-user/i386/elfload.c create mode 100644 linux-user/loongarch64/elfload.c create mode 100644 linux-user/m68k/elfload.c create mode 100644 linux-user/microblaze/elfload.c create mode 100644 linux-user/mips/elfload.c create mode 100644 linux-user/mips64/elfload.c create mode 100644 linux-user/openrisc/elfload.c create mode 100644 linux-user/ppc/elfload.c create mode 100644 linux-user/riscv/elfload.c create mode 100644 linux-user/s390x/elfload.c create mode 100644 linux-user/sh4/elfload.c create mode 100644 linux-user/sparc/elfload.c create mode 100644 linux-user/x86_64/elfload.c create mode 100644 linux-user/xtensa/elfload.c
linux-user/aarch64/elfload.c new file +1 -0
@@ -0,0 +1 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */
linux-user/alpha/elfload.c new file +1 -0
@@ -0,0 +1 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */
linux-user/arm/elfload.c new file +1 -0
@@ -0,0 +1 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */
linux-user/hexagon/elfload.c new file +1 -0
@@ -0,0 +1 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */
linux-user/hppa/elfload.c new file +1 -0
@@ -0,0 +1 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */
linux-user/i386/elfload.c new file +1 -0
@@ -0,0 +1 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */
linux-user/loongarch64/elfload.c new file +1 -0
@@ -0,0 +1 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */
linux-user/m68k/elfload.c new file +1 -0
@@ -0,0 +1 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */
linux-user/microblaze/elfload.c new file +1 -0
@@ -0,0 +1 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */
linux-user/mips/elfload.c new file +1 -0
@@ -0,0 +1 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */
linux-user/mips64/elfload.c new file +1 -0
@@ -0,0 +1 @@ +#include "../mips/elfload.c"
linux-user/openrisc/elfload.c new file +1 -0
@@ -0,0 +1 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */
linux-user/ppc/elfload.c new file +1 -0
@@ -0,0 +1 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */
linux-user/riscv/elfload.c new file +1 -0
@@ -0,0 +1 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */
linux-user/s390x/elfload.c new file +1 -0
@@ -0,0 +1 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */
linux-user/sh4/elfload.c new file +1 -0
@@ -0,0 +1 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */
linux-user/sparc/elfload.c new file +1 -0
@@ -0,0 +1 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */
linux-user/x86_64/elfload.c new file +1 -0
@@ -0,0 +1 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */
linux-user/xtensa/elfload.c new file +1 -0
@@ -0,0 +1 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */
meson.build +5 -1
@@ -4325,7 +4325,11 @@ foreach target : target_dirs ) if 'CONFIG_LINUX_USER' in config_target dir = base_dir / abi - arch_srcs += files(dir / 'signal.c', dir / 'cpu_loop.c') + arch_srcs += files( + dir / 'cpu_loop.c', + dir / 'elfload.c', + dir / 'signal.c', + ) if config_target.has_key('TARGET_SYSTBL_ABI') arch_srcs += \ syscall_nr_generators[abi].process(base_dir / abi / config_target['TARGET_SYSTBL'],
Signature · 1 line
2.43.0
PATCH v2 4/95 linux-user: Move ppc uabi/asm/elf.h workaround to osdep.h
In reply to Richard HendersonMove the workaround out of linux-user/elfload.c, so that we don't have to replicate it in many places. Place it immediately after the include of <signal.h>, which draws in the relevant symbols.
Note that ARCH_DLINFO is not defined by the kernel header, and so there's no need to undef it either.
--- include/qemu/osdep.h | 8 ++++++++ hw/core/loader.c | 4 ---- linux-user/elfload.c | 10 ---------- 3 files changed, 8 insertions(+), 14 deletions(-)
include/qemu/osdep.h +8 -0
@@ -133,6 +133,14 @@ QEMU_EXTERN_C int daemon(int, int);#include <setjmp.h> #include <signal.h> +/* +* Avoid conflict with linux/arch/powerpc/include/uapi/asm/elf.h, included +* from <asm/sigcontext.h>, but we might as well do this unconditionally. +*/ +#undef ELF_CLASS +#undef ELF_DATA +#undef ELF_ARCH +#ifdef CONFIG_IOVEC #include <sys/uio.h> #endif
hw/core/loader.c +0 -4
@@ -295,10 +295,6 @@ static void *load_at(int fd, off_t offset, size_t size)return ptr; } -#ifdef ELF_CLASS -#undef ELF_CLASS -#endif -#define ELF_CLASS ELFCLASS32#include "elf.h"
linux-user/elfload.c +0 -10
@@ -35,16 +35,6 @@#include "target/arm/cpu-features.h" #endif -#ifdef _ARCH_PPC64 -#undef ARCH_DLINFO -#undef ELF_PLATFORM -#undef ELF_HWCAP -#undef ELF_HWCAP2 -#undef ELF_CLASS -#undef ELF_DATA -#undef ELF_ARCH -#endif -#ifndef TARGET_ARCH_HAS_SIGTRAMP_PAGE #define TARGET_ARCH_HAS_SIGTRAMP_PAGE 0#endif
Signature · 1 line
2.43.0
Re: [PATCH v2 04/95] linux-user: Move ppc uabi/asm/elf.h workaround to osdep.h
Quoted 11 lines · Richard Henderson
Move the workaround out of
linux-user/elfload.c, so that we don't have to replicate it in many places. Place it immediately after the include of <signal.h>, which draws in the relevant symbols.Note that
ARCH_DLINFOis not defined by the kernel header, and so there's no need to undef it either.Signed-off-by Richard Henderson <[email protected]>---
thanks
-- PMM
PATCH v2 5/95 linux-user: Move get_elf_cpu_model to target/elfload.c
In reply to Richard HendersonRename from cpu_get_model to emphasize that this is an elf-specific function. Declare the function once in loader.h.
This frees up target_elf.h for other uses.
--- linux-user/aarch64/target_elf.h | 5 +--- linux-user/alpha/target_elf.h | 5 +--- linux-user/arm/target_elf.h | 5 +--- linux-user/hexagon/target_elf.h | 29 ------------------- linux-user/hppa/target_elf.h | 5 +--- linux-user/i386/target_elf.h | 5 +--- linux-user/loader.h | 3 ++ linux-user/loongarch64/target_elf.h | 5 +--- linux-user/m68k/target_elf.h | 9 ------ linux-user/microblaze/target_elf.h | 5 +--- linux-user/mips/target_elf.h | 11 +------- linux-user/mips64/target_elf.h | 27 +----------------- linux-user/openrisc/target_elf.h | 5 +--- linux-user/ppc/target_elf.h | 9 +----- linux-user/riscv/target_elf.h | 5 +--- linux-user/s390x/target_elf.h | 5 +--- linux-user/sh4/target_elf.h | 5 +--- linux-user/sparc/target_elf.h | 9 +----- linux-user/x86_64/target_elf.h | 5 +--- linux-user/xtensa/target_elf.h | 5 ---- linux-user/aarch64/elfload.c | 10 +++++++ linux-user/alpha/elfload.c | 10 +++++++ linux-user/arm/elfload.c | 10 +++++++ linux-user/hexagon/elfload.c | 34 +++++++++++++++++++++++ linux-user/hppa/elfload.c | 10 +++++++ linux-user/i386/elfload.c | 10 +++++++ linux-user/loongarch64/elfload.c | 10 +++++++ linux-user/m68k/elfload.c | 17 ++++++++++++ linux-user/main.c | 3 +- linux-user/microblaze/elfload.c | 10 +++++++ linux-user/mips/elfload.c | 43 +++++++++++++++++++++++++++++ linux-user/openrisc/elfload.c | 10 +++++++ linux-user/ppc/elfload.c | 14 ++++++++++ linux-user/riscv/elfload.c | 10 +++++++ linux-user/s390x/elfload.c | 10 +++++++ linux-user/sh4/elfload.c | 10 +++++++ linux-user/sparc/elfload.c | 14 ++++++++++ linux-user/x86_64/elfload.c | 10 +++++++ linux-user/xtensa/elfload.c | 10 +++++++ 39 files changed, 272 insertions(+), 145 deletions(-)
linux-user/aarch64/target_elf.h +1 -4
@@ -7,8 +7,5 @@#ifndef AARCH64_TARGET_ELF_H #define AARCH64_TARGET_ELF_H -static inline const char *cpu_get_model (uint32_t eflags) -{ -return "any" ; -} +#endif
linux-user/alpha/target_elf.h +1 -4
@@ -7,8 +7,5 @@#ifndef ALPHA_TARGET_ELF_H #define ALPHA_TARGET_ELF_H -static inline const char *cpu_get_model (uint32_t eflags) -{ -return "ev67" ; -} +#endif
linux-user/arm/target_elf.h +1 -4
@@ -7,8 +7,5 @@#ifndef ARM_TARGET_ELF_H #define ARM_TARGET_ELF_H -static inline const char *cpu_get_model (uint32_t eflags) -{ -return "any" ; -} +#endif
linux-user/hexagon/target_elf.h +0 -29
@@ -18,33 +18,4 @@#ifndef HEXAGON_TARGET_ELF_H #define HEXAGON_TARGET_ELF_H -static inline const char *cpu_get_model (uint32_t eflags) -{ -static char buf[32 ]; -int err; - -/* For now, treat anything newer than v5 as a v73 */ -/* FIXME - Disable instructions that are newer than the specified arch */ -if (eflags ==0x04 ||/* v5 */ - eflags ==0x05 ||/* v55 */ - eflags ==0x60 ||/* v60 */ - eflags ==0x61 ||/* v61 */ - eflags ==0x62 ||/* v62 */ - eflags ==0x65 ||/* v65 */ - eflags ==0x66 ||/* v66 */ - eflags ==0x67 ||/* v67 */ - eflags ==0x8067 ||/* v67t */ - eflags ==0x68 ||/* v68 */ - eflags ==0x69 ||/* v69 */ - eflags ==0x71 ||/* v71 */ - eflags ==0x8071 ||/* v71t */ - eflags ==0x73 /* v73 */ - ) { -return "v73" ; - } - - err =snprintf (buf,sizeof (buf),"unknown (0x%x)" , eflags); -return err >=0 && err <sizeof (buf) ? buf :"unknown" ; -} -#endif
linux-user/hppa/target_elf.h +1 -4
@@ -7,8 +7,5 @@#ifndef HPPA_TARGET_ELF_H #define HPPA_TARGET_ELF_H -static inline const char *cpu_get_model (uint32_t eflags) -{ -return "hppa" ; -} +#endif
linux-user/i386/target_elf.h +1 -4
@@ -7,8 +7,5 @@#ifndef I386_TARGET_ELF_H #define I386_TARGET_ELF_H -static inline const char *cpu_get_model (uint32_t eflags) -{ -return "max" ; -} +#endif
linux-user/loader.h +3 -0
@@ -98,6 +98,9 @@ abi_long memcpy_to_target(abi_ulong dest, const void *src,extern unsigned long guest_stack_size; +/* Note that Elf32 and Elf64 use uint32_t for e_flags. */ +const char *get_elf_cpu_model (uint32_t eflags); +#if defined(TARGET_S390X ) || defined(TARGET_AARCH64 ) || defined(TARGET_ARM )uint32_t get_elf_hwcap (void );const char *elf_hwcap_str (uint32_t bit);
linux-user/loongarch64/target_elf.h +1 -4
@@ -5,8 +5,5 @@#ifndef LOONGARCH_TARGET_ELF_H #define LOONGARCH_TARGET_ELF_H -static inline const char *cpu_get_model (uint32_t eflags) -{ -return "la464" ; -} +#endif
linux-user/m68k/target_elf.h +0 -9
@@ -7,14 +7,5 @@#ifndef M68K_TARGET_ELF_H #define M68K_TARGET_ELF_H -static inline const char *cpu_get_model (uint32_t eflags) -{ -if (eflags ==0 || (eflags &EF_M68K_M68000 )) { -/* 680x0 */ -return "m68040" ; - } -/* Coldfire */ -return "any" ; -}#endif
linux-user/microblaze/target_elf.h +1 -4
@@ -7,8 +7,5 @@#ifndef MICROBLAZE_TARGET_ELF_H #define MICROBLAZE_TARGET_ELF_H -static inline const char *cpu_get_model (uint32_t eflags) -{ -return "any" ; -} +#endif
linux-user/mips/target_elf.h +1 -10
@@ -7,14 +7,5 @@#ifndef MIPS_TARGET_ELF_H #define MIPS_TARGET_ELF_H -static inline const char *cpu_get_model (uint32_t eflags) -{ -if ((eflags &EF_MIPS_ARCH ) ==EF_MIPS_ARCH_32R6 ) { -return "mips32r6-generic" ; - } -if (eflags &EF_MIPS_NAN2008 ) { -return "P5600" ; - } -return "24Kf" ; -} +#endif
linux-user/mips64/target_elf.h +1 -26
@@ -7,30 +7,5 @@#ifndef MIPS64_TARGET_ELF_H #define MIPS64_TARGET_ELF_H -static inline const char *cpu_get_model (uint32_t eflags) -{ -switch (eflags &EF_MIPS_MACH ) { -case EF_MIPS_MACH_OCTEON : -case EF_MIPS_MACH_OCTEON2 : -case EF_MIPS_MACH_OCTEON3 : -return "Octeon68XX" ; -case EF_MIPS_MACH_LS2E : -return "Loongson-2E" ; -case EF_MIPS_MACH_LS2F : -return "Loongson-2F" ; -case EF_MIPS_MACH_LS3A : -return "Loongson-3A1000" ; -default : -break ; - } -switch (eflags &EF_MIPS_ARCH ) { -case EF_MIPS_ARCH_64R6 : -return "I6400" ; -case EF_MIPS_ARCH_64R2 : -return "MIPS64R2-generic" ; -default : -break ; - } -return "5KEf" ; -} +#endif
linux-user/openrisc/target_elf.h +1 -4
@@ -7,8 +7,5 @@#ifndef OPENRISC_TARGET_ELF_H #define OPENRISC_TARGET_ELF_H -static inline const char *cpu_get_model (uint32_t eflags) -{ -return "any" ; -} +#endif
linux-user/ppc/target_elf.h +1 -8
@@ -7,12 +7,5 @@#ifndef PPC_TARGET_ELF_H #define PPC_TARGET_ELF_H -static inline const char *cpu_get_model (uint32_t eflags) -{ -#ifdef TARGET_PPC64 -return "POWER9" ; -#else -return "750" ; -#endif -} +#endif
linux-user/riscv/target_elf.h +1 -4
@@ -7,8 +7,5 @@#ifndef RISCV_TARGET_ELF_H #define RISCV_TARGET_ELF_H -static inline const char *cpu_get_model (uint32_t eflags) -{ -return "max" ; -} +#endif
linux-user/s390x/target_elf.h +1 -4
@@ -7,8 +7,5 @@#ifndef S390X_TARGET_ELF_H #define S390X_TARGET_ELF_H -static inline const char *cpu_get_model (uint32_t eflags) -{ -return "qemu" ; -} +#endif
linux-user/sh4/target_elf.h +1 -4
@@ -7,8 +7,5 @@#ifndef SH4_TARGET_ELF_H #define SH4_TARGET_ELF_H -static inline const char *cpu_get_model (uint32_t eflags) -{ -return "sh7785" ; -} +#endif
linux-user/sparc/target_elf.h +1 -8
@@ -7,12 +7,5 @@#ifndef SPARC_TARGET_ELF_H #define SPARC_TARGET_ELF_H -static inline const char *cpu_get_model (uint32_t eflags) -{ -#ifdef TARGET_SPARC64 -return "TI UltraSparc II" ; -#else -return "Fujitsu MB86904" ; -#endif -} +#endif
linux-user/x86_64/target_elf.h +1 -4
@@ -7,8 +7,5 @@#ifndef X86_64_TARGET_ELF_H #define X86_64_TARGET_ELF_H -static inline const char *cpu_get_model (uint32_t eflags) -{ -return "max" ; -} +#endif
linux-user/xtensa/target_elf.h +0 -5
@@ -8,9 +8,4 @@#ifndef XTENSA_TARGET_ELF_H #define XTENSA_TARGET_ELF_H -static inline const char *cpu_get_model (uint32_t eflags) -{ -return XTENSA_DEFAULT_CPU_MODEL ; -} -#endif
linux-user/aarch64/elfload.c +10 -0
@@ -1 +1,11 @@/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "qemu/osdep.h" +#include "qemu.h" +#include "loader.h" + + +const char *get_elf_cpu_model (uint32_t eflags) +{ +return "any" ; +}
linux-user/alpha/elfload.c +10 -0
@@ -1 +1,11 @@/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "qemu/osdep.h" +#include "qemu.h" +#include "loader.h" + + +const char *get_elf_cpu_model (uint32_t eflags) +{ +return "ev67" ; +}
linux-user/arm/elfload.c +10 -0
@@ -1 +1,11 @@/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "qemu/osdep.h" +#include "qemu.h" +#include "loader.h" + + +const char *get_elf_cpu_model (uint32_t eflags) +{ +return "any" ; +}
linux-user/hexagon/elfload.c +34 -0
@@ -1 +1,35 @@/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "qemu/osdep.h" +#include "qemu.h" +#include "loader.h" + + +const char *get_elf_cpu_model (uint32_t eflags) +{ +static char buf[32 ]; +int err; + +/* For now, treat anything newer than v5 as a v73 */ +/* FIXME - Disable instructions that are newer than the specified arch */ +if (eflags ==0x04 ||/* v5 */ + eflags ==0x05 ||/* v55 */ + eflags ==0x60 ||/* v60 */ + eflags ==0x61 ||/* v61 */ + eflags ==0x62 ||/* v62 */ + eflags ==0x65 ||/* v65 */ + eflags ==0x66 ||/* v66 */ + eflags ==0x67 ||/* v67 */ + eflags ==0x8067 ||/* v67t */ + eflags ==0x68 ||/* v68 */ + eflags ==0x69 ||/* v69 */ + eflags ==0x71 ||/* v71 */ + eflags ==0x8071 ||/* v71t */ + eflags ==0x73 /* v73 */ + ) { +return "v73" ; + } + + err =snprintf (buf,sizeof (buf),"unknown (0x%x)" , eflags); +return err >=0 && err <sizeof (buf) ? buf :"unknown" ; +}
linux-user/hppa/elfload.c +10 -0
@@ -1 +1,11 @@/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "qemu/osdep.h" +#include "qemu.h" +#include "loader.h" + + +const char *get_elf_cpu_model (uint32_t eflags) +{ +return "hppa" ; +}
linux-user/i386/elfload.c +10 -0
@@ -1 +1,11 @@/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "qemu/osdep.h" +#include "qemu.h" +#include "loader.h" + + +const char *get_elf_cpu_model (uint32_t eflags) +{ +return "max" ; +}
linux-user/loongarch64/elfload.c +10 -0
@@ -1 +1,11 @@/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "qemu/osdep.h" +#include "qemu.h" +#include "loader.h" + + +const char *get_elf_cpu_model (uint32_t eflags) +{ +return "la464" ; +}
linux-user/m68k/elfload.c +17 -0
@@ -1 +1,18 @@/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "qemu/osdep.h" +#include "qemu.h" +#include "loader.h" +#include "elf.h" + + +const char *get_elf_cpu_model (uint32_t eflags) +{ +if (eflags ==0 || (eflags &EF_M68K_M68000 )) { +/* 680x0 */ +return "m68040" ; + } + +/* Coldfire */ +return "any" ; +}
linux-user/main.c +1 -2
@@ -49,7 +49,6 @@#include "qemu/guest-random.h" #include "elf.h" #include "trace/control.h" -#include "target_elf.h" #include "user/cpu_loop.h" #include "crypto/init.h" #include "fd-trans.h"
@@ -809,7 +808,7 @@ int main(int argc, char **argv, char **envp) }if (cpu_model ==NULL ) { - cpu_model =cpu_get_model (get_elf_eflags (execfd)); + cpu_model =get_elf_cpu_model (get_elf_eflags (execfd)); } cpu_type =parse_cpu_option (cpu_model);
linux-user/microblaze/elfload.c +10 -0
@@ -1 +1,11 @@/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "qemu/osdep.h" +#include "qemu.h" +#include "loader.h" + + +const char *get_elf_cpu_model (uint32_t eflags) +{ +return "any" ; +}
linux-user/mips/elfload.c +43 -0
44 lines not on this page · raw message
linux-user/openrisc/elfload.c +10 -0
@@ -1 +1,11 @@/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "qemu/osdep.h" +#include "qemu.h" +#include "loader.h" + + +const char *get_elf_cpu_model (uint32_t eflags) +{ +return "any" ; +}
linux-user/ppc/elfload.c +14 -0
@@ -1 +1,15 @@/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "qemu/osdep.h" +#include "qemu.h" +#include "loader.h" + + +const char *get_elf_cpu_model (uint32_t eflags) +{ +#ifdef TARGET_PPC64 +return "POWER9" ; +#else +return "750" ; +#endif +}
linux-user/riscv/elfload.c +10 -0
@@ -1 +1,11 @@/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "qemu/osdep.h" +#include "qemu.h" +#include "loader.h" + + +const char *get_elf_cpu_model (uint32_t eflags) +{ +return "max" ; +}
linux-user/s390x/elfload.c +10 -0
@@ -1 +1,11 @@/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "qemu/osdep.h" +#include "qemu.h" +#include "loader.h" + + +const char *get_elf_cpu_model (uint32_t eflags) +{ +return "qemu" ; +}
linux-user/sh4/elfload.c +10 -0
@@ -1 +1,11 @@/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "qemu/osdep.h" +#include "qemu.h" +#include "loader.h" + + +const char *get_elf_cpu_model (uint32_t eflags) +{ +return "sh7785" ; +}
linux-user/sparc/elfload.c +14 -0
@@ -1 +1,15 @@/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "qemu/osdep.h" +#include "qemu.h" +#include "loader.h" + + +const char *get_elf_cpu_model (uint32_t eflags) +{ +#ifdef TARGET_SPARC64 +return "TI UltraSparc II" ; +#else +return "Fujitsu MB86904" ; +#endif +}
linux-user/x86_64/elfload.c +10 -0
@@ -1 +1,11 @@/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "qemu/osdep.h" +#include "qemu.h" +#include "loader.h" + + +const char *get_elf_cpu_model (uint32_t eflags) +{ +return "max" ; +}
linux-user/xtensa/elfload.c +10 -0
@@ -1 +1,11 @@/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "qemu/osdep.h" +#include "qemu.h" +#include "loader.h" + + +const char *get_elf_cpu_model (uint32_t eflags) +{ +return XTENSA_DEFAULT_CPU_MODEL ; +}
Signature · 1 line
2.43.0
PATCH v2 6/95 linux-user: Move get_elf_hwcap to {i386, x86_64}/elfload.c
In reply to Richard HendersonChange the return type to abi_ulong, and pass in the cpu. Duplicate the one line function between i386 and x86_64, as most other additions to elfload.c won't be common.
--- linux-user/i386/target_elf.h | 2 ++ linux-user/loader.h | 3 +++ linux-user/x86_64/target_elf.h | 2 ++ linux-user/elfload.c | 9 +-------- linux-user/i386/elfload.c | 5 +++++ linux-user/x86_64/elfload.c | 5 +++++ 6 files changed, 18 insertions(+), 8 deletions(-)
linux-user/i386/target_elf.h +2 -0
@@ -8,4 +8,6 @@#ifndef I386_TARGET_ELF_H #define I386_TARGET_ELF_H +#define HAVE_ELF_HWCAP 1 +#endif
linux-user/loader.h +3 -0
@@ -101,6 +101,9 @@ extern unsigned long guest_stack_size;/* Note that Elf32 and Elf64 use uint32_t for e_flags. */ const char *get_elf_cpu_model (uint32_t eflags); +#if defined(TARGET_I386 ) || defined(TARGET_X86_64 ) +abi_ulong get_elf_hwcap (CPUState *cs); +#endif #if defined(TARGET_S390X ) || defined(TARGET_AARCH64 ) || defined(TARGET_ARM )uint32_t get_elf_hwcap (void );const char *elf_hwcap_str (uint32_t bit);
linux-user/x86_64/target_elf.h +2 -0
@@ -8,4 +8,6 @@#ifndef X86_64_TARGET_ELF_H #define X86_64_TARGET_ELF_H +#define HAVE_ELF_HWCAP 1 +#endif
linux-user/elfload.c +1 -8
@@ -148,14 +148,7 @@ typedef abi_int target_pid_t;#ifdef TARGET_I386 -#define ELF_HWCAP get_elf_hwcap() - -static uint32_t get_elf_hwcap (void ) -{ -X86CPU *cpu =X86_CPU (thread_cpu); - -return cpu->env.features[FEAT_1_EDX ]; -} +#define ELF_HWCAP get_elf_hwcap(thread_cpu)#ifdef TARGET_X86_64 #define ELF_CLASS ELFCLASS64
linux-user/i386/elfload.c +5 -0
@@ -9,3 +9,8 @@ const char *get_elf_cpu_model(uint32_t eflags) {return "max" ; } + +abi_ulong get_elf_hwcap (CPUState *cs) +{ +return cpu_env (cs)->features[FEAT_1_EDX ]; +}
linux-user/x86_64/elfload.c +5 -0
@@ -9,3 +9,8 @@ const char *get_elf_cpu_model(uint32_t eflags) {return "max" ; } + +abi_ulong get_elf_hwcap (CPUState *cs) +{ +return cpu_env (cs)->features[FEAT_1_EDX ]; +}
Signature · 1 line
2.43.0
PATCH v2 7/95 linux-user: Move hwcap functions to {arm, aarch64}/elfload.c
In reply to Richard HendersonFor get_elf_hwcap and get_elf_hwcap2, change the return type to abi_ulong, and pass in the cpu. We must do these targets at the same time because of the ifdef dependency between TARGET_AARCH64 and TARGET_ARM.
--- linux-user/aarch64/target_elf.h | 3 + linux-user/arm/target_elf.h | 3 + linux-user/arm/target_proc.h | 4 +- linux-user/loader.h | 10 +- linux-user/aarch64/elfload.c | 333 +++++++++++++++++++++ linux-user/arm/elfload.c | 161 ++++++++++ linux-user/elfload.c | 505 +------------------------------- 7 files changed, 510 insertions(+), 509 deletions(-)
linux-user/aarch64/target_elf.h +3 -0
@@ -8,4 +8,7 @@#ifndef AARCH64_TARGET_ELF_H #define AARCH64_TARGET_ELF_H +#define HAVE_ELF_HWCAP 1 +#define HAVE_ELF_HWCAP2 1 +#endif
linux-user/arm/target_elf.h +3 -0
@@ -8,4 +8,7 @@#ifndef ARM_TARGET_ELF_H #define ARM_TARGET_ELF_H +#define HAVE_ELF_HWCAP 1 +#define HAVE_ELF_HWCAP2 1 +#endif
linux-user/arm/target_proc.h +2 -2
@@ -10,8 +10,8 @@ static int open_cpuinfo(CPUArchState *cpu_env, int fd) {ARMCPU *cpu =env_archcpu (cpu_env);int arch, midr_rev, midr_part, midr_var, midr_impl; -target_ulong elf_hwcap =get_elf_hwcap (); -target_ulong elf_hwcap2 =get_elf_hwcap2 (); +target_ulong elf_hwcap =get_elf_hwcap (env_cpu (cpu_env)); +target_ulong elf_hwcap2 =get_elf_hwcap2 (env_cpu (cpu_env));const char *elf_name;int num_cpus, len_part, len_var;
linux-user/loader.h +4 -6
@@ -101,16 +101,14 @@ extern unsigned long guest_stack_size;/* Note that Elf32 and Elf64 use uint32_t for e_flags. */ const char *get_elf_cpu_model (uint32_t eflags); -#if defined(TARGET_I386 ) || defined(TARGET_X86_64 ) +#if defined(TARGET_I386 ) || defined(TARGET_X86_64 ) || defined(TARGET_ARM )abi_ulong get_elf_hwcap (CPUState *cs); +abi_ulong get_elf_hwcap2 (CPUState *cs);#endif -#if defined(TARGET_S390X ) || defined(TARGET_AARCH64 ) || defined(TARGET_ARM ) +#if defined(TARGET_S390X )uint32_t get_elf_hwcap (void ); +#endif const char *elf_hwcap_str (uint32_t bit); -#endif -#if defined(TARGET_AARCH64 ) || defined(TARGET_ARM ) -uint64_t get_elf_hwcap2 (void );const char *elf_hwcap2_str (uint32_t bit); -#endif #endif /* LINUX_USER_LOADER_H */
linux-user/aarch64/elfload.c +333 -0
342 lines not on this page · raw message
linux-user/arm/elfload.c +161 -0
170 lines not on this page · raw message
linux-user/elfload.c +4 -501
523 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v2 8/95 linux-user: Move get_elf_hwcap to sparc/elfload.c
In reply to Richard HendersonChange the return type to abi_ulong, and pass in the cpu.
--- linux-user/loader.h | 3 ++- linux-user/sparc/target_elf.h | 2 ++ linux-user/elfload.c | 30 +----------------------------- linux-user/sparc/elfload.c | 27 +++++++++++++++++++++++++++ 4 files changed, 32 insertions(+), 30 deletions(-)
linux-user/loader.h +2 -1
@@ -101,7 +101,8 @@ extern unsigned long guest_stack_size;/* Note that Elf32 and Elf64 use uint32_t for e_flags. */ const char *get_elf_cpu_model (uint32_t eflags); -#if defined(TARGET_I386 ) || defined(TARGET_X86_64 ) || defined(TARGET_ARM ) +#if defined(TARGET_I386 ) || defined(TARGET_X86_64 ) || defined(TARGET_ARM ) \ + || defined(TARGET_SPARC )abi_ulong get_elf_hwcap (CPUState *cs);abi_ulong get_elf_hwcap2 (CPUState *cs);#endif
linux-user/sparc/target_elf.h +2 -0
@@ -8,4 +8,6 @@#ifndef SPARC_TARGET_ELF_H #define SPARC_TARGET_ELF_H +#define HAVE_ELF_HWCAP 1 +#endif
linux-user/elfload.c +1 -29
@@ -565,35 +565,7 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs,# define ELF_ARCH EM_SPARCV9#endif -#include "elf.h" - -#define ELF_HWCAP get_elf_hwcap() - -static uint32_t get_elf_hwcap (void ) -{ -/* There are not many sparc32 hwcap bits -- we have all of them. */ -uint32_t r =HWCAP_SPARC_FLUSH |HWCAP_SPARC_STBAR | -HWCAP_SPARC_SWAP |HWCAP_SPARC_MULDIV ; - -#ifdef TARGET_SPARC64 -CPUSPARCState *env =cpu_env (thread_cpu); -uint32_t features = env->def.features; - - r |=HWCAP_SPARC_V9 |HWCAP_SPARC_V8PLUS ; -/* 32x32 multiply and divide are efficient. */ - r |=HWCAP_SPARC_MUL32 |HWCAP_SPARC_DIV32 ; -/* We don't have an internal feature bit for this. */ - r |=HWCAP_SPARC_POPC ; - r |= features &CPU_FEATURE_FSMULD ?HWCAP_SPARC_FSMULD :0 ; - r |= features &CPU_FEATURE_VIS1 ?HWCAP_SPARC_VIS :0 ; - r |= features &CPU_FEATURE_VIS2 ?HWCAP_SPARC_VIS2 :0 ; - r |= features &CPU_FEATURE_FMAF ?HWCAP_SPARC_FMAF :0 ; - r |= features &CPU_FEATURE_VIS3 ?HWCAP_SPARC_VIS3 :0 ; - r |= features &CPU_FEATURE_IMA ?HWCAP_SPARC_IMA :0 ; -#endif - -return r; -} +#define ELF_HWCAP get_elf_hwcap(thread_cpu)static inline void init_thread (struct target_pt_regs *regs,struct image_info *infop)
linux-user/sparc/elfload.c +27 -0
@@ -3,6 +3,7 @@#include "qemu/osdep.h" #include "qemu.h" #include "loader.h" +#include "elf.h" const char *get_elf_cpu_model (uint32_t eflags)
@@ -13,3 +14,29 @@ const char *get_elf_cpu_model(uint32_t eflags)return "Fujitsu MB86904" ;#endif } + +abi_ulong get_elf_hwcap (CPUState *cs) +{ +/* There are not many sparc32 hwcap bits -- we have all of them. */ +uint32_t r =HWCAP_SPARC_FLUSH |HWCAP_SPARC_STBAR | +HWCAP_SPARC_SWAP |HWCAP_SPARC_MULDIV ; + +#ifdef TARGET_SPARC64 +CPUSPARCState *env =cpu_env (cs); +uint32_t features = env->def.features; + + r |=HWCAP_SPARC_V9 |HWCAP_SPARC_V8PLUS ; +/* 32x32 multiply and divide are efficient. */ + r |=HWCAP_SPARC_MUL32 |HWCAP_SPARC_DIV32 ; +/* We don't have an internal feature bit for this. */ + r |=HWCAP_SPARC_POPC ; + r |= features &CPU_FEATURE_FSMULD ?HWCAP_SPARC_FSMULD :0 ; + r |= features &CPU_FEATURE_VIS1 ?HWCAP_SPARC_VIS :0 ; + r |= features &CPU_FEATURE_VIS2 ?HWCAP_SPARC_VIS2 :0 ; + r |= features &CPU_FEATURE_FMAF ?HWCAP_SPARC_FMAF :0 ; + r |= features &CPU_FEATURE_VIS3 ?HWCAP_SPARC_VIS3 :0 ; + r |= features &CPU_FEATURE_IMA ?HWCAP_SPARC_IMA :0 ; +#endif + +return r; +}
Signature · 1 line
2.43.0
PATCH v2 9/95 linux-user: Move hwcap functions to ppc/elfload.c
In reply to Richard HendersonChange the return type to abi_ulong, and pass in the cpu.
--- linux-user/loader.h | 2 +- linux-user/ppc/target_elf.h | 3 + linux-user/elfload.c | 116 +----------------------------------- linux-user/ppc/elfload.c | 116 ++++++++++++++++++++++++++++++++++++ 4 files changed, 122 insertions(+), 115 deletions(-)
linux-user/loader.h +1 -1
@@ -102,7 +102,7 @@ extern unsigned long guest_stack_size;const char *get_elf_cpu_model (uint32_t eflags);#if defined(TARGET_I386 ) || defined(TARGET_X86_64 ) || defined(TARGET_ARM ) \ - || defined(TARGET_SPARC ) + || defined(TARGET_SPARC ) || defined(TARGET_PPC )abi_ulong get_elf_hwcap (CPUState *cs);abi_ulong get_elf_hwcap2 (CPUState *cs);#endif
linux-user/ppc/target_elf.h +3 -0
@@ -8,4 +8,7 @@#ifndef PPC_TARGET_ELF_H #define PPC_TARGET_ELF_H +#define HAVE_ELF_HWCAP 1 +#define HAVE_ELF_HWCAP2 1 +#endif
linux-user/elfload.c +2 -114
122 lines not on this page · raw message
linux-user/ppc/elfload.c +116 -0
119 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v2 10/95 linux-user: Move get_elf_hwcap to loongarch64/elfload.c
In reply to Richard HendersonChange the return type to abi_ulong, and pass in the cpu.
--- linux-user/loader.h | 3 +- linux-user/loongarch64/target_elf.h | 2 ++ linux-user/elfload.c | 49 +---------------------------- linux-user/loongarch64/elfload.c | 47 +++++++++++++++++++++++++++ 4 files changed, 52 insertions(+), 49 deletions(-)
linux-user/loader.h +2 -1
@@ -102,7 +102,8 @@ extern unsigned long guest_stack_size;const char *get_elf_cpu_model (uint32_t eflags);#if defined(TARGET_I386 ) || defined(TARGET_X86_64 ) || defined(TARGET_ARM ) \ - || defined(TARGET_SPARC ) || defined(TARGET_PPC ) + || defined(TARGET_SPARC ) || defined(TARGET_PPC ) \ + || defined(TARGET_LOONGARCH64 )abi_ulong get_elf_hwcap (CPUState *cs);abi_ulong get_elf_hwcap2 (CPUState *cs);#endif
linux-user/loongarch64/target_elf.h +2 -0
@@ -6,4 +6,6 @@#ifndef LOONGARCH_TARGET_ELF_H #define LOONGARCH_TARGET_ELF_H +#define HAVE_ELF_HWCAP 1 +#endif
linux-user/elfload.c +1 -48
55 lines not on this page · raw message
linux-user/loongarch64/elfload.c +47 -0
50 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v2 11/95 linux-user: Move get_elf_hwcap to mips/elfload.c
In reply to Richard HendersonChange the return type to abi_ulong, and pass in the cpu.
--- linux-user/loader.h | 2 +- linux-user/mips/target_elf.h | 2 ++ linux-user/mips64/target_elf.h | 2 ++ linux-user/elfload.c | 52 +--------------------------------- linux-user/mips/elfload.c | 50 ++++++++++++++++++++++++++++++++ 5 files changed, 56 insertions(+), 52 deletions(-)
linux-user/loader.h +1 -1
@@ -103,7 +103,7 @@ const char *get_elf_cpu_model(uint32_t eflags);#if defined(TARGET_I386 ) || defined(TARGET_X86_64 ) || defined(TARGET_ARM ) \ || defined(TARGET_SPARC ) || defined(TARGET_PPC ) \ - || defined(TARGET_LOONGARCH64 ) + || defined(TARGET_LOONGARCH64 ) || defined(TARGET_MIPS )abi_ulong get_elf_hwcap (CPUState *cs);abi_ulong get_elf_hwcap2 (CPUState *cs);#endif
linux-user/mips/target_elf.h +2 -0
@@ -8,4 +8,6 @@#ifndef MIPS_TARGET_ELF_H #define MIPS_TARGET_ELF_H +#define HAVE_ELF_HWCAP 1 +#endif
linux-user/mips64/target_elf.h +2 -0
@@ -8,4 +8,6 @@#ifndef MIPS64_TARGET_ELF_H #define MIPS64_TARGET_ELF_H +#define HAVE_ELF_HWCAP 1 +#endif
linux-user/elfload.c +1 -51
58 lines not on this page · raw message
linux-user/mips/elfload.c +50 -0
53 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v2 12/95 linux-user: Move get_elf_hwcap to sh4/elfload.c
In reply to Richard HendersonChange the return type to abi_ulong, and pass in the cpu.
--- linux-user/loader.h | 3 ++- linux-user/sh4/target_elf.h | 2 ++ linux-user/elfload.c | 29 +---------------------------- linux-user/sh4/elfload.c | 27 +++++++++++++++++++++++++++ 4 files changed, 32 insertions(+), 29 deletions(-)
linux-user/loader.h +2 -1
@@ -103,7 +103,8 @@ const char *get_elf_cpu_model(uint32_t eflags);#if defined(TARGET_I386 ) || defined(TARGET_X86_64 ) || defined(TARGET_ARM ) \ || defined(TARGET_SPARC ) || defined(TARGET_PPC ) \ - || defined(TARGET_LOONGARCH64 ) || defined(TARGET_MIPS ) + || defined(TARGET_LOONGARCH64 ) || defined(TARGET_MIPS ) \ + || defined(TARGET_SH4 )abi_ulong get_elf_hwcap (CPUState *cs);abi_ulong get_elf_hwcap2 (CPUState *cs);#endif
linux-user/sh4/target_elf.h +2 -0
@@ -8,4 +8,6 @@#ifndef SH4_TARGET_ELF_H #define SH4_TARGET_ELF_H +#define HAVE_ELF_HWCAP 1 +#endif
linux-user/elfload.c +1 -28
@@ -963,34 +963,7 @@ static inline void elf_core_copy_regs(target_elf_gregset_t *regs,#define USE_ELF_CORE_DUMP #define ELF_EXEC_PAGESIZE 4096 -enum { -SH_CPU_HAS_FPU =0x0001 ,/* Hardware FPU support */ -SH_CPU_HAS_P2_FLUSH_BUG =0x0002 ,/* Need to flush the cache in P2 area */ -SH_CPU_HAS_MMU_PAGE_ASSOC =0x0004 ,/* SH3: TLB way selection bit support */ -SH_CPU_HAS_DSP =0x0008 ,/* SH-DSP: DSP support */ -SH_CPU_HAS_PERF_COUNTER =0x0010 ,/* Hardware performance counters */ -SH_CPU_HAS_PTEA =0x0020 ,/* PTEA register */ -SH_CPU_HAS_LLSC =0x0040 ,/* movli.l/movco.l */ -SH_CPU_HAS_L2_CACHE =0x0080 ,/* Secondary cache / URAM */ -SH_CPU_HAS_OP32 =0x0100 ,/* 32-bit instruction support */ -SH_CPU_HAS_PTEAEX =0x0200 ,/* PTE ASID Extension support */ -}; - -#define ELF_HWCAP get_elf_hwcap() - -static uint32_t get_elf_hwcap (void ) -{ -SuperHCPU *cpu =SUPERH_CPU (thread_cpu); -uint32_t hwcap =0 ; - - hwcap |=SH_CPU_HAS_FPU ; - -if (cpu->env.features &SH_FEATURE_SH4A ) { - hwcap |=SH_CPU_HAS_LLSC ; - } - -return hwcap; -} +#define ELF_HWCAP get_elf_hwcap(thread_cpu)#endif
linux-user/sh4/elfload.c +27 -0
@@ -9,3 +9,30 @@ const char *get_elf_cpu_model(uint32_t eflags) {return "sh7785" ; } + +enum { +SH_CPU_HAS_FPU =0x0001 ,/* Hardware FPU support */ +SH_CPU_HAS_P2_FLUSH_BUG =0x0002 ,/* Need to flush the cache in P2 area */ +SH_CPU_HAS_MMU_PAGE_ASSOC =0x0004 ,/* SH3: TLB way selection bit support */ +SH_CPU_HAS_DSP =0x0008 ,/* SH-DSP: DSP support */ +SH_CPU_HAS_PERF_COUNTER =0x0010 ,/* Hardware performance counters */ +SH_CPU_HAS_PTEA =0x0020 ,/* PTEA register */ +SH_CPU_HAS_LLSC =0x0040 ,/* movli.l/movco.l */ +SH_CPU_HAS_L2_CACHE =0x0080 ,/* Secondary cache / URAM */ +SH_CPU_HAS_OP32 =0x0100 ,/* 32-bit instruction support */ +SH_CPU_HAS_PTEAEX =0x0200 ,/* PTE ASID Extension support */ +}; + +abi_ulong get_elf_hwcap (CPUState *cs) +{ +SuperHCPU *cpu =SUPERH_CPU (cs); +abi_ulong hwcap =0 ; + + hwcap |=SH_CPU_HAS_FPU ; + +if (cpu->env.features &SH_FEATURE_SH4A ) { + hwcap |=SH_CPU_HAS_LLSC ; + } + +return hwcap; +}
Signature · 1 line
2.43.0
PATCH v2 13/95 linux-user: Move hwcap functions to s390x/elfload.c
In reply to Richard HendersonFor get_elf_hwcap, change the return type to abi_ulong and pass in the cpu.
--- linux-user/loader.h | 5 +-- linux-user/s390x/target_elf.h | 2 ++ linux-user/s390x/target_proc.h | 2 +- linux-user/elfload.c | 60 +--------------------------------- linux-user/s390x/elfload.c | 57 ++++++++++++++++++++++++++++++++ 5 files changed, 62 insertions(+), 64 deletions(-)
linux-user/loader.h +1 -4
@@ -104,13 +104,10 @@ const char *get_elf_cpu_model(uint32_t eflags);#if defined(TARGET_I386 ) || defined(TARGET_X86_64 ) || defined(TARGET_ARM ) \ || defined(TARGET_SPARC ) || defined(TARGET_PPC ) \ || defined(TARGET_LOONGARCH64 ) || defined(TARGET_MIPS ) \ - || defined(TARGET_SH4 ) + || defined(TARGET_SH4 ) || defined(TARGET_S390X )abi_ulong get_elf_hwcap (CPUState *cs);abi_ulong get_elf_hwcap2 (CPUState *cs);#endif -#if defined(TARGET_S390X ) -uint32_t get_elf_hwcap (void ); -#endif const char *elf_hwcap_str (uint32_t bit);const char *elf_hwcap2_str (uint32_t bit);
linux-user/s390x/target_elf.h +2 -0
@@ -8,4 +8,6 @@#ifndef S390X_TARGET_ELF_H #define S390X_TARGET_ELF_H +#define HAVE_ELF_HWCAP 1 +#endif
linux-user/s390x/target_proc.h +1 -1
@@ -48,7 +48,7 @@ static void show_cpu_summary(CPUArchState *cpu_env, int fd) {S390CPUModel *model =env_archcpu (cpu_env)->model;int num_cpus =sysconf (_SC_NPROCESSORS_ONLN); -uint32_t elf_hwcap =get_elf_hwcap (); +uint32_t elf_hwcap =get_elf_hwcap (env_cpu (cpu_env));const char *hwcap_str;int i;
linux-user/elfload.c +1 -59
66 lines not on this page · raw message
linux-user/s390x/elfload.c +57 -0
66 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v2 14/95 linux-user: Move get_elf_hwcap to riscv/elfload.c
In reply to Richard HendersonChange the return type to abi_ulong, and pass in the cpu. As this is the last instance of get_elf_hwcap to be converted, remove the ifdef around the declaration in loader.h.
--- linux-user/loader.h | 5 ----- linux-user/riscv/target_elf.h | 2 ++ linux-user/elfload.c | 14 +------------- linux-user/riscv/elfload.c | 12 ++++++++++++ 4 files changed, 15 insertions(+), 18 deletions(-)
linux-user/loader.h +0 -5
@@ -101,13 +101,8 @@ extern unsigned long guest_stack_size;/* Note that Elf32 and Elf64 use uint32_t for e_flags. */ const char *get_elf_cpu_model (uint32_t eflags); -#if defined(TARGET_I386 ) || defined(TARGET_X86_64 ) || defined(TARGET_ARM ) \ - || defined(TARGET_SPARC ) || defined(TARGET_PPC ) \ - || defined(TARGET_LOONGARCH64 ) || defined(TARGET_MIPS ) \ - || defined(TARGET_SH4 ) || defined(TARGET_S390X )abi_ulong get_elf_hwcap (CPUState *cs);abi_ulong get_elf_hwcap2 (CPUState *cs); -#endif const char *elf_hwcap_str (uint32_t bit);const char *elf_hwcap2_str (uint32_t bit);
linux-user/riscv/target_elf.h +2 -0
@@ -8,4 +8,6 @@#ifndef RISCV_TARGET_ELF_H #define RISCV_TARGET_ELF_H +#define HAVE_ELF_HWCAP 1 +#endif
linux-user/elfload.c +1 -13
@@ -1099,19 +1099,7 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs,#define VDSO_HEADER "vdso-64.c.inc"#endif -#define ELF_HWCAP get_elf_hwcap() - -static uint32_t get_elf_hwcap (void ) -{ -#define MISA_BIT (EXT ) (1 << (EXT - 'A')) -RISCVCPU *cpu =RISCV_CPU (thread_cpu); -uint32_t mask =MISA_BIT ('I' ) |MISA_BIT ('M' ) |MISA_BIT ('A' ) - |MISA_BIT ('F' ) |MISA_BIT ('D' ) |MISA_BIT ('C' ) - |MISA_BIT ('V' ); - -return cpu->env.misa_ext & mask; -#undef MISA_BIT -} +#define ELF_HWCAP get_elf_hwcap(thread_cpu)static inline void init_thread (struct target_pt_regs *regs,struct image_info *infop)
linux-user/riscv/elfload.c +12 -0
@@ -9,3 +9,15 @@ const char *get_elf_cpu_model(uint32_t eflags) {return "max" ; } + +abi_ulong get_elf_hwcap (CPUState *cs) +{ +#define MISA_BIT (EXT ) (1 << (EXT - 'A')) +RISCVCPU *cpu =RISCV_CPU (cs); +uint32_t mask =MISA_BIT ('I' ) |MISA_BIT ('M' ) |MISA_BIT ('A' ) + |MISA_BIT ('F' ) |MISA_BIT ('D' ) |MISA_BIT ('C' ) + |MISA_BIT ('V' ); + +return cpu->env.misa_ext & mask; +#undef MISA_BIT +}
Signature · 1 line
2.43.0
PATCH v2 15/95 linux-user: Remove ELF_HWCAP
In reply to Richard HendersonAll real definitions of ELF_HWCAP are now identical, and the stub definitions are 0. Provide zero stub as a fallback definition.
--- linux-user/elfload.c | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-)
linux-user/elfload.c +12 -23
@@ -28,6 +28,7 @@#include "qemu/lockable.h" #include "qapi/error.h" #include "qemu/error-report.h" +#include "target_elf.h" #include "target_signal.h" #include "tcg/debuginfo.h"
@@ -148,8 +149,6 @@ typedef abi_int target_pid_t;#ifdef TARGET_I386 -#define ELF_HWCAP get_elf_hwcap(thread_cpu) -#ifdef TARGET_X86_64 #define ELF_CLASS ELFCLASS64#define ELF_ARCH EM_X86_64
@@ -449,7 +448,6 @@ static bool init_guest_commpage(void)return true; } -#define ELF_HWCAP get_elf_hwcap(thread_cpu)#define ELF_HWCAP2 get_elf_hwcap2(thread_cpu)#define ELF_PLATFORM get_elf_platform()
@@ -539,7 +537,6 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs,#define USE_ELF_CORE_DUMP #define ELF_EXEC_PAGESIZE 4096 -#define ELF_HWCAP get_elf_hwcap(thread_cpu)#define ELF_HWCAP2 get_elf_hwcap2(thread_cpu)#if TARGET_BIG_ENDIAN
@@ -565,8 +562,6 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs,# define ELF_ARCH EM_SPARCV9#endif -#define ELF_HWCAP get_elf_hwcap(thread_cpu) -static inline void init_thread (struct target_pt_regs *regs,struct image_info *infop) {
@@ -598,7 +593,6 @@ static inline void init_thread(struct target_pt_regs *regs,#define ELF_ARCH EM_PPC -#define ELF_HWCAP get_elf_hwcap(thread_cpu)#define ELF_HWCAP2 get_elf_hwcap2(thread_cpu)/*
@@ -725,8 +719,6 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs,#define USE_ELF_CORE_DUMP #define ELF_EXEC_PAGESIZE 4096 -#define ELF_HWCAP get_elf_hwcap(thread_cpu) -#define ELF_PLATFORM "loongarch"#endif /* TARGET_LOONGARCH64 */
@@ -834,8 +826,6 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUMIPSState *e#define USE_ELF_CORE_DUMP #define ELF_EXEC_PAGESIZE 4096 -#define ELF_HWCAP get_elf_hwcap(thread_cpu) -#endif /* TARGET_MIPS */ #ifdef TARGET_MICROBLAZE
@@ -909,7 +899,7 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, (*regs)[32 ] =tswapreg (env->pc); (*regs)[33] = tswapreg(cpu_get_sr(env)); } -#define ELF_HWCAP 0 +#define ELF_PLATFORM NULL#endif /* TARGET_OPENRISC */
@@ -963,8 +953,6 @@ static inline void elf_core_copy_regs(target_elf_gregset_t *regs,#define USE_ELF_CORE_DUMP #define ELF_EXEC_PAGESIZE 4096 -#define ELF_HWCAP get_elf_hwcap(thread_cpu) -#endif #ifdef TARGET_M68K
@@ -1039,8 +1027,6 @@ static inline void init_thread(struct target_pt_regs *regs,#define ELF_DATA ELFDATA2MSB#define ELF_ARCH EM_S390 -#define ELF_HWCAP get_elf_hwcap(thread_cpu) -static inline void init_thread (struct target_pt_regs *regs,struct image_info *infop) { regs->psw.addr = infop->entry;
@@ -1099,8 +1085,6 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs,#define VDSO_HEADER "vdso-64.c.inc"#endif -#define ELF_HWCAP get_elf_hwcap(thread_cpu) -static inline void init_thread (struct target_pt_regs *regs,struct image_info *infop) {
@@ -1268,10 +1252,6 @@ static inline void init_thread(struct target_pt_regs *regs,#define elf_check_abi (x) (1)#endif -#ifndef ELF_HWCAP -#define ELF_HWCAP 0 -#endif -#ifndef STACK_GROWS_DOWN #define STACK_GROWS_DOWN 1#endif
@@ -1291,6 +1271,15 @@ static inline void init_thread(struct target_pt_regs *regs,#define EXSTACK_DEFAULT false#endif +/* +* Provide fallback definitions that the target may omit. +* One way or another, we'll get a link error if the setting of +* HAVE_* doesn't match the implementation. +*/ +#ifndef HAVE_ELF_HWCAP +abi_ulong get_elf_hwcap (CPUState *cs) {return 0 ; } +#endif +#include "elf.h" /* We must delay the following stanzas until after "elf.h". */
@@ -1868,7 +1857,7 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,NEW_AUX_ENT (AT_EUID , (abi_ulong )geteuid ());NEW_AUX_ENT (AT_GID , (abi_ulong )getgid ());NEW_AUX_ENT (AT_EGID , (abi_ulong )getegid ()); -NEW_AUX_ENT (AT_HWCAP , (abi_ulong )ELF_HWCAP ); +NEW_AUX_ENT (AT_HWCAP ,get_elf_hwcap (thread_cpu));NEW_AUX_ENT (AT_CLKTCK , (abi_ulong )sysconf (_SC_CLK_TCK));NEW_AUX_ENT (AT_RANDOM , (abi_ulong ) u_rand_bytes);NEW_AUX_ENT (AT_SECURE , (abi_ulong )qemu_getauxval (AT_SECURE ));
Signature · 1 line
2.43.0
PATCH v2 16/95 linux-user: Remove ELF_HWCAP2
In reply to Richard HendersonAll definitions of ELF_HWCAP2 are now identical. Provide a not-reached stub as a fallback definition of get_elf_hwcap2.
--- linux-user/elfload.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-)
linux-user/elfload.c +10 -13
@@ -448,8 +448,6 @@ static bool init_guest_commpage(void)return true; } -#define ELF_HWCAP2 get_elf_hwcap2(thread_cpu) -#define ELF_PLATFORM get_elf_platform()static const char *get_elf_platform (void )
@@ -537,8 +535,6 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs,#define USE_ELF_CORE_DUMP #define ELF_EXEC_PAGESIZE 4096 -#define ELF_HWCAP2 get_elf_hwcap2(thread_cpu) -#if TARGET_BIG_ENDIAN # define VDSO_HEADER "vdso-be.c.inc"#else
@@ -593,8 +589,6 @@ static inline void init_thread(struct target_pt_regs *regs,#define ELF_ARCH EM_PPC -#define ELF_HWCAP2 get_elf_hwcap2(thread_cpu) -/* * The requirements here are: * - keep the final alignment of sp (sp & 0xf)
@@ -1279,6 +1273,10 @@ static inline void init_thread(struct target_pt_regs *regs,#ifndef HAVE_ELF_HWCAP abi_ulong get_elf_hwcap (CPUState *cs) {return 0 ; }#endif +#ifndef HAVE_ELF_HWCAP2 +abi_ulong get_elf_hwcap2 (CPUState *cs) {g_assert_not_reached (); } +#define HAVE_ELF_HWCAP2 0 +#endif #include "elf.h"
@@ -1801,9 +1799,9 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,#ifdef DLINFO_ARCH_ITEMS size +=DLINFO_ARCH_ITEMS *2 ;#endif -#ifdef ELF_HWCAP2 - size +=2 ; -#endif +if (HAVE_ELF_HWCAP2 ) { + size +=2 ; + } info->auxv_len = size * n; size += envc + argc +2 ;
@@ -1863,10 +1861,9 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,NEW_AUX_ENT (AT_SECURE , (abi_ulong )qemu_getauxval (AT_SECURE ));NEW_AUX_ENT (AT_EXECFN , info->file_string); -#ifdef ELF_HWCAP2 -NEW_AUX_ENT (AT_HWCAP2 , (abi_ulong )ELF_HWCAP2 ); -#endif - +if (HAVE_ELF_HWCAP2 ) { +NEW_AUX_ENT (AT_HWCAP2 ,get_elf_hwcap (thread_cpu)); + }if (u_base_platform) {NEW_AUX_ENT (AT_BASE_PLATFORM , u_base_platform); }
Signature · 1 line
2.43.0
Re: [PATCH v2 16/95] linux-user: Remove ELF_HWCAP2
Quoted 8 lines · Richard Henderson
All definitions of
ELF_HWCAP2are now identical. Provide a not-reached stub as a fallback definition ofget_elf_hwcap2.Signed-off-by Richard Henderson <[email protected]>--- linux-user/elfload.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-)
thanks
-- PMM
PATCH v2 17/95 linux-user: Move get_elf_platform to {i386, x86_64}/elfload.c
In reply to Richard HendersonMove get_elf_platform to i386/elfload.c; pass in CPUState. Create a simple get_elf_platform for x86_64. Introduce HAVE_ELF_PLATFORM.
--- linux-user/i386/target_elf.h | 1 + linux-user/loader.h | 3 +++ linux-user/x86_64/target_elf.h | 1 + linux-user/elfload.c | 18 ++---------------- linux-user/i386/elfload.c | 13 +++++++++++++ linux-user/x86_64/elfload.c | 5 +++++ 6 files changed, 25 insertions(+), 16 deletions(-)
linux-user/i386/target_elf.h +1 -0
@@ -9,5 +9,6 @@#define I386_TARGET_ELF_H #define HAVE_ELF_HWCAP 1 +#define HAVE_ELF_PLATFORM 1#endif
linux-user/loader.h +3 -0
@@ -105,5 +105,8 @@ abi_ulong get_elf_hwcap(CPUState *cs);abi_ulong get_elf_hwcap2 (CPUState *cs);const char *elf_hwcap_str (uint32_t bit);const char *elf_hwcap2_str (uint32_t bit); +#if defined(TARGET_I386 ) +const char *get_elf_platform (CPUState *cs); +#endif #endif /* LINUX_USER_LOADER_H */
linux-user/x86_64/target_elf.h +1 -0
@@ -9,5 +9,6 @@#define X86_64_TARGET_ELF_H #define HAVE_ELF_HWCAP 1 +#define HAVE_ELF_PLATFORM 1#endif
linux-user/elfload.c +2 -16
@@ -149,12 +149,12 @@ typedef abi_int target_pid_t; #ifdef TARGET_I386 +#define ELF_PLATFORM get_elf_platform(thread_cpu) + #ifdef TARGET_X86_64 #define ELF_CLASS ELFCLASS64 #define ELF_ARCH EM_X86_64 -#define ELF_PLATFORM "x86_64" - static inline void init_thread(struct target_pt_regs *regs, struct image_info *infop) { regs->rax = 0;
@@ -237,22 +237,8 @@ static bool init_guest_commpage(void)#define ELF_CLASS ELFCLASS32#define ELF_ARCH EM_386 -#define ELF_PLATFORM get_elf_platform()#define EXSTACK_DEFAULT true -static const char *get_elf_platform (void ) -{ -static char elf_platform[] ="i386" ; -int family =object_property_get_int (OBJECT (thread_cpu),"family" ,NULL ); -if (family >6 ) { - family =6 ; - } -if (family >=3 ) { - elf_platform[1 ] ='0' + family; - } -return elf_platform; -} -static inline void init_thread (struct target_pt_regs *regs,struct image_info *infop) {
linux-user/i386/elfload.c +13 -0
@@ -14,3 +14,16 @@ abi_ulong get_elf_hwcap(CPUState *cs) {return cpu_env (cs)->features[FEAT_1_EDX ]; } + +const char *get_elf_platform (CPUState *cs) +{ +static char elf_platform[] ="i386" ; +int family =object_property_get_int (OBJECT (cs),"family" ,NULL ); +if (family >6 ) { + family =6 ; + } +if (family >=3 ) { + elf_platform[1 ] ='0' + family; + } +return elf_platform; +}
linux-user/x86_64/elfload.c +5 -0
@@ -14,3 +14,8 @@ abi_ulong get_elf_hwcap(CPUState *cs) {return cpu_env (cs)->features[FEAT_1_EDX ]; } + +const char *get_elf_platform (CPUState *cs) +{ +return "x86_64" ; +}
Signature · 1 line
2.43.0
PATCH v2 18/95 linux-user/i386: Return const data from get_elf_platform
In reply to Richard HendersonRather than modify a static buffer, index into an array of const data.
--- linux-user/i386/elfload.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
linux-user/i386/elfload.c +4 -8
@@ -17,13 +17,9 @@ abi_ulong get_elf_hwcap(CPUState *cs)const char *get_elf_platform (CPUState *cs) { -static char elf_platform[] ="i386" ; +static const char elf_platform[4 ][5 ] = {"i386" ,"i486" ,"i586" ,"i686" };int family =object_property_get_int (OBJECT (cs),"family" ,NULL ); -if (family >6 ) { - family =6 ; - } -if (family >=3 ) { - elf_platform[1 ] ='0' + family; - } -return elf_platform; + + family =MAX (MIN (family,6 ),3 ); +return elf_platform[family -3 ]; }
Signature · 1 line
2.43.0
PATCH v2 19/95 linux-user: Move get_elf_platform to arm/elfload.c
In reply to Richard HendersonMove the aarch32 get_elf_platform to arm/elfload.c; pass in CPUState. Create a simple version in aarch64/elfload.c, which we must do at the same time because of the ifdef dependency between TARGET_AARCH64 and TARGET_ARM.
Since all versions of get_elf_platform now have the same signature, remove the ifdef from the declaration in loader.h.
--- linux-user/aarch64/target_elf.h | 1 + linux-user/arm/target_elf.h | 1 + linux-user/loader.h | 2 -- linux-user/aarch64/elfload.c | 5 +++++ linux-user/arm/elfload.c | 29 +++++++++++++++++++++++++ linux-user/elfload.c | 38 ++------------------------------- 6 files changed, 38 insertions(+), 38 deletions(-)
linux-user/aarch64/target_elf.h +1 -0
@@ -10,5 +10,6 @@#define HAVE_ELF_HWCAP 1#define HAVE_ELF_HWCAP2 1 +#define HAVE_ELF_PLATFORM 1#endif
linux-user/arm/target_elf.h +1 -0
@@ -10,5 +10,6 @@#define HAVE_ELF_HWCAP 1#define HAVE_ELF_HWCAP2 1 +#define HAVE_ELF_PLATFORM 1#endif
linux-user/loader.h +0 -2
@@ -105,8 +105,6 @@ abi_ulong get_elf_hwcap(CPUState *cs);abi_ulong get_elf_hwcap2 (CPUState *cs);const char *elf_hwcap_str (uint32_t bit);const char *elf_hwcap2_str (uint32_t bit); -#if defined(TARGET_I386 )const char *get_elf_platform (CPUState *cs); -#endif #endif /* LINUX_USER_LOADER_H */
linux-user/aarch64/elfload.c +5 -0
@@ -342,3 +342,8 @@ const char *elf_hwcap2_str(uint32_t bit)return bit <ARRAY_SIZE (hwcap_str) ? hwcap_str[bit] :NULL ; } + +const char *get_elf_platform (CPUState *cs) +{ +return TARGET_BIG_ENDIAN ?"aarch64_be" :"aarch64" ; +}
linux-user/arm/elfload.c +29 -0
@@ -170,3 +170,32 @@ const char *elf_hwcap2_str(uint32_t bit)return bit <ARRAY_SIZE (hwcap_str) ? hwcap_str[bit] :NULL ; } + +const char *get_elf_platform (CPUState *cs) +{ +CPUARMState *env =cpu_env (cs); + +#if TARGET_BIG_ENDIAN +# define END "b" +#else +# define END "l" +#endif + +if (arm_feature (env,ARM_FEATURE_V8 )) { +return "v8" END ; + }else if (arm_feature (env,ARM_FEATURE_V7 )) { +if (arm_feature (env,ARM_FEATURE_M )) { +return "v7m" END ; + }else { +return "v7" END ; + } + }else if (arm_feature (env,ARM_FEATURE_V6 )) { +return "v6" END ; + }else if (arm_feature (env,ARM_FEATURE_V5 )) { +return "v5" END ; + }else { +return "v4" END ; + } + +#undef END +}
linux-user/elfload.c +2 -36
@@ -309,6 +309,8 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUX86State *en#ifdef TARGET_ARM +#define ELF_PLATFORM get_elf_platform(thread_cpu) +#ifndef TARGET_AARCH64 /* 32 bit ARM definitions */
@@ -434,37 +436,6 @@ static bool init_guest_commpage(void)return true; } -#define ELF_PLATFORM get_elf_platform() - -static const char *get_elf_platform (void ) -{ -CPUARMState *env =cpu_env (thread_cpu); - -#if TARGET_BIG_ENDIAN -# define END "b" -#else -# define END "l" -#endif - -if (arm_feature (env,ARM_FEATURE_V8 )) { -return "v8" END ; - }else if (arm_feature (env,ARM_FEATURE_V7 )) { -if (arm_feature (env,ARM_FEATURE_M )) { -return "v7m" END ; - }else { -return "v7" END ; - } - }else if (arm_feature (env,ARM_FEATURE_V6 )) { -return "v6" END ; - }else if (arm_feature (env,ARM_FEATURE_V5 )) { -return "v5" END ; - }else { -return "v4" END ; - } - -#undef END -} -#if TARGET_BIG_ENDIAN #include "elf.h" #include "vdso-be8.c.inc"
@@ -487,11 +458,6 @@ static const VdsoImageInfo *vdso_image_info(uint32_t elf_flags)#define ELF_ARCH EM_AARCH64#define ELF_CLASS ELFCLASS64 -#if TARGET_BIG_ENDIAN -# define ELF_PLATFORM "aarch64_be" -#else -# define ELF_PLATFORM "aarch64" -#endif static inline void init_thread (struct target_pt_regs *regs,struct image_info *infop)
Signature · 1 line
2.43.0
PATCH v2 20/95 linux-user/loongarch64: Create get_elf_platform
In reply to Richard HendersonMove the string literal to a new function.
--- linux-user/loongarch64/target_elf.h | 1 + linux-user/elfload.c | 2 +- linux-user/loongarch64/elfload.c | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-)
linux-user/loongarch64/target_elf.h +1 -0
@@ -7,5 +7,6 @@#define LOONGARCH_TARGET_ELF_H #define HAVE_ELF_HWCAP 1 +#define HAVE_ELF_PLATFORM 1#endif
linux-user/elfload.c +1 -1
@@ -665,7 +665,7 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs,#define USE_ELF_CORE_DUMP #define ELF_EXEC_PAGESIZE 4096 -#define ELF_PLATFORM "loongarch" +#define ELF_PLATFORM get_elf_platform(thread_cpu)#endif /* TARGET_LOONGARCH64 */
linux-user/loongarch64/elfload.c +5 -0
@@ -56,3 +56,8 @@ abi_ulong get_elf_hwcap(CPUState *cs)return hwcaps; } + +const char *get_elf_platform (CPUState *cs) +{ +return "loongarch" ; +}
Signature · 1 line
2.43.0
PATCH v2 21/95 linux-user/hppa: Create get_elf_platform
In reply to Richard HendersonMove the string literal to a new function.
--- linux-user/hppa/target_elf.h | 2 ++ linux-user/elfload.c | 2 +- linux-user/hppa/elfload.c | 5 +++++ 3 files changed, 8 insertions(+), 1 deletion(-)
linux-user/hppa/target_elf.h +2 -0
@@ -8,4 +8,6 @@#ifndef HPPA_TARGET_ELF_H #define HPPA_TARGET_ELF_H +#define HAVE_ELF_PLATFORM 1 +#endif
linux-user/elfload.c +1 -1
@@ -1046,7 +1046,7 @@ static inline void init_thread(struct target_pt_regs *regs,#define ELF_CLASS ELFCLASS32#define ELF_ARCH EM_PARISC -#define ELF_PLATFORM "PARISC" +#define ELF_PLATFORM get_elf_platform(thread_cpu)#define STACK_GROWS_DOWN 0#define STACK_ALIGNMENT 64
linux-user/hppa/elfload.c +5 -0
@@ -9,3 +9,8 @@ const char *get_elf_cpu_model(uint32_t eflags) {return "hppa" ; } + +const char *get_elf_platform (CPUState *cs) +{ +return "PARISC" ; +}
Signature · 1 line
2.43.0
PATCH v2 22/95 linux-user: Remove ELF_PLATFORM
In reply to Richard HendersonAll real definitions of ELF_PLATFORM are now identical, and the stub definitions are NULL. Use HAVE_ELF_PLATFORM and provide a stub as a fallback definition of get_elf_platform.
--- linux-user/elfload.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-)
linux-user/elfload.c +4 -14
@@ -149,8 +149,6 @@ typedef abi_int target_pid_t;#ifdef TARGET_I386 -#define ELF_PLATFORM get_elf_platform(thread_cpu) -#ifdef TARGET_X86_64 #define ELF_CLASS ELFCLASS64#define ELF_ARCH EM_X86_64
@@ -309,8 +307,6 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUX86State *en#ifdef TARGET_ARM -#define ELF_PLATFORM get_elf_platform(thread_cpu) -#ifndef TARGET_AARCH64 /* 32 bit ARM definitions */
@@ -665,8 +661,6 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs,#define USE_ELF_CORE_DUMP #define ELF_EXEC_PAGESIZE 4096 -#define ELF_PLATFORM get_elf_platform(thread_cpu) -#endif /* TARGET_LOONGARCH64 */ #ifdef TARGET_MIPS
@@ -846,8 +840,6 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, (*regs)[33] = tswapreg(cpu_get_sr(env)); } -#define ELF_PLATFORM NULL -#endif /* TARGET_OPENRISC */ #ifdef TARGET_SH4
@@ -1046,7 +1038,6 @@ static inline void init_thread(struct target_pt_regs *regs,#define ELF_CLASS ELFCLASS32#define ELF_ARCH EM_PARISC -#define ELF_PLATFORM get_elf_platform(thread_cpu)#define STACK_GROWS_DOWN 0#define STACK_ALIGNMENT 64
@@ -1182,10 +1173,6 @@ static inline void init_thread(struct target_pt_regs *regs,#define ELF_BASE_PLATFORM (NULL)#endif -#ifndef ELF_PLATFORM -#define ELF_PLATFORM (NULL) -#endif -#ifndef ELF_MACHINE #define ELF_MACHINE ELF_ARCH#endif
@@ -1229,6 +1216,9 @@ abi_ulong get_elf_hwcap(CPUState *cs) { return 0; }abi_ulong get_elf_hwcap2 (CPUState *cs) {g_assert_not_reached (); }#define HAVE_ELF_HWCAP2 0#endif +#ifndef HAVE_ELF_PLATFORM +const char *get_elf_platform (CPUState *cs) {return NULL ; } +#endif #include "elf.h"
@@ -1699,7 +1689,7 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc, } u_platform =0 ; - k_platform =ELF_PLATFORM ; + k_platform =get_elf_platform (thread_cpu);if (k_platform) {size_t len =strlen (k_platform) +1 ;if (STACK_GROWS_DOWN ) {
Signature · 1 line
2.43.0
PATCH v2 23/95 linux-user: Move get_elf_base_platform to mips/elfload.c
In reply to Richard HendersonPass in CPUState; define HAVE_ELF_BASE_PLATFORM.
Since this was the only instance of ELF_BASE_PLATFORM, go ahead and provide the stub definition for other platforms.
--- linux-user/loader.h | 1 + linux-user/mips/target_elf.h | 1 + linux-user/mips64/target_elf.h | 1 + linux-user/elfload.c | 40 ++++------------------------------ linux-user/mips/elfload.c | 30 +++++++++++++++++++++++++ 5 files changed, 37 insertions(+), 36 deletions(-)
linux-user/loader.h +1 -0
@@ -106,5 +106,6 @@ abi_ulong get_elf_hwcap2(CPUState *cs);const char *elf_hwcap_str (uint32_t bit);const char *elf_hwcap2_str (uint32_t bit);const char *get_elf_platform (CPUState *cs); +const char *get_elf_base_platform (CPUState *cs);#endif /* LINUX_USER_LOADER_H */
linux-user/mips/target_elf.h +1 -0
@@ -9,5 +9,6 @@#define MIPS_TARGET_ELF_H #define HAVE_ELF_HWCAP 1 +#define HAVE_ELF_BASE_PLATFORM 1#endif
linux-user/mips64/target_elf.h +1 -0
@@ -9,5 +9,6 @@#define MIPS64_TARGET_ELF_H #define HAVE_ELF_HWCAP 1 +#define HAVE_ELF_BASE_PLATFORM 1#endif
linux-user/elfload.c +4 -36
@@ -679,37 +679,6 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs,#define elf_check_abi (x) (!((x) & EF_MIPS_ABI2))#endif -#define ELF_BASE_PLATFORM get_elf_base_platform() - -#define MATCH_PLATFORM_INSN (_flags, _base_platform) \ - do { if ((cpu->env.insn_flags & (_flags)) == _flags) \ - { return _base_platform; } } while (0) - -static const char *get_elf_base_platform (void ) -{ -MIPSCPU *cpu =MIPS_CPU (thread_cpu); - -/* 64 bit ISAs goes first */ -MATCH_PLATFORM_INSN (CPU_MIPS64R6 ,"mips64r6" ); -MATCH_PLATFORM_INSN (CPU_MIPS64R5 ,"mips64r5" ); -MATCH_PLATFORM_INSN (CPU_MIPS64R2 ,"mips64r2" ); -MATCH_PLATFORM_INSN (CPU_MIPS64R1 ,"mips64" ); -MATCH_PLATFORM_INSN (CPU_MIPS5 ,"mips5" ); -MATCH_PLATFORM_INSN (CPU_MIPS4 ,"mips4" ); -MATCH_PLATFORM_INSN (CPU_MIPS3 ,"mips3" ); - -/* 32 bit ISAs */ -MATCH_PLATFORM_INSN (CPU_MIPS32R6 ,"mips32r6" ); -MATCH_PLATFORM_INSN (CPU_MIPS32R5 ,"mips32r5" ); -MATCH_PLATFORM_INSN (CPU_MIPS32R2 ,"mips32r2" ); -MATCH_PLATFORM_INSN (CPU_MIPS32R1 ,"mips32" ); -MATCH_PLATFORM_INSN (CPU_MIPS2 ,"mips2" ); - -/* Fallback */ -return "mips" ; -} -#undef MATCH_PLATFORM_INSN -static inline void init_thread (struct target_pt_regs *regs,struct image_info *infop) {
@@ -1169,10 +1138,6 @@ static inline void init_thread(struct target_pt_regs *regs,#endif /* TARGET_HEXAGON */ -#ifndef ELF_BASE_PLATFORM -#define ELF_BASE_PLATFORM (NULL) -#endif -#ifndef ELF_MACHINE #define ELF_MACHINE ELF_ARCH#endif
@@ -1219,6 +1184,9 @@ abi_ulong get_elf_hwcap2(CPUState *cs) { g_assert_not_reached(); }#ifndef HAVE_ELF_PLATFORM const char *get_elf_platform (CPUState *cs) {return NULL ; }#endif +#ifndef HAVE_ELF_BASE_PLATFORM +const char *get_elf_base_platform (CPUState *cs) {return NULL ; } +#endif #include "elf.h"
@@ -1673,7 +1641,7 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc, } u_base_platform =0 ; - k_base_platform =ELF_BASE_PLATFORM ; + k_base_platform =get_elf_base_platform (thread_cpu);if (k_base_platform) {size_t len =strlen (k_base_platform) +1 ;if (STACK_GROWS_DOWN ) {
linux-user/mips/elfload.c +30 -0
@@ -92,3 +92,33 @@ abi_ulong get_elf_hwcap(CPUState *cs)#undef GET_FEATURE_REG_EQU#undef GET_FEATURE_REG_SET#undef GET_FEATURE_INSN + +#define MATCH_PLATFORM_INSN (_flags, _base_platform) \ + do { if ((cpu->env.insn_flags & (_flags)) == _flags) \ + { return _base_platform; } } while (0) + +const char *get_elf_base_platform (CPUState *cs) +{ +MIPSCPU *cpu =MIPS_CPU (cs); + +/* 64 bit ISAs goes first */ +MATCH_PLATFORM_INSN (CPU_MIPS64R6 ,"mips64r6" ); +MATCH_PLATFORM_INSN (CPU_MIPS64R5 ,"mips64r5" ); +MATCH_PLATFORM_INSN (CPU_MIPS64R2 ,"mips64r2" ); +MATCH_PLATFORM_INSN (CPU_MIPS64R1 ,"mips64" ); +MATCH_PLATFORM_INSN (CPU_MIPS5 ,"mips5" ); +MATCH_PLATFORM_INSN (CPU_MIPS4 ,"mips4" ); +MATCH_PLATFORM_INSN (CPU_MIPS3 ,"mips3" ); + +/* 32 bit ISAs */ +MATCH_PLATFORM_INSN (CPU_MIPS32R6 ,"mips32r6" ); +MATCH_PLATFORM_INSN (CPU_MIPS32R5 ,"mips32r5" ); +MATCH_PLATFORM_INSN (CPU_MIPS32R2 ,"mips32r2" ); +MATCH_PLATFORM_INSN (CPU_MIPS32R1 ,"mips32" ); +MATCH_PLATFORM_INSN (CPU_MIPS2 ,"mips2" ); + +/* Fallback */ +return "mips" ; +} + +#undef MATCH_PLATFORM_INSN
Signature · 1 line
2.43.0
PATCH v2 24/95 linux-user: Move target_cpu_copy_regs decl to qemu.h
In reply to Richard HendersonThe function is not used by bsd-user, so placement within include/user/cpu_loop.h is not ideal.
--- include/user/cpu_loop.h | 4 ---- linux-user/qemu.h | 3 +++ 2 files changed, 3 insertions(+), 4 deletions(-)
include/user/cpu_loop.h +0 -4
@@ -81,8 +81,4 @@ void target_exception_dump(CPUArchState *env, const char *fmt, int code);#define EXCP_DUMP (env, fmt, code) \ target_exception_dump(env, fmt, code) -typedef struct target_pt_regs target_pt_regs ; - -void target_cpu_copy_regs (CPUArchState *env,target_pt_regs *regs); -#endif
linux-user/qemu.h +3 -0
@@ -359,4 +359,7 @@ void *lock_user_string(abi_ulong guest_addr);/* Clone cpu state */ CPUArchState *cpu_copy (CPUArchState *env); +typedef struct target_pt_regs target_pt_regs ; +void target_cpu_copy_regs (CPUArchState *env,target_pt_regs *regs); +#endif /* QEMU_H */
Signature · 1 line
2.43.0
PATCH v2 25/95 linux-user: Create do_init_main_thread
In reply to Richard HendersonProvide a unified function to initialize the main thread. Keep target_pt_regs isolated to this function.
--- linux-user/loader.h | 5 ++--- linux-user/elfload.c | 7 +++++-- linux-user/linuxload.c | 6 ++---- linux-user/main.c | 10 +++------- 4 files changed, 12 insertions(+), 16 deletions(-)
linux-user/loader.h +2 -3
@@ -82,12 +82,11 @@ struct linux_binprm {int (*core_dump)(int ,const CPUArchState *);/* coredump routine */ }; -void do_init_thread (struct target_pt_regs *regs,struct image_info *infop); +void do_init_main_thread (CPUState *cs,struct image_info *infop);abi_ulong loader_build_argptr (int envc,int argc,abi_ulong sp,abi_ulong stringp,int push_ptr);int loader_exec (int fdexec,const char *filename,char **argv,char **envp, -struct target_pt_regs *regs,struct image_info *infop, -struct linux_binprm *); +struct image_info *infop,struct linux_binprm *);uint32_t get_elf_eflags (int fd);int load_elf_binary (struct linux_binprm *bprm,struct image_info *info);
linux-user/elfload.c +5 -2
@@ -3619,7 +3619,10 @@ static int elf_core_dump(int signr, const CPUArchState *env) }#endif /* USE_ELF_CORE_DUMP */ -void do_init_thread (struct target_pt_regs *regs,struct image_info *infop) +void do_init_main_thread (CPUState *cs,struct image_info *infop) { -init_thread (regs, infop); +target_pt_regs regs = { }; + +init_thread (®s, infop); +target_cpu_copy_regs (cpu_env (cs), ®s); }
linux-user/linuxload.c +2 -4
@@ -139,8 +139,7 @@ abi_ulong loader_build_argptr(int envc, int argc, abi_ulong sp, }int loader_exec (int fdexec,const char *filename,char **argv,char **envp, -struct target_pt_regs *regs,struct image_info *infop, -struct linux_binprm *bprm) +struct image_info *infop,struct linux_binprm *bprm) {int retval;
@@ -175,8 +174,7 @@ int loader_exec(int fdexec, const char *filename, char **argv, char **envp,return retval; } -/* Success. Initialize important registers. */ -do_init_thread (regs, infop); +/* Success. */ return 0 ; }
linux-user/main.c +3 -7
@@ -696,7 +696,6 @@ static int parse_args(int argc, char **argv)int main (int argc,char **argv,char **envp) { -struct target_pt_regs regs1, *regs = ®s1;struct image_info info1, *info = &info1;struct linux_binprm bprm;TaskState *ts;
@@ -762,9 +761,6 @@ int main(int argc, char **argv, char **envp)trace_init_file ();qemu_plugin_load_list (&plugins, &error_fatal); -/* Zero out regs */ -memset (regs,0 ,sizeof (struct target_pt_regs )); -/* Zero out image_info */ memset (info,0 ,sizeof (struct image_info ));
@@ -988,8 +984,8 @@ int main(int argc, char **argv, char **envp)fd_trans_init (); - ret =loader_exec (execfd, exec_path, target_argv, target_environ, regs, - info, &bprm); + ret =loader_exec (execfd, exec_path, target_argv, target_environ, + info, &bprm);if (ret !=0 ) {printf ("Error while loading %s: %s\n" , exec_path,strerror (-ret));_exit (EXIT_FAILURE );
@@ -1041,7 +1037,7 @@ int main(int argc, char **argv, char **envp)the real value of GUEST_BASE into account. */ tcg_prologue_init (); -target_cpu_copy_regs (env, regs); +do_init_main_thread (cpu, info);if (gdbstub) {gdbserver_start (gdbstub, &error_fatal);
Signature · 1 line
2.43.0
PATCH v2 26/95 linux-user/i386: Create init_main_thread
In reply to Richard HendersonMerge init_thread and target_cpu_copy_regs.
There's no point going through a target_pt_regs intermediate. Temporarily introduce HAVE_INIT_MAIN_THREAD during conversion.
--- linux-user/qemu.h | 1 + linux-user/elfload.c | 29 +++++------------------ linux-user/i386/cpu_loop.c | 48 +++++++++++++++++--------------------- 3 files changed, 29 insertions(+), 49 deletions(-)
linux-user/qemu.h +1 -0
@@ -361,5 +361,6 @@ CPUArchState *cpu_copy(CPUArchState *env);typedef struct target_pt_regs target_pt_regs ;void target_cpu_copy_regs (CPUArchState *env,target_pt_regs *regs); +void init_main_thread (CPUState *cs,struct image_info *info);#endif /* QEMU_H */
linux-user/elfload.c +6 -23
@@ -149,17 +149,12 @@ typedef abi_int target_pid_t;#ifdef TARGET_I386 +#define HAVE_INIT_MAIN_THREAD +#ifdef TARGET_X86_64 #define ELF_CLASS ELFCLASS64#define ELF_ARCH EM_X86_64 -static inline void init_thread (struct target_pt_regs *regs,struct image_info *infop) -{ - regs->rax =0 ; - regs->rsp = infop->start_stack; - regs->rip = infop->entry; -} -#define ELF_NREG 27typedef target_elf_greg_t target_elf_gregset_t [ELF_NREG ];
@@ -237,22 +232,6 @@ static bool init_guest_commpage(void)#define EXSTACK_DEFAULT true -static inline void init_thread (struct target_pt_regs *regs, -struct image_info *infop) -{ - regs->esp = infop->start_stack; - regs->eip = infop->entry; - -/* SVR4/i386 ABI (pages 3-31, 3-32) says that when the program -starts %edx contains a pointer to a function which might be -registered using `atexit'. This provides a mean for the -dynamic linker to call DT_FINI functions for shared libraries -that have been loaded before the code runs. - -A value of 0 tells we have no such handler. */ - regs->edx =0 ; -} -#define ELF_NREG 17typedef target_elf_greg_t target_elf_gregset_t [ELF_NREG ];
@@ -3621,8 +3600,12 @@ static int elf_core_dump(int signr, const CPUArchState *env)void do_init_main_thread (CPUState *cs,struct image_info *infop) { +#ifdef HAVE_INIT_MAIN_THREAD +init_main_thread (cs, infop); +#else target_pt_regs regs = { };init_thread (®s, infop);target_cpu_copy_regs (cpu_env (cs), ®s); +#endif }
linux-user/i386/cpu_loop.c +22 -26
68 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [PATCH v2 26/95] linux-user/i386: Create init_main_thread
Quoted 7 lines · Richard Henderson
Merge
init_threadandtarget_cpu_copy_regs.
There's no point going through atarget_pt_regsintermediate. Temporarily introduceHAVE_INIT_MAIN_THREADduring conversion.Signed-off-by Richard Henderson <[email protected]>---
thanks
-- PMM
PATCH v2 27/95 linux-user/arm: Create init_main_thread
In reply to Richard HendersonMerge init_thread and target_cpu_copy_regs.
There's no point going through a target_pt_regs intermediate.
--- linux-user/arm/cpu_loop.c | 52 +++++++++++++++++++++++++++++++-------- linux-user/elfload.c | 41 +----------------------------- 2 files changed, 43 insertions(+), 50 deletions(-)
linux-user/arm/cpu_loop.c +42 -10
@@ -480,21 +480,53 @@ void cpu_loop(CPUARMState *env) } } -void target_cpu_copy_regs (CPUArchState *env,target_pt_regs *regs) +void init_main_thread (CPUState *cs,struct image_info *info) { -int i; +CPUARMState *env =cpu_env (cs); +abi_ptr stack = info->start_stack; +abi_ptr entry = info->entry; -cpsr_write (env, regs->uregs[16 ],CPSR_USER |CPSR_EXEC , - CPSRWriteByInstr); -for (i =0 ; i <16 ; i++) { - env->regs[i] = regs->uregs[i]; +cpsr_write (env,ARM_CPU_MODE_USR | (entry &1 ?CPSR_T :0 ), +CPSR_USER |CPSR_EXEC , CPSRWriteByInstr); + + env->regs[15 ] = entry &0xfffffffe ; + env->regs[13 ] = stack; + +/* FIXME - what to for failure of get_user()? */ +get_user_ual (env->regs[2 ], stack +8 );/* envp */ +get_user_ual (env->regs[1 ], stack +4 );/* envp */ + +/* +* Per the SVR4 ABI, r0 contains a pointer to a function to be +* registered with atexit. A value of 0 means we have no such handler. +*/ + env->regs[0 ] =0 ; + +/* For uClinux PIC binaries. */ +/* XXX: Linux does this only on ARM with no MMU (do we care?) */ + env->regs[10 ] = info->start_data; + +/* Support ARM FDPIC. */ +if (info_is_fdpic (info)) { +/* +* As described in the ABI document, r7 points to the loadmap info +* prepared by the kernel. If an interpreter is needed, r8 points +* to the interpreter loadmap and r9 points to the interpreter +* PT_DYNAMIC info. If no interpreter is needed, r8 is zero, and +* r9 points to the main program PT_DYNAMIC info. +*/ + env->regs[7 ] = info->loadmap_addr; +if (info->interpreter_loadmap_addr) { +/* Executable is dynamically loaded. */ + env->regs[8 ] = info->interpreter_loadmap_addr; + env->regs[9 ] = info->interpreter_pt_dynamic_addr; + }else { + env->regs[8 ] =0 ; + env->regs[9 ] = info->pt_dynamic_addr; + } }if (TARGET_BIG_ENDIAN ) { -CPUState *cpu =env_cpu (env); -TaskState *ts =get_task_state (cpu); -struct image_info *info = ts->info; -/* Enable BE8. */ if (EF_ARM_EABI_VERSION (info->elf_flags) >=EF_ARM_EABI_VER4 && (info->elf_flags &EF_ARM_BE8 )) {
linux-user/elfload.c +1 -40
47 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [PATCH v2 27/95] linux-user/arm: Create init_main_thread
Quoted 10 lines · Richard Henderson
Merge
init_threadandtarget_cpu_copy_regs.
There's no point going through atarget_pt_regsintermediate.Signed-off-by Richard Henderson <[email protected]>--- linux-user/arm/cpu_loop.c | 52 +++++++++++++++++++++++++++++++-------- linux-user/elfload.c | 41 +----------------------------- 2 files changed, 43 insertions(+), 50 deletions(-)
thanks
-- PMM
PATCH v2 28/95 linux-user/arm: Remove a.out startup remenents
In reply to Richard HendersonThe setting of r1/r2 was removed in kernel commit acfdd4b1f7590d0 ("ARM: 7791/1: a.out: remove partial a.out support"), and the kernel commit message explains the history.
--- linux-user/arm/cpu_loop.c | 4 ---- 1 file changed, 4 deletions(-)
linux-user/arm/cpu_loop.c +0 -4
@@ -492,10 +492,6 @@ void init_main_thread(CPUState *cs, struct image_info *info) env->regs[15 ] = entry &0xfffffffe ; env->regs[13 ] = stack; -/* FIXME - what to for failure of get_user()? */ -get_user_ual (env->regs[2 ], stack +8 );/* envp */ -get_user_ual (env->regs[1 ], stack +4 );/* envp */ -/* * Per the SVR4 ABI, r0 contains a pointer to a function to be * registered with atexit. A value of 0 means we have no such handler.
Signature · 1 line
2.43.0
Re: [PATCH v2 28/95] linux-user/arm: Remove a.out startup remenents
Quoted 26 lines · Richard Henderson
The setting of r1/r2 was removed in kernel commit
acfdd4b1f7590d0("ARM: 7791/1: a.out: remove partial a.out support"), and the kernel commit message explains the history.Signed-off-by Richard Henderson <[email protected]>--- linux-user/arm/cpu_loop.c | 4 ---- 1 file changed, 4 deletions(-)linux-user/arm/cpu_loop.c +0
-5@@ -492,10 +492,6 @@ void init_main_thread(CPUState *cs, struct image_info *info) env->regs[15 ] = entry &0xfffffffe ; env->regs[13 ] = stack; -/* FIXME - what to for failure of get_user()? */ -get_user_ual (env->regs[2 ], stack +8 );/* envp */ -get_user_ual (env->regs[1 ], stack +4 );/* envp */ -/* * Per the SVR4 ABI, r0 contains a pointer to a function to be * registered with atexit. A value of 0 means we have no such handler. --
Quoted 1 line
2.43.0
thanks
-- PMM
PATCH v2 29/95 linux-user/aarch64: Create init_main_thread
In reply to Richard HendersonMerge init_thread and target_cpu_copy_regs.
There's no point going through a target_pt_regs intermediate.
--- linux-user/aarch64/cpu_loop.c | 14 ++++++-------- linux-user/elfload.c | 10 +--------- 2 files changed, 7 insertions(+), 17 deletions(-)
linux-user/aarch64/cpu_loop.c +6 -8
@@ -137,10 +137,10 @@ void cpu_loop(CPUARMState *env) } } -void target_cpu_copy_regs (CPUArchState *env,target_pt_regs *regs) +void init_main_thread (CPUState *cs,struct image_info *info) { +CPUARMState *env =cpu_env (cs);ARMCPU *cpu =env_archcpu (env); -int i;if (!(arm_feature (env,ARM_FEATURE_AARCH64 ))) { fprintf(stderr,
@@ -148,14 +148,12 @@ void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs)exit (EXIT_FAILURE ); } -for (i =0 ; i <31 ; i++) { - env->xregs[i] = regs->regs[i]; - } - env->pc = regs->pc; - env->xregs[31 ] = regs->sp; + env->pc = info->entry & ~0x3ULL ; + env->xregs[31 ] = info->start_stack; +#if TARGET_BIG_ENDIAN env->cp15.sctlr_el[1 ] |=SCTLR_E0E ; -for (i =1 ; i <4 ; ++i) { +for (int i =1 ; i <4 ; ++i) { env->cp15.sctlr_el[i] |=SCTLR_EE ; }arm_rebuild_hflags (env);
linux-user/elfload.c +1 -9
@@ -395,15 +395,7 @@ static const VdsoImageInfo *vdso_image_info(uint32_t elf_flags)#define ELF_ARCH EM_AARCH64#define ELF_CLASS ELFCLASS64 -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)); - - regs->pc = infop->entry & ~0x3ULL ; - regs->sp = stack; -} +#define HAVE_INIT_MAIN_THREAD #define ELF_NREG 34typedef target_elf_greg_t target_elf_gregset_t [ELF_NREG ];
Signature · 1 line
2.43.0
PATCH v2 30/95 linux-user/sparc: Create init_main_thread
In reply to Richard HendersonMerge init_thread and target_cpu_copy_regs.
There's no point going through a target_pt_regs intermediate.
--- linux-user/elfload.c | 12 ++---------- linux-user/sparc/cpu_loop.c | 16 +++++++--------- 2 files changed, 9 insertions(+), 19 deletions(-)
linux-user/elfload.c +2 -10
@@ -438,16 +438,8 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs,# define ELF_ARCH EM_SPARCV9#endif -static inline void init_thread (struct target_pt_regs *regs, -struct image_info *infop) -{ -/* Note that target_cpu_copy_regs does not read psr/tstate. */ - regs->pc = infop->entry; - regs->npc = regs->pc +4 ; - regs->y =0 ; - regs->u_regs[14 ] = (infop->start_stack -16 *sizeof (abi_ulong) - -TARGET_STACK_BIAS ); -} +#define HAVE_INIT_MAIN_THREAD +#endif /* TARGET_SPARC */ #ifdef TARGET_PPC
linux-user/sparc/cpu_loop.c +7 -9
@@ -357,14 +357,12 @@ void cpu_loop (CPUSPARCState *env) } } -void target_cpu_copy_regs (CPUArchState *env,target_pt_regs *regs) +void init_main_thread (CPUState *cs,struct image_info *info) { -int i; - env->pc = regs->pc; - env->npc = regs->npc; - env->y = regs->y; -for (i =0 ; i <8 ; i++) - env->gregs[i] = regs->u_regs[i]; -for (i =0 ; i <8 ; i++) - env->regwptr[i] = regs->u_regs[i +8 ]; +CPUArchState *env =cpu_env (cs); + + env->pc = info->entry; + env->npc = env->pc +4 ; + env->regwptr[WREG_SP ] = (info->start_stack -16 *sizeof (abi_ulong) + -TARGET_STACK_BIAS ); }
Signature · 1 line
2.43.0
PATCH v2 31/95 linux-user/ppc: Create init_main_thread
In reply to Richard HendersonMerge init_thread and target_cpu_copy_regs.
There's no point going through a target_pt_regs intermediate.
--- linux-user/elfload.c | 17 +---------------- linux-user/ppc/cpu_loop.c | 26 ++++++++++++++++++-------- 2 files changed, 19 insertions(+), 24 deletions(-)
linux-user/elfload.c +1 -16
@@ -485,22 +485,7 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs,NEW_AUX_ENT (AT_UCACHEBSIZE ,0 ); \ } while (0) -static inline void init_thread(struct target_pt_regs *_regs, struct image_info *infop) -{ - _regs->gpr[1 ] = infop->start_stack; -#if defined(TARGET_PPC64 ) -if (get_ppc64_abi (infop) <2 ) { -uint64_t val; -get_user_u64 (val, infop->entry +8 ); - _regs->gpr[2 ] = val + infop->load_bias; -get_user_u64 (val, infop->entry); - infop->entry = val + infop->load_bias; - }else { - _regs->gpr[12 ] = infop->entry;/* r12 set to global entry address */ - } -#endif - _regs->nip = infop->entry; -} +#define HAVE_INIT_MAIN_THREAD /* See linux kernel: arch/powerpc/include/asm/elf.h. */ #define ELF_NREG 48
linux-user/ppc/cpu_loop.c +18 -8
@@ -378,21 +378,31 @@ void cpu_loop(CPUPPCState *env) } } -void target_cpu_copy_regs (CPUArchState *env,target_pt_regs *regs) +void init_main_thread (CPUState *cs,struct image_info *info) { -int i; +CPUArchState *env =cpu_env (cs); +abi_ptr entry = info->entry; + + env->gpr[1 ] = info->start_stack; + +#ifdef TARGET_PPC64 +if (get_ppc64_abi (info) <2 ) { +uint64_t val; +get_user_u64 (val, entry +8 ); + env->gpr[2 ] = val + info->load_bias; +get_user_u64 (val, entry); + entry = val + info->load_bias; + }else { + env->gpr[12 ] = entry;/* r12 set to global entry address */ + } -#if defined(TARGET_PPC64 )int flag = (env->insns_flags2 &PPC2_BOOKE206 ) ?MSR_CM :MSR_SF ;#if defined(TARGET_ABI32 )ppc_store_msr (env, env->msr & ~((target_ulong )1 << flag));#else ppc_store_msr (env, env->msr | (target_ulong )1 << flag);#endif -#endif +#endif /* TARGET_PPC64 */ - env->nip = regs->nip; -for (i =0 ; i <32 ; i++) { - env->gpr[i] = regs->gpr[i]; - } + env->nip = entry; }
Signature · 1 line
2.43.0
PATCH v2 32/95 linux-user/loongarch64: Create init_main_thread
In reply to Richard HendersonMerge init_thread and target_cpu_copy_regs.
There's no point going through a target_pt_regs intermediate.
Note that init_thread had set crmd in target_pt_regs, but target_cpu_copy_regs did not copy to env. This turns out to be ok because loongarch_cpu_reset_hold initializes CRMD properly.
--- linux-user/elfload.c | 9 +-------- linux-user/loongarch64/cpu_loop.c | 11 ++++------- 2 files changed, 5 insertions(+), 15 deletions(-)
linux-user/elfload.c +1 -8
@@ -533,14 +533,7 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUPPCState *en#define VDSO_HEADER "vdso.c.inc" -static inline void init_thread (struct target_pt_regs *regs, -struct image_info *infop) -{ -/*Set crmd PG,DA = 1,0 */ - regs->csr.crmd =2 <<3 ; - regs->csr.era = infop->entry; - regs->regs[3 ] = infop->start_stack; -} +#define HAVE_INIT_MAIN_THREAD /* See linux kernel: arch/loongarch/include/asm/elf.h */ #define ELF_NREG 45
linux-user/loongarch64/cpu_loop.c +4 -7
@@ -120,13 +120,10 @@ void cpu_loop(CPULoongArchState *env) } } -void target_cpu_copy_regs (CPUArchState *env,target_pt_regs *regs) +void init_main_thread (CPUState *cs,struct image_info *info) { -int i; - -for (i =0 ; i <32 ; i++) { - env->gpr[i] = regs->regs[i]; - } - env->pc = regs->csr.era; +CPUArchState *env =cpu_env (cs); + env->pc = info->entry; + env->gpr[3 ] = info->start_stack; }
Signature · 1 line
2.43.0
PATCH v2 33/95 linux-user/mips: Create init_main_thread
In reply to Richard HendersonMerge init_thread and target_cpu_copy_regs.
There's no point going through a target_pt_regs intermediate.
Note that init_thread had set cp0_status in target_pt_regs, but target_cpu_copy_regs did not copy to env. This turns out to be ok because mips_cpu_reset_hold initializes CP0_Status properly.
--- linux-user/elfload.c | 8 +------- linux-user/mips/cpu_loop.c | 16 ++++++---------- 2 files changed, 7 insertions(+), 17 deletions(-)
linux-user/elfload.c +1 -7
@@ -581,13 +581,7 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs,#define elf_check_abi (x) (!((x) & EF_MIPS_ABI2))#endif -static inline void init_thread (struct target_pt_regs *regs, -struct image_info *infop) -{ - regs->cp0_status =2 << CP0St_KSU; - regs->cp0_epc = infop->entry; - regs->regs[29 ] = infop->start_stack; -} +#define HAVE_INIT_MAIN_THREAD /* See linux kernel: arch/mips/include/asm/elf.h. */ #define ELF_NREG 45
linux-user/mips/cpu_loop.c +6 -10
@@ -211,12 +211,9 @@ done_syscall: } } -void target_cpu_copy_regs (CPUArchState *env,target_pt_regs *regs) +void init_main_thread (CPUState *cs,struct image_info *info) { -CPUState *cpu =env_cpu (env); -TaskState *ts =get_task_state (cpu); -struct image_info *info = ts->info; -int i; +CPUArchState *env =cpu_env (cs);struct mode_req {bool single;
@@ -245,12 +242,11 @@ void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs)struct mode_req prog_req;struct mode_req interp_req; +target_ulong entry = info->entry; -for (i =0 ; i <32 ; i++) { - env->active_tc.gpr[i] = regs->regs[i]; - } - env->active_tc.PC = regs->cp0_epc & ~(target_ulong )1 ; -if (regs->cp0_epc &1 ) { + env->active_tc.gpr[29 ] = info->start_stack; + env->active_tc.PC = entry & ~(target_ulong )1 ; +if (entry &1 ) { env->hflags |=MIPS_HFLAG_M16 ; }
Signature · 1 line
2.43.0
PATCH v2 34/95 linux-user/microblaze: Create init_main_thread
In reply to Richard HendersonMerge init_thread and target_cpu_copy_regs.
There's no point going through a target_pt_regs intermediate.
--- linux-user/elfload.c | 8 +------ linux-user/microblaze/cpu_loop.c | 39 ++++---------------------------- 2 files changed, 6 insertions(+), 41 deletions(-)
linux-user/elfload.c +1 -7
@@ -640,13 +640,7 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUMIPSState *e#define ELF_CLASS ELFCLASS32#define ELF_ARCH EM_MICROBLAZE -static inline void init_thread (struct target_pt_regs *regs, -struct image_info *infop) -{ - regs->pc = infop->entry; - regs->r1 = infop->start_stack; - -} +#define HAVE_INIT_MAIN_THREAD #define ELF_EXEC_PAGESIZE 4096
linux-user/microblaze/cpu_loop.c +5 -34
@@ -127,39 +127,10 @@ void cpu_loop(CPUMBState *env) } } -void target_cpu_copy_regs (CPUArchState *env,target_pt_regs *regs) +void init_main_thread (CPUState *cs,struct image_info *info) { - env->regs[0 ] = regs->r0; - env->regs[1 ] = regs->r1; - env->regs[2 ] = regs->r2; - env->regs[3 ] = regs->r3; - env->regs[4 ] = regs->r4; - env->regs[5 ] = regs->r5; - env->regs[6 ] = regs->r6; - env->regs[7 ] = regs->r7; - env->regs[8 ] = regs->r8; - env->regs[9 ] = regs->r9; - env->regs[10 ] = regs->r10; - env->regs[11 ] = regs->r11; - env->regs[12 ] = regs->r12; - env->regs[13 ] = regs->r13; - env->regs[14 ] = regs->r14; - env->regs[15 ] = regs->r15; - env->regs[16 ] = regs->r16; - env->regs[17 ] = regs->r17; - env->regs[18 ] = regs->r18; - env->regs[19 ] = regs->r19; - env->regs[20 ] = regs->r20; - env->regs[21 ] = regs->r21; - env->regs[22 ] = regs->r22; - env->regs[23 ] = regs->r23; - env->regs[24 ] = regs->r24; - env->regs[25 ] = regs->r25; - env->regs[26 ] = regs->r26; - env->regs[27 ] = regs->r27; - env->regs[28 ] = regs->r28; - env->regs[29 ] = regs->r29; - env->regs[30 ] = regs->r30; - env->regs[31 ] = regs->r31; - env->pc = regs->pc; +CPUArchState *env =cpu_env (cs); + + env->pc = info->entry; + env->regs[1 ] = info->start_stack; }
Signature · 1 line
2.43.0
PATCH v2 35/95 linux-user/openrisc: Create init_main_thread
In reply to Richard HendersonMerge init_thread and target_cpu_copy_regs.
There's no point going through a target_pt_regs intermediate.
--- linux-user/elfload.c | 7 +------ linux-user/openrisc/cpu_loop.c | 11 ++++------- 2 files changed, 5 insertions(+), 13 deletions(-)
linux-user/elfload.c +1 -6
@@ -673,12 +673,7 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUMBState *env#define ELF_CLASS ELFCLASS32#define ELF_DATA ELFDATA2MSB -static inline void init_thread (struct target_pt_regs *regs, -struct image_info *infop) -{ - regs->pc = infop->entry; - regs->gpr[1 ] = infop->start_stack; -} +#define HAVE_INIT_MAIN_THREAD #define USE_ELF_CORE_DUMP #define ELF_EXEC_PAGESIZE 8192
linux-user/openrisc/cpu_loop.c +4 -7
@@ -83,13 +83,10 @@ void cpu_loop(CPUOpenRISCState *env) } } -void target_cpu_copy_regs (CPUArchState *env,target_pt_regs *regs) +void init_main_thread (CPUState *cs,struct image_info *info) { -int i; +CPUArchState *env =cpu_env (cs); -for (i =0 ; i <32 ; i++) { -cpu_set_gpr (env, i, regs->gpr[i]); - } - env->pc = regs->pc; -cpu_set_sr (env, regs->sr); + env->pc = info->entry; +cpu_set_gpr (env,1 , info->start_stack); }
Signature · 1 line
2.43.0
PATCH v2 36/95 linux-user/sh4: Create init_main_thread
In reply to Richard HendersonMerge init_thread and target_cpu_copy_regs.
There's no point going through a target_pt_regs intermediate.
--- linux-user/elfload.c | 8 +------- linux-user/sh4/cpu_loop.c | 10 ++++------ 2 files changed, 5 insertions(+), 13 deletions(-)
linux-user/elfload.c +1 -7
@@ -701,13 +701,7 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs,#define ELF_CLASS ELFCLASS32#define ELF_ARCH EM_SH -static inline void init_thread (struct target_pt_regs *regs, -struct image_info *infop) -{ -/* Check other registers XXXXX */ - regs->pc = infop->entry; - regs->regs[15 ] = infop->start_stack; -} +#define HAVE_INIT_MAIN_THREAD /* See linux kernel: arch/sh/include/asm/elf.h. */ #define ELF_NREG 23
linux-user/sh4/cpu_loop.c +4 -6
@@ -81,12 +81,10 @@ void cpu_loop(CPUSH4State *env) } } -void target_cpu_copy_regs (CPUArchState *env,target_pt_regs *regs) +void init_main_thread (CPUState *cs,struct image_info *info) { -int i; +CPUArchState *env =cpu_env (cs); -for (i =0 ; i <16 ; i++) { - env->gregs[i] = regs->regs[i]; - } - env->pc = regs->pc; + env->pc = info->entry; + env->gregs[15 ] = info->start_stack; }
Signature · 1 line
2.43.0
PATCH v2 37/95 linux-user/m68k: Create init_main_thread
In reply to Richard HendersonMerge init_thread and target_cpu_copy_regs.
There's no point going through a target_pt_regs intermediate.
--- linux-user/elfload.c | 11 +---------- linux-user/m68k/cpu_loop.c | 25 ++++++------------------- 2 files changed, 7 insertions(+), 29 deletions(-)
linux-user/elfload.c +1 -10
@@ -746,16 +746,7 @@ static inline void elf_core_copy_regs(target_elf_gregset_t *regs,#define ELF_CLASS ELFCLASS32#define ELF_ARCH EM_68K -/* ??? Does this need to do anything? -#define ELF_PLAT_INIT(_r) */ - -static inline void init_thread (struct target_pt_regs *regs, -struct image_info *infop) -{ - regs->usp = infop->start_stack; - regs->sr =0 ; - regs->pc = infop->entry; -} +#define HAVE_INIT_MAIN_THREAD /* See linux kernel: arch/m68k/include/asm/elf.h. */ #define ELF_NREG 20
linux-user/m68k/cpu_loop.c +6 -19
@@ -92,24 +92,11 @@ void cpu_loop(CPUM68KState *env) } } -void target_cpu_copy_regs (CPUArchState *env,target_pt_regs *regs) +void init_main_thread (CPUState *cs,struct image_info *info) { - env->pc = regs->pc; - env->dregs[0 ] = regs->d0; - env->dregs[1 ] = regs->d1; - env->dregs[2 ] = regs->d2; - env->dregs[3 ] = regs->d3; - env->dregs[4 ] = regs->d4; - env->dregs[5 ] = regs->d5; - env->dregs[6 ] = regs->d6; - env->dregs[7 ] = regs->d7; - env->aregs[0 ] = regs->a0; - env->aregs[1 ] = regs->a1; - env->aregs[2 ] = regs->a2; - env->aregs[3 ] = regs->a3; - env->aregs[4 ] = regs->a4; - env->aregs[5 ] = regs->a5; - env->aregs[6 ] = regs->a6; - env->aregs[7 ] = regs->usp; - env->sr = regs->sr; +CPUArchState *env =cpu_env (cs); + + env->pc = info->entry; + env->aregs[7 ] = info->start_stack; + env->sr =0 ; }
Signature · 1 line
2.43.0
PATCH v2 38/95 linux-user/alpha: Create init_main_thread
In reply to Richard HendersonMerge init_thread and target_cpu_copy_regs.
There's no point going through a target_pt_regs intermediate.
Note that init_thread had set ps in target_pt_regs, but target_cpu_copy_regs did not copy to env. This turns out to be ok because alpha_cpu_initfn initializes flags properly.
--- linux-user/alpha/cpu_loop.c | 11 ++++------- linux-user/elfload.c | 8 +------- 2 files changed, 5 insertions(+), 14 deletions(-)
linux-user/alpha/cpu_loop.c +4 -7
@@ -173,13 +173,10 @@ void cpu_loop(CPUAlphaState *env) } } -void target_cpu_copy_regs (CPUArchState *env,target_pt_regs *regs) +void init_main_thread (CPUState *cs,struct image_info *info) { -int i; +CPUArchState *env =cpu_env (cs); -for (i =0 ; i <28 ; i++) { - env->ir[i] = ((abi_ulong *)regs)[i]; - } - env->ir[IR_SP ] = regs->usp; - env->pc = regs->pc; + env->pc = info->entry; + env->ir[IR_SP ] = info->start_stack; }
linux-user/elfload.c +1 -7
@@ -786,13 +786,7 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUM68KState *e#define ELF_CLASS ELFCLASS64#define ELF_ARCH EM_ALPHA -static inline void init_thread (struct target_pt_regs *regs, -struct image_info *infop) -{ - regs->pc = infop->entry; - regs->ps =8 ; - regs->usp = infop->start_stack; -} +#define HAVE_INIT_MAIN_THREAD #define ELF_EXEC_PAGESIZE 8192
Signature · 1 line
2.43.0
PATCH v2 39/95 linux-user/s390x: Create init_main_thread
In reply to Richard HendersonMerge init_thread and target_cpu_copy_regs.
There's no point going through a target_pt_regs intermediate.
--- linux-user/elfload.c | 9 +-------- linux-user/s390x/cpu_loop.c | 15 ++++++++------- 2 files changed, 9 insertions(+), 15 deletions(-)
linux-user/elfload.c +1 -8
@@ -798,14 +798,7 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUM68KState *e#define ELF_DATA ELFDATA2MSB#define ELF_ARCH EM_S390 -static inline void init_thread (struct target_pt_regs *regs,struct image_info *infop) -{ - regs->psw.addr = infop->entry; - regs->psw.mask =PSW_MASK_DAT |PSW_MASK_IO |PSW_MASK_EXT | \ -PSW_MASK_MCHECK |PSW_MASK_PSTATE |PSW_MASK_64 | \ -PSW_MASK_32 ; - regs->gprs[15 ] = infop->start_stack; -} +#define HAVE_INIT_MAIN_THREAD /* See linux kernel: arch/s390/include/uapi/asm/ptrace.h (s390_regs). */ #define ELF_NREG 27
linux-user/s390x/cpu_loop.c +8 -7
@@ -180,12 +180,13 @@ void cpu_loop(CPUS390XState *env) } } -void target_cpu_copy_regs (CPUArchState *env,target_pt_regs *regs) +void init_main_thread (CPUState *cs,struct image_info *info) { -int i; -for (i =0 ; i <16 ; i++) { - env->regs[i] = regs->gprs[i]; - } - env->psw.mask = regs->psw.mask; - env->psw.addr = regs->psw.addr; +CPUArchState *env =cpu_env (cs); + + env->psw.addr = info->entry; + env->psw.mask =PSW_MASK_DAT |PSW_MASK_IO |PSW_MASK_EXT | +PSW_MASK_MCHECK |PSW_MASK_PSTATE |PSW_MASK_64 | +PSW_MASK_32 ; + env->regs[15 ] = info->start_stack; }
Signature · 1 line
2.43.0
PATCH v2 40/95 linux-user/riscv: Create init_main_thread
In reply to Richard HendersonMerge init_thread and target_cpu_copy_regs.
There's no point going through a target_pt_regs intermediate.
--- linux-user/elfload.c | 7 +------ linux-user/riscv/cpu_loop.c | 10 ++++------ 2 files changed, 5 insertions(+), 12 deletions(-)
linux-user/elfload.c +1 -6
@@ -849,12 +849,7 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs,#define VDSO_HEADER "vdso-64.c.inc"#endif -static inline void init_thread (struct target_pt_regs *regs, -struct image_info *infop) -{ - regs->sepc = infop->entry; - regs->sp = infop->start_stack; -} +#define HAVE_INIT_MAIN_THREAD #define ELF_EXEC_PAGESIZE 4096
linux-user/riscv/cpu_loop.c +4 -6
@@ -94,14 +94,12 @@ void cpu_loop(CPURISCVState *env) } } -void target_cpu_copy_regs (CPUArchState *env,target_pt_regs *regs) +void init_main_thread (CPUState *cs,struct image_info *info) { -CPUState *cpu =env_cpu (env); -TaskState *ts =get_task_state (cpu); -struct image_info *info = ts->info; +CPUArchState *env =cpu_env (cs); - env->pc = regs->sepc; - env->gpr[xSP] = regs->sp; + env->pc = info->entry; + env->gpr[xSP] = info->start_stack; env->elf_flags = info->elf_flags;if ((env->misa_ext &RVE ) && !(env->elf_flags &EF_RISCV_RVE )) {
Signature · 1 line
2.43.0
PATCH v2 41/95 linux-user/hppa: Create init_main_thread
In reply to Richard HendersonMerge init_thread and target_cpu_copy_regs.
There's no point going through a target_pt_regs intermediate.
--- linux-user/elfload.c | 13 +------------ linux-user/hppa/cpu_loop.c | 18 +++++++++++------- 2 files changed, 12 insertions(+), 19 deletions(-)
linux-user/elfload.c +1 -12
@@ -864,18 +864,7 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs,#define VDSO_HEADER "vdso.c.inc" -static inline void init_thread (struct target_pt_regs *regs, -struct image_info *infop) -{ - regs->iaoq[0 ] = infop->entry |PRIV_USER ; - regs->iaoq[1 ] = regs->iaoq[0 ] +4 ; - regs->gr[23 ] =0 ; - regs->gr[24 ] = infop->argv; - regs->gr[25 ] = infop->argc; -/* The top-of-stack contains a linkage buffer. */ - regs->gr[30 ] = infop->start_stack +64 ; - regs->gr[31 ] = infop->entry; -} +#define HAVE_INIT_MAIN_THREAD #define LO_COMMPAGE 0
linux-user/hppa/cpu_loop.c +11 -7
@@ -196,12 +196,16 @@ void cpu_loop(CPUHPPAState *env) } } -void target_cpu_copy_regs (CPUArchState *env,target_pt_regs *regs) +void init_main_thread (CPUState *cs,struct image_info *info) { -int i; -for (i =1 ; i <32 ; i++) { - env->gr[i] = regs->gr[i]; - } - env->iaoq_f = regs->iaoq[0 ]; - env->iaoq_b = regs->iaoq[1 ]; +CPUArchState *env =cpu_env (cs); + + env->iaoq_f = info->entry |PRIV_USER ; + env->iaoq_b = env->iaoq_f +4 ; + env->gr[23 ] =0 ; + env->gr[24 ] = info->argv; + env->gr[25 ] = info->argc; +/* The top-of-stack contains a linkage buffer. */ + env->gr[30 ] = info->start_stack +64 ; + env->gr[31 ] = info->entry; }
Signature · 1 line
2.43.0
PATCH v2 42/95 linux-user/xtensa: Create init_main_thread
In reply to Richard HendersonMerge init_thread and target_cpu_copy_regs.
There's no point going through a target_pt_regs intermediate.
--- linux-user/elfload.c | 18 +----------------- linux-user/xtensa/cpu_loop.c | 22 ++++++++++++++++------ 2 files changed, 17 insertions(+), 23 deletions(-)
linux-user/elfload.c +1 -17
@@ -905,23 +905,7 @@ static bool init_guest_commpage(void)#define ELF_CLASS ELFCLASS32#define ELF_ARCH EM_XTENSA -static inline void init_thread (struct target_pt_regs *regs, -struct image_info *infop) -{ - regs->windowbase =0 ; - regs->windowstart =1 ; - regs->areg[1 ] = infop->start_stack; - regs->pc = infop->entry; -if (info_is_fdpic (infop)) { - regs->areg[4 ] = infop->loadmap_addr; - regs->areg[5 ] = infop->interpreter_loadmap_addr; -if (infop->interpreter_loadmap_addr) { - regs->areg[6 ] = infop->interpreter_pt_dynamic_addr; - }else { - regs->areg[6 ] = infop->pt_dynamic_addr; - } - } -} +#define HAVE_INIT_MAIN_THREAD /* See linux kernel: arch/xtensa/include/asm/elf.h. */ #define ELF_NREG 128
linux-user/xtensa/cpu_loop.c +16 -6
@@ -238,12 +238,22 @@ void cpu_loop(CPUXtensaState *env) } } -void target_cpu_copy_regs (CPUArchState *env,target_pt_regs *regs) +void init_main_thread (CPUState *cs,struct image_info *info) { -int i; -for (i =0 ; i <16 ; ++i) { - env->regs[i] = regs->areg[i]; +CPUArchState *env =cpu_env (cs); + + env->sregs[WINDOW_BASE ] =0 ; + env->sregs[WINDOW_START ] =1 ; + env->regs[1 ] = info->start_stack; + env->pc = info->entry; + +if (info_is_fdpic (info)) { + env->regs[4 ] = info->loadmap_addr; + env->regs[5 ] = info->interpreter_loadmap_addr; +if (info->interpreter_loadmap_addr) { + env->regs[6 ] = info->interpreter_pt_dynamic_addr; + }else { + env->regs[6 ] = info->pt_dynamic_addr; + } } - env->sregs[WINDOW_START ] = regs->windowstart; - env->pc = regs->pc; }
Signature · 1 line
2.43.0
PATCH v2 43/95 linux-user/hexagon: Create init_main_thread
In reply to Richard HendersonMerge init_thread and target_cpu_copy_regs.
There's no point going through a target_pt_regs intermediate.
--- linux-user/elfload.c | 7 +------ linux-user/hexagon/cpu_loop.c | 8 +++++--- 2 files changed, 6 insertions(+), 9 deletions(-)
linux-user/elfload.c +1 -6
@@ -954,12 +954,7 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs,#define ELF_CLASS ELFCLASS32#define ELF_ARCH EM_HEXAGON -static inline void init_thread (struct target_pt_regs *regs, -struct image_info *infop) -{ - regs->sepc = infop->entry; - regs->sp = infop->start_stack; -} +#define HAVE_INIT_MAIN_THREAD #endif /* TARGET_HEXAGON */
linux-user/hexagon/cpu_loop.c +5 -3
@@ -79,9 +79,11 @@ void cpu_loop(CPUHexagonState *env) } } -void target_cpu_copy_regs (CPUArchState *env,target_pt_regs *regs) +void init_main_thread (CPUState *cs,struct image_info *info) { - env->gpr[HEX_REG_PC ] = regs->sepc; - env->gpr[HEX_REG_SP ] = regs->sp; +CPUArchState *env =cpu_env (cs); + + env->gpr[HEX_REG_PC ] = info->entry; + env->gpr[HEX_REG_SP ] = info->start_stack; env->gpr[HEX_REG_USR ] =0x56000 ; }
Signature · 1 line
2.43.0
PATCH v2 44/95 linux-user: Remove do_init_main_thread
In reply to Richard HendersonAll targets have been converted, so we can call init_main_thread directly. Remove do_init_main_thread and HAVE_INIT_MAIN_THREAD.
--- linux-user/loader.h | 1 - linux-user/qemu.h | 2 -- linux-user/elfload.c | 46 -------------------------------------------- linux-user/main.c | 2 +- 4 files changed, 1 insertion(+), 50 deletions(-)
linux-user/loader.h +0 -1
@@ -82,7 +82,6 @@ struct linux_binprm {int (*core_dump)(int ,const CPUArchState *);/* coredump routine */ }; -void do_init_main_thread (CPUState *cs,struct image_info *infop);abi_ulong loader_build_argptr (int envc,int argc,abi_ulong sp,abi_ulong stringp,int push_ptr); int loader_exec(int fdexec, const char *filename, char **argv, char **envp,
linux-user/qemu.h +0 -2
@@ -359,8 +359,6 @@ void *lock_user_string(abi_ulong guest_addr);/* Clone cpu state */ CPUArchState *cpu_copy (CPUArchState *env); -typedef struct target_pt_regs target_pt_regs ; -void target_cpu_copy_regs (CPUArchState *env,target_pt_regs *regs);void init_main_thread (CPUState *cs,struct image_info *info);#endif /* QEMU_H */
linux-user/elfload.c +0 -46
151 lines not on this page · raw message
linux-user/main.c +1 -1
@@ -1037,7 +1037,7 @@ int main(int argc, char **argv, char **envp)the real value of GUEST_BASE into account. */ tcg_prologue_init (); -do_init_main_thread (cpu, info); +init_main_thread (cpu, info);if (gdbstub) {gdbserver_start (gdbstub, &error_fatal);
Signature · 1 line
2.43.0
PATCH v2 45/95 linux-user: Remove target_elf_greg_t
In reply to Richard HendersonThis typedef is synonymous with target_ulong.
--- linux-user/elfload.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-)
linux-user/elfload.c +13 -16
@@ -131,10 +131,8 @@ int info_is_fdpic(struct image_info *info)#endif #ifdef TARGET_ABI_MIPSN32 -typedef abi_ullong target_elf_greg_t ;#define tswapreg (ptr) tswap64(ptr)#else -typedef abi_ulong target_elf_greg_t ;#define tswapreg (ptr) tswapal(ptr)#endif
@@ -154,7 +152,7 @@ typedef abi_int target_pid_t;#define ELF_ARCH EM_X86_64#define ELF_NREG 27 -typedef target_elf_greg_t target_elf_gregset_t [ELF_NREG ]; +typedef target_ulong target_elf_gregset_t [ELF_NREG ];/* * Note that ELF_NREG should be 29 as there should be place for
@@ -231,7 +229,7 @@ static bool init_guest_commpage(void)#define EXSTACK_DEFAULT true#define ELF_NREG 17 -typedef target_elf_greg_t target_elf_gregset_t [ELF_NREG ]; +typedef target_ulong target_elf_gregset_t [ELF_NREG ];/* * Note that ELF_NREG should be 19 as there should be place for
@@ -292,7 +290,7 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUX86State *en#define EXSTACK_DEFAULT true#define ELF_NREG 18 -typedef target_elf_greg_t target_elf_gregset_t [ELF_NREG ]; +typedef target_ulong target_elf_gregset_t [ELF_NREG ];static void elf_core_copy_regs (target_elf_gregset_t *regs,const CPUARMState *env) {
@@ -392,7 +390,7 @@ static const VdsoImageInfo *vdso_image_info(uint32_t elf_flags)#define ELF_CLASS ELFCLASS64#define ELF_NREG 34 -typedef target_elf_greg_t target_elf_gregset_t [ELF_NREG ]; +typedef target_ulong target_elf_gregset_t [ELF_NREG ];static void elf_core_copy_regs (target_elf_gregset_t *regs,const CPUARMState *env)
@@ -479,7 +477,7 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs,/* See linux kernel: arch/powerpc/include/asm/elf.h. */ #define ELF_NREG 48 -typedef target_elf_greg_t target_elf_gregset_t [ELF_NREG ]; +typedef target_ulong target_elf_gregset_t [ELF_NREG ];static void elf_core_copy_regs (target_elf_gregset_t *regs,const CPUPPCState *env) {
@@ -525,7 +523,7 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUPPCState *en/* See linux kernel: arch/loongarch/include/asm/elf.h */ #define ELF_NREG 45 -typedef target_elf_greg_t target_elf_gregset_t [ELF_NREG ]; +typedef target_ulong target_elf_gregset_t [ELF_NREG ];enum {TARGET_EF_R0 =0 ,
@@ -571,7 +569,7 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs,/* See linux kernel: arch/mips/include/asm/elf.h. */ #define ELF_NREG 45 -typedef target_elf_greg_t target_elf_gregset_t [ELF_NREG ]; +typedef target_ulong target_elf_gregset_t [ELF_NREG ];/* See linux kernel: arch/mips/include/asm/reg.h. */ enum {
@@ -630,7 +628,7 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUMIPSState *e#define USE_ELF_CORE_DUMP #define ELF_NREG 38 -typedef target_elf_greg_t target_elf_gregset_t [ELF_NREG ]; +typedef target_ulong target_elf_gregset_t [ELF_NREG ];/* See linux kernel: arch/mips/kernel/process.c:elf_dump_regs. */ static void elf_core_copy_regs (target_elf_gregset_t *regs,const CPUMBState *env)
@@ -662,7 +660,7 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUMBState *env/* See linux kernel arch/openrisc/include/asm/elf.h. */ #define ELF_NREG 34/* gprs and pc, sr */ -typedef target_elf_greg_t target_elf_gregset_t [ELF_NREG ]; +typedef target_ulong target_elf_gregset_t [ELF_NREG ];static void elf_core_copy_regs (target_elf_gregset_t *regs,const CPUOpenRISCState *env)
@@ -685,7 +683,7 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs,/* See linux kernel: arch/sh/include/asm/elf.h. */ #define ELF_NREG 23 -typedef target_elf_greg_t target_elf_gregset_t [ELF_NREG ]; +typedef target_ulong target_elf_gregset_t [ELF_NREG ];/* See linux kernel: arch/sh/include/asm/ptrace.h. */ enum {
@@ -728,7 +726,7 @@ static inline void elf_core_copy_regs(target_elf_gregset_t *regs,/* See linux kernel: arch/m68k/include/asm/elf.h. */ #define ELF_NREG 20 -typedef target_elf_greg_t target_elf_gregset_t [ELF_NREG ]; +typedef target_ulong target_elf_gregset_t [ELF_NREG ];static void elf_core_copy_regs (target_elf_gregset_t *regs,const CPUM68KState *env) {
@@ -776,7 +774,7 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUM68KState *e/* See linux kernel: arch/s390/include/uapi/asm/ptrace.h (s390_regs). */ #define ELF_NREG 27 -typedef target_elf_greg_t target_elf_gregset_t [ELF_NREG ]; +typedef target_ulong target_elf_gregset_t [ELF_NREG ];enum {TARGET_REG_PSWM =0 ,
@@ -877,7 +875,7 @@ static bool init_guest_commpage(void)/* See linux kernel: arch/xtensa/include/asm/elf.h. */ #define ELF_NREG 128 -typedef target_elf_greg_t target_elf_gregset_t [ELF_NREG ]; +typedef target_ulong target_elf_gregset_t [ELF_NREG ];enum {TARGET_REG_PC ,
@@ -2864,7 +2862,6 @@ int load_elf_binary(struct linux_binprm *bprm, struct image_info *info)* Next you define type of register set used for dumping. ELF specification * says that it needs to be array of elf_greg_t that has size of ELF_NREG. * -* typedef <target_regtype> target_elf_greg_t; * #define ELF_NREG <number of registers> * typedef taret_elf_greg_t target_elf_gregset_t[ELF_NREG]; *
Signature · 1 line
2.43.0
Re: [PATCH v2 45/95] linux-user: Remove target_elf_greg_t
Quoted 13 lines · Richard Henderson
This typedef is synonymous with
target_ulong.Signed-off-by Richard Henderson <[email protected]>--- linux-user/elfload.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-)linux-user/elfload.c +0
-0
linux-user/elfload.c int info_is_fdpic(struct image_info *info) · line 137
Quoted 9 lines
linux-user/elfload.c +0
-2@@ -131,10 +131,8 @@ int info_is_fdpic(struct image_info *info)#endif #ifdef TARGET_ABI_MIPSN32 -typedef abi_ullong target_elf_greg_t ;#define tswapreg (ptr) tswap64(ptr)#else -typedef abi_ulong target_elf_greg_t ;#define tswapreg (ptr) tswapal(ptr)#endif
Previously we had target_elf_greg_t:
* for MIPSN32: abi_ullong, which is 64 bits
* for other TARGET_ABI32: abi_ulong, which is 32 bits
* for 64-bit archs: abi_ulong, which is 64 bits
* for 32-bit archs: abi_ulong, which is 32 bits
Now we have target_ulong, which is:
* for 64-bit archs: 64 bits
* for 32-bit archs: 32 bits
So the two TARGET_ABI32 which weren't special cased (hppa and sparc32plus) will go from a 32-bit type to a 64-bit type, won't they ?
It wouldn't surprise me if this is a bug in the hppa and sparc32plus cases, but if so we should say in the commit message that we're fixing it.
thanks
-- PMM
Re: [PATCH v2 45/95] linux-user: Remove target_elf_greg_t
Quoted 17 lines · Peter Maydell
Quoted 15 lines · Richard Henderson
This typedef is synonymous with
target_ulong.Signed-off-by Richard Henderson <[email protected]>--- linux-user/elfload.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-)linux-user/elfload.c +0
-0@@ -131,10 +131,8 @@ int info_is_fdpic(struct image_info *info)#endif
Quoted 10 lines
linux-user/elfload.c int info_is_fdpic(struct image_info *info) · line 137
Quoted 7 lines
linux-user/elfload.c +0
-2#ifdef TARGET_ABI_MIPSN32 -typedef abi_ullong target_elf_greg_t ;#define tswapreg (ptr) tswap64(ptr)#else -typedef abi_ulong target_elf_greg_t ;#define tswapreg (ptr) tswapal(ptr)#endif Previously we had
target_elf_greg_t:
* for MIPSN32:abi_ullong, which is 64 bits
MIPSN32 is a mips64 target.
Quoted 8 lines
* for other
TARGET_ABI32:abi_ulong, which is 32 bits
* for 64-bit archs:abi_ulong, which is 64 bits
* for 32-bit archs:abi_ulong, which is 32 bitsNow we have
target_ulong, which is:
* for 64-bit archs: 64 bits
* for 32-bit archs: 32 bits
Quoted 7 lines
So the two
TARGET_ABI32which weren't special cased (hppa and sparc32plus) will go from a 32-bit type to a 64-bit type, won't they ?It wouldn't surprise me if this is a bug in the hppa and sparc32plus cases, but if so we should say in the commit message that we're fixing it.
Neither sparc nor hppa implement core dumps so far, so we can put off considering them.
Perhaps the commit message can simply be expanded to
For the set of targets which support core dumps, target_elf_greg_t is synonymous with target_ulong.
?
r~
Re: [PATCH v2 45/95] linux-user: Remove target_elf_greg_t
Quoted 44 lines · Richard Henderson
Quoted 17 lines · Peter Maydell
Quoted 15 lines · Richard Henderson
This typedef is synonymous with
target_ulong.Signed-off-by Richard Henderson <[email protected]>--- linux-user/elfload.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-)linux-user/elfload.c +0
-0@@ -131,10 +131,8 @@ int info_is_fdpic(struct image_info *info)#endif Quoted 10 lines
linux-user/elfload.c int info_is_fdpic(struct image_info *info) · line 137
Quoted 7 lines
linux-user/elfload.c +0
-2#ifdef TARGET_ABI_MIPSN32 -typedef abi_ullong target_elf_greg_t ;#define tswapreg (ptr) tswap64(ptr)#else -typedef abi_ulong target_elf_greg_t ;#define tswapreg (ptr) tswapal(ptr)#endif Previously we had
target_elf_greg_t:
* for MIPSN32:abi_ullong, which is 64 bitsMIPSN32 is a mips64 target.
Quoted 12 lines
* for other
TARGET_ABI32:abi_ulong, which is 32 bits
* for 64-bit archs:abi_ulong, which is 64 bits
* for 32-bit archs:abi_ulong, which is 32 bitsNow we have
target_ulong, which is:
* for 64-bit archs: 64 bits
* for 32-bit archs: 32 bitsSo the two
TARGET_ABI32which weren't special cased (hppa and sparc32plus) will go from a 32-bit type to a 64-bit type, won't they ?
Quoted 6 lines
Quoted 3 lines
It wouldn't surprise me if this is a bug in the hppa and sparc32plus cases, but if so we should say in the commit message that we're fixing it.
Neither sparc nor hppa implement core dumps so far, so we can put off considering them.
I guess so, but if we have to undo the refactoring because it doesn't fit those architectures that would be annoying.
I had a look at the kernel sources and I think that here mips N32 really is an outlier -- arch/mips/include/asm/elfcore-compat.h defines the compat_elf_gregset_t to be the same as the (64-bit) elf_gregset_t, and has some macro magic to handle the O32 case which does have 32-bit registers.
On the other hand arch/parisc/include/asm/compat.h and arch/sparc/include/asm/elf_64.h both define the compat_elf_gregset_t type as 32-bit.
So I think it would be good to have at least a sketch of how hppa and sparc32plus would work in the new setup and why we wouldn't need to reintroduce the target_elf_greg_t type, before we rip it out.
thanks
-- PMM
PATCH v2 46/95 linux-user: Replace tswapreg with tswapl
In reply to Richard HendersonWith the removal of target_elf_greg_t, we don't need a special case tswap. Use tswapl for target_ulong.
--- linux-user/elfload.c | 264 +++++++++++++++++++++---------------------- 1 file changed, 129 insertions(+), 135 deletions(-)
linux-user/elfload.c +129 -135
@@ -130,12 +130,6 @@ int info_is_fdpic(struct image_info *info)#define ELF_DATA ELFDATA2LSB#endif -#ifdef TARGET_ABI_MIPSN32 -#define tswapreg (ptr) tswap64(ptr) -#else -#define tswapreg (ptr) tswapal(ptr) -#endif -#ifdef USE_UID16 typedef abi_ushort target_uid_t ;typedef abi_ushort target_gid_t ;
@@ -163,33 +157,33 @@ typedef target_ulong target_elf_gregset_t[ELF_NREG];*/ static void elf_core_copy_regs (target_elf_gregset_t *regs,const CPUX86State *env) { - (*regs)[0 ] =tswapreg (env->regs[15 ]); - (*regs)[1 ] =tswapreg (env->regs[14 ]); - (*regs)[2 ] =tswapreg (env->regs[13 ]); - (*regs)[3 ] =tswapreg (env->regs[12 ]); - (*regs)[4 ] =tswapreg (env->regs[R_EBP ]); - (*regs)[5 ] =tswapreg (env->regs[R_EBX ]); - (*regs)[6 ] =tswapreg (env->regs[11 ]); - (*regs)[7 ] =tswapreg (env->regs[10 ]); - (*regs)[8 ] =tswapreg (env->regs[9 ]); - (*regs)[9 ] =tswapreg (env->regs[8 ]); - (*regs)[10 ] =tswapreg (env->regs[R_EAX ]); - (*regs)[11 ] =tswapreg (env->regs[R_ECX ]); - (*regs)[12 ] =tswapreg (env->regs[R_EDX ]); - (*regs)[13 ] =tswapreg (env->regs[R_ESI ]); - (*regs)[14 ] =tswapreg (env->regs[R_EDI ]); - (*regs)[15 ] =tswapreg (get_task_state (env_cpu_const (env))->orig_ax); - (*regs)[16 ] =tswapreg (env->eip); - (*regs)[17 ] =tswapreg (env->segs[R_CS ].selector &0xffff ); - (*regs)[18 ] =tswapreg (env->eflags); - (*regs)[19 ] =tswapreg (env->regs[R_ESP ]); - (*regs)[20 ] =tswapreg (env->segs[R_SS ].selector &0xffff ); - (*regs)[21 ] =tswapreg (env->segs[R_FS ].selector &0xffff ); - (*regs)[22 ] =tswapreg (env->segs[R_GS ].selector &0xffff ); - (*regs)[23 ] =tswapreg (env->segs[R_DS ].selector &0xffff ); - (*regs)[24 ] =tswapreg (env->segs[R_ES ].selector &0xffff ); - (*regs)[25 ] =tswapreg (env->segs[R_FS ].selector &0xffff ); - (*regs)[26 ] =tswapreg (env->segs[R_GS ].selector &0xffff ); + (*regs)[0 ] =tswapl (env->regs[15 ]); + (*regs)[1 ] =tswapl (env->regs[14 ]); + (*regs)[2 ] =tswapl (env->regs[13 ]); + (*regs)[3 ] =tswapl (env->regs[12 ]); + (*regs)[4 ] =tswapl (env->regs[R_EBP ]); + (*regs)[5 ] =tswapl (env->regs[R_EBX ]); + (*regs)[6 ] =tswapl (env->regs[11 ]); + (*regs)[7 ] =tswapl (env->regs[10 ]); + (*regs)[8 ] =tswapl (env->regs[9 ]); + (*regs)[9 ] =tswapl (env->regs[8 ]); + (*regs)[10 ] =tswapl (env->regs[R_EAX ]); + (*regs)[11 ] =tswapl (env->regs[R_ECX ]); + (*regs)[12 ] =tswapl (env->regs[R_EDX ]); + (*regs)[13 ] =tswapl (env->regs[R_ESI ]); + (*regs)[14 ] =tswapl (env->regs[R_EDI ]); + (*regs)[15 ] =tswapl (get_task_state (env_cpu_const (env))->orig_ax); + (*regs)[16 ] =tswapl (env->eip); + (*regs)[17 ] =tswapl (env->segs[R_CS ].selector &0xffff ); + (*regs)[18 ] =tswapl (env->eflags); + (*regs)[19 ] =tswapl (env->regs[R_ESP ]); + (*regs)[20 ] =tswapl (env->segs[R_SS ].selector &0xffff ); + (*regs)[21 ] =tswapl (env->segs[R_FS ].selector &0xffff ); + (*regs)[22 ] =tswapl (env->segs[R_GS ].selector &0xffff ); + (*regs)[23 ] =tswapl (env->segs[R_DS ].selector &0xffff ); + (*regs)[24 ] =tswapl (env->segs[R_ES ].selector &0xffff ); + (*regs)[25 ] =tswapl (env->segs[R_FS ].selector &0xffff ); + (*regs)[26 ] =tswapl (env->segs[R_GS ].selector &0xffff ); }#if ULONG_MAX >UINT32_MAX
@@ -240,23 +234,23 @@ typedef target_ulong target_elf_gregset_t[ELF_NREG];*/ static void elf_core_copy_regs (target_elf_gregset_t *regs,const CPUX86State *env) { - (*regs)[0 ] =tswapreg (env->regs[R_EBX ]); - (*regs)[1 ] =tswapreg (env->regs[R_ECX ]); - (*regs)[2 ] =tswapreg (env->regs[R_EDX ]); - (*regs)[3 ] =tswapreg (env->regs[R_ESI ]); - (*regs)[4 ] =tswapreg (env->regs[R_EDI ]); - (*regs)[5 ] =tswapreg (env->regs[R_EBP ]); - (*regs)[6 ] =tswapreg (env->regs[R_EAX ]); - (*regs)[7 ] =tswapreg (env->segs[R_DS ].selector &0xffff ); - (*regs)[8 ] =tswapreg (env->segs[R_ES ].selector &0xffff ); - (*regs)[9 ] =tswapreg (env->segs[R_FS ].selector &0xffff ); - (*regs)[10 ] =tswapreg (env->segs[R_GS ].selector &0xffff ); - (*regs)[11 ] =tswapreg (get_task_state (env_cpu_const (env))->orig_ax); - (*regs)[12 ] =tswapreg (env->eip); - (*regs)[13 ] =tswapreg (env->segs[R_CS ].selector &0xffff ); - (*regs)[14 ] =tswapreg (env->eflags); - (*regs)[15 ] =tswapreg (env->regs[R_ESP ]); - (*regs)[16 ] =tswapreg (env->segs[R_SS ].selector &0xffff ); + (*regs)[0 ] =tswapl (env->regs[R_EBX ]); + (*regs)[1 ] =tswapl (env->regs[R_ECX ]); + (*regs)[2 ] =tswapl (env->regs[R_EDX ]); + (*regs)[3 ] =tswapl (env->regs[R_ESI ]); + (*regs)[4 ] =tswapl (env->regs[R_EDI ]); + (*regs)[5 ] =tswapl (env->regs[R_EBP ]); + (*regs)[6 ] =tswapl (env->regs[R_EAX ]); + (*regs)[7 ] =tswapl (env->segs[R_DS ].selector &0xffff ); + (*regs)[8 ] =tswapl (env->segs[R_ES ].selector &0xffff ); + (*regs)[9 ] =tswapl (env->segs[R_FS ].selector &0xffff ); + (*regs)[10 ] =tswapl (env->segs[R_GS ].selector &0xffff ); + (*regs)[11 ] =tswapl (get_task_state (env_cpu_const (env))->orig_ax); + (*regs)[12 ] =tswapl (env->eip); + (*regs)[13 ] =tswapl (env->segs[R_CS ].selector &0xffff ); + (*regs)[14 ] =tswapl (env->eflags); + (*regs)[15 ] =tswapl (env->regs[R_ESP ]); + (*regs)[16 ] =tswapl (env->segs[R_SS ].selector &0xffff ); }/*
@@ -294,25 +288,25 @@ typedef target_ulong target_elf_gregset_t[ELF_NREG];static void elf_core_copy_regs (target_elf_gregset_t *regs,const CPUARMState *env) { - (*regs)[0 ] =tswapreg (env->regs[0 ]); - (*regs)[1 ] =tswapreg (env->regs[1 ]); - (*regs)[2 ] =tswapreg (env->regs[2 ]); - (*regs)[3 ] =tswapreg (env->regs[3 ]); - (*regs)[4 ] =tswapreg (env->regs[4 ]); - (*regs)[5 ] =tswapreg (env->regs[5 ]); - (*regs)[6 ] =tswapreg (env->regs[6 ]); - (*regs)[7 ] =tswapreg (env->regs[7 ]); - (*regs)[8 ] =tswapreg (env->regs[8 ]); - (*regs)[9 ] =tswapreg (env->regs[9 ]); - (*regs)[10 ] =tswapreg (env->regs[10 ]); - (*regs)[11 ] =tswapreg (env->regs[11 ]); - (*regs)[12 ] =tswapreg (env->regs[12 ]); - (*regs)[13 ] =tswapreg (env->regs[13 ]); - (*regs)[14 ] =tswapreg (env->regs[14 ]); - (*regs)[15 ] =tswapreg (env->regs[15 ]); + (*regs)[0 ] =tswapl (env->regs[0 ]); + (*regs)[1 ] =tswapl (env->regs[1 ]); + (*regs)[2 ] =tswapl (env->regs[2 ]); + (*regs)[3 ] =tswapl (env->regs[3 ]); + (*regs)[4 ] =tswapl (env->regs[4 ]); + (*regs)[5 ] =tswapl (env->regs[5 ]); + (*regs)[6 ] =tswapl (env->regs[6 ]); + (*regs)[7 ] =tswapl (env->regs[7 ]); + (*regs)[8 ] =tswapl (env->regs[8 ]); + (*regs)[9 ] =tswapl (env->regs[9 ]); + (*regs)[10 ] =tswapl (env->regs[10 ]); + (*regs)[11 ] =tswapl (env->regs[11 ]); + (*regs)[12 ] =tswapl (env->regs[12 ]); + (*regs)[13 ] =tswapl (env->regs[13 ]); + (*regs)[14 ] =tswapl (env->regs[14 ]); + (*regs)[15 ] =tswapl (env->regs[15 ]); - (*regs)[16 ] =tswapreg (cpsr_read ((CPUARMState *)env)); - (*regs)[17 ] =tswapreg (env->regs[0 ]);/* XXX */ + (*regs)[16 ] =tswapl (cpsr_read ((CPUARMState *)env)); + (*regs)[17 ] =tswapl (env->regs[0 ]);/* XXX */ }#define USE_ELF_CORE_DUMP
@@ -398,10 +392,10 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs,int i;for (i =0 ; i <32 ; i++) { - (*regs)[i] =tswapreg (env->xregs[i]); + (*regs)[i] =tswapl (env->xregs[i]); } - (*regs)[32 ] =tswapreg (env->pc); - (*regs)[33 ] =tswapreg (pstate_read ((CPUARMState *)env)); + (*regs)[32 ] =tswapl (env->pc); + (*regs)[33 ] =tswapl (pstate_read ((CPUARMState *)env)); }#define USE_ELF_CORE_DUMP
@@ -485,17 +479,17 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUPPCState *entarget_ulong ccr =0 ;for (i =0 ; i <ARRAY_SIZE (env->gpr); i++) { - (*regs)[i] =tswapreg (env->gpr[i]); + (*regs)[i] =tswapl (env->gpr[i]); } - (*regs)[32 ] =tswapreg (env->nip); - (*regs)[33 ] =tswapreg (env->msr); - (*regs)[35 ] =tswapreg (env->ctr); - (*regs)[36 ] =tswapreg (env->lr); - (*regs)[37 ] =tswapreg (cpu_read_xer (env)); + (*regs)[32 ] =tswapl (env->nip); + (*regs)[33 ] =tswapl (env->msr); + (*regs)[35 ] =tswapl (env->ctr); + (*regs)[36 ] =tswapl (env->lr); + (*regs)[37 ] =tswapl (cpu_read_xer (env)); ccr =ppc_get_cr (env); - (*regs)[38 ] =tswapreg (ccr); + (*regs)[38 ] =tswapl (ccr); }#define USE_ELF_CORE_DUMP
@@ -539,11 +533,11 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, (*regs)[TARGET_EF_R0 ] =0 ;for (i =1 ; i <ARRAY_SIZE (env->gpr); i++) { - (*regs)[TARGET_EF_R0 + i] =tswapreg (env->gpr[i]); + (*regs)[TARGET_EF_R0 + i] =tswapl (env->gpr[i]); } - (*regs)[TARGET_EF_CSR_ERA ] =tswapreg (env->pc); - (*regs)[TARGET_EF_CSR_BADV ] =tswapreg (env->CSR_BADV); + (*regs)[TARGET_EF_CSR_ERA ] =tswapl (env->pc); + (*regs)[TARGET_EF_CSR_BADV ] =tswapl (env->CSR_BADV); }#define USE_ELF_CORE_DUMP
@@ -599,17 +593,17 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUMIPSState *e (*regs)[TARGET_EF_R0 ] =0 ;for (i =1 ; i <ARRAY_SIZE (env->active_tc.gpr); i++) { - (*regs)[TARGET_EF_R0 + i] =tswapreg (env->active_tc.gpr[i]); + (*regs)[TARGET_EF_R0 + i] =tswapl (env->active_tc.gpr[i]); } (*regs)[TARGET_EF_R26 ] =0 ; (*regs)[TARGET_EF_R27 ] =0 ; - (*regs)[TARGET_EF_LO ] =tswapreg (env->active_tc.LO[0 ]); - (*regs)[TARGET_EF_HI ] =tswapreg (env->active_tc.HI[0 ]); - (*regs)[TARGET_EF_CP0_EPC ] =tswapreg (env->active_tc.PC); - (*regs)[TARGET_EF_CP0_BADVADDR ] =tswapreg (env->CP0_BadVAddr); - (*regs)[TARGET_EF_CP0_STATUS ] =tswapreg (env->CP0_Status); - (*regs)[TARGET_EF_CP0_CAUSE ] =tswapreg (env->CP0_Cause); + (*regs)[TARGET_EF_LO ] =tswapl (env->active_tc.LO[0 ]); + (*regs)[TARGET_EF_HI ] =tswapl (env->active_tc.HI[0 ]); + (*regs)[TARGET_EF_CP0_EPC ] =tswapl (env->active_tc.PC); + (*regs)[TARGET_EF_CP0_BADVADDR ] =tswapl (env->CP0_BadVAddr); + (*regs)[TARGET_EF_CP0_STATUS ] =tswapl (env->CP0_Status); + (*regs)[TARGET_EF_CP0_CAUSE ] =tswapl (env->CP0_Cause); }#define USE_ELF_CORE_DUMP
@@ -636,15 +630,15 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUMBState *envint i, pos =0 ;for (i =0 ; i <32 ; i++) { - (*regs)[pos++] =tswapreg (env->regs[i]); + (*regs)[pos++] =tswapl (env->regs[i]); } - (*regs)[pos++] =tswapreg (env->pc); - (*regs)[pos++] =tswapreg (mb_cpu_read_msr (env)); + (*regs)[pos++] =tswapl (env->pc); + (*regs)[pos++] =tswapl (mb_cpu_read_msr (env)); (*regs)[pos++] =0 ; - (*regs)[pos++] =tswapreg (env->ear); + (*regs)[pos++] =tswapl (env->ear); (*regs)[pos++] =0 ; - (*regs)[pos++] = tswapreg(env->esr); + (*regs)[pos++] = tswapl(env->esr); }#endif /* TARGET_MICROBLAZE */
@@ -668,10 +662,10 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs,int i;for (i =0 ; i <32 ; i++) { - (*regs)[i] =tswapreg (cpu_get_gpr (env, i)); + (*regs)[i] =tswapl (cpu_get_gpr (env, i)); } - (*regs)[32 ] =tswapreg (env->pc); - (*regs)[33] = tswapreg(cpu_get_sr(env)); + (*regs)[32 ] =tswapl (env->pc); + (*regs)[33] = tswapl(cpu_get_sr(env)); }#endif /* TARGET_OPENRISC */
@@ -702,15 +696,15 @@ static inline void elf_core_copy_regs(target_elf_gregset_t *regs,int i;for (i =0 ; i <16 ; i++) { - (*regs)[i] =tswapreg (env->gregs[i]); + (*regs)[i] =tswapl (env->gregs[i]); } - (*regs)[TARGET_REG_PC ] =tswapreg (env->pc); - (*regs)[TARGET_REG_PR ] =tswapreg (env->pr); - (*regs)[TARGET_REG_SR ] =tswapreg (env->sr); - (*regs)[TARGET_REG_GBR ] =tswapreg (env->gbr); - (*regs)[TARGET_REG_MACH ] =tswapreg (env->mach); - (*regs)[TARGET_REG_MACL ] =tswapreg (env->macl); + (*regs)[TARGET_REG_PC ] =tswapl (env->pc); + (*regs)[TARGET_REG_PR ] =tswapl (env->pr); + (*regs)[TARGET_REG_SR ] =tswapl (env->sr); + (*regs)[TARGET_REG_GBR ] =tswapl (env->gbr); + (*regs)[TARGET_REG_MACH ] =tswapl (env->mach); + (*regs)[TARGET_REG_MACL ] =tswapl (env->macl); (*regs)[TARGET_REG_SYSCALL ] =0 ;/* FIXME */ }
@@ -730,25 +724,25 @@ typedef target_ulong target_elf_gregset_t[ELF_NREG];static void elf_core_copy_regs (target_elf_gregset_t *regs,const CPUM68KState *env) { - (*regs)[0 ] =tswapreg (env->dregs[1 ]); - (*regs)[1 ] =tswapreg (env->dregs[2 ]); - (*regs)[2 ] =tswapreg (env->dregs[3 ]); - (*regs)[3 ] =tswapreg (env->dregs[4 ]); - (*regs)[4 ] =tswapreg (env->dregs[5 ]); - (*regs)[5 ] =tswapreg (env->dregs[6 ]); - (*regs)[6 ] =tswapreg (env->dregs[7 ]); - (*regs)[7 ] =tswapreg (env->aregs[0 ]); - (*regs)[8 ] =tswapreg (env->aregs[1 ]); - (*regs)[9 ] =tswapreg (env->aregs[2 ]); - (*regs)[10 ] =tswapreg (env->aregs[3 ]); - (*regs)[11 ] =tswapreg (env->aregs[4 ]); - (*regs)[12 ] =tswapreg (env->aregs[5 ]); - (*regs)[13 ] =tswapreg (env->aregs[6 ]); - (*regs)[14 ] =tswapreg (env->dregs[0 ]); - (*regs)[15 ] =tswapreg (env->aregs[7 ]); - (*regs)[16 ] =tswapreg (env->dregs[0 ]);/* FIXME: orig_d0 */ - (*regs)[17 ] =tswapreg (env->sr); - (*regs)[18 ] =tswapreg (env->pc); + (*regs)[0 ] =tswapl (env->dregs[1 ]); + (*regs)[1 ] =tswapl (env->dregs[2 ]); + (*regs)[2 ] =tswapl (env->dregs[3 ]); + (*regs)[3 ] =tswapl (env->dregs[4 ]); + (*regs)[4 ] =tswapl (env->dregs[5 ]); + (*regs)[5 ] =tswapl (env->dregs[6 ]); + (*regs)[6 ] =tswapl (env->dregs[7 ]); + (*regs)[7 ] =tswapl (env->aregs[0 ]); + (*regs)[8 ] =tswapl (env->aregs[1 ]); + (*regs)[9 ] =tswapl (env->aregs[2 ]); + (*regs)[10 ] =tswapl (env->aregs[3 ]); + (*regs)[11 ] =tswapl (env->aregs[4 ]); + (*regs)[12 ] =tswapl (env->aregs[5 ]); + (*regs)[13 ] =tswapl (env->aregs[6 ]); + (*regs)[14 ] =tswapl (env->dregs[0 ]); + (*regs)[15 ] =tswapl (env->aregs[7 ]); + (*regs)[16 ] =tswapl (env->dregs[0 ]);/* FIXME: orig_d0 */ + (*regs)[17 ] =tswapl (env->sr); + (*regs)[18 ] =tswapl (env->pc); (*regs)[19 ] =0 ;/* FIXME: regs->format | regs->vector */ }
@@ -790,10 +784,10 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs,int i;uint32_t *aregs; - (*regs)[TARGET_REG_PSWM ] =tswapreg (env->psw.mask); - (*regs)[TARGET_REG_PSWA ] =tswapreg (env->psw.addr); + (*regs)[TARGET_REG_PSWM ] =tswapl (env->psw.mask); + (*regs)[TARGET_REG_PSWA ] =tswapl (env->psw.addr);for (i =0 ; i <16 ; i++) { - (*regs)[TARGET_REG_GPRS + i] =tswapreg (env->regs[i]); + (*regs)[TARGET_REG_GPRS + i] =tswapl (env->regs[i]); } aregs = (uint32_t *)&((*regs)[TARGET_REG_ARS ]);for (i =0 ; i <16 ; i++) {
@@ -895,18 +889,18 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, {unsigned i; - (*regs)[TARGET_REG_PC ] =tswapreg (env->pc); - (*regs)[TARGET_REG_PS ] =tswapreg (env->sregs[PS ] & ~PS_EXCM ); - (*regs)[TARGET_REG_LBEG ] =tswapreg (env->sregs[LBEG ]); - (*regs)[TARGET_REG_LEND ] =tswapreg (env->sregs[LEND ]); - (*regs)[TARGET_REG_LCOUNT ] =tswapreg (env->sregs[LCOUNT ]); - (*regs)[TARGET_REG_SAR ] =tswapreg (env->sregs[SAR ]); - (*regs)[TARGET_REG_WINDOWSTART ] =tswapreg (env->sregs[WINDOW_START ]); - (*regs)[TARGET_REG_WINDOWBASE ] =tswapreg (env->sregs[WINDOW_BASE ]); - (*regs)[TARGET_REG_THREADPTR ] =tswapreg (env->uregs[THREADPTR ]); + (*regs)[TARGET_REG_PC ] =tswapl (env->pc); + (*regs)[TARGET_REG_PS ] =tswapl (env->sregs[PS ] & ~PS_EXCM ); + (*regs)[TARGET_REG_LBEG ] =tswapl (env->sregs[LBEG ]); + (*regs)[TARGET_REG_LEND ] =tswapl (env->sregs[LEND ]); + (*regs)[TARGET_REG_LCOUNT ] =tswapl (env->sregs[LCOUNT ]); + (*regs)[TARGET_REG_SAR ] =tswapl (env->sregs[SAR ]); + (*regs)[TARGET_REG_WINDOWSTART ] =tswapl (env->sregs[WINDOW_START ]); + (*regs)[TARGET_REG_WINDOWBASE ] =tswapl (env->sregs[WINDOW_BASE ]); + (*regs)[TARGET_REG_THREADPTR ] =tswapl (env->uregs[THREADPTR ]);xtensa_sync_phys_from_window ((CPUXtensaState *)env);for (i =0 ; i < env->config->nareg; ++i) { - (*regs)[TARGET_REG_AR0 + i] =tswapreg (env->phys_regs[i]); + (*regs)[TARGET_REG_AR0 + i] =tswapl (env->phys_regs[i]); } }
Signature · 1 line
2.43.0
PATCH v2 47/95 linux-user: Unify elf_core_copy_regs signatures
In reply to Richard HendersonAll definitions of target_elf_gregset_t are an array of ELF_NREG target_ulong. Unify the signatures of the target-specific elf_core_copy_regs by passing a pointer to target_ulong instead.
Update the data usage within struct target_elf_prstatus.
--- linux-user/elfload.c | 321 +++++++++++++++++++------------------------ 1 file changed, 143 insertions(+), 178 deletions(-)
linux-user/elfload.c +143 -178
@@ -146,7 +146,6 @@ typedef abi_int target_pid_t;#define ELF_ARCH EM_X86_64#define ELF_NREG 27 -typedef target_ulong target_elf_gregset_t [ELF_NREG ];/* * Note that ELF_NREG should be 29 as there should be place for
@@ -155,35 +154,35 @@ typedef target_ulong target_elf_gregset_t[ELF_NREG];* * See linux kernel: arch/x86/include/asm/elf.h */ -static void elf_core_copy_regs (target_elf_gregset_t *regs,const CPUX86State *env) +static void elf_core_copy_regs (target_ulong *regs,const CPUX86State *env) { - (*regs)[0 ] =tswapl (env->regs[15 ]); - (*regs)[1 ] =tswapl (env->regs[14 ]); - (*regs)[2 ] =tswapl (env->regs[13 ]); - (*regs)[3 ] =tswapl (env->regs[12 ]); - (*regs)[4 ] =tswapl (env->regs[R_EBP ]); - (*regs)[5 ] =tswapl (env->regs[R_EBX ]); - (*regs)[6 ] =tswapl (env->regs[11 ]); - (*regs)[7 ] =tswapl (env->regs[10 ]); - (*regs)[8 ] =tswapl (env->regs[9 ]); - (*regs)[9 ] =tswapl (env->regs[8 ]); - (*regs)[10 ] =tswapl (env->regs[R_EAX ]); - (*regs)[11 ] =tswapl (env->regs[R_ECX ]); - (*regs)[12 ] =tswapl (env->regs[R_EDX ]); - (*regs)[13 ] =tswapl (env->regs[R_ESI ]); - (*regs)[14 ] =tswapl (env->regs[R_EDI ]); - (*regs)[15 ] =tswapl (get_task_state (env_cpu_const (env))->orig_ax); - (*regs)[16 ] =tswapl (env->eip); - (*regs)[17 ] =tswapl (env->segs[R_CS ].selector &0xffff ); - (*regs)[18 ] =tswapl (env->eflags); - (*regs)[19 ] =tswapl (env->regs[R_ESP ]); - (*regs)[20 ] =tswapl (env->segs[R_SS ].selector &0xffff ); - (*regs)[21 ] =tswapl (env->segs[R_FS ].selector &0xffff ); - (*regs)[22 ] =tswapl (env->segs[R_GS ].selector &0xffff ); - (*regs)[23 ] =tswapl (env->segs[R_DS ].selector &0xffff ); - (*regs)[24 ] =tswapl (env->segs[R_ES ].selector &0xffff ); - (*regs)[25 ] =tswapl (env->segs[R_FS ].selector &0xffff ); - (*regs)[26 ] =tswapl (env->segs[R_GS ].selector &0xffff ); + regs[0 ] =tswapl (env->regs[15 ]); + regs[1 ] =tswapl (env->regs[14 ]); + regs[2 ] =tswapl (env->regs[13 ]); + regs[3 ] =tswapl (env->regs[12 ]); + regs[4 ] =tswapl (env->regs[R_EBP ]); + regs[5 ] =tswapl (env->regs[R_EBX ]); + regs[6 ] =tswapl (env->regs[11 ]); + regs[7 ] =tswapl (env->regs[10 ]); + regs[8 ] =tswapl (env->regs[9 ]); + regs[9 ] =tswapl (env->regs[8 ]); + regs[10 ] =tswapl (env->regs[R_EAX ]); + regs[11 ] =tswapl (env->regs[R_ECX ]); + regs[12 ] =tswapl (env->regs[R_EDX ]); + regs[13 ] =tswapl (env->regs[R_ESI ]); + regs[14 ] =tswapl (env->regs[R_EDI ]); + regs[15 ] =tswapl (get_task_state (env_cpu_const (env))->orig_ax); + regs[16 ] =tswapl (env->eip); + regs[17 ] =tswapl (env->segs[R_CS ].selector &0xffff ); + regs[18 ] =tswapl (env->eflags); + regs[19 ] =tswapl (env->regs[R_ESP ]); + regs[20 ] =tswapl (env->segs[R_SS ].selector &0xffff ); + regs[21 ] =tswapl (env->segs[R_FS ].selector &0xffff ); + regs[22 ] =tswapl (env->segs[R_GS ].selector &0xffff ); + regs[23 ] =tswapl (env->segs[R_DS ].selector &0xffff ); + regs[24 ] =tswapl (env->segs[R_ES ].selector &0xffff ); + regs[25 ] =tswapl (env->segs[R_FS ].selector &0xffff ); + regs[26 ] =tswapl (env->segs[R_GS ].selector &0xffff ); }#if ULONG_MAX >UINT32_MAX
@@ -223,7 +222,6 @@ static bool init_guest_commpage(void)#define EXSTACK_DEFAULT true#define ELF_NREG 17 -typedef target_ulong target_elf_gregset_t [ELF_NREG ];/* * Note that ELF_NREG should be 19 as there should be place for
@@ -232,25 +230,25 @@ typedef target_ulong target_elf_gregset_t[ELF_NREG];* * See linux kernel: arch/x86/include/asm/elf.h */ -static void elf_core_copy_regs (target_elf_gregset_t *regs,const CPUX86State *env) +static void elf_core_copy_regs (target_ulong *regs,const CPUX86State *env) { - (*regs)[0 ] =tswapl (env->regs[R_EBX ]); - (*regs)[1 ] =tswapl (env->regs[R_ECX ]); - (*regs)[2 ] =tswapl (env->regs[R_EDX ]); - (*regs)[3 ] =tswapl (env->regs[R_ESI ]); - (*regs)[4 ] =tswapl (env->regs[R_EDI ]); - (*regs)[5 ] =tswapl (env->regs[R_EBP ]); - (*regs)[6 ] =tswapl (env->regs[R_EAX ]); - (*regs)[7 ] =tswapl (env->segs[R_DS ].selector &0xffff ); - (*regs)[8 ] =tswapl (env->segs[R_ES ].selector &0xffff ); - (*regs)[9 ] =tswapl (env->segs[R_FS ].selector &0xffff ); - (*regs)[10 ] =tswapl (env->segs[R_GS ].selector &0xffff ); - (*regs)[11 ] =tswapl (get_task_state (env_cpu_const (env))->orig_ax); - (*regs)[12 ] =tswapl (env->eip); - (*regs)[13 ] =tswapl (env->segs[R_CS ].selector &0xffff ); - (*regs)[14 ] =tswapl (env->eflags); - (*regs)[15 ] =tswapl (env->regs[R_ESP ]); - (*regs)[16 ] =tswapl (env->segs[R_SS ].selector &0xffff ); + regs[0 ] =tswapl (env->regs[R_EBX ]); + regs[1 ] =tswapl (env->regs[R_ECX ]); + regs[2 ] =tswapl (env->regs[R_EDX ]); + regs[3 ] =tswapl (env->regs[R_ESI ]); + regs[4 ] =tswapl (env->regs[R_EDI ]); + regs[5 ] =tswapl (env->regs[R_EBP ]); + regs[6 ] =tswapl (env->regs[R_EAX ]); + regs[7 ] =tswapl (env->segs[R_DS ].selector &0xffff ); + regs[8 ] =tswapl (env->segs[R_ES ].selector &0xffff ); + regs[9 ] =tswapl (env->segs[R_FS ].selector &0xffff ); + regs[10 ] =tswapl (env->segs[R_GS ].selector &0xffff ); + regs[11 ] =tswapl (get_task_state (env_cpu_const (env))->orig_ax); + regs[12 ] =tswapl (env->eip); + regs[13 ] =tswapl (env->segs[R_CS ].selector &0xffff ); + regs[14 ] =tswapl (env->eflags); + regs[15 ] =tswapl (env->regs[R_ESP ]); + regs[16 ] =tswapl (env->segs[R_SS ].selector &0xffff ); }/*
@@ -284,29 +282,14 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUX86State *en#define EXSTACK_DEFAULT true#define ELF_NREG 18 -typedef target_ulong target_elf_gregset_t [ELF_NREG ]; -static void elf_core_copy_regs (target_elf_gregset_t *regs,const CPUARMState *env) +static void elf_core_copy_regs (target_ulong *regs,const CPUARMState *env) { - (*regs)[0 ] =tswapl (env->regs[0 ]); - (*regs)[1 ] =tswapl (env->regs[1 ]); - (*regs)[2 ] =tswapl (env->regs[2 ]); - (*regs)[3 ] =tswapl (env->regs[3 ]); - (*regs)[4 ] =tswapl (env->regs[4 ]); - (*regs)[5 ] =tswapl (env->regs[5 ]); - (*regs)[6 ] =tswapl (env->regs[6 ]); - (*regs)[7 ] =tswapl (env->regs[7 ]); - (*regs)[8 ] =tswapl (env->regs[8 ]); - (*regs)[9 ] =tswapl (env->regs[9 ]); - (*regs)[10 ] =tswapl (env->regs[10 ]); - (*regs)[11 ] =tswapl (env->regs[11 ]); - (*regs)[12 ] =tswapl (env->regs[12 ]); - (*regs)[13 ] =tswapl (env->regs[13 ]); - (*regs)[14 ] =tswapl (env->regs[14 ]); - (*regs)[15 ] =tswapl (env->regs[15 ]); - - (*regs)[16 ] =tswapl (cpsr_read ((CPUARMState *)env)); - (*regs)[17 ] =tswapl (env->regs[0 ]);/* XXX */ +for (int i =0 ; i <16 ; i++) { + regs[i] =tswapl (env->regs[i]); + } + regs[16 ] =tswapl (cpsr_read ((CPUARMState *)env)); + regs[17 ] =tswapl (env->regs[0 ]);/* XXX */ }#define USE_ELF_CORE_DUMP
@@ -384,18 +367,16 @@ static const VdsoImageInfo *vdso_image_info(uint32_t elf_flags)#define ELF_CLASS ELFCLASS64#define ELF_NREG 34 -typedef target_ulong target_elf_gregset_t [ELF_NREG ]; -static void elf_core_copy_regs (target_elf_gregset_t *regs, -const CPUARMState *env) +static void elf_core_copy_regs (target_ulong *regs,const CPUARMState *env) {int i;for (i =0 ; i <32 ; i++) { - (*regs)[i] =tswapl (env->xregs[i]); + regs[i] =tswapl (env->xregs[i]); } - (*regs)[32 ] =tswapl (env->pc); - (*regs)[33 ] =tswapl (pstate_read ((CPUARMState *)env)); + regs[32 ] =tswapl (env->pc); + regs[33 ] =tswapl (pstate_read ((CPUARMState *)env)); }#define USE_ELF_CORE_DUMP
@@ -471,25 +452,24 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs,/* See linux kernel: arch/powerpc/include/asm/elf.h. */ #define ELF_NREG 48 -typedef target_ulong target_elf_gregset_t [ELF_NREG ]; -static void elf_core_copy_regs (target_elf_gregset_t *regs,const CPUPPCState *env) +static void elf_core_copy_regs (target_ulong *regs,const CPUPPCState *env) {int i;target_ulong ccr =0 ;for (i =0 ; i <ARRAY_SIZE (env->gpr); i++) { - (*regs)[i] =tswapl (env->gpr[i]); + regs[i] =tswapl (env->gpr[i]); } - (*regs)[32 ] =tswapl (env->nip); - (*regs)[33 ] =tswapl (env->msr); - (*regs)[35 ] =tswapl (env->ctr); - (*regs)[36 ] =tswapl (env->lr); - (*regs)[37 ] =tswapl (cpu_read_xer (env)); + regs[32 ] =tswapl (env->nip); + regs[33 ] =tswapl (env->msr); + regs[35 ] =tswapl (env->ctr); + regs[36 ] =tswapl (env->lr); + regs[37 ] =tswapl (cpu_read_xer (env)); ccr =ppc_get_cr (env); - (*regs)[38 ] =tswapl (ccr); + regs[38 ] =tswapl (ccr); }#define USE_ELF_CORE_DUMP
@@ -517,7 +497,6 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUPPCState *en/* See linux kernel: arch/loongarch/include/asm/elf.h */ #define ELF_NREG 45 -typedef target_ulong target_elf_gregset_t [ELF_NREG ];enum {TARGET_EF_R0 =0 ,
@@ -525,19 +504,18 @@ enum { TARGET_EF_CSR_BADV = TARGET_EF_R0 + 34, }; -static void elf_core_copy_regs (target_elf_gregset_t *regs, -const CPULoongArchState *env) +static void elf_core_copy_regs (target_ulong *regs,const CPULoongArchState *env) {int i; - (*regs)[TARGET_EF_R0 ] =0 ; + regs[TARGET_EF_R0 ] =0 ;for (i =1 ; i <ARRAY_SIZE (env->gpr); i++) { - (*regs)[TARGET_EF_R0 + i] =tswapl (env->gpr[i]); + regs[TARGET_EF_R0 + i] =tswapl (env->gpr[i]); } - (*regs)[TARGET_EF_CSR_ERA ] =tswapl (env->pc); - (*regs)[TARGET_EF_CSR_BADV ] =tswapl (env->CSR_BADV); + regs[TARGET_EF_CSR_ERA ] =tswapl (env->pc); + regs[TARGET_EF_CSR_BADV ] =tswapl (env->CSR_BADV); }#define USE_ELF_CORE_DUMP
@@ -563,7 +541,6 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs,/* See linux kernel: arch/mips/include/asm/elf.h. */ #define ELF_NREG 45 -typedef target_ulong target_elf_gregset_t [ELF_NREG ];/* See linux kernel: arch/mips/include/asm/reg.h. */ enum {
@@ -583,27 +560,27 @@ enum { };/* See linux kernel: arch/mips/kernel/process.c:elf_dump_regs. */ -static void elf_core_copy_regs (target_elf_gregset_t *regs,const CPUMIPSState *env) +static void elf_core_copy_regs (target_ulong *regs,const CPUMIPSState *env) {int i;for (i =0 ; i <TARGET_EF_R0 ; i++) { - (*regs)[i] =0 ; + regs[i] =0 ; } - (*regs)[TARGET_EF_R0 ] =0 ; + regs[TARGET_EF_R0 ] =0 ;for (i =1 ; i <ARRAY_SIZE (env->active_tc.gpr); i++) { - (*regs)[TARGET_EF_R0 + i] =tswapl (env->active_tc.gpr[i]); + regs[TARGET_EF_R0 + i] =tswapl (env->active_tc.gpr[i]); } - (*regs)[TARGET_EF_R26 ] =0 ; - (*regs)[TARGET_EF_R27 ] =0 ; - (*regs)[TARGET_EF_LO ] =tswapl (env->active_tc.LO[0 ]); - (*regs)[TARGET_EF_HI ] =tswapl (env->active_tc.HI[0 ]); - (*regs)[TARGET_EF_CP0_EPC ] =tswapl (env->active_tc.PC); - (*regs)[TARGET_EF_CP0_BADVADDR ] =tswapl (env->CP0_BadVAddr); - (*regs)[TARGET_EF_CP0_STATUS ] =tswapl (env->CP0_Status); - (*regs)[TARGET_EF_CP0_CAUSE ] =tswapl (env->CP0_Cause); + regs[TARGET_EF_R26 ] =0 ; + regs[TARGET_EF_R27 ] =0 ; + regs[TARGET_EF_LO ] =tswapl (env->active_tc.LO[0 ]); + regs[TARGET_EF_HI ] =tswapl (env->active_tc.HI[0 ]); + regs[TARGET_EF_CP0_EPC ] =tswapl (env->active_tc.PC); + regs[TARGET_EF_CP0_BADVADDR ] =tswapl (env->CP0_BadVAddr); + regs[TARGET_EF_CP0_STATUS ] =tswapl (env->CP0_Status); + regs[TARGET_EF_CP0_CAUSE ] =tswapl (env->CP0_Cause); }#define USE_ELF_CORE_DUMP
@@ -622,23 +599,22 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUMIPSState *e#define USE_ELF_CORE_DUMP #define ELF_NREG 38 -typedef target_ulong target_elf_gregset_t [ELF_NREG ];/* See linux kernel: arch/mips/kernel/process.c:elf_dump_regs. */ -static void elf_core_copy_regs (target_elf_gregset_t *regs,const CPUMBState *env) +static void elf_core_copy_regs (target_ulong *regs,const CPUMBState *env) {int i, pos =0 ;for (i =0 ; i <32 ; i++) { - (*regs)[pos++] =tswapl (env->regs[i]); + regs[pos++] =tswapl (env->regs[i]); } - (*regs)[pos++] =tswapl (env->pc); - (*regs)[pos++] =tswapl (mb_cpu_read_msr (env)); - (*regs)[pos++] =0 ; - (*regs)[pos++] =tswapl (env->ear); - (*regs)[pos++] =0 ; - (*regs)[pos++] =tswapl (env->esr); + regs[pos++] =tswapl (env->pc); + regs[pos++] =tswapl (mb_cpu_read_msr (env)); + regs[pos++] =0 ; + regs[pos++] =tswapl (env->ear); + regs[pos++] =0 ; + regs[pos++] =tswapl (env->esr); }#endif /* TARGET_MICROBLAZE */
@@ -654,18 +630,16 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUMBState *env/* See linux kernel arch/openrisc/include/asm/elf.h. */ #define ELF_NREG 34/* gprs and pc, sr */ -typedef target_ulong target_elf_gregset_t [ELF_NREG ]; -static void elf_core_copy_regs (target_elf_gregset_t *regs, -const CPUOpenRISCState *env) +static void elf_core_copy_regs (target_ulong *regs,const CPUOpenRISCState *env) {int i;for (i =0 ; i <32 ; i++) { - (*regs)[i] =tswapl (cpu_get_gpr (env, i)); + regs[i] =tswapl (cpu_get_gpr (env, i)); } - (*regs)[32 ] =tswapl (env->pc); - (*regs)[33 ] =tswapl (cpu_get_sr (env)); + regs[32 ] =tswapl (env->pc); + regs[33 ] =tswapl (cpu_get_sr (env)); }#endif /* TARGET_OPENRISC */
@@ -677,7 +651,6 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs,/* See linux kernel: arch/sh/include/asm/elf.h. */ #define ELF_NREG 23 -typedef target_ulong target_elf_gregset_t [ELF_NREG ];/* See linux kernel: arch/sh/include/asm/ptrace.h. */ enum {
@@ -690,22 +663,21 @@ enum {TARGET_REG_SYSCALL =22 }; -static inline void elf_core_copy_regs (target_elf_gregset_t *regs, -const CPUSH4State *env) +static void elf_core_copy_regs (target_ulong *regs,const CPUSH4State *env) {int i;for (i =0 ; i <16 ; i++) { - (*regs)[i] =tswapl (env->gregs[i]); + regs[i] =tswapl (env->gregs[i]); } - (*regs)[TARGET_REG_PC ] =tswapl (env->pc); - (*regs)[TARGET_REG_PR ] =tswapl (env->pr); - (*regs)[TARGET_REG_SR ] =tswapl (env->sr); - (*regs)[TARGET_REG_GBR ] =tswapl (env->gbr); - (*regs)[TARGET_REG_MACH ] =tswapl (env->mach); - (*regs)[TARGET_REG_MACL ] =tswapl (env->macl); - (*regs)[TARGET_REG_SYSCALL ] =0 ;/* FIXME */ + regs[TARGET_REG_PC ] =tswapl (env->pc); + regs[TARGET_REG_PR ] =tswapl (env->pr); + regs[TARGET_REG_SR ] =tswapl (env->sr); + regs[TARGET_REG_GBR ] =tswapl (env->gbr); + regs[TARGET_REG_MACH ] =tswapl (env->mach); + regs[TARGET_REG_MACL ] =tswapl (env->macl); + regs[TARGET_REG_SYSCALL ] =0 ;/* FIXME */ }#define USE_ELF_CORE_DUMP
@@ -720,30 +692,29 @@ static inline void elf_core_copy_regs(target_elf_gregset_t *regs,/* See linux kernel: arch/m68k/include/asm/elf.h. */ #define ELF_NREG 20 -typedef target_ulong target_elf_gregset_t [ELF_NREG ]; -static void elf_core_copy_regs (target_elf_gregset_t *regs,const CPUM68KState *env) +static void elf_core_copy_regs (target_ulong *regs,const CPUM68KState *env) { - (*regs)[0 ] =tswapl (env->dregs[1 ]); - (*regs)[1 ] =tswapl (env->dregs[2 ]); - (*regs)[2 ] =tswapl (env->dregs[3 ]); - (*regs)[3 ] =tswapl (env->dregs[4 ]); - (*regs)[4 ] =tswapl (env->dregs[5 ]); - (*regs)[5 ] =tswapl (env->dregs[6 ]); - (*regs)[6 ] =tswapl (env->dregs[7 ]); - (*regs)[7 ] =tswapl (env->aregs[0 ]); - (*regs)[8 ] =tswapl (env->aregs[1 ]); - (*regs)[9 ] =tswapl (env->aregs[2 ]); - (*regs)[10 ] =tswapl (env->aregs[3 ]); - (*regs)[11 ] =tswapl (env->aregs[4 ]); - (*regs)[12 ] =tswapl (env->aregs[5 ]); - (*regs)[13 ] =tswapl (env->aregs[6 ]); - (*regs)[14 ] =tswapl (env->dregs[0 ]); - (*regs)[15 ] =tswapl (env->aregs[7 ]); - (*regs)[16 ] =tswapl (env->dregs[0 ]);/* FIXME: orig_d0 */ - (*regs)[17 ] =tswapl (env->sr); - (*regs)[18 ] =tswapl (env->pc); - (*regs)[19 ] =0 ;/* FIXME: regs->format | regs->vector */ + regs[0 ] =tswapl (env->dregs[1 ]); + regs[1 ] =tswapl (env->dregs[2 ]); + regs[2 ] =tswapl (env->dregs[3 ]); + regs[3 ] =tswapl (env->dregs[4 ]); + regs[4 ] =tswapl (env->dregs[5 ]); + regs[5 ] =tswapl (env->dregs[6 ]); + regs[6 ] =tswapl (env->dregs[7 ]); + regs[7 ] =tswapl (env->aregs[0 ]); + regs[8 ] =tswapl (env->aregs[1 ]); + regs[9 ] =tswapl (env->aregs[2 ]); + regs[10 ] =tswapl (env->aregs[3 ]); + regs[11 ] =tswapl (env->aregs[4 ]); + regs[12 ] =tswapl (env->aregs[5 ]); + regs[13 ] =tswapl (env->aregs[6 ]); + regs[14 ] =tswapl (env->dregs[0 ]); + regs[15 ] =tswapl (env->aregs[7 ]); + regs[16 ] =tswapl (env->dregs[0 ]);/* FIXME: orig_d0 */ + regs[17 ] =tswapl (env->sr); + regs[18 ] =tswapl (env->pc); + regs[19 ] =0 ;/* FIXME: regs->format | regs->vector */ }#define USE_ELF_CORE_DUMP
@@ -768,7 +739,6 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUM68KState *e/* See linux kernel: arch/s390/include/uapi/asm/ptrace.h (s390_regs). */ #define ELF_NREG 27 -typedef target_ulong target_elf_gregset_t [ELF_NREG ];enum {TARGET_REG_PSWM =0 ,
@@ -778,22 +748,21 @@ enum { TARGET_REG_ORIG_R2 = 26, }; -static void elf_core_copy_regs (target_elf_gregset_t *regs, -const CPUS390XState *env) +static void elf_core_copy_regs (target_ulong *regs,const CPUS390XState *env) {int i;uint32_t *aregs; - (*regs)[TARGET_REG_PSWM ] =tswapl (env->psw.mask); - (*regs)[TARGET_REG_PSWA ] =tswapl (env->psw.addr); + regs[TARGET_REG_PSWM ] =tswapl (env->psw.mask); + regs[TARGET_REG_PSWA ] =tswapl (env->psw.addr);for (i =0 ; i <16 ; i++) { - (*regs)[TARGET_REG_GPRS + i] =tswapl (env->regs[i]); + regs[TARGET_REG_GPRS + i] =tswapl (env->regs[i]); } - aregs = (uint32_t *)&((*regs)[TARGET_REG_ARS ]); + aregs = (uint32_t *)®s[TARGET_REG_ARS ];for (i =0 ; i <16 ; i++) { aregs[i] =tswap32 (env->aregs[i]); } - (*regs)[TARGET_REG_ORIG_R2 ] =0 ; + regs[TARGET_REG_ORIG_R2 ] =0 ; }#define USE_ELF_CORE_DUMP
@@ -869,7 +838,6 @@ static bool init_guest_commpage(void)/* See linux kernel: arch/xtensa/include/asm/elf.h. */ #define ELF_NREG 128 -typedef target_ulong target_elf_gregset_t [ELF_NREG ];enum {TARGET_REG_PC ,
@@ -884,23 +852,22 @@ enum { TARGET_REG_AR0 = 64, }; -static void elf_core_copy_regs (target_elf_gregset_t *regs, -const CPUXtensaState *env) +static void elf_core_copy_regs (target_ulong *regs,const CPUXtensaState *env) {unsigned i; - (*regs)[TARGET_REG_PC ] =tswapl (env->pc); - (*regs)[TARGET_REG_PS ] =tswapl (env->sregs[PS ] & ~PS_EXCM ); - (*regs)[TARGET_REG_LBEG ] =tswapl (env->sregs[LBEG ]); - (*regs)[TARGET_REG_LEND ] =tswapl (env->sregs[LEND ]); - (*regs)[TARGET_REG_LCOUNT ] =tswapl (env->sregs[LCOUNT ]); - (*regs)[TARGET_REG_SAR ] =tswapl (env->sregs[SAR ]); - (*regs)[TARGET_REG_WINDOWSTART ] =tswapl (env->sregs[WINDOW_START ]); - (*regs)[TARGET_REG_WINDOWBASE ] =tswapl (env->sregs[WINDOW_BASE ]); - (*regs)[TARGET_REG_THREADPTR ] =tswapl (env->uregs[THREADPTR ]); + regs[TARGET_REG_PC ] =tswapl (env->pc); + regs[TARGET_REG_PS ] =tswapl (env->sregs[PS ] & ~PS_EXCM ); + regs[TARGET_REG_LBEG ] =tswapl (env->sregs[LBEG ]); + regs[TARGET_REG_LEND ] =tswapl (env->sregs[LEND ]); + regs[TARGET_REG_LCOUNT ] =tswapl (env->sregs[LCOUNT ]); + regs[TARGET_REG_SAR ] =tswapl (env->sregs[SAR ]); + regs[TARGET_REG_WINDOWSTART ] =tswapl (env->sregs[WINDOW_START ]); + regs[TARGET_REG_WINDOWBASE ] =tswapl (env->sregs[WINDOW_BASE ]); + regs[TARGET_REG_THREADPTR ] =tswapl (env->uregs[THREADPTR ]);xtensa_sync_phys_from_window ((CPUXtensaState *)env);for (i =0 ; i < env->config->nareg; ++i) { - (*regs)[TARGET_REG_AR0 + i] =tswapl (env->phys_regs[i]); + regs[TARGET_REG_AR0 + i] =tswapl (env->phys_regs[i]); } }
@@ -2857,13 +2824,11 @@ int load_elf_binary(struct linux_binprm *bprm, struct image_info *info)* says that it needs to be array of elf_greg_t that has size of ELF_NREG. * * #define ELF_NREG <number of registers> -* typedef taret_elf_greg_t target_elf_gregset_t[ELF_NREG]; * * Last step is to implement target specific function that copies registers * from given cpu into just specified register set. Prototype is: * -* static void elf_core_copy_regs(taret_elf_gregset_t *regs, -* const CPUArchState *env); +* static void elf_core_copy_regs(target_ulong *regs, const CPUArchState *env); * * Parameters: * regs - copy register values into here (allocated and zeroed by caller)
@@ -2891,7 +2856,7 @@ struct target_elf_prstatus {struct target_timeval pr_stime;/* XXX System time */ struct target_timeval pr_cutime;/* XXX Cumulative user time */ struct target_timeval pr_cstime;/* XXX Cumulative system time */ -target_elf_gregset_t pr_reg;/* GP registers */ +target_ulong pr_reg[ELF_NREG ];/* GP registers */ abi_int pr_fpvalid;/* XXX */ };
@@ -3060,7 +3025,7 @@ static void fill_prstatus_note(void *data, CPUState *cpu, int signr) .pr_sid = getsid(0), }; -elf_core_copy_regs (&prstatus.pr_reg,cpu_env (cpu)); +elf_core_copy_regs (prstatus.pr_reg,cpu_env (cpu));bswap_prstatus (&prstatus);memcpy (data, &prstatus,sizeof (prstatus)); }
Signature · 1 line
2.43.0
PATCH v2 48/95 linux-user: Declare elf_core_copy_regs in loader.h
In reply to Richard HendersonDrop the static from all implementations.
--- linux-user/loader.h | 1 + linux-user/elfload.c | 28 ++++++++++++++-------------- 2 files changed, 15 insertions(+), 14 deletions(-)
linux-user/loader.h +1 -0
@@ -105,5 +105,6 @@ const char *elf_hwcap_str(uint32_t bit);const char *elf_hwcap2_str (uint32_t bit);const char *get_elf_platform (CPUState *cs);const char *get_elf_base_platform (CPUState *cs); +void elf_core_copy_regs (target_ulong *regs,const CPUArchState *env);#endif /* LINUX_USER_LOADER_H */
linux-user/elfload.c +14 -14
@@ -154,7 +154,7 @@ typedef abi_int target_pid_t;* * See linux kernel: arch/x86/include/asm/elf.h */ -static void elf_core_copy_regs (target_ulong *regs,const CPUX86State *env) +void elf_core_copy_regs (target_ulong *regs,const CPUX86State *env) { regs[0 ] =tswapl (env->regs[15 ]); regs[1 ] =tswapl (env->regs[14 ]);
@@ -230,7 +230,7 @@ static bool init_guest_commpage(void)* * See linux kernel: arch/x86/include/asm/elf.h */ -static void elf_core_copy_regs (target_ulong *regs,const CPUX86State *env) +void elf_core_copy_regs (target_ulong *regs,const CPUX86State *env) { regs[0 ] =tswapl (env->regs[R_EBX ]); regs[1 ] =tswapl (env->regs[R_ECX ]);
@@ -283,7 +283,7 @@ static void elf_core_copy_regs(target_ulong *regs, const CPUX86State *env)#define ELF_NREG 18 -static void elf_core_copy_regs (target_ulong *regs,const CPUARMState *env) +void elf_core_copy_regs (target_ulong *regs,const CPUARMState *env) {for (int i =0 ; i <16 ; i++) { regs[i] =tswapl (env->regs[i]);
@@ -368,7 +368,7 @@ static const VdsoImageInfo *vdso_image_info(uint32_t elf_flags)#define ELF_NREG 34 -static void elf_core_copy_regs (target_ulong *regs,const CPUARMState *env) +void elf_core_copy_regs (target_ulong *regs,const CPUARMState *env) {int i;
@@ -453,7 +453,7 @@ static void elf_core_copy_regs(target_ulong *regs, const CPUARMState *env)/* See linux kernel: arch/powerpc/include/asm/elf.h. */ #define ELF_NREG 48 -static void elf_core_copy_regs (target_ulong *regs,const CPUPPCState *env) +void elf_core_copy_regs (target_ulong *regs,const CPUPPCState *env) {int i;target_ulong ccr =0 ;
@@ -504,7 +504,7 @@ enum { TARGET_EF_CSR_BADV = TARGET_EF_R0 + 34, }; -static void elf_core_copy_regs (target_ulong *regs,const CPULoongArchState *env) +void elf_core_copy_regs (target_ulong *regs,const CPULoongArchState *env) {int i;
@@ -560,7 +560,7 @@ enum { };/* See linux kernel: arch/mips/kernel/process.c:elf_dump_regs. */ -static void elf_core_copy_regs (target_ulong *regs,const CPUMIPSState *env) +void elf_core_copy_regs (target_ulong *regs,const CPUMIPSState *env) {int i;
@@ -601,7 +601,7 @@ static void elf_core_copy_regs(target_ulong *regs, const CPUMIPSState *env)#define ELF_NREG 38/* See linux kernel: arch/mips/kernel/process.c:elf_dump_regs. */ -static void elf_core_copy_regs (target_ulong *regs,const CPUMBState *env) +void elf_core_copy_regs (target_ulong *regs,const CPUMBState *env) {int i, pos =0 ;
@@ -631,7 +631,7 @@ static void elf_core_copy_regs(target_ulong *regs, const CPUMBState *env)/* See linux kernel arch/openrisc/include/asm/elf.h. */ #define ELF_NREG 34/* gprs and pc, sr */ -static void elf_core_copy_regs (target_ulong *regs,const CPUOpenRISCState *env) +void elf_core_copy_regs (target_ulong *regs,const CPUOpenRISCState *env) {int i;
@@ -663,7 +663,7 @@ enum { TARGET_REG_SYSCALL = 22 }; -static void elf_core_copy_regs (target_ulong *regs,const CPUSH4State *env) +void elf_core_copy_regs (target_ulong *regs,const CPUSH4State *env) {int i;
@@ -693,7 +693,7 @@ static void elf_core_copy_regs(target_ulong *regs, const CPUSH4State *env)/* See linux kernel: arch/m68k/include/asm/elf.h. */ #define ELF_NREG 20 -static void elf_core_copy_regs (target_ulong *regs,const CPUM68KState *env) +void elf_core_copy_regs (target_ulong *regs,const CPUM68KState *env) { regs[0 ] =tswapl (env->dregs[1 ]); regs[1 ] =tswapl (env->dregs[2 ]);
@@ -748,7 +748,7 @@ enum { TARGET_REG_ORIG_R2 = 26, }; -static void elf_core_copy_regs (target_ulong *regs,const CPUS390XState *env) +void elf_core_copy_regs (target_ulong *regs,const CPUS390XState *env) {int i;uint32_t *aregs;
@@ -852,7 +852,7 @@ enum { TARGET_REG_AR0 = 64, }; -static void elf_core_copy_regs (target_ulong *regs,const CPUXtensaState *env) +void elf_core_copy_regs (target_ulong *regs,const CPUXtensaState *env) {unsigned i;
@@ -2828,7 +2828,7 @@ int load_elf_binary(struct linux_binprm *bprm, struct image_info *info)* Last step is to implement target specific function that copies registers * from given cpu into just specified register set. Prototype is: * -* static void elf_core_copy_regs(target_ulong *regs, const CPUArchState *env); +* void elf_core_copy_regs(target_ulong *regs, const CPUArchState *env); * * Parameters: * regs - copy register values into here (allocated and zeroed by caller)
Signature · 1 line
2.43.0
PATCH v2 49/95 linux-user: Remove USE_ELF_CORE_DUMP
In reply to Richard HendersonSince ELF_NREG is defined if and only if USE_ELF_CORE_DUMP is also defined, and since ELF_NREG carries useful information, remove USE_ELF_CORE_DUMP and instead use ELF_NREG as a signal that core dumps are supported.
--- linux-user/elfload.c | 44 +++++--------------------------------------- 1 file changed, 5 insertions(+), 39 deletions(-)
linux-user/elfload.c +5 -39
@@ -267,7 +267,6 @@ void elf_core_copy_regs(target_ulong *regs, const CPUX86State *env)#define VDSO_HEADER "vdso.c.inc" -#define USE_ELF_CORE_DUMP #define ELF_EXEC_PAGESIZE 4096#endif /* TARGET_I386 */
@@ -292,7 +291,6 @@ void elf_core_copy_regs(target_ulong *regs, const CPUARMState *env) regs[17 ] =tswapl (env->regs[0 ]);/* XXX */ } -#define USE_ELF_CORE_DUMP #define ELF_EXEC_PAGESIZE 4096/* The commpage only exists for 32 bit kernels */
@@ -379,7 +377,6 @@ void elf_core_copy_regs(target_ulong *regs, const CPUARMState *env) regs[33 ] =tswapl (pstate_read ((CPUARMState *)env)); } -#define USE_ELF_CORE_DUMP #define ELF_EXEC_PAGESIZE 4096#if TARGET_BIG_ENDIAN
@@ -472,7 +469,6 @@ void elf_core_copy_regs(target_ulong *regs, const CPUPPCState *env) regs[38 ] =tswapl (ccr); } -#define USE_ELF_CORE_DUMP #define ELF_EXEC_PAGESIZE 4096#ifndef TARGET_PPC64
@@ -518,7 +514,6 @@ void elf_core_copy_regs(target_ulong *regs, const CPULoongArchState *env) regs[TARGET_EF_CSR_BADV] = tswapl(env->CSR_BADV); } -#define USE_ELF_CORE_DUMP #define ELF_EXEC_PAGESIZE 4096#endif /* TARGET_LOONGARCH64 */
@@ -583,7 +578,6 @@ void elf_core_copy_regs(target_ulong *regs, const CPUMIPSState *env) regs[TARGET_EF_CP0_CAUSE] = tswapl(env->CP0_Cause); } -#define USE_ELF_CORE_DUMP #define ELF_EXEC_PAGESIZE 4096#endif /* TARGET_MIPS */
@@ -597,7 +591,6 @@ void elf_core_copy_regs(target_ulong *regs, const CPUMIPSState *env)#define ELF_EXEC_PAGESIZE 4096 -#define USE_ELF_CORE_DUMP #define ELF_NREG 38/* See linux kernel: arch/mips/kernel/process.c:elf_dump_regs. */
@@ -625,7 +618,6 @@ void elf_core_copy_regs(target_ulong *regs, const CPUMBState *env)#define ELF_CLASS ELFCLASS32#define ELF_DATA ELFDATA2MSB -#define USE_ELF_CORE_DUMP #define ELF_EXEC_PAGESIZE 8192/* See linux kernel arch/openrisc/include/asm/elf.h. */
@@ -680,7 +672,6 @@ void elf_core_copy_regs(target_ulong *regs, const CPUSH4State *env) regs[TARGET_REG_SYSCALL] = 0; /* FIXME */ } -#define USE_ELF_CORE_DUMP #define ELF_EXEC_PAGESIZE 4096#endif
@@ -717,7 +708,6 @@ void elf_core_copy_regs(target_ulong *regs, const CPUM68KState *env) regs[19] = 0; /* FIXME: regs->format | regs->vector */ } -#define USE_ELF_CORE_DUMP #define ELF_EXEC_PAGESIZE 8192#endif
@@ -765,7 +755,6 @@ void elf_core_copy_regs(target_ulong *regs, const CPUS390XState *env) regs[TARGET_REG_ORIG_R2 ] =0 ; } -#define USE_ELF_CORE_DUMP #define ELF_EXEC_PAGESIZE 4096#define VDSO_HEADER "vdso.c.inc"
@@ -871,7 +860,6 @@ void elf_core_copy_regs(target_ulong *regs, const CPUXtensaState *env) } } -#define USE_ELF_CORE_DUMP #define ELF_EXEC_PAGESIZE 4096#endif /* TARGET_XTENSA */
@@ -1080,9 +1068,9 @@ static void bswap_mips_abiflags(Mips_elf_abiflags_v0 *abiflags) }#endif -#ifdef USE_ELF_CORE_DUMP +#ifdef ELF_NREG static int elf_core_dump (int ,const CPUArchState *); -#endif /* USE_ELF_CORE_DUMP */ +#endif static void load_symbols (struct elfhdr *hdr,const ImageSource *src,abi_ulong load_bias);
@@ -2792,14 +2780,14 @@ int load_elf_binary(struct linux_binprm *bprm, struct image_info *info)g_free (elf_interpreter); } -#ifdef USE_ELF_CORE_DUMP +#ifdef ELF_NREG bprm->core_dump = &elf_core_dump;#endif return 0 ; } -#ifdef USE_ELF_CORE_DUMP +#ifdef ELF_NREG /* * Definitions to generate Intel SVR4-like core files.
@@ -2813,28 +2801,6 @@ int load_elf_binary(struct linux_binprm *bprm, struct image_info *info)* are marked with XXX. * * Core dump code is copied from linux kernel (fs/binfmt_elf.c). -* -* Porting ELF coredump for target is (quite) simple process. First you -* define USE_ELF_CORE_DUMP in target ELF code (where init_thread() for -* the target resides): -* -* #define USE_ELF_CORE_DUMP -* -* Next you define type of register set used for dumping. ELF specification -* says that it needs to be array of elf_greg_t that has size of ELF_NREG. -* -* #define ELF_NREG <number of registers> -* -* Last step is to implement target specific function that copies registers -* from given cpu into just specified register set. Prototype is: -* -* void elf_core_copy_regs(target_ulong *regs, const CPUArchState *env); -* -* Parameters: -* regs - copy register values into here (allocated and zeroed by caller) -* env - copy registers from here -* -* Example for ARM target is provided in this file. */ struct target_elf_siginfo {
@@ -3359,4 +3325,4 @@ static int elf_core_dump(int signr, const CPUArchState *env) }return ret; } -#endif /* USE_ELF_CORE_DUMP */ +#endif /* ELF_NREG */
Signature · 1 line
2.43.0
PATCH v2 50/95 linux-user: Move elf_core_copy_regs to {i386, x86_64}/elfload.c
In reply to Richard HendersonMove elf_core_copy_regs to elfload.c.
Move ELF_NREG to target_elf.h.
--- linux-user/i386/target_elf.h | 8 ++++ linux-user/x86_64/target_elf.h | 8 ++++ linux-user/elfload.c | 70 ---------------------------------- linux-user/i386/elfload.c | 21 ++++++++++ linux-user/x86_64/elfload.c | 31 +++++++++++++++ 5 files changed, 68 insertions(+), 70 deletions(-)
linux-user/i386/target_elf.h +8 -0
@@ -11,4 +11,12 @@#define HAVE_ELF_HWCAP 1#define HAVE_ELF_PLATFORM 1 +/* +* Note that ELF_NREG should be 19 as there should be place for +* TRAPNO and ERR "registers" as well but linux doesn't dump those. +* +* See linux kernel: arch/x86/include/asm/elf.h +*/ +#define ELF_NREG 17 +#endif
linux-user/x86_64/target_elf.h +8 -0
@@ -11,4 +11,12 @@#define HAVE_ELF_HWCAP 1#define HAVE_ELF_PLATFORM 1 +/* +* Note that ELF_NREG should be 29 as there should be place for +* TRAPNO and ERR "registers" as well but linux doesn't dump those. +* +* See linux kernel: arch/x86/include/asm/elf.h +*/ +#define ELF_NREG 27 +#endif
linux-user/elfload.c +0 -70
82 lines not on this page · raw message
linux-user/i386/elfload.c +21 -0
@@ -23,3 +23,24 @@ const char *get_elf_platform(CPUState *cs) family =MAX (MIN (family,6 ),3 );return elf_platform[family -3 ]; } + +void elf_core_copy_regs (target_ulong *regs,const CPUX86State *env) +{ + regs[0 ] =tswapl (env->regs[R_EBX ]); + regs[1 ] =tswapl (env->regs[R_ECX ]); + regs[2 ] =tswapl (env->regs[R_EDX ]); + regs[3 ] =tswapl (env->regs[R_ESI ]); + regs[4 ] =tswapl (env->regs[R_EDI ]); + regs[5 ] =tswapl (env->regs[R_EBP ]); + regs[6 ] =tswapl (env->regs[R_EAX ]); + regs[7 ] =tswapl (env->segs[R_DS ].selector &0xffff ); + regs[8 ] =tswapl (env->segs[R_ES ].selector &0xffff ); + regs[9 ] =tswapl (env->segs[R_FS ].selector &0xffff ); + regs[10 ] =tswapl (env->segs[R_GS ].selector &0xffff ); + regs[11 ] =tswapl (get_task_state (env_cpu_const (env))->orig_ax); + regs[12 ] =tswapl (env->eip); + regs[13 ] =tswapl (env->segs[R_CS ].selector &0xffff ); + regs[14 ] =tswapl (env->eflags); + regs[15 ] =tswapl (env->regs[R_ESP ]); + regs[16 ] =tswapl (env->segs[R_SS ].selector &0xffff ); +}
linux-user/x86_64/elfload.c +31 -0
@@ -19,3 +19,34 @@ const char *get_elf_platform(CPUState *cs) {return "x86_64" ; } + +void elf_core_copy_regs (target_ulong *regs,const CPUX86State *env) +{ + regs[0 ] =tswapl (env->regs[15 ]); + regs[1 ] =tswapl (env->regs[14 ]); + regs[2 ] =tswapl (env->regs[13 ]); + regs[3 ] =tswapl (env->regs[12 ]); + regs[4 ] =tswapl (env->regs[R_EBP ]); + regs[5 ] =tswapl (env->regs[R_EBX ]); + regs[6 ] =tswapl (env->regs[11 ]); + regs[7 ] =tswapl (env->regs[10 ]); + regs[8 ] =tswapl (env->regs[9 ]); + regs[9 ] =tswapl (env->regs[8 ]); + regs[10 ] =tswapl (env->regs[R_EAX ]); + regs[11 ] =tswapl (env->regs[R_ECX ]); + regs[12 ] =tswapl (env->regs[R_EDX ]); + regs[13 ] =tswapl (env->regs[R_ESI ]); + regs[14 ] =tswapl (env->regs[R_EDI ]); + regs[15 ] =tswapl (get_task_state (env_cpu_const (env))->orig_ax); + regs[16 ] =tswapl (env->eip); + regs[17 ] =tswapl (env->segs[R_CS ].selector &0xffff ); + regs[18 ] =tswapl (env->eflags); + regs[19 ] =tswapl (env->regs[R_ESP ]); + regs[20 ] =tswapl (env->segs[R_SS ].selector &0xffff ); + regs[21 ] =tswapl (env->segs[R_FS ].selector &0xffff ); + regs[22 ] =tswapl (env->segs[R_GS ].selector &0xffff ); + regs[23 ] =tswapl (env->segs[R_DS ].selector &0xffff ); + regs[24 ] =tswapl (env->segs[R_ES ].selector &0xffff ); + regs[25 ] =tswapl (env->segs[R_FS ].selector &0xffff ); + regs[26 ] =tswapl (env->segs[R_GS ].selector &0xffff ); +}
Signature · 1 line
2.43.0
PATCH v2 51/95 linux-user: Move elf_core_copy_regs to arm/elfload.c
In reply to Richard HendersonMove elf_core_copy_regs to elfload.c.
Move ELF_NREG to target_elf.h.
--- linux-user/arm/target_elf.h | 2 ++ linux-user/arm/elfload.c | 9 +++++++++ linux-user/elfload.c | 11 ----------- 3 files changed, 11 insertions(+), 11 deletions(-)
linux-user/arm/target_elf.h +2 -0
@@ -12,4 +12,6 @@#define HAVE_ELF_HWCAP2 1#define HAVE_ELF_PLATFORM 1 +#define ELF_NREG 18 +#endif
linux-user/arm/elfload.c +9 -0
@@ -199,3 +199,12 @@ const char *get_elf_platform(CPUState *cs)#undef END } + +void elf_core_copy_regs (target_ulong *regs,const CPUARMState *env) +{ +for (int i =0 ; i <16 ; i++) { + regs[i] =tswapl (env->regs[i]); + } + regs[16 ] =tswapl (cpsr_read ((CPUARMState *)env)); + regs[17 ] =tswapl (env->regs[0 ]);/* XXX */ +}
linux-user/elfload.c +0 -11
@@ -210,17 +210,6 @@ static bool init_guest_commpage(void)#define ELF_CLASS ELFCLASS32#define EXSTACK_DEFAULT true -#define ELF_NREG 18 - -void elf_core_copy_regs (target_ulong *regs,const CPUARMState *env) -{ -for (int i =0 ; i <16 ; i++) { - regs[i] =tswapl (env->regs[i]); - } - regs[16 ] =tswapl (cpsr_read ((CPUARMState *)env)); - regs[17 ] =tswapl (env->regs[0 ]);/* XXX */ -} -#define ELF_EXEC_PAGESIZE 4096/* The commpage only exists for 32 bit kernels */
Signature · 1 line
2.43.0
PATCH v2 52/95 linux-user: Move elf_core_copy_regs to aarch64/elfload.c
In reply to Richard HendersonMove elf_core_copy_regs to elfload.c.
Move ELF_NREG to target_elf.h.
--- linux-user/aarch64/target_elf.h | 2 ++ linux-user/aarch64/elfload.c | 11 +++++++++++ linux-user/elfload.c | 13 ------------- 3 files changed, 13 insertions(+), 13 deletions(-)
linux-user/aarch64/target_elf.h +2 -0
@@ -12,4 +12,6 @@#define HAVE_ELF_HWCAP2 1#define HAVE_ELF_PLATFORM 1 +#define ELF_NREG 34 +#endif
linux-user/aarch64/elfload.c +11 -0
@@ -347,3 +347,14 @@ const char *get_elf_platform(CPUState *cs) {return TARGET_BIG_ENDIAN ?"aarch64_be" :"aarch64" ; } + +void elf_core_copy_regs (target_ulong *regs,const CPUARMState *env) +{ +int i; + +for (i =0 ; i <32 ; i++) { + regs[i] =tswapl (env->xregs[i]); + } + regs[32 ] =tswapl (env->pc); + regs[33 ] =tswapl (pstate_read ((CPUARMState *)env)); +}
linux-user/elfload.c +0 -13
@@ -283,19 +283,6 @@ static const VdsoImageInfo *vdso_image_info(uint32_t elf_flags)#define ELF_ARCH EM_AARCH64#define ELF_CLASS ELFCLASS64 -#define ELF_NREG 34 - -void elf_core_copy_regs (target_ulong *regs,const CPUARMState *env) -{ -int i; - -for (i =0 ; i <32 ; i++) { - regs[i] =tswapl (env->xregs[i]); - } - regs[32 ] =tswapl (env->pc); - regs[33 ] =tswapl (pstate_read ((CPUARMState *)env)); -} -#define ELF_EXEC_PAGESIZE 4096#if TARGET_BIG_ENDIAN
Signature · 1 line
2.43.0
PATCH v2 53/95 linux-user: Move elf_core_copy_regs to ppc/elfload.c
In reply to Richard HendersonMove elf_core_copy_regs to elfload.c.
Move ELF_NREG to target_elf.h.
--- linux-user/ppc/target_elf.h | 3 +++ linux-user/elfload.c | 22 ---------------------- linux-user/ppc/elfload.c | 19 +++++++++++++++++++ 3 files changed, 22 insertions(+), 22 deletions(-)
linux-user/ppc/target_elf.h +3 -0
@@ -11,4 +11,7 @@#define HAVE_ELF_HWCAP 1#define HAVE_ELF_HWCAP2 1 +/* See linux kernel: arch/powerpc/include/asm/elf.h. */ +#define ELF_NREG 48 +#endif
linux-user/elfload.c +0 -22
@@ -353,28 +353,6 @@ static const VdsoImageInfo *vdso_image_info(uint32_t elf_flags)NEW_AUX_ENT (AT_UCACHEBSIZE ,0 ); \ } while (0) -/* See linux kernel: arch/powerpc/include/asm/elf.h. */ -#define ELF_NREG 48 - -void elf_core_copy_regs (target_ulong *regs,const CPUPPCState *env) -{ -int i; -target_ulong ccr =0 ; - -for (i =0 ; i <ARRAY_SIZE (env->gpr); i++) { - regs[i] =tswapl (env->gpr[i]); - } - - regs[32 ] =tswapl (env->nip); - regs[33 ] =tswapl (env->msr); - regs[35 ] =tswapl (env->ctr); - regs[36 ] =tswapl (env->lr); - regs[37 ] =tswapl (cpu_read_xer (env)); - - ccr =ppc_get_cr (env); - regs[38 ] =tswapl (ccr); -} -#define ELF_EXEC_PAGESIZE 4096#ifndef TARGET_PPC64
linux-user/ppc/elfload.c +19 -0
@@ -129,3 +129,22 @@ abi_ulong get_elf_hwcap2(CPUState *cs)return features; } + +void elf_core_copy_regs (target_ulong *regs,const CPUPPCState *env) +{ +int i; +target_ulong ccr =0 ; + +for (i =0 ; i <ARRAY_SIZE (env->gpr); i++) { + regs[i] =tswapl (env->gpr[i]); + } + + regs[32 ] =tswapl (env->nip); + regs[33 ] =tswapl (env->msr); + regs[35 ] =tswapl (env->ctr); + regs[36 ] =tswapl (env->lr); + regs[37 ] =tswapl (cpu_read_xer (env)); + + ccr =ppc_get_cr (env); + regs[38 ] =tswapl (ccr); +}
Signature · 1 line
2.43.0
PATCH v2 54/95 linux-user: Move elf_core_copy_regs to loongarch64/elfload.c
In reply to Richard HendersonMove elf_core_copy_regs to elfload.c.
Move ELF_NREG to target_elf.h.
--- linux-user/loongarch64/target_elf.h | 3 +++ linux-user/elfload.c | 23 ----------------------- linux-user/loongarch64/elfload.c | 20 ++++++++++++++++++++ 3 files changed, 23 insertions(+), 23 deletions(-)
linux-user/loongarch64/target_elf.h +3 -0
@@ -9,4 +9,7 @@#define HAVE_ELF_HWCAP 1#define HAVE_ELF_PLATFORM 1 +/* See linux kernel: arch/loongarch/include/asm/elf.h */ +#define ELF_NREG 45 +#endif
linux-user/elfload.c +0 -23
@@ -375,29 +375,6 @@ static const VdsoImageInfo *vdso_image_info(uint32_t elf_flags)#define VDSO_HEADER "vdso.c.inc" -/* See linux kernel: arch/loongarch/include/asm/elf.h */ -#define ELF_NREG 45 - -enum { -TARGET_EF_R0 =0 , -TARGET_EF_CSR_ERA =TARGET_EF_R0 +33 , -TARGET_EF_CSR_BADV =TARGET_EF_R0 +34 , -}; - -void elf_core_copy_regs (target_ulong *regs,const CPULoongArchState *env) -{ -int i; - - regs[TARGET_EF_R0 ] =0 ; - -for (i =1 ; i <ARRAY_SIZE (env->gpr); i++) { - regs[TARGET_EF_R0 + i] =tswapl (env->gpr[i]); - } - - regs[TARGET_EF_CSR_ERA ] =tswapl (env->pc); - regs[TARGET_EF_CSR_BADV ] =tswapl (env->CSR_BADV); -} -#define ELF_EXEC_PAGESIZE 4096#endif /* TARGET_LOONGARCH64 */
linux-user/loongarch64/elfload.c +20 -0
@@ -61,3 +61,23 @@ const char *get_elf_platform(CPUState *cs) {return "loongarch" ; } + +enum { +TARGET_EF_R0 =0 , +TARGET_EF_CSR_ERA =TARGET_EF_R0 +33 , +TARGET_EF_CSR_BADV =TARGET_EF_R0 +34 , +}; + +void elf_core_copy_regs (target_ulong *regs,const CPULoongArchState *env) +{ +int i; + + regs[TARGET_EF_R0 ] =0 ; + +for (i =1 ; i <ARRAY_SIZE (env->gpr); i++) { + regs[TARGET_EF_R0 + i] =tswapl (env->gpr[i]); + } + + regs[TARGET_EF_CSR_ERA ] =tswapl (env->pc); + regs[TARGET_EF_CSR_BADV ] =tswapl (env->CSR_BADV); +}
Signature · 1 line
2.43.0
PATCH v2 55/95 linux-user: Move elf_core_copy_regs to mips/elfload.c
In reply to Richard HendersonMove elf_core_copy_regs to elfload.c.
Move ELF_NREG to target_elf.h.
--- linux-user/mips/target_elf.h | 3 +++ linux-user/mips64/target_elf.h | 3 +++ linux-user/elfload.c | 44 ---------------------------------- linux-user/mips/elfload.c | 41 +++++++++++++++++++++++++++++++ 4 files changed, 47 insertions(+), 44 deletions(-)
linux-user/mips/target_elf.h +3 -0
@@ -11,4 +11,7 @@#define HAVE_ELF_HWCAP 1#define HAVE_ELF_BASE_PLATFORM 1 +/* See linux kernel: arch/mips/include/asm/elf.h. */ +#define ELF_NREG 45 +#endif
linux-user/mips64/target_elf.h +3 -0
@@ -11,4 +11,7 @@#define HAVE_ELF_HWCAP 1#define HAVE_ELF_BASE_PLATFORM 1 +/* See linux kernel: arch/mips/include/asm/elf.h. */ +#define ELF_NREG 45 +#endif
linux-user/elfload.c +0 -44
50 lines not on this page · raw message
linux-user/mips/elfload.c +41 -0
44 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v2 56/95 linux-user: Move elf_core_copy_regs to microblaze/elfload.c
In reply to Richard HendersonMove elf_core_copy_regs to elfload.c.
Move ELF_NREG to target_elf.h.
--- linux-user/microblaze/target_elf.h | 2 ++ linux-user/elfload.c | 19 ------------------- linux-user/microblaze/elfload.c | 17 +++++++++++++++++ 3 files changed, 19 insertions(+), 19 deletions(-)
linux-user/microblaze/target_elf.h +2 -0
@@ -8,4 +8,6 @@#ifndef MICROBLAZE_TARGET_ELF_H #define MICROBLAZE_TARGET_ELF_H +#define ELF_NREG 38 +#endif
linux-user/elfload.c +0 -19
@@ -408,25 +408,6 @@ static const VdsoImageInfo *vdso_image_info(uint32_t elf_flags)#define ELF_EXEC_PAGESIZE 4096 -#define ELF_NREG 38 - -/* See linux kernel: arch/mips/kernel/process.c:elf_dump_regs. */ -void elf_core_copy_regs (target_ulong *regs,const CPUMBState *env) -{ -int i, pos =0 ; - -for (i =0 ; i <32 ; i++) { - regs[pos++] =tswapl (env->regs[i]); - } - - regs[pos++] =tswapl (env->pc); - regs[pos++] =tswapl (mb_cpu_read_msr (env)); - regs[pos++] =0 ; - regs[pos++] =tswapl (env->ear); - regs[pos++] =0 ; - regs[pos++] =tswapl (env->esr); -} -#endif /* TARGET_MICROBLAZE */ #ifdef TARGET_OPENRISC
linux-user/microblaze/elfload.c +17 -0
@@ -9,3 +9,20 @@ const char *get_elf_cpu_model(uint32_t eflags) {return "any" ; } + +/* See linux kernel: arch/mips/kernel/process.c:elf_dump_regs. */ +void elf_core_copy_regs (target_ulong *regs,const CPUMBState *env) +{ +int i, pos =0 ; + +for (i =0 ; i <32 ; i++) { + regs[pos++] =tswapl (env->regs[i]); + } + + regs[pos++] =tswapl (env->pc); + regs[pos++] =tswapl (mb_cpu_read_msr (env)); + regs[pos++] =0 ; + regs[pos++] =tswapl (env->ear); + regs[pos++] =0 ; + regs[pos++] =tswapl (env->esr); +}
Signature · 1 line
2.43.0
PATCH v2 57/95 linux-user: Move elf_core_copy_regs to openrisc/elfload.c
In reply to Richard HendersonMove elf_core_copy_regs to elfload.c.
Move ELF_NREG to target_elf.h.
--- linux-user/openrisc/target_elf.h | 3 +++ linux-user/elfload.c | 14 -------------- linux-user/openrisc/elfload.c | 11 +++++++++++ 3 files changed, 14 insertions(+), 14 deletions(-)
linux-user/openrisc/target_elf.h +3 -0
@@ -8,4 +8,7 @@#ifndef OPENRISC_TARGET_ELF_H #define OPENRISC_TARGET_ELF_H +/* See linux kernel arch/openrisc/include/asm/elf.h. */ +#define ELF_NREG 34/* gprs and pc, sr */ +#endif
linux-user/elfload.c +0 -14
@@ -418,20 +418,6 @@ static const VdsoImageInfo *vdso_image_info(uint32_t elf_flags)#define ELF_EXEC_PAGESIZE 8192 -/* See linux kernel arch/openrisc/include/asm/elf.h. */ -#define ELF_NREG 34/* gprs and pc, sr */ - -void elf_core_copy_regs (target_ulong *regs,const CPUOpenRISCState *env) -{ -int i; - -for (i =0 ; i <32 ; i++) { - regs[i] =tswapl (cpu_get_gpr (env, i)); - } - regs[32 ] =tswapl (env->pc); - regs[33 ] =tswapl (cpu_get_sr (env)); -} -#endif /* TARGET_OPENRISC */ #ifdef TARGET_SH4
linux-user/openrisc/elfload.c +11 -0
@@ -9,3 +9,14 @@ const char *get_elf_cpu_model(uint32_t eflags) {return "any" ; } + +void elf_core_copy_regs (target_ulong *regs,const CPUOpenRISCState *env) +{ +int i; + +for (i =0 ; i <32 ; i++) { + regs[i] =tswapl (cpu_get_gpr (env, i)); + } + regs[32 ] =tswapl (env->pc); + regs[33 ] =tswapl (cpu_get_sr (env)); +}
Signature · 1 line
2.43.0
PATCH v2 58/95 linux-user: Move elf_core_copy_regs to sh4/elfload.c
In reply to Richard HendersonMove elf_core_copy_regs to elfload.c.
Move ELF_NREG to target_elf.h.
--- linux-user/sh4/target_elf.h | 3 +++ linux-user/elfload.c | 31 ------------------------------- linux-user/sh4/elfload.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 31 deletions(-)
linux-user/sh4/target_elf.h +3 -0
@@ -10,4 +10,7 @@#define HAVE_ELF_HWCAP 1 +/* See linux kernel: arch/sh/include/asm/elf.h. */ +#define ELF_NREG 23 +#endif
linux-user/elfload.c +0 -31
@@ -425,37 +425,6 @@ static const VdsoImageInfo *vdso_image_info(uint32_t elf_flags)#define ELF_CLASS ELFCLASS32#define ELF_ARCH EM_SH -/* See linux kernel: arch/sh/include/asm/elf.h. */ -#define ELF_NREG 23 - -/* See linux kernel: arch/sh/include/asm/ptrace.h. */ -enum { -TARGET_REG_PC =16 , -TARGET_REG_PR =17 , -TARGET_REG_SR =18 , -TARGET_REG_GBR =19 , -TARGET_REG_MACH =20 , -TARGET_REG_MACL =21 , -TARGET_REG_SYSCALL =22 -}; - -void elf_core_copy_regs (target_ulong *regs,const CPUSH4State *env) -{ -int i; - -for (i =0 ; i <16 ; i++) { - regs[i] =tswapl (env->gregs[i]); - } - - regs[TARGET_REG_PC ] =tswapl (env->pc); - regs[TARGET_REG_PR ] =tswapl (env->pr); - regs[TARGET_REG_SR ] =tswapl (env->sr); - regs[TARGET_REG_GBR ] =tswapl (env->gbr); - regs[TARGET_REG_MACH ] =tswapl (env->mach); - regs[TARGET_REG_MACL ] =tswapl (env->macl); - regs[TARGET_REG_SYSCALL ] =0 ;/* FIXME */ -} -#define ELF_EXEC_PAGESIZE 4096#endif
linux-user/sh4/elfload.c +28 -0
@@ -36,3 +36,31 @@ abi_ulong get_elf_hwcap(CPUState *cs)return hwcap; } + +/* See linux kernel: arch/sh/include/asm/ptrace.h. */ +enum { +TARGET_REG_PC =16 , +TARGET_REG_PR =17 , +TARGET_REG_SR =18 , +TARGET_REG_GBR =19 , +TARGET_REG_MACH =20 , +TARGET_REG_MACL =21 , +TARGET_REG_SYSCALL =22 +}; + +void elf_core_copy_regs (target_ulong *regs,const CPUSH4State *env) +{ +int i; + +for (i =0 ; i <16 ; i++) { + regs[i] =tswapl (env->gregs[i]); + } + + regs[TARGET_REG_PC ] =tswapl (env->pc); + regs[TARGET_REG_PR ] =tswapl (env->pr); + regs[TARGET_REG_SR ] =tswapl (env->sr); + regs[TARGET_REG_GBR ] =tswapl (env->gbr); + regs[TARGET_REG_MACH ] =tswapl (env->mach); + regs[TARGET_REG_MACL ] =tswapl (env->macl); + regs[TARGET_REG_SYSCALL ] =0 ;/* FIXME */ +}
Signature · 1 line
2.43.0
PATCH v2 59/95 linux-user: Move elf_core_copy_regs to m68k/elfload.c
In reply to Richard HendersonMove elf_core_copy_regs to elfload.c.
Move ELF_NREG to target_elf.h.
--- linux-user/m68k/target_elf.h | 3 +++ linux-user/elfload.c | 27 --------------------------- linux-user/m68k/elfload.c | 24 ++++++++++++++++++++++++ 3 files changed, 27 insertions(+), 27 deletions(-)
linux-user/m68k/target_elf.h +3 -0
@@ -8,4 +8,7 @@#ifndef M68K_TARGET_ELF_H #define M68K_TARGET_ELF_H +/* See linux kernel: arch/m68k/include/asm/elf.h. */ +#define ELF_NREG 20 +#endif
linux-user/elfload.c +0 -27
@@ -434,33 +434,6 @@ static const VdsoImageInfo *vdso_image_info(uint32_t elf_flags)#define ELF_CLASS ELFCLASS32#define ELF_ARCH EM_68K -/* See linux kernel: arch/m68k/include/asm/elf.h. */ -#define ELF_NREG 20 - -void elf_core_copy_regs (target_ulong *regs,const CPUM68KState *env) -{ - regs[0 ] =tswapl (env->dregs[1 ]); - regs[1 ] =tswapl (env->dregs[2 ]); - regs[2 ] =tswapl (env->dregs[3 ]); - regs[3 ] =tswapl (env->dregs[4 ]); - regs[4 ] =tswapl (env->dregs[5 ]); - regs[5 ] =tswapl (env->dregs[6 ]); - regs[6 ] =tswapl (env->dregs[7 ]); - regs[7 ] =tswapl (env->aregs[0 ]); - regs[8 ] =tswapl (env->aregs[1 ]); - regs[9 ] =tswapl (env->aregs[2 ]); - regs[10 ] =tswapl (env->aregs[3 ]); - regs[11 ] =tswapl (env->aregs[4 ]); - regs[12 ] =tswapl (env->aregs[5 ]); - regs[13 ] =tswapl (env->aregs[6 ]); - regs[14 ] =tswapl (env->dregs[0 ]); - regs[15 ] =tswapl (env->aregs[7 ]); - regs[16 ] =tswapl (env->dregs[0 ]);/* FIXME: orig_d0 */ - regs[17 ] =tswapl (env->sr); - regs[18 ] =tswapl (env->pc); - regs[19 ] =0 ;/* FIXME: regs->format | regs->vector */ -} -#define ELF_EXEC_PAGESIZE 8192#endif
linux-user/m68k/elfload.c +24 -0
@@ -16,3 +16,27 @@ const char *get_elf_cpu_model(uint32_t eflags)/* Coldfire */ return "any" ; } + +void elf_core_copy_regs (target_ulong *regs,const CPUM68KState *env) +{ + regs[0 ] =tswapl (env->dregs[1 ]); + regs[1 ] =tswapl (env->dregs[2 ]); + regs[2 ] =tswapl (env->dregs[3 ]); + regs[3 ] =tswapl (env->dregs[4 ]); + regs[4 ] =tswapl (env->dregs[5 ]); + regs[5 ] =tswapl (env->dregs[6 ]); + regs[6 ] =tswapl (env->dregs[7 ]); + regs[7 ] =tswapl (env->aregs[0 ]); + regs[8 ] =tswapl (env->aregs[1 ]); + regs[9 ] =tswapl (env->aregs[2 ]); + regs[10 ] =tswapl (env->aregs[3 ]); + regs[11 ] =tswapl (env->aregs[4 ]); + regs[12 ] =tswapl (env->aregs[5 ]); + regs[13 ] =tswapl (env->aregs[6 ]); + regs[14 ] =tswapl (env->dregs[0 ]); + regs[15 ] =tswapl (env->aregs[7 ]); + regs[16 ] =tswapl (env->dregs[0 ]);/* FIXME: orig_d0 */ + regs[17 ] =tswapl (env->sr); + regs[18 ] =tswapl (env->pc); + regs[19 ] =0 ;/* FIXME: regs->format | regs->vector */ +}
Signature · 1 line
2.43.0
PATCH v2 60/95 linux-user: Move elf_core_copy_regs to s390x/elfload.c
In reply to Richard HendersonMove elf_core_copy_regs to elfload.c.
Move ELF_NREG to target_elf.h.
--- linux-user/s390x/target_elf.h | 3 +++ linux-user/elfload.c | 28 ---------------------------- linux-user/s390x/elfload.c | 25 +++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 28 deletions(-)
linux-user/s390x/target_elf.h +3 -0
@@ -10,4 +10,7 @@#define HAVE_ELF_HWCAP 1 +/* See linux kernel: arch/s390/include/uapi/asm/ptrace.h (s390_regs). */ +#define ELF_NREG 27 +#endif
linux-user/elfload.c +0 -28
@@ -453,34 +453,6 @@ static const VdsoImageInfo *vdso_image_info(uint32_t elf_flags)#define ELF_DATA ELFDATA2MSB#define ELF_ARCH EM_S390 -/* See linux kernel: arch/s390/include/uapi/asm/ptrace.h (s390_regs). */ -#define ELF_NREG 27 - -enum { -TARGET_REG_PSWM =0 , -TARGET_REG_PSWA =1 , -TARGET_REG_GPRS =2 , -TARGET_REG_ARS =18 , -TARGET_REG_ORIG_R2 =26 , -}; - -void elf_core_copy_regs (target_ulong *regs,const CPUS390XState *env) -{ -int i; -uint32_t *aregs; - - regs[TARGET_REG_PSWM ] =tswapl (env->psw.mask); - regs[TARGET_REG_PSWA ] =tswapl (env->psw.addr); -for (i =0 ; i <16 ; i++) { - regs[TARGET_REG_GPRS + i] =tswapl (env->regs[i]); - } - aregs = (uint32_t *)®s[TARGET_REG_ARS ]; -for (i =0 ; i <16 ; i++) { - aregs[i] =tswap32 (env->aregs[i]); - } - regs[TARGET_REG_ORIG_R2 ] =0 ; -} -#define ELF_EXEC_PAGESIZE 4096#define VDSO_HEADER "vdso.c.inc"
linux-user/s390x/elfload.c +25 -0
@@ -66,3 +66,28 @@ const char *elf_hwcap_str(uint32_t bit)return bit <ARRAY_SIZE (hwcap_str) ? hwcap_str[bit] :NULL ; } + +enum { +TARGET_REG_PSWM =0 , +TARGET_REG_PSWA =1 , +TARGET_REG_GPRS =2 , +TARGET_REG_ARS =18 , +TARGET_REG_ORIG_R2 =26 , +}; + +void elf_core_copy_regs (target_ulong *regs,const CPUS390XState *env) +{ +int i; +uint32_t *aregs; + + regs[TARGET_REG_PSWM ] =tswapl (env->psw.mask); + regs[TARGET_REG_PSWA ] =tswapl (env->psw.addr); +for (i =0 ; i <16 ; i++) { + regs[TARGET_REG_GPRS + i] =tswapl (env->regs[i]); + } + aregs = (uint32_t *)®s[TARGET_REG_ARS ]; +for (i =0 ; i <16 ; i++) { + aregs[i] =tswap32 (env->aregs[i]); + } + regs[TARGET_REG_ORIG_R2 ] =0 ; +}
Signature · 1 line
2.43.0
Re: [PATCH v2 60/95] linux-user: Move elf_core_copy_regs to s390x/elfload.c
Quoted 6 lines · Richard Henderson
Move
elf_core_copy_regstoelfload.c.
MoveELF_NREGtotarget_elf.h.Signed-off-by Richard Henderson <[email protected]>---
thanks
-- PMM
PATCH v2 61/95 linux-user: Move elf_core_copy_regs to xtensa/elfload.c
In reply to Richard HendersonMove elf_core_copy_regs to elfload.c.
Move ELF_NREG to target_elf.h.
--- linux-user/xtensa/target_elf.h | 3 +++ linux-user/elfload.c | 35 ---------------------------------- linux-user/xtensa/elfload.c | 32 +++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 35 deletions(-)
linux-user/xtensa/target_elf.h +3 -0
@@ -8,4 +8,7 @@#ifndef XTENSA_TARGET_ELF_H #define XTENSA_TARGET_ELF_H +/* See linux kernel: arch/xtensa/include/asm/elf.h. */ +#define ELF_NREG 128 +#endif
linux-user/elfload.c +0 -35
@@ -523,41 +523,6 @@ static bool init_guest_commpage(void)#define ELF_CLASS ELFCLASS32#define ELF_ARCH EM_XTENSA -/* See linux kernel: arch/xtensa/include/asm/elf.h. */ -#define ELF_NREG 128 - -enum { -TARGET_REG_PC , -TARGET_REG_PS , -TARGET_REG_LBEG , -TARGET_REG_LEND , -TARGET_REG_LCOUNT , -TARGET_REG_SAR , -TARGET_REG_WINDOWSTART , -TARGET_REG_WINDOWBASE , -TARGET_REG_THREADPTR , -TARGET_REG_AR0 =64 , -}; - -void elf_core_copy_regs (target_ulong *regs,const CPUXtensaState *env) -{ -unsigned i; - - regs[TARGET_REG_PC ] =tswapl (env->pc); - regs[TARGET_REG_PS ] =tswapl (env->sregs[PS ] & ~PS_EXCM ); - regs[TARGET_REG_LBEG ] =tswapl (env->sregs[LBEG ]); - regs[TARGET_REG_LEND ] =tswapl (env->sregs[LEND ]); - regs[TARGET_REG_LCOUNT ] =tswapl (env->sregs[LCOUNT ]); - regs[TARGET_REG_SAR ] =tswapl (env->sregs[SAR ]); - regs[TARGET_REG_WINDOWSTART ] =tswapl (env->sregs[WINDOW_START ]); - regs[TARGET_REG_WINDOWBASE ] =tswapl (env->sregs[WINDOW_BASE ]); - regs[TARGET_REG_THREADPTR ] =tswapl (env->uregs[THREADPTR ]); -xtensa_sync_phys_from_window ((CPUXtensaState *)env); -for (i =0 ; i < env->config->nareg; ++i) { - regs[TARGET_REG_AR0 + i] =tswapl (env->phys_regs[i]); - } -} -#define ELF_EXEC_PAGESIZE 4096#endif /* TARGET_XTENSA */
linux-user/xtensa/elfload.c +32 -0
@@ -9,3 +9,35 @@ const char *get_elf_cpu_model(uint32_t eflags) {return XTENSA_DEFAULT_CPU_MODEL ; } + +enum { +TARGET_REG_PC , +TARGET_REG_PS , +TARGET_REG_LBEG , +TARGET_REG_LEND , +TARGET_REG_LCOUNT , +TARGET_REG_SAR , +TARGET_REG_WINDOWSTART , +TARGET_REG_WINDOWBASE , +TARGET_REG_THREADPTR , +TARGET_REG_AR0 =64 , +}; + +void elf_core_copy_regs (target_ulong *regs,const CPUXtensaState *env) +{ +unsigned i; + + regs[TARGET_REG_PC ] =tswapl (env->pc); + regs[TARGET_REG_PS ] =tswapl (env->sregs[PS ] & ~PS_EXCM ); + regs[TARGET_REG_LBEG ] =tswapl (env->sregs[LBEG ]); + regs[TARGET_REG_LEND ] =tswapl (env->sregs[LEND ]); + regs[TARGET_REG_LCOUNT ] =tswapl (env->sregs[LCOUNT ]); + regs[TARGET_REG_SAR ] =tswapl (env->sregs[SAR ]); + regs[TARGET_REG_WINDOWSTART ] =tswapl (env->sregs[WINDOW_START ]); + regs[TARGET_REG_WINDOWBASE ] =tswapl (env->sregs[WINDOW_BASE ]); + regs[TARGET_REG_THREADPTR ] =tswapl (env->uregs[THREADPTR ]); +xtensa_sync_phys_from_window ((CPUXtensaState *)env); +for (i =0 ; i < env->config->nareg; ++i) { + regs[TARGET_REG_AR0 + i] =tswapl (env->phys_regs[i]); + } +}
Signature · 1 line
2.43.0
Re: [PATCH v2 61/95] linux-user: Move elf_core_copy_regs to xtensa/elfload.c
Quoted 5 lines · Richard Henderson
Move
elf_core_copy_regstoelfload.c.
MoveELF_NREGtotarget_elf.h.Signed-off-by Richard Henderson <[email protected]>
thanks
-- PMM
PATCH v2 62/95 linux-user: Move init_guest_commpage to x86_64/elfload.c
In reply to Richard HendersonRename INIT_GUEST_COMMPAGE to HAVE_GUEST_COMMPAGE
to match the other HAVE_* defines.
--- linux-user/loader.h | 3 +++ linux-user/x86_64/target_elf.h | 1 + linux-user/elfload.c | 23 +---------------------- linux-user/x86_64/elfload.c | 20 ++++++++++++++++++++ 4 files changed, 25 insertions(+), 22 deletions(-)
linux-user/loader.h +3 -0
@@ -105,6 +105,9 @@ const char *elf_hwcap_str(uint32_t bit);const char *elf_hwcap2_str (uint32_t bit);const char *get_elf_platform (CPUState *cs);const char *get_elf_base_platform (CPUState *cs); +#if defined(TARGET_X86_64 ) +bool init_guest_commpage (void ); +#endif void elf_core_copy_regs (target_ulong *regs,const CPUArchState *env);#endif /* LINUX_USER_LOADER_H */
linux-user/x86_64/target_elf.h +1 -0
@@ -10,6 +10,7 @@#define HAVE_ELF_HWCAP 1#define HAVE_ELF_PLATFORM 1 +#define HAVE_GUEST_COMMPAGE 1/* * Note that ELF_NREG should be 29 as there should be place for
linux-user/elfload.c +1 -22
@@ -145,27 +145,6 @@ typedef abi_int target_pid_t;#define ELF_CLASS ELFCLASS64#define ELF_ARCH EM_X86_64 -#if ULONG_MAX >UINT32_MAX -#define INIT_GUEST_COMMPAGE -static bool init_guest_commpage (void ) -{ -/* -* The vsyscall page is at a high negative address aka kernel space, -* which means that we cannot actually allocate it with target_mmap. -* We still should be able to use page_set_flags, unless the user -* has specified -R reserved_va, which would trigger an assert(). -*/ -if (reserved_va !=0 && -TARGET_VSYSCALL_PAGE +TARGET_PAGE_SIZE -1 > reserved_va) { -error_report ("Cannot allocate vsyscall page" ); -exit (EXIT_FAILURE ); - } -page_set_flags (TARGET_VSYSCALL_PAGE , -TARGET_VSYSCALL_PAGE | ~TARGET_PAGE_MASK , -PAGE_EXEC |PAGE_VALID ); -return true; -} -#endif #else /*
@@ -1215,7 +1194,7 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,#else #define HI_COMMPAGE 0#define LO_COMMPAGE -1 -#ifndef INIT_GUEST_COMMPAGE +#ifndef HAVE_GUEST_COMMPAGE #define init_guest_commpage () true#endif #endif
linux-user/x86_64/elfload.c +20 -0
@@ -1,6 +1,7 @@/* SPDX-License-Identifier: GPL-2.0-or-later */ #include "qemu/osdep.h" +#include "qemu/error-report.h" #include "qemu.h" #include "loader.h"
@@ -20,6 +21,25 @@ const char *get_elf_platform(CPUState *cs)return "x86_64" ; } +bool init_guest_commpage (void ) +{ +/* +* The vsyscall page is at a high negative address aka kernel space, +* which means that we cannot actually allocate it with target_mmap. +* We still should be able to use page_set_flags, unless the user +* has specified -R reserved_va, which would trigger an assert(). +*/ +if (reserved_va !=0 && +TARGET_VSYSCALL_PAGE +TARGET_PAGE_SIZE -1 > reserved_va) { +error_report ("Cannot allocate vsyscall page" ); +exit (EXIT_FAILURE ); + } +page_set_flags (TARGET_VSYSCALL_PAGE , +TARGET_VSYSCALL_PAGE | ~TARGET_PAGE_MASK , +PAGE_EXEC |PAGE_VALID ); +return true; +} +void elf_core_copy_regs (target_ulong *regs,const CPUX86State *env) { regs[0 ] =tswapl (env->regs[15 ]);
Signature · 1 line
2.43.0
PATCH v2 63/95 linux-user: Move init_guest_commpage to arm/elfload.c
In reply to Richard Henderson--- linux-user/arm/target_elf.h | 1 + linux-user/loader.h | 2 +- linux-user/arm/elfload.c | 46 +++++++++++++++++++++++++++++++++++ linux-user/elfload.c | 48 ------------------------------------- 4 files changed, 48 insertions(+), 49 deletions(-)
linux-user/arm/target_elf.h +1 -0
@@ -13,5 +13,6 @@#define HAVE_ELF_PLATFORM 1#define ELF_NREG 18 +#define HI_COMMPAGE ((intptr_t)0xffff0f00u)#endif
linux-user/loader.h +1 -1
@@ -105,7 +105,7 @@ const char *elf_hwcap_str(uint32_t bit);const char *elf_hwcap2_str (uint32_t bit);const char *get_elf_platform (CPUState *cs);const char *get_elf_base_platform (CPUState *cs); -#if defined(TARGET_X86_64 ) +#if defined(TARGET_X86_64 ) || defined(TARGET_ARM )bool init_guest_commpage (void );#endif void elf_core_copy_regs (target_ulong *regs,const CPUArchState *env);
linux-user/arm/elfload.c +46 -0
58 lines not on this page · raw message
linux-user/elfload.c +0 -48
54 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v2 64/95 linux-user: Move init_guest_commpage to hppa/elfload.c
In reply to Richard Henderson--- linux-user/hppa/target_elf.h | 2 ++ linux-user/loader.h | 2 -- linux-user/elfload.c | 32 -------------------------------- linux-user/hppa/elfload.c | 31 +++++++++++++++++++++++++++++++ 4 files changed, 33 insertions(+), 34 deletions(-)
linux-user/hppa/target_elf.h +2 -0
@@ -10,4 +10,6 @@#define HAVE_ELF_PLATFORM 1 +#define LO_COMMPAGE 0 +#endif
linux-user/loader.h +0 -2
@@ -105,9 +105,7 @@ const char *elf_hwcap_str(uint32_t bit);const char *elf_hwcap2_str (uint32_t bit);const char *get_elf_platform (CPUState *cs);const char *get_elf_base_platform (CPUState *cs); -#if defined(TARGET_X86_64 ) || defined(TARGET_ARM )bool init_guest_commpage (void ); -#endif void elf_core_copy_regs (target_ulong *regs,const CPUArchState *env);#endif /* LINUX_USER_LOADER_H */
linux-user/elfload.c +0 -32
@@ -415,38 +415,6 @@ static const VdsoImageInfo *vdso_image_info(uint32_t elf_flags)#define VDSO_HEADER "vdso.c.inc" -#define LO_COMMPAGE 0 - -static bool init_guest_commpage (void ) -{ -/* If reserved_va, then we have already mapped 0 page on the host. */ -if (!reserved_va) { -void *want, *addr; - - want =g2h_untagged (LO_COMMPAGE ); - addr =mmap (want,TARGET_PAGE_SIZE ,PROT_NONE , -MAP_ANONYMOUS |MAP_PRIVATE |MAP_FIXED_NOREPLACE ,-1 ,0 ); -if (addr ==MAP_FAILED ) { -perror ("Allocating guest commpage" ); -exit (EXIT_FAILURE ); - } -if (addr != want) { -return false; - } - } - -/* -* On Linux, page zero is normally marked execute only + gateway. -* Normal read or write is supposed to fail (thus PROT_NONE above), -* but specific offsets have kernel code mapped to raise permissions -* and implement syscalls. Here, simply mark the page executable. -* Special case the entry points during translation (see do_page_zero). -*/ -page_set_flags (LO_COMMPAGE ,LO_COMMPAGE | ~TARGET_PAGE_MASK , -PAGE_EXEC |PAGE_VALID ); -return true; -} -#endif /* TARGET_HPPA */ #ifdef TARGET_XTENSA
linux-user/hppa/elfload.c +31 -0
@@ -3,6 +3,7 @@#include "qemu/osdep.h" #include "qemu.h" #include "loader.h" +#include "target_elf.h" const char *get_elf_cpu_model (uint32_t eflags)
@@ -14,3 +15,33 @@ const char *get_elf_platform(CPUState *cs) {return "PARISC" ; } + +bool init_guest_commpage (void ) +{ +/* If reserved_va, then we have already mapped 0 page on the host. */ +if (!reserved_va) { +void *want, *addr; + + want =g2h_untagged (LO_COMMPAGE ); + addr =mmap (want,TARGET_PAGE_SIZE ,PROT_NONE , +MAP_ANONYMOUS |MAP_PRIVATE |MAP_FIXED_NOREPLACE ,-1 ,0 ); +if (addr ==MAP_FAILED ) { +perror ("Allocating guest commpage" ); +exit (EXIT_FAILURE ); + } +if (addr != want) { +return false; + } + } + +/* +* On Linux, page zero is normally marked execute only + gateway. +* Normal read or write is supposed to fail (thus PROT_NONE above), +* but specific offsets have kernel code mapped to raise permissions +* and implement syscalls. Here, simply mark the page executable. +* Special case the entry points during translation (see do_page_zero). +*/ +page_set_flags (LO_COMMPAGE ,LO_COMMPAGE | ~TARGET_PAGE_MASK , +PAGE_EXEC |PAGE_VALID ); +return true; +}
Signature · 1 line
2.43.0
PATCH v2 65/95 linux-user: Replace init_guest_commpage macro with function
In reply to Richard HendersonTurn the fallback macro into a function. This will produce a link error if the other macros are set up incorrectly.
--- linux-user/elfload.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/elfload.c +1 -1
@@ -1115,7 +1115,7 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,#define HI_COMMPAGE 0#define LO_COMMPAGE -1#ifndef HAVE_GUEST_COMMPAGE -#define init_guest_commpage () true +bool init_guest_commpage (void ) {return true; }#endif #endif
Signature · 1 line
2.43.0
PATCH v2 66/95 linux-user: Move get_vdso_image_info to arm/elfload.c
In reply to Richard HendersonRename from vdso_image_info to avoid a symbol clash. Define HAVE_VDSO_IMAGE_INFO to signal the external definition exists. Provide fallback versions for other targets.
--- linux-user/arm/target_elf.h | 1 + linux-user/loader.h | 12 +++++++++++ linux-user/arm/elfload.c | 20 ++++++++++++++++++ linux-user/elfload.c | 41 ++++++++----------------------------- 4 files changed, 42 insertions(+), 32 deletions(-)
linux-user/arm/target_elf.h +1 -0
@@ -11,6 +11,7 @@#define HAVE_ELF_HWCAP 1#define HAVE_ELF_HWCAP2 1#define HAVE_ELF_PLATFORM 1 +#define HAVE_VDSO_IMAGE_INFO 1#define ELF_NREG 18#define HI_COMMPAGE ((intptr_t)0xffff0f00u)
linux-user/loader.h +12 -0
@@ -108,4 +108,16 @@ const char *get_elf_base_platform(CPUState *cs);bool init_guest_commpage (void );void elf_core_copy_regs (target_ulong *regs,const CPUArchState *env); +typedef struct { +const uint8_t *image; +const uint32_t *relocs; +unsigned image_size; +unsigned reloc_count; +unsigned sigreturn_ofs; +unsigned rt_sigreturn_ofs; +}VdsoImageInfo ; + +/* Note that both Elf32_Word and Elf64_Word are uint32_t. */ +const VdsoImageInfo *get_vdso_image_info (uint32_t elf_flags); +#endif /* LINUX_USER_LOADER_H */
linux-user/arm/elfload.c +20 -0
@@ -6,6 +6,7 @@#include "user-internals.h" #include "target_elf.h" #include "target/arm/cpu-features.h" +#include "elf.h" const char *get_elf_cpu_model (uint32_t eflags)
@@ -254,3 +255,22 @@ void elf_core_copy_regs(target_ulong *regs, const CPUARMState *env) regs[16 ] =tswapl (cpsr_read ((CPUARMState *)env)); regs[17 ] =tswapl (env->regs[0 ]);/* XXX */ } + +#if TARGET_BIG_ENDIAN +# include "vdso-be8.c.inc" +# include "vdso-be32.c.inc" +#else +# include "vdso-le.c.inc" +#endif + +const VdsoImageInfo *get_vdso_image_info (uint32_t elf_flags) +{ +#if TARGET_BIG_ENDIAN +return (EF_ARM_EABI_VERSION (elf_flags) >=EF_ARM_EABI_VER4 + && (elf_flags &EF_ARM_BE8 ) + ? &vdso_be8_image_info + : &vdso_be32_image_info); +#else +return &vdso_image_info; +#endif +}
linux-user/elfload.c +9 -32
68 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v2 67/95 linux-user: Remove ELF_EXEC_PAGESIZE
In reply to Richard HendersonUse TARGET_PAGE_SIZE instead. If the target page size may vary, using a different fixed size is wrong.
--- linux-user/elfload.c | 32 ++------------------------------ 1 file changed, 2 insertions(+), 30 deletions(-)
linux-user/elfload.c +2 -30
@@ -167,8 +167,6 @@ typedef abi_int target_pid_t;#define VDSO_HEADER "vdso.c.inc" -#define ELF_EXEC_PAGESIZE 4096 -#endif /* TARGET_I386 */ #ifdef TARGET_ARM
@@ -180,16 +178,12 @@ typedef abi_int target_pid_t;#define ELF_CLASS ELFCLASS32#define EXSTACK_DEFAULT true -#define ELF_EXEC_PAGESIZE 4096 -#else /* 64 bit ARM definitions */ #define ELF_ARCH EM_AARCH64#define ELF_CLASS ELFCLASS64 -#define ELF_EXEC_PAGESIZE 4096 -#if TARGET_BIG_ENDIAN # define VDSO_HEADER "vdso-be.c.inc"#else
@@ -258,8 +252,6 @@ typedef abi_int target_pid_t;NEW_AUX_ENT (AT_UCACHEBSIZE ,0 ); \ } while (0) -#define ELF_EXEC_PAGESIZE 4096 -#ifndef TARGET_PPC64 # define VDSO_HEADER "vdso-32.c.inc"#elif TARGET_BIG_ENDIAN
@@ -280,8 +272,6 @@ typedef abi_int target_pid_t;#define VDSO_HEADER "vdso.c.inc" -#define ELF_EXEC_PAGESIZE 4096 -#endif /* TARGET_LOONGARCH64 */ #ifdef TARGET_MIPS
@@ -300,8 +290,6 @@ typedef abi_int target_pid_t;#define elf_check_abi (x) (!((x) & EF_MIPS_ABI2))#endif -#define ELF_EXEC_PAGESIZE 4096 -#endif /* TARGET_MIPS */ #ifdef TARGET_MICROBLAZE
@@ -311,8 +299,6 @@ typedef abi_int target_pid_t;#define ELF_CLASS ELFCLASS32#define ELF_ARCH EM_MICROBLAZE -#define ELF_EXEC_PAGESIZE 4096 -#endif /* TARGET_MICROBLAZE */ #ifdef TARGET_OPENRISC
@@ -321,8 +307,6 @@ typedef abi_int target_pid_t;#define ELF_CLASS ELFCLASS32#define ELF_DATA ELFDATA2MSB -#define ELF_EXEC_PAGESIZE 8192 -#endif /* TARGET_OPENRISC */ #ifdef TARGET_SH4
@@ -330,8 +314,6 @@ typedef abi_int target_pid_t;#define ELF_CLASS ELFCLASS32#define ELF_ARCH EM_SH -#define ELF_EXEC_PAGESIZE 4096 -#endif #ifdef TARGET_M68K
@@ -339,8 +321,6 @@ typedef abi_int target_pid_t;#define ELF_CLASS ELFCLASS32#define ELF_ARCH EM_68K -#define ELF_EXEC_PAGESIZE 8192 -#endif #ifdef TARGET_ALPHA
@@ -348,8 +328,6 @@ typedef abi_int target_pid_t;#define ELF_CLASS ELFCLASS64#define ELF_ARCH EM_ALPHA -#define ELF_EXEC_PAGESIZE 8192 -#endif /* TARGET_ALPHA */ #ifdef TARGET_S390X
@@ -358,8 +336,6 @@ typedef abi_int target_pid_t;#define ELF_DATA ELFDATA2MSB#define ELF_ARCH EM_S390 -#define ELF_EXEC_PAGESIZE 4096 -#define VDSO_HEADER "vdso.c.inc"#endif /* TARGET_S390X */
@@ -376,8 +352,6 @@ typedef abi_int target_pid_t;#define VDSO_HEADER "vdso-64.c.inc"#endif -#define ELF_EXEC_PAGESIZE 4096 -#endif /* TARGET_RISCV */ #ifdef TARGET_HPPA
@@ -396,8 +370,6 @@ typedef abi_int target_pid_t;#define ELF_CLASS ELFCLASS32#define ELF_ARCH EM_XTENSA -#define ELF_EXEC_PAGESIZE 4096 -#endif /* TARGET_XTENSA */ #ifdef TARGET_HEXAGON
@@ -2677,7 +2649,7 @@ static int wmr_fill_region_phdr(void *opaque, vaddr start, phdr->p_flags = (flags &PAGE_READ ?PF_R :0 ) | (flags &PAGE_WRITE_ORG ?PF_W :0 ) | (flags &PAGE_EXEC ?PF_X :0 ); - phdr->p_align =ELF_EXEC_PAGESIZE ; + phdr->p_align =TARGET_PAGE_SIZE ;bswap_phdr (phdr,1 ); d->phdr = phdr +1 ;
@@ -2785,7 +2757,7 @@ static int elf_core_dump(int signr, const CPUArchState *env) offset +=size_note ("CORE" ,sizeof (struct target_elf_prpsinfo )); offset +=size_note ("CORE" ,sizeof (struct target_elf_prstatus )) * cpus; note_size = offset - note_offset; - data_offset =ROUND_UP (offset,ELF_EXEC_PAGESIZE ); + data_offset =TARGET_PAGE_ALIGN (offset);/* Do not dump if the corefile size exceeds the limit. */ if (dumpsize.rlim_cur != RLIM_INFINITY
Signature · 1 line
2.43.0
PATCH v2 68/95 linux-user: Remove redundant ELF_DATA definitons
In reply to Richard HendersonWe already provide ELF_DATA based on TARGET_BIG_ENDIAN. Remove the extra definitions from openrisc and s390x.
--- linux-user/elfload.c | 2 -- 1 file changed, 2 deletions(-)
linux-user/elfload.c +0 -2
@@ -305,7 +305,6 @@ typedef abi_int target_pid_t;#define ELF_ARCH EM_OPENRISC#define ELF_CLASS ELFCLASS32 -#define ELF_DATA ELFDATA2MSB#endif /* TARGET_OPENRISC */
@@ -333,7 +332,6 @@ typedef abi_int target_pid_t;#ifdef TARGET_S390X #define ELF_CLASS ELFCLASS64 -#define ELF_DATA ELFDATA2MSB#define ELF_ARCH EM_S390#define VDSO_HEADER "vdso.c.inc"
Signature · 1 line
2.43.0
Re: [PATCH v2 68/95] linux-user: Remove redundant ELF_DATA definitons
Quoted 6 lines · Richard Henderson
We already provide
ELF_DATAbased onTARGET_BIG_ENDIAN. Remove the extra definitions from openrisc and s390x.Signed-off-by Richard Henderson <[email protected]>---
thanks
-- PMM
PATCH v2 69/95 linux-user: Move elf parameters to {i386, x86_64}/target_elf.h
In reply to Richard Henderson--- linux-user/i386/target_elf.h | 22 +++++++++++++++++++ linux-user/x86_64/target_elf.h | 4 ++++ linux-user/elfload.c | 39 ---------------------------------- 3 files changed, 26 insertions(+), 39 deletions(-)
linux-user/i386/target_elf.h +22 -0
@@ -8,6 +8,11 @@#ifndef I386_TARGET_ELF_H #define I386_TARGET_ELF_H +#define ELF_CLASS ELFCLASS32 +#define ELF_ARCH EM_386 +#define EXSTACK_DEFAULT true +#define VDSO_HEADER "vdso.c.inc" +#define HAVE_ELF_HWCAP 1#define HAVE_ELF_PLATFORM 1
@@ -19,4 +24,21 @@*/ #define ELF_NREG 17 +/* +* This is used to ensure we don't load something for the wrong architecture. +*/ +#define elf_check_arch (x) ((x) == EM_386 || (x) == EM_486) + +/* +* i386 is the only target which supplies AT_SYSINFO for the vdso. +* All others only supply AT_SYSINFO_EHDR. +*/ +#define DLINFO_ARCH_ITEMS (vdso_info != NULL) +#define ARCH_DLINFO \ + do { \ + if (vdso_info) { \ + NEW_AUX_ENT(AT_SYSINFO, vdso_info->entry); \ + } \ + } while (0) +#endif
linux-user/x86_64/target_elf.h +4 -0
@@ -8,6 +8,10 @@#ifndef X86_64_TARGET_ELF_H #define X86_64_TARGET_ELF_H +#define ELF_CLASS ELFCLASS64 +#define ELF_ARCH EM_X86_64 +#define VDSO_HEADER "vdso.c.inc" +#define HAVE_ELF_HWCAP 1#define HAVE_ELF_PLATFORM 1#define HAVE_GUEST_COMMPAGE 1
linux-user/elfload.c +0 -39
@@ -130,45 +130,6 @@ typedef abi_uint target_gid_t;#endif typedef abi_int target_pid_t ; -#ifdef TARGET_I386 - -#ifdef TARGET_X86_64 -#define ELF_CLASS ELFCLASS64 -#define ELF_ARCH EM_X86_64 - -#else - -/* -* This is used to ensure we don't load something for the wrong architecture. -*/ -#define elf_check_arch (x) ( ((x) == EM_386) || ((x) == EM_486) ) - -/* -* These are used to set parameters in the core dumps. -*/ -#define ELF_CLASS ELFCLASS32 -#define ELF_ARCH EM_386 - -#define EXSTACK_DEFAULT true - -/* -* i386 is the only target which supplies AT_SYSINFO for the vdso. -* All others only supply AT_SYSINFO_EHDR. -*/ -#define DLINFO_ARCH_ITEMS (vdso_info != NULL) -#define ARCH_DLINFO \ - do { \ - if (vdso_info) { \ - NEW_AUX_ENT(AT_SYSINFO, vdso_info->entry); \ - } \ - } while (0) - -#endif /* TARGET_X86_64 */ - -#define VDSO_HEADER "vdso.c.inc" - -#endif /* TARGET_I386 */ -#ifdef TARGET_ARM #ifndef TARGET_AARCH64
Signature · 1 line
2.43.0
PATCH v2 70/95 linux-user: Move elf parameters to {arm, aarch64}/target_elf.h
In reply to Richard Henderson--- linux-user/aarch64/target_elf.h | 9 +++++++++ linux-user/arm/target_elf.h | 4 ++++ linux-user/elfload.c | 25 ------------------------- 3 files changed, 13 insertions(+), 25 deletions(-)
linux-user/aarch64/target_elf.h +9 -0
@@ -8,10 +8,19 @@#ifndef AARCH64_TARGET_ELF_H #define AARCH64_TARGET_ELF_H +#define ELF_ARCH EM_AARCH64 +#define ELF_CLASS ELFCLASS64 +#define HAVE_ELF_HWCAP 1#define HAVE_ELF_HWCAP2 1#define HAVE_ELF_PLATFORM 1#define ELF_NREG 34 +#if TARGET_BIG_ENDIAN +# define VDSO_HEADER "vdso-be.c.inc" +#else +# define VDSO_HEADER "vdso-le.c.inc" +#endif +#endif
linux-user/arm/target_elf.h +4 -0
@@ -8,6 +8,10 @@#ifndef ARM_TARGET_ELF_H #define ARM_TARGET_ELF_H +#define ELF_ARCH EM_ARM +#define ELF_CLASS ELFCLASS32 +#define EXSTACK_DEFAULT true +#define HAVE_ELF_HWCAP 1#define HAVE_ELF_HWCAP2 1#define HAVE_ELF_PLATFORM 1
linux-user/elfload.c +0 -25
@@ -130,31 +130,6 @@ typedef abi_uint target_gid_t;#endif typedef abi_int target_pid_t ; -#ifdef TARGET_ARM - -#ifndef TARGET_AARCH64 -/* 32 bit ARM definitions */ - -#define ELF_ARCH EM_ARM -#define ELF_CLASS ELFCLASS32 -#define EXSTACK_DEFAULT true - -#else -/* 64 bit ARM definitions */ - -#define ELF_ARCH EM_AARCH64 -#define ELF_CLASS ELFCLASS64 - -#if TARGET_BIG_ENDIAN -# define VDSO_HEADER "vdso-be.c.inc" -#else -# define VDSO_HEADER "vdso-le.c.inc" -#endif - -#endif /* not TARGET_AARCH64 */ - -#endif /* TARGET_ARM */ -#ifdef TARGET_SPARC #ifndef TARGET_SPARC64
Signature · 1 line
2.43.0
PATCH v2 71/95 linux-user: Move elf parameters to sparc/target_elf.h
In reply to Richard Henderson--- linux-user/sparc/target_elf.h | 11 +++++++++++ linux-user/elfload.c | 15 --------------- 2 files changed, 11 insertions(+), 15 deletions(-)
linux-user/sparc/target_elf.h +11 -0
@@ -8,6 +8,17 @@#ifndef SPARC_TARGET_ELF_H #define SPARC_TARGET_ELF_H +#ifndef TARGET_SPARC64 +# define ELF_CLASS ELFCLASS32 +# define ELF_ARCH EM_SPARC +#elif defined(TARGET_ABI32 ) +# define ELF_CLASS ELFCLASS32 +# define elf_check_arch (x) ((x) == EM_SPARC32PLUS || (x) == EM_SPARC) +#else +# define ELF_CLASS ELFCLASS64 +# define ELF_ARCH EM_SPARCV9 +#endif +#define HAVE_ELF_HWCAP 1#endif
linux-user/elfload.c +0 -15
@@ -130,21 +130,6 @@ typedef abi_uint target_gid_t;#endif typedef abi_int target_pid_t ; -#ifdef TARGET_SPARC - -#ifndef TARGET_SPARC64 -# define ELF_CLASS ELFCLASS32 -# define ELF_ARCH EM_SPARC -#elif defined(TARGET_ABI32 ) -# define ELF_CLASS ELFCLASS32 -# define elf_check_arch (x) ((x) == EM_SPARC32PLUS || (x) == EM_SPARC) -#else -# define ELF_CLASS ELFCLASS64 -# define ELF_ARCH EM_SPARCV9 -#endif - -#endif /* TARGET_SPARC */ -#ifdef TARGET_PPC #define ELF_MACHINE PPC_ELF_MACHINE
Signature · 1 line
2.43.0
PATCH v2 72/95 linux-user: Move elf parameters to ppc/target_elf.h
In reply to Richard Henderson--- linux-user/ppc/target_elf.h | 43 ++++++++++++++++++++++++++++++ linux-user/elfload.c | 53 ------------------------------------- 2 files changed, 43 insertions(+), 53 deletions(-)
linux-user/ppc/target_elf.h +43 -0
@@ -8,10 +8,53 @@#ifndef PPC_TARGET_ELF_H #define PPC_TARGET_ELF_H +#define ELF_MACHINE PPC_ELF_MACHINE + +#ifdef TARGET_PPC64 +# define elf_check_arch (x) ((x) == EM_PPC64) +# define ELF_CLASS ELFCLASS64 +#else +# define ELF_CLASS ELFCLASS32 +# define EXSTACK_DEFAULT true +#endif +#define ELF_ARCH EM_PPC +#define HAVE_ELF_HWCAP 1#define HAVE_ELF_HWCAP2 1/* See linux kernel: arch/powerpc/include/asm/elf.h. */ #define ELF_NREG 48 +#ifndef TARGET_PPC64 +# define VDSO_HEADER "vdso-32.c.inc" +#elif TARGET_BIG_ENDIAN +# define VDSO_HEADER "vdso-64.c.inc" +#else +# define VDSO_HEADER "vdso-64le.c.inc" +#endif + +/* +* The requirements here are: +* - keep the final alignment of sp (sp & 0xf) +* - make sure the 32-bit value at the first 16 byte aligned position of +* AUXV is greater than 16 for glibc compatibility. +* AT_IGNOREPPC is used for that. +* - for compatibility with glibc ARCH_DLINFO must always be defined on PPC, +* even if DLINFO_ARCH_ITEMS goes to zero or is undefined. +*/ +#define DLINFO_ARCH_ITEMS 5 +#define ARCH_DLINFO \ + do { \ + PowerPCCPU *cpu = POWERPC_CPU(thread_cpu); \ +/* \ +* Handle glibc compatibility: these magic entries must \ +* be at the lowest addresses in the final auxv. \ +*/ \ +NEW_AUX_ENT (AT_IGNOREPPC ,AT_IGNOREPPC ); \ +NEW_AUX_ENT (AT_IGNOREPPC ,AT_IGNOREPPC ); \ +NEW_AUX_ENT (AT_DCACHEBSIZE , cpu->env.dcache_line_size); \ +NEW_AUX_ENT (AT_ICACHEBSIZE , cpu->env.icache_line_size); \ +NEW_AUX_ENT (AT_UCACHEBSIZE ,0 ); \ + } while (0) +#endif
linux-user/elfload.c +0 -53
59 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v2 73/95 linux-user: Move elf parameters to loongarch64/target_elf.h
In reply to Richard Henderson--- linux-user/loongarch64/target_elf.h | 6 ++++++ linux-user/elfload.c | 12 ------------ 2 files changed, 6 insertions(+), 12 deletions(-)
linux-user/loongarch64/target_elf.h +6 -0
@@ -6,6 +6,12 @@#ifndef LOONGARCH_TARGET_ELF_H #define LOONGARCH_TARGET_ELF_H +#define ELF_CLASS ELFCLASS64 +#define ELF_ARCH EM_LOONGARCH +#define EXSTACK_DEFAULT true +#define elf_check_arch (x) ((x) == EM_LOONGARCH) +#define VDSO_HEADER "vdso.c.inc" +#define HAVE_ELF_HWCAP 1#define HAVE_ELF_PLATFORM 1
linux-user/elfload.c +0 -12
@@ -130,18 +130,6 @@ typedef abi_uint target_gid_t;#endif typedef abi_int target_pid_t ; -#ifdef TARGET_LOONGARCH64 - -#define ELF_CLASS ELFCLASS64 -#define ELF_ARCH EM_LOONGARCH -#define EXSTACK_DEFAULT true - -#define elf_check_arch (x) ((x) == EM_LOONGARCH) - -#define VDSO_HEADER "vdso.c.inc" - -#endif /* TARGET_LOONGARCH64 */ -#ifdef TARGET_MIPS #ifdef TARGET_MIPS64
Signature · 1 line
2.43.0
PATCH v2 74/95 linux-user: Move elf parameters to {mips, mips64}/target_elf.h
In reply to Richard Henderson--- linux-user/mips/target_elf.h | 4 ++++ linux-user/mips64/target_elf.h | 10 ++++++++++ linux-user/elfload.c | 18 ------------------ 3 files changed, 14 insertions(+), 18 deletions(-)
linux-user/mips/target_elf.h +4 -0
@@ -8,6 +8,10 @@#ifndef MIPS_TARGET_ELF_H #define MIPS_TARGET_ELF_H +#define ELF_CLASS ELFCLASS32 +#define ELF_ARCH EM_MIPS +#define EXSTACK_DEFAULT true +#define HAVE_ELF_HWCAP 1#define HAVE_ELF_BASE_PLATFORM 1
linux-user/mips64/target_elf.h +10 -0
@@ -8,6 +8,16 @@#ifndef MIPS64_TARGET_ELF_H #define MIPS64_TARGET_ELF_H +#define ELF_CLASS ELFCLASS64 +#define ELF_ARCH EM_MIPS +#define EXSTACK_DEFAULT true + +#ifdef TARGET_ABI_MIPSN32 +#define elf_check_abi (x) ((x) & EF_MIPS_ABI2) +#else +#define elf_check_abi (x) (!((x) & EF_MIPS_ABI2)) +#endif +#define HAVE_ELF_HWCAP 1#define HAVE_ELF_BASE_PLATFORM 1
linux-user/elfload.c +0 -18
@@ -130,24 +130,6 @@ typedef abi_uint target_gid_t;#endif typedef abi_int target_pid_t ; -#ifdef TARGET_MIPS - -#ifdef TARGET_MIPS64 -#define ELF_CLASS ELFCLASS64 -#else -#define ELF_CLASS ELFCLASS32 -#endif -#define ELF_ARCH EM_MIPS -#define EXSTACK_DEFAULT true - -#ifdef TARGET_ABI_MIPSN32 -#define elf_check_abi (x) ((x) & EF_MIPS_ABI2) -#else -#define elf_check_abi (x) (!((x) & EF_MIPS_ABI2)) -#endif - -#endif /* TARGET_MIPS */ -#ifdef TARGET_MICROBLAZE #define elf_check_arch (x) ( (x) == EM_MICROBLAZE || (x) == EM_MICROBLAZE_OLD)
Signature · 1 line
2.43.0
PATCH v2 75/95 linux-user: Move elf parameters to microblaze/target_elf.h
In reply to Richard Henderson--- linux-user/microblaze/target_elf.h | 5 +++++ linux-user/elfload.c | 9 --------- 2 files changed, 5 insertions(+), 9 deletions(-)
linux-user/microblaze/target_elf.h +5 -0
@@ -8,6 +8,11 @@#ifndef MICROBLAZE_TARGET_ELF_H #define MICROBLAZE_TARGET_ELF_H +#define ELF_CLASS ELFCLASS32 +#define ELF_ARCH EM_MICROBLAZE +#define ELF_NREG 38 +#define elf_check_arch (x) ((x) == EM_MICROBLAZE || (x) == EM_MICROBLAZE_OLD) +#endif
linux-user/elfload.c +0 -9
@@ -130,15 +130,6 @@ typedef abi_uint target_gid_t;#endif typedef abi_int target_pid_t ; -#ifdef TARGET_MICROBLAZE - -#define elf_check_arch (x) ( (x) == EM_MICROBLAZE || (x) == EM_MICROBLAZE_OLD) - -#define ELF_CLASS ELFCLASS32 -#define ELF_ARCH EM_MICROBLAZE - -#endif /* TARGET_MICROBLAZE */ -#ifdef TARGET_OPENRISC #define ELF_ARCH EM_OPENRISC
Signature · 1 line
2.43.0
PATCH v2 76/95 linux-user: Move elf parameters to openrisc/target_elf.h
In reply to Richard Henderson--- linux-user/openrisc/target_elf.h | 3 +++ linux-user/elfload.c | 7 ------- 2 files changed, 3 insertions(+), 7 deletions(-)
linux-user/openrisc/target_elf.h +3 -0
@@ -8,6 +8,9 @@#ifndef OPENRISC_TARGET_ELF_H #define OPENRISC_TARGET_ELF_H +#define ELF_ARCH EM_OPENRISC +#define ELF_CLASS ELFCLASS32 +/* See linux kernel arch/openrisc/include/asm/elf.h. */ #define ELF_NREG 34/* gprs and pc, sr */
linux-user/elfload.c +0 -7
@@ -130,13 +130,6 @@ typedef abi_uint target_gid_t;#endif typedef abi_int target_pid_t ; -#ifdef TARGET_OPENRISC - -#define ELF_ARCH EM_OPENRISC -#define ELF_CLASS ELFCLASS32 - -#endif /* TARGET_OPENRISC */ -#ifdef TARGET_SH4 #define ELF_CLASS ELFCLASS32
Signature · 1 line
2.43.0
PATCH v2 77/95 linux-user: Move elf parameters to sh4/target_elf.h
In reply to Richard Henderson--- linux-user/sh4/target_elf.h | 3 +++ linux-user/elfload.c | 7 ------- 2 files changed, 3 insertions(+), 7 deletions(-)
linux-user/sh4/target_elf.h +3 -0
@@ -8,6 +8,9 @@#ifndef SH4_TARGET_ELF_H #define SH4_TARGET_ELF_H +#define ELF_CLASS ELFCLASS32 +#define ELF_ARCH EM_SH +#define HAVE_ELF_HWCAP 1/* See linux kernel: arch/sh/include/asm/elf.h. */
linux-user/elfload.c +0 -7
@@ -130,13 +130,6 @@ typedef abi_uint target_gid_t;#endif typedef abi_int target_pid_t ; -#ifdef TARGET_SH4 - -#define ELF_CLASS ELFCLASS32 -#define ELF_ARCH EM_SH - -#endif -#ifdef TARGET_M68K #define ELF_CLASS ELFCLASS32
Signature · 1 line
2.43.0
PATCH v2 78/95 linux-user: Move elf parameters to m68k/target_elf.h
In reply to Richard Henderson--- linux-user/m68k/target_elf.h | 3 +++ linux-user/elfload.c | 7 ------- 2 files changed, 3 insertions(+), 7 deletions(-)
linux-user/m68k/target_elf.h +3 -0
@@ -8,6 +8,9 @@#ifndef M68K_TARGET_ELF_H #define M68K_TARGET_ELF_H +#define ELF_CLASS ELFCLASS32 +#define ELF_ARCH EM_68K +/* See linux kernel: arch/m68k/include/asm/elf.h. */ #define ELF_NREG 20
linux-user/elfload.c +0 -7
@@ -130,13 +130,6 @@ typedef abi_uint target_gid_t;#endif typedef abi_int target_pid_t ; -#ifdef TARGET_M68K - -#define ELF_CLASS ELFCLASS32 -#define ELF_ARCH EM_68K - -#endif -#ifdef TARGET_ALPHA #define ELF_CLASS ELFCLASS64
Signature · 1 line
2.43.0
PATCH v2 79/95 linux-user: Move elf parameters to alpha/target_elf.h
In reply to Richard Henderson--- linux-user/alpha/target_elf.h | 3 +++ linux-user/elfload.c | 7 ------- 2 files changed, 3 insertions(+), 7 deletions(-)
linux-user/alpha/target_elf.h +3 -0
@@ -8,4 +8,7 @@#ifndef ALPHA_TARGET_ELF_H #define ALPHA_TARGET_ELF_H +#define ELF_CLASS ELFCLASS64 +#define ELF_ARCH EM_ALPHA +#endif
linux-user/elfload.c +0 -7
@@ -130,13 +130,6 @@ typedef abi_uint target_gid_t;#endif typedef abi_int target_pid_t ; -#ifdef TARGET_ALPHA - -#define ELF_CLASS ELFCLASS64 -#define ELF_ARCH EM_ALPHA - -#endif /* TARGET_ALPHA */ -#ifdef TARGET_S390X #define ELF_CLASS ELFCLASS64
Signature · 1 line
2.43.0
PATCH v2 80/95 linux-user: Move elf parameters to s390x/target_elf.h
In reply to Richard Henderson--- linux-user/s390x/target_elf.h | 4 ++++ linux-user/elfload.c | 9 --------- 2 files changed, 4 insertions(+), 9 deletions(-)
linux-user/s390x/target_elf.h +4 -0
@@ -8,6 +8,10 @@#ifndef S390X_TARGET_ELF_H #define S390X_TARGET_ELF_H +#define ELF_CLASS ELFCLASS64 +#define ELF_ARCH EM_S390 +#define VDSO_HEADER "vdso.c.inc" +#define HAVE_ELF_HWCAP 1/* See linux kernel: arch/s390/include/uapi/asm/ptrace.h (s390_regs). */
linux-user/elfload.c +0 -9
@@ -130,15 +130,6 @@ typedef abi_uint target_gid_t;#endif typedef abi_int target_pid_t ; -#ifdef TARGET_S390X - -#define ELF_CLASS ELFCLASS64 -#define ELF_ARCH EM_S390 - -#define VDSO_HEADER "vdso.c.inc" - -#endif /* TARGET_S390X */ -#ifdef TARGET_RISCV #define ELF_ARCH EM_RISCV
Signature · 1 line
2.43.0
PATCH v2 81/95 linux-user: Move elf parameters to riscv/target_elf.h
In reply to Richard Henderson--- linux-user/riscv/target_elf.h | 10 ++++++++++ linux-user/elfload.c | 14 -------------- 2 files changed, 10 insertions(+), 14 deletions(-)
linux-user/riscv/target_elf.h +10 -0
@@ -8,6 +8,16 @@#ifndef RISCV_TARGET_ELF_H #define RISCV_TARGET_ELF_H +#define ELF_ARCH EM_RISCV + +#ifdef TARGET_RISCV32 +#define ELF_CLASS ELFCLASS32 +#define VDSO_HEADER "vdso-32.c.inc" +#else +#define ELF_CLASS ELFCLASS64 +#define VDSO_HEADER "vdso-64.c.inc" +#endif +#define HAVE_ELF_HWCAP 1#endif
linux-user/elfload.c +0 -14
@@ -130,20 +130,6 @@ typedef abi_uint target_gid_t;#endif typedef abi_int target_pid_t ; -#ifdef TARGET_RISCV - -#define ELF_ARCH EM_RISCV - -#ifdef TARGET_RISCV32 -#define ELF_CLASS ELFCLASS32 -#define VDSO_HEADER "vdso-32.c.inc" -#else -#define ELF_CLASS ELFCLASS64 -#define VDSO_HEADER "vdso-64.c.inc" -#endif - -#endif /* TARGET_RISCV */ -#ifdef TARGET_HPPA #define ELF_CLASS ELFCLASS32
Signature · 1 line
2.43.0
PATCH v2 82/95 linux-user: Move elf parameters to hppa/target_elf.h
In reply to Richard Henderson--- linux-user/hppa/target_elf.h | 6 ++++++ linux-user/elfload.c | 11 ----------- 2 files changed, 6 insertions(+), 11 deletions(-)
linux-user/hppa/target_elf.h +6 -0
@@ -8,8 +8,14 @@#ifndef HPPA_TARGET_ELF_H #define HPPA_TARGET_ELF_H +#define ELF_CLASS ELFCLASS32 +#define ELF_ARCH EM_PARISC +#define HAVE_ELF_PLATFORM 1#define LO_COMMPAGE 0 +#define STACK_GROWS_DOWN 0 +#define STACK_ALIGNMENT 64 +#define VDSO_HEADER "vdso.c.inc"#endif
linux-user/elfload.c +0 -11
@@ -130,17 +130,6 @@ typedef abi_uint target_gid_t;#endif typedef abi_int target_pid_t ; -#ifdef TARGET_HPPA - -#define ELF_CLASS ELFCLASS32 -#define ELF_ARCH EM_PARISC -#define STACK_GROWS_DOWN 0 -#define STACK_ALIGNMENT 64 - -#define VDSO_HEADER "vdso.c.inc" - -#endif /* TARGET_HPPA */ -#ifdef TARGET_XTENSA #define ELF_CLASS ELFCLASS32
Signature · 1 line
2.43.0
PATCH v2 83/95 linux-user: Move elf parameters to xtensa/target_elf.h
In reply to Richard Henderson--- linux-user/xtensa/target_elf.h | 3 +++ linux-user/elfload.c | 7 ------- 2 files changed, 3 insertions(+), 7 deletions(-)
linux-user/xtensa/target_elf.h +3 -0
@@ -8,6 +8,9 @@#ifndef XTENSA_TARGET_ELF_H #define XTENSA_TARGET_ELF_H +#define ELF_CLASS ELFCLASS32 +#define ELF_ARCH EM_XTENSA +/* See linux kernel: arch/xtensa/include/asm/elf.h. */ #define ELF_NREG 128
linux-user/elfload.c +0 -7
@@ -130,13 +130,6 @@ typedef abi_uint target_gid_t;#endif typedef abi_int target_pid_t ; -#ifdef TARGET_XTENSA - -#define ELF_CLASS ELFCLASS32 -#define ELF_ARCH EM_XTENSA - -#endif /* TARGET_XTENSA */ -#ifdef TARGET_HEXAGON #define ELF_CLASS ELFCLASS32
Signature · 1 line
2.43.0
PATCH v2 84/95 linux-user: Move elf parameters to hexagon/target_elf.h
In reply to Richard Henderson--- linux-user/hexagon/target_elf.h | 3 +++ linux-user/elfload.c | 7 ------- 2 files changed, 3 insertions(+), 7 deletions(-)
linux-user/hexagon/target_elf.h +3 -0
@@ -18,4 +18,7 @@#ifndef HEXAGON_TARGET_ELF_H #define HEXAGON_TARGET_ELF_H +#define ELF_CLASS ELFCLASS32 +#define ELF_ARCH EM_HEXAGON +#endif
linux-user/elfload.c +0 -7
@@ -130,13 +130,6 @@ typedef abi_uint target_gid_t;#endif typedef abi_int target_pid_t ; -#ifdef TARGET_HEXAGON - -#define ELF_CLASS ELFCLASS32 -#define ELF_ARCH EM_HEXAGON - -#endif /* TARGET_HEXAGON */ -#ifndef ELF_MACHINE #define ELF_MACHINE ELF_ARCH#endif
Signature · 1 line
2.43.0
PATCH v2 85/95 linux-user: Standardize on ELF_MACHINE not ELF_ARCH
In reply to Richard HendersonPowerPC was the one outlier that defined both ELF_ARCH and ELF_MACHINE; ELF_ARCH was defined incorrectly, necessitating the definition of elf_check_arch.
However, the elf file header field in question is called e_machine, so ELF_MACHINE is in fact the better name.
Mechanically change most target/target_elf.h files, then adjust ppc/target_elf.h manually.
Do not provide a default for ELF_MACHINE.
--- linux-user/aarch64/target_elf.h | 2 +- linux-user/alpha/target_elf.h | 2 +- linux-user/arm/target_elf.h | 2 +- linux-user/hexagon/target_elf.h | 2 +- linux-user/hppa/target_elf.h | 2 +- linux-user/i386/target_elf.h | 2 +- linux-user/loongarch64/target_elf.h | 2 +- linux-user/m68k/target_elf.h | 2 +- linux-user/microblaze/target_elf.h | 2 +- linux-user/mips/target_elf.h | 2 +- linux-user/mips64/target_elf.h | 2 +- linux-user/openrisc/target_elf.h | 2 +- linux-user/ppc/target_elf.h | 2 -- linux-user/riscv/target_elf.h | 2 +- linux-user/s390x/target_elf.h | 2 +- linux-user/sh4/target_elf.h | 2 +- linux-user/sparc/target_elf.h | 4 ++-- linux-user/x86_64/target_elf.h | 2 +- linux-user/xtensa/target_elf.h | 2 +- linux-user/elfload.c | 6 +----- 20 files changed, 20 insertions(+), 26 deletions(-)
linux-user/aarch64/target_elf.h +1 -1
@@ -8,7 +8,7 @@#ifndef AARCH64_TARGET_ELF_H #define AARCH64_TARGET_ELF_H -#define ELF_ARCH EM_AARCH64 +#define ELF_MACHINE EM_AARCH64#define ELF_CLASS ELFCLASS64#define HAVE_ELF_HWCAP 1
linux-user/alpha/target_elf.h +1 -1
@@ -9,6 +9,6 @@#define ALPHA_TARGET_ELF_H #define ELF_CLASS ELFCLASS64 -#define ELF_ARCH EM_ALPHA +#define ELF_MACHINE EM_ALPHA#endif
linux-user/arm/target_elf.h +1 -1
@@ -8,7 +8,7 @@#ifndef ARM_TARGET_ELF_H #define ARM_TARGET_ELF_H -#define ELF_ARCH EM_ARM +#define ELF_MACHINE EM_ARM#define ELF_CLASS ELFCLASS32#define EXSTACK_DEFAULT true
linux-user/hexagon/target_elf.h +1 -1
@@ -19,6 +19,6 @@#define HEXAGON_TARGET_ELF_H #define ELF_CLASS ELFCLASS32 -#define ELF_ARCH EM_HEXAGON +#define ELF_MACHINE EM_HEXAGON#endif
linux-user/hppa/target_elf.h +1 -1
@@ -9,7 +9,7 @@#define HPPA_TARGET_ELF_H #define ELF_CLASS ELFCLASS32 -#define ELF_ARCH EM_PARISC +#define ELF_MACHINE EM_PARISC#define HAVE_ELF_PLATFORM 1
linux-user/i386/target_elf.h +1 -1
@@ -9,7 +9,7 @@#define I386_TARGET_ELF_H #define ELF_CLASS ELFCLASS32 -#define ELF_ARCH EM_386 +#define ELF_MACHINE EM_386#define EXSTACK_DEFAULT true#define VDSO_HEADER "vdso.c.inc"
linux-user/loongarch64/target_elf.h +1 -1
@@ -7,7 +7,7 @@#define LOONGARCH_TARGET_ELF_H #define ELF_CLASS ELFCLASS64 -#define ELF_ARCH EM_LOONGARCH +#define ELF_MACHINE EM_LOONGARCH#define EXSTACK_DEFAULT true#define elf_check_arch (x) ((x) == EM_LOONGARCH)#define VDSO_HEADER "vdso.c.inc"
linux-user/m68k/target_elf.h +1 -1
@@ -9,7 +9,7 @@#define M68K_TARGET_ELF_H #define ELF_CLASS ELFCLASS32 -#define ELF_ARCH EM_68K +#define ELF_MACHINE EM_68K/* See linux kernel: arch/m68k/include/asm/elf.h. */ #define ELF_NREG 20
linux-user/microblaze/target_elf.h +1 -1
@@ -9,7 +9,7 @@#define MICROBLAZE_TARGET_ELF_H #define ELF_CLASS ELFCLASS32 -#define ELF_ARCH EM_MICROBLAZE +#define ELF_MACHINE EM_MICROBLAZE#define ELF_NREG 38
linux-user/mips/target_elf.h +1 -1
@@ -9,7 +9,7 @@#define MIPS_TARGET_ELF_H #define ELF_CLASS ELFCLASS32 -#define ELF_ARCH EM_MIPS +#define ELF_MACHINE EM_MIPS#define EXSTACK_DEFAULT true#define HAVE_ELF_HWCAP 1
linux-user/mips64/target_elf.h +1 -1
@@ -9,7 +9,7 @@#define MIPS64_TARGET_ELF_H #define ELF_CLASS ELFCLASS64 -#define ELF_ARCH EM_MIPS +#define ELF_MACHINE EM_MIPS#define EXSTACK_DEFAULT true#ifdef TARGET_ABI_MIPSN32
linux-user/openrisc/target_elf.h +1 -1
@@ -8,7 +8,7 @@#ifndef OPENRISC_TARGET_ELF_H #define OPENRISC_TARGET_ELF_H -#define ELF_ARCH EM_OPENRISC +#define ELF_MACHINE EM_OPENRISC#define ELF_CLASS ELFCLASS32/* See linux kernel arch/openrisc/include/asm/elf.h. */
linux-user/ppc/target_elf.h +0 -2
@@ -11,13 +11,11 @@#define ELF_MACHINE PPC_ELF_MACHINE#ifdef TARGET_PPC64 -# define elf_check_arch (x) ((x) == EM_PPC64)# define ELF_CLASS ELFCLASS64#else # define ELF_CLASS ELFCLASS32# define EXSTACK_DEFAULT true#endif -#define ELF_ARCH EM_PPC#define HAVE_ELF_HWCAP 1#define HAVE_ELF_HWCAP2 1
linux-user/riscv/target_elf.h +1 -1
@@ -8,7 +8,7 @@#ifndef RISCV_TARGET_ELF_H #define RISCV_TARGET_ELF_H -#define ELF_ARCH EM_RISCV +#define ELF_MACHINE EM_RISCV#ifdef TARGET_RISCV32 #define ELF_CLASS ELFCLASS32
linux-user/s390x/target_elf.h +1 -1
@@ -9,7 +9,7 @@#define S390X_TARGET_ELF_H #define ELF_CLASS ELFCLASS64 -#define ELF_ARCH EM_S390 +#define ELF_MACHINE EM_S390#define VDSO_HEADER "vdso.c.inc"#define HAVE_ELF_HWCAP 1
linux-user/sh4/target_elf.h +1 -1
@@ -9,7 +9,7 @@#define SH4_TARGET_ELF_H #define ELF_CLASS ELFCLASS32 -#define ELF_ARCH EM_SH +#define ELF_MACHINE EM_SH#define HAVE_ELF_HWCAP 1
linux-user/sparc/target_elf.h +2 -2
@@ -10,13 +10,13 @@#ifndef TARGET_SPARC64 # define ELF_CLASS ELFCLASS32 -# define ELF_ARCH EM_SPARC +# define ELF_MACHINE EM_SPARC#elif defined(TARGET_ABI32 )# define ELF_CLASS ELFCLASS32# define elf_check_arch (x) ((x) == EM_SPARC32PLUS || (x) == EM_SPARC)#else # define ELF_CLASS ELFCLASS64 -# define ELF_ARCH EM_SPARCV9 +# define ELF_MACHINE EM_SPARCV9#endif #define HAVE_ELF_HWCAP 1
linux-user/x86_64/target_elf.h +1 -1
@@ -9,7 +9,7 @@#define X86_64_TARGET_ELF_H #define ELF_CLASS ELFCLASS64 -#define ELF_ARCH EM_X86_64 +#define ELF_MACHINE EM_X86_64#define VDSO_HEADER "vdso.c.inc"#define HAVE_ELF_HWCAP 1
linux-user/xtensa/target_elf.h +1 -1
@@ -9,7 +9,7 @@#define XTENSA_TARGET_ELF_H #define ELF_CLASS ELFCLASS32 -#define ELF_ARCH EM_XTENSA +#define ELF_MACHINE EM_XTENSA/* See linux kernel: arch/xtensa/include/asm/elf.h. */ #define ELF_NREG 128
linux-user/elfload.c +1 -5
@@ -130,12 +130,8 @@ typedef abi_uint target_gid_t;#endif typedef abi_int target_pid_t ; -#ifndef ELF_MACHINE -#define ELF_MACHINE ELF_ARCH -#endif -#ifndef elf_check_arch -#define elf_check_arch (x) ((x) == ELF_ARCH) +#define elf_check_arch (x) ((x) == ELF_MACHINE)#endif #ifndef elf_check_abi
Signature · 1 line
2.43.0
PATCH v2 86/95 linux-user: Rename elf_check_arch
In reply to Richard HendersonRename to elf_check_machine to match ELF_MACHINE. Remove the unnecessary definition for loongarch64.
--- linux-user/i386/target_elf.h | 2 +- linux-user/loongarch64/target_elf.h | 1 - linux-user/microblaze/target_elf.h | 2 +- linux-user/sparc/target_elf.h | 2 +- linux-user/elfload.c | 6 +++--- 5 files changed, 6 insertions(+), 7 deletions(-)
linux-user/i386/target_elf.h +1 -1
@@ -27,7 +27,7 @@/* * This is used to ensure we don't load something for the wrong architecture. */ -#define elf_check_arch (x) ((x) == EM_386 || (x) == EM_486) +#define elf_check_machine (x) ((x) == EM_386 || (x) == EM_486)/* * i386 is the only target which supplies AT_SYSINFO for the vdso.
linux-user/loongarch64/target_elf.h +0 -1
@@ -9,7 +9,6 @@#define ELF_CLASS ELFCLASS64#define ELF_MACHINE EM_LOONGARCH#define EXSTACK_DEFAULT true -#define elf_check_arch (x) ((x) == EM_LOONGARCH)#define VDSO_HEADER "vdso.c.inc"#define HAVE_ELF_HWCAP 1
linux-user/microblaze/target_elf.h +1 -1
@@ -13,6 +13,6 @@#define ELF_NREG 38 -#define elf_check_arch (x) ((x) == EM_MICROBLAZE || (x) == EM_MICROBLAZE_OLD) +#define elf_check_machine (x) ((x) == EM_MICROBLAZE || (x) == EM_MICROBLAZE_OLD)#endif
linux-user/sparc/target_elf.h +1 -1
@@ -13,7 +13,7 @@# define ELF_MACHINE EM_SPARC#elif defined(TARGET_ABI32 )# define ELF_CLASS ELFCLASS32 -# define elf_check_arch (x) ((x) == EM_SPARC32PLUS || (x) == EM_SPARC) +# define elf_check_machine (x) ((x) == EM_SPARC32PLUS || (x) == EM_SPARC)#else # define ELF_CLASS ELFCLASS64# define ELF_MACHINE EM_SPARCV9
linux-user/elfload.c +3 -3
@@ -130,8 +130,8 @@ typedef abi_uint target_gid_t;#endif typedef abi_int target_pid_t ; -#ifndef elf_check_arch -#define elf_check_arch (x) ((x) == ELF_MACHINE) +#ifndef elf_check_machine +#define elf_check_machine (x) ((x) == ELF_MACHINE)#endif #ifndef elf_check_abi
@@ -346,7 +346,7 @@ static bool elf_check_ident(struct elfhdr *ehdr)This has to wait until after bswapping the header. */ static bool elf_check_ehdr (struct elfhdr *ehdr) { -return (elf_check_arch (ehdr->e_machine) +return (elf_check_machine (ehdr->e_machine) &&elf_check_abi (ehdr->e_flags) && ehdr->e_ehsize ==sizeof (struct elfhdr ) && ehdr->e_phentsize == sizeof(struct elf_phdr)
Signature · 1 line
2.43.0
PATCH v2 87/95 linux-user: Remove ELIBBAD from elfload.c
In reply to Richard HendersonThe last use of this fallback was removed in 8e62a71738bc.
--- linux-user/elfload.c | 5 ----- 1 file changed, 5 deletions(-)
linux-user/elfload.c +0 -5
@@ -110,11 +110,6 @@ int info_is_fdpic(struct image_info *info)#define MAP_DENYWRITE 0#endif -/* should probably go in elf.h */ -#ifndef ELIBBAD -#define ELIBBAD 80 -#endif -#if TARGET_BIG_ENDIAN #define ELF_DATA ELFDATA2MSB#else
Signature · 1 line
2.43.0
PATCH v2 88/95 linux-user: Remove MAP_DENYWRITE from elfload.c
In reply to Richard HendersonThe last use of this fallback was removed in bf858897b769.
--- linux-user/elfload.c | 5 ----- 1 file changed, 5 deletions(-)
linux-user/elfload.c +0 -5
@@ -105,11 +105,6 @@ int info_is_fdpic(struct image_info *info)return info->personality ==PER_LINUX_FDPIC ; } -/* this flag is uneffective under linux too, should be deleted */ -#ifndef MAP_DENYWRITE -#define MAP_DENYWRITE 0 -#endif -#if TARGET_BIG_ENDIAN #define ELF_DATA ELFDATA2MSB#else
Signature · 1 line
2.43.0
PATCH v2 89/95 linux-user: Move arch_parse_elf_property to aarch64/elfload.c
In reply to Richard HendersonRename the controlling macro to HAVE_ELF_GNU_PROPERTY to match the other HAVE_* macros.
--- linux-user/aarch64/target_elf.h | 1 + linux-user/loader.h | 5 +++++ linux-user/aarch64/elfload.c | 18 +++++++++++++++ linux-user/elfload.c | 39 +++++++-------------------------- 4 files changed, 32 insertions(+), 31 deletions(-)
linux-user/aarch64/target_elf.h +1 -0
@@ -14,6 +14,7 @@#define HAVE_ELF_HWCAP 1#define HAVE_ELF_HWCAP2 1#define HAVE_ELF_PLATFORM 1 +#define HAVE_ELF_GNU_PROPERTY 1#define ELF_NREG 34
linux-user/loader.h +5 -0
@@ -120,4 +120,9 @@ typedef struct {/* Note that both Elf32_Word and Elf64_Word are uint32_t. */ const VdsoImageInfo *get_vdso_image_info (uint32_t elf_flags); +bool arch_parse_elf_property (uint32_t pr_type,uint32_t pr_datasz, +const uint32_t *data, +struct image_info *info, +Error **errp); +#endif /* LINUX_USER_LOADER_H */
linux-user/aarch64/elfload.c +18 -0
@@ -1,9 +1,11 @@/* SPDX-License-Identifier: GPL-2.0-or-later */ #include "qemu/osdep.h" +#include "qapi/error.h" #include "qemu.h" #include "loader.h" #include "target/arm/cpu-features.h" +#include "elf.h" const char *get_elf_cpu_model (uint32_t eflags)
@@ -348,6 +350,22 @@ const char *get_elf_platform(CPUState *cs)return TARGET_BIG_ENDIAN ?"aarch64_be" :"aarch64" ; } +bool arch_parse_elf_property (uint32_t pr_type,uint32_t pr_datasz, +const uint32_t *data, +struct image_info *info, +Error **errp) +{ +if (pr_type ==GNU_PROPERTY_AARCH64_FEATURE_1_AND ) { +if (pr_datasz !=sizeof (uint32_t )) { +error_setg (errp,"Ill-formed GNU_PROPERTY_AARCH64_FEATURE_1_AND" ); +return false; + } +/* We will extract GNU_PROPERTY_AARCH64_FEATURE_1_BTI later. */ + info->note_flags = *data; + } +return true; +} +void elf_core_copy_regs (target_ulong *regs,const CPUARMState *env) {int i;
linux-user/elfload.c +8 -31
@@ -166,41 +166,18 @@ const char *get_elf_platform(CPUState *cs) { return NULL; }const char *get_elf_base_platform (CPUState *cs) {return NULL ; }#endif -#include "elf.h" - -/* We must delay the following stanzas until after "elf.h". */ -#if defined(TARGET_AARCH64 ) - -static bool arch_parse_elf_property (uint32_t pr_type,uint32_t pr_datasz, -const uint32_t *data, -struct image_info *info, -Error **errp) -{ -if (pr_type ==GNU_PROPERTY_AARCH64_FEATURE_1_AND ) { -if (pr_datasz !=sizeof (uint32_t )) { -error_setg (errp,"Ill-formed GNU_PROPERTY_AARCH64_FEATURE_1_AND" ); -return false; - } -/* We will extract GNU_PROPERTY_AARCH64_FEATURE_1_BTI later. */ - info->note_flags = *data; - } -return true; -} -#define ARCH_USE_GNU_PROPERTY 1 - -#else - -static bool arch_parse_elf_property (uint32_t pr_type,uint32_t pr_datasz, -const uint32_t *data, -struct image_info *info, -Error **errp) +#ifndef HAVE_ELF_GNU_PROPERTY +bool arch_parse_elf_property (uint32_t pr_type,uint32_t pr_datasz, +const uint32_t *data,struct image_info *info, +Error **errp) {g_assert_not_reached (); } -#define ARCH_USE_GNU_PROPERTY 0 - +#define HAVE_ELF_GNU_PROPERTY 0#endif +#include "elf.h" +struct exec {unsigned int a_info;/* Use macros N_MAGIC, etc for access */
@@ -1233,7 +1210,7 @@ static bool parse_elf_properties(const ImageSource *src,uint32_t prev_type;/* Unless the arch requires properties, ignore them. */ -if (!ARCH_USE_GNU_PROPERTY ) { +if (!HAVE_ELF_GNU_PROPERTY ) {return true; }
Signature · 1 line
2.43.0
PATCH v2 90/95 linux-user: Remove a.out declarations from elfload.c
In reply to Richard HendersonThese should have been removed with the rest of the stub a.out support in b9329d4b5321, though they were not in use even then.
--- linux-user/elfload.c | 19 ------------------- 1 file changed, 19 deletions(-)
linux-user/elfload.c +0 -19
@@ -178,25 +178,6 @@ bool arch_parse_elf_property(uint32_t pr_type, uint32_t pr_datasz,#include "elf.h" -struct exec -{ -unsigned int a_info;/* Use macros N_MAGIC, etc for access */ -unsigned int a_text;/* length of text, in bytes */ -unsigned int a_data;/* length of data, in bytes */ -unsigned int a_bss;/* length of uninitialized data area, in bytes */ -unsigned int a_syms;/* length of symbol table data in file, in bytes */ -unsigned int a_entry;/* start address */ -unsigned int a_trsize;/* length of relocation info for text, in bytes */ -unsigned int a_drsize;/* length of relocation info for data, in bytes */ -}; - - -#define N_MAGIC (exec) ((exec).a_info & 0xffff) -#define OMAGIC 0407 -#define NMAGIC 0410 -#define ZMAGIC 0413 -#define QMAGIC 0314 -#define DLINFO_ITEMS 16static inline void memcpy_fromfs (void * to,const void * from,unsigned long n)
Signature · 1 line
2.43.0
PATCH v2 91/95 linux-user/sparc: Move target_pt_regs to signal.c
In reply to Richard HendersonThis structure is part of the sparc signal frame.
--- linux-user/sparc/target_syscall.h | 19 ------------------- linux-user/sparc/signal.c | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 19 deletions(-)
linux-user/sparc/target_syscall.h +0 -19
@@ -1,25 +1,6 @@#ifndef SPARC_TARGET_SYSCALL_H #define SPARC_TARGET_SYSCALL_H -#if defined(TARGET_SPARC64 ) && !defined(TARGET_ABI32 ) -struct target_pt_regs { -abi_ulong u_regs[16 ]; -abi_ulong tstate; -abi_ulong pc; -abi_ulong npc; -uint32_t y; -uint32_t magic; -}; -#else -struct target_pt_regs { -abi_ulong psr; -abi_ulong pc; -abi_ulong npc; -abi_ulong y; -abi_ulong u_regs[16 ]; -}; -#endif -#ifdef TARGET_SPARC64 # define UNAME_MACHINE "sparc64"#else
linux-user/sparc/signal.c +20 -0
@@ -22,6 +22,26 @@#include "signal-common.h" #include "linux-user/trace.h" + +#if defined(TARGET_SPARC64 ) && !defined(TARGET_ABI32 ) +struct target_pt_regs { +abi_ulong u_regs[16 ]; +abi_ulong tstate; +abi_ulong pc; +abi_ulong npc; +uint32_t y; +uint32_t magic; +}; +#else +struct target_pt_regs { +abi_ulong psr; +abi_ulong pc; +abi_ulong npc; +abi_ulong y; +abi_ulong u_regs[16 ]; +}; +#endif +/* A Sparc register window */ struct target_reg_window {abi_ulong locals[8 ];
Signature · 1 line
2.43.0
PATCH v2 92/95 linux-user/microblaze: Move target_pt_regs to signal.c
In reply to Richard HendersonThis structure is part of the microblaze signal frame.
--- linux-user/microblaze/target_syscall.h | 44 -------------------------- linux-user/microblaze/signal.c | 44 ++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 44 deletions(-)
linux-user/microblaze/target_syscall.h +0 -44
@@ -4,50 +4,6 @@#define UNAME_MACHINE "microblaze"#define UNAME_MINIMUM_RELEASE "2.6.32" -/* We use microblaze_reg_t to keep things similar to the kernel sources. */ -typedef uint32_t microblaze_reg_t ; - -struct target_pt_regs { -microblaze_reg_t r0; -microblaze_reg_t r1; -microblaze_reg_t r2; -microblaze_reg_t r3; -microblaze_reg_t r4; -microblaze_reg_t r5; -microblaze_reg_t r6; -microblaze_reg_t r7; -microblaze_reg_t r8; -microblaze_reg_t r9; -microblaze_reg_t r10; -microblaze_reg_t r11; -microblaze_reg_t r12; -microblaze_reg_t r13; -microblaze_reg_t r14; -microblaze_reg_t r15; -microblaze_reg_t r16; -microblaze_reg_t r17; -microblaze_reg_t r18; -microblaze_reg_t r19; -microblaze_reg_t r20; -microblaze_reg_t r21; -microblaze_reg_t r22; -microblaze_reg_t r23; -microblaze_reg_t r24; -microblaze_reg_t r25; -microblaze_reg_t r26; -microblaze_reg_t r27; -microblaze_reg_t r28; -microblaze_reg_t r29; -microblaze_reg_t r30; -microblaze_reg_t r31; -microblaze_reg_t pc; -microblaze_reg_t msr; -microblaze_reg_t ear; -microblaze_reg_t esr; -microblaze_reg_t fsr; -uint32_t kernel_mode; -}; -#define TARGET_CLONE_BACKWARDS #define TARGET_MCL_CURRENT 1#define TARGET_MCL_FUTURE 2
linux-user/microblaze/signal.c +44 -0
50 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v2 93/95 linux-user/openrisc: Move target_pt_regs to signal.c
In reply to Richard HendersonThis structure is part of the openrisc signal frame.
Rename to user_regs_struct, per the kernel's ptrace.h, which allows removal of the explination of the name change from the kernel source.
--- linux-user/openrisc/target_syscall.h | 11 ----------- linux-user/openrisc/signal.c | 9 ++++++++- 2 files changed, 8 insertions(+), 12 deletions(-)
linux-user/openrisc/target_syscall.h +0 -11
@@ -1,17 +1,6 @@#ifndef OPENRISC_TARGET_SYSCALL_H #define OPENRISC_TARGET_SYSCALL_H -/* Note that in linux/arch/openrisc/include/uapi/asm/ptrace.h, -* this is called user_regs_struct. Given that this is what -* is used within struct sigcontext we need this definition. -* However, elfload.c wants this name. -*/ -struct target_pt_regs { -abi_ulong gpr[32 ]; -abi_ulong pc; -abi_ulong sr; -}; -#define UNAME_MACHINE "openrisc"#define UNAME_MINIMUM_RELEASE "2.6.32"
linux-user/openrisc/signal.c +8 -1
@@ -22,8 +22,15 @@#include "signal-common.h" #include "linux-user/trace.h" +/* See linux/arch/openrisc/include/uapi/asm/ptrace.h. */ +struct user_regs_struct { +abi_ulong gpr[32 ]; +abi_ulong pc; +abi_ulong sr; +}; +typedef struct target_sigcontext { -struct target_pt_regs regs; +struct user_regs_struct regs;abi_ulong oldmask; }target_sigcontext ;
Signature · 1 line
2.43.0
Re: [PATCH v2 93/95] linux-user/openrisc: Move target_pt_regs to signal.c
Quoted 5 lines · Richard Henderson
This structure is part of the openrisc signal frame.
Rename to
user_regs_struct, per the kernel'sptrace.h, which allows removal of the explination of the name change from the kernel source.
"explanation"
Quoted 2 lines
Signed-off-by Richard Henderson <[email protected]>
thanks
-- PMM
PATCH v2 94/95 linux-user/s390x: Move target_psw_t to signal.c
In reply to Richard HendersonRemove struct target_pt_regs as unused. Move target_psw_t to signal.c, as it is used there.
--- linux-user/s390x/target_syscall.h | 22 ---------------------- linux-user/s390x/signal.c | 5 +++++ 2 files changed, 5 insertions(+), 22 deletions(-)
linux-user/s390x/target_syscall.h +0 -22
@@ -1,28 +1,6 @@#ifndef S390X_TARGET_SYSCALL_H #define S390X_TARGET_SYSCALL_H -/* this typedef defines how a Program Status Word looks like */ -typedef struct { -abi_ulong mask; -abi_ulong addr; -} __attribute__ ((aligned (8 )))target_psw_t ; - -/* -* The pt_regs struct defines the way the registers are stored on -* the stack during a system call. -*/ - -#define TARGET_NUM_GPRS 16 - -struct target_pt_regs { -abi_ulong args[1 ]; -target_psw_t psw; -abi_ulong gprs[TARGET_NUM_GPRS ]; -abi_ulong orig_gpr2; -unsigned short ilen; -unsigned short trap; -}; -#define UNAME_MACHINE "s390x"#define UNAME_MINIMUM_RELEASE "2.6.32"
linux-user/s390x/signal.c +5 -0
@@ -33,6 +33,11 @@#define _SIGMASK_COPY_SIZE (sizeof(unsigned long)*_SIGCONTEXT_NSIG_WORDS)#define S390_SYSCALL_OPCODE ((uint16_t)0x0a00) +typedef struct { +abi_ulong mask; +abi_ulong addr; +} __attribute__ ((aligned (8 )))target_psw_t ; + typedef struct { target_psw_t psw; abi_ulong gprs[__NUM_GPRS];
Signature · 1 line
2.43.0
PATCH v2 95/95 linux-user: Remove struct target_pt_regs from target_syscall.h
In reply to Richard HendersonThis structure is unused, and would only ever be used for the ptrace syscall, which we will never implement for linux-user.
--- linux-user/aarch64/target_syscall.h | 7 ----- linux-user/alpha/target_syscall.h | 40 ------------------------- linux-user/arm/target_syscall.h | 8 ----- linux-user/hexagon/target_syscall.h | 5 ---- linux-user/hppa/target_syscall.h | 18 ----------- linux-user/i386/target_syscall.h | 18 ----------- linux-user/loongarch64/target_syscall.h | 23 -------------- linux-user/m68k/target_syscall.h | 16 ---------- linux-user/mips/target_syscall.h | 19 ------------ linux-user/mips64/target_syscall.h | 16 ---------- linux-user/ppc/target_syscall.h | 28 ----------------- linux-user/riscv/target_syscall.h | 35 ---------------------- linux-user/sh4/target_syscall.h | 11 ------- linux-user/x86_64/target_syscall.h | 28 ----------------- linux-user/xtensa/target_syscall.h | 35 ---------------------- 15 files changed, 307 deletions(-)
linux-user/aarch64/target_syscall.h +0 -7
@@ -1,13 +1,6 @@#ifndef AARCH64_TARGET_SYSCALL_H #define AARCH64_TARGET_SYSCALL_H -struct target_pt_regs { -uint64_t regs[31 ]; -uint64_t sp; -uint64_t pc; -uint64_t pstate; -}; -#if TARGET_BIG_ENDIAN #define UNAME_MACHINE "aarch64_be"#else
linux-user/alpha/target_syscall.h +0 -40
@@ -1,46 +1,6 @@#ifndef ALPHA_TARGET_SYSCALL_H #define ALPHA_TARGET_SYSCALL_H -/* default linux values for the selectors */ -#define __USER_DS (1) - -struct target_pt_regs { -abi_ulong r0; -abi_ulong r1; -abi_ulong r2; -abi_ulong r3; -abi_ulong r4; -abi_ulong r5; -abi_ulong r6; -abi_ulong r7; -abi_ulong r8; -abi_ulong r19; -abi_ulong r20; -abi_ulong r21; -abi_ulong r22; -abi_ulong r23; -abi_ulong r24; -abi_ulong r25; -abi_ulong r26; -abi_ulong r27; -abi_ulong r28; -abi_ulong hae; -/* JRP - These are the values provided to a0-a2 by PALcode */ -abi_ulong trap_a0; -abi_ulong trap_a1; -abi_ulong trap_a2; -/* These are saved by PAL-code: */ -abi_ulong ps; -abi_ulong pc; -abi_ulong gp; -abi_ulong r16; -abi_ulong r17; -abi_ulong r18; -/* Those is needed by qemu to temporary store the user stack pointer */ -abi_ulong usp; -abi_ulong unique; -}; -#define UNAME_MACHINE "alpha"#define UNAME_MINIMUM_RELEASE "2.6.32"
linux-user/arm/target_syscall.h +0 -8
@@ -1,14 +1,6 @@#ifndef ARM_TARGET_SYSCALL_H #define ARM_TARGET_SYSCALL_H -/* this struct defines the way the registers are stored on the -stack during a system call. */ - -/* uregs[0..15] are r0 to r15; uregs[16] is CPSR; uregs[17] is ORIG_r0 */ -struct target_pt_regs { -abi_long uregs[18 ]; -}; -#define ARM_SYSCALL_BASE 0x900000#define ARM_THUMB_SYSCALL 0
linux-user/hexagon/target_syscall.h +0 -5
@@ -18,11 +18,6 @@#ifndef HEXAGON_TARGET_SYSCALL_H #define HEXAGON_TARGET_SYSCALL_H -struct target_pt_regs { -abi_long sepc; -abi_long sp; -}; -#define UNAME_MACHINE "hexagon"#define UNAME_MINIMUM_RELEASE "4.15.0"
linux-user/hppa/target_syscall.h +0 -18
@@ -1,24 +1,6 @@#ifndef HPPA_TARGET_SYSCALL_H #define HPPA_TARGET_SYSCALL_H -struct target_pt_regs { -target_ulong gr[32 ]; -uint64_t fr[32 ]; -target_ulong sr[8 ]; -target_ulong iasq[2 ]; -target_ulong iaoq[2 ]; -target_ulong cr27; -target_ulong __pad0; -target_ulong orig_r28; -target_ulong ksp; -target_ulong kpc; -target_ulong sar; -target_ulong iir; -target_ulong isr; -target_ulong ior; -target_ulong ipsw; -}; -#define UNAME_MACHINE "parisc"#define UNAME_MINIMUM_RELEASE "2.6.32"#define TARGET_CLONE_BACKWARDS
linux-user/i386/target_syscall.h +0 -18
@@ -5,24 +5,6 @@#define __USER_CS (0x23)#define __USER_DS (0x2B) -struct target_pt_regs { -long ebx; -long ecx; -long edx; -long esi; -long edi; -long ebp; -long eax; -int xds; -int xes; -long orig_eax; -long eip; -int xcs; -long eflags; -long esp; -int xss; -}; -/* ioctls */ #define TARGET_LDT_ENTRIES 8192
linux-user/loongarch64/target_syscall.h +0 -23
@@ -8,29 +8,6 @@#include "qemu/units.h" -/* -* this struct defines the way the registers are stored on the -* stack during a system call. -*/ - -struct target_pt_regs { -/* Saved main processor registers. */ -target_ulong regs[32 ]; - -/* Saved special registers. */ -struct { -target_ulong era; -target_ulong badv; -target_ulong crmd; -target_ulong prmd; -target_ulong euen; -target_ulong ecfg; -target_ulong estat; - } csr; -target_ulong orig_a0; -target_ulong __last[0 ]; -}; -#define UNAME_MACHINE "loongarch64"#define UNAME_MINIMUM_RELEASE "5.19.0"
linux-user/m68k/target_syscall.h +0 -16
@@ -1,22 +1,6 @@#ifndef M68K_TARGET_SYSCALL_H #define M68K_TARGET_SYSCALL_H -/* this struct defines the way the registers are stored on the -stack during a system call. */ - -struct target_pt_regs { -abi_long d1, d2, d3, d4, d5, d6, d7; -abi_long a0, a1, a2, a3, a4, a5, a6; -abi_ulong d0; -abi_ulong usp; -abi_ulong orig_d0; -int16_t stkadj; -uint16_t sr; -abi_ulong pc; -uint16_t fntvex; -uint16_t __fill; -}; -#define UNAME_MACHINE "m68k"#define UNAME_MINIMUM_RELEASE "2.6.32"
linux-user/mips/target_syscall.h +0 -19
@@ -1,25 +1,6 @@#ifndef MIPS_TARGET_SYSCALL_H #define MIPS_TARGET_SYSCALL_H -/* this struct defines the way the registers are stored on the -stack during a system call. */ - -struct target_pt_regs { -/* Pad bytes for argument save space on the stack. */ -abi_ulong pad0[6 ]; - -/* Saved main processor registers. */ -abi_ulong regs[32 ]; - -/* Saved special registers. */ -abi_ulong cp0_status; -abi_ulong lo; -abi_ulong hi; -abi_ulong cp0_badvaddr; -abi_ulong cp0_cause; -abi_ulong cp0_epc; -}; -#define UNAME_MACHINE "mips"#define UNAME_MINIMUM_RELEASE "2.6.32"
linux-user/mips64/target_syscall.h +0 -16
@@ -1,22 +1,6 @@#ifndef MIPS64_TARGET_SYSCALL_H #define MIPS64_TARGET_SYSCALL_H -/* this struct defines the way the registers are stored on the -stack during a system call. */ - -struct target_pt_regs { -/* Saved main processor registers. */ -target_ulong regs[32 ]; - -/* Saved special registers. */ -target_ulong cp0_status; -target_ulong lo; -target_ulong hi; -target_ulong cp0_badvaddr; -target_ulong cp0_cause; -target_ulong cp0_epc; -}; -#define UNAME_MACHINE "mips64"#define UNAME_MINIMUM_RELEASE "2.6.32"
linux-user/ppc/target_syscall.h +0 -28
@@ -20,34 +20,6 @@ #ifndef PPC_TARGET_SYSCALL_H #define PPC_TARGET_SYSCALL_H -/* XXX: ABSOLUTELY BUGGY: - * for now, this is quite just a cut-and-paste from i386 target... - */ - -/* default linux values for the selectors */ -#define __USER_DS (1) - -struct target_pt_regs { - abi_ulong gpr[32]; - abi_ulong nip; - abi_ulong msr; - abi_ulong orig_gpr3; /* Used for restarting system calls */ - abi_ulong ctr; - abi_ulong link; - abi_ulong xer; - abi_ulong ccr; -#if defined(TARGET_PPC64) - abi_ulong softe; -#else - abi_ulong mq; /* 601 only (not used at present) */ -#endif - /* Used on APUS to hold IPL value. */ - abi_ulong trap; /* Reason for being here */ - abi_ulong dar; /* Fault registers */ - abi_ulong dsisr; - abi_ulong result; /* Result of a system call */ -}; - /* ioctls */ struct target_revectored_struct { abi_ulong __map[8]; /* 256 bits */
linux-user/riscv/target_syscall.h +0 -35
@@ -8,41 +8,6 @@#ifndef LINUX_USER_RISCV_TARGET_SYSCALL_H #define LINUX_USER_RISCV_TARGET_SYSCALL_H -struct target_pt_regs { -abi_long sepc; -abi_long ra; -abi_long sp; -abi_long gp; -abi_long tp; -abi_long t0; -abi_long t1; -abi_long t2; -abi_long s0; -abi_long s1; -abi_long a0; -abi_long a1; -abi_long a2; -abi_long a3; -abi_long a4; -abi_long a5; -abi_long a6; -abi_long a7; -abi_long s2; -abi_long s3; -abi_long s4; -abi_long s5; -abi_long s6; -abi_long s7; -abi_long s8; -abi_long s9; -abi_long s10; -abi_long s11; -abi_long t3; -abi_long t4; -abi_long t5; -abi_long t6; -}; -#ifdef TARGET_RISCV32 #define UNAME_MACHINE "riscv32"#define UNAME_MINIMUM_RELEASE "5.4.0"
linux-user/sh4/target_syscall.h +0 -11
@@ -1,17 +1,6 @@#ifndef SH4_TARGET_SYSCALL_H #define SH4_TARGET_SYSCALL_H -struct target_pt_regs { -unsigned long regs[16 ]; -unsigned long pc; -unsigned long pr; -unsigned long sr; -unsigned long gbr; -unsigned long mach; -unsigned long macl; -long tra; -}; -#define UNAME_MACHINE "sh4"#define UNAME_MINIMUM_RELEASE "2.6.32"
linux-user/x86_64/target_syscall.h +0 -28
@@ -4,34 +4,6 @@#define __USER_CS (0x33)#define __USER_DS (0x2B) -struct target_pt_regs { -abi_ulong r15; -abi_ulong r14; -abi_ulong r13; -abi_ulong r12; -abi_ulong rbp; -abi_ulong rbx; -/* arguments: non interrupts/non tracing syscalls only save up to here */ -abi_ulong r11; -abi_ulong r10; -abi_ulong r9; -abi_ulong r8; -abi_ulong rax; -abi_ulong rcx; -abi_ulong rdx; -abi_ulong rsi; -abi_ulong rdi; -abi_ulong orig_rax; -/* end of arguments */ -/* cpu exception frame or undefined */ -abi_ulong rip; -abi_ulong cs; -abi_ulong eflags; -abi_ulong rsp; -abi_ulong ss; -/* top of stack page */ -}; -/* Maximum number of LDT entries supported. */ #define TARGET_LDT_ENTRIES 8192/* The size of each LDT entry. */
linux-user/xtensa/target_syscall.h +0 -35
@@ -8,41 +8,6 @@#define MMAP_SHIFT TARGET_PAGE_BITS -typedef uint32_t xtensa_reg_t ; -typedef struct { -}xtregs_opt_t ;/* TODO */ - -struct target_pt_regs { -xtensa_reg_t pc;/* 4 */ -xtensa_reg_t ps;/* 8 */ -xtensa_reg_t depc;/* 12 */ -xtensa_reg_t exccause;/* 16 */ -xtensa_reg_t excvaddr;/* 20 */ -xtensa_reg_t debugcause;/* 24 */ -xtensa_reg_t wmask;/* 28 */ -xtensa_reg_t lbeg;/* 32 */ -xtensa_reg_t lend;/* 36 */ -xtensa_reg_t lcount;/* 40 */ -xtensa_reg_t sar;/* 44 */ -xtensa_reg_t windowbase;/* 48 */ -xtensa_reg_t windowstart;/* 52 */ -xtensa_reg_t syscall;/* 56 */ -xtensa_reg_t icountlevel;/* 60 */ -xtensa_reg_t scompare1;/* 64 */ -xtensa_reg_t threadptr;/* 68 */ - -/* Additional configurable registers that are used by the compiler. */ -xtregs_opt_t xtregs_opt; - -/* Make sure the areg field is 16 bytes aligned. */ -int align[0 ] __attribute__ ((aligned (16 ))); - -/* current register frame. -* Note: The ESF for kernel exceptions ends after 16 registers! -*/ -xtensa_reg_t areg[16 ]; -}; -#define TARGET_MCL_CURRENT 1#define TARGET_MCL_FUTURE 2#define TARGET_MCL_ONFAULT 4
Signature · 1 line
2.43.0