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

Ramshankar ramshankar.venkataraman at oracle.com
Wed Jul 11 22:31:47 PDT 2012


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.

> 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.





More information about the vbox-dev mailing list