[vbox-dev] Using HGCM
vbox at zavalon.com
Fri Mar 12 00:32:35 PST 2010
Thanks for your help to date.
Please see inline for additional questions.
One reason that I have been searching for a way to share host allocated
memory, using mmap or shmem, with the guest is that it is highly
desirable to be able to be to create a shared memory block that is
shared between multiple guests and the host.
My understanding is that if the shared memory is allocated from a Guest
device memory then there is no way of sharing that physical memory with
Is this true?
I have been looking a number of public function from the GMMR3 group,
such as GMMR3AllocPagesPreform. These initially looked promising but the
more I looked the less sure I am about them.
Are these or the MMR3 functions likely be of any use to me?
n Thu, 2010-03-11 at 10:51 +0100, Vitali Pelenjow wrote:
> 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.
I am assuming that IO usage is optional, and both guest and host can
poll the memory itself for changes, using appropriate semaphore control.
eg using LOCKED XADD or LOCKED CMPXCHG type instructions.
Is this true ?
> 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.
Thanks for the clarification.
> > 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
Thanks, I will look into CFGM to what is needed.
> > 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.
I will look into this, and hopefully follow your suggestion.
> > 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.
When you say the performance is much better, are you referring to the
memory read and write access performance, or the functions call to
control the memory.
I have done a simple test using HGCM shared memory, and have found that
the bottom 8 bits of the virtual address are different between the host
and guest indicating that there is some background copy operation
happening, because I think that the x86 can only map on page
boundaries(4K?) hence the bottom 12 bits of the Guest virtual address
should be the same as the Host virtual address.
Is this true?
If true then this memory is not suitable for my application.
But it is still suitable for passing the requests between host and
> Best regards,
More information about the vbox-dev