From patchwork Fri Nov 12 06:49:55 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 319072 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oAC713bv026338 for ; Fri, 12 Nov 2010 07:01:04 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751771Ab0KLHAS (ORCPT ); Fri, 12 Nov 2010 02:00:18 -0500 Received: from cn.fujitsu.com ([222.73.24.84]:49837 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1751793Ab0KLG7s (ORCPT ); Fri, 12 Nov 2010 01:59:48 -0500 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id 7623F17064E; Fri, 12 Nov 2010 14:59:47 +0800 (CST) Received: from mailserver.fnst.cn.fujitus.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id oAC6tKER007991; Fri, 12 Nov 2010 14:55:25 +0800 Received: from [10.167.225.99] ([10.167.225.99]) by mailserver.fnst.cn.fujitus.com (Lotus Domino Release 8.5.1FP4) with ESMTP id 2010111214460181-53726 ; Fri, 12 Nov 2010 14:46:01 +0800 Message-ID: <4CDCE393.9040408@cn.fujitsu.com> Date: Fri, 12 Nov 2010 14:49:55 +0800 From: Xiao Guangrong User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.11) Gecko/20100713 Thunderbird/3.0.6 MIME-Version: 1.0 To: Avi Kivity CC: Marcelo Tosatti , Gleb Natapov , LKML , KVM Subject: [PATCH v2 4/5] KVM: MMU: fix apf prefault if nested guest is enabled References: <4CDCE2B0.7000601@cn.fujitsu.com> In-Reply-To: <4CDCE2B0.7000601@cn.fujitsu.com> X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2010-11-12 14:46:01, Serialize by Router on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2010-11-12 15:00:13, Serialize complete at 2010-11-12 15:00:13 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 (demeter1.kernel.org [140.211.167.41]); Fri, 12 Nov 2010 07:01:04 +0000 (UTC) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 7f20f2c..b04c0fa 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -600,6 +600,7 @@ struct kvm_x86_ops { struct kvm_arch_async_pf { u32 token; gfn_t gfn; + bool direct_map; }; extern struct kvm_x86_ops *kvm_x86_ops; diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 5ee5b97..bdb9fa9 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -2608,6 +2608,7 @@ static int kvm_arch_setup_async_pf(struct kvm_vcpu *vcpu, gva_t gva, gfn_t gfn) struct kvm_arch_async_pf arch; arch.token = (vcpu->arch.apf.id++ << 12) | vcpu->vcpu_id; arch.gfn = gfn; + arch.direct_map = vcpu->arch.mmu.direct_map; return kvm_setup_async_pf(vcpu, gva, gfn, &arch); } diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index c071d73..003a0ca 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -6169,7 +6169,8 @@ void kvm_arch_async_page_ready(struct kvm_vcpu *vcpu, struct kvm_async_pf *work) { int r; - if (!vcpu->arch.mmu.direct_map || is_error_page(work->page)) + if (!vcpu->arch.mmu.direct_map || !work->arch.direct_map || + is_error_page(work->page)) return; r = kvm_mmu_reload(vcpu);