aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/kvm_host.h2
-rw-r--r--virt/kvm/kvm_main.c16
2 files changed, 10 insertions, 8 deletions
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 10c1146cd009..b3b7598b4d94 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -288,6 +288,8 @@ int kvm_cpu_has_interrupt(struct kvm_vcpu *v);
288int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu); 288int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu);
289void kvm_vcpu_kick(struct kvm_vcpu *vcpu); 289void kvm_vcpu_kick(struct kvm_vcpu *vcpu);
290 290
291int kvm_is_mmio_pfn(pfn_t pfn);
292
291struct kvm_irq_ack_notifier { 293struct kvm_irq_ack_notifier {
292 struct hlist_node link; 294 struct hlist_node link;
293 unsigned gsi; 295 unsigned gsi;
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 485bcdc16552..cf0ab8ed3845 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -316,7 +316,7 @@ static inline int valid_vcpu(int n)
316 return likely(n >= 0 && n < KVM_MAX_VCPUS); 316 return likely(n >= 0 && n < KVM_MAX_VCPUS);
317} 317}
318 318
319static inline int is_mmio_pfn(pfn_t pfn) 319inline int kvm_is_mmio_pfn(pfn_t pfn)
320{ 320{
321 if (pfn_valid(pfn)) 321 if (pfn_valid(pfn))
322 return PageReserved(pfn_to_page(pfn)); 322 return PageReserved(pfn_to_page(pfn));
@@ -994,7 +994,7 @@ pfn_t gfn_to_pfn(struct kvm *kvm, gfn_t gfn)
994 994
995 pfn = ((addr - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff; 995 pfn = ((addr - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff;
996 up_read(&current->mm->mmap_sem); 996 up_read(&current->mm->mmap_sem);
997 BUG_ON(!is_mmio_pfn(pfn)); 997 BUG_ON(!kvm_is_mmio_pfn(pfn));
998 } else 998 } else
999 pfn = page_to_pfn(page[0]); 999 pfn = page_to_pfn(page[0]);
1000 1000
@@ -1008,10 +1008,10 @@ struct page *gfn_to_page(struct kvm *kvm, gfn_t gfn)
1008 pfn_t pfn; 1008 pfn_t pfn;
1009 1009
1010 pfn = gfn_to_pfn(kvm, gfn); 1010 pfn = gfn_to_pfn(kvm, gfn);
1011 if (!is_mmio_pfn(pfn)) 1011 if (!kvm_is_mmio_pfn(pfn))
1012 return pfn_to_page(pfn); 1012 return pfn_to_page(pfn);
1013 1013
1014 WARN_ON(is_mmio_pfn(pfn)); 1014 WARN_ON(kvm_is_mmio_pfn(pfn));
1015 1015
1016 get_page(bad_page); 1016 get_page(bad_page);
1017 return bad_page; 1017 return bad_page;
@@ -1027,7 +1027,7 @@ EXPORT_SYMBOL_GPL(kvm_release_page_clean);
1027 1027
1028void kvm_release_pfn_clean(pfn_t pfn) 1028void kvm_release_pfn_clean(pfn_t pfn)
1029{ 1029{
1030 if (!is_mmio_pfn(pfn)) 1030 if (!kvm_is_mmio_pfn(pfn))
1031 put_page(pfn_to_page(pfn)); 1031 put_page(pfn_to_page(pfn));
1032} 1032}
1033EXPORT_SYMBOL_GPL(kvm_release_pfn_clean); 1033EXPORT_SYMBOL_GPL(kvm_release_pfn_clean);
@@ -1053,7 +1053,7 @@ EXPORT_SYMBOL_GPL(kvm_set_page_dirty);
1053 1053
1054void kvm_set_pfn_dirty(pfn_t pfn) 1054void kvm_set_pfn_dirty(pfn_t pfn)
1055{ 1055{
1056 if (!is_mmio_pfn(pfn)) { 1056 if (!kvm_is_mmio_pfn(pfn)) {
1057 struct page *page = pfn_to_page(pfn); 1057 struct page *page = pfn_to_page(pfn);
1058 if (!PageReserved(page)) 1058 if (!PageReserved(page))
1059 SetPageDirty(page); 1059 SetPageDirty(page);
@@ -1063,14 +1063,14 @@ EXPORT_SYMBOL_GPL(kvm_set_pfn_dirty);
1063 1063
1064void kvm_set_pfn_accessed(pfn_t pfn) 1064void kvm_set_pfn_accessed(pfn_t pfn)
1065{ 1065{
1066 if (!is_mmio_pfn(pfn)) 1066 if (!kvm_is_mmio_pfn(pfn))
1067 mark_page_accessed(pfn_to_page(pfn)); 1067 mark_page_accessed(pfn_to_page(pfn));
1068} 1068}
1069EXPORT_SYMBOL_GPL(kvm_set_pfn_accessed); 1069EXPORT_SYMBOL_GPL(kvm_set_pfn_accessed);
1070 1070
1071void kvm_get_pfn(pfn_t pfn) 1071void kvm_get_pfn(pfn_t pfn)
1072{ 1072{
1073 if (!is_mmio_pfn(pfn)) 1073 if (!kvm_is_mmio_pfn(pfn))
1074 get_page(pfn_to_page(pfn)); 1074 get_page(pfn_to_page(pfn));
1075} 1075}
1076EXPORT_SYMBOL_GPL(kvm_get_pfn); 1076EXPORT_SYMBOL_GPL(kvm_get_pfn);