Skip to content

Commit 16b854c

Browse files
Xiao Guangrongavikivity
authored andcommitted
KVM: iommu: fix releasing unmapped page
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 <[email protected]> Signed-off-by: Avi Kivity <[email protected]>
1 parent d89cc61 commit 16b854c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

virt/kvm/iommu.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ int kvm_iommu_map_pages(struct kvm *kvm, struct kvm_memory_slot *slot)
107107
*/
108108
pfn = kvm_pin_pages(slot, gfn, page_size);
109109
if (is_error_pfn(pfn)) {
110+
kvm_release_pfn_clean(pfn);
110111
gfn += 1;
111112
continue;
112113
}
@@ -300,6 +301,12 @@ static void kvm_iommu_put_pages(struct kvm *kvm,
300301

301302
/* Get physical address */
302303
phys = iommu_iova_to_phys(domain, gfn_to_gpa(gfn));
304+
305+
if (!phys) {
306+
gfn++;
307+
continue;
308+
}
309+
303310
pfn = phys >> PAGE_SHIFT;
304311

305312
/* Unmap address from IO address space */

0 commit comments

Comments
 (0)