From owner-svn-src-projects@FreeBSD.ORG Wed Sep 18 03:51:50 2013 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 24B5C931; Wed, 18 Sep 2013 03:51:50 +0000 (UTC) (envelope-from neel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 131E1299A; Wed, 18 Sep 2013 03:51:50 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8I3pnrH006908; Wed, 18 Sep 2013 03:51:49 GMT (envelope-from neel@svn.freebsd.org) Received: (from neel@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r8I3pnCl006907; Wed, 18 Sep 2013 03:51:49 GMT (envelope-from neel@svn.freebsd.org) Message-Id: <201309180351.r8I3pnCl006907@svn.freebsd.org> From: Neel Natu Date: Wed, 18 Sep 2013 03:51:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r255661 - projects/bhyve_npt_pmap/sys/amd64/vmm X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Sep 2013 03:51:50 -0000 Author: neel Date: Wed Sep 18 03:51:49 2013 New Revision: 255661 URL: http://svnweb.freebsd.org/changeset/base/255661 Log: Destroy the iommu domain in vm_destroy() in preference to doing it when the last passthru device is detached from the virtual machine. There are code paths in vm_assign_pptdev() where we can return after creating the iommu domain but before the first passthru device is successfully attached. In this case there aren't any passthru devices attached to the virtual machine and therefore vm_unassign_pptdev() will not be called and the iommu domain is not destroyed. This is very easy to reproduce by trying to attach a non-existent passthru device to the virtual machine and then destroying the virtual machine. Modified: projects/bhyve_npt_pmap/sys/amd64/vmm/vmm.c Modified: projects/bhyve_npt_pmap/sys/amd64/vmm/vmm.c ============================================================================== --- projects/bhyve_npt_pmap/sys/amd64/vmm/vmm.c Wed Sep 18 00:33:24 2013 (r255660) +++ projects/bhyve_npt_pmap/sys/amd64/vmm/vmm.c Wed Sep 18 03:51:49 2013 (r255661) @@ -331,7 +331,8 @@ vm_destroy(struct vm *vm) ppt_unassign_all(vm); - KASSERT(vm->iommu == NULL, ("vm_destroy: iommu should be NULL")); + if (vm->iommu != NULL) + iommu_destroy_domain(vm->iommu); for (i = 0; i < vm->num_mem_segs; i++) vm_free_mem_seg(vm, &vm->mem_segs[i]); @@ -564,8 +565,6 @@ vm_unassign_pptdev(struct vm *vm, int bu if (ppt_num_devices(vm) == 0) { vm_iommu_unmap(vm); vm_gpa_unwire(vm); - iommu_destroy_domain(vm->iommu); - vm->iommu = NULL; } return (0); }