* [Qemu-devel] [PATCH v2] linux-user/signal.c: Generate opcode data for restorer in setup_rt_frame
@ 2016-03-29 13:53 chengang
2016-03-29 14:17 ` Laurent Vivier
0 siblings, 1 reply; 2+ messages in thread
From: chengang @ 2016-03-29 13:53 UTC (permalink / raw)
To: rth, peter.maydell, cmetcalf, laurent
Cc: walt, Chen Gang, riku.voipio, qemu-devel, Chen Gang
From: Chen Gang <chengang@emindsoft.com.cn>
Original implementation uses do_rt_sigreturn directly in host space,
when a guest program is in unwind procedure in guest space, it will get
an incorrect restore address, then causes unwind failure.
Also cleanup the original incorrect indentation.
Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
---
linux-user/signal.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/linux-user/signal.c b/linux-user/signal.c
index 96e86c0..e487f9e 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -5559,8 +5559,13 @@ struct target_rt_sigframe {
unsigned char save_area[16]; /* caller save area */
struct target_siginfo info;
struct target_ucontext uc;
+ abi_ulong retcode[2];
};
+#define INSN_MOVELI_R10_139 0x00045fe551483000ULL /* { moveli r10, 139 } */
+#define INSN_SWINT1 0x286b180051485000ULL /* { swint1 } */
+
+
static void setup_sigcontext(struct target_sigcontext *sc,
CPUArchState *env, int signo)
{
@@ -5636,9 +5641,12 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,
__put_user(target_sigaltstack_used.ss_size, &frame->uc.tuc_stack.ss_size);
setup_sigcontext(&frame->uc.tuc_mcontext, env, info->si_signo);
- restorer = (unsigned long) do_rt_sigreturn;
if (ka->sa_flags & TARGET_SA_RESTORER) {
- restorer = (unsigned long) ka->sa_restorer;
+ restorer = (unsigned long) ka->sa_restorer;
+ } else {
+ __put_user(INSN_MOVELI_R10_139, &frame->retcode[0]);
+ __put_user(INSN_SWINT1, &frame->retcode[1]);
+ restorer = frame_addr + offsetof(struct target_rt_sigframe, retcode);
}
env->pc = (unsigned long) ka->_sa_handler;
env->regs[TILEGX_R_SP] = (unsigned long) frame;
--
1.9.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH v2] linux-user/signal.c: Generate opcode data for restorer in setup_rt_frame
2016-03-29 13:53 [Qemu-devel] [PATCH v2] linux-user/signal.c: Generate opcode data for restorer in setup_rt_frame chengang
@ 2016-03-29 14:17 ` Laurent Vivier
0 siblings, 0 replies; 2+ messages in thread
From: Laurent Vivier @ 2016-03-29 14:17 UTC (permalink / raw)
To: chengang, rth, peter.maydell, cmetcalf
Cc: walt, riku.voipio, qemu-devel, Chen Gang
Le 29/03/2016 15:53, chengang@emindsoft.com.cn a écrit :
> From: Chen Gang <chengang@emindsoft.com.cn>
>
> Original implementation uses do_rt_sigreturn directly in host space,
> when a guest program is in unwind procedure in guest space, it will get
> an incorrect restore address, then causes unwind failure.
>
> Also cleanup the original incorrect indentation.
>
> Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
> ---
> linux-user/signal.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/linux-user/signal.c b/linux-user/signal.c
> index 96e86c0..e487f9e 100644
> --- a/linux-user/signal.c
> +++ b/linux-user/signal.c
> @@ -5559,8 +5559,13 @@ struct target_rt_sigframe {
> unsigned char save_area[16]; /* caller save area */
> struct target_siginfo info;
> struct target_ucontext uc;
> + abi_ulong retcode[2];
> };
>
> +#define INSN_MOVELI_R10_139 0x00045fe551483000ULL /* { moveli r10, 139 } */
> +#define INSN_SWINT1 0x286b180051485000ULL /* { swint1 } */
> +
> +
> static void setup_sigcontext(struct target_sigcontext *sc,
> CPUArchState *env, int signo)
> {
> @@ -5636,9 +5641,12 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,
> __put_user(target_sigaltstack_used.ss_size, &frame->uc.tuc_stack.ss_size);
> setup_sigcontext(&frame->uc.tuc_mcontext, env, info->si_signo);
>
> - restorer = (unsigned long) do_rt_sigreturn;
> if (ka->sa_flags & TARGET_SA_RESTORER) {
> - restorer = (unsigned long) ka->sa_restorer;
> + restorer = (unsigned long) ka->sa_restorer;
> + } else {
> + __put_user(INSN_MOVELI_R10_139, &frame->retcode[0]);
> + __put_user(INSN_SWINT1, &frame->retcode[1]);
> + restorer = frame_addr + offsetof(struct target_rt_sigframe, retcode);
> }
> env->pc = (unsigned long) ka->_sa_handler;
> env->regs[TILEGX_R_SP] = (unsigned long) frame;
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-03-29 14:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-29 13:53 [Qemu-devel] [PATCH v2] linux-user/signal.c: Generate opcode data for restorer in setup_rt_frame chengang
2016-03-29 14:17 ` Laurent Vivier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).