Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@redhat.com>
To: kvm@vger.kernel.org
Cc: stable@vger.kernel.org, linux-kernel@vger.kernel.org,
	alex.williamson@redhat.com, avi@redhat.com,
	jan.kiszka@siemens.com, mtosatti@redhat.com
Subject: [PATCH v2 2/2] kvm: unpin guest and free iommu domain after deassign last device
Date: Wed, 11 Apr 2012 09:51:56 -0600	[thread overview]
Message-ID: <20120411155156.13227.9696.stgit@bling.home> (raw)
In-Reply-To: <20120411154536.13227.10413.stgit@bling.home>

Unpin the guest and free the iommu domain if there are no longer
any devices attached.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---

 virt/kvm/assigned-dev.c |    3 +++
 virt/kvm/iommu.c        |    1 +
 2 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/virt/kvm/assigned-dev.c b/virt/kvm/assigned-dev.c
index 01f572c..01e7c37 100644
--- a/virt/kvm/assigned-dev.c
+++ b/virt/kvm/assigned-dev.c
@@ -765,6 +765,9 @@ static int kvm_vm_ioctl_deassign_device(struct kvm *kvm,
 
 	kvm_free_assigned_device(kvm, match);
 
+	if (list_empty(&kvm->arch.assigned_dev_head))
+		kvm_iommu_unmap_guest(kvm);
+
 out:
 	mutex_unlock(&kvm->lock);
 	return r;
diff --git a/virt/kvm/iommu.c b/virt/kvm/iommu.c
index fec1723..ee4c236 100644
--- a/virt/kvm/iommu.c
+++ b/virt/kvm/iommu.c
@@ -342,5 +342,6 @@ int kvm_iommu_unmap_guest(struct kvm *kvm)
 
 	kvm_iommu_unmap_memslots(kvm);
 	iommu_domain_free(domain);
+	kvm->arch.iommu_domain = NULL;
 	return 0;
 }


  parent reply	other threads:[~2012-04-11 15:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-11 15:51 [PATCH v2 0/2] kvm: iommu unmap fixes Alex Williamson
2012-04-11 15:51 ` [PATCH v2 1/2] kvm: unmap pages from the iommu when slots are removed Alex Williamson
2012-04-11 15:51 ` Alex Williamson [this message]
2012-04-11 15:59 ` [PATCH v2 0/2] kvm: iommu unmap fixes Greg KH
2012-04-11 16:17   ` Alex Williamson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120411155156.13227.9696.stgit@bling.home \
    --to=alex.williamson@redhat.com \
    --cc=avi@redhat.com \
    --cc=jan.kiszka@siemens.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox