aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/kvm_host.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/kvm_host.h')
-rw-r--r--include/linux/kvm_host.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index eada8e69fe58..9698080c902b 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -651,6 +651,31 @@ static inline void kvm_guest_exit(void)
651 current->flags &= ~PF_VCPU; 651 current->flags &= ~PF_VCPU;
652} 652}
653 653
654/*
655 * search_memslots() and __gfn_to_memslot() are here because they are
656 * used in non-modular code in arch/powerpc/kvm/book3s_hv_rm_mmu.c.
657 * gfn_to_memslot() itself isn't here as an inline because that would
658 * bloat other code too much.
659 */
660static inline struct kvm_memory_slot *
661search_memslots(struct kvm_memslots *slots, gfn_t gfn)
662{
663 struct kvm_memory_slot *memslot;
664
665 kvm_for_each_memslot(memslot, slots)
666 if (gfn >= memslot->base_gfn &&
667 gfn < memslot->base_gfn + memslot->npages)
668 return memslot;
669
670 return NULL;
671}
672
673static inline struct kvm_memory_slot *
674__gfn_to_memslot(struct kvm_memslots *slots, gfn_t gfn)
675{
676 return search_memslots(slots, gfn);
677}
678
654static inline int memslot_id(struct kvm *kvm, gfn_t gfn) 679static inline int memslot_id(struct kvm *kvm, gfn_t gfn)
655{ 680{
656 return gfn_to_memslot(kvm, gfn)->id; 681 return gfn_to_memslot(kvm, gfn)->id;