Skip to content

Commit

Permalink
KVM: iommu: fix releasing unmapped page
Browse files Browse the repository at this point in the history
There are two bugs:
- the 'error page' is forgot to be released
  [ it is unneeded after commit a276632, for backport, we
    still do kvm_release_pfn_clean for the error pfn ]

- guest pages are always released regardless of the unmapped page
  (e,g, caused by hwpoison)

Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
  • Loading branch information
Xiao Guangrong authored and Avi Kivity committed Aug 6, 2012
1 parent d89cc61 commit 16b854c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions virt/kvm/iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ int kvm_iommu_map_pages(struct kvm *kvm, struct kvm_memory_slot *slot)
*/
pfn = kvm_pin_pages(slot, gfn, page_size);
if (is_error_pfn(pfn)) {
kvm_release_pfn_clean(pfn);
gfn += 1;
continue;
}
Expand Down Expand Up @@ -300,6 +301,12 @@ static void kvm_iommu_put_pages(struct kvm *kvm,

/* Get physical address */
phys = iommu_iova_to_phys(domain, gfn_to_gpa(gfn));

if (!phys) {
gfn++;
continue;
}

pfn = phys >> PAGE_SHIFT;

/* Unmap address from IO address space */
Expand Down

0 comments on commit 16b854c

Please sign in to comment.