From mboxrd@z Thu Jan 1 00:00:00 1970 From: abc Subject: Question: How to grant pages to other domUs Date: Mon, 01 Sep 2008 17:28:10 +0200 Message-ID: <48BC0A0A.8090808@mailbarrier.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------020905090705050107080204" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. --------------020905090705050107080204 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit 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 ---------------------------------------------------------------------------------- --------------020905090705050107080204 Content-Type: text/plain; name="granttables_basic.c" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="granttables_basic.c" // 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; --------------020905090705050107080204 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --------------020905090705050107080204--