The fundamentals of Virtualization--io Virtualization

Source: Internet
Author: User
Tags new set

The topic of this article:
Overview of IO Virtualization
Device Discovery access interception device analog device sharing
Software-based IO virtualization
IO virtualization based on front-end backend
Hardware-based IO virtualization

Overview

From the processor's point of view, peripherals are accessed through a set of I/O resources (port I/O or Mmio), so the associated virtualization of the device is called I/O virtualization. The idea is that VMM intercepts requests for access to devices by the customer's operating system, and then simulates the effects of real-world devices by means of software. The way and characteristics of I/O virtualization are complex based on the variety of device types.

A complete system virtualization scenario requires processing of the following blocks in I/O virtualization

Virtual chipset

Virtual PCI bus layout, mainly through the virtualized PCI configuration space, for the client operating system to render virtual or directly allocated to use the device.

Virtual system devices, such as pic, io-apic, Pit, and RTC.

Virtual basic input, such as graphics cards, network cards, and hard drives.

I/O virtualization mainly includes the following aspects of virtualization

I/O port registers

Mmio Register

Interrupt

IO Virtualization

Below is a detailed description of what IO virtualization needs to do

Device Discovery

Device discovery is the first step in IO virtualization that allows VMM to provide a way for the client operating system to discover virtual devices so that the client operating system can load the associated driver. Device discovery depends on the type of device being virtual.

Simulates a device on a physical bus, which contains the following two types.

1) Simulating a bus type that is not enumerable is a physical device, and the resource that the device itself belongs to is hard-coded fixed. such as ISA device, PS/2 keyboard, mouse, RTC, and traditional IDE controller. For such devices, the driver detects the presence of the device in a device-specific way, such as reading status information for a specific port. For the discovery of such devices, VMM correctly simulates a given port by intercepting the client's access to the port and simulating the result to the client.

2) Simulating a bus type is an enumerable physical device, and the associated device resources are software configurable, such as PCI devices. Because the PCI bus is defined by the PCI configuration space a complete set of device Discovery mode, and run the system software through the PCI configuration space of some fields to the given PCI device resources configuration, such as allow or prohibit I/O port and Mmio, set the I/O and Mmio start address, etc. So it is not enough for VMM to emulate its own logic, and it must further emulate the behavior of the PCI bus, including topological relationships and device-specific configuration space content, so that the client operating system can discover such virtual devices.

Simulate a fully virtual device

In this case, without a real-world specification, the type of bus in which the virtual device is located is entirely at the discretion of VMM, and VMM can choose to hang the virtual device on the PCI bus or fully customize a new set of virtual bus protocols so that the guest operating system must be equipped with a new bus driver.

Access Interception

After the virtual appliance is discovered by the client operating system, the driver in the guest operating system accesses the virtual device as defined by the interface. At this point, VMM must intercept the driver's access to the virtual device and impersonate it.

Devices that are not directly assigned to the guest operating system

For the port I/o,io instruction itself is a privileged instruction, a low-privileged client access port I/O throws an exception, which in turn falls into VMM and is presented to the Device Emulator for impersonation.

For MMIO,VMM, the page table mapped to the MMIO is set to invalid, and the client accesses the Mmio with a fault that is thrown into the VMM and is presented to the Device Emulator for impersonation.

For interrupts, VMM needs to provide a mechanism for the Device Emulator to notify the virtual interrupt logic when it receives a physical interrupt and need to trigger an interrupt, and then simulate the injection of a virtual interrupt by the virtual interrupt logic.

devices that are assigned directly to the guest operating system

For port I/O, client Access can be made directly.

For Mmio, the client can also be directly mapped to access.

For interrupts, when the VMM physical interrupt handler receives a physical interrupt, it identifies which client the interrupt source belongs to and notifies the client of the virtual interrupt logic directly.

Device Simulation

In the previous step we have mentioned several times that the following classification describes the device simulation.

Software-based full virtualization

A virtual device has exactly the same interface definition as a real-world device. In this case, the VMM Device Emulator needs to carefully study the interface definition and internal design specifications of the real device and then simulate the real logic circuit in a software way to meet the definition and effect of each interface. The Device Emulator needs to present the same resources as the actual equipment. In this case, the original driver of the guest operating system can drive the virtual device without modification. During device access, VMM simulates access to the device by intercepting the driver.

Example: Qemu VMware Workstation

Semi-virtualized

Provides a specific driver for the client operating system (called the Front end), the emulator in VMM is called the backend, and the front end requests the communication mechanism provided by VMM to send directly to the backend, and the backend processes the request before sending back the notification to the former. Compared with the traditional device driver process (the previous method), the traditional device program, in order to complete an operation involving multiple registers, causes the VMM to intercept each register access and perform the corresponding simulation, resulting in multiple context switches. This approach can greatly reduce the frequency of context switching, providing greater space for optimization.

Example: Xen virtio (virtio Next I will continue to research, mainly including virtio framework, Virtio front-end driver, backend implementation mode and principle, the front-end back-end shared memory way)

Direct hardware-based allocation (in fact it's not a device emulation)

The physical device is assigned directly to the guest operating system, and the target device is accessed directly by the guest operating system. In this case, there is virtually no device emulation, and the client operates the real hardware directly from the original driver. This approach is optimal in terms of performance, but this approach requires more hardware resources.

Hardware-based direct distribution There is also a way, the hardware itself to support virtualization, itself can be different virtual machines to provide independent hardware support, the device itself supports multiple virtual machines simultaneously access. Like SR-Iov. (This way I will continue to study)

Example: Intel vt-d SR-Iov

In a VMM, there are often multiple virtualization approaches.

Comparison of different IO virtualization modes

Device Sharing

In device virtualization, some devices can be simulated completely in software by the software emulator without touching the actual physical device, such as CMOS, while some devices require device emulation to further request the help of the physical hardware. General input and output class device, such as mouse, keyboard, video card, hard disk, network card. These devices involve getting input or output from a real device to a real device.

For multiple clients, each client has its own device emulator, and multiple device emulators need to share the same physical device, in which case the driver for the real device in VMM needs to receive and process requests from multiple customers or processes at the same time to reuse the physical resources.

Click on the link below to go to my own blog to see more articles on virtualization.

Original link: http://itblogs.ga/blog/20150111003133/reprint please indicate the source


The fundamentals of Virtualization--io Virtualization

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.