Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=539cb6608ca804e7805d8e88c83377d991a552b1
Commit:     539cb6608ca804e7805d8e88c83377d991a552b1
Parent:     f9d46eb0e4a5b5e0926ca61c19f8c8bbb9496b28
Author:     Izik Eidus <[EMAIL PROTECTED]>
AuthorDate: Sun Nov 11 22:05:04 2007 +0200
Committer:  Avi Kivity <[EMAIL PROTECTED]>
CommitDate: Wed Jan 30 17:53:01 2008 +0200

    KVM: introduce gfn_to_hva()
    
    Convert a guest frame number to the corresponding host virtual address.
    
    Signed-off-by: Izik Eidus <[EMAIL PROTECTED]>
    Signed-off-by: Avi Kivity <[EMAIL PROTECTED]>
---
 drivers/kvm/kvm_main.c |   25 +++++++++++++++++--------
 1 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index dfb65e2..04544ae 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -559,28 +559,37 @@ int kvm_is_visible_gfn(struct kvm *kvm, gfn_t gfn)
 }
 EXPORT_SYMBOL_GPL(kvm_is_visible_gfn);
 
+static unsigned long gfn_to_hva(struct kvm *kvm, gfn_t gfn)
+{
+       struct kvm_memory_slot *slot;
+
+       gfn = unalias_gfn(kvm, gfn);
+       slot = __gfn_to_memslot(kvm, gfn);
+       if (!slot)
+               return bad_hva();
+       return (slot->userspace_addr + (gfn - slot->base_gfn) * PAGE_SIZE);
+}
+
 /*
  * Requires current->mm->mmap_sem to be held
  */
 static struct page *__gfn_to_page(struct kvm *kvm, gfn_t gfn)
 {
-       struct kvm_memory_slot *slot;
        struct page *page[1];
+       unsigned long addr;
        int npages;
 
        might_sleep();
 
-       gfn = unalias_gfn(kvm, gfn);
-       slot = __gfn_to_memslot(kvm, gfn);
-       if (!slot) {
+       addr = gfn_to_hva(kvm, gfn);
+       if (kvm_is_error_hva(addr)) {
                get_page(bad_page);
                return bad_page;
        }
 
-       npages = get_user_pages(current, current->mm,
-                               slot->userspace_addr
-                               + (gfn - slot->base_gfn) * PAGE_SIZE, 1,
-                               1, 1, page, NULL);
+       npages = get_user_pages(current, current->mm, addr, 1, 1, 1, page,
+                               NULL);
+
        if (npages != 1) {
                get_page(bad_page);
                return bad_page;
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to