diff mbox series

[v5,04/67] accel/tcg: Fold cpu_exit_tb_from_sighandler into caller

Message ID 20211015041053.2769193-5-richard.henderson@linaro.org
State Superseded
Headers show
Series user-only: Cleanup SIGSEGV and SIGBUS handling | expand

Commit Message

Richard Henderson Oct. 15, 2021, 4:09 a.m. UTC
Remove the comment about siglongjmp.  We do use sigsetjmp
in the main cpu loop, but we do not save the signal mask
as most exits from the cpu loop do not require them.

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

---
 accel/tcg/user-exec.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

-- 
2.25.1

Comments

Warner Losh Oct. 15, 2021, 6:20 p.m. UTC | #1
On Thu, Oct 14, 2021 at 10:10 PM Richard Henderson <
richard.henderson@linaro.org> wrote:

> Remove the comment about siglongjmp.  We do use sigsetjmp

> in the main cpu loop, but we do not save the signal mask

> as most exits from the cpu loop do not require them.

>

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

> ---

>  accel/tcg/user-exec.c | 14 ++------------

>  1 file changed, 2 insertions(+), 12 deletions(-)

>


Reviewed-by: Warner Losh <imp@bsdimp.com>




> diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c

> index cb63e528c5..744af19397 100644

> --- a/accel/tcg/user-exec.c

> +++ b/accel/tcg/user-exec.c

> @@ -46,17 +46,6 @@ __thread uintptr_t helper_retaddr;

>

>  //#define DEBUG_SIGNAL

>

> -/* exit the current TB from a signal handler. The host registers are

> -   restored in a state compatible with the CPU emulator

> - */

> -static void QEMU_NORETURN cpu_exit_tb_from_sighandler(CPUState *cpu,

> -                                                      sigset_t *old_set)

> -{

> -    /* XXX: use siglongjmp ? */

> -    sigprocmask(SIG_SETMASK, old_set, NULL);

> -    cpu_loop_exit_noexc(cpu);

> -}

> -

>  /*

>   * Adjust the pc to pass to cpu_restore_state; return the memop type.

>   */

> @@ -155,7 +144,8 @@ bool handle_sigsegv_accerr_write(CPUState *cpu,

> sigset_t *old_set,

>           * currently executing TB was modified and must be exited

>           * immediately.  Clear helper_retaddr for next execution.

>           */

> -        cpu_exit_tb_from_sighandler(cpu, old_set);

> +        sigprocmask(SIG_SETMASK, old_set, NULL);

> +        cpu_loop_exit_noexc(cpu);

>          /* NORETURN */

>      default:

>          g_assert_not_reached();

> --

> 2.25.1

>

>
<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Oct 14, 2021 at 10:10 PM Richard Henderson &lt;<a href="mailto:richard.henderson@linaro.org">richard.henderson@linaro.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Remove the comment about siglongjmp.  We do use sigsetjmp<br>
in the main cpu loop, but we do not save the signal mask<br>
as most exits from the cpu loop do not require them.<br>
<br>
Signed-off-by: Richard Henderson &lt;<a href="mailto:richard.henderson@linaro.org" target="_blank">richard.henderson@linaro.org</a>&gt;<br>

---<br>
 accel/tcg/user-exec.c | 14 ++------------<br>
 1 file changed, 2 insertions(+), 12 deletions(-)<br></blockquote><div><br></div><div><div>Reviewed-by: Warner Losh &lt;<a href="mailto:imp@bsdimp.com">imp@bsdimp.com</a>&gt;</div><br class="gmail-Apple-interchange-newline"></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c<br>
index cb63e528c5..744af19397 100644<br>
--- a/accel/tcg/user-exec.c<br>
+++ b/accel/tcg/user-exec.c<br>
@@ -46,17 +46,6 @@ __thread uintptr_t helper_retaddr;<br>
<br>
 //#define DEBUG_SIGNAL<br>
<br>
-/* exit the current TB from a signal handler. The host registers are<br>
-   restored in a state compatible with the CPU emulator<br>
- */<br>
-static void QEMU_NORETURN cpu_exit_tb_from_sighandler(CPUState *cpu,<br>
-                                                      sigset_t *old_set)<br>
-{<br>
-    /* XXX: use siglongjmp ? */<br>
-    sigprocmask(SIG_SETMASK, old_set, NULL);<br>
-    cpu_loop_exit_noexc(cpu);<br>
-}<br>
-<br>
 /*<br>
  * Adjust the pc to pass to cpu_restore_state; return the memop type.<br>
  */<br>
@@ -155,7 +144,8 @@ bool handle_sigsegv_accerr_write(CPUState *cpu, sigset_t *old_set,<br>
          * currently executing TB was modified and must be exited<br>
          * immediately.  Clear helper_retaddr for next execution.<br>
          */<br>
-        cpu_exit_tb_from_sighandler(cpu, old_set);<br>
+        sigprocmask(SIG_SETMASK, old_set, NULL);<br>
+        cpu_loop_exit_noexc(cpu);<br>
         /* NORETURN */<br>
     default:<br>
         g_assert_not_reached();<br>
-- <br>
2.25.1<br>
<br>
</blockquote></div></div>
diff mbox series

Patch

diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c
index cb63e528c5..744af19397 100644
--- a/accel/tcg/user-exec.c
+++ b/accel/tcg/user-exec.c
@@ -46,17 +46,6 @@  __thread uintptr_t helper_retaddr;
 
 //#define DEBUG_SIGNAL
 
-/* exit the current TB from a signal handler. The host registers are
-   restored in a state compatible with the CPU emulator
- */
-static void QEMU_NORETURN cpu_exit_tb_from_sighandler(CPUState *cpu,
-                                                      sigset_t *old_set)
-{
-    /* XXX: use siglongjmp ? */
-    sigprocmask(SIG_SETMASK, old_set, NULL);
-    cpu_loop_exit_noexc(cpu);
-}
-
 /*
  * Adjust the pc to pass to cpu_restore_state; return the memop type.
  */
@@ -155,7 +144,8 @@  bool handle_sigsegv_accerr_write(CPUState *cpu, sigset_t *old_set,
          * currently executing TB was modified and must be exited
          * immediately.  Clear helper_retaddr for next execution.
          */
-        cpu_exit_tb_from_sighandler(cpu, old_set);
+        sigprocmask(SIG_SETMASK, old_set, NULL);
+        cpu_loop_exit_noexc(cpu);
         /* NORETURN */
     default:
         g_assert_not_reached();