VirtualBox

Changeset 18873 in vbox for trunk/src/VBox/VMM


Ignore:
Timestamp:
Apr 11, 2009 10:10:51 PM (16 years ago)
Author:
vboxsync
Message:

PGMPhys.cpp: Also mangle the MMIO2 description.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/PGMPhys.cpp

    r18869 r18873  
    2626#define LOG_GROUP LOG_GROUP_PGM_PHYS
    2727#include <VBox/pgm.h>
    28 #include <VBox/cpum.h>
    2928#include <VBox/iom.h>
    30 #include <VBox/sup.h>
    3129#include <VBox/mm.h>
    3230#include <VBox/stam.h>
    3331#include <VBox/rem.h>
    34 #include <VBox/csam.h>
     32#include <VBox/pdmdev.h>
    3533#include "PGMInternal.h"
    3634#include <VBox/vm.h>
    37 #include <VBox/dbg.h>
     35#include <VBox/sup.h>
    3836#include <VBox/param.h>
    3937#include <VBox/err.h>
     38#include <VBox/log.h>
    4039#include <iprt/assert.h>
    4140#include <iprt/alloc.h>
    4241#include <iprt/asm.h>
    43 #include <VBox/log.h>
    4442#include <iprt/thread.h>
    4543#include <iprt/string.h>
     
    14761474
    14771475    /*
     1476     * For the 2nd+ instance, mangle the description string so it's unique.
     1477     */
     1478    if (pDevIns->iInstance > 0)
     1479    {
     1480        pszDesc = MMR3HeapAPrintf(pVM, MM_TAG_PGM_PHYS, "%s [%u]", pszDesc, pDevIns->iInstance);
     1481        if (!pszDesc)
     1482            return VERR_NO_MEMORY;
     1483    }
     1484
     1485    /*
    14781486     * Try reserve and allocate the backing memory first as this is what is
    14791487     * most likely to fail.
    14801488     */
    14811489    int rc = MMR3AdjustFixedReservation(pVM, cPages, pszDesc);
    1482     if (RT_FAILURE(rc))
    1483         return rc;
    1484 
    1485     void *pvPages;
    1486     PSUPPAGE paPages = (PSUPPAGE)RTMemTmpAlloc(cPages * sizeof(SUPPAGE));
    14871490    if (RT_SUCCESS(rc))
    1488         rc = SUPR3PageAllocEx(cPages, 0 /*fFlags*/, &pvPages, NULL /*pR0Ptr*/, paPages);
    1489     if (RT_SUCCESS(rc))
    1490     {
    1491         memset(pvPages, 0, cPages * PAGE_SIZE);
    1492 
    1493         /*
    1494          * Create the MMIO2 range record for it.
    1495          */
    1496         const size_t cbRange = RT_OFFSETOF(PGMMMIO2RANGE, RamRange.aPages[cPages]);
    1497         PPGMMMIO2RANGE pNew;
    1498         rc = MMR3HyperAllocOnceNoRel(pVM, cbRange, 0, MM_TAG_PGM_PHYS, (void **)&pNew);
    1499         AssertLogRelMsgRC(rc, ("cbRamRange=%zu\n", cbRange));
     1491    {   
     1492        void *pvPages;
     1493        PSUPPAGE paPages = (PSUPPAGE)RTMemTmpAlloc(cPages * sizeof(SUPPAGE));
    15001494        if (RT_SUCCESS(rc))
    1501         {
    1502             pNew->pDevInsR3             = pDevIns;
    1503             pNew->pvR3                  = pvPages;
    1504             //pNew->pNext               = NULL;
    1505             //pNew->fMapped             = false;
    1506             //pNew->fOverlapping        = false;
    1507             pNew->iRegion               = iRegion;
    1508             pNew->RamRange.pSelfR0      = MMHyperCCToR0(pVM, &pNew->RamRange);
    1509             pNew->RamRange.pSelfRC      = MMHyperCCToRC(pVM, &pNew->RamRange);
    1510             pNew->RamRange.GCPhys       = NIL_RTGCPHYS;
    1511             pNew->RamRange.GCPhysLast   = NIL_RTGCPHYS;
    1512             pNew->RamRange.pszDesc      = pszDesc;
    1513             pNew->RamRange.cb           = cb;
    1514             //pNew->RamRange.fFlags     = 0; /// @todo MMIO2 flag?
    1515 
    1516             pNew->RamRange.pvR3         = pvPages;
    1517 
    1518             uint32_t iPage = cPages;
    1519             while (iPage-- > 0)
     1495            rc = SUPR3PageAllocEx(cPages, 0 /*fFlags*/, &pvPages, NULL /*pR0Ptr*/, paPages);
     1496        if (RT_SUCCESS(rc))
     1497        {
     1498            memset(pvPages, 0, cPages * PAGE_SIZE);
     1499   
     1500            /*
     1501             * Create the MMIO2 range record for it.
     1502             */
     1503            const size_t cbRange = RT_OFFSETOF(PGMMMIO2RANGE, RamRange.aPages[cPages]);
     1504            PPGMMMIO2RANGE pNew;
     1505            rc = MMR3HyperAllocOnceNoRel(pVM, cbRange, 0, MM_TAG_PGM_PHYS, (void **)&pNew);
     1506            AssertLogRelMsgRC(rc, ("cbRamRange=%zu\n", cbRange));
     1507            if (RT_SUCCESS(rc))
    15201508            {
    1521                 PGM_PAGE_INIT(&pNew->RamRange.aPages[iPage],
    1522                               paPages[iPage].Phys & X86_PTE_PAE_PG_MASK, NIL_GMM_PAGEID,
    1523                               PGMPAGETYPE_MMIO2, PGM_PAGE_STATE_ALLOCATED);
     1509                pNew->pDevInsR3             = pDevIns;
     1510                pNew->pvR3                  = pvPages;
     1511                //pNew->pNext               = NULL;
     1512                //pNew->fMapped             = false;
     1513                //pNew->fOverlapping        = false;
     1514                pNew->iRegion               = iRegion;
     1515                pNew->RamRange.pSelfR0      = MMHyperCCToR0(pVM, &pNew->RamRange);
     1516                pNew->RamRange.pSelfRC      = MMHyperCCToRC(pVM, &pNew->RamRange);
     1517                pNew->RamRange.GCPhys       = NIL_RTGCPHYS;
     1518                pNew->RamRange.GCPhysLast   = NIL_RTGCPHYS;
     1519                pNew->RamRange.pszDesc      = pszDesc;
     1520                pNew->RamRange.cb           = cb;
     1521                //pNew->RamRange.fFlags     = 0; /// @todo MMIO2 flag?
     1522   
     1523                pNew->RamRange.pvR3         = pvPages;
     1524   
     1525                uint32_t iPage = cPages;
     1526                while (iPage-- > 0)
     1527                {
     1528                    PGM_PAGE_INIT(&pNew->RamRange.aPages[iPage],
     1529                                  paPages[iPage].Phys & X86_PTE_PAE_PG_MASK, NIL_GMM_PAGEID,
     1530                                  PGMPAGETYPE_MMIO2, PGM_PAGE_STATE_ALLOCATED);
     1531                }
     1532   
     1533                /* update page count stats */
     1534                pVM->pgm.s.cAllPages     += cPages;
     1535                pVM->pgm.s.cPrivatePages += cPages;
     1536   
     1537                /*
     1538                 * Link it into the list.
     1539                 * Since there is no particular order, just push it.
     1540                 */
     1541                pNew->pNextR3 = pVM->pgm.s.pMmio2RangesR3;
     1542                pVM->pgm.s.pMmio2RangesR3 = pNew;
     1543   
     1544                *ppv = pvPages;
     1545                RTMemTmpFree(paPages);
     1546                return VINF_SUCCESS;
    15241547            }
    1525 
    1526             /* update page count stats */
    1527             pVM->pgm.s.cAllPages     += cPages;
    1528             pVM->pgm.s.cPrivatePages += cPages;
    1529 
    1530             /*
    1531              * Link it into the list.
    1532              * Since there is no particular order, just push it.
    1533              */
    1534             pNew->pNextR3 = pVM->pgm.s.pMmio2RangesR3;
    1535             pVM->pgm.s.pMmio2RangesR3 = pNew;
    1536 
    1537             *ppv = pvPages;
    1538             RTMemTmpFree(paPages);
    1539             return VINF_SUCCESS;
    1540         }
    1541 
    1542         SUPR3PageFreeEx(pvPages, cPages);
    1543     }
    1544     RTMemTmpFree(paPages);
    1545     MMR3AdjustFixedReservation(pVM, -(int32_t)cPages, pszDesc);
     1548   
     1549            SUPR3PageFreeEx(pvPages, cPages);
     1550        }
     1551        RTMemTmpFree(paPages);
     1552        MMR3AdjustFixedReservation(pVM, -(int32_t)cPages, pszDesc);
     1553    }
     1554    if (pDevIns->iInstance > 0)
     1555        MMR3HeapFree((void *)pszDesc);
    15461556    return rc;
    15471557}
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette