diff mbox

linux-user/signal.c: Use s390 target space address instead of host space address for restorer

Message ID 1459261750-5879-1-git-send-email-chengang@emindsoft.com.cn
State New
Headers show

Commit Message

Chen Gang March 29, 2016, 2:29 p.m. UTC
From: Chen Gang <chengang@emindsoft.com.cn>

The return address is in target space, so the restorer address needs to
be target space, too.

Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
---
 linux-user/signal.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Peter Maydell May 4, 2016, 4:06 p.m. UTC | #1
On 29 March 2016 at 15:29,  <chengang@emindsoft.com.cn> wrote:
> From: Chen Gang <chengang@emindsoft.com.cn>
>
> The return address is in target space, so the restorer address needs to
> be target space, too.
>
> Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
> ---
>  linux-user/signal.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/linux-user/signal.c b/linux-user/signal.c
> index c0a6f7e..6a73321 100644
> --- a/linux-user/signal.c
> +++ b/linux-user/signal.c
> @@ -4117,8 +4117,8 @@ static void setup_frame(int sig, struct target_sigaction *ka,
>              env->regs[14] = (unsigned long)
>                      ka->sa_restorer | PSW_ADDR_AMODE;
>      } else {
> -            env->regs[14] = (unsigned long)
> -                    frame->retcode | PSW_ADDR_AMODE;
> +            env->regs[14] = (frame_addr + offsetof(sigframe, retcode))
> +                            | PSW_ADDR_AMODE;
>              __put_user(S390_SYSCALL_OPCODE | TARGET_NR_sigreturn,
>                         (uint16_t *)(frame->retcode));
>      }

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM
Laurent Vivier May 4, 2016, 5:47 p.m. UTC | #2
Le 29/03/2016 à 16:29, chengang@emindsoft.com.cn a écrit :
> From: Chen Gang <chengang@emindsoft.com.cn>
> 
> The return address is in target space, so the restorer address needs to
> be target space, too.
> 
> Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
> ---
>  linux-user/signal.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/linux-user/signal.c b/linux-user/signal.c
> index c0a6f7e..6a73321 100644
> --- a/linux-user/signal.c
> +++ b/linux-user/signal.c
> @@ -4117,8 +4117,8 @@ static void setup_frame(int sig, struct target_sigaction *ka,
>              env->regs[14] = (unsigned long)
>                      ka->sa_restorer | PSW_ADDR_AMODE;
>      } else {
> -            env->regs[14] = (unsigned long)
> -                    frame->retcode | PSW_ADDR_AMODE;
> +            env->regs[14] = (frame_addr + offsetof(sigframe, retcode))
> +                            | PSW_ADDR_AMODE;
>              __put_user(S390_SYSCALL_OPCODE | TARGET_NR_sigreturn,
>                         (uint16_t *)(frame->retcode));
>      }
> 
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
diff mbox

Patch

diff --git a/linux-user/signal.c b/linux-user/signal.c
index c0a6f7e..6a73321 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -4117,8 +4117,8 @@  static void setup_frame(int sig, struct target_sigaction *ka,
             env->regs[14] = (unsigned long)
                     ka->sa_restorer | PSW_ADDR_AMODE;
     } else {
-            env->regs[14] = (unsigned long)
-                    frame->retcode | PSW_ADDR_AMODE;
+            env->regs[14] = (frame_addr + offsetof(sigframe, retcode))
+                            | PSW_ADDR_AMODE;
             __put_user(S390_SYSCALL_OPCODE | TARGET_NR_sigreturn,
                        (uint16_t *)(frame->retcode));
     }