From: "Jan Beulich" Subject: Re: [Patch RFC 00/13] VT-d Asynchronous Device-TLB Flush for ATS Device Date: Wed, 30 Sep 2015 08:03:38 -0600 Message-ID: <560C07DA02000078000A721D@prv-mh.provo.novell.com> References: <1442409847-65383-1-git-send-email-quan.xu@intel.com> <945CA011AD5F084CBEA3E851C0AB28894029E71C@SHSMSX101.ccr.corp.intel.com> <20150923162647.GA91198@deinos.phlegethon.org> <945CA011AD5F084CBEA3E851C0AB2889402A4BF2@SHSMSX101.ccr.corp.intel.com> <5608FE9002000078000A5F99@prv-mh.provo.novell.com> <945CA011AD5F084CBEA3E851C0AB2889402A66EC@SHSMSX101.ccr.corp.intel.com> <560A582C02000078000A6637@prv-mh.provo.novell.com> <945CA011AD5F084CBEA3E851C0AB2889402A7F89@SHSMSX101.ccr.corp.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <945CA011AD5F084CBEA3E851C0AB2889402A7F89@SHSMSX101.ccr.corp.intel.com> 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: Quan Xu Cc: Kevin Tian , "keir@xen.org" , "ian.campbell@citrix.com" , "george.dunlap@eu.citrix.com" , "andrew.cooper3@citrix.com" , Tim Deegan , "xen-devel@lists.xen.org" , Jun Nakajima , YangZ Zhang List-Id: xen-devel@lists.xenproject.org >>> On 30.09.15 at 15:55, wrote: >> >> >> >>> On September 29, 2015 at 3:22 PM, wrote: >> >>> On 29.09.15 at 04:53, wrote: >> >>>> Monday, September 28, 2015 2:47 PM, wrote: >> >> >>> On 28.09.15 at 05:08, wrote: >> >> >>>> Thursday, September 24, 2015 12:27 AM, Tim Deegan wrote: >> > >> > For Tim's suggestion --"to make the IOMMU table take typed refcounts >> > to anything it points to, and only drop those refcounts when the flush >> > completes." >> > >> > From IOMMU point of view, if it can walk through IOMMU table to get >> > these pages and take typed refcounts. >> > These pages are maybe owned by hardware_domain, dummy, HVM guest .etc. >> > could I narrow it down to HVM guest? --- It is not for anything it >> > points to, but just for HVM guest related. this will simplify the design. >> >> I don't follow. Why would you want to walk page tables? And why would a HVM >> guest have pages other than those owned by itself or granted access to by >> another guest mapped in its IOMMU page tables? > > It is tricky. Let's ignore it. > > This is an analysis of IOMMU table to take typed refcounts to anything it > points to. > I know the IOMMU table and EPT table may share the same page > table('iommu_hap_pt_share = 1'). > Then, go through iommu table and take typed refcounts. > >> In any event - the ref-counting >> would need to happen as you _create_ the mappings, not at some later point. >> > a general rule. Agreed. > > When create the mappings, what conditions to take typed refcounts? On any r/o mapping, take a general ref. On any r/w mapping take a writable ref. >> > --- a/xen/include/asm-x86/mm.h >> > +++ b/xen/include/asm-x86/mm.h >> > @@ -183,6 +183,7 @@ struct page_info >> > #define PGT_seg_desc_page PG_mask(5, 4) /* using this page in a GDT/LDT? >> */ >> > #define PGT_writable_page PG_mask(7, 4) /* has writable mappings? >> */ >> > #define PGT_shared_page PG_mask(8, 4) /* CoW sharable page >> */ >> > +#define PGT_dev_tlb_page PG_mask(9, 4) /* Maybe in Device-TLB >> mapping? */ >> > #define PGT_type_mask PG_mask(15, 4) /* Bits 28-31 or 60-63. >> */ >> > >> > * I define a new typed refcounts PGT_dev_tlb_page. >> >> Why? I.e. why won't a base ref for r/o pages and a writable type-ref for r/w > ones >> suffice, just like we do everywhere else? >> > > I think it is different from r/o or writable. > > The page freed from the domain, the Device-TLB flush is not completed. > The page is _not_ r/o or writable, and can only access though DMA.. DMA or not, the page can either be accessed (read) (when mapped r/o in the IOMMU) or written (when mapped r/w in the IOMMU). For the purpose of refcounting it doesn't matter where the reads/writes originate. Jan