From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wei Wang2 Subject: Re: [PATCH 03 of 16] amd iommu: Add iommu emulation for hvm guest Date: Thu, 15 Dec 2011 15:30:36 +0100 Message-ID: <201112151530.36889.wei.wang2@amd.com> References: <201112151509.29366.wei.wang2@amd.com> <4EEA0EB502000078000682EA@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <4EEA0EB502000078000682EA@nat28.tlf.novell.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Jan Beulich Cc: Tim Deegan , xen-devel@lists.xensource.com, keir@xen.org List-Id: xen-devel@lists.xenproject.org On Thursday 15 December 2011 15:13:57 Jan Beulich wrote: > >>> On 15.12.11 at 15:09, Wei Wang2 wrote: > > > > On Thursday 15 December 2011 14:35:55 Tim Deegan wrote: > >> Hi, > >> > >> At 16:29 +0100 on 14 Dec (1323880164), Wei Wang wrote: > >> > +static struct page_info* guest_iommu_get_page(struct list_head > >> > *pglist, + unsigned int > >> > entry_size, + unsigned > >> > int pos) +{ > >> > + int idx; > >> > + struct list_head *head; > >> > + struct guest_pages *gpage = NULL; > >> > + > >> > + idx = (pos * entry_size) >> PAGE_SHIFT; > >> > + list_for_each( head, pglist ) > >> > + { > >> > + gpage = list_entry(head, struct guest_pages, list); > >> > + if ( (--idx) < 0 ) > >> > + break; > >> > + } > >> > >> Given that you allocate all these elements together, and free them, all > >> together, why not just use an array instead of a linked list? > >> > >> Cheers, > >> > >> Tim. > > > > The numbers of element might be variant. But array should also work, > > considering iommu tables has max. length of 2MB, the array length is > > small. > > Small enough so the array would fit in a single page? > > Jan Well...then, How about that I just save the first gfn of the table base address and mapping gfn + n dynamically? Since all gfns for iommu tables must be contiguous guest space.. Thanks, Wei