All of lore.kernel.org
 help / color / mirror / Atom feed
From: abc <abc@mailbarrier.de>
To: Xen-devel@lists.xensource.com
Subject: Question: How to grant pages to other domUs
Date: Mon, 01 Sep 2008 17:28:10 +0200	[thread overview]
Message-ID: <48BC0A0A.8090808@mailbarrier.de> (raw)

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

                 reply	other threads:[~2008-09-01 15:28 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48BC0A0A.8090808@mailbarrier.de \
    --to=abc@mailbarrier.de \
    --cc=Xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.