Hi everyone, I''m working on a research project now and encounter a problem like this: I establish a new array in the tools directory and pass the address of this array to the hypervisor. I want to know how can I translate the virtual address of the array to the machine address. In this way, the hypervisor can modify the values in this array. Thanks for your help. -- View this message in context: http://xen.1045712.n5.nabble.com/Translate-virtual-address-to-physical-address-tp5112670p5112670.html Sent from the Xen - Dev mailing list archive at Nabble.com.
On Sat, 2011-12-31 at 21:52 +0000, lmingcsce wrote:> Hi everyone, I''m working on a research project now and encounter a problem > like this: > I establish a new array in the tools directory and pass the address of this > array to the hypervisor. I want to know how can I translate the virtual > address of the array to the machine address. In this way, the hypervisor can > modify the values in this array. > Thanks for your help. >Establishing a new array in the tools *directory*? I presume the "directory" is superfluous. You can take a look at some hypercall implementations, e.g. multicall. Example code can be found at xc_minios.c:minios_privcmd_hypercall and multicall.c:do_multicall . One thing I want to remind you is that you don''t have to translate virtual address to machine address before passing it to hypervisor. copy_from_guest can handle that for you. But you do need to define GUEST_HANDLE for your hypercall. (Again, check multicall implementation for details.) Wei.
Thanks for your reply. "Establishing a new array in the tools directory" means that I declare a new array in /tools/libxc/xc_domain_save.c and want to pass the physical address of this array to the hypervisor. I have already tried copy_to_user and copy_to_guest and from the experiment, I find that there is size limit for these two functions. By the way, I also want to ask the code organization of xen. What''s the function of stubdom directory? When the virtual machines execute, the function in tools will execute in the Dom0 space? Can you illustrate that for me or give me some specific material? I have already seen some explanation, and don''t find the answer. Thanks. On Jan 1, 2012, at 6:54 AM, Wei Liu-2 [via Xen] wrote:> On Sat, 2011-12-31 at 21:52 +0000, lmingcsce wrote: > > Hi everyone, I''m working on a research project now and encounter a problem > > like this: > > I establish a new array in the tools directory and pass the address of this > > array to the hypervisor. I want to know how can I translate the virtual > > address of the array to the machine address. In this way, the hypervisor can > > modify the values in this array. > > Thanks for your help. > > > > Establishing a new array in the tools *directory*? I presume the > "directory" is superfluous. > > You can take a look at some hypercall implementations, e.g. multicall. > Example code can be found at xc_minios.c:minios_privcmd_hypercall and > multicall.c:do_multicall . > > One thing I want to remind you is that you don''t have to translate > virtual address to machine address before passing it to hypervisor. > copy_from_guest can handle that for you. But you do need to define > GUEST_HANDLE for your hypercall. (Again, check multicall implementation > for details.) > > > Wei. > > > _______________________________________________ > Xen-devel mailing list > [hidden email] > http://lists.xensource.com/xen-devel > > > If you reply to this email, your message will be added to the discussion below: > http://xen.1045712.n5.nabble.com/Translate-virtual-address-to-physical-address-tp5112670p5113058.html > To unsubscribe from Translate virtual address to physical address, click here. > NAML-- View this message in context: http://xen.1045712.n5.nabble.com/Translate-virtual-address-to-physical-address-tp5112670p5113190.html Sent from the Xen - Dev mailing list archive at Nabble.com. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Please don''t top-posting. On Sun, 2012-01-01 at 14:59 +0000, lmingcsce wrote:> Thanks for your reply. > "Establishing a new array in the tools directory" means that I declare > a new array in /tools/libxc/xc_domain_save.c and want to pass the > physical address of this array to the hypervisor. > I have already tried copy_to_user and copy_to_guest and from the > experiment, I find that there is size limit for these two functions.What size limit? I don''t quite get it. I''ve never seen an array large enough to bloat whole address space.> By the way, I also want to ask the code organization of xen. What''s > the function of stubdom directory?stubdom is used to boost HVM performance. It is based on minios, with qemu compiled in. It is not mandatory though.> When the virtual machines execute, the function in tools will execute > in the Dom0 space? Can you illustrate that for me or give me some > specific material? I have already seen some explanation, and don''t > find the answer. > Thanks.Of course tools run in Dom0, they are just normal user programs. However, every functionality requires hypervisor to do the actual job. A normal work flow is like: toolstack ---(syscall)--> kernel ---(hypercall)--> hypervisor The kernel entry is /proc/xen/privcmd, whose source code is in Linux tree drivers/xen/xenfs. Wei.