xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* How the pv guest responds hypercall_create_continuation ?
@ 2013-05-23  0:03 Xinxin Jin
  2013-05-23  1:39 ` Matthew Daley
  2013-05-23  8:49 ` Andrew Cooper
  0 siblings, 2 replies; 3+ messages in thread
From: Xinxin Jin @ 2013-05-23  0:03 UTC (permalink / raw)
  To: Xen-devel


[-- Attachment #1.1: Type: text/plain, Size: 872 bytes --]

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

[-- Attachment #1.2: Type: text/html, Size: 1564 bytes --]

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How the pv guest responds hypercall_create_continuation ?
  2013-05-23  0:03 How the pv guest responds hypercall_create_continuation ? Xinxin Jin
@ 2013-05-23  1:39 ` Matthew Daley
  2013-05-23  8:49 ` Andrew Cooper
  1 sibling, 0 replies; 3+ messages in thread
From: Matthew Daley @ 2013-05-23  1:39 UTC (permalink / raw)
  To: Xinxin Jin; +Cc: Xen-devel

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
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How the pv guest responds hypercall_create_continuation ?
  2013-05-23  0:03 How the pv guest responds hypercall_create_continuation ? Xinxin Jin
  2013-05-23  1:39 ` Matthew Daley
@ 2013-05-23  8:49 ` Andrew Cooper
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew Cooper @ 2013-05-23  8:49 UTC (permalink / raw)
  To: Xinxin Jin; +Cc: Xen-devel@lists.xen.org


[-- Attachment #1.1: Type: text/plain, Size: 1576 bytes --]

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,
>
>
> Xinxin

The 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

[-- Attachment #1.2: Type: text/html, Size: 3009 bytes --]

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-05-23  8:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-23  0:03 How the pv guest responds hypercall_create_continuation ? Xinxin Jin
2013-05-23  1:39 ` Matthew Daley
2013-05-23  8:49 ` Andrew Cooper

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).