[vbox-dev] Question regarding channel callbacks between guest and host
ramshankar.venkataraman at oracle.com
Mon Apr 28 09:28:32 UTC 2014
On 04/28/14 06:06 AM, Jaeyong Yoo wrote:
> Hello Ramshankar,
>> The way we do IO and MMIO access is a bit complicated to trace because of
>> a lot of indirection but the structure of the overall design is quite
>> When executing guest-code under hardware virtualization, we'll get VM-
>> Exits/#VMEXIT (for VT-x, see VMMR0/HMVMXR0.cpp hmR0VmxExitIoInstr(),
>> hmR0VmxExitXcptPF() etc., for AMD-V see VMMR0/HMSVMR0.cpp:
>> hmR0SvmExitIOInstr(), hmR0SvmExitXcptPF() etc.) that end up calling into
>> the PDM/PGM/IOM subsystem. That then based on the port and access will
>> choose the access handler which was registered for the port/MMIO region.
>> Different devices register access handlers for IO ports using
>> PDMDevHlpIOPortRegister() and MMIO using PDMDevHlpMMIORegister().
>> Finding which access handler gets called can be a bit tricky. One of the
>> easier ways is, to see what has been registered using the VM debugger
>> ("info phys" and "info handlers").
>> Depending on whether the device can handle the access request in ring-0 or
>> not, we may reschedule the work to be done in ring-3.
> After reading your explanation and I read the code, it quite understandable.
> I've got one more question: I expect that IO/MMIO is the only way of
> from the guest to the host. In case of the host to the guest interaction,
> VirtualBox rely on interrupt injection (supported by VT-x) or does it use
> kind of software-emulated method (like Xen's event channel)?
>> Hope that helps.
> Helped a lot. Thanks!
I'm not sure what kind of interaction you're referring to, but I'm sure,
if one needed, it would be possible to create a some kind of shared
memory interface and use make use of special interrupts to poke things.
The guest may provide a page in its address space to the hypervisor and
this could be used to communicate using hypercalls. This obviously
requires co-operation from the guest.
Both Intel and AMD-V have instructions that allow unconditional traps
into the hypervisor (see, VMCALL for Intel and VMMCALL for AMD-V). There
are also other methods that can be used to communicate between guest and
host without using architecture-specific instructions, but require the
guest to co-operate in a defined manner.
I don't know how interrupt delivery is all that relevant to the topic at
hand, but yes, VirtualBox uses VT-x and AMD-V's interrupt injection
mechanics (except for one specific case where we inject interrupts
manually when the CPU isn't capable of real-mode execution with VT-x,
More information about the vbox-dev