From: "Jan Beulich" Subject: Re: [PATCH] VT-d: fix RMRR handling Date: Tue, 04 Mar 2014 08:04:49 +0000 Message-ID: <531597310200007800120BDA@nat28.tlf.novell.com> References: <52F8E56D020000780011AC43@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WKkLR-0000d9-CN for xen-devel@lists.xenproject.org; Tue, 04 Mar 2014 08:04:57 +0000 In-Reply-To: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Xiantao Zhang Cc: xen-devel List-Id: xen-devel@lists.xenproject.org >>> On 01.03.14 at 08:03, "Zhang, Xiantao" wrote: > Jan, my comments embedded, thanks! > >> Removing mapped RMRR tracking structures in dma_pte_clear_one() is wrong >> for two reasons: First, these regions may cover more than a single page. And >> second, multiple devices (and hence multiple devices assigned to any >> particular guest) may share a single RMRR (whether assigning such devices to >> distinct guests is a safe thing to do is another question). > > Agree, this is a real issue as you described > >> Therefore move the removal of the tracking structures into the counterpart >> function to the one doing the insertion - intel_iommu_remove_device(), and >> add a reference count to the tracking structure. > > Adding a reference count is a good idea, but from the logic, seems you are > adding a global counter for each rmrr? I don't think so: mapped_rmrrs is rooted in struct hvm_iommu, which is a per-domain thing. > In theory, one rmrr may be mapped for multiple devices in multiple domains, > global counter for once rmrr is not enough. > Maybe we need to per-domain counter there ? And even if it was, I wouldn't think so, for security reasons: Sharing an RMRR across domains is insecure afaict, so if anything we ought to suppress assigning devices sharing an RMRR to different guests (e.g. via intel_iommu_group_id() or a second, similar mechanism), at least in "iommu=force" mode. Jan