diff options
author | Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com> | 2012-10-16 08:10:59 -0400 |
---|---|---|
committer | Marcelo Tosatti <mtosatti@redhat.com> | 2012-10-29 18:31:04 -0400 |
commit | 81c52c56e2b43589091ee29038bcf793d3f184ab (patch) | |
tree | 763236629eb034e519db87d8568946883499a155 /virt | |
parent | 19bf7f8ac3f8131100027281c495dbbe00cd5ae0 (diff) |
KVM: do not treat noslot pfn as a error pfn
This patch filters noslot pfn out from error pfns based on Marcelo comment:
noslot pfn is not a error pfn
After this patch,
- is_noslot_pfn indicates that the gfn is not in slot
- is_error_pfn indicates that the gfn is in slot but the error is occurred
when translate the gfn to pfn
- is_error_noslot_pfn indicates that the pfn either it is error pfns or it
is noslot pfn
And is_invalid_pfn can be removed, it makes the code more clean
Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'virt')
-rw-r--r-- | virt/kvm/iommu.c | 4 | ||||
-rw-r--r-- | virt/kvm/kvm_main.c | 6 |
2 files changed, 5 insertions, 5 deletions
diff --git a/virt/kvm/iommu.c b/virt/kvm/iommu.c index 18e1e30019e3..4a340cb23013 100644 --- a/virt/kvm/iommu.c +++ b/virt/kvm/iommu.c | |||
@@ -52,7 +52,7 @@ static pfn_t kvm_pin_pages(struct kvm_memory_slot *slot, gfn_t gfn, | |||
52 | end_gfn = gfn + (size >> PAGE_SHIFT); | 52 | end_gfn = gfn + (size >> PAGE_SHIFT); |
53 | gfn += 1; | 53 | gfn += 1; |
54 | 54 | ||
55 | if (is_error_pfn(pfn)) | 55 | if (is_error_noslot_pfn(pfn)) |
56 | return pfn; | 56 | return pfn; |
57 | 57 | ||
58 | while (gfn < end_gfn) | 58 | while (gfn < end_gfn) |
@@ -106,7 +106,7 @@ int kvm_iommu_map_pages(struct kvm *kvm, struct kvm_memory_slot *slot) | |||
106 | * important because we unmap and unpin in 4kb steps later. | 106 | * important because we unmap and unpin in 4kb steps later. |
107 | */ | 107 | */ |
108 | pfn = kvm_pin_pages(slot, gfn, page_size); | 108 | pfn = kvm_pin_pages(slot, gfn, page_size); |
109 | if (is_error_pfn(pfn)) { | 109 | if (is_error_noslot_pfn(pfn)) { |
110 | gfn += 1; | 110 | gfn += 1; |
111 | continue; | 111 | continue; |
112 | } | 112 | } |
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index be70035fd42a..2fb73191801f 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c | |||
@@ -1208,7 +1208,7 @@ __gfn_to_pfn_memslot(struct kvm_memory_slot *slot, gfn_t gfn, bool atomic, | |||
1208 | return KVM_PFN_ERR_RO_FAULT; | 1208 | return KVM_PFN_ERR_RO_FAULT; |
1209 | 1209 | ||
1210 | if (kvm_is_error_hva(addr)) | 1210 | if (kvm_is_error_hva(addr)) |
1211 | return KVM_PFN_ERR_BAD; | 1211 | return KVM_PFN_NOSLOT; |
1212 | 1212 | ||
1213 | /* Do not map writable pfn in the readonly memslot. */ | 1213 | /* Do not map writable pfn in the readonly memslot. */ |
1214 | if (writable && memslot_is_readonly(slot)) { | 1214 | if (writable && memslot_is_readonly(slot)) { |
@@ -1290,7 +1290,7 @@ EXPORT_SYMBOL_GPL(gfn_to_page_many_atomic); | |||
1290 | 1290 | ||
1291 | static struct page *kvm_pfn_to_page(pfn_t pfn) | 1291 | static struct page *kvm_pfn_to_page(pfn_t pfn) |
1292 | { | 1292 | { |
1293 | if (is_error_pfn(pfn)) | 1293 | if (is_error_noslot_pfn(pfn)) |
1294 | return KVM_ERR_PTR_BAD_PAGE; | 1294 | return KVM_ERR_PTR_BAD_PAGE; |
1295 | 1295 | ||
1296 | if (kvm_is_mmio_pfn(pfn)) { | 1296 | if (kvm_is_mmio_pfn(pfn)) { |
@@ -1322,7 +1322,7 @@ EXPORT_SYMBOL_GPL(kvm_release_page_clean); | |||
1322 | 1322 | ||
1323 | void kvm_release_pfn_clean(pfn_t pfn) | 1323 | void kvm_release_pfn_clean(pfn_t pfn) |
1324 | { | 1324 | { |
1325 | if (!is_error_pfn(pfn) && !kvm_is_mmio_pfn(pfn)) | 1325 | if (!is_error_noslot_pfn(pfn) && !kvm_is_mmio_pfn(pfn)) |
1326 | put_page(pfn_to_page(pfn)); | 1326 | put_page(pfn_to_page(pfn)); |
1327 | } | 1327 | } |
1328 | EXPORT_SYMBOL_GPL(kvm_release_pfn_clean); | 1328 | EXPORT_SYMBOL_GPL(kvm_release_pfn_clean); |