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:46:24 +0200 Message-ID: <4BA63140.9050809@redhat.com> References: <1269169701-22306-1-git-send-email-gleb@redhat.com> <1269169701-22306-2-git-send-email-gleb@redhat.com> <4BA63014.9060304@redhat.com> <20100321144425.GG13522@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]:5268 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752983Ab0CUOq0 (ORCPT ); Sun, 21 Mar 2010 10:46:26 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o2LEkQWk027908 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 21 Mar 2010 10:46:26 -0400 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o2LEkPrY006774 for ; Sun, 21 Mar 2010 10:46:26 -0400 In-Reply-To: <20100321144425.GG13522@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 03/21/2010 04:44 PM, Gleb Natapov wrote: > On Sun, Mar 21, 2010 at 04:41:24PM +0200, Avi Kivity wrote: > >> 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. >> >> > Agree. Before this patch cmpxchg8b emulation always called > cmpxchg_emulated(), so to be extra careful I wanted to preserve old > behaviour. Resend the patch without this line? > Better a 3/2 that removes it. So we have a large patch that just transforms code, and a small patch that corrects an earlier bug. May help a bisector one day. -- error compiling committee.c: too many arguments to function