On 08/01/20 21:24, Sean Christopherson wrote: > - level = host_pfn_mapping_level(vcpu, gfn, pfn); > + slot = kvm_vcpu_gfn_to_memslot(vcpu, gfn); > + if (!memslot_valid_for_gpte(slot, true)) > + return PT_PAGE_TABLE_LEVEL; Following up on my remark to patch 7, this can also use gfn_to_memslot_dirty_bitmap. Paolo > + > + max_level = min(max_level, kvm_x86_ops->get_lpage_level()); > + for ( ; max_level > PT_PAGE_TABLE_LEVEL; max_level--) { > + if (!__mmu_gfn_lpage_is_disallowed(gfn, max_level, slot)) > + break; > + } > + > + if (max_level == PT_PAGE_TABLE_LEVEL) > + return PT_PAGE_TABLE_LEVEL; > + > + level = host_pfn_mapping_level(vcpu, gfn, pfn, slot); > if (level == PT_PAGE_TABLE_LEVEL) > return level; > > @@ -4182,8 +4172,6 @@ static int direct_page_fault(struct kvm_vcpu *vcpu, gpa_t gpa, u32 error_code, > if (lpage_disallowed) > max_level = PT_PAGE_TABLE_LEVEL; > > - max_level = max_mapping_level(vcpu, gfn, max_level); > - > if (fast_page_fault(vcpu, gpa, error_code)) > return RET_PF_RETRY; > > diff --git a/arch/x86/kvm/mmu/paging_tmpl.h b/arch/x86/kvm/mmu/paging_tmpl.h > index 0560982eda8b..ea174d85700a 100644 > --- a/arch/x86/kvm/mmu/paging_tmpl.h > +++ b/arch/x86/kvm/mmu/paging_tmpl.h > @@ -817,8 +817,6 @@ static int FNAME(page_fault)(struct kvm_vcpu *vcpu, gpa_t addr, u32 error_code, > else > max_level = walker.level; > > - max_level = max_mapping_level(vcpu, walker.gfn, max_level); > - > mmu_seq = vcpu->kvm->mmu_notifier_seq; > smp_rmb(); > >