Skip to contentSkip to conversation

Communication between HVM and dom0 through the Hypervisor

DISCUSSION Daniele Sgandurra 3 participants 7 messages Apr 18, 2007 – Apr 19, 2007

lore
Share & tools
lore
#0 lore raw

Is there currently a method for passing information between a HVM domain and domain 0 directly through the hypervisor?
I understand there could be at least three ways to do so:

-VMCALL from HVM + params in registers. -using "PV-on-HVM", but I think the frontend drivers need to be ported in the mainline Linux kernel and this is currently being done, right?
-using XenStore/XenBus (is that possible?)

As an example, suppose I have a HVM running Linux (on Intel IVT-x), and I want to call a callback function in dom0 each time the HVM contacts the hypervisor, what would you suggest me to do? Imagine I want to notify dom0 each time a process issues a system call, by adding some code in the prologue of the syscall handler to notify the hypervisor.

Thank you very much :-)

      ___________________________________ 

L'email della prossima generazione? Puoi averla con la nuova Yahoo! Mail: http://it.docs.yahoo.com/nowyoucan.html

#1 lore raw
Quoted 19 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Daniele Sgandurra
Sent: 18 April 2007 16:22
To: [email protected]
Subject: [Xen-devel] Communication between HVM and dom0 through the Hypervisor

Is there currently a method for passing information between a HVM domain and domain 0 directly through the hypervisor?
I understand there could be at least three ways to do so:

(quoted diff) +0 -2
-VMCALL from HVM + params in registers.
-using "PV-on-HVM", but I think the frontend drivers
Quoted 2 lines

need to be ported in the mainline Linux kernel and this is currently being done, right?

What do you mean. There is the "unmodified_drivers" directory in Xen, which contains, as far as I know, complete drivers for block and network on HVM Linux. Of course, you'd need a differnet source-code if you want Linux 2.4 drivers or Windows drivers, neither of which is supplied with Xen's sources.

Quoted 1 line

-using XenStore/XenBus (is that possible?)

I believe so, but I'm not entirely sure about how that works in a HVM guest.

Quoted 8 lines

As an example, suppose I have a HVM running Linux (on Intel IVT-x), and I want to call a callback function in dom0 each time the HVM contacts the hypervisor, what would you suggest me to do? Imagine I want to notify dom0 each time a process issues a system call, by adding some code in the prologue of the syscall handler to notify the hypervisor.

You can use VM[M]CALL, although this is ALREADY being used for PV-on-HVM drivers, so you'd have to filter your calls from the ones used by PV-on-HVM drivers (using a high bit to indicate that those are your functions rather than PV-calls would be the easiest method).

Another possibility is to find a unused IO-port or memory address and cause a IOIO-exit or Page-fault on a MMIO address that isn't otherwise used. IO-ports such as 0xBCDE, 0xAAA0 are most likely not used, so you could to a 8, 16 or 32-bit IO to one of those pretty easily.

The NEXT problem is of course getting this information out of the hypervisor into Dom0.

--
Mats

Quoted 15 lines

Thank you very much :-)

      ___________________________________ 

L'email della prossima generazione? Puoi averla con la nuova Yahoo! Mail: http://it.docs.yahoo.com/nowyoucan.html

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#2 lore raw
Quoted 6 lines
Quoted 6 lines

Is there currently a method for passing information between a HVM domain and domain 0 directly through the hypervisor?
I understand there could be at least three ways to do so:

Quoted 10 lines
Quoted 4 lines
(quoted diff) +0 -2
-VMCALL from HVM + params in registers.
-using "PV-on-HVM", but I think the frontend drivers

need to be ported in the mainline Linux kernel and this is currently being done, right?

What do you mean. There is the "unmodified_drivers" directory in Xen, which contains, as far as I know, complete drivers for block and network on HVM Linux. Of course, you'd need a differnet source-code if you want Linux 2.4 drivers or Windows drivers, neither of which is supplied with Xen's sources.

I think Daniele has read confusing accounts of the PV-on-HVM drivers vs the mainline kernel merge. These are (semi) independent issues: for Linux 2.6 PV-on-HVM drivers can simply be built by the administrator and installed into their VM if they want them.

The code that's being proposed for the Linux merge is to support full PV, not PV-on-HVM (as far as I know).

Quoted 4 lines
Quoted 1 line

-using XenStore/XenBus (is that possible?)

I believe so, but I'm not entirely sure about how that works in a HVM guest.

Yes, but it requires the PV-on-HVM driver infrastructure. I'm not clear on the exact implementation details, but it involves the guest talking to a fake "Xen platform" PCI device, which enables it to then set up a Xenstore connection and share configuration data on it.

Quoted 13 lines
Quoted 7 lines

As an example, suppose I have a HVM running Linux (on Intel IVT-x), and I want to call a callback function in dom0 each time the HVM contacts the hypervisor, what would you suggest me to do? Imagine I want to notify dom0 each time a process issues a system call, by adding some code in the prologue of the syscall handler to notify the hypervisor.

You can use VM[M]CALL, although this is ALREADY being used for PV-on-HVM drivers, so you'd have to filter your calls from the ones used by PV-on-HVM drivers (using a high bit to indicate that those are your functions rather than PV-calls would be the easiest method).

Quoted 7 lines

Another possibility is to find a unused IO-port or memory address and cause a IOIO-exit or Page-fault on a MMIO address that isn't otherwise used. IO-ports such as 0xBCDE, 0xAAA0 are most likely not used, so you could to a 8, 16 or 32-bit IO to one of those pretty easily.

The NEXT problem is of course getting this information out of the hypervisor into Dom0.

It it possible to arrange for a VMEXIT to occur on int 0x80 (which IIRC is the Linux system call... I guess VT-x would also be able to intercept sysenter)? That way the guest wouldn't have to be modified to notify Xen. Xen would then have to e.g. share a ring buffer with dom0 regarding events of this nature for each domain. You could hack something up so that the guest blocked on each syscall until dom0 acknowledged it...

There's also the Xen gdb server - maybe (if it supports HVM guests?) you could use this to watch the syscall paths.

HTH,
cheers,
Mark

Signature · 4 lines
Dave: Just a question. What use is a unicyle with no seat?  And no pedals!
Mark: To answer a question with a question: What use is a skateboard?
Dave: Skateboards have wheels.
Mark: My wheel has a wheel!
#3 lore raw
Quoted 10 lines

There's also the Xen gdb server - maybe (if it
supports HVM guests?) you could
use this to watch the syscall paths.

HTH,
cheers,
Mark

Yes, gdb-server works on HVM too (I was able to make it work with a HVM domain running Fedora and installing the kernel-debuginfo on dom0). There is also a useful paper on kernel debugging with gbd on Xen:
https://ols2006.108.redhat.com/reprints/kamble-reprint.pdf

Thank you very much for your hints :-)

      ___________________________________ 

L'email della prossima generazione? Puoi averla con la nuova Yahoo! Mail: http://it.docs.yahoo.com/nowyoucan.html

#4 lore raw
In reply to Mark Williamson
Quoted 50 lines

-----Original Message-----
From: M.A. Williamson [mailto:[email protected]] On Behalf Of Mark Williamson
Sent: 19 April 2007 03:22
To: [email protected]
Cc: Petersson, Mats; Daniele Sgandurra
Subject: Re: [Xen-devel] Communication between HVM and dom0 through the Hypervisor

Quoted 6 lines
Quoted 6 lines

Is there currently a method for passing information between a HVM domain and domain 0 directly through the hypervisor?
I understand there could be at least three ways to do so:

Quoted 6 lines
Quoted 4 lines
(quoted diff) +0 -2
-VMCALL from HVM + params in registers.
-using "PV-on-HVM", but I think the frontend drivers

need to be ported in the mainline Linux kernel and this is currently being done, right?

What do you mean. There is the "unmodified_drivers"

directory in Xen,

Quoted 1 line

which contains, as far as I know, complete drivers for

block and network

Quoted 1 line

on HVM Linux. Of course, you'd need a differnet source-code

if you want

Quoted 1 line

Linux 2.4 drivers or Windows drivers, neither of which is

supplied with

Quoted 1 line

Xen's sources.

I think Daniele has read confusing accounts of the PV-on-HVM drivers vs the
mainline kernel merge. These are (semi) independent issues:
for Linux 2.6
PV-on-HVM drivers can simply be built by the administrator and installed into
their VM if they want them.

The code that's being proposed for the Linux merge is to support full PV, not
PV-on-HVM (as far as I know).

Quoted 3 lines
Quoted 1 line

-using XenStore/XenBus (is that possible?)

I believe so, but I'm not entirely sure about how that

works in a HVM

Quoted 1 line

guest.

Quoted 7 lines

Yes, but it requires the PV-on-HVM driver infrastructure. I'm not clear on
the exact implementation details, but it involves the guest talking to a
fake "Xen platform" PCI device, which enables it to then set up a Xenstore
connection and share configuration data on it.

Thanks for filling that in.

Quoted 15 lines
Quoted 10 lines
Quoted 8 lines

As an example, suppose I have a HVM running Linux (on Intel IVT-x), and I want to call a callback function in dom0 each time the HVM contacts the hypervisor, what would you suggest me to do? Imagine I want to notify dom0 each time a process issues a system call, by adding some code in the prologue of the syscall handler to notify the hypervisor.

You can use VM[M]CALL, although this is ALREADY being used

for PV-on-HVM

Quoted 4 lines

drivers, so you'd have to filter your calls from the ones used by PV-on-HVM drivers (using a high bit to indicate that those are your functions rather than PV-calls would be the easiest method).

Quoted 7 lines
Quoted 1 line

Another possibility is to find a unused IO-port or memory

address and

Quoted 1 line

cause a IOIO-exit or Page-fault on a MMIO address that

isn't otherwise

Quoted 1 line

used. IO-ports such as 0xBCDE, 0xAAA0 are most likely not

used, so you

Quoted 1 line

could to a 8, 16 or 32-bit IO to one of those pretty easily.

One thing I forgot to add: At the point of the intercept, you will have access to all CPU registers, so it's not really important which method you use for the intercept from that perspective.

Quoted 4 lines
Quoted 3 lines

The NEXT problem is of course getting this information out of the hypervisor into Dom0.

Quoted 11 lines

It it possible to arrange for a VMEXIT to occur on int 0x80 (which IIRC is the
Linux system call... I guess VT-x would also be able to intercept sysenter)?
That way the guest wouldn't have to be modified to notify Xen. Xen would
then have to e.g. share a ring buffer with dom0 regarding events of this
nature for each domain. You could hack something up so that the guest
blocked on each syscall until dom0 acknowledged it...

Now,that's a brilliant idea. Why didn't I think of that.

Only one minor problem: It will only work for INT n instructions (but since it's possible to hide SYSENTER/SYSCALL instrutions from the guest via CPUID intercept, it can at least for 32-bit be forced to only do INT 80h calls), and only on AMD processors (this is more of a problem, as the original post talks about Intel processors). Intel processors don't allow intercepts of INT n instructions. Neither processor allow intercepts of SYSENTER/SYSCALL instructions. [It's still a very good idea, and I wish I had at least THOUGHT of it!]

--
Mats

Quoted 18 lines

There's also the Xen gdb server - maybe (if it supports HVM guests?) you could
use this to watch the syscall paths.

HTH,
cheers,
Mark

Signature · 5 lines
Dave: Just a question. What use is a unicyle with no seat?  
And no pedals!
Mark: To answer a question with a question: What use is a skateboard?
Dave: Skateboards have wheels.
Mark: My wheel has a wheel!
#5 lore raw
Quoted 14 lines
Quoted 11 lines

It it possible to arrange for a VMEXIT to occur on int 0x80 (which IIRC is the
Linux system call... I guess VT-x would also be able to intercept sysenter)?
That way the guest wouldn't have to be modified to notify Xen. Xen would
then have to e.g. share a ring buffer with dom0 regarding events of this
nature for each domain. You could hack something up so that the guest
blocked on each syscall until dom0 acknowledged it...

Now,that's a brilliant idea. Why didn't I think of that.

Quoted 8 lines

Only one minor problem: It will only work for INT n instructions (but since it's possible to hide SYSENTER/SYSCALL instrutions from the guest via CPUID intercept, it can at least for 32-bit be forced to only do INT 80h calls), and only on AMD processors (this is more of a problem, as the original post talks about Intel processors). Intel processors don't allow intercepts of INT n instructions. Neither processor allow intercepts of SYSENTER/SYSCALL instructions. [It's still a very good idea, and I wish I had at least THOUGHT of it!]

Perhaps on intel, something could be bodged together? E.g. intercept loading the IDT and replace the handler for the int n you're interested in with something that'll cause a trap? I'm not really clear out sysenter etc actually works, so not so sure about that.

I did read through the VT-x / VT-i manuals at some stage, but it's a long time ago and things are a bit hazy now :-)

Cheers,
Mark

Signature · 4 lines
Dave: Just a question. What use is a unicyle with no seat?  And no pedals!
Mark: To answer a question with a question: What use is a skateboard?
Dave: Skateboards have wheels.
Mark: My wheel has a wheel!
#6 lore raw
Quoted 39 lines

-----Original Message-----
From: M.A. Williamson [mailto:[email protected]] On Behalf Of Mark Williamson
Sent: 19 April 2007 15:07
To: Petersson, Mats
Cc: [email protected]; Daniele Sgandurra
Subject: Re: [Xen-devel] Communication between HVM and dom0 through the Hypervisor

Quoted 12 lines
Quoted 11 lines

It it possible to arrange for a VMEXIT to occur on int 0x80 (which IIRC is the
Linux system call... I guess VT-x would also be able to intercept sysenter)?
That way the guest wouldn't have to be modified to notify Xen. Xen would
then have to e.g. share a ring buffer with dom0 regarding events of this
nature for each domain. You could hack something up so that the guest
blocked on each syscall until dom0 acknowledged it...

Quoted 3 lines

Now,that's a brilliant idea. Why didn't I think of that.

Only one minor problem: It will only work for INT n

instructions (but

Quoted 1 line

since it's possible to hide SYSENTER/SYSCALL instrutions

from the guest

Quoted 1 line

via CPUID intercept, it can at least for 32-bit be forced

to only do INT

Quoted 1 line

80h calls), and only on AMD processors (this is more of a

problem, as

Quoted 1 line

the original post talks about Intel processors). Intel

processors don't

Quoted 3 lines

allow intercepts of INT n instructions. Neither processor allow intercepts of SYSENTER/SYSCALL instructions. [It's still a very good idea, and I wish I had at least THOUGHT of it!]

Quoted 7 lines

Perhaps on intel, something could be bodged together? E.g. intercept loading
the IDT and replace the handler for the int n you're interested in with
something that'll cause a trap? I'm not really clear out sysenter etc
actually works, so not so sure about that.

Possibly. The obvious solution of just stuffing an invalid value in CS would perhaps work, and then fix up CS and "continue". Of course, the difficulty may well be that IDT isn't actually hard-coded, so the IDT entry for INT 80h isn't in the IDT when it's written to - of course, we could change the IDT to an "invalid" address so that it generates a page-fault, identify that it's the IDT and then set the entries manually in the page-fault handler. Ideally, for this, you'd want to set the IDT read-only, and then trap only on writes - that way there's no penalty on interrupt traffic itself (which only reads the IDT).

SYSENTER/SYSCALL uses MSR's to determine the RIP, RSP, CS etc. Not sure if it's possible to set those up with a bad register (CS) or some such - possibly it will work - it's possible to intercept the MSR writes to these registers (in fact Intel does for some of them already, if not all).

An alternative to an invalid CS is an invalid RIP that causes a page-fault, and replace the RIP with the correct value (as per the MSR/IDT write). If the RIP is wrong, I expect the trap to come after the IDT has been read and the old values stored on the stack - not quite sure if that's the case for invalid CS for example, so using an invalid RIP value may be better].

Quoted 4 lines

I did read through the VT-x / VT-i manuals at some stage, but it's a long time
ago and things are a bit hazy now :-)

I had to look it up, so I don't expect someone who isn't actively working on HVM-stuff to know these type of things.

--
Mats

Quoted 13 lines

Cheers,
Mark

Signature · 5 lines
Dave: Just a question. What use is a unicyle with no seat?  
And no pedals!
Mark: To answer a question with a question: What use is a skateboard?
Dave: Skateboards have wheels.
Mark: My wheel has a wheel!