Xinxin Jin
2013-May-23 00:03 UTC
How the pv guest responds hypercall_create_continuation ?
Hi all, In Xen''s hypercall handler, sometimes when -EAGAIN error happens, Xen will call a function hypercall_create_continuation(), which writes the arguments of this hypercall to guest user registers. I guess the purpose of this function is to indicate guest to try the failed hypercall again, right ? Then I looked at guest Linux''s code and try to find the interface: A typical guest hypercall calling routine is (take HYPERVISOR_mmu_update for example): static inline int HYPERVISOR_mmu_update( mmu_update_t *req, int count, int *success_count, domid_t domid) { return _hypercall4(int, mmu_update, req, count, success_count, domid); } Then _hypercall4 will call corresponding code in hypercall_page and return. But where is the interface with hypercall_create_continuation()? How the guest knows it needs to try the hypercall again? Thanks a lot, Xinxin _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
Matthew Daley
2013-May-23 01:39 UTC
Re: How the pv guest responds hypercall_create_continuation ?
On Thu, May 23, 2013 at 12:03 PM, Xinxin Jin <xinxinjin89@gmail.com> wrote:> Hi all, > > In Xen''s hypercall handler, sometimes when -EAGAIN error happens, Xen will > call a function hypercall_create_continuation(), which writes the arguments > of this hypercall to guest user registers. I guess the purpose of this > function is to indicate guest to try the failed hypercall again, right ? > Then I looked at guest Linux''s code and try to find the interface: > > A typical guest hypercall calling routine is (take HYPERVISOR_mmu_update for > example): > > static inline int > HYPERVISOR_mmu_update( > mmu_update_t *req, int count, int *success_count, domid_t domid) > { > return _hypercall4(int, mmu_update, req, count, success_count, domid); > } > > Then _hypercall4 will call corresponding code in hypercall_page and return. > But where is the interface with hypercall_create_continuation()? How the > guest knows it needs to try the hypercall again?You must have missed this part of hypercall_create_continuation: http://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=xen/arch/x86/domain.c;h=161d1b34d7e5097e8316b7ac99fba2b2d246640e;hb=HEAD#l1563 This rewinds the guest''s IP so that the hypercall is re-executed when the guest is rescheduled. The guest hypercall argument register writes you saw (as defined by the ''format'' argument) ensure that work continues where it was left off when the hypercall was stopped and a continuation formed. - Matthew> > Thanks a lot, > > > Xinxin > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel >
Andrew Cooper
2013-May-23 08:49 UTC
Re: How the pv guest responds hypercall_create_continuation ?
On 23/05/13 01:03, Xinxin Jin wrote:> Hi all, > > In Xen''s hypercall handler, sometimes when -EAGAIN error happens, Xen > will call a function hypercall_create_continuation(), which writes the > arguments of this hypercall to guest user registers. I guess the > purpose of this function is to indicate guest to try the failed > hypercall again, right ? Then I looked at guest Linux''s code and try > to find the interface: > > A typical guest hypercall calling routine is (take > HYPERVISOR_mmu_update for example): > > static inline int > HYPERVISOR_mmu_update( > mmu_update_t *req, int count, int *success_count, domid_t domid) > { > return _hypercall4(int, mmu_update, req, count, success_count, domid); > } > > Then _hypercall4 will call corresponding code in hypercall_page and > return. But where is the interface with > hypercall_create_continuation()? How the guest knows it needs to try > the hypercall again? > > Thanks a lot, > > > XinxinThe whole point of hypercall continuations is to reduce the time spent in the hypervisor without processing softirqs/events etc. Therefore, long running hypercall operations create continuations, allowing a small chunk of work to be done now, and the next chunk of work to be done when the VCPU is next scheduled, which might be right afterwards but might be in a long times time. The mechanism for creating a continuation is to store the intermediate state in the guest registers and subtract 2 from the guests EIP, causing it to re-execute the int 0x82/sysenter/syscall instruction when next scheduled. ~Andrew --------------070707000205020607000306 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: 8bit <html> <head> <meta content="text/html; charset=UTF-8" http-equiv="Content-Type"> </head> <body text="#000000" bgcolor="#FFFFFF"> <div class="moz-cite-prefix">On 23/05/13 01:03, Xinxin Jin wrote:<br> </div> <blockquote cite="mid:CAJJWZcyH3gVw6cRkk2fYb73zTVUnKKr8P3A1Ojen4ceUiS0Lqw@mail.gmail.com" type="cite"><font face="arial,helvetica,sans-serif">Hi all, </font> <div><font face="arial,helvetica,sans-serif"><br> </font></div> <div><font face="arial, helvetica, sans-serif">In Xen''s hypercall handler, sometimes when -EAGAIN error happens, Xen will call a function hypercall_create_continuation(), which writes the arguments of this hypercall to guest user registers. I guess the purpose of this function is to indicate guest to try the failed hypercall again, right ? Then I looked at guest Linux''s code and try to find the interface:</font></div> <div><font face="arial, helvetica, sans-serif"><br> </font></div> <div><font face="arial, helvetica, sans-serif">A typical guest hypercall calling routine is (take HYPERVISOR_mmu_update for example):</font></div> <div><font face="arial, helvetica, sans-serif"><br> </font></div> <div><font face="arial, helvetica, sans-serif"> <div>static inline int</div> <div>HYPERVISOR_mmu_update(</div> <div> mmu_update_t *req, int count, int *success_count, domid_t domid)</div> <div>{</div> <div> return _hypercall4(int, mmu_update, req, count, success_count, domid);</div> <div>}</div> <div><br> </div> <div>Then _hypercall4 will call corresponding code in hypercall_page and return. But where is the interface with hypercall_create_continuation()? How the guest knows it needs to try the hypercall again?</div> <div><br> </div> <div>Thanks a lot,</div> </font></div> <div><font face="arial,helvetica,sans-serif"><br clear="all"> </font><br clear="all"> <div><font face="arial, helvetica, sans-serif">Xinxin</font></div> </div> </blockquote> <br> The whole point of hypercall continuations is to reduce the time spent in the hypervisor without processing softirqs/events etc.<br> <br> Therefore, long running hypercall operations create continuations, allowing a small chunk of work to be done now, and the next chunk of work to be done when the VCPU is next scheduled, which might be right afterwards but might be in a long times time.<br> <br> The mechanism for creating a continuation is to store the intermediate state in the guest registers and subtract 2 from the guests EIP, causing it to re-execute the int 0x82/sysenter/syscall instruction when next scheduled.<br> <br> ~Andrew<br> </body> </html> --------------070707000205020607000306-- --===============7788172207690795171=Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --===============7788172207690795171==--