Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O5PwQ-0006Xd-5e for qemu-devel@nongnu.org; Fri, 23 Apr 2010 16:57:38 -0400 Received: from [140.186.70.92] (port=48097 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O5PwO-0006XL-Km for qemu-devel@nongnu.org; Fri, 23 Apr 2010 16:57:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O5PwM-0003hs-Ar for qemu-devel@nongnu.org; Fri, 23 Apr 2010 16:57:36 -0400 Received: from cantor2.suse.de ([195.135.220.15]:53082 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O5PwM-0003hS-4r for qemu-devel@nongnu.org; Fri, 23 Apr 2010 16:57:34 -0400 Subject: Re: [Qemu-devel] Atomicity of i386 guest atomic instructions Mime-Version: 1.0 (Apple Message framework v1078) Content-Type: text/plain; charset=us-ascii From: Alexander Graf In-Reply-To: <4BD1D883.9080601@jermar.eu> Date: Fri, 23 Apr 2010 22:57:29 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: References: <4BD1D883.9080601@jermar.eu> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jakub Jermar Cc: qemu-devel@nongnu.org On 23.04.2010, at 19:27, Jakub Jermar wrote: > Hello, >=20 > is it at least theoretically possible that the guest atomic = instructions (e.g. XCHG, > LOCK CMPXCHG) on target-i386 are somehow not atomic when = simulated/translated by Qemu? >=20 > I am observing a problem with one of my HelenOS/ia32 builds which = suggests me that for > some reason HelenOS spinlocks are not working as expected, because at = one point there are=20 > two CPUs in one spinlock-protected critical section. I have been = looking into this for > several days and could not find anything on the HelenOS side. The = assembly code which > does the locking looks good and the respective spinlock is not = corrupted. The problem > shows in about 2/3 of all dual-CPU boots. When it shows, the stack = trace is always the > same. When it does not show during the boot, the system continues to = run stable and I > never see the problem after the system started up. >=20 > I reproduced this on Qemu 0.11.1 and 0.12.2-3 without kvm, both on = ia32 and amd64 hosts. They should be atomic. TCG SMP swaps between different vCPUs only after = translation blocks are done. In fact, the only way I'm aware of to stop = the execution of a TB mid-way is a page fault. You can as always check things with the -d parameter. Alex