KVM: MMU: fix apf prefault if nested guest is enabled
authorXiao Guangrong <xiaoguangrong@cn.fujitsu.com>
Fri, 12 Nov 2010 06:49:55 +0000 (14:49 +0800)
committerAvi Kivity <avi@redhat.com>
Wed, 12 Jan 2011 09:29:14 +0000 (11:29 +0200)
If apf is generated in L2 guest and is completed in L1 guest, it will
prefault this apf in L1 guest's mmu context.

Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/mmu.c
arch/x86/kvm/x86.c

index 116dac5e01d6cb8ce46ec2f4bfdd37c572798241..f1e8d5b99f5d01c393b9d4fc3255e1ebda51dec4 100644 (file)
@@ -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;
index db0fd555a5a2844193d399e1569707029bea3bc3..ab100a7e0c494b40aa559d08288e97b820cff9c4 100644 (file)
@@ -2609,6 +2609,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);
 }
index 9b875ff05410f01875e2a7e96322d63cc6268cdb..c673e726fbdb26639749e9c2f40da3ffc7842ee9 100644 (file)
@@ -6168,7 +6168,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);