From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752091AbbGPREA (ORCPT ); Thu, 16 Jul 2015 13:04:00 -0400 Received: from 8bytes.org ([81.169.241.247]:38266 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751434AbbGPRD6 (ORCPT ); Thu, 16 Jul 2015 13:03:58 -0400 Date: Thu, 16 Jul 2015 19:03:57 +0200 From: Joerg Roedel To: Alex Williamson Cc: iommu@lists.linux-foundation.org, dwmw2@infradead.org, jiang.liu@linux.intel.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] iommu/vt-d: Fix VM domain ID leak Message-ID: <20150716170356.GC10969@8bytes.org> References: <20150714204731.10189.28556.stgit@gimli.home> <20150716152030.GB10969@8bytes.org> <1437061435.1391.580.camel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1437061435.1391.580.camel@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 16, 2015 at 09:43:55AM -0600, Alex Williamson wrote: > I was tempted to do this as well, but what about > domain_remove_dev_info() where we also handle vm domains specially and > don't do a symmetric detach in both directions? I started down that > path but quickly found the code to fragile to make those kinds of > changes. Thanks, Okay, so domain_remove_dev_info() does: if (domain_type_is_vm(domain)) { iommu_detach_dependent_devices(info->iommu, info->dev); domain_detach_iommu(domain, info->iommu); } ... in a loop over all devices attached to the domain. The first function (iommu_detach_dependent_devices) is not special to vm-domains. In fact, domain_remove_one_dev_info calls it for all domain types. And domain_detach_iommu only clears the bit in the iommu_bmp of the domain, which is also not special and also called for all domain types in domain_remove_one_dev_info. So it looks like this special handling has no real purpose and is just part of the whole mess. I am currently working on the conversion of the Intel VT-d driver to use default-domains from the iommu-core. When this is done we can get rid of that mess. Joerg