Mapping hvm guest pages in Dom0
hello,
I would like to map (Read/Write) pages owned by a HVM guest from my Dom0 Linux kernel module. I have access to the "machine frame numbers" of these pages.
1. What is the right interface to do this? kmap needs 'struct page' ptrs which I doubt exist for pages owned by a HVM guest. Is there a hypercall to do this then?
2. Do I need to modify the HVM behavior in any way for this? (e.g., load a driver in the guest that will setup grant tables?). I need to keep my guest "pure HVM".
thanks,
./satya
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 4 lines · Satya
hello,
I would like to map (Read/Write) pages owned by a HVM guest from my Dom0 Linux kernel module. I have access to the "machine frame numbers" of these pages.
Won't this make your HVM guest go boom?
After all you are changing the state of the pages *supposedly* owned by a HVM domain.
Quoted 4 lines
1. What is the right interface to do this? kmap needs 'struct page' ptrs which I doubt exist for pages owned by a HVM guest. Is there a hypercall to do this then?
Do grant tables exist for HVM guests, I doubt it?
Quoted 4 lines
2. Do I need to modify the HVM behavior in any way for this? (e.g., load a driver in the guest that will setup grant tables?). I need to keep my guest "pure HVM".
pure HVM which knows that some pages are being used by the domain0 will essentially make them non pure I guess :).
BTW perhaps you can make sure that a HVM domain sees a region of memory as shared with some other kernel. To do this you can write a kernel module in the HVM domain( I hope it is linux ).
But this is all pure guess work, so please do not take my word. May be you can think something better on similar lines. :)
Thanks,
--Pradeep
Quoted 10 lines
thanks,
./satya_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Signature · 3 lines
Pradeep Singh Rautela http://eagain.wordpress.com http://emptydomain.googlepages.com
Hi,
Quoted 9 lines · Satya
hello,
I would like to map (Read/Write) pages owned by a HVM guest from my Dom0 Linux kernel module. I have access to the "machine frame numbers" of these pages.1. What is the right interface to do this? kmap needs 'struct page' ptrs which I doubt exist for pages owned by a HVM guest. Is there a hypercall to do this then?
You can use xc_map_foreign_ranges function inside libxc (link with xenctrl).
Quoted 4 lines
2. Do I need to modify the HVM behavior in any way for this? (e.g., load a driver in the guest that will setup grant tables?). I need to keep my guest "pure HVM".
You don't need to modify your hvm for doing that.
Signature · 1 line
Jean Guyader
Am Freitag, 26. September 2008 schrieb Satya:
Quoted 9 lines
hello,
I would like to map (Read/Write) pages owned by a HVM guest from my Dom0 Linux kernel module. I have access to the "machine frame numbers" of these pages.1. What is the right interface to do this? kmap needs 'struct page' ptrs which I doubt exist for pages owned by a HVM guest. Is there a hypercall to do this then?
Quoted 6 lines
2. Do I need to modify the HVM behavior in any way for this? (e.g., load a driver in the guest that will setup grant tables?). I need to keep my guest "pure HVM".
thanks,
./satya
If you have the gmfn's from the HVM domU (I'am not sure where you get this from if you want to keep your guest "pure" HVM) and the domU id, you can map the domU memory into the dom0 kernel memory with
struct vm_struct area;
area = alloc_vm_area(num_pages * PAGE_SIZE); direct_kernel_remap_pfn_range(((unsigned long)) area->addr, gmfn,
PAGE_SIZE*num_pages, prots, domU_id);
Dietmar.
Signature · 5 lines
Dietmar Hahn IP SW OS6 Telephone: +49 (0) 89 636 40274 Fujitsu Siemens Computers Email: [email protected] Otto-Hahn-Ring 6 Internet: http://www.fujitsu-siemens.com D-81739 München Company details: www.fujitsu-siemens.com/imprint.html
If you have the gmfn's from the HVM domU (I'am not sure where you get this
Quoted 9 lines
from if you want to keep your guest "pure" HVM) and the domU id, you can map
the domU memory into the dom0 kernel memory withstruct
vm_structarea;
area =alloc_vm_area(num_pages * PAGE_SIZE); direct_kernel_remap_pfn_range(((unsigned long))area->addr, gmfn,PAGE_SIZE*num_pages, prots, domU_id);
I did that but the hypercall from __direct_remap_pfn_range() errors out (-EINVAL) if prots include _PAGE_PRESENT. Without this flag the kernel cannot handle reads and writes to these pages (will essentially page fault). Any thoughts?
./satya
ps: Thanks to everyone for the replies.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Am Dienstag, 7. Oktober 2008 schrieb Satya:
Quoted 11 lines
If you have the gmfn's from the HVM domU (I'am not sure where you get this
Quoted 8 lines
from if you want to keep your guest "pure" HVM) and the domU id, you can map
the domU memory into the dom0 kernel memory withstruct
vm_structarea;
area =alloc_vm_area(num_pages * PAGE_SIZE); direct_kernel_remap_pfn_range(((unsigned long))area->addr, gmfn,PAGE_SIZE*num_pages, prots, domU_id);
Quoted 8 lines
I did that but the hypercall from
__direct_remap_pfn_range()errors out (-EINVAL) if prots include_PAGE_PRESENT. Without this flag the kernel cannot handle reads and writes to these pages (will essentially page fault). Any thoughts?./satya
ps: Thanks to everyone for the replies.
Maybe your gmfn is wrong.
Are you seeing a message on serial console or 'xm log' ?
What I do is:
domU gives the gmfn's to dom0
prot = __pgprot(_KERNPG_TABLE); // _KERNPG_TABLE contains _PAGE_PRESENT
area = alloc_vm_area(num_pages * PAGE_SIZE); direct_kernel_remap_pfn_range(((unsigned long)) area->addr, gmfn,
PAGE_SIZE*num_pages, prots, domU_id);
Now I can read and write the domU memory from dom0 kernel!
You can find an example in xenoprof part in the dom0 linux kernel:xenoprof_arch_map_shared_buffer() or xenoprof_arch_set_passive() in arch/i386/oprofile/xenoprof.c
Dietmar.
Quoted 19 lines · Dietmar Hahn
Am Dienstag, 7. Oktober 2008 schrieb Satya:
Quoted 1 line
If you have the gmfn's from the HVM domU (I'am not sure where you get
this
Quoted 2 lines
Quoted 2 lines
from if you want to keep your guest "pure" HVM) and the domU id, you
can
Quoted 13 lines
Quoted 7 lines
map
the domU memory into the dom0 kernel memory withstruct
vm_structarea;
area =alloc_vm_area(num_pages * PAGE_SIZE); direct_kernel_remap_pfn_range(((unsigned long))area->addr, gmfn,PAGE_SIZE*num_pages, prots, domU_id);I did that but the hypercall from
__direct_remap_pfn_range()errors out (-EINVAL) if prots include_PAGE_PRESENT. Without this flag the kernel cannot handle reads and writes to these pages (will essentially page fault). Any thoughts?
Quoted 5 lines
Quoted 3 lines
./satya
ps: Thanks to everyone for the replies.
Maybe your gmfn is wrong.
yeah, I only have the host machine frame numbers. I don't have the 'gmfn' - which is I believe is the guest's view of this machine frame number. Is there a function f(hostmfn, domid) that will give me the corresponding gmfn? i.e I should be able to read the guest's p2m table. I sent out another message to xen-devel asking the same question, but I don't see it posted to the list yet.
Quoted 2 lines
Are you seeing a message on serial console or 'xm log' ?
Well 'xm dmesg' showed nothing relevant.
Quoted 7 lines
What I do is:
domU gives the gmfn's to dom0
prot =__pgprot(_KERNPG_TABLE); //_KERNPG_TABLEcontains_PAGE_PRESENT
area =alloc_vm_area(num_pages * PAGE_SIZE); direct_kernel_remap_pfn_range(((unsigned long))area->addr, gmfn,
Quoted 7 lines
PAGE_SIZE*num_pages, prots, domU_id);Now I can read and write the domU memory from dom0 kernel!
You can find an example in xenoprof part in the dom0 linux kernel:
xenoprof_arch_map_shared_buffer()orxenoprof_arch_set_passive()inarch/i386/oprofile/xenoprof.c
Thanks, that was helpful.
./satya
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel