qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] linux-user/s390x: Use the guest pointer for the sigreturn stub
@ 2021-03-24 18:51 Andreas Krebbel
  2021-03-25 10:42 ` Laurent Vivier
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Andreas Krebbel @ 2021-03-24 18:51 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-s390x, richard.henderson, laurent

When setting up the pointer for the sigreturn stub in the return
address register (r14) we currently use the host frame address instead
of the guest frame address.

Note: This only caused problems if Qemu has been built with
--disable-pie (as it is in distros nowadays). Otherwise guest_base
defaults to 0 hiding the actual problem.

Signed-off-by: Andreas Krebbel <krebbel@linux.ibm.com>
---
 linux-user/s390x/signal.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/linux-user/s390x/signal.c b/linux-user/s390x/signal.c
index ecfa2a14a9..7107c5fb53 100644
--- a/linux-user/s390x/signal.c
+++ b/linux-user/s390x/signal.c
@@ -211,9 +211,10 @@ void setup_rt_frame(int sig, struct target_sigaction *ka,
     /* Set up to return from userspace.  If provided, use a stub
        already in userspace.  */
     if (ka->sa_flags & TARGET_SA_RESTORER) {
-        env->regs[14] = (unsigned long) ka->sa_restorer | PSW_ADDR_AMODE;
+        env->regs[14] = ka->sa_restorer | PSW_ADDR_AMODE;
     } else {
-        env->regs[14] = (unsigned long) frame->retcode | PSW_ADDR_AMODE;
+        env->regs[14] = (frame_addr + offsetof(typeof(*frame), retcode))
+                        | PSW_ADDR_AMODE;
         __put_user(S390_SYSCALL_OPCODE | TARGET_NR_rt_sigreturn,
                    (uint16_t *)(frame->retcode));
     }
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v3] linux-user/s390x: Use the guest pointer for the sigreturn stub
  2021-03-24 18:51 [PATCH v3] linux-user/s390x: Use the guest pointer for the sigreturn stub Andreas Krebbel
@ 2021-03-25 10:42 ` Laurent Vivier
  2021-03-25 12:46 ` Richard Henderson
  2021-03-25 19:55 ` Laurent Vivier
  2 siblings, 0 replies; 5+ messages in thread
From: Laurent Vivier @ 2021-03-25 10:42 UTC (permalink / raw)
  To: Andreas Krebbel, qemu-devel; +Cc: qemu-s390x, richard.henderson

Le 24/03/2021 à 19:51, Andreas Krebbel a écrit :
> When setting up the pointer for the sigreturn stub in the return
> address register (r14) we currently use the host frame address instead
> of the guest frame address.
> 
> Note: This only caused problems if Qemu has been built with
> --disable-pie (as it is in distros nowadays). Otherwise guest_base
> defaults to 0 hiding the actual problem.
> 
> Signed-off-by: Andreas Krebbel <krebbel@linux.ibm.com>
> ---
>  linux-user/s390x/signal.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/linux-user/s390x/signal.c b/linux-user/s390x/signal.c
> index ecfa2a14a9..7107c5fb53 100644
> --- a/linux-user/s390x/signal.c
> +++ b/linux-user/s390x/signal.c
> @@ -211,9 +211,10 @@ void setup_rt_frame(int sig, struct target_sigaction *ka,
>      /* Set up to return from userspace.  If provided, use a stub
>         already in userspace.  */
>      if (ka->sa_flags & TARGET_SA_RESTORER) {
> -        env->regs[14] = (unsigned long) ka->sa_restorer | PSW_ADDR_AMODE;
> +        env->regs[14] = ka->sa_restorer | PSW_ADDR_AMODE;
>      } else {
> -        env->regs[14] = (unsigned long) frame->retcode | PSW_ADDR_AMODE;
> +        env->regs[14] = (frame_addr + offsetof(typeof(*frame), retcode))
> +                        | PSW_ADDR_AMODE;
>          __put_user(S390_SYSCALL_OPCODE | TARGET_NR_rt_sigreturn,
>                     (uint16_t *)(frame->retcode));
>      }
> 

Reviewed-by: Laurent Vivier <laurent@vivier.eu>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v3] linux-user/s390x: Use the guest pointer for the sigreturn stub
  2021-03-24 18:51 [PATCH v3] linux-user/s390x: Use the guest pointer for the sigreturn stub Andreas Krebbel
  2021-03-25 10:42 ` Laurent Vivier
@ 2021-03-25 12:46 ` Richard Henderson
  2021-03-25 19:55 ` Laurent Vivier
  2 siblings, 0 replies; 5+ messages in thread
From: Richard Henderson @ 2021-03-25 12:46 UTC (permalink / raw)
  To: Andreas Krebbel, qemu-devel; +Cc: qemu-s390x, laurent

On 3/24/21 12:51 PM, Andreas Krebbel wrote:
> When setting up the pointer for the sigreturn stub in the return
> address register (r14) we currently use the host frame address instead
> of the guest frame address.
> 
> Note: This only caused problems if Qemu has been built with
> --disable-pie (as it is in distros nowadays). Otherwise guest_base
> defaults to 0 hiding the actual problem.
> 
> Signed-off-by: Andreas Krebbel<krebbel@linux.ibm.com>
> ---
>   linux-user/s390x/signal.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v3] linux-user/s390x: Use the guest pointer for the sigreturn stub
  2021-03-24 18:51 [PATCH v3] linux-user/s390x: Use the guest pointer for the sigreturn stub Andreas Krebbel
  2021-03-25 10:42 ` Laurent Vivier
  2021-03-25 12:46 ` Richard Henderson
@ 2021-03-25 19:55 ` Laurent Vivier
  2021-03-26  6:51   ` Andreas Krebbel
  2 siblings, 1 reply; 5+ messages in thread
From: Laurent Vivier @ 2021-03-25 19:55 UTC (permalink / raw)
  To: Andreas Krebbel, qemu-devel; +Cc: qemu-s390x, richard.henderson

Le 24/03/2021 à 19:51, Andreas Krebbel a écrit :
> When setting up the pointer for the sigreturn stub in the return
> address register (r14) we currently use the host frame address instead
> of the guest frame address.
> 
> Note: This only caused problems if Qemu has been built with
> --disable-pie (as it is in distros nowadays). Otherwise guest_base
> defaults to 0 hiding the actual problem.
> 
> Signed-off-by: Andreas Krebbel <krebbel@linux.ibm.com>
> ---
>  linux-user/s390x/signal.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/linux-user/s390x/signal.c b/linux-user/s390x/signal.c
> index ecfa2a14a9..7107c5fb53 100644
> --- a/linux-user/s390x/signal.c
> +++ b/linux-user/s390x/signal.c
> @@ -211,9 +211,10 @@ void setup_rt_frame(int sig, struct target_sigaction *ka,
>      /* Set up to return from userspace.  If provided, use a stub
>         already in userspace.  */
>      if (ka->sa_flags & TARGET_SA_RESTORER) {
> -        env->regs[14] = (unsigned long) ka->sa_restorer | PSW_ADDR_AMODE;
> +        env->regs[14] = ka->sa_restorer | PSW_ADDR_AMODE;
>      } else {
> -        env->regs[14] = (unsigned long) frame->retcode | PSW_ADDR_AMODE;
> +        env->regs[14] = (frame_addr + offsetof(typeof(*frame), retcode))
> +                        | PSW_ADDR_AMODE;
>          __put_user(S390_SYSCALL_OPCODE | TARGET_NR_rt_sigreturn,
>                     (uint16_t *)(frame->retcode));
>      }
> 

Applied to my linux-user-for-6.0 branch

Thanks,
Laurent


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v3] linux-user/s390x: Use the guest pointer for the sigreturn stub
  2021-03-25 19:55 ` Laurent Vivier
@ 2021-03-26  6:51   ` Andreas Krebbel
  0 siblings, 0 replies; 5+ messages in thread
From: Andreas Krebbel @ 2021-03-26  6:51 UTC (permalink / raw)
  To: Laurent Vivier, qemu-devel; +Cc: qemu-s390x, richard.henderson, qemu-stable

On 3/25/21 8:55 PM, Laurent Vivier wrote:
> Le 24/03/2021 à 19:51, Andreas Krebbel a écrit :
>> When setting up the pointer for the sigreturn stub in the return
>> address register (r14) we currently use the host frame address instead
>> of the guest frame address.
>>
>> Note: This only caused problems if Qemu has been built with
>> --disable-pie (as it is in distros nowadays). Otherwise guest_base
>> defaults to 0 hiding the actual problem.
>>
>> Signed-off-by: Andreas Krebbel <krebbel@linux.ibm.com>
>> ---
>>  linux-user/s390x/signal.c | 5 +++--
>>  1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/linux-user/s390x/signal.c b/linux-user/s390x/signal.c
>> index ecfa2a14a9..7107c5fb53 100644
>> --- a/linux-user/s390x/signal.c
>> +++ b/linux-user/s390x/signal.c
>> @@ -211,9 +211,10 @@ void setup_rt_frame(int sig, struct target_sigaction *ka,
>>      /* Set up to return from userspace.  If provided, use a stub
>>         already in userspace.  */
>>      if (ka->sa_flags & TARGET_SA_RESTORER) {
>> -        env->regs[14] = (unsigned long) ka->sa_restorer | PSW_ADDR_AMODE;
>> +        env->regs[14] = ka->sa_restorer | PSW_ADDR_AMODE;
>>      } else {
>> -        env->regs[14] = (unsigned long) frame->retcode | PSW_ADDR_AMODE;
>> +        env->regs[14] = (frame_addr + offsetof(typeof(*frame), retcode))
>> +                        | PSW_ADDR_AMODE;
>>          __put_user(S390_SYSCALL_OPCODE | TARGET_NR_rt_sigreturn,
>>                     (uint16_t *)(frame->retcode));
>>      }
>>
> 
> Applied to my linux-user-for-6.0 branch

Thanks! Since this fixes a problem which prevents important applications (e.g. golang) to run
properly under Qemu for IBM Z right now I think it qualifies for stable branch.

The patch applies cleanly on 5.0 branch. Testsuite is clean and I've verfified that it fixes the
actual problem there as well.

Please consider inclusion into stable branch.

Andreas

> 
> Thanks,
> Laurent
> 



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-03-26  6:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-24 18:51 [PATCH v3] linux-user/s390x: Use the guest pointer for the sigreturn stub Andreas Krebbel
2021-03-25 10:42 ` Laurent Vivier
2021-03-25 12:46 ` Richard Henderson
2021-03-25 19:55 ` Laurent Vivier
2021-03-26  6:51   ` Andreas Krebbel

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).