aboutsummaryrefslogtreecommitdiffstats
path: root/virt/kvm/kvm_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'virt/kvm/kvm_main.c')
-rw-r--r--virt/kvm/kvm_main.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 93d3c6e063c8..eafba99d1070 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -102,9 +102,6 @@ static bool largepages_enabled = true;
102 102
103bool kvm_is_mmio_pfn(pfn_t pfn) 103bool kvm_is_mmio_pfn(pfn_t pfn)
104{ 104{
105 if (is_error_pfn(pfn))
106 return false;
107
108 if (pfn_valid(pfn)) { 105 if (pfn_valid(pfn)) {
109 int reserved; 106 int reserved;
110 struct page *tail = pfn_to_page(pfn); 107 struct page *tail = pfn_to_page(pfn);
@@ -1165,10 +1162,13 @@ EXPORT_SYMBOL_GPL(gfn_to_page_many_atomic);
1165 1162
1166static struct page *kvm_pfn_to_page(pfn_t pfn) 1163static struct page *kvm_pfn_to_page(pfn_t pfn)
1167{ 1164{
1168 WARN_ON(kvm_is_mmio_pfn(pfn)); 1165 if (is_error_pfn(pfn))
1166 return KVM_ERR_PTR_BAD_PAGE;
1169 1167
1170 if (is_error_pfn(pfn) || kvm_is_mmio_pfn(pfn)) 1168 if (kvm_is_mmio_pfn(pfn)) {
1169 WARN_ON(1);
1171 return KVM_ERR_PTR_BAD_PAGE; 1170 return KVM_ERR_PTR_BAD_PAGE;
1171 }
1172 1172
1173 return pfn_to_page(pfn); 1173 return pfn_to_page(pfn);
1174} 1174}
@@ -1193,7 +1193,9 @@ EXPORT_SYMBOL_GPL(kvm_release_page_clean);
1193 1193
1194void kvm_release_pfn_clean(pfn_t pfn) 1194void kvm_release_pfn_clean(pfn_t pfn)
1195{ 1195{
1196 if (!is_error_pfn(pfn) && !kvm_is_mmio_pfn(pfn)) 1196 WARN_ON(is_error_pfn(pfn));
1197
1198 if (!kvm_is_mmio_pfn(pfn))
1197 put_page(pfn_to_page(pfn)); 1199 put_page(pfn_to_page(pfn));
1198} 1200}
1199EXPORT_SYMBOL_GPL(kvm_release_pfn_clean); 1201EXPORT_SYMBOL_GPL(kvm_release_pfn_clean);