diff mbox series

[6/7] linux-user/nios2: Use QEMU_ESIGRETURN from do_rt_sigreturn

Message ID 20220320160009.2665152-7-richard.henderson@linaro.org
State Superseded
Headers show
Series linux-user/nios2: Fix clone and sigreturn | expand

Commit Message

Richard Henderson March 20, 2022, 4 p.m. UTC
Drop the kernel-specific "pr2" code structure and use
the qemu-specific error return value.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/nios2/signal.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

Comments

Peter Maydell March 25, 2022, 12:16 p.m. UTC | #1
On Sun, 20 Mar 2022 at 16:06, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> Drop the kernel-specific "pr2" code structure and use
> the qemu-specific error return value.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  linux-user/nios2/signal.c | 10 +++-------
>  1 file changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/linux-user/nios2/signal.c b/linux-user/nios2/signal.c
> index 133bc05673..4442974001 100644
> --- a/linux-user/nios2/signal.c
> +++ b/linux-user/nios2/signal.c
> @@ -77,8 +77,7 @@ static void rt_setup_ucontext(struct target_ucontext *uc, CPUNios2State *env)
>      __put_user(env->regs[R_SP], &gregs[28]);
>  }
>
> -static int rt_restore_ucontext(CPUNios2State *env, struct target_ucontext *uc,
> -                               int *pr2)
> +static int rt_restore_ucontext(CPUNios2State *env, struct target_ucontext *uc)
>  {
>      int temp;
>      unsigned long *gregs = uc->tuc_mcontext.gregs;
> @@ -128,8 +127,6 @@ static int rt_restore_ucontext(CPUNios2State *env, struct target_ucontext *uc,
>      __get_user(env->regs[R_SP], &gregs[28]);
>
>      target_restore_altstack(&uc->tuc_stack, env);
> -
> -    *pr2 = env->regs[2];
>      return 0;
>  }
>
> @@ -191,7 +188,6 @@ long do_rt_sigreturn(CPUNios2State *env)
>      abi_ulong frame_addr = env->regs[R_SP];
>      struct target_rt_sigframe *frame;
>      sigset_t set;
> -    int rval;
>
>      if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) {
>          goto badframe;
> @@ -200,12 +196,12 @@ long do_rt_sigreturn(CPUNios2State *env)
>      target_to_host_sigset(&set, &frame->uc.tuc_sigmask);
>      set_sigmask(&set);
>
> -    if (rt_restore_ucontext(env, &frame->uc, &rval)) {
> +    if (rt_restore_ucontext(env, &frame->uc)) {
>          goto badframe;
>      }
>
>      unlock_user_struct(frame, frame_addr, 0);
> -    return rval;
> +    return -QEMU_ESIGRETURN;
>
>  badframe:
>      unlock_user_struct(frame, frame_addr, 0);

Don't you also need to return -QEMU_ESIGRETURN in the badframe
error-handling case? The other guest architecture implementations
of do_sigreturn seem to do that.

thanks
-- PMM
Richard Henderson March 25, 2022, 7:09 p.m. UTC | #2
On 3/25/22 06:16, Peter Maydell wrote:
>> +    return -QEMU_ESIGRETURN;
>>
>>   badframe:
>>       unlock_user_struct(frame, frame_addr, 0);
> 
> Don't you also need to return -QEMU_ESIGRETURN in the badframe
> error-handling case? The other guest architecture implementations
> of do_sigreturn seem to do that.

Yep, good catch.

r~
diff mbox series

Patch

diff --git a/linux-user/nios2/signal.c b/linux-user/nios2/signal.c
index 133bc05673..4442974001 100644
--- a/linux-user/nios2/signal.c
+++ b/linux-user/nios2/signal.c
@@ -77,8 +77,7 @@  static void rt_setup_ucontext(struct target_ucontext *uc, CPUNios2State *env)
     __put_user(env->regs[R_SP], &gregs[28]);
 }
 
-static int rt_restore_ucontext(CPUNios2State *env, struct target_ucontext *uc,
-                               int *pr2)
+static int rt_restore_ucontext(CPUNios2State *env, struct target_ucontext *uc)
 {
     int temp;
     unsigned long *gregs = uc->tuc_mcontext.gregs;
@@ -128,8 +127,6 @@  static int rt_restore_ucontext(CPUNios2State *env, struct target_ucontext *uc,
     __get_user(env->regs[R_SP], &gregs[28]);
 
     target_restore_altstack(&uc->tuc_stack, env);
-
-    *pr2 = env->regs[2];
     return 0;
 }
 
@@ -191,7 +188,6 @@  long do_rt_sigreturn(CPUNios2State *env)
     abi_ulong frame_addr = env->regs[R_SP];
     struct target_rt_sigframe *frame;
     sigset_t set;
-    int rval;
 
     if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) {
         goto badframe;
@@ -200,12 +196,12 @@  long do_rt_sigreturn(CPUNios2State *env)
     target_to_host_sigset(&set, &frame->uc.tuc_sigmask);
     set_sigmask(&set);
 
-    if (rt_restore_ucontext(env, &frame->uc, &rval)) {
+    if (rt_restore_ucontext(env, &frame->uc)) {
         goto badframe;
     }
 
     unlock_user_struct(frame, frame_addr, 0);
-    return rval;
+    return -QEMU_ESIGRETURN;
 
 badframe:
     unlock_user_struct(frame, frame_addr, 0);