* Confusion about copy_to/from_guest @ 2010-04-26 2:32 Tej 2010-04-26 5:33 ` Keir Fraser 0 siblings, 1 reply; 3+ messages in thread From: Tej @ 2010-04-26 2:32 UTC (permalink / raw) To: xen-devel All, Small and naive question about the semantics of copy_to/from_guest. In Kernel space I have created a linked list lets say 10 elements. Now I have created similar list in hypervisor. Now passing the list_head from kernel using hypercall. Now how do I copy the element between kernel and hypervisor. 1. copy_from_guest(hyp_list_head, arg, 1) or copy_from_guest(hyp_list_head, arg, <num_of_elements_list>) 2. copy_to_guest(arg, hyp_list_head, 1) or copy_to_guest(arg, hyp_list_head, <num of element in list>) 2nd question: I did first one, but first element of list was not accessible in hypervisor space, why? It looks like I am doing something horribly wrong, so can someone point out that. Thanks for any help -tej ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Confusion about copy_to/from_guest 2010-04-26 2:32 Confusion about copy_to/from_guest Tej @ 2010-04-26 5:33 ` Keir Fraser 2010-04-27 11:52 ` Tej 0 siblings, 1 reply; 3+ messages in thread From: Keir Fraser @ 2010-04-26 5:33 UTC (permalink / raw) To: Tej, xen-devel@lists.xensource.com On 26/04/2010 03:32, "Tej" <bewith.tej@gmail.com> wrote: > Now passing the list_head from kernel using hypercall. Now how do I > copy the element between kernel and hypervisor. > > 1. copy_from_guest(hyp_list_head, arg, 1) or > copy_from_guest(hyp_list_head, arg, <num_of_elements_list>) > 2. copy_to_guest(arg, hyp_list_head, 1) or copy_to_guest(arg, > hyp_list_head, <num of element in list>) The first of these. Copy_{to,from}_guest can copy arrays of structures, but since this is a linked structure you'd have to do the copy one element at a time. > 2nd question: > I did first one, but first element of list was not accessible in > hypervisor space, why? Well, if you are really only copying the list_head, the above should work. -- Keir ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Confusion about copy_to/from_guest 2010-04-26 5:33 ` Keir Fraser @ 2010-04-27 11:52 ` Tej 0 siblings, 0 replies; 3+ messages in thread From: Tej @ 2010-04-27 11:52 UTC (permalink / raw) To: Keir Fraser; +Cc: xen-devel@lists.xensource.com On Mon, Apr 26, 2010 at 11:03 AM, Keir Fraser <keir.fraser@eu.citrix.com> wrote: > On 26/04/2010 03:32, "Tej" <bewith.tej@gmail.com> wrote: > >> Now passing the list_head from kernel using hypercall. Now how do I >> copy the element between kernel and hypervisor. >> >> 1. copy_from_guest(hyp_list_head, arg, 1) or >> copy_from_guest(hyp_list_head, arg, <num_of_elements_list>) >> 2. copy_to_guest(arg, hyp_list_head, 1) or copy_to_guest(arg, >> hyp_list_head, <num of element in list>) > > The first of these. Copy_{to,from}_guest can copy arrays of structures, but > since this is a linked structure you'd have to do the copy one element at a > time. you mean to say, in hypervisor space copy first element using copy_from_guest(hyp_list_head, arg, 1), extract the next address from it and then copy again the next element using "copy_from_guest(hyp_list_head->next, arg->next, 1)" ??? > >> 2nd question: >> I did first one, but first element of list was not accessible in >> hypervisor space, why? > > Well, if you are really only copying the list_head, the above should work. Yes, I have carried out the sample test, by allocating small struct linked list and then passing between hypervisor and kernel copy_from_guest(hyp_list_head, arg, 1) is working correctly. But my actial code is not working. Ok let me put some more effort, if not I will push the code for review. Thanks for your help > > -- Keir > > > ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-04-27 11:52 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-04-26 2:32 Confusion about copy_to/from_guest Tej 2010-04-26 5:33 ` Keir Fraser 2010-04-27 11:52 ` Tej
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).