From patchwork Tue Mar 1 05:07:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Weil X-Patchwork-Id: 8461831 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5F9A1C0553 for ; Tue, 1 Mar 2016 05:08:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BC3202034C for ; Tue, 1 Mar 2016 05:08:19 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9E4AC2034B for ; Tue, 1 Mar 2016 05:08:18 +0000 (UTC) Received: from localhost ([::1]:40854 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aacXh-0006yH-Hf for patchwork-qemu-devel@patchwork.kernel.org; Tue, 01 Mar 2016 00:08:17 -0500 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 Received: by qemu.weilnetz.de (Postfix, from userid 1000) id 2DE5617F64F; Tue, 1 Mar 2016 06:08:02 +0100 (CET) From: Stefan Weil To: QEMU Developer , Andrew Baumann Date: Tue, 1 Mar 2016 06:07:49 +0100 Message-Id: <1456808869-20286-1-git-send-email-sw@weilnetz.de> X-Mailer: git-send-email 2.1.4 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 37.221.198.45 Cc: Paolo Bonzini , Stefan Weil , Richard Henderson , Peter Crosthwaite Subject: [Qemu-devel] [PATCH] Use special code for sigsetjmp only in cpu-exec.c X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The rest of the code can use longjmp with stack unwinding. Signed-off-by: Stefan Weil Tested-by: Andrew Baumann --- 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