All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sergey Fedorov <serge.fdrv@gmail.com>
To: Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Riku Voipio <riku.voipio@iki.fi>,
	Richard Henderson <rth@twiddle.net>,
	Eduardo Habkost <ehabkost@redhat.com>,
	patches@linaro.org
Subject: Re: [Qemu-devel] [PATCH 4/5] user-exec: Don't reextract sigmask from usercontext pointer
Date: Mon, 16 May 2016 21:00:06 +0300	[thread overview]
Message-ID: <573A0AA6.4070803@gmail.com> (raw)
In-Reply-To: <1463414992-8357-5-git-send-email-peter.maydell@linaro.org>

On 16/05/16 19:09, Peter Maydell wrote:
> Extracting the old signal mask from the usercontext pointer passed to
> a signal handler is a pain because it is OS and CPU dependent.
> Since we've already done it once and passed it to handle_cpu_signal(),
> there's no need to do it again in cpu_exit_tb_from_sighandler().
> This then means we don't need to pass a usercontext pointer in to
> handle_cpu_signal() at all.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Reviewed-by: Sergey Fedorov <sergey.fedorov@linaro.org>

> ---
>  user-exec.c | 48 ++++++++++++++++--------------------------------
>  1 file changed, 16 insertions(+), 32 deletions(-)
>
> diff --git a/user-exec.c b/user-exec.c
> index 40b5e7c..ad669f4 100644
> --- a/user-exec.c
> +++ b/user-exec.c
> @@ -54,25 +54,10 @@ static void exception_action(CPUState *cpu)
>  /* exit the current TB from a signal handler. The host registers are
>     restored in a state compatible with the CPU emulator
>   */
> -static void cpu_exit_tb_from_sighandler(CPUState *cpu, void *puc)
> +static void cpu_exit_tb_from_sighandler(CPUState *cpu, sigset_t *old_set)
>  {
> -#ifdef __linux__
> -    struct ucontext *uc = puc;
> -#elif defined(__OpenBSD__)
> -    struct sigcontext *uc = puc;
> -#endif
> -
>      /* XXX: use siglongjmp ? */
> -#ifdef __linux__
> -#ifdef __ia64
> -    sigprocmask(SIG_SETMASK, (sigset_t *)&uc->uc_sigmask, NULL);
> -#else
> -    sigprocmask(SIG_SETMASK, &uc->uc_sigmask, NULL);
> -#endif
> -#elif defined(__OpenBSD__)
> -    sigprocmask(SIG_SETMASK, &uc->sc_mask, NULL);
> -#endif
> -
> +    sigprocmask(SIG_SETMASK, old_set, NULL);
>      cpu_loop_exit_noexc(cpu);
>  }
>  
> @@ -81,8 +66,7 @@ static void cpu_exit_tb_from_sighandler(CPUState *cpu, void *puc)
>     write caused the exception and otherwise 0'. 'old_set' is the
>     signal set which should be restored */
>  static inline int handle_cpu_signal(uintptr_t pc, unsigned long address,
> -                                    int is_write, sigset_t *old_set,
> -                                    void *puc)
> +                                    int is_write, sigset_t *old_set)
>  {
>      CPUState *cpu;
>      CPUClass *cc;
> @@ -110,7 +94,7 @@ static inline int handle_cpu_signal(uintptr_t pc, unsigned long address,
>               * currently executing TB was modified and must be exited
>               * immediately.
>               */
> -            cpu_exit_tb_from_sighandler(current_cpu, puc);
> +            cpu_exit_tb_from_sighandler(current_cpu, old_set);
>              g_assert_not_reached();
>          default:
>              g_assert_not_reached();
> @@ -204,7 +188,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
>      return handle_cpu_signal(pc, (unsigned long)info->si_addr,
>                               trapno == 0xe ?
>                               (ERROR_sig(uc) >> 1) & 1 : 0,
> -                             &MASK_sig(uc), puc);
> +                             &MASK_sig(uc));
>  }
>  
>  #elif defined(__x86_64__)
> @@ -250,7 +234,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
>      return handle_cpu_signal(pc, (unsigned long)info->si_addr,
>                               TRAP_sig(uc) == 0xe ?
>                               (ERROR_sig(uc) >> 1) & 1 : 0,
> -                             &MASK_sig(uc), puc);
> +                             &MASK_sig(uc));
>  }
>  
>  #elif defined(_ARCH_PPC)
> @@ -366,7 +350,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
>      }
>  #endif
>      return handle_cpu_signal(pc, (unsigned long)info->si_addr,
> -                             is_write, &uc->uc_sigmask, puc);
> +                             is_write, &uc->uc_sigmask);
>  }
>  
>  #elif defined(__alpha__)
> @@ -397,7 +381,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
>      }
>  
>      return handle_cpu_signal(pc, (unsigned long)info->si_addr,
> -                             is_write, &uc->uc_sigmask, puc);
> +                             is_write, &uc->uc_sigmask);
>  }
>  #elif defined(__sparc__)
>  
> @@ -457,7 +441,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
>          }
>      }
>      return handle_cpu_signal(pc, (unsigned long)info->si_addr,
> -                             is_write, sigmask, NULL);
> +                             is_write, sigmask);
>  }
>  
>  #elif defined(__arm__)
> @@ -492,7 +476,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
>      is_write = extract32(uc->uc_mcontext.error_code, 11, 1);
>      return handle_cpu_signal(pc, (unsigned long)info->si_addr,
>                               is_write,
> -                             &uc->uc_sigmask, puc);
> +                             &uc->uc_sigmask);
>  }
>  
>  #elif defined(__aarch64__)
> @@ -520,7 +504,7 @@ int cpu_signal_handler(int host_signum, void *pinfo, void *puc)
>                  || (insn & 0x3a400000) == 0x28000000); /* C3.3.7,14-16 */
>  
>      return handle_cpu_signal(pc, (uintptr_t)info->si_addr,
> -                             is_write, &uc->uc_sigmask, puc);
> +                             is_write, &uc->uc_sigmask);
>  }
>  
>  #elif defined(__mc68000)
> @@ -538,7 +522,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
>      is_write = 0;
>      return handle_cpu_signal(pc, (unsigned long)info->si_addr,
>                               is_write,
> -                             &uc->uc_sigmask, puc);
> +                             &uc->uc_sigmask);
>  }
>  
>  #elif defined(__ia64)
> @@ -573,7 +557,7 @@ int cpu_signal_handler(int host_signum, void *pinfo, void *puc)
>      }
>      return handle_cpu_signal(ip, (unsigned long)info->si_addr,
>                               is_write,
> -                             (sigset_t *)&uc->uc_sigmask, puc);
> +                             (sigset_t *)&uc->uc_sigmask);
>  }
>  
>  #elif defined(__s390__)
> @@ -626,7 +610,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
>          break;
>      }
>      return handle_cpu_signal(pc, (unsigned long)info->si_addr,
> -                             is_write, &uc->uc_sigmask, puc);
> +                             is_write, &uc->uc_sigmask);
>  }
>  
>  #elif defined(__mips__)
> @@ -642,7 +626,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
>      /* XXX: compute is_write */
>      is_write = 0;
>      return handle_cpu_signal(pc, (unsigned long)info->si_addr,
> -                             is_write, &uc->uc_sigmask, puc);
> +                             is_write, &uc->uc_sigmask);
>  }
>  
>  #elif defined(__hppa__)
> @@ -684,7 +668,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
>      }
>  
>      return handle_cpu_signal(pc, (unsigned long)info->si_addr,
> -                             is_write, &uc->uc_sigmask, puc);
> +                             is_write, &uc->uc_sigmask);
>  }
>  
>  #else

  reply	other threads:[~2016-05-16 18:00 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-16 16:09 [Qemu-devel] [PATCH 0/5] user-exec: cpu_resume_from_signal() cleanups Peter Maydell
2016-05-16 16:09 ` [Qemu-devel] [PATCH 1/5] translate-all.c: Don't pass puc, locked to tb_invalidate_phys_page() Peter Maydell
2016-05-16 17:13   ` Sergey Fedorov
2016-05-16 17:15     ` Peter Maydell
2016-05-16 17:24       ` Sergey Fedorov
2016-05-16 16:09 ` [Qemu-devel] [PATCH 2/5] user-exec: Push resume-from-signal code out to handle_cpu_signal() Peter Maydell
2016-05-16 17:57   ` Sergey Fedorov
2016-05-16 16:09 ` [Qemu-devel] [PATCH 3/5] cpu-exec: Rename cpu_resume_from_signal() to cpu_loop_exit_noexc() Peter Maydell
2016-05-16 17:58   ` Sergey Fedorov
2016-05-16 16:09 ` [Qemu-devel] [PATCH 4/5] user-exec: Don't reextract sigmask from usercontext pointer Peter Maydell
2016-05-16 18:00   ` Sergey Fedorov [this message]
2016-05-16 16:09 ` [Qemu-devel] [PATCH 5/5] target-i386: Move user-mode exception actions out of user-exec.c Peter Maydell
2016-05-16 17:54   ` Sergey Fedorov
2016-05-16 18:33     ` Peter Maydell
2016-05-16 20:24       ` Peter Maydell
2016-05-17 13:47     ` Peter Maydell

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=573A0AA6.4070803@gmail.com \
    --to=serge.fdrv@gmail.com \
    --cc=ehabkost@redhat.com \
    --cc=patches@linaro.org \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=riku.voipio@iki.fi \
    --cc=rth@twiddle.net \
    /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.