From patchwork Sun Jul 29 08:12:03 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 1251991 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id B5DE03FC33 for ; Sun, 29 Jul 2012 08:13:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752643Ab2G2IM6 (ORCPT ); Sun, 29 Jul 2012 04:12:58 -0400 Received: from e23smtp06.au.ibm.com ([202.81.31.148]:54682 "EHLO e23smtp06.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752381Ab2G2IML (ORCPT ); Sun, 29 Jul 2012 04:12:11 -0400 Received: from /spool/local by e23smtp06.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sun, 29 Jul 2012 18:11:53 +1000 Received: from d23relay04.au.ibm.com (202.81.31.246) by e23smtp06.au.ibm.com (202.81.31.212) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Sun, 29 Jul 2012 18:11:51 +1000 Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q6T83qsf14352506; Sun, 29 Jul 2012 18:03:52 +1000 Received: from d23av02.au.ibm.com (loopback [127.0.0.1]) by d23av02.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q6T8C5SF009957; Sun, 29 Jul 2012 18:12:05 +1000 Received: from localhost.localdomain ([9.123.236.99]) by d23av02.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q6T8C3Il009614; Sun, 29 Jul 2012 18:12:04 +1000 Message-ID: <5014F053.8020305@linux.vnet.ibm.com> Date: Sun, 29 Jul 2012 16:12:03 +0800 From: Xiao Guangrong User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120717 Thunderbird/14.0 MIME-Version: 1.0 To: Avi Kivity CC: Marcelo Tosatti , LKML , KVM Subject: [PATCH 1/9] KVM: iommu: fix releasing unmapped page x-cbid: 12072908-7014-0000-0000-000001A392ED Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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 --- virt/kvm/iommu.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) 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 */