All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Vivier <laurent@vivier.eu>
To: Chen Gang <chengang@emindsoft.com.cn>,
	rth@twiddle.net, peter.maydell@linaro.org, cmetcalf@ezchip.com
Cc: walt@tilera.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] linux-user/signal.c: Generate opcode data for restorer in setup_rt_frame
Date: Tue, 29 Mar 2016 00:17:52 +0200	[thread overview]
Message-ID: <56F9AD90.4090106@vivier.eu> (raw)
In-Reply-To: <56F7AB79.8010403@emindsoft.com.cn>



Le 27/03/2016 11:44, Chen Gang a écrit :
> Hello All:
> 
> Please help check this patch when you have time.
> 
> After this patch, we can let gcc testsuite cleanup-10 run successfully.
> 
> Next, I shall continue to implement floating point instructions: remove
> (u)int64_to_float64 from fdouble implementation.
> 
> 
> Thanks.
> 
> On 3/15/16 05:51, chengang@emindsoft.com.cn wrote:
>> 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 919aa83..0e3b1c6 100644
>> --- a/linux-user/signal.c
>> +++ b/linux-user/signal.c
>> @@ -5566,8 +5566,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)
>>  {
>> @@ -5643,9 +5648,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 = (unsigned long)frame->retcode;

The address of retcode in host and guest can differ.
You need something like:

	restorer = (unsigned long)(frame_addr + offsetof(struct
target_rt_sigframe, retcode));

I've experienced this on sh4 (see commit 2a0fa68)

>>      }
>>      env->pc = (unsigned long) ka->_sa_handler;
>>      env->regs[TILEGX_R_SP] = (unsigned long) frame;
>>
> 

Laurent

  reply	other threads:[~2016-03-28 22:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-14 21:51 [Qemu-devel] [PATCH] linux-user/signal.c: Generate opcode data for restorer in setup_rt_frame chengang
2016-03-27  9:44 ` Chen Gang
2016-03-28 22:17   ` Laurent Vivier [this message]
2016-03-28 22:57     ` Chen Gang
2016-03-29 13:53       ` Chen Gang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56F9AD90.4090106@vivier.eu \
    --to=laurent@vivier.eu \
    --cc=chengang@emindsoft.com.cn \
    --cc=cmetcalf@ezchip.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=walt@tilera.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.