WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] Question: How to grant pages to other domUs

To: Xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] Question: How to grant pages to other domUs
From: abc <abc@xxxxxxxxxxxxxx>
Date: Mon, 01 Sep 2008 17:28:10 +0200
Cc:
Delivery-date: Mon, 01 Sep 2008 08:28:34 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 2.0.0.16 (X11/20080707)
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
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] Question: How to grant pages to other domUs, abc <=