Question: How to grant pages to other domUs
Hi,
I would like to have a kernel-module inside a domU granting rw-access to memory-pages for other domUs.
Below you can find an excerpt from my sources.
Everything compiles into one The module is being loaded in both guest OSs. The secondly loaded module gets the grant-reference of the granted page as commandline-argument.
The problem: DomainB always gets an error-code in the field op.status.
What's wrong with my code?
Am I missing something?
regards,
Gregor
CODE ----------------------------------------------------------------------------------
// DomainA (ID=1) -------------------------------------------------------------------- // allocate + grant a page to DomainB
unsigned int DomainB_ID = 2;
unsigned long mfn;
mfn = get_zeroed_page(0);grant_ref = gnttab_grant_foreign_access( DomainB_ID, virt_to_phys( (void *) mfn), 0 );
// DomainB (ID=2) -------------------------------------------------------------------- // obtain the granted page from DomainA
unsigned int DomainA_ID = 1;
unsigned long mfn;
struct gnttab_map_grant_ref op;
struct vm_struct *area;
op.flags = GNTMAP_host_map;
op.ref = master_grant;
op.dom = master_domain_id;
area = alloc_vm_area(PAGE_SIZE);
op.host_addr = (unsigned long) area->addr; HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
if (op.status != GNTST_okay) {
free_vm_area(area);
printk(KERN_ALERT "sm_communicator: ERROR cannot map granted page
#%li\n", master_grant);
return op.status;
}
area->phys_addr = (unsigned long) op.handle; // Stuff the handle in an unused field
LogicalAddress = area->addr;
/CODE ----------------------------------------------------------------------------------
// DomainA (ID=1) -------------------------------------------------------------------- // allocate + grant a page to DomainB
unsigned int DomainB_ID = 2;
unsigned long mfn;
mfn = get_zeroed_page(0);grant_ref = gnttab_grant_foreign_access( DomainB_ID, virt_to_phys( (void *) mfn), 0 );
// DomainB (ID=2) -------------------------------------------------------------------- // obtain the granted page from DomainA
unsigned int DomainA_ID = 1;
unsigned long mfn;
struct gnttab_map_grant_ref op;
struct vm_struct *area;
op.flags = GNTMAP_host_map;
op.ref = master_grant;
op.dom = master_domain_id;
area = alloc_vm_area(PAGE_SIZE);
op.host_addr = (unsigned long) area->addr; HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
if (op.status != GNTST_okay) {
free_vm_area(area);
printk(KERN_ALERT "sm_communicator: ERROR cannot map granted page #%li\n", master_grant); return op.status;
}
area->phys_addr = (unsigned long) op.handle; // Stuff the handle in an unused field
LogicalAddress = area->addr;
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel