From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wei Yongjun Subject: [PATCH] KVM: x86 emulator: fix xchg instruction emulation Date: Wed, 14 Jul 2010 13:15:09 +0800 Message-ID: <4C3D47DD.4010108@cn.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset=GB2312 Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org To: Avi Kivity Return-path: Received: from cn.fujitsu.com ([222.73.24.84]:50283 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1750983Ab0GNFRh (ORCPT ); Wed, 14 Jul 2010 01:17:37 -0400 Sender: kvm-owner@vger.kernel.org List-ID: 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; kaddr = kmap_atomic(page, KM_USER0); kaddr += offset_in_page(gpa); -- 1.7.0.4