From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH] Handle vma regions with no backing page (v2) Date: Wed, 30 Apr 2008 11:59:47 +0300 Message-ID: <48183503.9050005@qumranet.com> References: <1209496160-20482-1-git-send-email-aliguori@us.ibm.com> <20080430061140.GE7378@il.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: kvm-devel@lists.sourceforge.net, Andrea Arcangeli , Ben-Ami Yassour1 To: Muli Ben-Yehuda Return-path: In-Reply-To: <20080430061140.GE7378@il.ibm.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces@lists.sourceforge.net Errors-To: kvm-devel-bounces@lists.sourceforge.net List-Id: kvm.vger.kernel.org Muli Ben-Yehuda wrote: >> @@ -544,19 +545,35 @@ pfn_t gfn_to_pfn(struct kvm *kvm, gfn_t gfn) >> npages = get_user_pages(current, current->mm, addr, 1, 1, 1, page, >> NULL); >> >> - if (npages != 1) { >> - get_page(bad_page); >> - return page_to_pfn(bad_page); >> - } >> + if (unlikely(npages != 1)) { >> + struct vm_area_struct *vma; >> >> - return page_to_pfn(page[0]); >> + vma = find_vma(current->mm, addr); >> + if (vma == NULL || addr >= vma->vm_start || >> + !(vma->vm_flags & VM_PFNMAP)) { >> > > Isn't the check for addr backwards here? For the VMA we would like to > to find, vma->vm_start <= addr < vma->vm_end. > > The code is not trying to find a vma for the address, but a vma for the address which also has VM_PFNMAP set. The cases for vma not found, or vma found, but not VM_PFNMAP, are folded together. -- Any sufficiently difficult bug is indistinguishable from a feature. ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone