From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: Re: [PATCH] KVM: x86 emulator: fix xchg instruction emulation Date: Wed, 14 Jul 2010 13:37:52 -0300 Message-ID: <20100714163752.GA1100@amt.cnet> References: <4C3D47DD.4010108@cn.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Avi Kivity , kvm@vger.kernel.org To: Wei Yongjun Return-path: Received: from mx1.redhat.com ([209.132.183.28]:5386 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751565Ab0GNRMs (ORCPT ); Wed, 14 Jul 2010 13:12:48 -0400 Content-Disposition: inline In-Reply-To: <4C3D47DD.4010108@cn.fujitsu.com> Sender: kvm-owner@vger.kernel.org List-ID: On Wed, Jul 14, 2010 at 01:15:09PM +0800, Wei Yongjun wrote: > If the destination is a memory operand and the memory > cannot map to a valid page, the xchg instruction emulation > will fail. If so, we should emulate exchange as write > to fix it. > > Signed-off-by: Wei Yongjun > --- > arch/x86/kvm/x86.c | 2 ++ > 1 files changed, 2 insertions(+), 0 deletions(-) > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index d94811e..ac63f6f 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -3560,6 +3560,8 @@ static int emulator_cmpxchg_emulated(unsigned long addr, > goto emul_write; > > page = gfn_to_page(vcpu->kvm, gpa >> PAGE_SHIFT); > + if (is_error_page(page)) > + goto emul_write; Forgot to release page.