James Harper
2010-Oct-17 05:27 UTC
[Xen-devel] sharing memory between qemu and domu without grant tables or vmexits...
Is it possible to share a page of memory between qemu in dom0 and domu without using grant tables and without domu access to that page causing a vmexit? To set up a custom kernel debug dll under windows I need to load very early, much earlier than my PV drivers. To have any hope of usefully increasing the speed over serial port debugging I need to be able to transfer data faster than 1-byte-per-vmexit... Thanks James _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Keir Fraser
2010-Oct-17 07:36 UTC
Re: [Xen-devel] sharing memory between qemu and domu without grant tables or vmexits...
On 17/10/2010 06:27, "James Harper" <james.harper@bendigoit.com.au> wrote:> Is it possible to share a page of memory between qemu in dom0 and domu > without using grant tables and without domu access to that page causing > a vmexit?Pick a reserved page in guest''s physical memory map. Communicate that address to both domU and qemu somehow (e.g., one might pick it and communicate it to the other; or it may be a statically assigned well-known address; or whatever). Qemu can map that page, as obviously can the guest. To get that reserved page, you could: (1) pick an unused frame slot in the hole below 4GB (e.g., between LAPIC and IOAPIC mappings) allocate a page there from qemu, or hvmloader, or domU, or...; or (2) you could have hvm domain builder, or hvmloader, reserve a page from the guest''s regular RAM space, and update guest e820 appropiately to indicate page is reserved. Communicate that address as necessary, and away you go. -- Keir> To set up a custom kernel debug dll under windows I need to load very > early, much earlier than my PV drivers. To have any hope of usefully > increasing the speed over serial port debugging I need to be able to > transfer data faster than 1-byte-per-vmexit... > > Thanks > > James > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xensource.com > http://lists.xensource.com/xen-devel_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
James Harper
2010-Oct-17 08:23 UTC
RE: [Xen-devel] sharing memory between qemu and domu without grant tables or vmexits...
> > > Is it possible to share a page of memory between qemu in dom0 anddomu> > without using grant tables and without domu access to that pagecausing> > a vmexit? > > Pick a reserved page in guest''s physical memory map. Communicate that > address to both domU and qemu somehow (e.g., one might pick it and > communicate it to the other; or it may be a statically assignedwell-known> address; or whatever). Qemu can map that page, as obviously can theguest.> > To get that reserved page, you could: (1) pick an unused frame slot inthe> hole below 4GB (e.g., between LAPIC and IOAPIC mappings) allocate apage> there from qemu, or hvmloader, or domU, or...; or (2) you could havehvm> domain builder, or hvmloader, reserve a page from the guest''s regularRAM> space, and update guest e820 appropiately to indicate page isreserved.> Communicate that address as necessary, and away you go. >I''m still not sure I understand it all... might the following work them: 1. Allocate a page of memory in my windows code 2. Write the PFN to a known io port (with some sort of interlock so that a random io write that hits that port isn''t going to do anything bad) 3. qemu is called when the io port is triggered and maps the page to its own space Can qemu map an actual page of domu memory without a grant reference (remember, grant table is not set up at this point)? Or do I need to map a page of shared memory into the memory hole I allocated? What calls should I be making in qemu to actually map the page? Thanks James _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Keir Fraser
2010-Oct-17 08:54 UTC
Re: [Xen-devel] sharing memory between qemu and domu without grant tables or vmexits...
On 17/10/2010 09:23, "James Harper" <james.harper@bendigoit.com.au> wrote:> I''m still not sure I understand it all... might the following work them: > 1. Allocate a page of memory in my windows code > 2. Write the PFN to a known io port (with some sort of interlock so that > a random io write that hits that port isn''t going to do anything bad) > 3. qemu is called when the io port is triggered and maps the page to its > own spaceOh yes, that is probably the best way for you to get a page of memory.> Can qemu map an actual page of domu memory without a grant reference > (remember, grant table is not set up at this point)? Or do I need to map > a page of shared memory into the memory hole I allocated?Qemu can map domU memory with no need for a grant reference. Assuming you allocated a page of RAM in step 1 above, you have not allocated a ''memory hole'' and so there is no mapping into that pseudophysical frame slot to be done.> What calls should I be making in qemu to actually map the page?Probably ''xc_map_foreign_range(xc_handle, domid, XC_PAGE_SIZE, PROT_READ|PROT_WRITE, pfn_from_your_windows_driver)'' -- Keir _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel