diff options
author | Avi Kivity <avi@qumranet.com> | 2007-03-30 14:02:32 +0300 |
---|---|---|
committer | Avi Kivity <avi@qumranet.com> | 2007-05-03 10:52:28 +0300 |
commit | 954bbbc236afe23b368abdf4942f313a5f6e1d50 (patch) | |
tree | 4c990bff08f7a9a13980deb68a85e091065bb1ec /drivers/kvm/mmu.c | |
parent | e0fa826f969c262c23908953bf85add487cc2e6c (diff) | |
download | linux-stable-954bbbc236afe23b368abdf4942f313a5f6e1d50.tar.gz linux-stable-954bbbc236afe23b368abdf4942f313a5f6e1d50.tar.bz2 linux-stable-954bbbc236afe23b368abdf4942f313a5f6e1d50.zip |
KVM: Simply gfn_to_page()
Mapping a guest page to a host page is a common operation. Currently,
one has first to find the memory slot where the page belongs (gfn_to_memslot),
then locate the page itself (gfn_to_page()).
This is clumsy, and also won't work well with memory aliases. So simplify
gfn_to_page() not to require memory slot translation first, and instead do it
internally.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm/mmu.c')
-rw-r--r-- | drivers/kvm/mmu.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/drivers/kvm/mmu.c b/drivers/kvm/mmu.c index 376800a33968..8bdb9ca1811c 100644 --- a/drivers/kvm/mmu.c +++ b/drivers/kvm/mmu.c @@ -390,13 +390,11 @@ static void rmap_write_protect(struct kvm_vcpu *vcpu, u64 gfn) { struct kvm *kvm = vcpu->kvm; struct page *page; - struct kvm_memory_slot *slot; struct kvm_rmap_desc *desc; u64 *spte; - slot = gfn_to_memslot(kvm, gfn); - BUG_ON(!slot); - page = gfn_to_page(slot, gfn); + page = gfn_to_page(kvm, gfn); + BUG_ON(!page); while (page_private(page)) { if (!(page_private(page) & 1)) @@ -711,14 +709,12 @@ hpa_t safe_gpa_to_hpa(struct kvm_vcpu *vcpu, gpa_t gpa) hpa_t gpa_to_hpa(struct kvm_vcpu *vcpu, gpa_t gpa) { - struct kvm_memory_slot *slot; struct page *page; ASSERT((gpa & HPA_ERR_MASK) == 0); - slot = gfn_to_memslot(vcpu->kvm, gpa >> PAGE_SHIFT); - if (!slot) + page = gfn_to_page(vcpu->kvm, gpa >> PAGE_SHIFT); + if (!page) return gpa | HPA_ERR_MASK; - page = gfn_to_page(slot, gpa >> PAGE_SHIFT); return ((hpa_t)page_to_pfn(page) << PAGE_SHIFT) | (gpa & (PAGE_SIZE-1)); } |