mirror of https://github.com/xemu-project/xemu.git
linux-user: fill target sigcontext struct accordingly
A segfault is noticed when an emulated program uses any of ucontext regs fields. Risu detected this issue in the following operation when handling a signal: ucontext_t *uc = (ucontext_t*)uc; uc->uc_mcontext.regs->nip += 4; but this works fine: uc->uc_mcontext.gp_regs[PT_NIP] += 4; This patch set regs to a valid location as well as other sigcontext fields. Signed-off-by: Jose Ricardo Ziviani <joserz@linux.vnet.ibm.com> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <1485900317-3256-1-git-send-email-joserz@linux.vnet.ibm.com> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
This commit is contained in:
parent
35f2fd04ce
commit
26920a2961
|
@ -5155,6 +5155,7 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,
|
||||||
target_ulong rt_sf_addr, newsp = 0;
|
target_ulong rt_sf_addr, newsp = 0;
|
||||||
int i, err = 0;
|
int i, err = 0;
|
||||||
#if defined(TARGET_PPC64)
|
#if defined(TARGET_PPC64)
|
||||||
|
struct target_sigcontext *sc = 0;
|
||||||
struct image_info *image = ((TaskState *)thread_cpu->opaque)->info;
|
struct image_info *image = ((TaskState *)thread_cpu->opaque)->info;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -5183,6 +5184,10 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,
|
||||||
#if defined(TARGET_PPC64)
|
#if defined(TARGET_PPC64)
|
||||||
mctx = &rt_sf->uc.tuc_sigcontext.mcontext;
|
mctx = &rt_sf->uc.tuc_sigcontext.mcontext;
|
||||||
trampptr = &rt_sf->trampoline[0];
|
trampptr = &rt_sf->trampoline[0];
|
||||||
|
|
||||||
|
sc = &rt_sf->uc.tuc_sigcontext;
|
||||||
|
__put_user(h2g(mctx), &sc->regs);
|
||||||
|
__put_user(sig, &sc->signal);
|
||||||
#else
|
#else
|
||||||
mctx = &rt_sf->uc.tuc_mcontext;
|
mctx = &rt_sf->uc.tuc_mcontext;
|
||||||
trampptr = (uint32_t *)&rt_sf->uc.tuc_mcontext.tramp;
|
trampptr = (uint32_t *)&rt_sf->uc.tuc_mcontext.tramp;
|
||||||
|
|
Loading…
Reference in New Issue