Expand description
Port-mapped IO vmexit controller.
Port-mapped I/O is a method of communication between external devices and the CPU, where each device is assigned a unique port address that is used as an operand in the in/out instruction family. This allows the CPU to directly read or write data to the devices. There are different variations of the in/out instructions, depending on the type and size of the operands used.
In virtual machine management, the VMM can choose to allow or trap port-mapped I/O instructions executed by the guest. However, in this section, all I/O instructions are trapped to the host, giving the VMM control over their behavior to hand-on the concept of the instruction emulation.
Instruction emulation contains two steps; 1) decode the “semantic” of the instruction; 2) emulate the “semantic” of the instruction. Through the implementation, you could follow the way that traditional virtualization emulates the instruction.
Tasks
In this part, You need to emulate the 18 in/out instructions. The given template conducts the step 2, emulation.
Decode the instruction and initialize the IoInstruction
instance with the corresponding opcode and registers.
The controller will then use this information to forward the request to the appropriate handler.
When handling Outsw_DX_m8, Outsw_DX_m16 and Outsd_DX_m32, it is necessary to copy the memory contents by translating guest virtual address to host virtual address.
You can translate the guest address to the host address by Probe
.