Received: from eggs.gnu.org ([2001:4830:134:3::10]:58672) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aacXb-0006yA-3C for qemu-devel@nongnu.org; Tue, 01 Mar 2016 00:08:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aacXW-00052L-5A for qemu-devel@nongnu.org; Tue, 01 Mar 2016 00:08:11 -0500 Received: from qemu.weilnetz.de ([37.221.198.45]:53009) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aacXV-000525-VX for qemu-devel@nongnu.org; Tue, 01 Mar 2016 00:08:06 -0500 From: Stefan Weil Date: Tue, 1 Mar 2016 06:07:49 +0100 Message-Id: <1456808869-20286-1-git-send-email-sw@weilnetz.de> Subject: [Qemu-devel] [PATCH] Use special code for sigsetjmp only in cpu-exec.c List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 --- 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