Skip to contentSkip to conversation

Full virtualization and I/O

DISCUSSION Thomas Heinz 5 participants 12 messages Nov 20, 2006 – Nov 23, 2006

lore
Share & tools
lore
#0 lore raw

Hi

Full virtualization is about providing multiple virtual ISA level environments and mapping them to a single physical one. One particular aspect of this mapping are I/O instructions (explicit or mmapped I/O). In general, there are two strategies to partition the devices, either in time or in space. Partitioning a device in space means that the device (or a part of it) is exclusively available to a single VM. Partitioning a device in time (or time multiplexing) means that it can be used by multiple VMs but only one VM may use it at any point in time.

I am trying to understand how I/O virtualization on the ISA level works if a device is shared between multiple VM instances. On a very high level, it should be as follows. First of all, the VMM has to intercept the VM's I/O commands (I/O instructions or load/store to dedicated memory addresses - let's ignore interrupts for the moment). This could be done by traps or by replacing the resp. instructions by VMM calls to I/O primitives. The VMM keeps multiple device model instances (one for each VM using the device) in memory. The models somehow reflect the low level I/O API of the device. Depending on which I/O command is issued by the VM, either the memory model is changed or a number of I/O instructions are executed to make the physical device state reflect the one represented in the memory model.

This approach brings up a number of questions. It would be great if some of the virtualization experts here could shed some light on them (even though they are not immediately related to Xen, I know):

- How do these device memory models look like? Is there a common (automata) theory behind or are they done ad hoc?
- What kind of strategies/algorithms are used in the merge phase, i.e. the phase where the virtual memory model and the physical one are synchronized? What kind of problems can occur in this phase?
- Are specific usage patterns used in real world implementations (e.g. VMWare) to simplify the virtualization (model or merge phase)?
- Do you have any interesting pointers to literature dealing with full I/O virtualization? In particular, how does VMWare's full virtualization works with respect to I/O?
- Is every device time partitionable? If not, which requirements does it have to meet to be time partitionable?
-> I don't think every device is. What about a device which supports
different modes of operation. If two VMs drive the virtual device in different modes, it may not be possible to constantly switch between them. Ok, this is pretty artificial.

Thanks a lot for your help!

Best wishes

Thomas

#1 lore raw
Quoted 10 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Thomas Heinz
Sent: 20 November 2006 23:39
To: [email protected]
Subject: [Xen-devel] Full virtualization and I/O

Hi

Quoted 14 lines

Full virtualization is about providing multiple virtual ISA level environments and mapping them to a single physical one. One particular
aspect of this mapping are I/O instructions (explicit or mmapped I/O). In
general, there are two strategies to partition the devices, either in time
or in space. Partitioning a device in space means that the device (or a
part of it) is exclusively available to a single VM. Partitioning a device
in time (or time multiplexing) means that it can be used by multiple VMs
but only one VM may use it at any point in time.

The Xen approach is to not allow any sharing of devices, a device is owned by one domain, no other domain can directly access the device. There is a protocol of so called frontend/backend driver which is basically a dummy-device that forwards a request to another domain (normally domain 0) and the other half of the driver-pair is picking up this data, forwards it to some processing task, that then sends the packet onto the real hardware.

For fully virtualized mode (hardware supported virtual machine, such as AMD-V or Intel VT, aka HVM), there is a different model, where a "device model" is involved to perform the hardware modelling. In Xen, this is using a modified version of qemu (called qemu-dm), which has a fairly complete set of "hardware" in it's model. It's got for example IDE controller, several types of network devices, graphics and mouse/keyboard models. The things you'd usually find in a PC, that is. The way it works is that the hypervisor intercepts IOIO and memory mapped IO regions that match the devices involved (such as the A0000-BFFFF region for VGA frame buffer memory or the 0x1F0-0x1F7 IO ports for the IDE controller), and forwards a request from the hypervisor to qemu-dm, where the operation changes the current state, and when it's necessary, the state-change will result in for example a read-request to the "hard-disk" (which may be a real disk, a file on a local disk, or a file on a network storage device, to give some examples).

There is also the option of using the frontend drivers as described above in the fully virtualized model.

Finally, while I'm on the subject of fully virtualized mode: It is currently not possible to give a DMA-based device to a fully-virtualized domain. The reason for this is that the guest OS will have been told that memory is from 0..256MB (say), and it's actual machine physical address is at 256MB..512MB. The OS is completely unaware of this "mismatch". So the OS will perform some operation to take a virtual address of some buffer (say a network packet) and make it into a "physical address", which will be an address in the range of 0..256MB. This will of course (at least) lead to the wrong data being transmitted, as the address of the actual data is somewhere in the range 256MB..512MB. The only solution to this is to have an IOMMU, which can translate the guest's understanding of a physical address (0..256MB) to a machine physical address (256..512MB).

Quoted 13 lines

I am trying to understand how I/O virtualization on the ISA level works if
a device is shared between multiple VM instances. On a very high level, it
should be as follows. First of all, the VMM has to intercept the VM's I/O
commands (I/O instructions or load/store to dedicated memory addresses -
let's ignore interrupts for the moment). This could be done by traps or by
replacing the resp. instructions by VMM calls to I/O primitives. The VMM

Quoted 8 lines

keeps multiple device model instances (one for each VM using the device)
in memory. The models somehow reflect the low level I/O API of the device.
Depending on which I/O command is issued by the VM, either the memory model is changed or a number of I/O instructions are executed to make the
physical device state reflect the one represented in the memory model.

Do you by ISA mean "Instruction Set Architecture" or something else (I presume it's NOT meaning ISA-bus...)?

Intercepting IOIO instructions or MMIO instructions is not that hard - in HVM the two processor architectures have specific intercepts and bitmaps to indicate which IO instructions should be intercepted. MMIO will require the page-tables to be set up such that the memory mapped region is mapped "not present" so that any operation to this region gives a page-fault, and then the page-fault is analyzed to see if it's for a MMIO address or for a "real page fault".

For para-virtualization, the model is similar, but the exact model of how to intercept the IOIO or MMIO instruction is slightly different - but in essence it's the same principle. Let me know if you really need to know how Xen goes about doing this, as it's quite complicated (more so than the HVM version, for sure).

Quoted 9 lines

This approach brings up a number of questions. It would be great if some of
the virtualization experts here could shed some light on them (even though
they are not immediately related to Xen, I know):

- How do these device memory models look like? Is there a common (automata) theory behind or are they done ad hoc?

Not sure what you're asking for here. Since the devices are either modeled after a REAL device (qemu-dm) and as such will resemble as closely as possible the REAL hardware device that it's emulating, or in the frontend/backend driver, there is an "idealized model", such that the request contains just the basic data that the OS provides normally to the driver, and it's placed in a queue with a message-signaling system to tell the other side that it's got something in the queue.

Quoted 4 lines

- What kind of strategies/algorithms are used in the merge phase, i.e. the
phase where the virtual memory model and the physical one are synchronized? What kind of problems can occur in this phase?

The Xen approach is to avoid this by only giving one device to each machine.

Quoted 2 lines

- Are specific usage patterns used in real world implementations (e.g. VMWare) to simplify the virtualization (model or merge phase)?

This is probably the wrong list to ask detailed questions about how VMWare works... ;-)

Quoted 4 lines

- Do you have any interesting pointers to literature dealing with full I/O
virtualization? In particular, how does VMWare's full virtualization works with respect to I/O?

Again, wrong list for VMWare questions.

Quoted 3 lines

- Is every device time partitionable? If not, which requirements does it
have to meet to be time partitionable?

Certainly not - I would say that almost all devices are NOT time partitionable, as the state in the device is dependant on the current usage. The more complex the device is, the more likely it is to have difficulties, but even such a simple deevice as a serial port would struggle to work in a time-shared fashion (not to mention that serial ports generally are used for multiple transactions to make a whole "bigger picture transaction", so for example a web-server connected via a serial modem would send a packet of several hundred bytes to the serial port driver, which is then portioned out as and when the serial port is ready to send another few bytes. If you switch from one guest to another during this process, and the second guest also has something to send on the serial port, you'd end up with a very scrambled message from the first guest and quite likely the second guests message completely lost!).

There are some devices that are specifically built to manage multiple hosts, but other than that, any sharing of a device requires some software to gather up "a full transaction" and then sending that to the actual hardware, often also waiting for the transaction to complete (for example the interrupt signal to say that the hard disk write is complete).

Quoted 6 lines

-> I don't think every device is. What about a device which supports
different modes of operation. If two VMs drive the
virtual device in
different modes, it may not be possible to constantly
switch between
them. Ok, this is pretty artificial.

A particular problem is devices where you can't necessarily read back the last mode-setting, which may well be the case in many different devices. You can't, for example, read back all the registers on an IDE device, because the read of a particular address amy give the status rather than the current comamnd sent, or some such.

--
Mats

Quoted 15 lines

Thanks a lot for your help!

Best wishes

Thomas

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

#2 lore raw

Hi Mats,

Thanks for your explanation in such details.

As you mentioned in your post, could you elaborate using unmodified driver in HVM domain (i.e. using front-end driver in full-virtualized domain)? Do you think para-virtualized domain will have exactly the same behavior as full-virtualized domain when both of them are using this unmodified driver to access virtual block devices?

Best regards,

Liang

----- Original Message ----- From: "Petersson, Mats" <[email protected]>
To: "Thomas Heinz" <[email protected]>; <[email protected]>
Sent: Wednesday, November 22, 2006 9:24 AM
Subject: RE: [Xen-devel] Full virtualization and I/O

Quoted 10 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Thomas Heinz
Sent: 20 November 2006 23:39
To: [email protected]
Subject: [Xen-devel] Full virtualization and I/O

Hi

Quoted 14 lines

Full virtualization is about providing multiple virtual ISA level environments and mapping them to a single physical one. One particular
aspect of this mapping are I/O instructions (explicit or mmapped I/O). In
general, there are two strategies to partition the devices, either in time
or in space. Partitioning a device in space means that the device (or a
part of it) is exclusively available to a single VM. Partitioning a device
in time (or time multiplexing) means that it can be used by multiple VMs
but only one VM may use it at any point in time.

The Xen approach is to not allow any sharing of devices, a device is owned by one domain, no other domain can directly access the device. There is a protocol of so called frontend/backend driver which is basically a dummy-device that forwards a request to another domain (normally domain 0) and the other half of the driver-pair is picking up this data, forwards it to some processing task, that then sends the packet onto the real hardware.

For fully virtualized mode (hardware supported virtual machine, such as AMD-V or Intel VT, aka HVM), there is a different model, where a "device model" is involved to perform the hardware modelling. In Xen, this is using a modified version of qemu (called qemu-dm), which has a fairly complete set of "hardware" in it's model. It's got for example IDE controller, several types of network devices, graphics and mouse/keyboard models. The things you'd usually find in a PC, that is. The way it works is that the hypervisor intercepts IOIO and memory mapped IO regions that match the devices involved (such as the A0000-BFFFF region for VGA frame buffer memory or the 0x1F0-0x1F7 IO ports for the IDE controller), and forwards a request from the hypervisor to qemu-dm, where the operation changes the current state, and when it's necessary, the state-change will result in for example a read-request to the "hard-disk" (which may be a real disk, a file on a local disk, or a file on a network storage device, to give some examples).

There is also the option of using the frontend drivers as described above in the fully virtualized model.

Finally, while I'm on the subject of fully virtualized mode: It is currently not possible to give a DMA-based device to a fully-virtualized domain. The reason for this is that the guest OS will have been told that memory is from 0..256MB (say), and it's actual machine physical address is at 256MB..512MB. The OS is completely unaware of this "mismatch". So the OS will perform some operation to take a virtual address of some buffer (say a network packet) and make it into a "physical address", which will be an address in the range of 0..256MB. This will of course (at least) lead to the wrong data being transmitted, as the address of the actual data is somewhere in the range 256MB..512MB. The only solution to this is to have an IOMMU, which can translate the guest's understanding of a physical address (0..256MB) to a machine physical address (256..512MB).

Quoted 13 lines

I am trying to understand how I/O virtualization on the ISA level works if
a device is shared between multiple VM instances. On a very high level, it
should be as follows. First of all, the VMM has to intercept the VM's I/O
commands (I/O instructions or load/store to dedicated memory addresses -
let's ignore interrupts for the moment). This could be done by traps or by
replacing the resp. instructions by VMM calls to I/O primitives. The VMM

Quoted 8 lines

keeps multiple device model instances (one for each VM using the device)
in memory. The models somehow reflect the low level I/O API of the device.
Depending on which I/O command is issued by the VM, either the memory model is changed or a number of I/O instructions are executed to make the
physical device state reflect the one represented in the memory model.

Do you by ISA mean "Instruction Set Architecture" or something else (I presume it's NOT meaning ISA-bus...)?

Intercepting IOIO instructions or MMIO instructions is not that hard - in HVM the two processor architectures have specific intercepts and bitmaps to indicate which IO instructions should be intercepted. MMIO will require the page-tables to be set up such that the memory mapped region is mapped "not present" so that any operation to this region gives a page-fault, and then the page-fault is analyzed to see if it's for a MMIO address or for a "real page fault".

For para-virtualization, the model is similar, but the exact model of how to intercept the IOIO or MMIO instruction is slightly different - but in essence it's the same principle. Let me know if you really need to know how Xen goes about doing this, as it's quite complicated (more so than the HVM version, for sure).

Quoted 9 lines

This approach brings up a number of questions. It would be great if some of
the virtualization experts here could shed some light on them (even though
they are not immediately related to Xen, I know):

- How do these device memory models look like? Is there a common (automata) theory behind or are they done ad hoc?

Not sure what you're asking for here. Since the devices are either modeled after a REAL device (qemu-dm) and as such will resemble as closely as possible the REAL hardware device that it's emulating, or in the frontend/backend driver, there is an "idealized model", such that the request contains just the basic data that the OS provides normally to the driver, and it's placed in a queue with a message-signaling system to tell the other side that it's got something in the queue.

Quoted 4 lines

- What kind of strategies/algorithms are used in the merge phase, i.e. the
phase where the virtual memory model and the physical one are synchronized? What kind of problems can occur in this phase?

The Xen approach is to avoid this by only giving one device to each machine.

Quoted 2 lines

- Are specific usage patterns used in real world implementations (e.g. VMWare) to simplify the virtualization (model or merge phase)?

This is probably the wrong list to ask detailed questions about how VMWare works... ;-)

Quoted 4 lines

- Do you have any interesting pointers to literature dealing with full I/O
virtualization? In particular, how does VMWare's full virtualization works with respect to I/O?

Again, wrong list for VMWare questions.

Quoted 3 lines

- Is every device time partitionable? If not, which requirements does it
have to meet to be time partitionable?

Certainly not - I would say that almost all devices are NOT time partitionable, as the state in the device is dependant on the current usage. The more complex the device is, the more likely it is to have difficulties, but even such a simple deevice as a serial port would struggle to work in a time-shared fashion (not to mention that serial ports generally are used for multiple transactions to make a whole "bigger picture transaction", so for example a web-server connected via a serial modem would send a packet of several hundred bytes to the serial port driver, which is then portioned out as and when the serial port is ready to send another few bytes. If you switch from one guest to another during this process, and the second guest also has something to send on the serial port, you'd end up with a very scrambled message from the first guest and quite likely the second guests message completely lost!).

There are some devices that are specifically built to manage multiple hosts, but other than that, any sharing of a device requires some software to gather up "a full transaction" and then sending that to the actual hardware, often also waiting for the transaction to complete (for example the interrupt signal to say that the hard disk write is complete).

Quoted 6 lines

-> I don't think every device is. What about a device which supports
different modes of operation. If two VMs drive the
virtual device in
different modes, it may not be possible to constantly
switch between
them. Ok, this is pretty artificial.

A particular problem is devices where you can't necessarily read back the last mode-setting, which may well be the case in many different devices. You can't, for example, read back all the registers on an IDE device, because the read of a particular address amy give the status rather than the current comamnd sent, or some such.

--
Mats

Quoted 4 lines

Thanks a lot for your help!

Quoted 11 lines

Best wishes

Thomas

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

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

#3 lore raw
Quoted 13 lines

-----Original Message-----
From: Liang Yang [mailto:[email protected]]
Sent: 22 November 2006 16:51
To: Petersson, Mats
Cc: Thomas Heinz; [email protected]
Subject: Re: [Xen-devel] Full virtualization and I/O

Hi Mats,

Thanks for your explanation in such details.

Quoted 9 lines

As you mentioned in your post, could you elaborate using unmodified driver
in HVM domain (i.e. using front-end driver in full-virtualized domain)? Do
you think para-virtualized domain will have exactly the same behavior as
full-virtualized domain when both of them are using this unmodified driver
to access virtual block devices?

Not sure exactly what you're asking, but if you're asking if the performance of driver-related work will be approximately the same, yes.

By the way, I wouldn't call that an "unmodified" driver - it is definitely a MODIFIED driver (a para-virtual driver).

--
Mats

Quoted 245 lines

Best regards,

Liang

----- Original Message -----
From: "Petersson, Mats" <[email protected]>
To: "Thomas Heinz" <[email protected]>; <[email protected]>
Sent: Wednesday, November 22, 2006 9:24 AM
Subject: RE: [Xen-devel] Full virtualization and I/O

Quoted 10 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Thomas Heinz
Sent: 20 November 2006 23:39
To: [email protected]
Subject: [Xen-devel] Full virtualization and I/O

Hi

Quoted 14 lines

Full virtualization is about providing multiple virtual ISA level environments and mapping them to a single physical one. One particular
aspect of this mapping are I/O instructions (explicit or mmapped I/O). In
general, there are two strategies to partition the devices, either in time
or in space. Partitioning a device in space means that the device (or a
part of it) is exclusively available to a single VM. Partitioning a device
in time (or time multiplexing) means that it can be used by multiple VMs
but only one VM may use it at any point in time.

The Xen approach is to not allow any sharing of devices, a device is owned by one domain, no other domain can directly access the device. There is a protocol of so called frontend/backend driver which is basically a dummy-device that forwards a request to another domain (normally domain 0) and the other half of the driver-pair is picking up
this data, forwards it to some processing task, that then sends the packet onto the real hardware.

For fully virtualized mode (hardware supported virtual machine, such as
AMD-V or Intel VT, aka HVM), there is a different model, where a "device
model" is involved to perform the hardware modelling. In Xen, this is using a modified version of qemu (called qemu-dm), which has a fairly complete set of "hardware" in it's model. It's got for example IDE controller, several types of network devices, graphics and mouse/keyboard models. The things you'd usually find in a PC, that is. The way it works is that the hypervisor intercepts IOIO and memory mapped IO regions that match the devices involved (such as the A0000-BFFFF region for VGA frame buffer memory or the 0x1F0-0x1F7 IO ports for the IDE controller), and forwards a request from the hypervisor to qemu-dm, where the operation changes the current state, and when it's necessary, the state-change will result in for example a read-request to the "hard-disk" (which may be a real disk, a file on a local disk, or a file on a network storage device, to give some examples).

There is also the option of using the frontend drivers as described above in the fully virtualized model.

Finally, while I'm on the subject of fully virtualized mode: It is currently not possible to give a DMA-based device to a fully-virtualized
domain. The reason for this is that the guest OS will have been told that memory is from 0..256MB (say), and it's actual machine physical address is at 256MB..512MB. The OS is completely unaware of this "mismatch". So the OS will perform some operation to take a virtual address of some buffer (say a network packet) and make it into a "physical address", which will be an address in the range of 0..256MB. This will of course (at least) lead to the wrong data being transmitted,
as the address of the actual data is somewhere in the range 256MB..512MB. The only solution to this is to have an IOMMU, which can translate the guest's understanding of a physical address (0..256MB) to
a machine physical address (256..512MB).

Quoted 10 lines

I am trying to understand how I/O virtualization on the ISA level works if
a device is shared between multiple VM instances. On a very high level, it
should be as follows. First of all, the VMM has to intercept the VM's I/O
commands (I/O instructions or load/store to dedicated memory addresses -
let's ignore interrupts for the moment). This could be done

Quoted 8 lines

by traps or by
replacing the resp. instructions by VMM calls to I/O primitives. The VMM
keeps multiple device model instances (one for each VM using the device)
in memory. The models somehow reflect the low level I/O API of the device.
Depending on which I/O command is issued by the VM, either

the memory

Quoted 3 lines

model is changed or a number of I/O instructions are executed to make the
physical device state reflect the one represented in the

memory model.

Do you by ISA mean "Instruction Set Architecture" or something else (I presume it's NOT meaning ISA-bus...)?

Intercepting IOIO instructions or MMIO instructions is not that hard - in HVM the two processor architectures have specific intercepts and bitmaps to indicate which IO instructions should be intercepted. MMIO will require the page-tables to be set up such that the memory mapped region is mapped "not present" so that any operation to this region gives a page-fault, and then the page-fault is analyzed to see if it's for a MMIO address or for a "real page fault".

For para-virtualization, the model is similar, but the exact model of how to intercept the IOIO or MMIO instruction is slightly different - but in essence it's the same principle. Let me know if you really need to know how Xen goes about doing this, as it's quite complicated (more so than the HVM version, for sure).

Quoted 9 lines

This approach brings up a number of questions. It would be great if some of
the virtualization experts here could shed some light on them (even though
they are not immediately related to Xen, I know):

- How do these device memory models look like? Is there a common (automata) theory behind or are they done ad hoc?

Not sure what you're asking for here. Since the devices are either modeled after a REAL device (qemu-dm) and as such will resemble as closely as possible the REAL hardware device that it's emulating, or in
the frontend/backend driver, there is an "idealized model", such that the request contains just the basic data that the OS provides normally to the driver, and it's placed in a queue with a message-signaling system to tell the other side that it's got something in the queue.

Quoted 4 lines

- What kind of strategies/algorithms are used in the merge phase, i.e. the
phase where the virtual memory model and the physical one are synchronized? What kind of problems can occur in this phase?

The Xen approach is to avoid this by only giving one device to each machine.

Quoted 1 line

- Are specific usage patterns used in real world

implementations (e.g.

Quoted 1 line

VMWare) to simplify the virtualization (model or merge phase)?

This is probably the wrong list to ask detailed questions about how VMWare works... ;-)

Quoted 3 lines

- Do you have any interesting pointers to literature dealing with full I/O
virtualization? In particular, how does VMWare's full

virtualization

Quoted 1 line

works with respect to I/O?

Again, wrong list for VMWare questions.

Quoted 3 lines

- Is every device time partitionable? If not, which requirements does it
have to meet to be time partitionable?

Certainly not - I would say that almost all devices are NOT time partitionable, as the state in the device is dependant on the current usage. The more complex the device is, the more likely it is to have difficulties, but even such a simple deevice as a serial port would struggle to work in a time-shared fashion (not to mention that serial ports generally are used for multiple transactions to make a whole "bigger picture transaction", so for example a web-server connected via
a serial modem would send a packet of several hundred bytes to the serial port driver, which is then portioned out as and when the serial port is ready to send another few bytes. If you switch from one guest to
another during this process, and the second guest also has something to
send on the serial port, you'd end up with a very scrambled message from
the first guest and quite likely the second guests message completely lost!).

There are some devices that are specifically built to manage multiple hosts, but other than that, any sharing of a device requires some software to gather up "a full transaction" and then sending that to the
actual hardware, often also waiting for the transaction to complete (for
example the interrupt signal to say that the hard disk write is complete).

Quoted 1 line

-> I don't think every device is. What about a device

which supports

Quoted 5 lines

different modes of operation. If two VMs drive the
virtual device in
different modes, it may not be possible to constantly
switch between
them. Ok, this is pretty artificial.

A particular problem is devices where you can't necessarily read back the last mode-setting, which may well be the case in many different devices. You can't, for example, read back all the registers on an IDE device, because the read of a particular address amy give the status rather than the current comamnd sent, or some such.

--
Mats

Quoted 4 lines

Thanks a lot for your help!

Quoted 11 lines

Best wishes

Thomas

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

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

#4 lore raw

Hi Mats,

This para-virtualized driver in HVM domain is just like the dummy device driver in para-virtualized domain. And after using this para-virtualized driver in HVM domain, HVM doamin is also using this kind of front-end/back-end model to handle I/O instead of using "device model" which a typical HVM domain will use.

Am I correct?

Liang

----- Original Message ----- From: "Petersson, Mats" <[email protected]>
To: "Liang Yang" <[email protected]>
Cc: "Thomas Heinz" <[email protected]>; <[email protected]>
Sent: Wednesday, November 22, 2006 9:57 AM
Subject: RE: [Xen-devel] Full virtualization and I/O

Quoted 11 lines

-----Original Message-----
From: Liang Yang [mailto:[email protected]]
Sent: 22 November 2006 16:51
To: Petersson, Mats
Cc: Thomas Heinz; [email protected]
Subject: Re: [Xen-devel] Full virtualization and I/O

Hi Mats,

Thanks for your explanation in such details.

Quoted 9 lines

As you mentioned in your post, could you elaborate using unmodified driver
in HVM domain (i.e. using front-end driver in full-virtualized domain)? Do
you think para-virtualized domain will have exactly the same behavior as
full-virtualized domain when both of them are using this unmodified driver
to access virtual block devices?

Not sure exactly what you're asking, but if you're asking if the performance of driver-related work will be approximately the same, yes.

By the way, I wouldn't call that an "unmodified" driver - it is definitely a MODIFIED driver (a para-virtual driver).

--
Mats

Quoted 245 lines

Best regards,

Liang

----- Original Message -----
From: "Petersson, Mats" <[email protected]>
To: "Thomas Heinz" <[email protected]>; <[email protected]>
Sent: Wednesday, November 22, 2006 9:24 AM
Subject: RE: [Xen-devel] Full virtualization and I/O

Quoted 10 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Thomas Heinz
Sent: 20 November 2006 23:39
To: [email protected]
Subject: [Xen-devel] Full virtualization and I/O

Hi

Quoted 14 lines

Full virtualization is about providing multiple virtual ISA level environments and mapping them to a single physical one. One particular
aspect of this mapping are I/O instructions (explicit or mmapped I/O). In
general, there are two strategies to partition the devices, either in time
or in space. Partitioning a device in space means that the device (or a
part of it) is exclusively available to a single VM. Partitioning a device
in time (or time multiplexing) means that it can be used by multiple VMs
but only one VM may use it at any point in time.

The Xen approach is to not allow any sharing of devices, a device is owned by one domain, no other domain can directly access the device. There is a protocol of so called frontend/backend driver which is basically a dummy-device that forwards a request to another domain (normally domain 0) and the other half of the driver-pair is picking up
this data, forwards it to some processing task, that then sends the packet onto the real hardware.

For fully virtualized mode (hardware supported virtual machine, such as
AMD-V or Intel VT, aka HVM), there is a different model, where a "device
model" is involved to perform the hardware modelling. In Xen, this is using a modified version of qemu (called qemu-dm), which has a fairly complete set of "hardware" in it's model. It's got for example IDE controller, several types of network devices, graphics and mouse/keyboard models. The things you'd usually find in a PC, that is. The way it works is that the hypervisor intercepts IOIO and memory mapped IO regions that match the devices involved (such as the A0000-BFFFF region for VGA frame buffer memory or the 0x1F0-0x1F7 IO ports for the IDE controller), and forwards a request from the hypervisor to qemu-dm, where the operation changes the current state, and when it's necessary, the state-change will result in for example a read-request to the "hard-disk" (which may be a real disk, a file on a local disk, or a file on a network storage device, to give some examples).

There is also the option of using the frontend drivers as described above in the fully virtualized model.

Finally, while I'm on the subject of fully virtualized mode: It is currently not possible to give a DMA-based device to a fully-virtualized
domain. The reason for this is that the guest OS will have been told that memory is from 0..256MB (say), and it's actual machine physical address is at 256MB..512MB. The OS is completely unaware of this "mismatch". So the OS will perform some operation to take a virtual address of some buffer (say a network packet) and make it into a "physical address", which will be an address in the range of 0..256MB. This will of course (at least) lead to the wrong data being transmitted,
as the address of the actual data is somewhere in the range 256MB..512MB. The only solution to this is to have an IOMMU, which can translate the guest's understanding of a physical address (0..256MB) to
a machine physical address (256..512MB).

Quoted 10 lines

I am trying to understand how I/O virtualization on the ISA level works if
a device is shared between multiple VM instances. On a very high level, it
should be as follows. First of all, the VMM has to intercept the VM's I/O
commands (I/O instructions or load/store to dedicated memory addresses -
let's ignore interrupts for the moment). This could be done

Quoted 8 lines

by traps or by
replacing the resp. instructions by VMM calls to I/O primitives. The VMM
keeps multiple device model instances (one for each VM using the device)
in memory. The models somehow reflect the low level I/O API of the device.
Depending on which I/O command is issued by the VM, either

the memory

Quoted 3 lines

model is changed or a number of I/O instructions are executed to make the
physical device state reflect the one represented in the

memory model.

Do you by ISA mean "Instruction Set Architecture" or something else (I presume it's NOT meaning ISA-bus...)?

Intercepting IOIO instructions or MMIO instructions is not that hard - in HVM the two processor architectures have specific intercepts and bitmaps to indicate which IO instructions should be intercepted. MMIO will require the page-tables to be set up such that the memory mapped region is mapped "not present" so that any operation to this region gives a page-fault, and then the page-fault is analyzed to see if it's for a MMIO address or for a "real page fault".

For para-virtualization, the model is similar, but the exact model of how to intercept the IOIO or MMIO instruction is slightly different - but in essence it's the same principle. Let me know if you really need to know how Xen goes about doing this, as it's quite complicated (more so than the HVM version, for sure).

Quoted 9 lines

This approach brings up a number of questions. It would be great if some of
the virtualization experts here could shed some light on them (even though
they are not immediately related to Xen, I know):

- How do these device memory models look like? Is there a common (automata) theory behind or are they done ad hoc?

Not sure what you're asking for here. Since the devices are either modeled after a REAL device (qemu-dm) and as such will resemble as closely as possible the REAL hardware device that it's emulating, or in
the frontend/backend driver, there is an "idealized model", such that the request contains just the basic data that the OS provides normally to the driver, and it's placed in a queue with a message-signaling system to tell the other side that it's got something in the queue.

Quoted 4 lines

- What kind of strategies/algorithms are used in the merge phase, i.e. the
phase where the virtual memory model and the physical one are synchronized? What kind of problems can occur in this phase?

The Xen approach is to avoid this by only giving one device to each machine.

Quoted 1 line

- Are specific usage patterns used in real world

implementations (e.g.

Quoted 1 line

VMWare) to simplify the virtualization (model or merge phase)?

This is probably the wrong list to ask detailed questions about how VMWare works... ;-)

Quoted 3 lines

- Do you have any interesting pointers to literature dealing with full I/O
virtualization? In particular, how does VMWare's full

virtualization

Quoted 1 line

works with respect to I/O?

Again, wrong list for VMWare questions.

Quoted 3 lines

- Is every device time partitionable? If not, which requirements does it
have to meet to be time partitionable?

Certainly not - I would say that almost all devices are NOT time partitionable, as the state in the device is dependant on the current usage. The more complex the device is, the more likely it is to have difficulties, but even such a simple deevice as a serial port would struggle to work in a time-shared fashion (not to mention that serial ports generally are used for multiple transactions to make a whole "bigger picture transaction", so for example a web-server connected via
a serial modem would send a packet of several hundred bytes to the serial port driver, which is then portioned out as and when the serial port is ready to send another few bytes. If you switch from one guest to
another during this process, and the second guest also has something to
send on the serial port, you'd end up with a very scrambled message from
the first guest and quite likely the second guests message completely lost!).

There are some devices that are specifically built to manage multiple hosts, but other than that, any sharing of a device requires some software to gather up "a full transaction" and then sending that to the
actual hardware, often also waiting for the transaction to complete (for
example the interrupt signal to say that the hard disk write is complete).

Quoted 1 line

-> I don't think every device is. What about a device

which supports

Quoted 5 lines

different modes of operation. If two VMs drive the
virtual device in
different modes, it may not be possible to constantly
switch between
them. Ok, this is pretty artificial.

A particular problem is devices where you can't necessarily read back the last mode-setting, which may well be the case in many different devices. You can't, for example, read back all the registers on an IDE device, because the read of a particular address amy give the status rather than the current comamnd sent, or some such.

--
Mats

Quoted 4 lines

Thanks a lot for your help!

Quoted 11 lines

Best wishes

Thomas

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

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

#5 lore raw
Quoted 21 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Liang Yang
Sent: 22 November 2006 17:17
To: Petersson, Mats
Cc: [email protected]; Thomas Heinz
Subject: Re: [Xen-devel] Full virtualization and I/O

Hi Mats,

This para-virtualized driver in HVM domain is just like the dummy device
driver in para-virtualized domain. And after using this para-virtualized
driver in HVM domain, HVM doamin is also using this kind of front-end/back-end model to handle I/O instead of using "device model" which
a typical HVM domain will use.

Quoted 1 line

Am I correct?

Yes, exactly.

Of course, the HVM domain may well use a mixture, say for example using the normal (device-model) IDE device driver to access the disk, and a para-virtual network driver to access the network.

--
Mats

Quoted 326 lines

Liang

----- Original Message -----
From: "Petersson, Mats" <[email protected]>
To: "Liang Yang" <[email protected]>
Cc: "Thomas Heinz" <[email protected]>; <[email protected]>
Sent: Wednesday, November 22, 2006 9:57 AM
Subject: RE: [Xen-devel] Full virtualization and I/O

Quoted 11 lines

-----Original Message-----
From: Liang Yang [mailto:[email protected]]
Sent: 22 November 2006 16:51
To: Petersson, Mats
Cc: Thomas Heinz; [email protected]
Subject: Re: [Xen-devel] Full virtualization and I/O

Hi Mats,

Thanks for your explanation in such details.

Quoted 9 lines

As you mentioned in your post, could you elaborate using unmodified driver
in HVM domain (i.e. using front-end driver in full-virtualized domain)? Do
you think para-virtualized domain will have exactly the same behavior as
full-virtualized domain when both of them are using this unmodified driver
to access virtual block devices?

Not sure exactly what you're asking, but if you're asking if the performance of driver-related work will be approximately the same, yes.

By the way, I wouldn't call that an "unmodified" driver - it is definitely a MODIFIED driver (a para-virtual driver).

--
Mats

Quoted 47 lines

Best regards,

Liang

----- Original Message -----
From: "Petersson, Mats" <[email protected]>
To: "Thomas Heinz" <[email protected]>; <[email protected]>
Sent: Wednesday, November 22, 2006 9:24 AM
Subject: RE: [Xen-devel] Full virtualization and I/O

Quoted 10 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Thomas Heinz
Sent: 20 November 2006 23:39
To: [email protected]
Subject: [Xen-devel] Full virtualization and I/O

Hi

Quoted 14 lines

Full virtualization is about providing multiple virtual ISA level environments and mapping them to a single physical one. One particular
aspect of this mapping are I/O instructions (explicit or mmapped I/O). In
general, there are two strategies to partition the devices, either in time
or in space. Partitioning a device in space means that the device (or a
part of it) is exclusively available to a single VM. Partitioning a device
in time (or time multiplexing) means that it can be used by multiple VMs
but only one VM may use it at any point in time.

The Xen approach is to not allow any sharing of devices, a device is owned by one domain, no other domain can directly access the device. There is a protocol of so called frontend/backend driver which is basically a dummy-device that forwards a request to another domain (normally domain 0) and the other half of the driver-pair is picking up
this data, forwards it to some processing task, that then sends the packet onto the real hardware.

Quoted 5 lines

For fully virtualized mode (hardware supported virtual machine, such as
AMD-V or Intel VT, aka HVM), there is a different model, where a "device
model" is involved to perform the hardware modelling. In

Xen, this is

Quoted 1 line

using a modified version of qemu (called qemu-dm), which

has a fairly

Quoted 3 lines

complete set of "hardware" in it's model. It's got for example IDE controller, several types of network devices, graphics and mouse/keyboard models. The things you'd usually find in a

PC, that is.

Quoted 5 lines

The way it works is that the hypervisor intercepts IOIO and memory mapped IO regions that match the devices involved (such as the A0000-BFFFF region for VGA frame buffer memory or the 0x1F0-0x1F7 IO ports for the IDE controller), and forwards a request from the hypervisor to qemu-dm, where the operation changes the

current state,

Quoted 1 line

and when it's necessary, the state-change will result in

for example a

Quoted 1 line

read-request to the "hard-disk" (which may be a real disk,

a file on a

Quoted 6 lines

local disk, or a file on a network storage device, to give some examples).

There is also the option of using the frontend drivers as described above in the fully virtualized model.

Quoted 9 lines

Finally, while I'm on the subject of fully virtualized mode: It is currently not possible to give a DMA-based device to a fully-virtualized
domain. The reason for this is that the guest OS will have been told that memory is from 0..256MB (say), and it's actual machine physical address is at 256MB..512MB. The OS is completely unaware of this "mismatch". So the OS will perform some operation to take a virtual address of some buffer (say a network packet) and make it into a "physical address", which will be an address in the range

of 0..256MB.

Quoted 4 lines

This will of course (at least) lead to the wrong data being transmitted,
as the address of the actual data is somewhere in the range 256MB..512MB. The only solution to this is to have an

IOMMU, which can

Quoted 22 lines

translate the guest's understanding of a physical address (0..256MB) to
a machine physical address (256..512MB).

Quoted 10 lines

I am trying to understand how I/O virtualization on the ISA level works if
a device is shared between multiple VM instances. On a very high level, it
should be as follows. First of all, the VMM has to intercept the VM's I/O
commands (I/O instructions or load/store to dedicated memory addresses -
let's ignore interrupts for the moment). This could be done

Quoted 8 lines

by traps or by
replacing the resp. instructions by VMM calls to I/O primitives. The VMM
keeps multiple device model instances (one for each VM using the device)
in memory. The models somehow reflect the low level I/O API of the device.
Depending on which I/O command is issued by the VM, either

Quoted 7 lines

the memory

Quoted 3 lines

model is changed or a number of I/O instructions are executed to make the
physical device state reflect the one represented in the

memory model.

Do you by ISA mean "Instruction Set Architecture" or

something else (I

Quoted 3 lines

presume it's NOT meaning ISA-bus...)?

Intercepting IOIO instructions or MMIO instructions is not

that hard -

Quoted 2 lines

in HVM the two processor architectures have specific intercepts and bitmaps to indicate which IO instructions should be

intercepted. MMIO

Quoted 1 line

will require the page-tables to be set up such that the

memory mapped

Quoted 2 lines

region is mapped "not present" so that any operation to this region gives a page-fault, and then the page-fault is analyzed to

see if it's

Quoted 3 lines

for a MMIO address or for a "real page fault".

For para-virtualization, the model is similar, but the

exact model of

Quoted 1 line

how to intercept the IOIO or MMIO instruction is slightly

different -

Quoted 1 line

but in essence it's the same principle. Let me know if you

really need

Quoted 1 line

to know how Xen goes about doing this, as it's quite

complicated (more

Quoted 10 lines

so than the HVM version, for sure).

Quoted 7 lines

This approach brings up a number of questions. It would be great if some of
the virtualization experts here could shed some light on them (even though
they are not immediately related to Xen, I know):

Quoted 8 lines
Quoted 2 lines

- How do these device memory models look like? Is there a common (automata) theory behind or are they done ad hoc?

Not sure what you're asking for here. Since the devices are either modeled after a REAL device (qemu-dm) and as such will resemble as closely as possible the REAL hardware device that it's emulating, or in
the frontend/backend driver, there is an "idealized model",

such that

Quoted 1 line

the request contains just the basic data that the OS

provides normally

Quoted 24 lines

to the driver, and it's placed in a queue with a message-signaling system to tell the other side that it's got something in the queue.

Quoted 4 lines

- What kind of strategies/algorithms are used in the merge phase, i.e. the
phase where the virtual memory model and the physical one are synchronized? What kind of problems can occur in this phase?

The Xen approach is to avoid this by only giving one device to each machine.

Quoted 1 line

- Are specific usage patterns used in real world

implementations (e.g.

Quoted 1 line

VMWare) to simplify the virtualization (model or merge phase)?

This is probably the wrong list to ask detailed questions about how VMWare works... ;-)

Quoted 3 lines

- Do you have any interesting pointers to literature dealing with full I/O
virtualization? In particular, how does VMWare's full

virtualization

Quoted 1 line

works with respect to I/O?

Quoted 8 lines

Again, wrong list for VMWare questions.

Quoted 3 lines

- Is every device time partitionable? If not, which requirements does it
have to meet to be time partitionable?

Certainly not - I would say that almost all devices are NOT time partitionable, as the state in the device is dependant on

the current

Quoted 3 lines

usage. The more complex the device is, the more likely it is to have difficulties, but even such a simple deevice as a serial port would struggle to work in a time-shared fashion (not to mention

that serial

Quoted 5 lines

ports generally are used for multiple transactions to make a whole "bigger picture transaction", so for example a web-server connected via
a serial modem would send a packet of several hundred bytes to the serial port driver, which is then portioned out as and when

the serial

Quoted 7 lines

port is ready to send another few bytes. If you switch from one guest to
another during this process, and the second guest also has something to
send on the serial port, you'd end up with a very scrambled message from
the first guest and quite likely the second guests message

completely

Quoted 3 lines

lost!).

There are some devices that are specifically built to

manage multiple

Quoted 10 lines

hosts, but other than that, any sharing of a device requires some software to gather up "a full transaction" and then sending that to the
actual hardware, often also waiting for the transaction to complete (for
example the interrupt signal to say that the hard disk write is complete).

Quoted 1 line

-> I don't think every device is. What about a device

Quoted 8 lines

which supports

Quoted 5 lines

different modes of operation. If two VMs drive the
virtual device in
different modes, it may not be possible to constantly
switch between
them. Ok, this is pretty artificial.

A particular problem is devices where you can't necessarily

read back

Quoted 2 lines

the last mode-setting, which may well be the case in many different devices. You can't, for example, read back all the

registers on an IDE

Quoted 23 lines

device, because the read of a particular address amy give the status rather than the current comamnd sent, or some such.

--
Mats

Quoted 4 lines

Thanks a lot for your help!

Quoted 11 lines

Best wishes

Thomas

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

Quoted 8 lines

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

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

#6 lore raw

Hi Mats,

The problem using QEMU device mode is it can only support four disks at most as IDE can only support two master/slave pair devices. Do you know if this limitation will be gone in the future in QEMU, e.g. emulating SCSI disks instead of IDE devices, so it can support much more than four block devices?

Thanks,

Liang

----- Original Message ----- From: "Petersson, Mats" <[email protected]>
To: "Liang Yang" <[email protected]>
Cc: <[email protected]>; "Thomas Heinz" <[email protected]>
Sent: Wednesday, November 22, 2006 10:22 AM
Subject: RE: [Xen-devel] Full virtualization and I/O

Quoted 19 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Liang Yang
Sent: 22 November 2006 17:17
To: Petersson, Mats
Cc: [email protected]; Thomas Heinz
Subject: Re: [Xen-devel] Full virtualization and I/O

Hi Mats,

This para-virtualized driver in HVM domain is just like the dummy device
driver in para-virtualized domain. And after using this para-virtualized
driver in HVM domain, HVM doamin is also using this kind of front-end/back-end model to handle I/O instead of using "device model" which
a typical HVM domain will use.

Quoted 1 line

Am I correct?

Yes, exactly.

Of course, the HVM domain may well use a mixture, say for example using the normal (device-model) IDE device driver to access the disk, and a para-virtual network driver to access the network.

--
Mats

Quoted 319 lines

Liang

----- Original Message -----
From: "Petersson, Mats" <[email protected]>
To: "Liang Yang" <[email protected]>
Cc: "Thomas Heinz" <[email protected]>; <[email protected]>
Sent: Wednesday, November 22, 2006 9:57 AM
Subject: RE: [Xen-devel] Full virtualization and I/O

Quoted 11 lines

-----Original Message-----
From: Liang Yang [mailto:[email protected]]
Sent: 22 November 2006 16:51
To: Petersson, Mats
Cc: Thomas Heinz; [email protected]
Subject: Re: [Xen-devel] Full virtualization and I/O

Hi Mats,

Thanks for your explanation in such details.

Quoted 9 lines

As you mentioned in your post, could you elaborate using unmodified driver
in HVM domain (i.e. using front-end driver in full-virtualized domain)? Do
you think para-virtualized domain will have exactly the same behavior as
full-virtualized domain when both of them are using this unmodified driver
to access virtual block devices?

Not sure exactly what you're asking, but if you're asking if the performance of driver-related work will be approximately the same, yes.

By the way, I wouldn't call that an "unmodified" driver - it is definitely a MODIFIED driver (a para-virtual driver).

--
Mats

Quoted 47 lines

Best regards,

Liang

----- Original Message -----
From: "Petersson, Mats" <[email protected]>
To: "Thomas Heinz" <[email protected]>; <[email protected]>
Sent: Wednesday, November 22, 2006 9:24 AM
Subject: RE: [Xen-devel] Full virtualization and I/O

Quoted 10 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Thomas Heinz
Sent: 20 November 2006 23:39
To: [email protected]
Subject: [Xen-devel] Full virtualization and I/O

Hi

Quoted 14 lines

Full virtualization is about providing multiple virtual ISA level environments and mapping them to a single physical one. One particular
aspect of this mapping are I/O instructions (explicit or mmapped I/O). In
general, there are two strategies to partition the devices, either in time
or in space. Partitioning a device in space means that the device (or a
part of it) is exclusively available to a single VM. Partitioning a device
in time (or time multiplexing) means that it can be used by multiple VMs
but only one VM may use it at any point in time.

The Xen approach is to not allow any sharing of devices, a device is owned by one domain, no other domain can directly access the device. There is a protocol of so called frontend/backend driver which is basically a dummy-device that forwards a request to another domain (normally domain 0) and the other half of the driver-pair is picking up
this data, forwards it to some processing task, that then sends the packet onto the real hardware.

Quoted 5 lines

For fully virtualized mode (hardware supported virtual machine, such as
AMD-V or Intel VT, aka HVM), there is a different model, where a "device
model" is involved to perform the hardware modelling. In

Xen, this is

Quoted 1 line

using a modified version of qemu (called qemu-dm), which

has a fairly

Quoted 3 lines

complete set of "hardware" in it's model. It's got for example IDE controller, several types of network devices, graphics and mouse/keyboard models. The things you'd usually find in a

PC, that is.

Quoted 5 lines

The way it works is that the hypervisor intercepts IOIO and memory mapped IO regions that match the devices involved (such as the A0000-BFFFF region for VGA frame buffer memory or the 0x1F0-0x1F7 IO ports for the IDE controller), and forwards a request from the hypervisor to qemu-dm, where the operation changes the

current state,

Quoted 1 line

and when it's necessary, the state-change will result in

for example a

Quoted 1 line

read-request to the "hard-disk" (which may be a real disk,

a file on a

Quoted 6 lines

local disk, or a file on a network storage device, to give some examples).

There is also the option of using the frontend drivers as described above in the fully virtualized model.

Quoted 9 lines

Finally, while I'm on the subject of fully virtualized mode: It is currently not possible to give a DMA-based device to a fully-virtualized
domain. The reason for this is that the guest OS will have been told that memory is from 0..256MB (say), and it's actual machine physical address is at 256MB..512MB. The OS is completely unaware of this "mismatch". So the OS will perform some operation to take a virtual address of some buffer (say a network packet) and make it into a "physical address", which will be an address in the range

of 0..256MB.

Quoted 4 lines

This will of course (at least) lead to the wrong data being transmitted,
as the address of the actual data is somewhere in the range 256MB..512MB. The only solution to this is to have an

IOMMU, which can

Quoted 22 lines

translate the guest's understanding of a physical address (0..256MB) to
a machine physical address (256..512MB).

Quoted 10 lines

I am trying to understand how I/O virtualization on the ISA level works if
a device is shared between multiple VM instances. On a very high level, it
should be as follows. First of all, the VMM has to intercept the VM's I/O
commands (I/O instructions or load/store to dedicated memory addresses -
let's ignore interrupts for the moment). This could be done

Quoted 8 lines

by traps or by
replacing the resp. instructions by VMM calls to I/O primitives. The VMM
keeps multiple device model instances (one for each VM using the device)
in memory. The models somehow reflect the low level I/O API of the device.
Depending on which I/O command is issued by the VM, either

Quoted 7 lines

the memory

Quoted 3 lines

model is changed or a number of I/O instructions are executed to make the
physical device state reflect the one represented in the

memory model.

Do you by ISA mean "Instruction Set Architecture" or

something else (I

Quoted 3 lines

presume it's NOT meaning ISA-bus...)?

Intercepting IOIO instructions or MMIO instructions is not

that hard -

Quoted 2 lines

in HVM the two processor architectures have specific intercepts and bitmaps to indicate which IO instructions should be

intercepted. MMIO

Quoted 1 line

will require the page-tables to be set up such that the

memory mapped

Quoted 2 lines

region is mapped "not present" so that any operation to this region gives a page-fault, and then the page-fault is analyzed to

see if it's

Quoted 3 lines

for a MMIO address or for a "real page fault".

For para-virtualization, the model is similar, but the

exact model of

Quoted 1 line

how to intercept the IOIO or MMIO instruction is slightly

different -

Quoted 1 line

but in essence it's the same principle. Let me know if you

really need

Quoted 1 line

to know how Xen goes about doing this, as it's quite

complicated (more

Quoted 10 lines

so than the HVM version, for sure).

Quoted 7 lines

This approach brings up a number of questions. It would be great if some of
the virtualization experts here could shed some light on them (even though
they are not immediately related to Xen, I know):

Quoted 8 lines
Quoted 2 lines

- How do these device memory models look like? Is there a common (automata) theory behind or are they done ad hoc?

Not sure what you're asking for here. Since the devices are either modeled after a REAL device (qemu-dm) and as such will resemble as closely as possible the REAL hardware device that it's emulating, or in
the frontend/backend driver, there is an "idealized model",

such that

Quoted 1 line

the request contains just the basic data that the OS

provides normally

Quoted 24 lines

to the driver, and it's placed in a queue with a message-signaling system to tell the other side that it's got something in the queue.

Quoted 4 lines

- What kind of strategies/algorithms are used in the merge phase, i.e. the
phase where the virtual memory model and the physical one are synchronized? What kind of problems can occur in this phase?

The Xen approach is to avoid this by only giving one device to each machine.

Quoted 1 line

- Are specific usage patterns used in real world

implementations (e.g.

Quoted 1 line

VMWare) to simplify the virtualization (model or merge phase)?

This is probably the wrong list to ask detailed questions about how VMWare works... ;-)

Quoted 3 lines

- Do you have any interesting pointers to literature dealing with full I/O
virtualization? In particular, how does VMWare's full

virtualization

Quoted 1 line

works with respect to I/O?

Quoted 8 lines

Again, wrong list for VMWare questions.

Quoted 3 lines

- Is every device time partitionable? If not, which requirements does it
have to meet to be time partitionable?

Certainly not - I would say that almost all devices are NOT time partitionable, as the state in the device is dependant on

the current

Quoted 3 lines

usage. The more complex the device is, the more likely it is to have difficulties, but even such a simple deevice as a serial port would struggle to work in a time-shared fashion (not to mention

that serial

Quoted 5 lines

ports generally are used for multiple transactions to make a whole "bigger picture transaction", so for example a web-server connected via
a serial modem would send a packet of several hundred bytes to the serial port driver, which is then portioned out as and when

the serial

Quoted 7 lines

port is ready to send another few bytes. If you switch from one guest to
another during this process, and the second guest also has something to
send on the serial port, you'd end up with a very scrambled message from
the first guest and quite likely the second guests message

completely

Quoted 3 lines

lost!).

There are some devices that are specifically built to

manage multiple

Quoted 10 lines

hosts, but other than that, any sharing of a device requires some software to gather up "a full transaction" and then sending that to the
actual hardware, often also waiting for the transaction to complete (for
example the interrupt signal to say that the hard disk write is complete).

Quoted 1 line

-> I don't think every device is. What about a device

Quoted 8 lines

which supports

Quoted 5 lines

different modes of operation. If two VMs drive the
virtual device in
different modes, it may not be possible to constantly
switch between
them. Ok, this is pretty artificial.

A particular problem is devices where you can't necessarily

read back

Quoted 2 lines

the last mode-setting, which may well be the case in many different devices. You can't, for example, read back all the

registers on an IDE

Quoted 23 lines

device, because the read of a particular address amy give the status rather than the current comamnd sent, or some such.

--
Mats

Quoted 4 lines

Thanks a lot for your help!

Quoted 11 lines

Best wishes

Thomas

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

Quoted 8 lines

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

Quoted 7 lines

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

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

#7 lore raw
Quoted 4 lines · On Wed, 22 Nov 2006 10:36:42 -0700 "Liang Yang" <[email protected]>…

Hi Mats,

The problem using QEMU device mode is it can only support four disks at most as IDE can only support two master/slave pair devices.

IDE can support lots more than this.

Alan

#8 lore raw
In reply to Petersson, Mats

Mats,

Quoted 1 line

For fully virtualized mode (hardware supported virtual machine, such

as

Quoted 2 lines

Finally, while I'm on the subject of fully virtualized mode: It is currently not possible to give a DMA-based device to a

fully-virtualized

Quoted 7 lines

domain. The reason for this is that the guest OS will have been told that memory is from 0..256MB (say), and it's actual machine physical address is at 256MB..512MB. The OS is completely unaware of this "mismatch". So the OS will perform some operation to take a virtual address of some buffer (say a network packet) and make it into a "physical address", which will be an address in the range of 0..256MB. This will of course (at least) lead to the wrong data being

transmitted,

Quoted 3 lines

as the address of the actual data is somewhere in the range 256MB..512MB. The only solution to this is to have an IOMMU, which can translate the guest's understanding of a physical address (0..256MB)

to

Quoted 1 line

a machine physical address (256..512MB).

I know that individual domains can be given direct access to individual PCI devices.

http://www.cl.cam.ac.uk/research/srg/netos/xen/readmes/user/user.html#SE
CTION03230000000000000000

Is this not possible with HVM domains? Is it possible for HVM domains to be a PCI frontend and receive a PCI device which is "hidden" from Dom0? Or is this what paravirtualized drivers for HVM domains are doing?

Thanks,
Aravindh

#9 lore raw
Quoted 41 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Puthiyaparambil, Aravindh
Sent: 22 November 2006 18:34
To: Petersson, Mats; Thomas Heinz; [email protected]
Subject: RE: [Xen-devel] Full virtualization and I/O

Mats,

Quoted 1 line

For fully virtualized mode (hardware supported virtual machine, such

as

Quoted 2 lines

Finally, while I'm on the subject of fully virtualized mode: It is currently not possible to give a DMA-based device to a

fully-virtualized

Quoted 6 lines

domain. The reason for this is that the guest OS will have been told that memory is from 0..256MB (say), and it's actual machine physical address is at 256MB..512MB. The OS is completely unaware of this "mismatch". So the OS will perform some operation to take a virtual address of some buffer (say a network packet) and make it into a "physical address", which will be an address in the range

of 0..256MB.

Quoted 1 line

This will of course (at least) lead to the wrong data being

transmitted,

Quoted 2 lines

as the address of the actual data is somewhere in the range 256MB..512MB. The only solution to this is to have an

IOMMU, which can

Quoted 1 line

translate the guest's understanding of a physical address (0..256MB)

to

Quoted 1 line

a machine physical address (256..512MB).

I know that individual domains can be given direct access to individual
PCI devices.

http://www.cl.cam.ac.uk/research/srg/netos/xen/readmes/user/us
er.html#SE
CTION03230000000000000000

Quoted 5 lines

Is this not possible with HVM domains? Is it possible for HVM domains to
be a PCI frontend and receive a PCI device which is "hidden" from Dom0?
Or is this what paravirtualized drivers for HVM domains are doing?

No, PV-on-HVM drivers are using the "standard" front/back-end driver structures.

You could write a Virtualization-Aware driver for HVM. That would require replacing any "virtual-to-physical" translations from the native OS driver version to a "virtualization aware" model that calls the hypervisor to translate the data.

Aside from that, all you need is a way to inform the HVM domain of the existance of that PCI device, which shouldn't be a major deal.

--
Mats

Quoted 11 lines

Thanks,
Aravindh

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

#10 lore raw
In reply to Petersson, Mats

Hi Mats

Thanks a lot for your detailed reply!

Quoted 8 lines · You

For fully virtualized mode (hardware supported virtual machine, such as AMD-V or Intel VT, aka HVM), there is a different model, where a "device model" is involved to perform the hardware modelling. In Xen, this is using a modified version of qemu (called qemu-dm), which has a fairly complete set of "hardware" in it's model. It's got for example IDE controller, several types of network devices, graphics and mouse/keyboard models. The things you'd usually find in a PC, that is. The way it works is that the hypervisor intercepts IOIO and memory

Quoted 8 lines

mapped IO regions that match the devices involved (such as the A0000-BFFFF region for VGA frame buffer memory or the 0x1F0-0x1F7 IO ports for the IDE controller), and forwards a request from the hypervisor to qemu-dm, where the operation changes the current state, and when it's necessary, the state-change will result in for example a read-request to the "hard-disk" (which may be a real disk, a file on a local disk, or a file on a network storage device, to give some examples).

This is very interesting. So qemu models the low level device interface (I/O interface) in software and translates I/O actions to either model changes or to library or system calls (since QEMU runs as normal process).

Is there any documentation about this or is the source the doc ;)

Quoted 2 lines

Do you by ISA mean "Instruction Set Architecture" or something else (I presume it's NOT meaning ISA-bus...)?

Yes, I mean instruction set architecture.

Quoted 8 lines

Intercepting IOIO instructions or MMIO instructions is not that hard - in HVM the two processor architectures have specific intercepts and bitmaps to indicate which IO instructions should be intercepted. MMIO will require the page-tables to be set up such that the memory mapped region is mapped "not present" so that any operation to this region gives a page-fault, and then the page-fault is analyzed to see if it's for a MMIO address or for a "real page fault".

Quoted 5 lines

For para-virtualization, the model is similar, but the exact model of how to intercept the IOIO or MMIO instruction is slightly different - but in essence it's the same principle. Let me know if you really need to know how Xen goes about doing this, as it's quite complicated (more so than the HVM version, for sure).

Although it is interesting to see how interception works in detail, I am currently more interested in how device state is modelled and translated into system/library calls or sequences of I/O instructions. So, in fact the operation after the interception has taken place.

Quoted 7 lines

Not sure what you're asking for here. Since the devices are either modeled after a REAL device (qemu-dm) and as such will resemble as closely as possible the REAL hardware device that it's emulating, or in the frontend/backend driver, there is an "idealized model", such that the request contains just the basic data that the OS provides normally to the driver, and it's placed in a queue with a message-signaling system to tell the other side that it's got something in the queue.

I am basically asking about general/theoretical concepts behind device modelling as e.g. done by qemu. I think it's a good idea to understand how qemu actually does this.

Quoted 6 lines

Certainly not - I would say that almost all devices are NOT time partitionable, as the state in the device is dependant on the current usage. The more complex the device is, the more likely it is to have difficulties, but even such a simple deevice as a serial port would struggle to work in a time-shared fashion (not to mention that serial ports generally are used for multiple transactions to make a whole

Quoted 8 lines

"bigger picture transaction", so for example a web-server connected via a serial modem would send a packet of several hundred bytes to the serial port driver, which is then portioned out as and when the serial port is ready to send another few bytes. If you switch from one guest to another during this process, and the second guest also has something to send on the serial port, you'd end up with a very scrambled message from the first guest and quite likely the second guests message completely lost!).

Very nice example. Clearly, high level driver interfaces (e.g. send/receive, read/write) can be designed in a way that time-sharing is possible, e.g. using message/transaction queues. On the I/O level, it is likely to be harder to reconstruct the "full transaction". It might also be necessary to make assumptions about the actual guest, i.e. the way the device is being used.

Quoted 5 lines

A particular problem is devices where you can't necessarily read back the last mode-setting, which may well be the case in many different devices. You can't, for example, read back all the registers on an IDE device, because the read of a particular address amy give the status rather than the current comamnd sent, or some such.

This could be stored in memory when you have a virtual (in-memory) device model.

Best wishes

Thomas

#11 lore raw
Quoted 41 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Thomas Heinz
Sent: 23 November 2006 16:23
To: Petersson, Mats
Cc: [email protected]
Subject: Re: [Xen-devel] Full virtualization and I/O

Hi Mats

Thanks a lot for your detailed reply!

Quoted 1 line · You

For fully virtualized mode (hardware supported virtual

machine, such as

Quoted 1 line

AMD-V or Intel VT, aka HVM), there is a different model,

where a "device

Quoted 1 line

model" is involved to perform the hardware modelling. In

Xen, this is

Quoted 1 line

using a modified version of qemu (called qemu-dm), which

has a fairly

Quoted 3 lines

complete set of "hardware" in it's model. It's got for example IDE controller, several types of network devices, graphics and mouse/keyboard models. The things you'd usually find in a

PC, that is.

Quoted 5 lines

The way it works is that the hypervisor intercepts IOIO and memory mapped IO regions that match the devices involved (such as the A0000-BFFFF region for VGA frame buffer memory or the 0x1F0-0x1F7 IO ports for the IDE controller), and forwards a request from the hypervisor to qemu-dm, where the operation changes the

current state,

Quoted 1 line

and when it's necessary, the state-change will result in

for example a

Quoted 1 line

read-request to the "hard-disk" (which may be a real disk,

a file on a

Quoted 2 lines

local disk, or a file on a network storage device, to give some examples).

Quoted 8 lines

This is very interesting. So qemu models the low level device interface
(I/O interface) in software and translates I/O actions to either model
changes or to library or system calls (since QEMU runs as normal process).

Is there any documentation about this or is the source the doc ;)

I haven't looked for any documentation - for the work I've done using QEMU, I've just used to source as doc's. It's a fairly large project, so there may be some docs somewhere....

Quoted 29 lines
Quoted 2 lines

Do you by ISA mean "Instruction Set Architecture" or

something else (I

Quoted 1 line

presume it's NOT meaning ISA-bus...)?

Yes, I mean instruction set architecture.

Quoted 1 line

Intercepting IOIO instructions or MMIO instructions is not

that hard -

Quoted 2 lines

in HVM the two processor architectures have specific intercepts and bitmaps to indicate which IO instructions should be

intercepted. MMIO

Quoted 1 line

will require the page-tables to be set up such that the

memory mapped

Quoted 2 lines

region is mapped "not present" so that any operation to this region gives a page-fault, and then the page-fault is analyzed to

see if it's

Quoted 3 lines

for a MMIO address or for a "real page fault".

For para-virtualization, the model is similar, but the

exact model of

Quoted 1 line

how to intercept the IOIO or MMIO instruction is slightly

different -

Quoted 1 line

but in essence it's the same principle. Let me know if you

really need

Quoted 1 line

to know how Xen goes about doing this, as it's quite

complicated (more

Quoted 1 line

so than the HVM version, for sure).

Quoted 7 lines

Although it is interesting to see how interception works in detail, I am
currently more interested in how device state is modelled and translated
into system/library calls or sequences of I/O instructions. So, in fact
the operation after the interception has taken place.

Ok, so if we take as an example a IDE block read, it consists of several IO instructions:
Assuming void outb(uint16 port_no, uint8 value) is a

outb(0x1f2, sector_count);
outb(0x1f3, sector_number);
outb(0x1f4, cylinder_lsb);
outb(0x1f5, cylinder_lsb);
outb(0x1f6, drive_head);
outb(0x1f7, command);

[In LBA mode, sector_number and the two cylinder numbers (and I think the head part of drive_head) convert into a "large" sector number, rather than cylinder/head/sector combination].

In QEMU, the initial 5 writes will just change the internal state of the IDE controller (i.e. the number of sectors, sector/cylinder numbers, etc, are just stored in some per-controller data structure). Note that disk0 and disk1 on one controller shares the same register set - drive bit out of drive_head selects drive 0 or drive 1.

The sixth out (in our sequence, it's based on the address, not the number of writes), will tell QEMU that the sequence is a complete transaction, and it will go ahead and perform the read of the strage that corresponds to the IDE device (such as a file or partition).

The data read is stored in a "per device" buffer, when the code is complete on the device-side, the guest will be informed of this via a virtual interrupt. This will, assuming normal behaviour then trigger a 512-byte (in the form of 16-bit "in" or "ins" instruction with a port address of 0x1f0) where the data is read by the guest into whatever memory it wanted to use.

The completion of a write operation, on the other hand, is of course complete first when the 512-byte sector has been written using the "out" or "outs" instruction to port 0x1f0.

Quoted 41 lines
Quoted 4 lines

Not sure what you're asking for here. Since the devices are either modeled after a REAL device (qemu-dm) and as such will resemble as closely as possible the REAL hardware device that it's

emulating, or in

Quoted 1 line

the frontend/backend driver, there is an "idealized model",

such that

Quoted 1 line

the request contains just the basic data that the OS

provides normally

Quoted 2 lines

to the driver, and it's placed in a queue with a message-signaling system to tell the other side that it's got something in the queue.

I am basically asking about general/theoretical concepts behind device
modelling as e.g. done by qemu. I think it's a good idea to understand how
qemu actually does this.

Quoted 2 lines

Certainly not - I would say that almost all devices are NOT time partitionable, as the state in the device is dependant on

the current

Quoted 3 lines

usage. The more complex the device is, the more likely it is to have difficulties, but even such a simple deevice as a serial port would struggle to work in a time-shared fashion (not to mention

that serial

Quoted 2 lines

ports generally are used for multiple transactions to make a whole "bigger picture transaction", so for example a web-server

connected via

Quoted 2 lines

a serial modem would send a packet of several hundred bytes to the serial port driver, which is then portioned out as and when

the serial

Quoted 1 line

port is ready to send another few bytes. If you switch from

one guest to

Quoted 1 line

another during this process, and the second guest also has

something to

Quoted 1 line

send on the serial port, you'd end up with a very scrambled

message from

Quoted 1 line

the first guest and quite likely the second guests message

completely

Quoted 1 line

lost!).

Quoted 10 lines

Very nice example. Clearly, high level driver interfaces (e.g. send/receive, read/write) can be designed in a way that time-sharing is
possible, e.g. using message/transaction queues. On the I/O level, it is
likely to be harder to reconstruct the "full transaction". It might also
be necessary to make assumptions about the actual guest, i.e. the way the
device is being used.

Yes, this is essentially how the frontend/backend drivers work. They send a complete "high level" message to for example send a ethernet packet or write a sector to the disk. As the message is "complete" (not dependant on other messages), it's entirely possible (and in fact I believe that's how Xen works) to use a single back-end driver (per device type) for multiple front-end drivers.

Of course, if we're talking about disk access, there is another complication, which has nothing to do with the actual physical
interface: the meta-data that is the "filesystem" will also need to be guaranteed to be "correct". Most filesystems have a whole lot of different data structures (such as list of free blocks, directory structures, file-name-to-directory-entry binary tree, etc). If you have two guest operating systems writing to the same "disk", the filesystem will most certainly get corrupted... For example, imagine that both systems are creating a new file, and picks the same block from the free block list... Or deleting files at the same time and putting two different free blocks into the same free block list entry...

So, even if you could share the device-interface, the consistency of the actual device would not be good if two guests DID share the disk-interface to the same physical instance of a "disk" (whether it's ACTUALLY a real disk or a file-based disk-image that "pretends" to be a disk).

Quoted 5 lines
Quoted 2 lines

A particular problem is devices where you can't necessarily

read back

Quoted 2 lines

the last mode-setting, which may well be the case in many different devices. You can't, for example, read back all the

Quoted 7 lines

registers on an IDE

Quoted 2 lines

device, because the read of a particular address amy give the status rather than the current comamnd sent, or some such.

This could be stored in memory when you have a virtual (in-memory) device
model.

Sure, that's how it works in QEMU - but that requires that you intercept the actual operation and stores what the individual steps of a full transaction.

--
Mats

Quoted 13 lines

Best wishes

Thomas

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