Hi All ,
1) I am trying to learn Xen memory sharing by writing a piece of code to
share a single page from domU to dom0
I have an producer module running in domU sharing an page & consumer
module running in dom0
- Producer writes some string in page so that consumer get read the
same string if the mapping is correct
2) I am able to get the page mapped in consumer ( dom0)
But when i try to read the string written by producer ( domU) in
consumer (dom0) ,
* Xen watchdog is triggered *
Any input as to how to map a page between dom0 & domU ?
3) The logic flow of producer & consumer is shared below ( can share the
code also if required )
// ========= Page-Produmer-domU
=======================================================
*In INIT Function: *
frame = __get_free_pages(GFP_KERNEL, 1);
framenum = virt_to_gfn(frame);
gref = gnttab_grant_foreign_access(DOM0_ID, framenum, 0); //
Grant access for one page
// Write some data to frame
strcpy((char *)frame, "Data is written in frame \n");
*In EXIT function : *
gnttab_end_foreign_access(gref, 0, frame);
// ========= Page-Consumer-dom0
=======================================================
*In INIT Function:* struct gnttab_map_grant_ref ops;
struct gnttab_unmap_grant_ref unmap_ops;
typedef struct info_t {
grant_ref_t gref;
int domid; /* remote domID */
} info_t;
info_t info;
int gref; // Value obtained from producer & passed as module-param
int domid; // Domid of producer
struct vm_struct *vm_start;
info.gref = gref;
info.domid = domid;
vm_start = alloc_vm_area(PAGE_SIZE, NULL);
gnttab_set_map_op(&ops, (unsigned long)vm_start->addr,
GNTMAP_host_map,info.gref, info.domid);
HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &ops, 1)
// == This printk causes watchdog to be triggered
=====================
printk("[Consumer-INIT]: We got string as = %s\n",
(char*)vm_start->addr );
unmap_ops.host_addr = (unsigned long)(vm_start->addr);
unmap_ops.handle = ops.handle;
*In EXIT function : *
HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &unmap_ops, 1)
//
===============================================================================
Thanks
Ashish
1) I am trying to learn Xen memory sharing by writing a piece of code to
share a single page from domU to dom0
I have an producer module running in domU sharing an page & consumer
module running in dom0
- Producer writes some string in page so that consumer get read the
same string if the mapping is correct
2) I am able to get the page mapped in consumer ( dom0)
But when i try to read the string written by producer ( domU) in
consumer (dom0) ,
* Xen watchdog is triggered *
Any input as to how to map a page between dom0 & domU ?
3) The logic flow of producer & consumer is shared below ( can share the
code also if required )
// ========= Page-Produmer-domU
=======================================================
*In INIT Function: *
frame = __get_free_pages(GFP_KERNEL, 1);
framenum = virt_to_gfn(frame);
gref = gnttab_grant_foreign_access(DOM0_ID, framenum, 0); //
Grant access for one page
// Write some data to frame
strcpy((char *)frame, "Data is written in frame \n");
*In EXIT function : *
gnttab_end_foreign_access(gref, 0, frame);
// ========= Page-Consumer-dom0
=======================================================
*In INIT Function:* struct gnttab_map_grant_ref ops;
struct gnttab_unmap_grant_ref unmap_ops;
typedef struct info_t {
grant_ref_t gref;
int domid; /* remote domID */
} info_t;
info_t info;
int gref; // Value obtained from producer & passed as module-param
int domid; // Domid of producer
struct vm_struct *vm_start;
info.gref = gref;
info.domid = domid;
vm_start = alloc_vm_area(PAGE_SIZE, NULL);
gnttab_set_map_op(&ops, (unsigned long)vm_start->addr,
GNTMAP_host_map,info.gref, info.domid);
HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &ops, 1)
// == This printk causes watchdog to be triggered
=====================
printk("[Consumer-INIT]: We got string as = %s\n",
(char*)vm_start->addr );
unmap_ops.host_addr = (unsigned long)(vm_start->addr);
unmap_ops.handle = ops.handle;
*In EXIT function : *
HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &unmap_ops, 1)
//
===============================================================================
Thanks
Ashish