Skip to contentSkip to conversation

Blocking upcall to dom0

DISCUSSION Andrew Biggadike 3 participants 8 messages Feb 28, 2005 – Mar 2, 2005

lore
Share & tools
lore
#0 lore raw

xen-devel,

I'm working on a project in which I'd like to implement an upcall into dom0 from certain points within Xen, where Xen is running in the context of one of the unprivileged domains. The upcall will pass a variable-sized data structure (up to a few hundred bytes) to dom0, and I need Xen to block on the completion of this upcall. Also, it's important that the source of the upcall start from within Xen itself, rather than the domU guest.

For example, on each hypercall from a particular domU, I'd want to collect a bunch of state from within Xen and pass that state to dom0, then wait for a return value before continuing on with the hypercall.

I'm looking for suggestions on the best way to go about this. I've just started looking at the event channel code and I'm wondering how I can best use this. My first thought is to create a virtual interrupt, but I'm not sure whether this will synchronously deliver the VIRQ and wait for dom0 to complete before proceeding. Another issue is how best to pass the data, though it appears a shared page between Xen and dom0 is the preferred approach.

Any information or pointers to files/functions would be a great help.

Thanks,
Andrew

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click

#1 lore raw
Quoted 7 lines · Andrew Biggadike

I'm working on a project in which I'd like to implement an upcall into dom0 from certain points within Xen, where Xen is running in the context of one of the unprivileged domains. The upcall will pass a variable-sized data structure (up to a few hundred bytes) to dom0, and I need Xen to block on the completion of this upcall. Also, it's important that the source of the upcall start from within Xen itself, rather than the domU guest.

In what context do you want to block? That of some other domain, or block all domains while dom0 executes, or something else?

Xen doesn't support arbitrary blocking within itself since it only maintains per-CPU stacks, not per-domain stacks. So you have to create a closure manually.

-- Keir

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click

#2 lore raw
Quoted 2 lines · Keir Fraser

In what context do you want to block? That of some other domain, or block all domains while dom0 executes, or something else?

I want to block in the context of the unprivileged domain that was running, and only block that domain. In the hypercall example I gave, I'd want the domain that invoked the hypercall to block within Xen until dom0 completed the upcall.

Quoted 2 lines

Xen doesn't support arbitrary blocking within itself since it only maintains per-CPU stacks, not per-domain stacks.

Interesting. So this means the scheduler is only ever invoked on entry to and exit from Xen when there is no Xen state to worry about saving?

Quoted 1 line

So you have to create a closure manually.

This is a bit more work than I had bargained for, but it seems doable. Does temporarily setting a different schedule_tail() function to restore the state from the closure seem reasonable?

Andrew

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click

#3 lore raw
Quoted 6 lines · Andrew Biggadike
Quoted 2 lines

Xen doesn't support arbitrary blocking within itself since it only maintains per-CPU stacks, not per-domain stacks.

Interesting. So this means the scheduler is only ever invoked on entry to and exit from Xen when there is no Xen state to worry about saving?

Or at other times when we really know what we are doing (e.g., interrupting long-lived hypercalls).

Quoted 5 lines
Quoted 1 line

So you have to create a closure manually.

This is a bit more work than I had bargained for, but it seems doable. Does temporarily setting a different schedule_tail() function to restore the state from the closure seem reasonable?

I think that would be an excellent place to hook in.

-- Keir

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click

#4 lore raw
In reply to Andrew Biggadike
Quoted 9 lines
Quoted 2 lines · Keir Fraser

In what context do you want to block? That of some other domain, or block all domains while dom0 executes, or something else?

I want to block in the context of the unprivileged domain that was running, and only block that domain. In the hypercall example I gave, I'd want the domain that invoked the hypercall to block within Xen until dom0 completed the upcall.

Why not just use an event channel? This is precisely what they are for. That way the invoking domain can simply kick an event, and block waiting for a response. No new magic required in Xen at all.

S.

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click

#5 lore raw
Quoted 9 lines · Steven Hand
Quoted 8 lines
Quoted 2 lines · Keir Fraser

In what context do you want to block? That of some other domain, or block all domains while dom0 executes, or something else?

I want to block in the context of the unprivileged domain that was running, and only block that domain. In the hypercall example I gave, I'd want the domain that invoked the hypercall to block within Xen until dom0 completed the upcall.

Quoted 4 lines

Why not just use an event channel? This is precisely what they are for. That way the invoking domain can simply kick an event, and block waiting for a response. No new magic required in Xen at all.

That's what I was originally thinking, but from Keir's first reply it seems that I can't arbitrarily block within Xen since stacks are per-CPU rather than per-domain.

I'd like to block within Xen and resume at that same point in Xen, not in the guest. If I understand the flow of things correctly, then using an event channel and blocking will resume the domain from the guest's last execution context, rather than Xen's. Please correct me if I'm wrong.

Thanks,
Andrew

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click

#6 lore raw
Quoted 9 lines · Andrew Biggadike

That's what I was originally thinking, but from Keir's first reply it seems that I can't arbitrarily block within Xen since stacks are per-CPU rather than per-domain.

I'd like to block within Xen and resume at that same point in Xen, not in the guest. If I understand the flow of things correctly, then using an event channel and blocking will resume the domain from the guest's last execution context, rather than Xen's. Please correct me if I'm wrong.

Yes that's right. So you want to block on communications that the guest is unaware of?

-- Keir

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click

#7 lore raw
Quoted 4 lines · Keir Fraser
Quoted 4 lines

That's what I was originally thinking, but from Keir's first reply it seems that I can't arbitrarily block within Xen since stacks are per-CPU rather than per-domain.

Quoted 8 lines
Quoted 5 lines

I'd like to block within Xen and resume at that same point in Xen, not in the guest. If I understand the flow of things correctly, then using an event channel and blocking will resume the domain from the guest's last execution context, rather than Xen's. Please correct me if I'm wrong.

Yes that's right. So you want to block on communications that the guest is unaware of?

Yes, exactly. I'm looking at ways to do intrusion detection on the guest kernel, so I want to decide whether the guest should continue without it being involved in the decision or information flow.

Andrew

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click