From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36076) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VaKEu-0007wE-GT for qemu-devel@nongnu.org; Sun, 27 Oct 2013 02:54:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VaKEo-00059e-V0 for qemu-devel@nongnu.org; Sun, 27 Oct 2013 02:54:20 -0400 Received: from mail-ee0-x231.google.com ([2a00:1450:4013:c00::231]:38963) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VaKEo-00059a-K3 for qemu-devel@nongnu.org; Sun, 27 Oct 2013 02:54:14 -0400 Received: by mail-ee0-f49.google.com with SMTP id e52so1032030eek.36 for ; Sat, 26 Oct 2013 23:54:13 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <526CB88D.6030209@redhat.com> Date: Sun, 27 Oct 2013 07:54:05 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <20131023073949.GA4527@bom.nom.co> <52679025.3000106@redhat.com> <526830E6.6070904@weilnetz.de> <5268F8B4.7030105@redhat.com> <52694CC1.6040301@weilnetz.de> <5269958A.50400@redhat.com> <526B908B.20104@weilnetz.de> In-Reply-To: <526B908B.20104@weilnetz.de> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] qemu 1.6.1 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Weil Cc: "Michael W. Bombardieri" , qemu-devel@nongnu.org, Stefan Hajnoczi Il 26/10/2013 11:51, Stefan Weil ha scritto: > Am 24.10.2013 23:47, schrieb Paolo Bonzini: >> Il 24/10/2013 17:37, Stefan Weil ha scritto: >>> Yes, that works, too. It also fixes the problem with the assertion >>> (tested with Wine). >>> >>> No, we cannot remove from_, because the same interface is also used >>> for Linux and other hosts which don't have a 'current' variable. >>> Or we would have to call qemu_coroutine_self() to get the current >>> coroutine. >> Yes, I was thinking of using qemu_coroutine_self(). >> >> By the way, can you post the two assembly language outputs for just >> >> - CoroutineWin32 *from = DO_UPCAST(CoroutineWin32, base, from_); >> + CoroutineWin32 *from = DO_UPCAST(CoroutineWin32, base, current); >> >> which AIUI works and is enough to fix the bug? >> >> Paolo > > See disassembled code below. I removed compiler option -fstack-protector-all > to simplify the assembler code and tested that the result was not affected > by this removal. > > The C and assembler code from the test is also available at > http://qemu.weilnetz.de/test/coroutine-win32/. Here is the code with annotations broken works ------------------------------------------------------------------------- push %ebx sub $0x18,%esp sub $0x1c,%esp mov %ebx,0x14(%esp) mov %esi,0x18(%esp) movl $0x6d62a8,(%esp) movl $0x6d62a8,(%esp) mov 0x24(%esp),%ebx mov 0x24(%esp),%ebx ebx = to; call ___emutls_get_address call ___emutls_get_address eax = ¤t; mov (%eax),%esi esi = current; mov %ebx,(%eax) mov %ebx,(%eax) current = to; mov 0x28(%esp),%eax mov 0x28(%esp),%eax eax = action mov %eax,0x24(%ebx) mov %eax,0x24(%ebx) to->action = action mov 0x20(%ebx),%eax mov 0x20(%ebx),%eax eax = to->fiber mov %eax,(%esp) mov %eax,(%esp) "push" to->fiber call *0x835fc0 call *0x835fc0 SwitchToFiber(to->fiber) sub $0x4,%esp sub $0x4,%esp undo PASCAL calling convention ** mov 0x20(%esp),%eax eax = from mov 0x24(%eax),%eax mov 0x24(%esi),%eax eax = from->action mov 0x14(%esp),%ebx mov 0x18(%esp),%esi add $0x18,%esp add $0x1c,%esp pop %ebx ret ret I think the problem is that 0x20(%esp) gets somehow corrupted at the instruction I highlighted with **. The simplest fix then would be to add a barrier() before and after SwitchToFiber. Paolo