> -----Original Message----- > From: George Dunlap [mailto:george.dun...@citrix.com] > Sent: 11 July 2018 12:46 > To: Paul Durrant <paul.durr...@citrix.com>; xen-devel@lists.xenproject.org > Cc: Jan Beulich <jbeul...@suse.com>; Andrew Cooper > <andrew.coop...@citrix.com>; George Dunlap > <george.dun...@citrix.com>; Ian Jackson <ian.jack...@citrix.com>; Julien > Grall <julien.gr...@arm.com>; Konrad Rzeszutek Wilk > <konrad.w...@oracle.com>; Stefano Stabellini <sstabell...@kernel.org>; Tim > (Xen.org) <t...@xen.org>; Wei Liu <wei.l...@citrix.com> > Subject: Re: [PATCH v2 12/13] x86: add iommu_ops to modify and flush > IOMMU mappings > > On 07/07/2018 12:05 PM, Paul Durrant wrote: > > This patch adds iommu_ops to add (map) or remove (unmap) frames in the > > domain's IOMMU mappings, and an iommu_op to synchronize (flush) > those > > manipulations with the hardware. > > > > Mappings added by the map operation are tracked and only those > mappings > > may be removed by a subsequent unmap operation. Frames are specified > by the > > owning domain and GFN. It is, of course, permissable for a domain to map > > its own frames using DOMID_SELF. > > > > NOTE: The owning domain and GFN must also be specified in the unmap > > operation, as well as the BFN, so that they can be cross-checked > > with the existent mapping. > > > > Signed-off-by: Paul Durrant <paul.durr...@citrix.com> > > The code on the whole looks correct, but I don't see any reference > counting. The call to get_paged_gfn() in iommuop_unmap() kind of > underlines the issue -- what's to stop the following sequence of events? > > * iommuop_map() page A > * share(A) > * DMA write into A # >
I don't follow. In iommuop_map() we do a get_paged_gfn() and that reference is retained. In iommuop_unmap() there is another call to get_paged_gfn() but that is there to check that the specified gfn matches the mfn that's looked up in the IOMMU. Only if they match is the original page ref dropped. Paul > -George _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel