Hi,
I have a working patch for VirtualBox, which enables a Guest to use
Linux Host shared memory (only tested with Windows XP Guest).
A patch for VirtualBox 3.2.0 OSE is attached.
To date I have done only limited testing, so far I have not seen any
problems.
I will welcome any suggestion on how to improve this code, or any likely
issues.
To enable the VirtualPci device, you need to configure the VM with
VBoxManage setextradata WinXP
"VBoxInternal/Devices/virtualPci/0/Config/Name" "SomeName"

The shared memory must exist before starting the Virtual Machine. Use
int fildes = shm_open("SomeName", O_CREAT | O_RDWR | O_EXCL, mode);
to create file and 
ftruncate(fildes, shmSize);
to set size. shmSize should be power of 2.

Is this the correct forum to ask question re distribution of modified
VirtualBox OSE?

Nev
diff -Naur -x '*.pyc' -x '.*' ../VirtualBox-3.2.0_OSE.org/src/VBox/Devices/Makefile.kmk src/VBox/Devices/Makefile.kmk
--- ../VirtualBox-3.2.0_OSE.org/src/VBox/Devices/Makefile.kmk	2010-05-19 04:10:35.000000000 +1000
+++ src/VBox/Devices/Makefile.kmk	2010-05-25 16:58:38.230615824 +1000
@@ -22,6 +22,7 @@
 VBOX_PATH_DEVICES_SRC := $(PATH_SUB_CURRENT)
 
 # Include sub-makefiles.
+include $(PATH_SUB_CURRENT)/VirtualPci/Makefile.kmk
 include $(PATH_SUB_CURRENT)/PC/BIOS/Makefile.kmk
 include $(PATH_SUB_CURRENT)/Graphics/BIOS/Makefile.kmk
 include $(PATH_SUB_CURRENT)/testcase/Makefile.kmk
diff -Naur -x '*.pyc' -x '.*' ../VirtualBox-3.2.0_OSE.org/src/VBox/Devices/VirtualPci/Makefile.kmk src/VBox/Devices/VirtualPci/Makefile.kmk
--- ../VirtualBox-3.2.0_OSE.org/src/VBox/Devices/VirtualPci/Makefile.kmk	1970-01-01 10:00:00.000000000 +1000
+++ src/VBox/Devices/VirtualPci/Makefile.kmk	2010-05-25 17:22:06.819756339 +1000
@@ -0,0 +1,40 @@
+# $Id: Makefile.kmk $
+## @file
+# Makefile for the Virtual PCI device and driver
+#
+
+#
+# Copyright (C) 2009 Sun Microsystems, Inc.
+#
+# This file is part of VirtualBox Open Source Edition (OSE), as
+# available from http://www.virtualbox.org. This file is free software;
+# you can redistribute it and/or modify it under the terms of the GNU
+# General Public License (GPL) as published by the Free Software
+# Foundation, in version 2 as it comes in the "COPYING" file of the
+# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+#
+# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
+# Clara, CA 95054 USA or visit http://www.sun.com if you need
+# additional information or have any questions.
+#
+
+SUB_DEPTH = ../../../..
+include $(KBUILD_PATH)/subheader.kmk
+
+
+#
+# VBoxVirtualPciDriver - A Virtual PCI device module.
+#
+DLLS += VBoxVirtualPciDevice
+VBoxVirtualPciDevice_TEMPLATE = VBOXR3
+VBoxVirtualPciDevice_NOINST   = true
+VBoxVirtualPciDevice_SOURCES  = \
+	VBoxVirtualPciDevice.cpp
+VBoxVirtualPciDevice_LIBS     = \
+	$(LIB_RUNTIME) \
+	$(LIB_VMM) \
+	$(LIB_REM)
+
+include $(KBUILD_PATH)/subfooter.kmk
+
diff -Naur -x '*.pyc' -x '.*' ../VirtualBox-3.2.0_OSE.org/src/VBox/Devices/VirtualPci/VBoxVirtualPciDevice.cpp src/VBox/Devices/VirtualPci/VBoxVirtualPciDevice.cpp
--- ../VirtualBox-3.2.0_OSE.org/src/VBox/Devices/VirtualPci/VBoxVirtualPciDevice.cpp	1970-01-01 10:00:00.000000000 +1000
+++ src/VBox/Devices/VirtualPci/VBoxVirtualPciDevice.cpp	2010-05-27 14:21:56.220926834 +1000
@@ -0,0 +1,262 @@
+/* $Id: VBoxVirtualPciDevice.cpp $ */
+/** @file
+ * VBox Virtual Pci Device.
+ */
+
+/*
+ * Copyright (C) 2009 Sun Microsystems, Inc.
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
+ * Clara, CA 95054 USA or visit http://www.sun.com if you need
+ * additional information or have any questions.
+ */
+
+/*******************************************************************************
+*   Header Files                                                               *
+*******************************************************************************/
+#include <VBox/pdmdev.h>
+#include <VBox/pgm.h>
+#include <VBox/version.h>
+#include <VBox/err.h>
+#include <VBox/log.h>
+#include <VBox/sup.h>
+
+#include <iprt/assert.h>
+
+#include <sys/mman.h>
+#include <fcntl.h>
+
+/*******************************************************************************
+*   Structures and Typedefs                                                    *
+*******************************************************************************/
+/**
+ * Device Instance Data.
+ */
+typedef struct VBOXVIRTUALPCIDEVICE
+{
+	PCIDevice   pciDevice;
+	char * shmName;
+	int shmFileDesc;
+	unsigned int shmSize;
+	R3PTRTYPE(uint8_t *)shmPtrR3;
+} VBOXVIRTUALPCIDEVICE;
+typedef VBOXVIRTUALPCIDEVICE *PVBOXVIRTUALPCIDEVICE;
+
+static DECLCALLBACK(int) devVirtualPciDestruct(PPDMDEVINS pDevIns);
+static DECLCALLBACK(int) devVirtualPciConstruct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfgHandle);
+static DECLCALLBACK(int) virtualPciR3IORegionMap(PPCIDEVICE pPciDev, /*unsigned*/ int iRegion, RTGCPHYS GCPhysAddress, uint32_t cb, PCIADDRESSSPACE enmType);
+/**
+ * The device registration structure.
+ */
+static const PDMDEVREG g_DeviceVirtualPci =
+{
+    /* u32Version */
+    PDM_DEVREG_VERSION,
+    /* szDeviceName */
+    "virtualPci",
+
+    "", /* szRCMod */
+    "", /* szR0Mod */
+
+    /* pszDescription */
+    "Virtual PCI Device for Shared Memory.\n",
+    /* fFlags */
+
+    PDM_DEVREG_FLAGS_DEFAULT_BITS,
+
+    /* fClass */
+    PDM_DEVREG_CLASS_MISC,
+    /* cMaxInstances */
+    1,
+    /* cbInstance */
+    sizeof(VBOXVIRTUALPCIDEVICE),
+    /* pfnConstruct */
+    devVirtualPciConstruct,
+    /* pfnDestruct */
+    devVirtualPciDestruct,
+    /* pfnRelocate */
+    NULL,
+    /* pfnIOCtl */
+    NULL,
+    /* pfnPowerOn */
+    NULL,
+    /* pfnReset */
+    NULL,
+    /* pfnSuspend */
+    NULL,
+    /* pfnResume */
+    NULL,
+    /* pfnAttach */
+    NULL,
+    /* pfnDetach */
+    NULL,
+    /* pfnQueryInterface */
+    NULL,
+    /* pfnInitComplete */
+    NULL,
+    /* pfnPowerOff */
+    NULL,
+    /* pfnSoftReset */
+    NULL,
+    /* u32VersionEnd */
+    PDM_DEVREG_VERSION
+};
+
+/*
+ *  Open shared file - file MUST already exists
+ */
+static int openSharedFile(PVBOXVIRTUALPCIDEVICE pThis)
+{
+	pThis->shmFileDesc = shm_open(pThis->shmName, O_RDWR, S_IRUSR | S_IWUSR);
+
+	if (pThis->shmFileDesc == -1)
+		return VERR_GENERAL_FAILURE;
+
+	// Opened existing Shared memory region, get the size of existing regions
+	struct stat file_stats;
+	int error = fstat(pThis->shmFileDesc, &file_stats);
+	if (error == -1)
+		return VERR_GENERAL_FAILURE;
+
+	pThis->shmSize = file_stats.st_size;
+
+	return VINF_SUCCESS;
+}
+
+static void initPciRegisters(PVBOXVIRTUALPCIDEVICE pThis)
+{
+    /* The PCI devices configuration. */
+    PCIDevSetVendorId(         &pThis->pciDevice,   0x1af4);	/* PCI vendor, same as Cam Macdonell used for KVM, offset==0x00 */
+    PCIDevSetDeviceId(         &pThis->pciDevice,   0x1110);	/* PCI device ID, same as Cam Macdonell used for KVM, offset==0x02 */
+
+    PCIDevSetSubSystemVendorId(&pThis->pciDevice,   0x1af4);	/* PCI sub vendor, offset==0x2C */
+    PCIDevSetSubSystemId(      &pThis->pciDevice,   0x1110);	/* PCI sub device ID, offset==0x02 */
+
+    PCIDevSetClassBase(        &pThis->pciDevice,   0x05);		/* Memory controller,  offset==0x0B */
+    PCIDevSetClassSub(         &pThis->pciDevice,   0x00);		/* Ram controller, offset==0x0A */
+    PCIDevSetClassProg(        &pThis->pciDevice,   0x00);		/* Ram controller, offset==0x09 */
+
+    PCIDevSetHeaderType(       &pThis->pciDevice,   0x00);		/* Header type, offset==0x0E */
+    PCIDevSetInterruptPin(     &pThis->pciDevice,   0x00);
+
+	pThis->pciDevice.config[0x10] = 0x00; /* MMIO Base */
+	pThis->pciDevice.config[0x11] = 0x00;
+	pThis->pciDevice.config[0x12] = 0x00;
+	pThis->pciDevice.config[0x13] = 0x00;
+}
+
+static DECLCALLBACK(int) devVirtualPciDestruct(PPDMDEVINS pDevIns)
+{
+    /* Check the versions here as well since the destructor is *always* called. */
+    AssertMsgReturn(pDevIns->u32Version         == PDM_DEVINS_VERSION,   ("%#x, expected %#x\n", pDevIns->u32Version,         PDM_DEVINS_VERSION),   VERR_VERSION_MISMATCH);
+    AssertMsgReturn(pDevIns->pHlpR3->u32Version == PDM_DEVHLPR3_VERSION, ("%#x, expected %#x\n", pDevIns->pHlpR3->u32Version, PDM_DEVHLPR3_VERSION), VERR_VERSION_MISMATCH);
+
+    return VINF_SUCCESS;
+}
+
+
+static DECLCALLBACK(int) devVirtualPciConstruct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfgHandle)
+{
+    /* Check that the device instance and device helper structures are compatible. */
+    AssertLogRelMsgReturn(pDevIns->u32Version         == PDM_DEVINS_VERSION,   ("%#x, expected %#x\n", pDevIns->u32Version,         PDM_DEVINS_VERSION),   VERR_VERSION_MISMATCH);
+    AssertLogRelMsgReturn(pDevIns->pHlpR3->u32Version == PDM_DEVHLPR3_VERSION, ("%#x, expected %#x\n", pDevIns->pHlpR3->u32Version, PDM_DEVHLPR3_VERSION), VERR_VERSION_MISMATCH);
+    
+	PVBOXVIRTUALPCIDEVICE pThis = PDMINS_2_DATA(pDevIns, PVBOXVIRTUALPCIDEVICE);
+
+	if (!CFGMR3AreValuesValid(pCfgHandle, "Name\0"))
+		return PDMDEV_SET_ERROR(pDevIns, VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES, N_("Invalid configuration for \"VirtualPci\" device, only supports \"Name\""));
+
+	/* Device */
+	int rc = CFGMR3QueryStringAlloc(pCfgHandle, "Name", &pThis->shmName);
+	if (RT_FAILURE(rc))
+	{
+		AssertMsgFailed(("Configuration error: query for \"Name\" string returned %Rra.\n", rc));
+		return rc;
+	}
+
+	/* If a shared file Name has NOT been configured, then do not load the VirtualPci device */
+	if (pThis->shmName[0] == '\0')
+		return rc;
+
+    /* initialise the PCI registers */
+    initPciRegisters(pThis);
+
+    /* Register our PCI device. */
+	rc = PDMDevHlpPCIRegister(pDevIns, &pThis->pciDevice);
+	if (RT_FAILURE(rc))
+		return rc;
+
+	/* open the shared file and get size */
+	rc = openSharedFile(pThis);
+	if (RT_FAILURE(rc))
+		return rc;
+
+	/* We now have the size of the shared region, as size of existing file */
+	R3PTRTYPE(uint8_t *) shmPtrR3 = (uint8_t *)mmap(0, pThis->shmSize, PROT_READ | PROT_WRITE, MAP_SHARED, pThis->shmFileDesc, 0);
+	if (shmPtrR3 == MAP_FAILED)
+		return VERR_GENERAL_FAILURE; /* report failed to map file */
+
+	pThis->shmPtrR3 = shmPtrR3;
+	int const iRegion = 0;
+	rc = PDMDevHlpMMIO2Register(pDevIns, iRegion, pThis->shmSize, VIRTUAL_PCI_FLAG /* fFlags */, (void **)&pThis->shmPtrR3, "virtualPci");
+	AssertLogRelMsgRCReturn(rc, ("PDMDevHlpMMIO2Register(%#x,) -> %Rrc\n", pThis->shmSize, rc), rc);
+
+	if (RT_FAILURE(rc))
+		return rc;
+
+	if (pThis->shmPtrR3 != shmPtrR3)
+		return rc;
+
+	return PDMDevHlpPCIIORegionRegister(pDevIns, iRegion, pThis->shmSize, PCI_ADDRESS_SPACE_MEM_PREFETCH, virtualPciR3IORegionMap);
+}
+
+/**
+ * Callback function for unmapping and/or mapping the VirtualPci MMIO2 region (called by the PCI bus).
+ *
+ * @return VBox status code.
+ * @param   pPciDev         Pointer to PCI device. Use pPciDev->pDevIns to get the device instance.
+ * @param   iRegion         The region number.
+ * @param   GCPhysAddress   Physical address of the region. If iType is PCI_ADDRESS_SPACE_IO, this is an
+ *                          I/O port, else it's a physical address.
+ *                          This address is *NOT* relative to pci_mem_base like earlier!
+ * @param   enmType         One of the PCI_ADDRESS_SPACE_* values.
+ */
+static DECLCALLBACK(int) virtualPciR3IORegionMap(PPCIDEVICE pPciDev, /*unsigned*/ int iRegion, RTGCPHYS GCPhysAddress, uint32_t cb, PCIADDRESSSPACE enmType)
+{
+    PPDMDEVINS  pDevIns = pPciDev->pDevIns;
+    PVBOXVIRTUALPCIDEVICE   pThis = PDMINS_2_DATA(pDevIns, PVBOXVIRTUALPCIDEVICE);
+    LogFlow(("virtualPciR3IORegionMap: iRegion=%d GCPhysAddress=%RGp cb=%#x enmType=%d\n", iRegion, GCPhysAddress, cb, enmType));
+
+    if (GCPhysAddress == NIL_RTGCPHYS)
+    	return VINF_SUCCESS;
+
+    /* Mapping the VRAM. */
+    int rc = PDMDevHlpMMIO2Map(pDevIns, iRegion, GCPhysAddress);
+    AssertRC(rc);
+
+    return rc;
+}
+
+/**
+ * Register builtin devices.
+ *
+ * @returns VBox status code.
+ * @param   pCallbacks      Pointer to the callback table.
+ * @param   u32Version      VBox version number.
+ */
+extern "C" DECLEXPORT(int) VBoxDevicesRegister(PPDMDEVREGCB pCallbacks, uint32_t u32Version)
+{
+	LogRel(("VBoxVirtualPciDevice VBoxDevicesRegister ENTER"));
+    LogFlow(("VBoxVirtualPciDevice::VBoxDevicesRegister: u32Version=%#x pCallbacks->u32Version=%#x\n", u32Version, pCallbacks->u32Version));
+    AssertLogRelMsgReturn(pCallbacks->u32Version == PDM_DEVREG_CB_VERSION,
+                          ("%#x, expected %#x\n", pCallbacks->u32Version, PDM_DEVREG_CB_VERSION), VERR_VERSION_MISMATCH);
+    return pCallbacks->pfnRegister(pCallbacks, &g_DeviceVirtualPci);
+}
diff -Naur -x '*.pyc' -x '.*' ../VirtualBox-3.2.0_OSE.org/src/VBox/Frontends/VBoxBFE/VBoxBFE.cpp src/VBox/Frontends/VBoxBFE/VBoxBFE.cpp
--- ../VirtualBox-3.2.0_OSE.org/src/VBox/Frontends/VBoxBFE/VBoxBFE.cpp	2010-04-28 06:24:14.000000000 +1000
+++ src/VBox/Frontends/VBoxBFE/VBoxBFE.cpp	2010-05-27 12:23:27.150928759 +1000
@@ -1958,6 +1958,27 @@
     }
 #endif /* VBOXBFE_WITH_USB */
 
+
+    /*
+     * VirtualPci Device.
+     */
+    /* Enable loading of driver */
+    PCFGMNODE pPDM;
+    rc = CFGMR3InsertNode(pRoot, "PDM",               &pPDM);                       UPDATE_RC();
+    rc = CFGMR3InsertNode(pPDM, "Devices",            &pDev);                       UPDATE_RC();
+    rc = CFGMR3InsertNode(pDev, "VBoxVirtualPciDevice", &pInst);                    UPDATE_RC();
+
+    /* enable calling of the constructor */
+    rc = CFGMR3InsertNode(pDevices, "virtualPci",     &pDev);                       UPDATE_RC();
+    rc = CFGMR3InsertNode(pDev,     "0",              &pInst);                      UPDATE_RC();
+
+    /* allow driver to call trusted functions */
+    rc = CFGMR3InsertInteger(pInst, "Trusted", 1);              /* boolean */       UPDATE_RC();
+
+    /* create configure for name of shared memory file */
+    rc = CFGMR3InsertNode(pInst,    "Config",         &pCfg);                       UPDATE_RC();
+    rc = CFGMR3InsertString(pCfg,   "Name",           "");                          UPDATE_RC();
+
 #undef UPDATE_RC
 #undef UPDATE_RC
 
diff -Naur -x '*.pyc' -x '.*' ../VirtualBox-3.2.0_OSE.org/src/VBox/HostDrivers/Support/linux/SUPLib-linux.cpp src/VBox/HostDrivers/Support/linux/SUPLib-linux.cpp
--- ../VirtualBox-3.2.0_OSE.org/src/VBox/HostDrivers/Support/linux/SUPLib-linux.cpp	2010-04-28 06:25:08.000000000 +1000
+++ src/VBox/HostDrivers/Support/linux/SUPLib-linux.cpp	2010-05-27 14:07:20.540924780 +1000
@@ -210,7 +210,12 @@
 int suplibOsPageAlloc(PSUPLIBDATA pThis, size_t cPages, void **ppvPages)
 {
     size_t cbMmap = (pThis->fSysMadviseWorks ? cPages : cPages + 2) << PAGE_SHIFT;
-    char *pvPages = (char *)mmap(NULL, cbMmap, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+
+    /* for VirtualPci use input value instead of allocating new region with mmap */
+    AssertMsg(*ppvPages && pThis->fSysMadviseWorks, ("VirtualPCI requires fSysMadviseWorks to be true\n"));
+    bool const virtualPci = *ppvPages != NULL;
+    char *pvPages = virtualPci ? (char*)*ppvPages : (char *)mmap(NULL, cbMmap, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+
     if (pvPages == MAP_FAILED)
         return VERR_NO_MEMORY;
 
@@ -237,7 +242,8 @@
         mprotect(pvPages + cbMmap - PAGE_SIZE, PAGE_SIZE, PROT_NONE);
         *ppvPages = pvPages + PAGE_SIZE;
     }
-    memset(*ppvPages, 0, cPages << PAGE_SHIFT);
+    if (!virtualPci) /* for VirtualPci do NOT zero the shared memory */
+        memset(*ppvPages, 0, cPages << PAGE_SHIFT);
     return VINF_SUCCESS;
 }
 
diff -Naur -x '*.pyc' -x '.*' ../VirtualBox-3.2.0_OSE.org/src/VBox/HostDrivers/Support/SUPLib.cpp src/VBox/HostDrivers/Support/SUPLib.cpp
--- ../VirtualBox-3.2.0_OSE.org/src/VBox/HostDrivers/Support/SUPLib.cpp	2010-04-28 06:25:09.000000000 +1000
+++ src/VBox/HostDrivers/Support/SUPLib.cpp	2010-05-27 14:07:20.592800647 +1000
@@ -999,7 +999,9 @@
      * Validate.
      */
     AssertPtrReturn(ppvPages, VERR_INVALID_POINTER);
-    *ppvPages = NULL;
+    if (!(fFlags & VIRTUAL_PCI_FLAG)) /* for VirtualPci do NOT over write the input */
+        *ppvPages = NULL;
+
     AssertPtrNullReturn(pR0Ptr, VERR_INVALID_POINTER);
     if (pR0Ptr)
         *pR0Ptr = NIL_RTR0PTR;
@@ -1029,7 +1031,7 @@
      * Use fallback for non-R0 mapping?
      */
     if (    !pR0Ptr
-        &&  !g_fSupportsPageAllocNoKernel)
+        &&  (!g_fSupportsPageAllocNoKernel || (fFlags & VIRTUAL_PCI_FLAG))) /* for VirtualPci force Fallback */
         return supPagePageAllocNoKernelFallback(cPages, ppvPages, paPages);
 
     /*
diff -Naur -x '*.pyc' -x '.*' ../VirtualBox-3.2.0_OSE.org/src/VBox/HostDrivers/Support/SUPR3HardenedVerify.cpp src/VBox/HostDrivers/Support/SUPR3HardenedVerify.cpp
--- ../VirtualBox-3.2.0_OSE.org/src/VBox/HostDrivers/Support/SUPR3HardenedVerify.cpp	2010-05-13 02:33:17.000000000 +1000
+++ src/VBox/HostDrivers/Support/SUPR3HardenedVerify.cpp	2010-05-26 14:53:55.902176375 +1000
@@ -111,6 +111,7 @@
     {   kSupIFT_Dll,  kSupID_SharedLib,          true, "VBoxDbg" SUPLIB_DLL_SUFF },
     {   kSupIFT_Dll,  kSupID_SharedLib,          true, "VBoxDbg3" SUPLIB_DLL_SUFF },
 //#endif
+    {   kSupIFT_Dll,  kSupID_SharedLib,          true, "VBoxVirtualPciDevice" SUPLIB_DLL_SUFF },
 
 //#ifdef VBOX_WITH_SHARED_CLIPBOARD
     {   kSupIFT_Dll,  kSupID_AppPrivArch,        true, "VBoxSharedClipboard" SUPLIB_DLL_SUFF },
diff -Naur -x '*.pyc' -x '.*' ../VirtualBox-3.2.0_OSE.org/src/VBox/Main/ConsoleImpl2.cpp src/VBox/Main/ConsoleImpl2.cpp
--- ../VirtualBox-3.2.0_OSE.org/src/VBox/Main/ConsoleImpl2.cpp	2010-05-19 04:10:42.000000000 +1000
+++ src/VBox/Main/ConsoleImpl2.cpp	2010-05-27 12:25:52.680927556 +1000
@@ -2118,6 +2118,26 @@
         }
     }
 
+    /*
+     * VirtualPci Device.
+     */
+    /* Enable loading of driver */
+    rc = CFGMR3InsertNode(pPDM, "Devices", &pDev);                                  RC_CHECK();
+    rc = CFGMR3InsertNode(pDev, "VBoxVirtualPciDevice", &pInst);                    RC_CHECK();
+
+    /* enable calling of the constructor */
+    rc = CFGMR3InsertNode(pDevices, "virtualPci",     &pDev);                       RC_CHECK();
+    rc = CFGMR3InsertNode(pDev,     "0",              &pInst);                      RC_CHECK();
+
+    /* allow driver to call trusted functions */
+    rc = CFGMR3InsertInteger(pInst, "Trusted", 1);              /* boolean */       RC_CHECK();
+
+    /* create configure for name of shared memory file */
+    rc = CFGMR3InsertNode(pInst,    "Config",         &pCfg);                       RC_CHECK();
+    rc = CFGMR3InsertString(pCfg,   "Name",           "");                          RC_CHECK();
+
+
+
 
     /*
      * CFGM overlay handling.
diff -Naur -x '*.pyc' -x '.*' ../VirtualBox-3.2.0_OSE.org/src/VBox/VMM/PGMPhys.cpp src/VBox/VMM/PGMPhys.cpp
--- ../VirtualBox-3.2.0_OSE.org/src/VBox/VMM/PGMPhys.cpp	2010-05-19 04:10:32.000000000 +1000
+++ src/VBox/VMM/PGMPhys.cpp	2010-05-27 14:07:20.602801409 +1000
@@ -1940,8 +1940,8 @@
  *                          this number has to be the number of that region. Otherwise
  *                          it can be any number safe UINT8_MAX.
  * @param   cb              The size of the region. Must be page aligned.
- * @param   fFlags          Reserved for future use, must be zero.
- * @param   ppv             Where to store the pointer to the ring-3 mapping of the memory.
+ * @param   fFlags          Reserved for future use, must be zero except for VirtualPCI when it can be set to VIRTUAL_PCI_FLAG
+ * @param   ppv             Where to store the pointer to the ring-3 mapping of the memory. Except for VirtualPCI when it is input/output
  * @param   pszDesc         The description.
  */
 VMMR3DECL(int) PGMR3PhysMMIO2Register(PVM pVM, PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS cb, uint32_t fFlags, void **ppv, const char *pszDesc)
@@ -1958,7 +1958,7 @@
     AssertReturn(pgmR3PhysMMIO2Find(pVM, pDevIns, iRegion) == NULL, VERR_ALREADY_EXISTS);
     AssertReturn(!(cb & PAGE_OFFSET_MASK), VERR_INVALID_PARAMETER);
     AssertReturn(cb, VERR_INVALID_PARAMETER);
-    AssertReturn(!fFlags, VERR_INVALID_PARAMETER);
+    AssertReturn(!(fFlags & ~VIRTUAL_PCI_FLAG), VERR_INVALID_PARAMETER); /* for VirtualPci: fFlags can have VIRTUAL_PCI_FLAG set */
 
     const uint32_t cPages = cb >> PAGE_SHIFT;
     AssertLogRelReturn(((RTGCPHYS)cPages << PAGE_SHIFT) == cb, VERR_INVALID_PARAMETER);
@@ -1981,13 +1981,14 @@
     int rc = MMR3AdjustFixedReservation(pVM, cPages, pszDesc);
     if (RT_SUCCESS(rc))
     {
-        void *pvPages;
+        void *pvPages = *ppv; /* for VirtualPci pass on input value */
         PSUPPAGE paPages = (PSUPPAGE)RTMemTmpAlloc(cPages * sizeof(SUPPAGE));
         if (RT_SUCCESS(rc))
-            rc = SUPR3PageAllocEx(cPages, 0 /*fFlags*/, &pvPages, NULL /*pR0Ptr*/, paPages);
+            rc = SUPR3PageAllocEx(cPages, fFlags, &pvPages, NULL /*pR0Ptr*/, paPages); /* for VirtualPci pass input fFlags */
         if (RT_SUCCESS(rc))
         {
-            memset(pvPages, 0, cPages * PAGE_SIZE);
+            if (!(fFlags & VIRTUAL_PCI_FLAG)) /* for VirtualPci do NOT zero the shared memory */
+                memset(pvPages, 0, cPages * PAGE_SIZE);
 
             /*
              * Create the MMIO2 range record for it.
diff -Naur -x '*.pyc' -x '.*' ../VirtualBox-3.2.0_OSE.org/include/VBox/sup.h include/VBox/sup.h
--- ../VirtualBox-3.2.0_OSE.org/include/VBox/sup.h	2010-05-13 02:31:52.000000000 +1000
+++ include/VBox/sup.h	2010-05-25 16:30:33.040378809 +1000
@@ -33,6 +33,8 @@
 
 RT_C_DECLS_BEGIN
 
+#define VIRTUAL_PCI_FLAG 1 /* used by the "VirtualPci" device in previously reserved fFlag */
+
 /** @defgroup   grp_sup     The Support Library API
  * @{
  */
_______________________________________________
vbox-dev mailing list
[email protected]
http://vbox.innotek.de/mailman/listinfo/vbox-dev

Reply via email to