From: Keir Fraser Subject: Re: [Patch] cmpxchg emulation returns wrong ZF Date: Thu, 06 Aug 2009 09:12:48 +0100 Message-ID: References: <4A7A7CEB.9080702@ts.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <4A7A7CEB.9080702@ts.fujitsu.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Juergen Gross , "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org On 06/08/2009 07:49, "Juergen Gross" wrote: > attached patch corrects a bug in cmpxchg emulation in the hypervisor. > > BS2000 running as HVM-domain on 4 vcpus (no HAP) hit an error due to this bug > after several days. You'll have to give more details as I don't see the bug that this patch fixes. Changeset comment says "ops->cmpxchg might return X86EMUL_CMPXCHG_FAILED if the addressed memory location changed after checking the old contents. In this case ZF was not changed and could remain 1 instead of being set to 0." Now, firstly the patch does not directly alter ZF when X86EMUL_CMPXCHG_FAILED. Secondly, the X86EMUL_CMPXCHG_FAILED is supposed to be safe to propagate to the caller of x86_emulate(), who can then choose to retry. Most callers implicitly retry by treating similar to X86EMUL_OKAY -- returning to guest context where the instruction gets reattempted due to EIP not having changed. That last point is crucial to the correctness of course: Indeed we are not messing with EFLAGS.ZF on that return code, but then we are not updating *any* state (including the program counter) so it is supposed to be as if the instruction was not executed (which is obviously correct, since it wasn't). -- Keir