[vbox-dev] Using HGCM

Vitali Pelenjow Vitali.Pelenjow at Sun.COM
Thu Mar 11 01:51:19 PST 2010

Hi Nev,

HGSMI uses a virtual device memory to exchange data between host and 
guest. Currently it is only implemented for the virtual VGA device.
Both guest and host can place some data in the guest VRAM and then the 
other side will read data. Guest informs host using an port IO,
host can inform guest using an IRQ or the guest can poll an IO port.

Nev wrote:
> Hi Michael,
> Not meaning to be pushy but my day is just ending, and I suspect yours is just beginning,
> and you have not even seen the previous email.
> I have made some progress on searching the source for answers to my own questions.
> Hence this email.
> I have found "Host Guest Shared Memory Interface" or HGSMI. Which has a number of functions such as:
> HGSMICreate, HGSMIDestroy, HGSMIHostRead, HGSMIGuestRead.
> These look like they maybe close to the functions that I need, but are LOCAL HIDDEN symbols in VBoxDD.so
> But all the functions they call are public symbols in VBoxRT, VBoxVMM and VBoxREM.
> My Question is do these function create memory that is shared between Host and Guest
> and can the memory be read and written without generating exception on every read or write?
There function do not create memory. They use an existing virtual device 
memory region. The memory can be accessed by both guest and host without 
generating an exception.
> Is this memory accessible from Ring 3?
On the host it is accessible from ring3. In the guest it can be mapped 
to ring 3 by the guest device driver, I think.
> Do I need to implement this interface as Device or Driver, or would a shared library do the job?
You would need to implement a virtual device. I think it is possible to 
implement such device as a shared library which can be loaded by VBox. 
There should be a way to configure this using CFGM. But I do not know 
> If a device is required, is VBoxSampleDevice.cpp a good starting point ?
For HGSMI you will probably have to take a look at the DevVGA. Search 
for HGSMI there.
> If Driver is required is there a good starting point ?
In principle a Driver may not be required at all. But I think a PDM 
Driver, which is attached to your PDM device, is a cleaner design.
The device will simply pass data between the PDM driver and the guest. 
You could then change the Driver without touching the Device.
> Sorry if these question are too simplistic, but I trying to not waste time by following a wrong path.
> PS. should I change the subject of email ?
HGSMI is faster that HGCM. However HGSMI is also more low level and 
needs a virtual device and a guest device driver for it.
Also HGSMI in not yet a public interface and may change. The main 
advantage of HGSMI is of course that it can transfer data in both 
directions and the performance is much better than in HGCM.

Best regards,

More information about the vbox-dev mailing list