diff --git a/bsd-user/freebsd/os-sys.c b/bsd-user/freebsd/os-sys.c index 79594094d6..728410a61c 100644 --- a/bsd-user/freebsd/os-sys.c +++ b/bsd-user/freebsd/os-sys.c @@ -1139,7 +1139,7 @@ static abi_long do_freebsd_sysctl_oid(CPUArchState *env, int32_t *snamep, switch (snamep[1]) { case 1: /* This should be documented elsewhere. */ holdlen = sizeof(abi_ulong); - (*(abi_ulong *)holdp) = env->dcache_line_size; + (*(abi_ulong *)holdp) = tswapal(env->dcache_line_size); ret = 0; goto out; } diff --git a/bsd-user/ppc/target_arch_cpu.h b/bsd-user/ppc/target_arch_cpu.h index 0beefb9882..cd5056a407 100644 --- a/bsd-user/ppc/target_arch_cpu.h +++ b/bsd-user/ppc/target_arch_cpu.h @@ -85,6 +85,7 @@ static inline void target_cpu_loop(CPUPPCState *env) case POWERPC_EXCP_DSI: /* Data storage exception */ fprintf(stderr, "Invalid data memory access: 0x" TARGET_FMT_lx "\n", env->spr[SPR_DAR]); + /* XXX: check this. Seems bugged */ if (env->error_code & 0x40000000) { info.si_signo = TARGET_SIGSEGV; @@ -431,6 +432,7 @@ static inline void target_cpu_loop(CPUPPCState *env) * in syscalls. */ env->crf[0] &= ~0x1; + env->nip += 4; ret = do_freebsd_syscall(env, env->gpr[0], env->gpr[3], env->gpr[4], env->gpr[5], env->gpr[6], env->gpr[7], env->gpr[8], env->gpr[9], env->gpr[10]); @@ -438,7 +440,9 @@ static inline void target_cpu_loop(CPUPPCState *env) /* Returning from a successful sigreturn syscall. Avoid corrupting register state. */ break; - } else if (ret == (target_ulong)(-TARGET_ERESTART)) { + } + else if (ret == (target_ulong)(-TARGET_ERESTART)) { + /* Re-exec the sc */ env->nip -= 4; break; } diff --git a/bsd-user/ppc/target_arch_signal.h b/bsd-user/ppc/target_arch_signal.h index a95791bffb..9ce2950cdf 100644 --- a/bsd-user/ppc/target_arch_signal.h +++ b/bsd-user/ppc/target_arch_signal.h @@ -23,10 +23,10 @@ #define TARGET_INSN_SIZE 4 /* powerpc instruction size */ #if defined(TARGET_PPC64) && !defined(TARGET_ABI32) -/* Size of the signal trampolin code placed on the stack. */ +/* Size of the signal trampoline code placed on the stack. */ #define TARGET_SZSIGCODE ((abi_ulong)(12 * TARGET_INSN_SIZE)) #else -#define TARGET_SZSIGCODE ((abi_ulong)(7 * TARGET_INSN_SIZE)) +#define TARGET_SZSIGCODE ((abi_ulong)(8 * TARGET_INSN_SIZE)) #endif #define TARGET_MINSIGSTKSZ (512 * 4) @@ -56,14 +56,13 @@ typedef struct target_trapframe { abi_long srr0; abi_long srr1; abi_long exc; + abi_long dar; /* DAR filled in on DSI traps */ union { struct { - /* dar & dsisr are only filled on a DSI trap */ - abi_long dar; + /* dsisr only filled on a DSI trap */ abi_long dsisr; } aim; struct { - abi_long dear; abi_long esr; abi_long dbcr0; } booke; @@ -80,12 +79,13 @@ struct target_sigcontext { typedef struct target_mcontext { int32_t mc_vers; int32_t mc_flags; - int32_t mc_onstack; /* sigstack state to restore */ - int32_t mc_len; - uint64_t mc_avec[32*2]; - uint32_t mc_av[2]; - abi_long mc_frame[42]; /* process regs 0 to 31 */ - uint64_t mc_fpreg[33]; /* fp regs 0 to 31 */ + int32_t mc_onstack; /* sigstack state to restore */ + int32_t mc_len; + uint64_t mc_avec[32*2]; + uint32_t mc_av[2]; + abi_long mc_frame[42]; /* process regs 0 to 31 */ + uint64_t mc_fpreg[33]; /* fp regs 0 to 31 */ + uint64_t mc_vsxfpreg[32]; /* low-order half of VSR0-31 */ } target_mcontext_t; typedef struct target_ucontext { @@ -129,6 +129,7 @@ set_sigtramp_args(CPUPPCState *regs, int sig, struct target_sigframe *frame, regs->gpr[5] = frame_addr + offsetof(struct target_sigframe, sf_uc); regs->lr = ka->_sa_handler; + /* Aim at the beginning of the sigcode. */ regs->nip = TARGET_PS_STRINGS - TARGET_SZSIGCODE; return 0; diff --git a/bsd-user/ppc/target_arch_sigtramp.h b/bsd-user/ppc/target_arch_sigtramp.h index 760aa1af38..112f78221c 100644 --- a/bsd-user/ppc/target_arch_sigtramp.h +++ b/bsd-user/ppc/target_arch_sigtramp.h @@ -18,19 +18,20 @@ static inline abi_long setup_sigtramp(abi_ulong offset, unsigned sigf_uc, /* 7 */ 0x38610070 + sigf_uc, /* addi r3,r1,112+SF_UC */ /* 8 */ 0x38000000 + sys_sigreturn, /* li r0,SYS_sigreturn */ /* 9 */ 0x44000002, /* sc */ - /* 10 */ 0x38000001, /* li r0,1 */ + /* 10 */ 0x38000001, /* li r0,SYS_exit */ /* 11 */ 0x44000002, /* sc */ /* 12 */ 0x60000000 /* nop */ }; #else uint32_t sigtramp_code[TARGET_SZSIGCODE/TARGET_INSN_SIZE] = { - /* 1 */ 0x3821FFEC, /* addi r1,r1,-20 */ + /* 1 */ 0x3821FFE0, /* addi r1,r1,-32 */ /* 2 */ 0x4E800021, /* blrl */ - /* 3 */ 0x38610014 + sigf_uc, /* addi r3,r1,20+SF_UC */ + /* 3 */ 0x38610020 + sigf_uc, /* addi r3,r1,20+SF_UC */ /* 4 */ 0x38000000 + sys_sigreturn, /* li r0,SYS_sigreturn */ /* 5 */ 0x44000002, /* sc */ - /* 6 */ 0x38000001, /* li r0,1 */ - /* 7 */ 0x44000002 /* sc */ + /* 6 */ 0x38000001, /* li r0,SYS_exit */ + /* 7 */ 0x44000002, /* sc */ + /* 8 */ 0x60000000 /* nop */ }; #endif