qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] Use special code for sigsetjmp only in cpu-exec.c
@ 2016-03-01  5:07 Stefan Weil
  2016-03-01  6:23 ` Andrew Baumann
  2016-03-01  9:59 ` Peter Maydell
  0 siblings, 2 replies; 10+ messages in thread
From: Stefan Weil @ 2016-03-01  5:07 UTC (permalink / raw)
  To: QEMU Developer, Andrew Baumann
  Cc: Paolo Bonzini, Stefan Weil, Richard Henderson, Peter Crosthwaite

The rest of the code can use longjmp with stack unwinding.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
---

This is a bug fix needed for 64 bit Windows.

QEMU for Windows currently gets the wrong definition for
sigsetjmp. It uses stack unwinding for longjmp which results
in a crash when it is called from generated code.

Thanks to Andrew Baumann for his reminder that this patch was
still missing. Andrew, could you please test it with your
RPi emulation?

Regards,
Stefan

 cpu-exec.c                | 9 +++++++++
 include/sysemu/os-win32.h | 8 --------
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/cpu-exec.c b/cpu-exec.c
index fd92452..6a725e0 100644
--- a/cpu-exec.c
+++ b/cpu-exec.c
@@ -33,6 +33,15 @@
 #endif
 #include "sysemu/replay.h"
 
+#if defined(_WIN64)
+/* On w64, sigsetjmp is implemented by _setjmp which needs a second parameter.
+ * If this parameter is NULL, longjump does no stack unwinding.
+ * That is what we need for QEMU. Passing the value of register rsp (default)
+ * lets longjmp try a stack unwinding which will crash with generated code. */
+#undef sigsetjmp
+#define sigsetjmp(env, savesigs) _setjmp(env, NULL)
+#endif
+
 /* -icount align implementation. */
 
 typedef struct SyncClocks {
diff --git a/include/sysemu/os-win32.h b/include/sysemu/os-win32.h
index fbed346..b151e74 100644
--- a/include/sysemu/os-win32.h
+++ b/include/sysemu/os-win32.h
@@ -55,14 +55,6 @@
 # define EWOULDBLOCK  WSAEWOULDBLOCK
 #endif
 
-#if defined(_WIN64)
-/* On w64, setjmp is implemented by _setjmp which needs a second parameter.
- * If this parameter is NULL, longjump does no stack unwinding.
- * That is what we need for QEMU. Passing the value of register rsp (default)
- * lets longjmp try a stack unwinding which will crash with generated code. */
-# undef setjmp
-# define setjmp(env) _setjmp(env, NULL)
-#endif
 /* QEMU uses sigsetjmp()/siglongjmp() as the portable way to specify
  * "longjmp and don't touch the signal masks". Since we know that the
  * savemask parameter will always be zero we can safely define these
-- 
2.1.4

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

end of thread, other threads:[~2016-03-01 19:08 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-01  5:07 [Qemu-devel] [PATCH] Use special code for sigsetjmp only in cpu-exec.c Stefan Weil
2016-03-01  6:23 ` Andrew Baumann
2016-03-01  9:59 ` Peter Maydell
2016-03-01 11:54   ` Stefan Weil
2016-03-01 12:22     ` Peter Maydell
2016-03-01 13:15       ` Stefan Weil
2016-03-01 17:46         ` Andrew Baumann
2016-03-01 17:53           ` Paolo Bonzini
2016-03-01 17:54             ` Peter Maydell
2016-03-01 19:08               ` Stefan Weil

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