All of lore.kernel.org
 help / color / mirror / Atom feed
* Question: How to grant pages to other domUs
@ 2008-09-01 15:28 abc
  0 siblings, 0 replies; only message in thread
From: abc @ 2008-09-01 15:28 UTC (permalink / raw)
  To: Xen-devel

[-- Attachment #1: Type: text/plain, Size: 1691 bytes --]

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 
----------------------------------------------------------------------------------



[-- Attachment #2: granttables_basic.c --]
[-- Type: text/plain, Size: 1029 bytes --]

// 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;


[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-09-01 15:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-01 15:28 Question: How to grant pages to other domUs abc

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.