From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH 2/2] KVM: x86 emulator: add decoding of CMPXCHG8B dst operand. Date: Sun, 21 Mar 2010 16:41:24 +0200 Message-ID: <4BA63014.9060304@redhat.com> References: <1269169701-22306-1-git-send-email-gleb@redhat.com> <1269169701-22306-2-git-send-email-gleb@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: mtosatti@redhat.com, kvm@vger.kernel.org To: Gleb Natapov Return-path: Received: from mx1.redhat.com ([209.132.183.28]:4952 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752983Ab0CUOlZ (ORCPT ); Sun, 21 Mar 2010 10:41:25 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o2LEfPtR026610 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 21 Mar 2010 10:41:25 -0400 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o2LEfOjS013897 for ; Sun, 21 Mar 2010 10:41:25 -0400 In-Reply-To: <1269169701-22306-2-git-send-email-gleb@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 03/21/2010 01:08 PM, Gleb Natapov wrote: > Decode CMPXCHG8B destination operand in decoding stage. Fixes regression > introduced by "If LOCK prefix is used dest arg should be memory" commit. > This commit relies on dst operand be decoded at the beginning of an > instruction emulation. > > @@ -1719,15 +1719,12 @@ static inline int emulate_grp9(struct x86_emulate_ctxt *ctxt, > c->regs[VCPU_REGS_RAX] = (u32) (old>> 0); > c->regs[VCPU_REGS_RDX] = (u32) (old>> 32); > ctxt->eflags&= ~EFLG_ZF; > - > } else { > - new = ((u64)c->regs[VCPU_REGS_RCX]<< 32) | > + c->dst.val = ((u64)c->regs[VCPU_REGS_RCX]<< 32) | > (u32) c->regs[VCPU_REGS_RBX]; > > - rc = ops->cmpxchg_emulated(c->modrm_ea,&old,&new, 8, ctxt->vcpu); > - if (rc != X86EMUL_CONTINUE) > - return rc; > ctxt->eflags |= EFLG_ZF; > + c->lock_prefix = 1; > Why is this bit needed? cmpxchg64b without lock is valid and racy, but the guest may know it is safe. -- error compiling committee.c: too many arguments to function