]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
KVM: opencode gfn_to_page in kvm_vm_fault
authorMarcelo Tosatti <mtosatti@redhat.com>
Tue, 16 Sep 2008 23:54:46 +0000 (20:54 -0300)
committerAvi Kivity <avi@redhat.com>
Wed, 15 Oct 2008 12:25:05 +0000 (14:25 +0200)
kvm_vm_fault is invoked with mmap_sem held in read mode. Since gfn_to_page
will be converted to get_user_pages_fast, which requires this lock NOT
to be held, switch to opencoded get_user_pages.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
virt/kvm/kvm_main.c

index f42d5c2a396d44b89be0b57b10d032a98b36d294..2907d05cfcc348a4dd32aeab919b5a62dcaf1ab6 100644 (file)
@@ -1394,17 +1394,22 @@ out:
 
 static int kvm_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
 {
+       struct page *page[1];
+       unsigned long addr;
+       int npages;
+       gfn_t gfn = vmf->pgoff;
        struct kvm *kvm = vma->vm_file->private_data;
-       struct page *page;
 
-       if (!kvm_is_visible_gfn(kvm, vmf->pgoff))
+       addr = gfn_to_hva(kvm, gfn);
+       if (kvm_is_error_hva(addr))
                return VM_FAULT_SIGBUS;
-       page = gfn_to_page(kvm, vmf->pgoff);
-       if (is_error_page(page)) {
-               kvm_release_page_clean(page);
+
+       npages = get_user_pages(current, current->mm, addr, 1, 1, 0, page,
+                               NULL);
+       if (unlikely(npages != 1))
                return VM_FAULT_SIGBUS;
-       }
-       vmf->page = page;
+
+       vmf->page = page[0];
        return 0;
 }