Fix ppc64-linux-user
cover Fix ppc64-linux-user
At the moment, no ppc64-linux-user tests work at all. With these two patches, I can at least run the linux-user-test-0.3 binary and a statically linked empty program (int main() { return 0; }).
Given that linux-user-test-0.3 is in fact busybox, this is rather more comprehensive testing than it would otherwise sound.
r~
Richard Henderson (2):
ppc64-linux-user: Properly interpret the entry function descriptor.
ppc64-linux-user: Fix syscall return type.
linux-user/elfload.c | 8 ++++---- linux-user/main.c | 13 +++---------- 2 files changed, 7 insertions(+), 14 deletions(-)
Signature · 1 line
1.7.6.4
PATCH 1/2 ppc64-linux-user: Properly interpret the entry function descriptor.
Don't confuse the load address with the load bias. They're equal for ET_DYN objects (i.e. ld.so) but different for ET_EXEC objects (i.e. statically linked).
--- linux-user/elfload.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
linux-user/elfload.c +4 -4
@@ -618,8 +618,8 @@ static inline void init_thread(struct target_pt_regs *_regs, struct image_info * { _regs->gpr[1 ] = infop->start_stack;#if defined(TARGET_PPC64 ) && !defined(TARGET_ABI32 ) - _regs->gpr[2 ] =ldq_raw (infop->entry +8 ) + infop->load_addr; - infop->entry =ldq_raw (infop->entry) + infop->load_addr; + _regs->gpr[2 ] =ldq_raw (infop->entry +8 ) + infop->load_bias; + infop->entry =ldq_raw (infop->entry) + infop->load_bias;#endif _regs->nip = infop->entry; }
@@ -1884,11 +1884,11 @@ int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs, info->start_stack = bprm->p;/* If we have an interpreter, set that as the program's entry point. -Copy the load_addr as well, to help PPC64 interpret the entry +Copy the load_bias as well, to help PPC64 interpret the entry point as a function descriptor. Do this after creating elf tables so that we copy the original program entry point into the AUXV. */ if (elf_interpreter) { - info->load_addr = interp_info.load_addr; + info->load_bias = interp_info.load_bias; info->entry = interp_info.entry;free (elf_interpreter); }
Signature · 1 line
1.7.6.4
Re: [Qemu-devel] [PATCH 1/2] ppc64-linux-user: Properly interpret the entry function descriptor.
Quoted 5 lines · Richard Henderson
Don't confuse the load address with the load bias. They're equal for
ET_DYNobjects (i.e. ld.so) but different forET_EXECobjects (i.e. statically linked).Signed-off-by Richard Henderson <[email protected]>
Alex
PATCH 2/2 ppc64-linux-user: Fix syscall return type.
In reply to Richard HendersonUse target_ulong instead of hard-coded uint32_t. Remove the disabled printf's that are redundant with -strace.
--- linux-user/main.c | 13 +++---------- 1 files changed, 3 insertions(+), 10 deletions(-)
linux-user/main.c +3 -10
@@ -1332,7 +1332,7 @@ void cpu_loop(CPUPPCState *env) {target_siginfo_t info;int trapnr; -uint32_t ret; +target_ulong ret;for (;;) {cpu_exec_start (env);
@@ -1695,27 +1695,20 @@ void cpu_loop(CPUPPCState *env)* PPC ABI uses overflow flag in cr0 to signal an error * in syscalls. */ -#if 0 -printf ("syscall %d 0x%08x 0x%08x 0x%08x 0x%08x\n" , env->gpr[0 ], - env->gpr[3 ], env->gpr[4 ], env->gpr[5 ], env->gpr[6 ]); -#endif env->crf[0 ] &= ~0x1 ; ret =do_syscall (env, env->gpr[0 ], env->gpr[3 ], env->gpr[4 ], env->gpr[5 ], env->gpr[6 ], env->gpr[7 ], env->gpr[8 ],0 ,0 ); -if (ret == (uint32_t )(-TARGET_QEMU_ESIGRETURN )) { +if (ret == (target_ulong)(-TARGET_QEMU_ESIGRETURN )) {/* Returning from a successful sigreturn syscall. Avoid corrupting register state. */ break ; } -if (ret > (uint32_t )(-515 )) { +if (ret > (target_ulong)(-515 )) { env->crf[0 ] |=0x1 ; ret = -ret; } env->gpr[3 ] = ret; -#if 0 -printf ("syscall returned 0x%08x (%d)\n" , ret, ret); -#endif break ;case POWERPC_EXCP_STCX :if (do_store_exclusive (env)) {
Signature · 1 line
1.7.6.4
Re: [Qemu-devel] [PATCH 2/2] ppc64-linux-user: Fix syscall return type.
Quoted 4 lines · Richard Henderson
Use
target_ulonginstead of hard-codeduint32_t. Remove the disabled printf's that are redundant with -strace.Signed-off-by Richard Henderson <[email protected]>
Riku, do you want to take these in or should I?
Alex