[vbox-dev] HGCM question...guest memory mapping

Jaikumar G jaienigma at gmail.com
Mon Jul 16 15:17:20 PDT 2012

Hi Ram,

On Wed, Jul 11, 2012 at 10:31 PM, Ramshankar <
ramshankar.venkataraman at oracle.com> wrote:

> On 12/07/12 04:47, Jaikumar G wrote:
>> Hello folks,
>>     So from the documentation for HGCM -
>> A request is constructed in the guest physical memory, which must be
>> locked by the guest. The physical address is passed to the VMM device
>> using a 32 bit out edx, eax instruction.
>> Can someone elaborate as to where in the code I can find as to how the
>> physical address is passed to the VMM device ? Also how is the guest
>> physical memory mapped to be accessed by the host ?
> The guest physical memory is allocated and locked down in the guest using
> the guest additions. Take a look at VBoxGuestLib/GenericRequest.**cpp:VbglGRAlloc()
> and vbglPhysHeapChunkAlloc() which calls into IPRT's RTMemContAlloc() which
> is implemented for each supported platform which actually does the physical
> memory allocation and lock down, obviously this allocation is kept below
> the _4G range for port IO.
> See VBoxGuestLib/GenericRequest.**cpp: VbglGRPerform() The 32-bit
> physical address of the request is transferred using port IO of the VMM PCI
> device. The port address is initialized by the vboxguest PCI driver (take a
> look at callers of VBoxGuestInitDevExt() if interested).
> On the host side this translates as port IO which gets handled in
> Devices/VMMDev/VMMDEv.cpp:**vmmdevRequestHandler(). The devices accces
> memory via PDM, in this case PDMDevHlpPhysRead() reads the guest physical
> memory. The guest memory is allocated and locked down on the host and
> handled as RAM/ROM ranges with context based access handlers.

Thanks that makes a lot of sense.

Regarding allocation of memory in guest space:

"QEMU has a feature where it can translate a guest virtual address in user
space directly into the corresponding physical/backing page in RAM without
the need for allocating memory in Guest space."

Is is something that can be done in virtual box ? Is there any significant
performance differences ?

>  I looked around in the HGCM files in the both
>> Additions/common/VBoxGuest* and in Devices/VMMDev but I was just going
>> around in circles.
> Devices/VMMDev/ is the place to look to see how these requests are handled
> on the host side.
>  Any pointers would be really appreciated.
>> Thanks
> Regards,
> Ram.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.virtualbox.org/pipermail/vbox-dev/attachments/20120716/8c9dd212/attachment-0001.html 

More information about the vbox-dev mailing list