From: Muli Ben-Y. <mu...@il...> - 2008-05-11 08:49:21
|
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 |