Index: trunk/src/VBox/Devices/Graphics/DevVGA.cpp
===================================================================
--- trunk/src/VBox/Devices/Graphics/DevVGA.cpp	(revision 17733)
+++ trunk/src/VBox/Devices/Graphics/DevVGA.cpp	(revision 17767)
@@ -885,4 +885,9 @@
                 s->vbe_regs[s->vbe_index] = val;
             }
+#ifdef VBOX_WITH_HGSMI
+            else if (val == VBE_DISPI_ID_HGSMI) {
+                s->vbe_regs[s->vbe_index] = val;
+            }
+#endif /* VBOX_WITH_HGSMI */
 #endif /* VBOX */
             break;
@@ -3131,4 +3136,27 @@
     NOREF(pvUser);
 
+#ifdef VBOX_WITH_HGSMI
+#ifdef IN_RING3
+    if (s->vbe_index == VBE_DISPI_INDEX_VBVA_GUEST)
+    {
+        HGSMIGuestWrite (s->pHGSMI, u32);
+        return VINF_SUCCESS;
+    }
+    if (s->vbe_index == VBE_DISPI_INDEX_VBVA_HOST)
+    {
+        HGSMIHostWrite (s->pHGSMI, u32);
+        return VINF_SUCCESS;
+    }
+#else
+    if (   s->vbe_index == VBE_DISPI_INDEX_VBVA_HOST
+        || s->vbe_index == VBE_DISPI_INDEX_VBVA_GUEST)
+    {
+        Log(("vgaIOPortWriteVBEData: %s - Switching to host...\n",
+             s->vbe_index == VBE_DISPI_INDEX_VBVA_HOST? "VBE_DISPI_INDEX_VBVA_HOST": "VBE_DISPI_INDEX_VBVA_GUEST"));
+        return VINF_IOM_HC_IOPORT_WRITE;
+    }
+#endif /* !IN_RING3 */
+#endif /* VBOX_WITH_HGSMI */
+
 #ifndef IN_RING3
     /*
@@ -3246,4 +3274,28 @@
 {
     NOREF(pvUser);
+
+#ifdef VBOX_WITH_HGSMI
+#ifdef IN_RING3
+    VGAState *s = PDMINS_2_DATA(pDevIns, PVGASTATE);
+
+    if (s->vbe_index == VBE_DISPI_INDEX_VBVA_GUEST)
+    {
+        *pu32 = HGSMIGuestRead (s->pHGSMI);
+        return VINF_SUCCESS;
+    }
+    if (s->vbe_index == VBE_DISPI_INDEX_VBVA_HOST)
+    {
+        *pu32 = HGSMIHostRead (s->pHGSMI);
+        return VINF_SUCCESS;
+    }
+#else
+    if (   Port == VBE_DISPI_INDEX_VBVA_HOST
+        || Port == VBE_DISPI_INDEX_VBVA_GUEST)
+    {
+       return VINF_IOM_HC_IOPORT_WRITE;
+    }
+#endif /* !IN_RING3 */
+#endif /* VBOX_WITH_HGSMI */
+
 #ifdef VBE_BYTEWISE_IO
     if (cb == 1)
@@ -4603,5 +4655,12 @@
     PPDMDEVINS pDevIns = pThis->CTX_SUFF(pDevIns);
 
+#ifndef VBOX_WITH_HGSMI
     /* This should be called only in non VBVA mode. */
+#else
+    if (VBVAUpdateDisplay (pThis) == VINF_SUCCESS)
+    {
+        return VINF_SUCCESS;
+    }
+#endif /* VBOX_WITH_HGSMI */
 
     int rc = vga_update_display(pThis, false);
@@ -6114,4 +6173,8 @@
     if (FileLogo != NIL_RTFILE)
         RTFileClose(FileLogo);
+
+#ifdef VBOX_WITH_HGSMI
+    VBVAInit (pThis);
+#endif /* VBOX_WITH_HGSMI */
 
     /*
Index: trunk/src/VBox/Devices/Graphics/DevVGA.h
===================================================================
--- trunk/src/VBox/Devices/Graphics/DevVGA.h	(revision 17733)
+++ trunk/src/VBox/Devices/Graphics/DevVGA.h	(revision 17767)
@@ -44,4 +44,8 @@
  * THE SOFTWARE.
  */
+
+#ifdef VBOX_WITH_HGSMI
+#include "HGSMI/HGSMIHost.h"
+#endif /* VBOX_WITH_HGSMI */
 
 #define MSR_COLOR_EMULATION 0x01
@@ -74,5 +78,12 @@
 #define VBE_DISPI_INDEX_Y_OFFSET        0x9
 #define VBE_DISPI_INDEX_VBOX_VIDEO      0xa
+#ifdef VBOX_WITH_HGSMI
+/* @todo this will break saved state and is inefficient. use 2 PCI io ports. */
+#define VBE_DISPI_INDEX_VBVA_HOST       0xb
+#define VBE_DISPI_INDEX_VBVA_GUEST      0xc
+#define VBE_DISPI_INDEX_NB              0xd
+#else
 #define VBE_DISPI_INDEX_NB              0xb
+#endif /* !VBOX_WITH_HGSMI */
 
 #define VBE_DISPI_ID0                   0xB0C0
@@ -85,4 +96,10 @@
 /* The VBOX interface id. Indicates support for VBE_DISPI_INDEX_VBOX_VIDEO. */
 #define VBE_DISPI_ID_VBOX_VIDEO         0xBE00
+#ifdef VBOX_WITH_HGSMI
+/* The VBOX interface id. Indicates support for VBVA shared memory interface,
+ * VBE_DISPI_INDEX_VBVA_GUEST_CMD and VBE_DISPI_INDEX_VBVA_HOST_CMD VBE indexes.
+ */
+#define VBE_DISPI_ID_HGSMI              0xBE01
+#endif /* VBOX_WITH_HGSMI */
 #endif /* VBOX */
 
@@ -268,4 +285,8 @@
     bool                        padding9[2];
 
+#ifdef VBOX_WITH_HGSMI
+    R3PTRTYPE(PHGSMIINSTANCE)   pHGSMI;
+#endif /* VBOX_WITH_HGSMI */
+
     /** Current refresh timer interval. */
     uint32_t                    cMilliesRefreshInterval;
@@ -416,4 +437,11 @@
 #endif /* !VBOX || IN_RING3 */
 
+
+#ifdef VBOX_WITH_HGSMI
+int      VBVAInit       (PVGASTATE pVGAState);
+void     VBVADestroy    (PVGASTATE pVGAState);
+int      VBVAUpdateDisplay (PVGASTATE pVGAState);
+#endif /* VBOX_WITH_HGSMI */
+
 #ifndef VBOX
 void vga_common_init(VGAState *s, DisplayState *ds, uint8_t *vga_ram_base,
