From patchwork Thu Jul 15 00:51:58 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yongjun X-Patchwork-Id: 112121 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o6F0smrp020619 for ; Thu, 15 Jul 2010 00:55:18 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757949Ab0GOAyb (ORCPT ); Wed, 14 Jul 2010 20:54:31 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:63481 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1757940Ab0GOAya (ORCPT ); Wed, 14 Jul 2010 20:54:30 -0400 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id D7DF717012A; Thu, 15 Jul 2010 08:54:28 +0800 (CST) Received: from fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id o6F0pgj8028287; Thu, 15 Jul 2010 08:51:42 +0800 Received: from [10.167.141.76] (unknown [10.167.141.76]) by fnst.cn.fujitsu.com (Postfix) with ESMTPA id E46FB1CC1FD; Thu, 15 Jul 2010 08:54:50 +0800 (CST) Message-ID: <4C3E5BAE.1010306@cn.fujitsu.com> Date: Thu, 15 Jul 2010 08:51:58 +0800 From: Wei Yongjun User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.10) Gecko/20100528 Thunderbird/3.0.5 MIME-Version: 1.0 To: Marcelo Tosatti CC: Avi Kivity , kvm@vger.kernel.org Subject: [PATCHv2] KVM: x86 emulator: fix xchg instruction emulation References: <4C3D47DD.4010108@cn.fujitsu.com> <20100714163752.GA1100@amt.cnet> In-Reply-To: <20100714163752.GA1100@amt.cnet> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 15 Jul 2010 00:55:59 +0000 (UTC) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 86c8102..84bfb51 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -3562,6 +3562,10 @@ 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)) { + kvm_release_page_clean(page); + goto emul_write; + } kaddr = kmap_atomic(page, KM_USER0); kaddr += offset_in_page(gpa);