|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: Watchdog triggered while trying to access shared page
Hi Ashish,
The overall model that you are trying to follow should work.
Just make sure that the EXIT function of producer-domU is not called
until the consuder-dom0 has finished reading the data.
More comments inline below, I found a couple of issues.
AshishKumar Mishra wrote:
> 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);
Can you try to use kmalloc, or better alloc_xenballooned_pages, instead
of alloc_vm_area to allocate the page? See:
drivers/xen/xenbus/xenbus_client.c:xenbus_map_ring_valloc_hvm as a
reference.
> gnttab_set_map_op(&ops, (unsigned long)vm_start->addr,
You need to pass the guest physical address of the page/vm_area, not the
virtual address (i.e. the __pa() address).
> 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
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |