diff options
author | Avi Kivity <avi@qumranet.com> | 2007-03-30 07:02:32 -0400 |
---|---|---|
committer | Avi Kivity <avi@qumranet.com> | 2007-05-03 03:52:28 -0400 |
commit | 954bbbc236afe23b368abdf4942f313a5f6e1d50 (patch) | |
tree | 4c990bff08f7a9a13980deb68a85e091065bb1ec /drivers/kvm/kvm.h | |
parent | e0fa826f969c262c23908953bf85add487cc2e6c (diff) |
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/kvm.h')
-rw-r--r-- | drivers/kvm/kvm.h | 12 |
1 files changed, 1 insertions, 11 deletions
diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h index 59357bea5b61..d19985a5508a 100644 --- a/drivers/kvm/kvm.h +++ b/drivers/kvm/kvm.h | |||
@@ -443,11 +443,7 @@ void kvm_emulator_want_group7_invlpg(void); | |||
443 | 443 | ||
444 | extern hpa_t bad_page_address; | 444 | extern hpa_t bad_page_address; |
445 | 445 | ||
446 | static inline struct page *gfn_to_page(struct kvm_memory_slot *slot, gfn_t gfn) | 446 | struct page *gfn_to_page(struct kvm *kvm, gfn_t gfn); |
447 | { | ||
448 | return slot->phys_mem[gfn - slot->base_gfn]; | ||
449 | } | ||
450 | |||
451 | struct kvm_memory_slot *gfn_to_memslot(struct kvm *kvm, gfn_t gfn); | 447 | struct kvm_memory_slot *gfn_to_memslot(struct kvm *kvm, gfn_t gfn); |
452 | void mark_page_dirty(struct kvm *kvm, gfn_t gfn); | 448 | void mark_page_dirty(struct kvm *kvm, gfn_t gfn); |
453 | 449 | ||
@@ -523,12 +519,6 @@ static inline int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t gva, | |||
523 | return vcpu->mmu.page_fault(vcpu, gva, error_code); | 519 | return vcpu->mmu.page_fault(vcpu, gva, error_code); |
524 | } | 520 | } |
525 | 521 | ||
526 | static inline struct page *_gfn_to_page(struct kvm *kvm, gfn_t gfn) | ||
527 | { | ||
528 | struct kvm_memory_slot *slot = gfn_to_memslot(kvm, gfn); | ||
529 | return (slot) ? slot->phys_mem[gfn - slot->base_gfn] : NULL; | ||
530 | } | ||
531 | |||
532 | static inline int is_long_mode(struct kvm_vcpu *vcpu) | 522 | static inline int is_long_mode(struct kvm_vcpu *vcpu) |
533 | { | 523 | { |
534 | #ifdef CONFIG_X86_64 | 524 | #ifdef CONFIG_X86_64 |