From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jordan Justen Subject: Re: How to initialize the grant table in a HVM guest OS and its bios Date: Fri, 17 Aug 2012 10:08:47 -0700 Message-ID: References: <1344439371.32142.46.camel@zakaz.uk.xensource.com> <1344441333.32142.48.camel@zakaz.uk.xensource.com> <1345218274.10161.86.camel@zakaz.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1345218274.10161.86.camel@zakaz.uk.xensource.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: Ian Campbell Cc: Bei Guan , xen-devel List-Id: xen-devel@lists.xenproject.org On Fri, Aug 17, 2012 at 8:44 AM, Ian Campbell wrote: > On Fri, 2012-08-17 at 16:31 +0100, Bei Guan wrote: >> >> 2012/8/8 Ian Campbell >> On Wed, 2012-08-08 at 16:48 +0100, Bei Guan wrote: >> >> > Thank you very much for your help. >> > Is there any example code of initialization of grant table >> in HVM that >> > I can refer to? >> >> >> The PVHVM support in upstream Linux would be a good place to >> look. >> >> So might the code in the xen tree in >> unmodified_drivers/linux-2.6/ >> >> IIRC Daniel got grant tables working in SeaBIOS last summer >> for GSoC so >> you might also find some useful examples in >> git://github.com/evildani/seabios_patch.git >> Hi Ian, >> >> >> Thank you very much for this information. It's very useful to me. >> >> >> However, I'm still confused with the initialization of the grant table >> in HVM. >> >> >> The relationship of the methods in the initialization of the grant >> table in linux source code (driver/xen) is: >> platform_pci_init()-->gnttab_init()-->gnttab_resume()-->gnttab_map()-->arch_gnttab_map_shared()-->apply_to_page_range(). >> >> >> So, I am not sure that what's the function of the method >> apply_to_page_range(), which is implemented in code file [1]. >> This function is a little complex. Is there any simple method to do >> this? Thank you for your time. > > This function is the simple method ;-) > > All it basically does is iterate over the page tables corresponding to a > range of addresses and calling a user supplied function on each leaf > PTE. In the case of the gnttab_map this user supplied function simply > sets the leaf PTEs to point to the right grant table page. > > I suppose you are working on tianocore? I've no idea what the page table > layout is in that environment, I suppose it either has a linear map or > some other way of getting at the leaf ptes. Anyway since the method to > use is specific to the OS (or firmware) environment you are running in I > think you'll have to ask on the tianocore development list. At boot time all pages are identity mapped. I don't think we need this mapping step for our firmware. Does that sound right? -Jordan