Message ID | 20220103165625.307309-2-matheus.ferst@eldorado.org.br (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | linux-user/ppc: Deliver SIGTRAP on tw[i]/td[i] | expand |
On 1/3/22 8:56 AM, matheus.ferst@eldorado.org.br wrote: > From: Matheus Ferst <matheus.ferst@eldorado.org.br> > > Handle POWERPC_EXCP_TRAP in cpu_loop to deliver SIGTRAP on tw[i]/td[i]. > The si_code comes from do_program_check in the kernel source file > arch/powerpc/kernel/traps.c > > Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br> > --- > linux-user/ppc/cpu_loop.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/linux-user/ppc/cpu_loop.c b/linux-user/ppc/cpu_loop.c > index 30c82f2354..8fbaa772dc 100644 > --- a/linux-user/ppc/cpu_loop.c > +++ b/linux-user/ppc/cpu_loop.c > @@ -242,7 +242,9 @@ void cpu_loop(CPUPPCState *env) > } > break; > case POWERPC_EXCP_TRAP: > - cpu_abort(cs, "Tried to call a TRAP\n"); > + info.si_signo = TARGET_SIGTRAP; > + info.si_errno = 0; > + info.si_code = TARGET_TRAP_BRKPT; You're missing the address, which should be nip. https://github.com/torvalds/linux/blob/master/arch/powerpc/kernel/traps.c#L1503 Please use force_sig_fault. (I have a pending patch set to convert all other instances; hopefully that can be merged soon...) r~
On 03/01/2022 14:50, Richard Henderson wrote: > On 1/3/22 8:56 AM, matheus.ferst@eldorado.org.br wrote: >> From: Matheus Ferst <matheus.ferst@eldorado.org.br> >> >> Handle POWERPC_EXCP_TRAP in cpu_loop to deliver SIGTRAP on tw[i]/td[i]. >> The si_code comes from do_program_check in the kernel source file >> arch/powerpc/kernel/traps.c >> >> Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br> >> --- >> linux-user/ppc/cpu_loop.c | 4 +++- >> 1 file changed, 3 insertions(+), 1 deletion(-) >> >> diff --git a/linux-user/ppc/cpu_loop.c b/linux-user/ppc/cpu_loop.c >> index 30c82f2354..8fbaa772dc 100644 >> --- a/linux-user/ppc/cpu_loop.c >> +++ b/linux-user/ppc/cpu_loop.c >> @@ -242,7 +242,9 @@ void cpu_loop(CPUPPCState *env) >> } >> break; >> case POWERPC_EXCP_TRAP: >> - cpu_abort(cs, "Tried to call a TRAP\n"); >> + info.si_signo = TARGET_SIGTRAP; >> + info.si_errno = 0; >> + info.si_code = TARGET_TRAP_BRKPT; > > You're missing the address, which should be nip. > > https://github.com/torvalds/linux/blob/master/arch/powerpc/kernel/traps.c#L1503 > After this switch-case, there is a info._sifields._sigfault._addr = env->nip; Is there anything else to be set? > > Please use force_sig_fault. (I have a pending patch set to convert all > other instances; > hopefully that can be merged soon...) > I'll send v2 with a Based-on Thanks, Matheus K. Ferst Instituto de Pesquisas ELDORADO <http://www.eldorado.org.br/> Analista de Software Aviso Legal - Disclaimer <https://www.eldorado.org.br/disclaimer.html>
On 1/3/22 10:12 AM, Matheus K. Ferst wrote: > On 03/01/2022 14:50, Richard Henderson wrote: >> On 1/3/22 8:56 AM, matheus.ferst@eldorado.org.br wrote: >>> From: Matheus Ferst <matheus.ferst@eldorado.org.br> >>> >>> Handle POWERPC_EXCP_TRAP in cpu_loop to deliver SIGTRAP on tw[i]/td[i]. >>> The si_code comes from do_program_check in the kernel source file >>> arch/powerpc/kernel/traps.c >>> >>> Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br> >>> --- >>> linux-user/ppc/cpu_loop.c | 4 +++- >>> 1 file changed, 3 insertions(+), 1 deletion(-) >>> >>> diff --git a/linux-user/ppc/cpu_loop.c b/linux-user/ppc/cpu_loop.c >>> index 30c82f2354..8fbaa772dc 100644 >>> --- a/linux-user/ppc/cpu_loop.c >>> +++ b/linux-user/ppc/cpu_loop.c >>> @@ -242,7 +242,9 @@ void cpu_loop(CPUPPCState *env) >>> } >>> break; >>> case POWERPC_EXCP_TRAP: >>> - cpu_abort(cs, "Tried to call a TRAP\n"); >>> + info.si_signo = TARGET_SIGTRAP; >>> + info.si_errno = 0; >>> + info.si_code = TARGET_TRAP_BRKPT; >> >> You're missing the address, which should be nip. >> >> https://github.com/torvalds/linux/blob/master/arch/powerpc/kernel/traps.c#L1503 > > After this switch-case, there is a > > info._sifields._sigfault._addr = env->nip; > > Is there anything else to be set? Nope, sorry I missed that. r~
diff --git a/linux-user/ppc/cpu_loop.c b/linux-user/ppc/cpu_loop.c index 30c82f2354..8fbaa772dc 100644 --- a/linux-user/ppc/cpu_loop.c +++ b/linux-user/ppc/cpu_loop.c @@ -242,7 +242,9 @@ void cpu_loop(CPUPPCState *env) } break; case POWERPC_EXCP_TRAP: - cpu_abort(cs, "Tried to call a TRAP\n"); + info.si_signo = TARGET_SIGTRAP; + info.si_errno = 0; + info.si_code = TARGET_TRAP_BRKPT; break; default: /* Should not happen ! */