[vbox-dev] detailed paths from vm i/o to host?

Knut St. Osmundsen knut.osmundsen at oracle.com
Thu Dec 9 08:33:49 GMT 2010


On Dec 8, 2010, at 11:02 PM, Huihong Luo wrote:

> 
> I wonder if anyone can provide some detailed info as how guest i/o comes to the host emulation layer (user space). For example, how does "outb port_num, val" instruction travel from guest kernel to host user space on AMD64 with VT-x/AMD-V?
>  
> The reason I aksed is that I was wondering if performance would be further improved if moving some emulation layer from host user space to host kernel layer? that should at least saves two context switches.
>  
> KVM provides some callbacks, any similar api exists for VBox? 


For I/O ports we have had PDMDevHlpIOPortRegister, PDMDevHlpIOPortRegisterR0 and PDMDevHlpIOPortRegisterRC since day one. All performance critical devices registers ring-3, ring-0 (R0) and raw-mode context (RC) callbacks for their I/O ports and will handle exits (R0 (VT-x/AMD-V)) and virtualization traps (RC) directly without switching the context when possible.

For memory mapped I/O (MMIO) ranges there are similar APIs: PDMDevHlpMMIORegister, PDMDevHlpMMIORegisterR0 and PDMDevHlpMMIORegisterRC.

What happens when we take an I/O port access exit in VT-x or AMD-V mode is that we use as much information as the hardware provides and tells the I/O manager (IOM) to dispatch it to the relevant callback.  Usually the IOM can dispatch this directly without having to switch back to user mode (ring-3).

In raw-mode the trap manager's (TRPM) general protection fault handler will catch the IN/OUT/INSx/OUTSx instruction and decode it. Seeing that it's an port I/O instruction it will hand it on to EMInterpretPortIO which will interpret the instruction with the help of IOM like in the VT-x/AMD-V case.

-- 

Kind regards / Mit freundlichen Gruessen / Vennlig hilsen,
 bird

--

ORACLE Deutschland B.V. & Co. KG  Knut St. Osmundsen
Werkstrasse 24                    Senior Staff Engineer, VirtualBox
71384 Weinstadt, Germany          mailto:bird at sun.com

Hauptverwaltung: Riesstr. 25, D-80992 Muenchen
Registergericht: Amtsgericht Muenchen, HRA 95603

Komplementaerin: ORACLE Deutschland Verwaltung B.V.
Rijnzathe 6, 3454PV De Meern, Niederlande
Handelsregister der Handelskammer Midden-Niederlande, Nr. 30143697
Geschaeftsfuehrer: J. Kunz, M. van de Molen, A. van der Ven

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.virtualbox.org/pipermail/vbox-dev/attachments/20101209/ea52e504/attachment.html>


More information about the vbox-dev mailing list