From mboxrd@z Thu Jan 1 00:00:00 1970 From: Muli Ben-Yehuda Subject: Re: [RFC] [VTD][patch 1/3] vt-d support for pci passthrough: kvm-vtd--kernel.patch Date: Sun, 11 May 2008 11:53:03 +0300 Message-ID: <20080511085303.GR7484@il.ibm.com> References: <1FE6DD409037234FAB833C420AA843EC01438CB3@orsmsx424.amr.corp.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: Chris Wright , kvm-devel@lists.sourceforge.net, Avi Kivity , Ben-Ami Yassour1 To: "Kay, Allen M" Return-path: Content-Disposition: inline In-Reply-To: <1FE6DD409037234FAB833C420AA843EC01438CB3@orsmsx424.amr.corp.intel.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 On Mon, May 05, 2008 at 02:36:23PM -0700, Kay, Allen M wrote: > + for (j = 0; j < npages; j++) { > + gpa += PAGE_SIZE; > + page = gfn_to_page(kvm, gpa >> PAGE_SHIFT); > + hpa = page_to_phys(page); > + domain_page_mapping(kvm->arch.domain, gpa, hpa, > PAGE_SIZE, > + DMA_PTE_READ | DMA_PTE_WRITE); > + vma = find_vma(current->mm, gpa); > + if (!vma) > + return 1; > + write = (vma->vm_flags & VM_WRITE) != 0; > + get_user_pages(current, current->mm, gpa, > + PAGE_SIZE, write, 0, NULL, NULL); > + } > + return 0; > +} get_user_pages can fail. We should first try to fault in the pages and only if succesfull map them in the IOMMU. Also, you need to protect against the vma going away here. Cheers, Muli ------------------------------------------------------------------------- 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