From: Xiao Guangrong Date: Fri, 3 Aug 2012 07:36:52 +0000 (+0800) Subject: KVM: iommu: fix releasing unmapped page X-Git-Tag: v3.7-rc1~113^2~81 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=16b854c889673d988285719bc020543a730f9ac6;p=profile%2Fivi%2Fkernel-x86-ivi.git KVM: iommu: fix releasing unmapped page There are two bugs: - the 'error page' is forgot to be released [ it is unneeded after commit a2766325cf9f9, 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 Signed-off-by: Avi Kivity --- diff --git a/virt/kvm/iommu.c b/virt/kvm/iommu.c index c03f1fb..6a67bea 100644 --- a/virt/kvm/iommu.c +++ b/virt/kvm/iommu.c @@ -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; } @@ -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 */