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
_______________________________________________
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel

Reply via email to