From: Quan Xu Subject: [Patch RFC 10/13] vt-d: Held on the removed page until the Device-TLB flush is completed. Date: Wed, 16 Sep 2015 09:24:04 -0400 Message-ID: <1442409847-65383-11-git-send-email-quan.xu@intel.com> References: <1442409847-65383-1-git-send-email-quan.xu@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1442409847-65383-1-git-send-email-quan.xu@intel.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: andrew.cooper3@citrix.com, eddie.dong@intel.com, ian.campbell@citrix.com, ian.jackson@eu.citrix.com, jbeulich@suse.com, jun.nakajima@intel.com, keir@xen.org, kevin.tian@intel.com, tim@xen.org, yang.z.zhang@intel.com, george.dunlap@eu.citrix.com Cc: Quan Xu , xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org Signed-off-by: Quan Xu --- xen/common/memory.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/xen/common/memory.c b/xen/common/memory.c index 61bb94c..4b2def5 100644 --- a/xen/common/memory.c +++ b/xen/common/memory.c @@ -253,7 +253,21 @@ int guest_remove_page(struct domain *d, unsigned long gmfn) guest_physmap_remove_page(d, gmfn, mfn, 0); - put_page(page); +#ifdef HAS_PASSTHROUGH + /* + * The page freed from the domain should be on held, until the + * Device-TLB flush is completed. The page previously associated + * with the freed portion of GPA should not be reallocated for + * another purpose until the appropriate invalidations have been + * performed. Otherwise, the original page owner can still access + * freed page though DMA. + */ + if ( need_iommu(d) && QI_FLUSHING(d) && !d->is_dying ) + qi_hold_page(d, page); + else +#endif + put_page(page); + put_gfn(d, gmfn); return 1; -- 1.8.3.2