Index: /trunk/include/VBox/mm.h
===================================================================
--- /trunk/include/VBox/mm.h	(revision 14593)
+++ /trunk/include/VBox/mm.h	(revision 14594)
@@ -340,5 +340,4 @@
 VMMR3DECL(int)      MMR3HyperMapGCPhys(PVM pVM, RTGCPHYS GCPhys, size_t cb, const char *pszDesc, PRTGCPTR pGCPtr);
 VMMR3DECL(int)      MMR3HyperMapMMIO2(PVM pVM, PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS off, RTGCPHYS cb, const char *pszDesc, PRTRCPTR pRCPtr);
-VMMR3DECL(int)      MMR3HyperMapHCRam(PVM pVM, void *pvHC, size_t cb, bool fFree, const char *pszDesc, PRTGCPTR pGCPtr);
 VMMR3DECL(int)      MMR3HyperMapPages(PVM pVM, void *pvR3, RTR0PTR pvR0, size_t cPages, PCSUPPAGE paPages, const char *pszDesc, PRTGCPTR pGCPtr);
 VMMR3DECL(int)      MMR3HyperReserve(PVM pVM, unsigned cb, const char *pszDesc, PRTGCPTR pGCPtr);
Index: /trunk/src/VBox/VMM/MMHyper.cpp
===================================================================
--- /trunk/src/VBox/VMM/MMHyper.cpp	(revision 14593)
+++ /trunk/src/VBox/VMM/MMHyper.cpp	(revision 14594)
@@ -510,79 +510,4 @@
         }
     }
-    return rc;
-}
-
-
-/**
- * Locks and Maps HC virtual memory into the hypervisor region in the GC.
- *
- * @return VBox status code.
- *
- * @param   pVM         VM handle.
- * @param   pvR3        Host context address of the memory (may be not page
- *                      aligned).
- * @param   cb          Size of the memory. Will be rounded up to nearest page.
- * @param   fFree       Set this if MM is responsible for freeing the memory
- *                      using SUPPageFree.
- * @param   pszDesc     Mapping description.
- * @param   pGCPtr      Where to store the GC address corresponding to pvR3.
- */
-VMMR3DECL(int) MMR3HyperMapHCRam(PVM pVM, void *pvR3, size_t cb, bool fFree, const char *pszDesc, PRTGCPTR pGCPtr)
-{
-    LogFlow(("MMR3HyperMapHCRam: pvR3=%p cb=%d fFree=%d pszDesc=%p:{%s} pGCPtr=%p\n", pvR3, (int)cb, fFree, pszDesc, pszDesc, pGCPtr));
-
-    /*
-     * Validate input.
-     */
-    if (    !pvR3
-        ||  cb <= 0
-        ||  !pszDesc
-        ||  !*pszDesc)
-    {
-        AssertMsgFailed(("Invalid parameter\n"));
-        return VERR_INVALID_PARAMETER;
-    }
-
-    /*
-     * Page align address and size.
-     */
-    void *pvR3Page = (void *)((uintptr_t)pvR3 & PAGE_BASE_HC_MASK);
-    cb += (uintptr_t)pvR3 & PAGE_OFFSET_MASK;
-    cb = RT_ALIGN_Z(cb, PAGE_SIZE);
-
-    /*
-     * Add the memory to the hypervisor area.
-     */
-    RTGCPTR         GCPtr;
-    PMMLOOKUPHYPER  pLookup;
-    int rc = mmR3HyperMap(pVM, cb, pszDesc, &GCPtr, &pLookup);
-    if (RT_SUCCESS(rc))
-    {
-        /*
-         * Lock the heap memory and tell PGM about the locked pages.
-         */
-        PMMLOCKEDMEM    pLockedMem;
-        rc = mmR3LockMem(pVM, pvR3Page, cb, fFree ? MM_LOCKED_TYPE_HYPER : MM_LOCKED_TYPE_HYPER_NOFREE, &pLockedMem, false /* fSilentFailure */);
-        if (RT_SUCCESS(rc))
-        {
-            /* map the stuff into guest address space. */
-            if (pVM->mm.s.fPGMInitialized)
-                rc = mmR3MapLocked(pVM, pLockedMem, GCPtr, 0, ~(size_t)0, 0);
-            if (RT_SUCCESS(rc))
-            {
-                pLookup->enmType = MMLOOKUPHYPERTYPE_LOCKED;
-                pLookup->u.Locked.pvR3       = pvR3;
-                pLookup->u.Locked.pvR0       = NIL_RTR0PTR;
-                pLookup->u.Locked.pLockedMem = pLockedMem;
-
-                /* done. */
-                GCPtr    |= (uintptr_t)pvR3 & PAGE_OFFSET_MASK;
-                *pGCPtr   = GCPtr;
-                return rc;
-            }
-            /* Don't care about failure clean, we're screwed if this fails anyway. */
-        }
-    }
-
     return rc;
 }
Index: /trunk/src/VBox/VMM/PDMLdr.cpp
===================================================================
--- /trunk/src/VBox/VMM/PDMLdr.cpp	(revision 14593)
+++ /trunk/src/VBox/VMM/PDMLdr.cpp	(revision 14594)
@@ -460,53 +460,63 @@
          * Allocate space in the hypervisor.
          */
-        size_t cb = RTLdrSize(pModule->hLdrMod);
+        size_t      cb = RTLdrSize(pModule->hLdrMod);
         cb = RT_ALIGN_Z(cb, PAGE_SIZE);
-        rc = SUPPageAlloc(cb >> PAGE_SHIFT, &pModule->pvBits);
-        if (RT_SUCCESS(rc))
-        {
-            RTGCPTR GCPtr;
-            rc = MMR3HyperMapHCRam(pVM, pModule->pvBits, cb, true, pModule->szName, &GCPtr);
+        uint32_t    cPages = cb >> PAGE_SHIFT;
+        PSUPPAGE    paPages = (PSUPPAGE)RTMemTmpAlloc(cPages * sizeof(paPages[0]));
+        if (paPages)
+        {
+            rc = SUPR3PageAllocEx(cPages, 0 /*fFlags*/, &pModule->pvBits, NULL /*pR0Ptr*/, paPages);
             if (RT_SUCCESS(rc))
             {
-                MMR3HyperReserve(pVM, PAGE_SIZE, "fence", NULL);
-
-                /*
-                 * Get relocated image bits.
-                 */
-                Assert(MMHyperR3ToRC(pVM, pModule->pvBits) == GCPtr);
-                pModule->ImageBase = GCPtr;
-                PDMGETIMPORTARGS Args;
-                Args.pVM = pVM;
-                Args.pModule = pModule;
-                rc = RTLdrGetBits(pModule->hLdrMod, pModule->pvBits, pModule->ImageBase, pdmR3GetImportRC, &Args);
+                RTGCPTR GCPtr;
+                rc = MMR3HyperMapPages(pVM, pModule->pvBits, (uintptr_t)pModule->pvBits,
+                                       cPages, paPages, pModule->szName, &GCPtr);
                 if (RT_SUCCESS(rc))
                 {
+                    MMR3HyperReserve(pVM, PAGE_SIZE, "fence", NULL);
+
                     /*
-                     * Insert the module.
+                     * Get relocated image bits.
                      */
-                    PUVM pUVM = pVM->pUVM;
-                    if (pUVM->pdm.s.pModules)
+                    Assert(MMHyperR3ToRC(pVM, pModule->pvBits) == GCPtr);
+                    pModule->ImageBase = GCPtr;
+                    PDMGETIMPORTARGS Args;
+                    Args.pVM = pVM;
+                    Args.pModule = pModule;
+                    rc = RTLdrGetBits(pModule->hLdrMod, pModule->pvBits, pModule->ImageBase, pdmR3GetImportRC, &Args);
+                    if (RT_SUCCESS(rc))
                     {
-                        /* we don't expect this list to be very long, so rather save the tail pointer. */
-                        PPDMMOD pCur = pUVM->pdm.s.pModules;
-                        while (pCur->pNext)
-                            pCur = pCur->pNext;
-                        pCur->pNext = pModule;
+                        /*
+                         * Insert the module.
+                         */
+                        PUVM pUVM = pVM->pUVM;
+                        if (pUVM->pdm.s.pModules)
+                        {
+                            /* we don't expect this list to be very long, so rather save the tail pointer. */
+                            PPDMMOD pCur = pUVM->pdm.s.pModules;
+                            while (pCur->pNext)
+                                pCur = pCur->pNext;
+                            pCur->pNext = pModule;
+                        }
+                        else
+                            pUVM->pdm.s.pModules = pModule; /* (pNext is zeroed by alloc) */
+                        Log(("PDM: RC Module at %RRv %s (%s)\n", (RTRCPTR)pModule->ImageBase, pszName, pszFilename));
+                        RTMemTmpFree(pszFile);
+                        RTMemTmpFree(paPages);
+                        return VINF_SUCCESS;
                     }
-                    else
-                        pUVM->pdm.s.pModules = pModule; /* (pNext is zeroed by alloc) */
-                    Log(("PDM: RC Module at %RRv %s (%s)\n", (RTRCPTR)pModule->ImageBase, pszName, pszFilename));
-                    RTMemTmpFree(pszFile);
-                    return VINF_SUCCESS;
                 }
+                else
+                {
+                    AssertRC(rc);
+                    SUPR3PageFreeEx(pModule->pvBits, cPages);
+                }
             }
             else
-            {
-                AssertRC(rc);
-                SUPPageFree(pModule->pvBits, cb >> PAGE_SHIFT);
-            }
+                AssertMsgFailed(("SUPPageAlloc(%d,) -> %Rrc\n", cPages, rc));
+            RTMemTmpFree(paPages);
         }
         else
-            AssertMsgFailed(("SUPPageAlloc(%d,) -> %Rrc\n", cb >> PAGE_SHIFT, rc));
+            rc = VERR_NO_TMP_MEMORY;
         int rc2 = RTLdrClose(pModule->hLdrMod);
         AssertRC(rc2);
