* How to initialize the grant table in a HVM guest OS and its bios
@ 2012-08-08 15:10 Bei Guan
2012-08-08 15:22 ` Ian Campbell
0 siblings, 1 reply; 9+ messages in thread
From: Bei Guan @ 2012-08-08 15:10 UTC (permalink / raw)
To: xen-devel; +Cc: Attilio Rao, Jordan Justen, Andrei E. Warkentin
[-- Attachment #1.1: Type: text/plain, Size: 660 bytes --]
Hi,
In Mini-OS, the initialization of the grant table maps the grant table
entries into an area called demand_map_area. The code is in the file
mini-os/gnttab.c and it's like this
gnttab_table = map_frames(frames, NR_GRANT_FRAMES);
It seems that getting the demand_map_area needs the infomation from the
start_info page in Mini-OS (refer to the method allocate_ondemand int
mini-os/arch/x86/mm.c). However, there is no start_info page in a HVM guest
OS (maybe it's also true for its virtual bios, such as seabios and uefi
bios). So, how to map the grant table entries in a HVM guest OS and its
bios?
Any suggestions is appreciated.
Best Regards,
Bei Guan
[-- Attachment #1.2: Type: text/html, Size: 808 bytes --]
[-- Attachment #2: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How to initialize the grant table in a HVM guest OS and its bios
2012-08-08 15:10 How to initialize the grant table in a HVM guest OS and its bios Bei Guan
@ 2012-08-08 15:22 ` Ian Campbell
2012-08-08 15:48 ` Bei Guan
0 siblings, 1 reply; 9+ messages in thread
From: Ian Campbell @ 2012-08-08 15:22 UTC (permalink / raw)
To: Bei Guan; +Cc: Attilio Rao, Andrei E. Warkentin, Jordan Justen, xen-devel
On Wed, 2012-08-08 at 16:10 +0100, Bei Guan wrote:
> Hi,
>
>
> In Mini-OS, the initialization of the grant table maps the grant table
> entries into an area called demand_map_area. The code is in the file
> mini-os/gnttab.c and it's like this
> gnttab_table = map_frames(frames, NR_GRANT_FRAMES);
>
>
> It seems that getting the demand_map_area needs the infomation from
> the start_info page in Mini-OS (refer to the method allocate_ondemand
> int mini-os/arch/x86/mm.c). However, there is no start_info page in a
> HVM guest OS (maybe it's also true for its virtual bios, such as
> seabios and uefi bios). So, how to map the grant table entries in a
> HVM guest OS and its bios?
The PCI Platform device provides a BAR region which is specifically set
aside for the guest OS to use as a hole for grant tab mappings. Or if
you control the phyiscal address space you can just allocate somewhere
to do the mapping.
>
>
> Any suggestions is appreciated.
>
>
>
>
> Best Regards,
> Bei Guan
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How to initialize the grant table in a HVM guest OS and its bios
2012-08-08 15:22 ` Ian Campbell
@ 2012-08-08 15:48 ` Bei Guan
2012-08-08 15:55 ` Ian Campbell
0 siblings, 1 reply; 9+ messages in thread
From: Bei Guan @ 2012-08-08 15:48 UTC (permalink / raw)
To: Ian Campbell; +Cc: Attilio Rao, Andrei E. Warkentin, Jordan Justen, xen-devel
[-- Attachment #1.1: Type: text/plain, Size: 1293 bytes --]
2012/8/8 Ian Campbell <Ian.Campbell@citrix.com>
> On Wed, 2012-08-08 at 16:10 +0100, Bei Guan wrote:
> > Hi,
> >
> >
> > In Mini-OS, the initialization of the grant table maps the grant table
> > entries into an area called demand_map_area. The code is in the file
> > mini-os/gnttab.c and it's like this
> > gnttab_table = map_frames(frames, NR_GRANT_FRAMES);
> >
> >
> > It seems that getting the demand_map_area needs the infomation from
> > the start_info page in Mini-OS (refer to the method allocate_ondemand
> > int mini-os/arch/x86/mm.c). However, there is no start_info page in a
> > HVM guest OS (maybe it's also true for its virtual bios, such as
> > seabios and uefi bios). So, how to map the grant table entries in a
> > HVM guest OS and its bios?
>
> The PCI Platform device provides a BAR region which is specifically set
> aside for the guest OS to use as a hole for grant tab mappings. Or if
> you control the phyiscal address space you can just allocate somewhere
> to do the mapping.
>
Hi Ian,
Thank you very much for your help.
Is there any example code of initialization of grant table in HVM that I
can refer to?
Thanks,
Bei Guan
>
>
> >
> >
> > Any suggestions is appreciated.
> >
> >
> >
> >
> > Best Regards,
> > Bei Guan
> >
>
>
>
--
Best Regards,
Bei Guan
[-- Attachment #1.2: Type: text/html, Size: 2106 bytes --]
[-- Attachment #2: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How to initialize the grant table in a HVM guest OS and its bios
2012-08-08 15:48 ` Bei Guan
@ 2012-08-08 15:55 ` Ian Campbell
2012-08-17 15:31 ` Bei Guan
0 siblings, 1 reply; 9+ messages in thread
From: Ian Campbell @ 2012-08-08 15:55 UTC (permalink / raw)
To: Bei Guan; +Cc: Attilio Rao, Andrei E. Warkentin, Jordan Justen, xen-devel
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
Ian
>
>
>
>
> Thanks,
> Bei Guan
>
>
>
>
>
> >
> >
> > Any suggestions is appreciated.
> >
> >
> >
> >
> > Best Regards,
> > Bei Guan
> >
>
>
>
>
>
>
>
> --
> Best Regards,
> Bei Guan
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How to initialize the grant table in a HVM guest OS and its bios
2012-08-08 15:55 ` Ian Campbell
@ 2012-08-17 15:31 ` Bei Guan
2012-08-17 15:44 ` Ian Campbell
0 siblings, 1 reply; 9+ messages in thread
From: Bei Guan @ 2012-08-17 15:31 UTC (permalink / raw)
To: Ian Campbell; +Cc: xen-devel
[-- Attachment #1.1: Type: text/plain, Size: 1241 bytes --]
2012/8/8 Ian Campbell <Ian.Campbell@citrix.com>
> 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.
[1] http://lxr.free-electrons.com/source/mm/memory.c#L2412
Best Regards,
Bei Guan
[-- Attachment #1.2: Type: text/html, Size: 1952 bytes --]
[-- Attachment #2: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How to initialize the grant table in a HVM guest OS and its bios
2012-08-17 15:31 ` Bei Guan
@ 2012-08-17 15:44 ` Ian Campbell
2012-08-17 16:24 ` Bei Guan
2012-08-17 17:08 ` Jordan Justen
0 siblings, 2 replies; 9+ messages in thread
From: Ian Campbell @ 2012-08-17 15:44 UTC (permalink / raw)
To: Bei Guan; +Cc: xen-devel
On Fri, 2012-08-17 at 16:31 +0100, Bei Guan wrote:
>
> 2012/8/8 Ian Campbell <Ian.Campbell@citrix.com>
> 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.
Ian.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How to initialize the grant table in a HVM guest OS and its bios
2012-08-17 15:44 ` Ian Campbell
@ 2012-08-17 16:24 ` Bei Guan
2012-08-17 17:08 ` Jordan Justen
1 sibling, 0 replies; 9+ messages in thread
From: Bei Guan @ 2012-08-17 16:24 UTC (permalink / raw)
To: Ian Campbell; +Cc: xen-devel
[-- Attachment #1.1: Type: text/plain, Size: 2086 bytes --]
Hi Ian,
Yes, I'm working on the PV support on tianocore UEFI bios.
I have read the code in drivers/xen/grant-table.c. And my understanding of
the initialization of the grant table in HVM is as the following. Please
correct me if possible.
1. DomU sets up the grant table for itself. (Uses the hypercall
HYPERVISOR_grant_table_op)
2. DomU maps the shared grant table to its address space. (Uses the
hypercall HYPERVISOR_memory_op)
3. DomU needs to map the the shared grant table to the installed grant
table in step 1 (Maybe it's done in the method apply_to_page_range()).
Then, DomU can operate the shared grant table through the installed grant
table.
Thank you very much.
Best Regards,
Bei Guan
> > 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.
>
> Ian.
>
>
>
[-- Attachment #1.2: Type: text/html, Size: 2761 bytes --]
[-- Attachment #2: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How to initialize the grant table in a HVM guest OS and its bios
2012-08-17 15:44 ` Ian Campbell
2012-08-17 16:24 ` Bei Guan
@ 2012-08-17 17:08 ` Jordan Justen
2012-08-17 18:46 ` Ian Campbell
1 sibling, 1 reply; 9+ messages in thread
From: Jordan Justen @ 2012-08-17 17:08 UTC (permalink / raw)
To: Ian Campbell; +Cc: Bei Guan, xen-devel
On Fri, Aug 17, 2012 at 8:44 AM, Ian Campbell <Ian.Campbell@citrix.com> wrote:
> On Fri, 2012-08-17 at 16:31 +0100, Bei Guan wrote:
>>
>> 2012/8/8 Ian Campbell <Ian.Campbell@citrix.com>
>> 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
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How to initialize the grant table in a HVM guest OS and its bios
2012-08-17 17:08 ` Jordan Justen
@ 2012-08-17 18:46 ` Ian Campbell
0 siblings, 0 replies; 9+ messages in thread
From: Ian Campbell @ 2012-08-17 18:46 UTC (permalink / raw)
To: Jordan Justen; +Cc: Bei Guan, xen-devel
On Fri, 2012-08-17 at 18:08 +0100, Jordan Justen wrote:
> On Fri, Aug 17, 2012 at 8:44 AM, Ian Campbell <Ian.Campbell@citrix.com> wrote:
> > On Fri, 2012-08-17 at 16:31 +0100, Bei Guan wrote:
> >>
> >> 2012/8/8 Ian Campbell <Ian.Campbell@citrix.com>
> >> 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?
In that case you can skip the page table setup bit, you just need the
step where you add the grant table to your physical address space.
Ian.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2012-08-17 18:46 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-08 15:10 How to initialize the grant table in a HVM guest OS and its bios Bei Guan
2012-08-08 15:22 ` Ian Campbell
2012-08-08 15:48 ` Bei Guan
2012-08-08 15:55 ` Ian Campbell
2012-08-17 15:31 ` Bei Guan
2012-08-17 15:44 ` Ian Campbell
2012-08-17 16:24 ` Bei Guan
2012-08-17 17:08 ` Jordan Justen
2012-08-17 18:46 ` Ian Campbell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).