VirtualBox

Changeset 93650 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Feb 8, 2022 10:43:53 AM (3 years ago)
Author:
vboxsync
Message:

VMM/PGM,*: Split the physical access handler type registration into separate ring-0 and ring-3 steps, expanding the type to 64-bit. bugref:10094

Location:
trunk/src/VBox
Files:
1 added
27 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA.cpp

    r93115 r93650  
    62196219    pSVGAState = pThisCC->svga.pSvgaR3State;
    62206220
    6221     /* Register the write-protected GBO access handler type. */
    6222     rc = PDMDevHlpPGMHandlerPhysicalTypeRegister(pDevIns, PGMPHYSHANDLERKIND_WRITE,
    6223                                                  vmsvgaR3GboAccessHandler,
    6224                                                  NULL, NULL,
    6225                                                  NULL, NULL,
     6221    /* Register the write-protected GBO access handler type (no ring-0 callbacks here). */
     6222    rc = PDMDevHlpPGMHandlerPhysicalTypeRegister(pDevIns, PGMPHYSHANDLERKIND_WRITE, vmsvgaR3GboAccessHandler,
    62266223                                                 "VMSVGA GBO", &pSVGAState->hGboAccessHandlerType);
    62276224    AssertRCReturn(rc, rc);
     
    62736270# ifdef DEBUG_GMR_ACCESS
    62746271    /* Register the GMR access handler type. */
    6275     rc = PDMDevHlpPGMHandlerPhysicalTypeRegister(pDevIns, PGMPHYSHANDLERKIND_WRITE,
    6276                                                  vmsvgaR3GmrAccessHandler,
    6277                                                  NULL, NULL,
    6278                                                  NULL, NULL,
     6272    rc = PDMDevHlpPGMHandlerPhysicalTypeRegister(pDevIns, PGMPHYSHANDLERKIND_WRITE, vmsvgaR3GmrAccessHandler,
    62796273                                                 "VMSVGA GMR", &pThis->svga.hGmrAccessHandlerType);
    62806274    AssertRCReturn(rc, rc);
     
    62826276
    62836277# if defined(VMSVGA_USE_FIFO_ACCESS_HANDLER) || defined(DEBUG_FIFO_ACCESS)
    6284     /* Register the FIFO access handler type.  In addition to
    6285        debugging FIFO access, this is also used to facilitate
    6286        extended fifo thread sleeps. */
     6278    /* Register the FIFO access handler type.  In addition to debugging FIFO
     6279       access, this is also used to facilitate extended fifo thread sleeps. */
    62876280    rc = PDMDevHlpPGMHandlerPhysicalTypeRegister(pDevIns,
    62886281#  ifdef DEBUG_FIFO_ACCESS
     
    62926285#  endif
    62936286                                                 vmsvgaR3FifoAccessHandler,
    6294                                                  NULL, NULL,
    6295                                                  NULL, NULL,
    62966287                                                 "VMSVGA FIFO", &pThis->svga.hFifoAccessHandlerType);
    62976288    AssertRCReturn(rc, rc);
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA.h

    r93307 r93650  
    370370    /** FIFO debug access handler type handle. */
    371371    PGMPHYSHANDLERTYPE          hFifoAccessHandlerType;
    372 #elif defined(DEBUG_GMR_ACCESS)
    373     uint32_t                    uPadding1;
    374372#endif
    375373    /** Number of GMRs (VMSVGA_MAX_GMR_IDS, count of elements in VMSVGAR3STATE::paGMR array). */
  • trunk/src/VBox/Runtime/Makefile.kmk

    r93483 r93650  
    27892789        common/misc/term.cpp \
    27902790        common/path/RTPathFilename.cpp \
     2791        common/rand/rand.cpp \
     2792        common/rand/randadv.cpp \
     2793        common/rand/randparkmiller.cpp \
    27912794        common/string/strprintf-ellipsis.cpp \
    27922795        common/string/strprintf2-ellipsis.cpp \
     
    27942797        common/string/strncmp.cpp \
    27952798        common/string/strpbrk.cpp \
     2799        common/string/strtonum.cpp \
    27962800        common/string/RTStrCat.cpp \
    27972801        common/string/RTStrCatEx.cpp \
     
    28242828        generic/critsect-generic.cpp \
    28252829        generic/critsectrw-generic.cpp \
     2830        generic/RTRandAdvCreateSystemFaster-generic.cpp \
     2831        generic/RTRandAdvCreateSystemTruer-generic.cpp \
    28262832        \
    28272833        $(RuntimeNoCrt_SOURCES)
  • trunk/src/VBox/VMM/Makefile.kmk

    r93609 r93650  
    481481        VMMR0/HMVMXR0.cpp \
    482482        VMMR0/HMSVMR0.cpp \
     483        VMMR0/IEMR0.cpp \
    483484        VMMR0/IOMR0.cpp \
    484485        VMMR0/IOMR0IoPort.cpp \
  • trunk/src/VBox/VMM/VMMAll/IEMAllCImplVmxInstr.cpp.h

    r93635 r93650  
    68516851        if (!PGMHandlerPhysicalIsRegistered(pVCpu->CTX_SUFF(pVM), GCPhysApicAccess))
    68526852        {
    6853             PVMCC pVM       = pVCpu->CTX_SUFF(pVM);
    6854             PVMCPUCC pVCpu0 = VMCC_GET_CPU_0(pVM);
     6853            PVMCC pVM = pVCpu->CTX_SUFF(pVM);
    68556854            int rc = PGMHandlerPhysicalRegister(pVM, GCPhysApicAccess, GCPhysApicAccess + X86_PAGE_4K_SIZE - 1,
    6856                                                 pVCpu0->iem.s.hVmxApicAccessPage, 0 /*uUser*/, NULL /*pszDesc*/);
     6855                                                pVM->iem.s.hVmxApicAccessPage, 0 /*uUser*/, NULL /*pszDesc*/);
    68576856            if (RT_SUCCESS(rc))
    68586857            { /* likely */ }
  • trunk/src/VBox/VMM/VMMAll/IOMAllMmioNew.cpp

    r93635 r93650  
    728728 * @remarks The @a uUser argument is the MMIO handle.
    729729 */
    730 DECLEXPORT(VBOXSTRICTRC) iomMmioPfHandlerNew(PVMCC pVM, PVMCPUCC pVCpu, RTGCUINT uErrorCode, PCPUMCTXCORE pCtxCore,
    731                                              RTGCPTR pvFault, RTGCPHYS GCPhysFault, uint64_t uUser)
     730DECLCALLBACK(VBOXSTRICTRC) iomMmioPfHandlerNew(PVMCC pVM, PVMCPUCC pVCpu, RTGCUINT uErrorCode, PCPUMCTXCORE pCtxCore,
     731                                               RTGCPTR pvFault, RTGCPHYS GCPhysFault, uint64_t uUser)
    732732{
    733733    STAM_PROFILE_START(&pVM->iom.s.StatMmioPfHandler, Prf);
     
    797797 * @remarks The @a uUser argument is the MMIO handle.
    798798 */
    799 PGM_ALL_CB2_DECL(VBOXSTRICTRC) iomMmioHandlerNew(PVMCC pVM, PVMCPUCC pVCpu, RTGCPHYS GCPhysFault, void *pvPhys, void *pvBuf,
    800                                                  size_t cbBuf, PGMACCESSTYPE enmAccessType, PGMACCESSORIGIN enmOrigin, uint64_t uUser)
     799DECLCALLBACK(VBOXSTRICTRC) iomMmioHandlerNew(PVMCC pVM, PVMCPUCC pVCpu, RTGCPHYS GCPhysFault, void *pvPhys, void *pvBuf,
     800                                             size_t cbBuf, PGMACCESSTYPE enmAccessType, PGMACCESSORIGIN enmOrigin, uint64_t uUser)
    801801{
    802802    STAM_PROFILE_START(UnusedMacroArg, Prf);
  • trunk/src/VBox/VMM/VMMAll/MMAllHyper.cpp

    r93592 r93650  
    12601260
    12611261/**
    1262  * Converts a context neutral heap offset into a pointer.
    1263  *
    1264  * @returns Pointer to hyper heap data.
    1265  * @param   pVM         The cross context VM structure.
    1266  * @param   offHeap     The hyper heap offset.
    1267  */
    1268 VMMDECL(void *) MMHyperHeapOffsetToPtr(PVM pVM, uint32_t offHeap)
    1269 {
    1270     Assert(offHeap - MMYPERHEAP_HDR_SIZE <= pVM->mm.s.CTX_SUFF(pHyperHeap)->cbHeap);
    1271     return (uint8_t *)pVM->mm.s.CTX_SUFF(pHyperHeap) + offHeap;
    1272 }
    1273 
    1274 
    1275 /**
    1276  * Converts a context specific heap pointer into a neutral heap offset.
    1277  *
    1278  * @returns Heap offset.
    1279  * @param   pVM         The cross context VM structure.
    1280  * @param   pv          Pointer to the heap data.
    1281  */
    1282 VMMDECL(uint32_t) MMHyperHeapPtrToOffset(PVM pVM, void *pv)
    1283 {
    1284     size_t offHeap = (uint8_t *)pv - (uint8_t *)pVM->mm.s.CTX_SUFF(pHyperHeap);
    1285     Assert(offHeap - MMYPERHEAP_HDR_SIZE <= pVM->mm.s.CTX_SUFF(pHyperHeap)->cbHeap);
    1286     return (uint32_t)offHeap;
    1287 }
    1288 
    1289 
    1290 /**
    12911262 * Checks if an address is within the hypervisor memory area.
    12921263 *
  • trunk/src/VBox/VMM/VMMAll/PGMAllBth.h

    r93635 r93650  
    243243        if (pCur)
    244244        {
    245             PPGMPHYSHANDLERTYPEINT pCurType = PGMPHYSHANDLER_GET_TYPE(pVM, pCur);
     245            PCPGMPHYSHANDLERTYPEINT const pCurType = PGMPHYSHANDLER_GET_TYPE(pVM, pCur);
    246246
    247247#  ifdef PGM_SYNC_N_PAGES
     
    312312            }
    313313
    314             if (pCurType->CTX_SUFF(pfnPfHandler))
     314            if (pCurType->pfnPfHandler)
    315315            {
    316316                STAM_PROFILE_START(&pCur->Stat, h);
     
    318318                if (pCurType->fKeepPgmLock)
    319319                {
    320                     rcStrict = pCurType->CTX_SUFF(pfnPfHandler)(pVM, pVCpu, uErr, pRegFrame, pvFault, GCPhysFault,
    321                                                                 !pCurType->fRing0DevInsIdx ? pCur->uUser
    322                                                                 : (uintptr_t)PDMDeviceRing0IdxToInstance(pVM, pCur->uUser));
     320                    rcStrict = pCurType->pfnPfHandler(pVM, pVCpu, uErr, pRegFrame, pvFault, GCPhysFault,
     321                                                      !pCurType->fRing0DevInsIdx ? pCur->uUser
     322                                                      : (uintptr_t)PDMDeviceRing0IdxToInstance(pVM, pCur->uUser));
    323323
    324324#  ifdef VBOX_WITH_STATISTICS
     
    335335                    *pfLockTaken = false;
    336336
    337                     rcStrict = pCurType->CTX_SUFF(pfnPfHandler)(pVM, pVCpu, uErr, pRegFrame, pvFault, GCPhysFault, uUser);
     337                    rcStrict = pCurType->pfnPfHandler(pVM, pVCpu, uErr, pRegFrame, pvFault, GCPhysFault, uUser);
    338338
    339339#  ifdef VBOX_WITH_STATISTICS
  • trunk/src/VBox/VMM/VMMAll/PGMAllHandler.cpp

    r93635 r93650  
    4747
    4848/*********************************************************************************************************************************
     49*   Global Variables                                                                                                             *
     50*********************************************************************************************************************************/
     51/** Dummy physical access handler type record. */
     52CTX_SUFF(PGMPHYSHANDLERTYPEINT) const g_pgmHandlerPhysicalDummyType =
     53{
     54    /* .hType = */              UINT64_C(0x93b7557e1937aaff),
     55    /* .enmKind = */            PGMPHYSHANDLERKIND_INVALID,
     56    /* .uState = */             PGM_PAGE_HNDL_PHYS_STATE_ALL,
     57    /* .fKeepPgmLock = */       true,
     58    /* .fRing0DevInsIdx = */    false,
     59#ifdef IN_RING0
     60    /* .afPadding = */          {false},
     61    /* .pfnHandler = */         pgmR0HandlerPhysicalHandlerToRing3,
     62    /* .pfnPfHandler = */       pgmR0HandlerPhysicalPfHandlerToRing3,
     63#elif defined(IN_RING3)
     64    /* .fRing0Enabled = */      false,
     65    /* .pfnHandler = */         pgmR3HandlerPhysicalHandlerInvalid,
     66#else
     67# error "unsupported context"
     68#endif
     69    /* .pszDesc = */            "dummy"
     70};
     71
     72
     73/*********************************************************************************************************************************
    4974*   Internal Functions                                                                                                           *
    5075*********************************************************************************************************************************/
     
    5580
    5681
    57 /**
    58  * Internal worker for releasing a physical handler type registration reference.
    59  *
    60  * @returns New reference count. UINT32_MAX if invalid input (asserted).
    61  * @param   pVM         The cross context VM structure.
    62  * @param   pType       Pointer to the type registration.
    63  */
    64 DECLINLINE(uint32_t) pgmHandlerPhysicalTypeRelease(PVMCC pVM, PPGMPHYSHANDLERTYPEINT pType)
    65 {
    66     AssertMsgReturn(pType->u32Magic == PGMPHYSHANDLERTYPEINT_MAGIC, ("%#x\n", pType->u32Magic), UINT32_MAX);
    67     uint32_t cRefs = ASMAtomicDecU32(&pType->cRefs);
    68     if (cRefs == 0)
    69     {
    70         PGM_LOCK_VOID(pVM);
    71         pType->u32Magic = PGMPHYSHANDLERTYPEINT_MAGIC_DEAD;
    72         RTListOff32NodeRemove(&pType->ListNode);
    73         PGM_UNLOCK(pVM);
    74         MMHyperFree(pVM, pType);
    75     }
    76     return cRefs;
    77 }
    78 
    79 
    80 /**
    81  * Internal worker for retaining a physical handler type registration reference.
    82  *
    83  * @returns New reference count. UINT32_MAX if invalid input (asserted).
    84  * @param   pVM         The cross context VM structure.
    85  * @param   pType       Pointer to the type registration.
    86  */
    87 DECLINLINE(uint32_t) pgmHandlerPhysicalTypeRetain(PVM pVM, PPGMPHYSHANDLERTYPEINT pType)
    88 {
    89     NOREF(pVM);
    90     AssertMsgReturn(pType->u32Magic == PGMPHYSHANDLERTYPEINT_MAGIC, ("%#x\n", pType->u32Magic), UINT32_MAX);
    91     uint32_t cRefs = ASMAtomicIncU32(&pType->cRefs);
    92     Assert(cRefs < _1M && cRefs > 0);
    93     return cRefs;
    94 }
    95 
    96 
    97 /**
    98  * Releases a reference to a physical handler type registration.
    99  *
    100  * @returns New reference count. UINT32_MAX if invalid input (asserted).
    101  * @param   pVM         The cross context VM structure.
    102  * @param   hType       The type regiration handle.
    103  */
    104 VMMDECL(uint32_t) PGMHandlerPhysicalTypeRelease(PVMCC pVM, PGMPHYSHANDLERTYPE hType)
    105 {
    106     if (hType != NIL_PGMPHYSHANDLERTYPE)
    107         return pgmHandlerPhysicalTypeRelease(pVM, PGMPHYSHANDLERTYPEINT_FROM_HANDLE(pVM, hType));
    108     return 0;
    109 }
    110 
    111 
    112 /**
    113  * Retains a reference to a physical handler type registration.
    114  *
    115  * @returns New reference count. UINT32_MAX if invalid input (asserted).
    116  * @param   pVM         The cross context VM structure.
    117  * @param   hType       The type regiration handle.
    118  */
    119 VMMDECL(uint32_t) PGMHandlerPhysicalTypeRetain(PVM pVM, PGMPHYSHANDLERTYPE hType)
    120 {
    121     return pgmHandlerPhysicalTypeRetain(pVM, PGMPHYSHANDLERTYPEINT_FROM_HANDLE(pVM, hType));
    122 }
     82#ifndef IN_RING3
     83
     84/**
     85 * @callback_method_impl{FNPGMPHYSHANDLER,
     86 *      Dummy for forcing ring-3 handling of the access.}
     87 */
     88DECLCALLBACK(VBOXSTRICTRC)
     89pgmR0HandlerPhysicalHandlerToRing3(PVMCC pVM, PVMCPUCC pVCpu, RTGCPHYS GCPhys, void *pvPhys, void *pvBuf, size_t cbBuf,
     90                                   PGMACCESSTYPE enmAccessType, PGMACCESSORIGIN enmOrigin, uint64_t uUser)
     91{
     92    RT_NOREF(pVM, pVCpu, GCPhys, pvPhys, pvBuf, cbBuf, enmAccessType, enmOrigin, uUser);
     93    return VINF_EM_RAW_EMULATE_INSTR;
     94}
     95
     96
     97/**
     98 * @callback_method_impl{FNPGMRZPHYSPFHANDLER,
     99 *      Dummy for forcing ring-3 handling of the access.}
     100 */
     101DECLCALLBACK(VBOXSTRICTRC)
     102pgmR0HandlerPhysicalPfHandlerToRing3(PVMCC pVM, PVMCPUCC pVCpu, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame,
     103                                     RTGCPTR pvFault, RTGCPHYS GCPhysFault, uint64_t uUser)
     104{
     105    RT_NOREF(pVM, pVCpu, uErrorCode, pRegFrame, pvFault, GCPhysFault, uUser);
     106    return VINF_EM_RAW_EMULATE_INSTR;
     107}
     108
     109#endif /* !IN_RING3 */
    123110
    124111
     
    145132                               R3PTRTYPE(const char *) pszDesc, PPGMPHYSHANDLER *ppPhysHandler)
    146133{
    147     PPGMPHYSHANDLERTYPEINT pType = PGMPHYSHANDLERTYPEINT_FROM_HANDLE(pVM, hType);
     134    /*
     135     * Validate input.
     136     */
     137    PCPGMPHYSHANDLERTYPEINT const pType = pgmHandlerPhysicalTypeHandleToPtr(pVM, hType);
     138    AssertReturn(pType, VERR_INVALID_HANDLE);
     139    AssertReturn(pType->enmKind > PGMPHYSHANDLERKIND_INVALID && pType->enmKind < PGMPHYSHANDLERKIND_END, VERR_INVALID_HANDLE);
     140    AssertPtr(ppPhysHandler);
     141
    148142    Log(("pgmHandlerPhysicalExCreate: uUser=%#RX64 hType=%#x (%d, %s) pszDesc=%RHv:%s\n",
    149          uUser, hType, pType->enmKind, R3STRING(pType->pszDesc), pszDesc, R3STRING(pszDesc)));
    150 
    151     /*
    152      * Validate input.
    153      */
    154     AssertPtr(ppPhysHandler);
    155     AssertReturn(pType->u32Magic == PGMPHYSHANDLERTYPEINT_MAGIC, VERR_INVALID_HANDLE);
     143         uUser, hType, pType->enmKind, pType->pszDesc, pszDesc, R3STRING(pszDesc)));
    156144
    157145    /*
     
    169157        pNew->uUser         = uUser;
    170158        pNew->hType         = hType;
    171         pNew->pszDesc       = pszDesc != NIL_RTR3PTR ? pszDesc : pType->pszDesc;
    172         pgmHandlerPhysicalTypeRetain(pVM, pType);
     159        pNew->pszDesc       = pszDesc != NIL_RTR3PTR ? pszDesc
     160#ifdef IN_RING3
     161                            : pType->pszDesc;
     162#else
     163                            : pVM->pgm.s.aPhysHandlerTypes[hType].pszDesc;
     164#endif
    173165        *ppPhysHandler = pNew;
    174166        return VINF_SUCCESS;
     
    213205     * Validate input.
    214206     */
     207    PGMPHYSHANDLERTYPE const      hType = pPhysHandler->hType;
     208    PCPGMPHYSHANDLERTYPEINT const pType = pgmHandlerPhysicalTypeHandleToPtr(pVM, hType);
     209    AssertReturn(pType, VERR_INVALID_HANDLE);
     210    AssertReturn(pType->enmKind > PGMPHYSHANDLERKIND_INVALID && pType->enmKind < PGMPHYSHANDLERKIND_END, VERR_INVALID_HANDLE);
     211
    215212    AssertPtr(pPhysHandler);
    216     PPGMPHYSHANDLERTYPEINT pType = PGMPHYSHANDLERTYPEINT_FROM_HANDLE(pVM, pPhysHandler->hType);
    217     Assert(pType->u32Magic == PGMPHYSHANDLERTYPEINT_MAGIC);
    218     Log(("pgmHandlerPhysicalExRegister: GCPhys=%RGp GCPhysLast=%RGp hType=%#x (%d, %s) pszDesc=%RHv:%s\n",
    219          GCPhys, GCPhysLast, pPhysHandler->hType, pType->enmKind, R3STRING(pType->pszDesc), pPhysHandler->pszDesc, R3STRING(pPhysHandler->pszDesc)));
     213
     214    Log(("pgmHandlerPhysicalExRegister: GCPhys=%RGp GCPhysLast=%RGp hType=%#x (%d, %s) pszDesc=%RHv:%s\n", GCPhys, GCPhysLast,
     215         hType, pType->enmKind, pType->pszDesc, pPhysHandler->pszDesc, R3STRING(pPhysHandler->pszDesc)));
    220216    AssertReturn(pPhysHandler->Core.Key == NIL_RTGCPHYS, VERR_WRONG_ORDER);
    221217
     
    313309{
    314310#ifdef LOG_ENABLED
    315     PPGMPHYSHANDLERTYPEINT pType = PGMPHYSHANDLERTYPEINT_FROM_HANDLE(pVM, hType);
     311    PCPGMPHYSHANDLERTYPEINT pType = pgmHandlerPhysicalTypeHandleToPtr(pVM, hType);
    316312    Log(("PGMHandlerPhysicalRegister: GCPhys=%RGp GCPhysLast=%RGp uUser=%#RX64 hType=%#x (%d, %s) pszDesc=%RHv:%s\n",
    317313         GCPhys, GCPhysLast, uUser, hType, pType->enmKind, R3STRING(pType->pszDesc), pszDesc, R3STRING(pszDesc)));
     
    353349    bool                    fFlushTLBs = false;
    354350    int                     rc         = VINF_SUCCESS;
    355     PPGMPHYSHANDLERTYPEINT  pCurType   = PGMPHYSHANDLER_GET_TYPE(pVM, pCur);
     351    PCPGMPHYSHANDLERTYPEINT pCurType   = PGMPHYSHANDLER_GET_TYPE_NO_NULL(pVM, pCur);
    356352    const unsigned          uState     = pCurType->uState;
    357353    uint32_t                cPages     = pCur->cPages;
     
    483479        AssertPtr(pHandler);
    484480        AssertReturn(pHandler->Core.Key == NIL_RTGCPHYS, VERR_WRONG_ORDER);
    485         PGMHandlerPhysicalTypeRelease(pVM, pHandler->hType);
    486481        MMHyperFree(pVM, pHandler);
    487482    }
     
    539534{
    540535#ifdef VBOX_WITH_NATIVE_NEM
    541     PPGMPHYSHANDLERTYPEINT  pCurType    = PGMPHYSHANDLER_GET_TYPE(pVM, pCur);
     536    PCPGMPHYSHANDLERTYPEINT pCurType    = PGMPHYSHANDLER_GET_TYPE_NO_NULL(pVM, pCur);
    542537    RTGCPHYS                GCPhysStart = pCur->Core.Key;
    543538    RTGCPHYS                GCPhysLast  = pCur->Core.KeyLast;
     
    623618            || ((fAbove ? pCur->Core.Key : pCur->Core.KeyLast) >> GUEST_PAGE_SHIFT) != (GCPhys >> GUEST_PAGE_SHIFT))
    624619            break;
    625         PPGMPHYSHANDLERTYPEINT pCurType = PGMPHYSHANDLER_GET_TYPE(pVM, pCur);
     620        PCPGMPHYSHANDLERTYPEINT pCurType = PGMPHYSHANDLER_GET_TYPE_NO_NULL(pVM, pCur);
    626621        uState = RT_MAX(uState, pCurType->uState);
    627622
     
    636631
    637632    /*
    638      * Update if we found something that is a higher priority
    639      * state than the current.
     633     * Update if we found something that is a higher priority state than the current.
    640634     */
    641635    if (uState != PGM_PAGE_HNDL_PHYS_STATE_NONE)
     
    786780            }
    787781#ifdef VBOX_STRICT
    788             PPGMPHYSHANDLERTYPEINT pCurType = PGMPHYSHANDLER_GET_TYPE(pVM, pCur);
    789             AssertMsg(pCurType->enmKind != PGMPHYSHANDLERKIND_MMIO || PGM_PAGE_IS_MMIO(pPage), ("%RGp %R[pgmpage]\n", GCPhys, pPage));
     782            PCPGMPHYSHANDLERTYPEINT const pCurType = PGMPHYSHANDLER_GET_TYPE(pVM, pCur);
     783            AssertMsg(pCurType && (pCurType->enmKind != PGMPHYSHANDLERKIND_MMIO || PGM_PAGE_IS_MMIO(pPage)),
     784                      ("%RGp %R[pgmpage]\n", GCPhys, pPage));
    790785#endif
    791786            PGM_PAGE_SET_HNDL_PHYS_STATE(pPage, PGM_PAGE_HNDL_PHYS_STATE_NONE);
     
    855850         */
    856851        pgmHandlerPhysicalResetRamFlags(pVM, pCur);
    857         PPGMPHYSHANDLERTYPEINT const pCurType      = PGMPHYSHANDLER_GET_TYPE(pVM, pCur);
     852        PCPGMPHYSHANDLERTYPEINT const pCurType     = PGMPHYSHANDLER_GET_TYPE_NO_NULL(pVM, pCur);
     853        @todo pCurType validation
    858854        bool const                   fRestoreAsRAM = pCurType->pfnHandlerR3 /** @todo this isn't entirely correct. */
    859855                                                  && pCurType->enmKind != PGMPHYSHANDLERKIND_MMIO;
     
    11411137         * Validate kind.
    11421138         */
    1143         PPGMPHYSHANDLERTYPEINT pCurType = PGMPHYSHANDLER_GET_TYPE(pVM, pCur);
     1139        PCPGMPHYSHANDLERTYPEINT pCurType = PGMPHYSHANDLER_GET_TYPE_NO_NULL(pVM, pCur);
    11441140        switch (pCurType->enmKind)
    11451141        {
     
    12051201             */
    12061202            default:
    1207                 AssertMsgFailed(("Invalid type %d! Corruption!\n",  pCurType->enmKind));
     1203                AssertMsgFailed(("Invalid type %d/%#x! Corruption!\n",  pCurType->enmKind, pCur->hType));
    12081204                rc = VERR_PGM_PHYS_HANDLER_IPE;
    12091205                break;
     
    12491245         * Validate kind.
    12501246         */
    1251         PPGMPHYSHANDLERTYPEINT pCurType = PGMPHYSHANDLER_GET_TYPE(pVM, pCur);
    1252         if (pCurType->enmKind == PGMPHYSHANDLERKIND_WRITE)
     1247        PCPGMPHYSHANDLERTYPEINT pCurType = PGMPHYSHANDLER_GET_TYPE(pVM, pCur);
     1248        if (   pCurType
     1249            && pCurType->enmKind == PGMPHYSHANDLERKIND_WRITE)
    12531250        {
    12541251            STAM_COUNTER_INC(&pVM->pgm.s.Stats.CTX_MID_Z(Stat,PhysHandlerReset));
     
    13161313    if (RT_LIKELY(pCur))
    13171314    {
    1318         if (RT_LIKELY(    GCPhysPage >= pCur->Core.Key
    1319                       &&  GCPhysPage <= pCur->Core.KeyLast))
     1315        if (RT_LIKELY(   GCPhysPage >= pCur->Core.Key
     1316                      && GCPhysPage <= pCur->Core.KeyLast))
    13201317        {
    13211318            Assert(!(pCur->Core.Key & GUEST_PAGE_OFFSET_MASK));
    13221319            Assert((pCur->Core.KeyLast & GUEST_PAGE_OFFSET_MASK) == GUEST_PAGE_OFFSET_MASK);
    13231320
    1324             PPGMPHYSHANDLERTYPEINT pCurType = PGMPHYSHANDLER_GET_TYPE(pVM, pCur);
    1325             AssertReturnStmt(   pCurType->enmKind == PGMPHYSHANDLERKIND_WRITE
    1326                              || pCurType->enmKind == PGMPHYSHANDLERKIND_ALL,
     1321            PCPGMPHYSHANDLERTYPEINT const pCurType = PGMPHYSHANDLER_GET_TYPE(pVM, pCur);
     1322            AssertReturnStmt(   pCurType
     1323                             && (   pCurType->enmKind == PGMPHYSHANDLERKIND_WRITE
     1324                                 || pCurType->enmKind == PGMPHYSHANDLERKIND_ALL),
    13271325                             PGM_UNLOCK(pVM), VERR_ACCESS_DENIED);
    13281326
     
    14881486                      && GCPhysPage <= pCur->Core.KeyLast))
    14891487        {
    1490             PPGMPHYSHANDLERTYPEINT pCurType = PGMPHYSHANDLER_GET_TYPE(pVM, pCur);
     1488            PCPGMPHYSHANDLERTYPEINT const pCurType = PGMPHYSHANDLER_GET_TYPE_NO_NULL(pVM, pCur);
    14911489            AssertReturnStmt(pCurType->enmKind == PGMPHYSHANDLERKIND_MMIO, PGM_UNLOCK(pVM), VERR_ACCESS_DENIED);
    14921490            AssertReturnStmt(!(pCur->Core.Key & GUEST_PAGE_OFFSET_MASK), PGM_UNLOCK(pVM), VERR_INVALID_PARAMETER);
     
    16171615                      &&  GCPhysPage <= pCur->Core.KeyLast))
    16181616        {
    1619             PPGMPHYSHANDLERTYPEINT pCurType = PGMPHYSHANDLER_GET_TYPE(pVM, pCur);
     1617            PCPGMPHYSHANDLERTYPEINT const pCurType = PGMPHYSHANDLER_GET_TYPE_NO_NULL(pVM, pCur);
    16201618            AssertReturnStmt(pCurType->enmKind == PGMPHYSHANDLERKIND_MMIO, PGM_UNLOCK(pVM), VERR_ACCESS_DENIED);
    16211619            AssertReturnStmt(!(pCur->Core.Key & GUEST_PAGE_OFFSET_MASK), PGM_UNLOCK(pVM), VERR_INVALID_PARAMETER);
     
    17061704#ifdef VBOX_STRICT
    17071705        Assert(GCPhys >= pCur->Core.Key && GCPhys <= pCur->Core.KeyLast);
    1708         PPGMPHYSHANDLERTYPEINT pCurType = PGMPHYSHANDLER_GET_TYPE(pVM, pCur);
     1706        PCPGMPHYSHANDLERTYPEINT const pCurType = PGMPHYSHANDLER_GET_TYPE_NO_NULL(pVM, pCur);
    17091707        Assert(   pCurType->enmKind == PGMPHYSHANDLERKIND_WRITE
    17101708               || pCurType->enmKind == PGMPHYSHANDLERKIND_ALL
     
    17401738        return true;
    17411739    }
    1742     PPGMPHYSHANDLERTYPEINT pCurType = PGMPHYSHANDLER_GET_TYPE(pVM, pCur);
     1740
     1741    /* Only whole pages can be disabled. */
     1742    Assert(   pCur->Core.Key     <= (GCPhys & ~(RTGCPHYS)GUEST_PAGE_OFFSET_MASK)
     1743           && pCur->Core.KeyLast >= (GCPhys | GUEST_PAGE_OFFSET_MASK));
     1744
     1745    PCPGMPHYSHANDLERTYPEINT const pCurType = PGMPHYSHANDLER_GET_TYPE_NO_NULL(pVM, pCur);
    17431746    Assert(   pCurType->enmKind == PGMPHYSHANDLERKIND_WRITE
    17441747           || pCurType->enmKind == PGMPHYSHANDLERKIND_ALL
    17451748           || pCurType->enmKind == PGMPHYSHANDLERKIND_MMIO); /* sanity */
    1746     /* Only whole pages can be disabled. */
    1747     Assert(   pCur->Core.Key     <= (GCPhys & ~(RTGCPHYS)GUEST_PAGE_OFFSET_MASK)
    1748            && pCur->Core.KeyLast >= (GCPhys | GUEST_PAGE_OFFSET_MASK));
    1749 
    1750     bool bRet = pCurType->enmKind != PGMPHYSHANDLERKIND_WRITE;
     1749    bool const fRet = pCurType->enmKind != PGMPHYSHANDLERKIND_WRITE;
    17511750    PGM_UNLOCK(pVM);
    1752     return bRet;
     1751    return fRet;
    17531752}
    17541753
     
    18181817                    if (pPhys)
    18191818                    {
    1820                         PPGMPHYSHANDLERTYPEINT pPhysType = (PPGMPHYSHANDLERTYPEINT)MMHyperHeapOffsetToPtr(pVM, pPhys->hType);
     1819                        PCPGMPHYSHANDLERTYPEINT pPhysType = pgmHandlerPhysicalTypeHandleToPtr(pVM, pPhys->hType);
    18211820                        unsigned uState = pPhysType->uState;
    18221821
     
    18291828                                ||  pPhys2->Core.Key > (State.GCPhys | GUEST_PAGE_OFFSET_MASK))
    18301829                                break;
    1831                             PPGMPHYSHANDLERTYPEINT pPhysType2 = (PPGMPHYSHANDLERTYPEINT)MMHyperHeapOffsetToPtr(pVM, pPhys2->hType);
     1830                            PCPGMPHYSHANDLERTYPEINT pPhysType2 = pgmHandlerPhysicalTypeHandleToPtr(pVM, pPhys2->hType);
    18321831                            uState = RT_MAX(uState, pPhysType2->uState);
    18331832                            pPhys = pPhys2;
  • trunk/src/VBox/VMM/VMMAll/PGMAllPhys.cpp

    r93635 r93650  
    114114
    115115
    116 #ifndef IN_RING3
    117 
    118 /**
    119  * @callback_method_impl{FNPGMPHYSHANDLER,
    120  *      Dummy for forcing ring-3 handling of the access.}
    121  */
    122 DECLEXPORT(VBOXSTRICTRC)
    123 pgmPhysHandlerRedirectToHC(PVMCC pVM, PVMCPUCC pVCpu, RTGCPHYS GCPhys, void *pvPhys, void *pvBuf, size_t cbBuf,
    124                            PGMACCESSTYPE enmAccessType, PGMACCESSORIGIN enmOrigin, uint64_t uUser)
    125 {
    126     RT_NOREF(pVM, pVCpu, GCPhys, pvPhys, pvBuf, cbBuf, enmAccessType, enmOrigin, uUser);
    127     return VINF_EM_RAW_EMULATE_INSTR;
    128 }
    129 
    130 
    131 /**
    132  * @callback_method_impl{FNPGMRZPHYSPFHANDLER,
    133  *      Dummy for forcing ring-3 handling of the access.}
    134  */
    135 VMMDECL(VBOXSTRICTRC) pgmPhysPfHandlerRedirectToHC(PVMCC pVM, PVMCPUCC pVCpu, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame,
    136                                                    RTGCPTR pvFault, RTGCPHYS GCPhysFault, uint64_t uUser)
    137 {
    138     RT_NOREF(pVM, pVCpu, uErrorCode, pRegFrame, pvFault, GCPhysFault, uUser);
    139     return VINF_EM_RAW_EMULATE_INSTR;
    140 }
    141 
    142 #endif /* !IN_RING3 */
    143 
    144116/**
    145117 * Looks up a ROM range by its PGMROMRANGE::GCPhys value.
     
    161133 * @remarks The @a uUser argument is the PGMROMRANGE::GCPhys value.
    162134 */
    163 DECLEXPORT(VBOXSTRICTRC) pgmPhysRomWritePfHandler(PVMCC pVM, PVMCPUCC pVCpu, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame,
    164                                                   RTGCPTR pvFault, RTGCPHYS GCPhysFault, uint64_t uUser)
     135DECLCALLBACK(VBOXSTRICTRC) pgmPhysRomWritePfHandler(PVMCC pVM, PVMCPUCC pVCpu, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame,
     136                                                    RTGCPTR pvFault, RTGCPHYS GCPhysFault, uint64_t uUser)
    165137
    166138{
     
    233205 * @remarks The @a uUser argument is the PGMROMRANGE::GCPhys value.
    234206 */
    235 PGM_ALL_CB2_DECL(VBOXSTRICTRC)
     207DECLCALLBACK(VBOXSTRICTRC)
    236208pgmPhysRomWriteHandler(PVMCC pVM, PVMCPUCC pVCpu, RTGCPHYS GCPhys, void *pvPhys, void *pvBuf, size_t cbBuf,
    237209                       PGMACCESSTYPE enmAccessType, PGMACCESSORIGIN enmOrigin, uint64_t uUser)
     
    396368 * @remarks The @a uUser is the MMIO2 index.
    397369 */
    398 DECLEXPORT(VBOXSTRICTRC) pgmPhysMmio2WritePfHandler(PVMCC pVM, PVMCPUCC pVCpu, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame,
    399                                                     RTGCPTR pvFault, RTGCPHYS GCPhysFault, uint64_t uUser)
     370DECLCALLBACK(VBOXSTRICTRC) pgmPhysMmio2WritePfHandler(PVMCC pVM, PVMCPUCC pVCpu, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame,
     371                                                      RTGCPTR pvFault, RTGCPHYS GCPhysFault, uint64_t uUser)
    400372{
    401373    RT_NOREF(pVCpu, uErrorCode, pRegFrame);
     
    417389 * @remarks The @a uUser is the MMIO2 index.
    418390 */
    419 PGM_ALL_CB2_DECL(VBOXSTRICTRC)
     391DECLCALLBACK(VBOXSTRICTRC)
    420392pgmPhysMmio2WriteHandler(PVMCC pVM, PVMCPUCC pVCpu, RTGCPHYS GCPhys, void *pvPhys, void *pvBuf, size_t cbBuf,
    421393                         PGMACCESSTYPE enmAccessType, PGMACCESSORIGIN enmOrigin, uint64_t uUser)
     
    24362408    {
    24372409        PPGMPHYSHANDLER pCur = pgmHandlerPhysicalLookup(pVM, GCPhys);
    2438         AssertReleaseMsg(pCur, ("GCPhys=%RGp cb=%#x\n", GCPhys, cb));
    2439         Assert(GCPhys >= pCur->Core.Key && GCPhys <= pCur->Core.KeyLast);
    2440         Assert((pCur->Core.Key     & GUEST_PAGE_OFFSET_MASK) == 0);
    2441         Assert((pCur->Core.KeyLast & GUEST_PAGE_OFFSET_MASK) == GUEST_PAGE_OFFSET_MASK);
     2410        if (pCur)
     2411        {
     2412            Assert(pCur && GCPhys >= pCur->Core.Key && GCPhys <= pCur->Core.KeyLast);
     2413            Assert((pCur->Core.Key     & GUEST_PAGE_OFFSET_MASK) == 0);
     2414            Assert((pCur->Core.KeyLast & GUEST_PAGE_OFFSET_MASK) == GUEST_PAGE_OFFSET_MASK);
    24422415#ifndef IN_RING3
    2443         if (enmOrigin != PGMACCESSORIGIN_IEM)
    2444         {
    2445             /* Cannot reliably handle informational status codes in this context */
    2446             pgmPhysReleaseInternalPageMappingLock(pVM, &PgMpLck);
    2447             return VERR_PGM_PHYS_WR_HIT_HANDLER;
    2448         }
     2416            if (enmOrigin != PGMACCESSORIGIN_IEM)
     2417            {
     2418                /* Cannot reliably handle informational status codes in this context */
     2419                pgmPhysReleaseInternalPageMappingLock(pVM, &PgMpLck);
     2420                return VERR_PGM_PHYS_WR_HIT_HANDLER;
     2421            }
    24492422#endif
    2450         PPGMPHYSHANDLERTYPEINT const pCurType   = PGMPHYSHANDLER_GET_TYPE(pVM, pCur);
    2451         PFNPGMPHYSHANDLER const      pfnHandler = pCurType->CTX_SUFF(pfnHandler); Assert(pfnHandler);
    2452         uint64_t const               uUser      = !pCurType->fRing0DevInsIdx ? pCur->uUser
    2453                                                 : (uintptr_t)PDMDeviceRing0IdxToInstance(pVM, pCur->uUser);
    2454 
    2455         Log5(("pgmPhysReadHandler: GCPhys=%RGp cb=%#x pPage=%R[pgmpage] phys %s\n", GCPhys, cb, pPage, R3STRING(pCur->pszDesc) ));
    2456         STAM_PROFILE_START(&pCur->Stat, h);
    2457         PGM_LOCK_ASSERT_OWNER(pVM);
    2458 
    2459         /* Release the PGM lock as MMIO handlers take the IOM lock. (deadlock prevention) */
    2460         PGM_UNLOCK(pVM);
    2461         rcStrict = pfnHandler(pVM, pVCpu, GCPhys, (void *)pvSrc, pvBuf, cb, PGMACCESSTYPE_READ, enmOrigin, uUser);
    2462         PGM_LOCK_VOID(pVM);
     2423            PCPGMPHYSHANDLERTYPEINT const pCurType   = PGMPHYSHANDLER_GET_TYPE_NO_NULL(pVM, pCur);
     2424            PFNPGMPHYSHANDLER const       pfnHandler = pCurType->pfnHandler; Assert(pfnHandler);
     2425            uint64_t const                uUser      = !pCurType->fRing0DevInsIdx ? pCur->uUser
     2426                                                     : (uintptr_t)PDMDeviceRing0IdxToInstance(pVM, pCur->uUser);
     2427
     2428            Log5(("pgmPhysReadHandler: GCPhys=%RGp cb=%#x pPage=%R[pgmpage] phys %s\n", GCPhys, cb, pPage, R3STRING(pCur->pszDesc) ));
     2429            STAM_PROFILE_START(&pCur->Stat, h);
     2430            PGM_LOCK_ASSERT_OWNER(pVM);
     2431
     2432            /* Release the PGM lock as MMIO handlers take the IOM lock. (deadlock prevention) */
     2433            PGM_UNLOCK(pVM);
     2434            rcStrict = pfnHandler(pVM, pVCpu, GCPhys, (void *)pvSrc, pvBuf, cb, PGMACCESSTYPE_READ, enmOrigin, uUser);
     2435            PGM_LOCK_VOID(pVM);
    24632436
    24642437#ifdef VBOX_WITH_STATISTICS
    2465         pCur = pgmHandlerPhysicalLookup(pVM, GCPhys);
    2466         if (pCur)
    2467             STAM_PROFILE_STOP(&pCur->Stat, h);
     2438            pCur = pgmHandlerPhysicalLookup(pVM, GCPhys);
     2439            if (pCur)
     2440                STAM_PROFILE_STOP(&pCur->Stat, h);
    24682441#else
    2469         pCur = NULL; /* might not be valid anymore. */
     2442            pCur = NULL; /* might not be valid anymore. */
    24702443#endif
    2471         AssertLogRelMsg(PGM_HANDLER_PHYS_IS_VALID_STATUS(rcStrict, false),
    2472                         ("rcStrict=%Rrc GCPhys=%RGp\n", VBOXSTRICTRC_VAL(rcStrict), GCPhys));
    2473         if (   rcStrict != VINF_PGM_HANDLER_DO_DEFAULT
    2474             && !PGM_PHYS_RW_IS_SUCCESS(rcStrict))
    2475         {
    2476             pgmPhysReleaseInternalPageMappingLock(pVM, &PgMpLck);
    2477             return rcStrict;
    2478         }
     2444            AssertLogRelMsg(PGM_HANDLER_PHYS_IS_VALID_STATUS(rcStrict, false),
     2445                            ("rcStrict=%Rrc GCPhys=%RGp\n", VBOXSTRICTRC_VAL(rcStrict), GCPhys));
     2446            if (   rcStrict != VINF_PGM_HANDLER_DO_DEFAULT
     2447                && !PGM_PHYS_RW_IS_SUCCESS(rcStrict))
     2448            {
     2449                pgmPhysReleaseInternalPageMappingLock(pVM, &PgMpLck);
     2450                return rcStrict;
     2451            }
     2452        }
     2453        else
     2454            AssertLogRelMsgFailed(("GCPhys=%RGp cb=%#x\n", GCPhys, cb));
    24792455    }
    24802456
     
    26652641     * Give priority to physical handlers (like #PF does).
    26662642     *
    2667      * Hope for a lonely physical handler first that covers the whole
    2668      * write area. This should be a pretty frequent case with MMIO and
    2669      * the heavy usage of full page handlers in the page pool.
     2643     * Hope for a lonely physical handler first that covers the whole write
     2644     * area.  This should be a pretty frequent case with MMIO and the heavy
     2645     * usage of full page handlers in the page pool.
    26702646     */
    26712647    PVMCPUCC pVCpu = VMMGetCpu(pVM);
     
    26832659            cbRange = cbWrite;
    26842660
    2685         Assert(PGMPHYSHANDLER_GET_TYPE(pVM, pCur)->CTX_SUFF(pfnHandler));
     2661        Assert(PGMPHYSHANDLER_GET_TYPE(pVM, pCur)->pfnHandler);
    26862662        Log5(("pgmPhysWriteHandler: GCPhys=%RGp cbRange=%#x pPage=%R[pgmpage] phys %s\n",
    26872663              GCPhys, cbRange, pPage, R3STRING(pCur->pszDesc) ));
     
    26922668        if (RT_SUCCESS(rcStrict))
    26932669        {
    2694             PPGMPHYSHANDLERTYPEINT const pCurType   = PGMPHYSHANDLER_GET_TYPE(pVM, pCur);
    2695             PFNPGMPHYSHANDLER const      pfnHandler = pCurType->CTX_SUFF(pfnHandler);
    2696             uint64_t const               uUser      = !pCurType->fRing0DevInsIdx ? pCur->uUser
    2697                                                     : (uintptr_t)PDMDeviceRing0IdxToInstance(pVM, pCur->uUser);
     2670            PCPGMPHYSHANDLERTYPEINT const pCurType   = PGMPHYSHANDLER_GET_TYPE_NO_NULL(pVM, pCur);
     2671            PFNPGMPHYSHANDLER const       pfnHandler = pCurType->pfnHandler;
     2672            uint64_t const                uUser      = !pCurType->fRing0DevInsIdx ? pCur->uUser
     2673                                                     : (uintptr_t)PDMDeviceRing0IdxToInstance(pVM, pCur->uUser);
    26982674            STAM_PROFILE_START(&pCur->Stat, h);
    26992675
     
    27472723    else /* The handler is somewhere else in the page, deal with it below. */
    27482724        rcStrict = VINF_SUCCESS;
    2749     Assert(!PGM_PAGE_IS_MMIO_OR_ALIAS(pPage)); /* MMIO handlers are all PAGE_SIZEed! */
     2725    Assert(!PGM_PAGE_IS_MMIO_OR_ALIAS(pPage)); /* MMIO handlers are all GUEST_PAGE_SIZEed! */
    27502726
    27512727    /*
     
    27632739    }
    27642740
     2741    /** @todo clean up this code some more now there are no virtual handlers any
     2742     *        more. */
    27652743    /* The loop state (big + ugly). */
    27662744    PPGMPHYSHANDLER pPhys       = NULL;
     
    28042782        VBOXSTRICTRC rcStrict2 = VINF_PGM_HANDLER_DO_DEFAULT;
    28052783        uint32_t cbRange = (uint32_t)cbWrite;
     2784        Assert(cbRange == cbWrite);
    28062785
    28072786        /*
     
    28182797                cbRange = offPhysLast + 1;
    28192798
    2820             PPGMPHYSHANDLERTYPEINT const pCurType   = PGMPHYSHANDLER_GET_TYPE(pVM, pPhys);
    2821             PFNPGMPHYSHANDLER const      pfnHandler = pCurType->CTX_SUFF(pfnHandler);
    2822             uint64_t const               uUser      = !pCurType->fRing0DevInsIdx ? pPhys->uUser
    2823                                                     : (uintptr_t)PDMDeviceRing0IdxToInstance(pVM, pPhys->uUser);
     2799            PCPGMPHYSHANDLERTYPEINT const pCurType   = PGMPHYSHANDLER_GET_TYPE_NO_NULL(pVM, pPhys);
     2800            PFNPGMPHYSHANDLER const       pfnHandler = pCurType->pfnHandler;
     2801            uint64_t const                uUser      = !pCurType->fRing0DevInsIdx ? pPhys->uUser
     2802                                                     : (uintptr_t)PDMDeviceRing0IdxToInstance(pVM, pPhys->uUser);
    28242803
    28252804            Log5(("pgmPhysWriteHandler: GCPhys=%RGp cbRange=%#x pPage=%R[pgmpage] phys %s\n", GCPhys, cbRange, pPage, R3STRING(pPhys->pszDesc) ));
  • trunk/src/VBox/VMM/VMMR0/IOMR0.cpp

    r93115 r93650  
    2222#define LOG_GROUP LOG_GROUP_IOM
    2323#include <VBox/vmm/iom.h>
     24#include <VBox/vmm/pgm.h>
    2425#include "IOMInternal.h"
    2526#include <VBox/vmm/vmcc.h>
    2627#include <VBox/log.h>
     28#include <iprt/assert.h>
    2729#include <iprt/assertcompile.h>
     30#include <iprt/errcore.h>
    2831
    2932
     
    4851
    4952/**
     53 * Called during ring-0 init (vmmR0InitVM).
     54 *
     55 * @returns VBox status code.
     56 * @param   pGVM    Pointer to the global VM structure.
     57 */
     58VMMR0_INT_DECL(int) IOMR0InitVM(PGVM pGVM)
     59{
     60    int rc = PGMR0HandlerPhysicalTypeSetUpContext(pGVM, PGMPHYSHANDLERKIND_MMIO, 0 /*fFlags*/,
     61                                                  iomMmioHandlerNew, iomMmioPfHandlerNew,
     62                                                  "MMIO", pGVM->iom.s.hNewMmioHandlerType);
     63    AssertRCReturn(rc, rc);
     64    return VINF_SUCCESS;
     65}
     66
     67
     68/**
    5069 * Cleans up any loose ends before the GVM structure is destroyed.
    5170 */
  • trunk/src/VBox/VMM/VMMR0/PDMR0DevHlp.cpp

    r93609 r93650  
    13211321    LogFlow(("pdmR0DevHlp_HpetSetUpContext: caller='%s'/%d: returns %Rrc\n", pDevIns->pReg->szName, pDevIns->iInstance, VINF_SUCCESS));
    13221322    return VINF_SUCCESS;
     1323}
     1324
     1325
     1326/** @interface_method_impl{PDMDEVHLPR0,pfnPGMHandlerPhysicalTypeSetUpContext} */
     1327static DECLCALLBACK(int) pdmR0DevHlp_PGMHandlerPhysicalTypeSetUpContext(PPDMDEVINS pDevIns, PGMPHYSHANDLERKIND enmKind,
     1328                                                                        PFNPGMPHYSHANDLER pfnHandler,
     1329                                                                        PFNPGMRZPHYSPFHANDLER pfnPfHandler,
     1330                                                                        const char *pszDesc, PGMPHYSHANDLERTYPE hType)
     1331{
     1332    PDMDEV_ASSERT_DEVINS(pDevIns);
     1333    LogFlow(("pdmR0DevHlp_PGMHandlerPhysicalTypeSetUpContext: caller='%s'/%d: enmKind=%d pfnHandler=%p pfnPfHandler=%p pszDesc=%p:{%s} hType=%#x\n",
     1334             pDevIns->pReg->szName, pDevIns->iInstance, enmKind, pfnHandler, pfnPfHandler, pszDesc, pszDesc, hType));
     1335
     1336    int rc = PGMR0HandlerPhysicalTypeSetUpContext(pDevIns->Internal.s.pGVM, enmKind, PGMPHYSHANDLER_F_R0_DEVINS_IDX,
     1337                                                  pfnHandler, pfnPfHandler, pszDesc, hType);
     1338
     1339    Log(("pdmR0DevHlp_PGMHandlerPhysicalTypeSetUpContext: caller='%s'/%d: returns %Rrc\n",
     1340         pDevIns->pReg->szName, pDevIns->iInstance, rc));
     1341    return rc;
    13231342}
    13241343
     
    14771496    pdmR0DevHlp_IoApicSetUpContext,
    14781497    pdmR0DevHlp_HpetSetUpContext,
     1498    pdmR0DevHlp_PGMHandlerPhysicalTypeSetUpContext,
    14791499    pdmR0DevHlp_PGMHandlerPhysicalPageTempOff,
    14801500    pdmR0DevHlp_MmioMapMmio2Page,
     
    15891609    pdmR0DevHlp_IoApicSetUpContext,
    15901610    pdmR0DevHlp_HpetSetUpContext,
     1611    pdmR0DevHlp_PGMHandlerPhysicalTypeSetUpContext,
    15911612    pdmR0DevHlp_PGMHandlerPhysicalPageTempOff,
    15921613    pdmR0DevHlp_MmioMapMmio2Page,
  • trunk/src/VBox/VMM/VMMR0/PGMR0.cpp

    r93635 r93650  
    3535#include <iprt/mem.h>
    3636#include <iprt/memobj.h>
     37#include <iprt/rand.h>
    3738#include <iprt/string.h>
    3839#include <iprt/time.h>
     
    8384
    8485    /*
     86     * Initialize the handler type table with return to ring-3 callbacks so we
     87     * don't have to do anything special for ring-3 only registrations.
     88     *
     89     * Note! The random bits of the hType value is mainly for prevent trouble
     90     *       with zero initialized handles w/o needing to sacrifice handle zero.
     91     */
     92    for (size_t i = 0; i < RT_ELEMENTS(pGVM->pgm.s.aPhysHandlerTypes); i++)
     93    {
     94        pGVM->pgmr0.s.aPhysHandlerTypes[i].hType        = i | (RTRandU64() & ~(uint64_t)PGMPHYSHANDLERTYPE_IDX_MASK);
     95        pGVM->pgmr0.s.aPhysHandlerTypes[i].enmKind      = PGMPHYSHANDLERKIND_INVALID;
     96        pGVM->pgmr0.s.aPhysHandlerTypes[i].pfnHandler   = pgmR0HandlerPhysicalHandlerToRing3;
     97        pGVM->pgmr0.s.aPhysHandlerTypes[i].pfnPfHandler = pgmR0HandlerPhysicalPfHandlerToRing3;
     98
     99        pGVM->pgm.s.aPhysHandlerTypes[i].hType          = pGVM->pgmr0.s.aPhysHandlerTypes[i].hType;
     100        pGVM->pgm.s.aPhysHandlerTypes[i].enmKind        = PGMPHYSHANDLERKIND_INVALID;
     101    }
     102
     103    /*
    85104     * Get the physical address of the ZERO and MMIO-dummy pages.
    86105     */
     
    107126VMMR0_INT_DECL(int) PGMR0InitVM(PGVM pGVM)
    108127{
    109     RT_NOREF(pGVM);
    110     /* Was used for DynMap init */
    111     return VINF_SUCCESS;
     128    /*
     129     * Set up the ring-0 context for our access handlers.
     130     */
     131    int rc = PGMR0HandlerPhysicalTypeSetUpContext(pGVM, PGMPHYSHANDLERKIND_WRITE, 0 /*fFlags*/,
     132                                                  pgmPhysRomWriteHandler, pgmPhysRomWritePfHandler,
     133                                                  "ROM write protection", pGVM->pgm.s.hRomPhysHandlerType);
     134    AssertLogRelRCReturn(rc, rc);
     135
     136    /*
     137     * Register the physical access handler doing dirty MMIO2 tracing.
     138     */
     139    rc = PGMR0HandlerPhysicalTypeSetUpContext(pGVM, PGMPHYSHANDLERKIND_WRITE, PGMPHYSHANDLER_F_KEEP_PGM_LOCK,
     140                                              pgmPhysMmio2WriteHandler, pgmPhysMmio2WritePfHandler,
     141                                              "MMIO2 dirty page tracing", pGVM->pgm.s.hMmio2DirtyPhysHandlerType);
     142    AssertLogRelRCReturn(rc, rc);
     143
     144    /*
     145     * The page pool.
     146     */
     147    return pgmR0PoolInitVM(pGVM);
     148}
     149
     150
     151/**
     152 * Called at the end of the ring-0 initialization to seal access handler types.
     153 *
     154 * @returns VBox status code.
     155 * @param   pGVM    Pointer to the global VM structure.
     156 */
     157VMMR0_INT_DECL(void) PGMR0DoneInitVM(PGVM pGVM)
     158{
     159    /*
     160     * Seal all the access handler types. Does both ring-3 and ring-0.
     161     *
     162     * Note! Since this is a void function and we don't have any ring-0 state
     163     *       machinery for marking the VM as bogus, this code will just
     164     *       override corrupted values as best as it can.
     165     */
     166    AssertCompile(RT_ELEMENTS(pGVM->pgmr0.s.aPhysHandlerTypes) == RT_ELEMENTS(pGVM->pgm.s.aPhysHandlerTypes));
     167    for (size_t i = 0; i < RT_ELEMENTS(pGVM->pgmr0.s.aPhysHandlerTypes); i++)
     168    {
     169        PPGMPHYSHANDLERTYPEINTR0 const pTypeR0   = &pGVM->pgmr0.s.aPhysHandlerTypes[i];
     170        PPGMPHYSHANDLERTYPEINTR3 const pTypeR3   = &pGVM->pgm.s.aPhysHandlerTypes[i];
     171        PGMPHYSHANDLERKIND       const enmKindR3 = pTypeR3->enmKind;
     172        PGMPHYSHANDLERKIND       const enmKindR0 = pTypeR0->enmKind;
     173        AssertLogRelMsgStmt(pTypeR0->hType == pTypeR3->hType,
     174                            ("i=%u %#RX64 vs %#RX64 %s\n", i, pTypeR0->hType, pTypeR3->hType, pTypeR0->pszDesc),
     175                            pTypeR3->hType = pTypeR0->hType);
     176        switch (enmKindR3)
     177        {
     178            case PGMPHYSHANDLERKIND_ALL:
     179            case PGMPHYSHANDLERKIND_MMIO:
     180                if (   enmKindR0 == enmKindR3
     181                    || enmKindR0 == PGMPHYSHANDLERKIND_INVALID)
     182                {
     183                    pTypeR3->fRing0Enabled = enmKindR0 == enmKindR3;
     184                    pTypeR0->uState = PGM_PAGE_HNDL_PHYS_STATE_ALL;
     185                    pTypeR3->uState = PGM_PAGE_HNDL_PHYS_STATE_ALL;
     186                    continue;
     187                }
     188                break;
     189
     190            case PGMPHYSHANDLERKIND_WRITE:
     191                if (   enmKindR0 == enmKindR3
     192                    || enmKindR0 == PGMPHYSHANDLERKIND_INVALID)
     193                {
     194                    pTypeR3->fRing0Enabled = enmKindR0 == enmKindR3;
     195                    pTypeR0->uState = PGM_PAGE_HNDL_PHYS_STATE_WRITE;
     196                    pTypeR3->uState = PGM_PAGE_HNDL_PHYS_STATE_WRITE;
     197                    continue;
     198                }
     199                break;
     200
     201            default:
     202                AssertLogRelMsgFailed(("i=%u enmKindR3=%d\n", i, enmKindR3));
     203                RT_FALL_THROUGH();
     204            case PGMPHYSHANDLERKIND_INVALID:
     205                AssertLogRelMsg(enmKindR0 == PGMPHYSHANDLERKIND_INVALID,
     206                                ("i=%u enmKind=%d %s\n", i, enmKindR0, pTypeR0->pszDesc));
     207                AssertLogRelMsg(pTypeR0->pfnHandler == pgmR0HandlerPhysicalHandlerToRing3,
     208                                ("i=%u pfnHandler=%p %s\n", i, pTypeR0->pfnHandler, pTypeR0->pszDesc));
     209                AssertLogRelMsg(pTypeR0->pfnPfHandler == pgmR0HandlerPhysicalPfHandlerToRing3,
     210                                ("i=%u pfnPfHandler=%p %s\n", i, pTypeR0->pfnPfHandler, pTypeR0->pszDesc));
     211
     212                /* Unused of bad ring-3 entry, make it and the ring-0 one harmless. */
     213                pTypeR3->enmKind         = PGMPHYSHANDLERKIND_END;
     214                pTypeR3->fRing0DevInsIdx = false;
     215                pTypeR3->fKeepPgmLock    = false;
     216                pTypeR3->uState          = 0;
     217                break;
     218        }
     219        pTypeR3->fRing0Enabled   = false;
     220
     221        /* Make sure the entry is harmless and goes to ring-3. */
     222        pTypeR0->enmKind         = PGMPHYSHANDLERKIND_END;
     223        pTypeR0->pfnHandler      = pgmR0HandlerPhysicalHandlerToRing3;
     224        pTypeR0->pfnPfHandler    = pgmR0HandlerPhysicalPfHandlerToRing3;
     225        pTypeR0->fRing0DevInsIdx = false;
     226        pTypeR0->fKeepPgmLock    = false;
     227        pTypeR0->uState          = 0;
     228        pTypeR0->pszDesc         = "invalid";
     229    }
    112230}
    113231
     
    631749    return SUPR0PageMapKernel(pGVM->pSession, pvR3, (uint32_t)offSub, (uint32_t)cbSub, 0 /*fFlags*/, ppvMapping);
    632750#endif
     751}
     752
     753
     754/**
     755 * Updates a physical access handler type with ring-0 callback functions.
     756 *
     757 * The handler type must first have been registered in ring-3.
     758 *
     759 * @returns VBox status code.
     760 * @param   pGVM            The global (ring-0) VM structure.
     761 * @param   enmKind         The kind of access handler.
     762 * @param   fFlags          PGMPHYSHANDLER_F_XXX
     763 * @param   pfnHandler      Pointer to the ring-0 handler callback.
     764 * @param   pfnPfHandler    Pointer to the ring-0 \#PF handler callback.
     765 *                          callback.
     766 * @param   pszDesc         The type description.
     767 * @param   hType           The handle to do ring-0 callback registrations for.
     768 * @thread  EMT(0)
     769 */
     770VMMR0_INT_DECL(int) PGMR0HandlerPhysicalTypeSetUpContext(PGVM pGVM, PGMPHYSHANDLERKIND enmKind, uint32_t fFlags,
     771                                                         PFNPGMPHYSHANDLER pfnHandler, PFNPGMRZPHYSPFHANDLER pfnPfHandler,
     772                                                         const char *pszDesc, PGMPHYSHANDLERTYPE hType)
     773{
     774    /*
     775     * Validate input.
     776     */
     777    AssertPtrReturn(pfnHandler, VERR_INVALID_POINTER);
     778    AssertPtrReturn(pfnPfHandler, VERR_INVALID_POINTER);
     779    AssertPtrReturn(pszDesc, VERR_INVALID_POINTER);
     780    AssertReturn(   enmKind == PGMPHYSHANDLERKIND_WRITE
     781                 || enmKind == PGMPHYSHANDLERKIND_ALL
     782                 || enmKind == PGMPHYSHANDLERKIND_MMIO,
     783                 VERR_INVALID_PARAMETER);
     784    AssertMsgReturn(!(fFlags & ~PGMPHYSHANDLER_F_VALID_MASK), ("%#x\n", fFlags), VERR_INVALID_FLAGS);
     785
     786    PPGMPHYSHANDLERTYPEINTR0 const pTypeR0 = &pGVM->pgmr0.s.aPhysHandlerTypes[hType & PGMPHYSHANDLERTYPE_IDX_MASK];
     787    AssertMsgReturn(hType == pTypeR0->hType, ("%#RX64, expected=%#RX64\n", hType, pTypeR0->hType), VERR_INVALID_HANDLE);
     788    AssertCompile(RT_ELEMENTS(pGVM->pgmr0.s.aPhysHandlerTypes) == RT_ELEMENTS(pGVM->pgm.s.aPhysHandlerTypes));
     789    AssertCompile(RT_ELEMENTS(pGVM->pgmr0.s.aPhysHandlerTypes) == PGMPHYSHANDLERTYPE_IDX_MASK + 1);
     790    AssertReturn(pTypeR0->enmKind == PGMPHYSHANDLERKIND_INVALID, VERR_ALREADY_INITIALIZED);
     791
     792    int rc = GVMMR0ValidateGVMandEMT(pGVM, 0);
     793    AssertRCReturn(rc, rc);
     794    VM_ASSERT_STATE_RETURN(pGVM, VMSTATE_CREATING, VERR_VM_INVALID_VM_STATE); /** @todo ring-0 safe state check. */
     795
     796    PPGMPHYSHANDLERTYPEINTR3 const pTypeR3 = &pGVM->pgm.s.aPhysHandlerTypes[hType & PGMPHYSHANDLERTYPE_IDX_MASK];
     797    AssertMsgReturn(pTypeR3->enmKind == enmKind,
     798                    ("%#x: %d, expected %d\n", hType, pTypeR3->enmKind, enmKind),
     799                    VERR_INVALID_HANDLE);
     800    AssertMsgReturn(pTypeR3->fKeepPgmLock == RT_BOOL(fFlags & PGMPHYSHANDLER_F_KEEP_PGM_LOCK),
     801                    ("%#x: %d, fFlags=%d\n", hType, pTypeR3->fKeepPgmLock, fFlags),
     802                    VERR_INVALID_HANDLE);
     803    AssertMsgReturn(pTypeR3->fRing0DevInsIdx == RT_BOOL(fFlags & PGMPHYSHANDLER_F_R0_DEVINS_IDX),
     804                    ("%#x: %d, fFlags=%d\n", hType, pTypeR3->fRing0DevInsIdx, fFlags),
     805                    VERR_INVALID_HANDLE);
     806
     807    /*
     808     * Update the entry.
     809     */
     810    pTypeR0->enmKind          = enmKind;
     811    pTypeR0->uState           = enmKind == PGMPHYSHANDLERKIND_WRITE
     812                              ? PGM_PAGE_HNDL_PHYS_STATE_WRITE : PGM_PAGE_HNDL_PHYS_STATE_ALL;
     813    pTypeR0->fKeepPgmLock     = RT_BOOL(fFlags & PGMPHYSHANDLER_F_KEEP_PGM_LOCK);
     814    pTypeR0->fRing0DevInsIdx  = RT_BOOL(fFlags & PGMPHYSHANDLER_F_R0_DEVINS_IDX);
     815    pTypeR0->pfnHandler       = pfnHandler;
     816    pTypeR0->pfnPfHandler     = pfnPfHandler;
     817    pTypeR0->pszDesc          = pszDesc;
     818
     819    pTypeR3->fRing0Enabled    = true;
     820
     821    LogFlow(("PGMR0HandlerPhysicalTypeRegister: hType=%#x: enmKind=%d fFlags=%#x pfnHandler=%p pfnPfHandler=%p pszDesc=%s\n",
     822             hType, enmKind, fFlags, pfnHandler, pfnPfHandler, pszDesc));
     823    return VINF_SUCCESS;
    633824}
    634825
     
    9651156     */
    9661157    PGM_LOCK_VOID(pGVM);
    967     PPGMPHYSHANDLER         pHandler     = pgmHandlerPhysicalLookup(pGVM, GCPhysFault);
    968     PPGMPHYSHANDLERTYPEINT  pHandlerType = RT_LIKELY(pHandler) ? PGMPHYSHANDLER_GET_TYPE(pGVM, pHandler) : NULL;
     1158    PPGMPHYSHANDLER          pHandler     = pgmHandlerPhysicalLookup(pGVM, GCPhysFault);
     1159    PCPGMPHYSHANDLERTYPEINT  pHandlerType = RT_LIKELY(pHandler) ? PGMPHYSHANDLER_GET_TYPE_NO_NULL(pGVM, pHandler) : NULL;
    9691160    if (RT_LIKELY(pHandler && pHandlerType->enmKind != PGMPHYSHANDLERKIND_WRITE))
    9701161    {
     
    9881179        else
    9891180        {
    990             if (pHandlerType->CTX_SUFF(pfnPfHandler))
     1181            if (pHandlerType->pfnPfHandler)
    9911182            {
    9921183                uint64_t const uUser = !pHandlerType->fRing0DevInsIdx ? pHandler->uUser
     
    9951186                PGM_UNLOCK(pGVM);
    9961187
    997                 Log6(("PGMR0Trap0eHandlerNPMisconfig: calling %p(,%#x,,%RGp,%p)\n", pHandlerType->CTX_SUFF(pfnPfHandler), uErr, GCPhysFault, uUser));
    998                 rc = pHandlerType->CTX_SUFF(pfnPfHandler)(pGVM, pGVCpu, uErr == UINT32_MAX ? RTGCPTR_MAX : uErr, pRegFrame,
    999                                                           GCPhysFault, GCPhysFault, uUser);
     1188                Log6(("PGMR0Trap0eHandlerNPMisconfig: calling %p(,%#x,,%RGp,%p)\n", pHandlerType->pfnPfHandler, uErr, GCPhysFault, uUser));
     1189                rc = pHandlerType->pfnPfHandler(pGVM, pGVCpu, uErr == UINT32_MAX ? RTGCPTR_MAX : uErr, pRegFrame,
     1190                                                GCPhysFault, GCPhysFault, uUser);
    10001191
    10011192#ifdef VBOX_WITH_STATISTICS
  • trunk/src/VBox/VMM/VMMR0/PGMR0Pool.cpp

    r93554 r93650  
    3232#include <iprt/mem.h>
    3333#include <iprt/memobj.h>
     34
     35
     36/**
     37 * Called by PGMR0InitVM to complete the page pool setup for ring-0.
     38 *
     39 * @returns VBox status code.
     40 * @param   pGVM    Pointer to the global VM structure.
     41 */
     42int pgmR0PoolInitVM(PGVM pGVM)
     43{
     44    PPGMPOOL pPool = pGVM->pgm.s.pPoolR0;
     45    AssertPtrReturn(pPool, VERR_PGM_POOL_IPE);
     46
     47    int rc = PGMR0HandlerPhysicalTypeSetUpContext(pGVM, PGMPHYSHANDLERKIND_WRITE, PGMPHYSHANDLER_F_KEEP_PGM_LOCK,
     48                                                  pgmPoolAccessHandler, pgmRZPoolAccessPfHandler,
     49                                                  "Guest Paging Access Handler", pPool->hAccessHandlerType);
     50    AssertLogRelRCReturn(rc, rc);
     51
     52    return VINF_SUCCESS;
     53}
    3454
    3555
  • trunk/src/VBox/VMM/VMMR0/VMMR0.cpp

    r93609 r93650  
    2323#include <VBox/vmm/vmm.h>
    2424#include <VBox/sup.h>
     25#include <VBox/vmm/iem.h>
    2526#include <VBox/vmm/iom.h>
    2627#include <VBox/vmm/trpm.h>
     
    5556#include <iprt/assert.h>
    5657#include <iprt/crc.h>
     58#include <iprt/initterm.h>
    5759#include <iprt/mem.h>
    5860#include <iprt/memobj.h>
     
    282284
    283285    vmmTermFormatTypes();
     286    RTTermRunCallbacks(RTTERMREASON_UNLOAD, 0);
    284287
    285288    LogFlow(("ModuleTerm: returns\n"));
     
    436439    {
    437440        /*
    438          * Init HM, CPUM and PGM (Darwin only).
     441         * Init HM, CPUM and PGM.
    439442         */
    440443        rc = HMR0InitVM(pGVM);
     
    450453                    if (RT_SUCCESS(rc))
    451454                    {
    452 #ifdef VBOX_WITH_PCI_PASSTHROUGH
    453                         rc = PciRawR0InitVM(pGVM);
    454 #endif
     455                        rc = IEMR0InitVM(pGVM);
    455456                        if (RT_SUCCESS(rc))
    456457                        {
    457                             rc = GIMR0InitVM(pGVM);
     458                            rc = IOMR0InitVM(pGVM);
    458459                            if (RT_SUCCESS(rc))
    459460                            {
    460                                 GVMMR0DoneInitVM(pGVM);
    461 
    462                                 /*
    463                                  * Collect a bit of info for the VM release log.
    464                                  */
    465                                 pGVM->vmm.s.fIsPreemptPendingApiTrusty = RTThreadPreemptIsPendingTrusty();
    466                                 pGVM->vmm.s.fIsPreemptPossible         = RTThreadPreemptIsPossible();;
    467                                 return rc;
    468 
    469                                 /* bail out*/
    470                                 //GIMR0TermVM(pGVM);
     461#ifdef VBOX_WITH_PCI_PASSTHROUGH
     462                                rc = PciRawR0InitVM(pGVM);
     463#endif
     464                                if (RT_SUCCESS(rc))
     465                                {
     466                                    rc = GIMR0InitVM(pGVM);
     467                                    if (RT_SUCCESS(rc))
     468                                    {
     469                                        GVMMR0DoneInitVM(pGVM);
     470                                        PGMR0DoneInitVM(pGVM);
     471
     472                                        /*
     473                                         * Collect a bit of info for the VM release log.
     474                                         */
     475                                        pGVM->vmm.s.fIsPreemptPendingApiTrusty = RTThreadPreemptIsPendingTrusty();
     476                                        pGVM->vmm.s.fIsPreemptPossible         = RTThreadPreemptIsPossible();;
     477                                        return rc;
     478
     479                                        /* bail out*/
     480                                        //GIMR0TermVM(pGVM);
     481                                    }
     482#ifdef VBOX_WITH_PCI_PASSTHROUGH
     483                                    PciRawR0TermVM(pGVM);
     484#endif
     485                                }
    471486                            }
    472 #ifdef VBOX_WITH_PCI_PASSTHROUGH
    473                             PciRawR0TermVM(pGVM);
    474 #endif
    475487                        }
    476488                    }
  • trunk/src/VBox/VMM/VMMR3/IEMR3.cpp

    r93635 r93650  
    171171    if (pVM->cpum.ro.GuestFeatures.fVmx)
    172172    {
    173         PVMCPU pVCpu0 = pVM->apCpusR3[0];
    174173        int rc = PGMR3HandlerPhysicalTypeRegister(pVM, PGMPHYSHANDLERKIND_ALL, 0 /*fFlags*/,
    175174                                                  iemVmxApicAccessPageHandler,
    176                                                   NULL /* pszModR0 */,
    177                                                   "iemVmxApicAccessPageHandler", NULL /* pszPfHandlerR0 */,
    178                                                   NULL /* pszModRC */,
    179                                                   NULL /* pszHandlerRC */, NULL /* pszPfHandlerRC */,
    180                                                   "VMX APIC-access page", &pVCpu0->iem.s.hVmxApicAccessPage);
     175                                                  "VMX APIC-access page", &pVM->iem.s.hVmxApicAccessPage);
    181176        AssertLogRelRCReturn(rc, rc);
    182177    }
  • trunk/src/VBox/VMM/VMMR3/IOM.cpp

    r93635 r93650  
    160160     */
    161161    rc = PGMR3HandlerPhysicalTypeRegister(pVM, PGMPHYSHANDLERKIND_MMIO, 0 /*fFlags*/,
    162                                           iomMmioHandlerNew,
    163                                           NULL, "iomMmioHandlerNew", "iomMmioPfHandlerNew",
    164                                           NULL, "iomMmioHandlerNew", "iomMmioPfHandlerNew",
    165                                           "MMIO New", &pVM->iom.s.hNewMmioHandlerType);
     162                                          iomMmioHandlerNew, "MMIO", &pVM->iom.s.hNewMmioHandlerType);
    166163    AssertRCReturn(rc, rc);
    167164
  • trunk/src/VBox/VMM/VMMR3/PDMDevHlp.cpp

    r93635 r93650  
    860860/** @interface_method_impl{PDMDEVHLPR3,pfnPGMHandlerPhysicalTypeRegister} */
    861861static DECLCALLBACK(int) pdmR3DevHlp_PGMHandlerPhysicalTypeRegister(PPDMDEVINS pDevIns, PGMPHYSHANDLERKIND enmKind,
    862                                                                     R3PTRTYPE(PFNPGMPHYSHANDLER) pfnHandlerR3,
    863                                                                     const char *pszHandlerR0, const char *pszPfHandlerR0,
    864                                                                     const char *pszHandlerRC, const char *pszPfHandlerRC,
    865                                                                     const char *pszDesc, PPGMPHYSHANDLERTYPE phType)
     862                                                                    PFNPGMPHYSHANDLER pfnHandlerR3, const char *pszDesc,
     863                                                                    PPGMPHYSHANDLERTYPE phType)
    866864{
    867865    PDMDEV_ASSERT_DEVINS(pDevIns);
    868866    PVM  pVM = pDevIns->Internal.s.pVMR3;
    869     LogFlow(("pdmR3DevHlp_PGMHandlerPhysicalTypeRegister: caller='%s'/%d: enmKind=%d pfnHandlerR3=%p pszHandlerR0=%p:{%s} pszPfHandlerR0=%p:{%s} pszHandlerRC=%p:{%s} pszPfHandlerRC=%p:{%s} pszDesc=%p:{%s} phType=%p\n",
    870              pDevIns->pReg->szName, pDevIns->iInstance, enmKind, pfnHandlerR3,
    871              pszHandlerR0, pszHandlerR0, pszPfHandlerR0, pszPfHandlerR0,
    872              pszHandlerRC, pszHandlerRC, pszPfHandlerRC, pszPfHandlerRC,
    873              pszDesc, pszDesc, phType));
     867    LogFlow(("pdmR3DevHlp_PGMHandlerPhysicalTypeRegister: caller='%s'/%d: enmKind=%d pfnHandlerR3=%p pszDesc=%p:{%s} phType=%p\n",
     868             pDevIns->pReg->szName, pDevIns->iInstance, enmKind, pfnHandlerR3, pszDesc, pszDesc, phType));
    874869
    875870    int rc = PGMR3HandlerPhysicalTypeRegister(pVM, enmKind,
    876871                                              pDevIns->Internal.s.fIntFlags & PDMDEVINSINT_FLAGS_R0_ENABLED
    877872                                              ? PGMPHYSHANDLER_F_R0_DEVINS_IDX : 0,
    878                                               pfnHandlerR3,
    879                                               pDevIns->pReg->pszR0Mod, pszHandlerR0, pszPfHandlerR0,
    880                                               pDevIns->pReg->pszRCMod, pszHandlerRC, pszPfHandlerRC,
    881                                               pszDesc, phType);
     873                                              pfnHandlerR3, pszDesc, phType);
    882874
    883875    Log(("pdmR3DevHlp_PGMHandlerPhysicalTypeRegister: caller='%s'/%d: returns %Rrc\n",
     
    57645756/** @interface_method_impl{PDMDEVHLPR3,pfnPGMHandlerPhysicalTypeRegister} */
    57655757static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_PGMHandlerPhysicalTypeRegister(PPDMDEVINS pDevIns, PGMPHYSHANDLERKIND enmKind,
    5766                                                                               R3PTRTYPE(PFNPGMPHYSHANDLER) pfnHandlerR3,
    5767                                                                               const char *pszHandlerR0, const char *pszPfHandlerR0,
    5768                                                                               const char *pszHandlerRC, const char *pszPfHandlerRC,
     5758                                                                              PFNPGMPHYSHANDLER pfnHandler,
    57695759                                                                              const char *pszDesc, PPGMPHYSHANDLERTYPE phType)
    57705760{
    57715761    PDMDEV_ASSERT_DEVINS(pDevIns);
    5772     RT_NOREF(enmKind, pfnHandlerR3, pszHandlerR0, pszPfHandlerR0, pszHandlerRC, pszPfHandlerRC, pszDesc, phType);
     5762    RT_NOREF(pDevIns, enmKind, pfnHandler, pszDesc);
    57735763    AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n",
    57745764                            pDevIns->pReg->szName, pDevIns->iInstance));
     5765    *phType = NIL_PGMPHYSHANDLERTYPE;
    57755766    return VERR_ACCESS_DENIED;
    57765767}
  • trunk/src/VBox/VMM/VMMR3/PGM.cpp

    r93635 r93650  
    618618#include <iprt/assert.h>
    619619#include <iprt/env.h>
     620#include <iprt/file.h>
    620621#include <iprt/mem.h>
    621 #include <iprt/file.h>
     622#include <iprt/rand.h>
    622623#include <iprt/string.h>
    623624#include <iprt/thread.h>
     
    794795        pVM->pgm.s.aLargeHandyPage[i].idPage        = NIL_GMM_PAGEID;
    795796        pVM->pgm.s.aLargeHandyPage[i].idSharedPage  = NIL_GMM_PAGEID;
     797    }
     798
     799    AssertReleaseReturn(pVM->pgm.s.cPhysHandlerTypes == 0, VERR_WRONG_ORDER);
     800    for (size_t i = 0; i < RT_ELEMENTS(pVM->pgm.s.aPhysHandlerTypes); i++)
     801    {
     802        if (fDriverless)
     803            pVM->pgm.s.aPhysHandlerTypes[i].hType  = i | (RTRandU64() & ~(uint64_t)PGMPHYSHANDLERTYPE_IDX_MASK);
     804        pVM->pgm.s.aPhysHandlerTypes[i].enmKind    = PGMPHYSHANDLERKIND_INVALID;
     805        pVM->pgm.s.aPhysHandlerTypes[i].pfnHandler = pgmR3HandlerPhysicalHandlerInvalid;
    796806    }
    797807
     
    954964    if (RT_SUCCESS(rc))
    955965        /** @todo why isn't pgmPhysRomWriteHandler registered for ring-0?   */
    956         rc = PGMR3HandlerPhysicalTypeRegister(pVM, PGMPHYSHANDLERKIND_WRITE, 0 /*fFlags*/,
    957                                               pgmPhysRomWriteHandler,
    958                                               NULL, NULL, "pgmPhysRomWritePfHandler",
    959                                               NULL, NULL, "pgmPhysRomWritePfHandler",
    960                                               "ROM write protection",
    961                                               &pVM->pgm.s.hRomPhysHandlerType);
     966        rc = PGMR3HandlerPhysicalTypeRegister(pVM, PGMPHYSHANDLERKIND_WRITE, 0 /*fFlags*/, pgmPhysRomWriteHandler,
     967                                              "ROM write protection", &pVM->pgm.s.hRomPhysHandlerType);
    962968
    963969    /*
     
    966972    if (RT_SUCCESS(rc))
    967973        rc = PGMR3HandlerPhysicalTypeRegister(pVM, PGMPHYSHANDLERKIND_WRITE, PGMPHYSHANDLER_F_KEEP_PGM_LOCK,
    968                                               pgmPhysMmio2WriteHandler,
    969                                               NULL, "pgmPhysMmio2WriteHandler", "pgmPhysMmio2WritePfHandler",
    970                                               NULL, "pgmPhysMmio2WriteHandler", "pgmPhysMmio2WritePfHandler",
    971                                               "MMIO2 dirty page tracing",
     974                                              pgmPhysMmio2WriteHandler, "MMIO2 dirty page tracing",
    972975                                              &pVM->pgm.s.hMmio2DirtyPhysHandlerType);
    973976
  • trunk/src/VBox/VMM/VMMR3/PGMHandler.cpp

    r93635 r93650  
    5858
    5959
    60 
    61 /**
    62  * Register a physical page access handler type, extended version.
     60/**
     61 * @callback_method_impl{FNPGMPHYSHANDLER,
     62 * Invalid callback entry triggering guru mediation}
     63 */
     64DECLCALLBACK(VBOXSTRICTRC) pgmR3HandlerPhysicalHandlerInvalid(PVMCC pVM, PVMCPUCC pVCpu, RTGCPHYS GCPhys, void *pvPhys,
     65                                                              void *pvBuf, size_t cbBuf, PGMACCESSTYPE enmAccessType,
     66                                                              PGMACCESSORIGIN enmOrigin, uint64_t uUser)
     67{
     68    RT_NOREF(pVM, pVCpu, GCPhys, pvPhys, pvBuf, cbBuf, enmAccessType, enmOrigin, uUser);
     69    LogRel(("GCPhys=%RGp cbBuf=%#zx enmAccessType=%d uUser=%#RX64\n", GCPhys, cbBuf, enmAccessType, uUser));
     70    return VERR_PGM_HANDLER_IPE_1;
     71}
     72
     73
     74/**
     75 * Register a physical page access handler type.
    6376 *
    6477 * @returns VBox status code.
    65  * @param   pVM             The cross context VM structure.
    66  * @param   enmKind         The kind of access handler.
    67  * @param   fFlags          PGMPHYSHANDLER_F_XXX
    68  * @param   pfnHandlerR3    Pointer to the ring-3 handler callback.
    69  * @param   pfnHandlerR0    Pointer to the ring-0 handler callback.
    70  * @param   pfnPfHandlerR0  Pointer to the ring-0 \#PF handler callback.
    71  *                          callback.
    72  * @param   pszDesc         The type description.
    73  * @param   phType          Where to return the type handle (cross context
    74  *                          safe).
    75  */
    76 VMMR3_INT_DECL(int) PGMR3HandlerPhysicalTypeRegisterEx(PVM pVM, PGMPHYSHANDLERKIND enmKind, uint32_t fFlags,
    77                                                        PFNPGMPHYSHANDLER pfnHandlerR3,
    78                                                        R0PTRTYPE(PFNPGMPHYSHANDLER) pfnHandlerR0,
    79                                                        R0PTRTYPE(PFNPGMRZPHYSPFHANDLER) pfnPfHandlerR0,
    80                                                        const char *pszDesc, PPGMPHYSHANDLERTYPE phType)
    81 {
    82     AssertPtrReturn(pfnHandlerR3, VERR_INVALID_POINTER);
    83     AssertReturn(pfnHandlerR0   != NIL_RTR0PTR || SUPR3IsDriverless(), VERR_INVALID_POINTER);
    84     AssertReturn(pfnPfHandlerR0 != NIL_RTR0PTR || SUPR3IsDriverless(), VERR_INVALID_POINTER);
     78 * @param   pVM         The cross context VM structure.
     79 * @param   enmKind     The kind of access handler.
     80 * @param   fFlags      PGMPHYSHANDLER_F_XXX
     81 * @param   pfnHandler  Pointer to the ring-3 handler callback.
     82 * @param   pszDesc     The type description.
     83 * @param   phType      Where to return the type handle (cross context safe).
     84 */
     85VMMR3_INT_DECL(int) PGMR3HandlerPhysicalTypeRegister(PVM pVM, PGMPHYSHANDLERKIND enmKind, uint32_t fFlags,
     86                                                     PFNPGMPHYSHANDLER pfnHandler, const char *pszDesc,
     87                                                     PPGMPHYSHANDLERTYPE phType)
     88{
     89    /*
     90     * Validate input.
     91     */
     92    AssertPtrReturn(phType, VERR_INVALID_POINTER);
     93    *phType = NIL_PGMPHYSHANDLERTYPE;
     94
     95    AssertPtrReturn(pfnHandler, VERR_INVALID_POINTER);
    8596    AssertPtrReturn(pszDesc, VERR_INVALID_POINTER);
    8697    AssertReturn(   enmKind == PGMPHYSHANDLERKIND_WRITE
     
    90101    AssertMsgReturn(!(fFlags & ~PGMPHYSHANDLER_F_VALID_MASK), ("%#x\n", fFlags), VERR_INVALID_FLAGS);
    91102
    92     PPGMPHYSHANDLERTYPEINT pType;
    93     int rc = MMHyperAlloc(pVM, sizeof(*pType), 0, MM_TAG_PGM_HANDLER_TYPES, (void **)&pType);
    94     if (RT_SUCCESS(rc))
    95     {
    96         pType->u32Magic         = PGMPHYSHANDLERTYPEINT_MAGIC;
    97         pType->cRefs            = 1;
    98         pType->enmKind          = enmKind;
    99         pType->uState           = enmKind == PGMPHYSHANDLERKIND_WRITE
    100                                 ? PGM_PAGE_HNDL_PHYS_STATE_WRITE : PGM_PAGE_HNDL_PHYS_STATE_ALL;
    101         pType->fKeepPgmLock     = RT_BOOL(fFlags & PGMPHYSHANDLER_F_KEEP_PGM_LOCK);
    102         pType->fRing0DevInsIdx  = RT_BOOL(fFlags & PGMPHYSHANDLER_F_R0_DEVINS_IDX);
    103         pType->pfnHandlerR3     = pfnHandlerR3;
    104         pType->pfnHandlerR0     = pfnHandlerR0;
    105         pType->pfnPfHandlerR0   = pfnPfHandlerR0;
    106         pType->pszDesc          = pszDesc;
    107 
    108         PGM_LOCK_VOID(pVM);
    109         RTListOff32Append(&pVM->pgm.s.CTX_SUFF(pTrees)->HeadPhysHandlerTypes, &pType->ListNode);
    110         PGM_UNLOCK(pVM);
    111 
    112         *phType = MMHyperHeapPtrToOffset(pVM, pType);
    113         LogFlow(("PGMR3HandlerPhysicalTypeRegisterEx: %p/%#x: enmKind=%d pfnHandlerR3=%RHv pfnHandlerR0=%RHv pszDesc=%s\n",
    114                  pType, *phType, enmKind, pfnHandlerR3, pfnPfHandlerR0, pszDesc));
    115         return VINF_SUCCESS;
    116     }
    117     *phType = NIL_PGMPHYSHANDLERTYPE;
    118     return rc;
    119 }
    120 
    121 
    122 /**
    123  * Register a physical page access handler type.
    124  *
    125  * @returns VBox status code.
    126  * @param   pVM             The cross context VM structure.
    127  * @param   enmKind         The kind of access handler.
    128  * @param   fFlags          PGMPHYSHANDLER_F_XXX
    129  * @param   pfnHandlerR3    Pointer to the ring-3 handler callback.
    130  * @param   pszModR0        The name of the ring-0 module, NULL is an alias for
    131  *                          the main ring-0 module.
    132  * @param   pszHandlerR0    The name of the ring-0 handler, NULL if the ring-3
    133  *                          handler should be called.
    134  * @param   pszPfHandlerR0  The name of the ring-0 \#PF handler, NULL if the
    135  *                          ring-3 handler should be called.
    136  * @param   pszModRC        The name of the raw-mode context module, NULL is an
    137  *                          alias for the main RC module.
    138  * @param   pszHandlerRC    The name of the raw-mode context handler, NULL if
    139  *                          the ring-3 handler should be called.
    140  * @param   pszPfHandlerRC  The name of the raw-mode context \#PF handler, NULL
    141  *                          if the ring-3 handler should be called.
    142  * @param   pszDesc         The type description.
    143  * @param   phType          Where to return the type handle (cross context
    144  *                          safe).
    145  */
    146 VMMR3DECL(int) PGMR3HandlerPhysicalTypeRegister(PVM pVM, PGMPHYSHANDLERKIND enmKind, uint32_t fFlags,
    147                                                 R3PTRTYPE(PFNPGMPHYSHANDLER) pfnHandlerR3,
    148                                                 const char *pszModR0, const char *pszHandlerR0, const char *pszPfHandlerR0,
    149                                                 const char *pszModRC, const char *pszHandlerRC, const char *pszPfHandlerRC,
    150                                                 const char *pszDesc, PPGMPHYSHANDLERTYPE phType)
    151 {
    152     LogFlow(("PGMR3HandlerPhysicalTypeRegister: enmKind=%d pfnHandlerR3=%RHv pszModR0=%s pszHandlerR0=%s pszPfHandlerR0=%s pszModRC=%s pszHandlerRC=%s pszPfHandlerRC=%s pszDesc=%s\n",
    153              enmKind, pfnHandlerR3, pszModR0, pszHandlerR0, pszPfHandlerR0, pszModRC, pszHandlerRC, pszPfHandlerRC, pszDesc));
    154 
    155     /*
    156      * Validate input.
    157      */
    158     AssertPtrReturn(pfnHandlerR3, VERR_INVALID_POINTER);
    159     AssertPtrNullReturn(pszModR0, VERR_INVALID_POINTER);
    160     AssertPtrNullReturn(pszHandlerR0, VERR_INVALID_POINTER);
    161     AssertPtrNullReturn(pszPfHandlerR0, VERR_INVALID_POINTER);
    162     AssertPtrNullReturn(pszModRC, VERR_INVALID_POINTER);
    163     AssertPtrNullReturn(pszHandlerRC, VERR_INVALID_POINTER);
    164     AssertPtrNullReturn(pszPfHandlerRC, VERR_INVALID_POINTER);
    165 
    166     /*
    167      * Resolve the R0 handlers.
    168      */
    169     R0PTRTYPE(PFNPGMPHYSHANDLER) pfnHandlerR0 = NIL_RTR0PTR;
    170     R0PTRTYPE(PFNPGMR0PHYSPFHANDLER) pfnPfHandlerR0 = NIL_RTR0PTR;
    171     int rc = VINF_SUCCESS;
    172     if (!SUPR3IsDriverless())
    173     {
    174         rc = PDMR3LdrGetSymbolR0Lazy(pVM, pszHandlerR0 ? pszModR0 : NULL, NULL /*pszSearchPath*/,
    175                                          pszHandlerR0 ? pszHandlerR0 : "pgmPhysHandlerRedirectToHC", &pfnHandlerR0);
    176         if (RT_SUCCESS(rc))
    177         {
    178             rc = PDMR3LdrGetSymbolR0Lazy(pVM, pszPfHandlerR0 ? pszModR0 : NULL, NULL /*pszSearchPath*/,
    179                                          pszPfHandlerR0 ? pszPfHandlerR0 : "pgmPhysPfHandlerRedirectToHC", &pfnPfHandlerR0);
    180             AssertMsgRC(rc, ("Failed to resolve %s.%s, rc=%Rrc.\n", pszPfHandlerR0 ? pszModR0 : VMMR0_MAIN_MODULE_NAME,
    181                              pszPfHandlerR0 ? pszPfHandlerR0 : "pgmPhysHandlerRedirectToHC", rc));
    182         }
    183         else
    184             AssertMsgFailed(("Failed to resolve %s.%s, rc=%Rrc.\n", pszHandlerR0 ? pszModR0 : VMMR0_MAIN_MODULE_NAME,
    185                              pszHandlerR0 ? pszHandlerR0 : "pgmPhysHandlerRedirectToHC", rc));
    186     }
    187     if (RT_SUCCESS(rc))
    188     {
    189         /*
    190          * Resolve the GC handler.
    191          */
    192         RTRCPTR pfnHandlerRC   = NIL_RTRCPTR;
    193         RTRCPTR pfnPfHandlerRC = NIL_RTRCPTR;
    194         if (VM_IS_RAW_MODE_ENABLED(pVM))
    195         {
    196             rc = PDMR3LdrGetSymbolRCLazy(pVM, pszHandlerRC ? pszModRC : NULL, NULL /*pszSearchPath*/,
    197                                          pszHandlerRC ? pszHandlerRC : "pgmPhysHandlerRedirectToHC", &pfnHandlerRC);
    198             if (RT_SUCCESS(rc))
    199             {
    200                 rc = PDMR3LdrGetSymbolRCLazy(pVM, pszPfHandlerRC ? pszModRC : NULL, NULL /*pszSearchPath*/,
    201                                              pszPfHandlerRC ? pszPfHandlerRC : "pgmPhysPfHandlerRedirectToHC", &pfnPfHandlerRC);
    202                 AssertMsgRC(rc, ("Failed to resolve %s.%s, rc=%Rrc.\n", pszPfHandlerRC ? pszModRC : VMMRC_MAIN_MODULE_NAME,
    203                                  pszPfHandlerRC ? pszPfHandlerRC : "pgmPhysPfHandlerRedirectToHC", rc));
    204             }
    205             else
    206                 AssertMsgFailed(("Failed to resolve %s.%s, rc=%Rrc.\n", pszHandlerRC ? pszModRC : VMMRC_MAIN_MODULE_NAME,
    207                                  pszHandlerRC ? pszHandlerRC : "pgmPhysHandlerRedirectToHC", rc));
    208 
    209         }
    210         if (RT_SUCCESS(rc))
    211             return PGMR3HandlerPhysicalTypeRegisterEx(pVM, enmKind, fFlags, pfnHandlerR3,
    212                                                       pfnHandlerR0, pfnPfHandlerR0, pszDesc, phType);
    213     }
    214 
    215     return rc;
     103    VM_ASSERT_EMT0_RETURN(pVM, VERR_VM_THREAD_NOT_EMT);
     104    VM_ASSERT_STATE_RETURN(pVM, VMSTATE_CREATING, VERR_VM_INVALID_VM_STATE);
     105
     106    /*
     107     * Do the allocating.
     108     */
     109    PGMPHYSHANDLERTYPE hType = pVM->pgm.s.cPhysHandlerTypes;
     110    AssertLogRelReturn(hType < RT_ELEMENTS(pVM->pgm.s.aPhysHandlerTypes), VERR_OUT_OF_RESOURCES);
     111    PPGMPHYSHANDLERTYPEINTR3 const pType = &pVM->pgm.s.aPhysHandlerTypes[hType];
     112    AssertReturn(pType->enmKind == PGMPHYSHANDLERKIND_INVALID, VERR_PGM_HANDLER_IPE_1);
     113    pVM->pgm.s.cPhysHandlerTypes++;
     114
     115    pType->enmKind          = enmKind;
     116    pType->uState           = enmKind == PGMPHYSHANDLERKIND_WRITE
     117                            ? PGM_PAGE_HNDL_PHYS_STATE_WRITE : PGM_PAGE_HNDL_PHYS_STATE_ALL;
     118    pType->fKeepPgmLock     = RT_BOOL(fFlags & PGMPHYSHANDLER_F_KEEP_PGM_LOCK);
     119    pType->fRing0DevInsIdx  = RT_BOOL(fFlags & PGMPHYSHANDLER_F_R0_DEVINS_IDX);
     120    pType->pfnHandler       = pfnHandler;
     121    pType->pszDesc          = pszDesc;
     122
     123    *phType = pType->hType;
     124    LogFlow(("PGMR3HandlerPhysicalTypeRegisterEx: hType=%#x: enmKind=%d fFlags=%#x pfnHandler=%p pszDesc=%s\n",
     125             hType, enmKind, fFlags, pfnHandler, pszDesc));
     126    return VINF_SUCCESS;
    216127}
    217128
     
    294205    PVM                     pVM       = (PVM)pvUser;
    295206    PPGMPHYSHANDLER         pCur      = (PPGMPHYSHANDLER)pNode;
    296     PPGMPHYSHANDLERTYPEINT  pCurType  = PGMPHYSHANDLER_GET_TYPE(pVM, pCur);
     207    PCPGMPHYSHANDLERTYPEINT pCurType  = PGMPHYSHANDLER_GET_TYPE_NO_NULL(pVM, pCur);
    297208    unsigned                uState    = pCurType->uState;
    298209    PPGMRAMRANGE            pRamHint  = NULL;
     
    365276    pHlp->pfnPrintf(pHlp,
    366277                    "Physical handlers: (PhysHandlers=%d (%#x))\n"
    367                     "%*s %*s %*s %*s uUser              Type     Description\n",
     278                    "%*s %*s %*s uUser             Type     Description\n",
    368279                    pVM->pgm.s.pTreesR3->PhysHandlers, pVM->pgm.s.pTreesR3->PhysHandlers,
    369280                    - (int)sizeof(RTGCPHYS) * 2,     "From",
    370281                    - (int)sizeof(RTGCPHYS) * 2 - 3, "- To (incl)",
    371                     - (int)sizeof(RTHCPTR)  * 2 - 1, "HandlerR3",
    372                     - (int)sizeof(RTHCPTR)  * 2 - 1, "HandlerR0");
     282                    - (int)sizeof(RTHCPTR)  * 2 - 1, "Handler (R3)");
    373283    RTAvlroGCPhysDoWithAll(&pVM->pgm.s.pTreesR3->PhysHandlers, true, pgmR3InfoHandlersPhysicalOne, &Args);
    374284}
     
    384294static DECLCALLBACK(int) pgmR3InfoHandlersPhysicalOne(PAVLROGCPHYSNODECORE pNode, void *pvUser)
    385295{
    386     PPGMPHYSHANDLER        pCur     = (PPGMPHYSHANDLER)pNode;
    387     PPGMHANDLERINFOARG     pArgs    = (PPGMHANDLERINFOARG)pvUser;
    388     PCDBGFINFOHLP          pHlp     = pArgs->pHlp;
    389     PPGMPHYSHANDLERTYPEINT pCurType = PGMPHYSHANDLER_GET_TYPE(pArgs->pVM, pCur);
     296    PPGMPHYSHANDLER         pCur     = (PPGMPHYSHANDLER)pNode;
     297    PPGMHANDLERINFOARG      pArgs    = (PPGMHANDLERINFOARG)pvUser;
     298    PCDBGFINFOHLP           pHlp     = pArgs->pHlp;
     299    PCPGMPHYSHANDLERTYPEINT pCurType = PGMPHYSHANDLER_GET_TYPE_NO_NULL(pArgs->pVM, pCur);
    390300    const char *pszType;
    391301    switch (pCurType->enmKind)
     
    394304        case PGMPHYSHANDLERKIND_WRITE:  pszType = "Write  "; break;
    395305        case PGMPHYSHANDLERKIND_ALL:    pszType = "All    "; break;
    396         default:                        pszType = "????"; break;
     306        default:                        pszType = "???????"; break;
    397307    }
     308
     309    char   szFlags[80];
     310    size_t cchFlags = 0;
     311    if (pCurType->fKeepPgmLock)
     312        cchFlags = RTStrPrintf(szFlags, sizeof(szFlags), "(keep-pgm-lock");
     313    if (pCurType->fRing0DevInsIdx)
     314        cchFlags += RTStrPrintf(&szFlags[cchFlags], sizeof(szFlags) - cchFlags, cchFlags ? ", keep-pgm-lock" : "(keep-pgm-lock");
     315    if (pCurType->fRing0Enabled)
     316        cchFlags += RTStrPrintf(&szFlags[cchFlags], sizeof(szFlags) - cchFlags, cchFlags ? ", r0-enabled)" : "(r0-enabled)");
     317    else
     318        cchFlags += RTStrPrintf(&szFlags[cchFlags], sizeof(szFlags) - cchFlags, cchFlags ? ", r3-only)" : "(r3-only)");
     319
    398320    pHlp->pfnPrintf(pHlp,
    399                     "%RGp - %RGp  %RHv  %RHv  %#018RX64  %s  %s\n",
    400                     pCur->Core.Key, pCur->Core.KeyLast, pCurType->pfnHandlerR3, pCurType->pfnPfHandlerR0, pCur->uUser,
    401                     pszType, pCur->pszDesc);
     321                    "%RGp - %RGp  %p  %016RX64  %s  %s  %s\n",
     322                    pCur->Core.Key, pCur->Core.KeyLast, pCurType->pfnHandler, pCur->uUser, pszType, pCur->pszDesc, szFlags);
    402323#ifdef VBOX_WITH_STATISTICS
    403324    if (pArgs->fStats)
  • trunk/src/VBox/VMM/VMMR3/PGMPhys.cpp

    r93635 r93650  
    22712271    AssertPtrReturn(pszDesc, VERR_INVALID_POINTER);
    22722272    AssertReturn(*pszDesc, VERR_INVALID_PARAMETER);
    2273     Assert(((PPGMPHYSHANDLERTYPEINT)MMHyperHeapOffsetToPtr(pVM, hType))->enmKind == PGMPHYSHANDLERKIND_MMIO);
     2273#ifdef VBOX_STRICT
     2274    PCPGMPHYSHANDLERTYPEINT pType = pgmHandlerPhysicalTypeHandleToPtr(pVM, hType);
     2275    Assert(pType);
     2276    Assert(pType->enmKind == PGMPHYSHANDLERKIND_MMIO);
     2277#endif
    22742278
    22752279    int rc = PGM_LOCK(pVM);
  • trunk/src/VBox/VMM/VMMR3/PGMPool.cpp

    r93635 r93650  
    284284    pPool->hAccessHandlerType = NIL_PGMPHYSHANDLERTYPE;
    285285    rc = PGMR3HandlerPhysicalTypeRegister(pVM, PGMPHYSHANDLERKIND_WRITE, PGMPHYSHANDLER_F_KEEP_PGM_LOCK,
    286                                           pgmPoolAccessHandler,
    287                                           NULL, "pgmPoolAccessHandler", "pgmRZPoolAccessPfHandler",
    288                                           NULL, "pgmPoolAccessHandler", "pgmRZPoolAccessPfHandler",
    289                                           "Guest Paging Access Handler",
    290                                           &pPool->hAccessHandlerType);
     286                                          pgmPoolAccessHandler, "Guest Paging Access Handler", &pPool->hAccessHandlerType);
    291287    AssertLogRelRCReturn(rc, rc);
    292288
  • trunk/src/VBox/VMM/include/GIMInternal.h

    r93115 r93650  
    5151    /** Physical access handler type for semi-read-only MMIO2 memory. Lazy creation. */
    5252    PGMPHYSHANDLERTYPE              hSemiReadOnlyMmio2Handler;
    53     /** Alignment padding. */
    54     uint32_t                        u32Padding;
    5553
    5654    /** Pointer to the GIM device - R3 ptr. */
  • trunk/src/VBox/VMM/include/IEMInternal.h

    r93115 r93650  
    552552    /** The error code for the current exception / interrupt. */
    553553    uint32_t                uCurXcptErr;
    554     /** The VMX APIC-access page handler type. */
    555     PGMPHYSHANDLERTYPE      hVmxApicAccessPage;
    556554
    557555    /** @name Statistics
     
    725723# define IEM_GET_INSTR_LEN(a_pVCpu)     ((a_pVCpu)->iem.s.offOpcode)
    726724#endif
     725
     726
     727/**
     728 * Shared per-VM IEM data.
     729 */
     730typedef struct IEM
     731{
     732    /** The VMX APIC-access page handler type. */
     733    PGMPHYSHANDLERTYPE      hVmxApicAccessPage;
     734} IEM;
     735
    727736
    728737
  • trunk/src/VBox/VMM/include/IOMInternal.h

    r93115 r93650  
    571571
    572572#ifndef IN_RING3
    573 DECLEXPORT(FNPGMRZPHYSPFHANDLER)    iomMmioPfHandlerNew;
    574 #endif
    575 PGM_ALL_CB2_PROTO(FNPGMPHYSHANDLER) iomMmioHandlerNew;
     573DECLCALLBACK(FNPGMRZPHYSPFHANDLER)  iomMmioPfHandlerNew;
     574#endif
     575DECLCALLBACK(FNPGMPHYSHANDLER)      iomMmioHandlerNew;
    576576
    577577/* IOM locking helpers. */
  • trunk/src/VBox/VMM/include/PGMInline.h

    r93554 r93650  
    992992
    993993/**
     994 * Converts a handle to a pointer.
     995 *
     996 * @returns Pointer on success, NULL on failure (asserted).
     997 * @param   pVM     The cross context VM structure.
     998 * @param   hType   Physical access handler type handle.
     999 */
     1000DECLINLINE(PCPGMPHYSHANDLERTYPEINT) pgmHandlerPhysicalTypeHandleToPtr(PVMCC pVM, PGMPHYSHANDLERTYPE hType)
     1001{
     1002#ifdef IN_RING0
     1003    PPGMPHYSHANDLERTYPEINT pType = &pVM->pgmr0.s.aPhysHandlerTypes[hType & PGMPHYSHANDLERTYPE_IDX_MASK];
     1004#elif defined(IN_RING3)
     1005    PPGMPHYSHANDLERTYPEINT pType = &pVM->pgm.s.aPhysHandlerTypes[hType & PGMPHYSHANDLERTYPE_IDX_MASK];
     1006#else
     1007# error "Invalid context"
     1008#endif
     1009    AssertReturn(pType->hType == hType, NULL);
     1010    return pType;
     1011}
     1012
     1013
     1014/**
     1015 * Converts a handle to a pointer, never returns NULL.
     1016 *
     1017 * @returns Pointer on success, dummy on failure (asserted).
     1018 * @param   pVM     The cross context VM structure.
     1019 * @param   hType   Physical access handler type handle.
     1020 */
     1021DECLINLINE(PCPGMPHYSHANDLERTYPEINT) pgmHandlerPhysicalTypeHandleToPtr2(PVMCC pVM, PGMPHYSHANDLERTYPE hType)
     1022{
     1023#ifdef IN_RING0
     1024    PPGMPHYSHANDLERTYPEINT pType = &pVM->pgmr0.s.aPhysHandlerTypes[hType & PGMPHYSHANDLERTYPE_IDX_MASK];
     1025#elif defined(IN_RING3)
     1026    PPGMPHYSHANDLERTYPEINT pType = &pVM->pgm.s.aPhysHandlerTypes[hType & PGMPHYSHANDLERTYPE_IDX_MASK];
     1027#else
     1028# error "Invalid context"
     1029#endif
     1030    AssertReturn(pType->hType == hType, &g_pgmHandlerPhysicalDummyType);
     1031    return pType;
     1032}
     1033
     1034
     1035/**
    9941036 * Internal worker for finding a 'in-use' shadow page give by it's physical address.
    9951037 *
  • trunk/src/VBox/VMM/include/PGMInternal.h

    r93635 r93650  
    483483
    484484
    485 /**
    486  * Physical page access handler type registration.
    487  */
    488 typedef struct PGMPHYSHANDLERTYPEINT
    489 {
    490     /** Number of references.   */
    491     uint32_t volatile                   cRefs;
    492     /** Magic number (PGMPHYSHANDLERTYPEINT_MAGIC). */
    493     uint32_t                            u32Magic;
    494     /** Link of handler types anchored in PGMTREES::HeadPhysHandlerTypes.   */
    495     RTLISTOFF32NODE                     ListNode;
     485/** The physical access handler type handle count (power of two). */
     486#define PGMPHYSHANDLERTYPE_COUNT        0x20
     487/** Mask for getting the array index from an access handler type handle.
     488 * The other handle bits are random and non-zero to avoid mixups due to zero
     489 * initialized fields. */
     490#define PGMPHYSHANDLERTYPE_IDX_MASK     0x1f
     491
     492/**
     493 * Physical page access handler type registration, ring-0 part.
     494 */
     495typedef struct PGMPHYSHANDLERTYPEINTR0
     496{
     497    /** The handle value for verfication.  */
     498    PGMPHYSHANDLERTYPE                  hType;
    496499    /** The kind of accesses we're handling. */
    497500    PGMPHYSHANDLERKIND                  enmKind;
     
    506509    bool                                fRing0DevInsIdx;
    507510    bool                                afPadding[1];
    508     /** Pointer to R3 callback function. */
    509     R3PTRTYPE(PFNPGMPHYSHANDLER)        pfnHandlerR3;
    510     /** Pointer to R0 callback function. */
    511     R0PTRTYPE(PFNPGMPHYSHANDLER)        pfnHandlerR0;
    512     /** Pointer to R0 callback function for \#PFs. */
    513     R0PTRTYPE(PFNPGMRZPHYSPFHANDLER)    pfnPfHandlerR0;
     511    /** Pointer to the ring-0 callback function. */
     512    R0PTRTYPE(PFNPGMPHYSHANDLER)        pfnHandler;
     513    /** Pointer to the ring-9 callback function for \#PFs. */
     514    R0PTRTYPE(PFNPGMRZPHYSPFHANDLER)    pfnPfHandler;
     515    /** Description / Name. For easing debugging. */
     516    R0PTRTYPE(const char *)             pszDesc;
     517} PGMPHYSHANDLERTYPEINTR0;
     518/** Pointer to a physical access handler type registration. */
     519typedef PGMPHYSHANDLERTYPEINTR0 *PPGMPHYSHANDLERTYPEINTR0;
     520
     521/**
     522 * Physical page access handler type registration, shared/ring-3 part.
     523 */
     524typedef struct PGMPHYSHANDLERTYPEINTR3
     525{
     526    /** The handle value for verfication.  */
     527    PGMPHYSHANDLERTYPE                  hType;
     528    /** The kind of accesses we're handling. */
     529    PGMPHYSHANDLERKIND                  enmKind;
     530    /** The PGM_PAGE_HNDL_PHYS_STATE_XXX value corresponding to enmKind. */
     531    uint8_t                             uState;
     532    /** Whether to keep the PGM lock when calling the handler.
     533     * @sa PGMPHYSHANDLER_F_KEEP_PGM_LOCK  */
     534    bool                                fKeepPgmLock;
     535    /** Set if this is registered by a device instance and uUser should be
     536     * translated from a device instance ID to a pointer.
     537     * @sa PGMPHYSHANDLER_F_R0_DEVINS_IDX  */
     538    bool                                fRing0DevInsIdx;
     539    /** Set by ring-0 if the handler is ring-0 enabled (for debug). */
     540    bool                                fRing0Enabled : 1;
     541    /** Pointer to the ring-3 callback function. */
     542    R3PTRTYPE(PFNPGMPHYSHANDLER)        pfnHandler;
    514543    /** Description / Name. For easing debugging. */
    515544    R3PTRTYPE(const char *)             pszDesc;
    516 } PGMPHYSHANDLERTYPEINT;
     545} PGMPHYSHANDLERTYPEINTR3;
    517546/** Pointer to a physical access handler type registration. */
    518 typedef PGMPHYSHANDLERTYPEINT *PPGMPHYSHANDLERTYPEINT;
    519 /** Magic value for the physical handler callbacks (Robert A. Heinlein). */
    520 #define PGMPHYSHANDLERTYPEINT_MAGIC        UINT32_C(0x19070707)
    521 /** Magic value for the physical handler callbacks. */
    522 #define PGMPHYSHANDLERTYPEINT_MAGIC_DEAD   UINT32_C(0x19880508)
    523 
    524 /**
    525  * Converts a handle to a pointer.
    526  * @returns PPGMPHYSHANDLERTYPEINT
    527  * @param   a_pVM           The cross context VM structure.
    528  * @param   a_hType         Physical access handler type handle.
    529  */
    530 #define PGMPHYSHANDLERTYPEINT_FROM_HANDLE(a_pVM, a_hType) ((PPGMPHYSHANDLERTYPEINT)MMHyperHeapOffsetToPtr(a_pVM, a_hType))
     547typedef PGMPHYSHANDLERTYPEINTR3 *PPGMPHYSHANDLERTYPEINTR3;
     548
     549/** Pointer to a physical access handler type record for the current context. */
     550typedef CTX_SUFF(PPGMPHYSHANDLERTYPEINT) PPGMPHYSHANDLERTYPEINT;
     551/** Pointer to a const physical access handler type record for the current context. */
     552typedef CTX_SUFF(PGMPHYSHANDLERTYPEINT) const *PCPGMPHYSHANDLERTYPEINT;
     553/** Dummy physical access handler type record. */
     554extern CTX_SUFF(PGMPHYSHANDLERTYPEINT) const g_pgmHandlerPhysicalDummyType;
    531555
    532556
     
    546570    /** Set if we have pages that have temporarily been disabled. */
    547571    uint32_t                            cTmpOffPages;
    548     /** Registered handler type handle (heap offset). */
    549     PGMPHYSHANDLERTYPE                  hType;
     572    uint32_t                            u32Padding;
     573    /** Registered handler type handle.
     574     * @note Marked volatile to prevent re-reading after validation. */
     575    PGMPHYSHANDLERTYPE volatile         hType;
    550576    /** User argument for the handlers. */
    551577    uint64_t                            uUser;
     
    562588/**
    563589 * Gets the type record for a physical handler (no reference added).
    564  * @returns PPGMPHYSHANDLERTYPEINT
     590 * @returns PCPGMPHYSHANDLERTYPEINT, can be NULL
    565591 * @param   a_pVM           The cross context VM structure.
    566592 * @param   a_pPhysHandler  Pointer to the physical handler structure
    567593 *                          (PGMPHYSHANDLER).
    568594 */
    569 #define PGMPHYSHANDLER_GET_TYPE(a_pVM, a_pPhysHandler) PGMPHYSHANDLERTYPEINT_FROM_HANDLE(a_pVM, (a_pPhysHandler)->hType)
     595#define PGMPHYSHANDLER_GET_TYPE(a_pVM, a_pPhysHandler) \
     596    pgmHandlerPhysicalTypeHandleToPtr(a_pVM, (a_pPhysHandler) ? (a_pPhysHandler)->hType : NIL_PGMPHYSHANDLERTYPE)
     597
     598/**
     599 * Gets the type record for a physical handler, never returns NULL.
     600 *
     601 * @returns PCPGMPHYSHANDLERTYPEINT, never NULL.
     602 * @param   a_pVM           The cross context VM structure.
     603 * @param   a_pPhysHandler  Pointer to the physical handler structure
     604 *                          (PGMPHYSHANDLER).
     605 */
     606#define PGMPHYSHANDLER_GET_TYPE_NO_NULL(a_pVM, a_pPhysHandler) \
     607    pgmHandlerPhysicalTypeHandleToPtr2(a_pVM, (a_pPhysHandler) ? (a_pPhysHandler)->hType : NIL_PGMPHYSHANDLERTYPE)
    570608
    571609
     
    20342072    /** The current number of modified pages. */
    20352073    uint16_t                    cModifiedPages;
     2074    /** Alignment padding. */
     2075    uint32_t                    u32Padding2;
    20362076    /** Physical access handler type registration handle. */
    20372077    PGMPHYSHANDLERTYPE          hAccessHandlerType;
     
    23302370typedef struct PGMTREES
    23312371{
    2332     /** List of physical access handler types (offset pointers) of type
    2333      * PGMPHYSHANDLERTYPEINT.  This is needed for relocations. */
    2334     RTLISTOFF32ANCHOR               HeadPhysHandlerTypes;
    23352372    /** Physical access handlers (AVL range+offsetptr tree). */
    23362373    AVLROGCPHYSTREE                 PhysHandlers;
     2374    uint32_t                        u32PaddingTo8Bytes;
    23372375} PGMTREES;
    23382376/** Pointer to PGM trees. */
     
    29542992     *  owner via pgmPhysGCPhys2CCPtrInternalDepr. */
    29552993    uint32_t                        cDeprecatedPageLocks;
    2956     /** Alignment padding. */
    2957     uint32_t                        au32Alignment2[1+2];
     2994
     2995    /** Registered physical access handler types. */
     2996    uint32_t                        cPhysHandlerTypes;
     2997    /** Physical access handler types.
     2998     * Initialized to callback causing guru meditations and invalid enmKind. */
     2999    PGMPHYSHANDLERTYPEINTR3         aPhysHandlerTypes[PGMPHYSHANDLERTYPE_COUNT];
    29583000
    29593001    /** PGM critical section.
     
    35373579     * @{ */
    35383580    /** Critical section for serializing pool growth. */
    3539     RTCRITSECT  PoolGrowCritSect;
     3581    RTCRITSECT                      PoolGrowCritSect;
    35403582    /** The memory objects for the pool pages. */
    3541     RTR0MEMOBJ  ahPoolMemObjs[(PGMPOOL_IDX_LAST + PGMPOOL_CFG_MAX_GROW - 1) / PGMPOOL_CFG_MAX_GROW];
     3583    RTR0MEMOBJ                      ahPoolMemObjs[(PGMPOOL_IDX_LAST + PGMPOOL_CFG_MAX_GROW - 1) / PGMPOOL_CFG_MAX_GROW];
    35423584    /** The ring-3 mapping objects for the pool pages. */
    3543     RTR0MEMOBJ  ahPoolMapObjs[(PGMPOOL_IDX_LAST + PGMPOOL_CFG_MAX_GROW - 1) / PGMPOOL_CFG_MAX_GROW];
     3585    RTR0MEMOBJ                      ahPoolMapObjs[(PGMPOOL_IDX_LAST + PGMPOOL_CFG_MAX_GROW - 1) / PGMPOOL_CFG_MAX_GROW];
    35443586    /** @} */
     3587
     3588    /** Physical access handler types for ring-0.
     3589     * Initialized to callback causing return to ring-3 and invalid enmKind. */
     3590    PGMPHYSHANDLERTYPEINTR0         aPhysHandlerTypes[PGMPHYSHANDLERTYPE_COUNT];
    35453591} PGMR0PERVM;
    35463592
     
    35833629DECLHIDDEN(int) pgmHandlerPhysicalResetMmio2WithBitmap(PVMCC pVM, RTGCPHYS GCPhys, void *pvBitmap, uint32_t offBitmap);
    35843630DECLCALLBACK(void) pgmR3InfoHandlers(PVM pVM, PCDBGFINFOHLP pHlp, const char *pszArgs);
     3631DECLCALLBACK(FNPGMPHYSHANDLER)      pgmR3HandlerPhysicalHandlerInvalid;
     3632#ifndef IN_RING3
     3633DECLCALLBACK(FNPGMPHYSHANDLER)      pgmR0HandlerPhysicalHandlerToRing3;
     3634DECLCALLBACK(FNPGMRZPHYSPFHANDLER)  pgmR0HandlerPhysicalPfHandlerToRing3;
     3635#endif
     3636
    35853637int             pgmR3InitSavedState(PVM pVM, uint64_t cbRam);
    35863638
     
    36063658int             pgmPhysGCPhys2CCPtrInternalReadOnly(PVMCC pVM, PPGMPAGE pPage, RTGCPHYS GCPhys, const void **ppv, PPGMPAGEMAPLOCK pLock);
    36073659void            pgmPhysReleaseInternalPageMappingLock(PVMCC pVM, PPGMPAGEMAPLOCK pLock);
    3608 PGM_ALL_CB2_PROTO(FNPGMPHYSHANDLER) pgmPhysRomWriteHandler;
    3609 PGM_ALL_CB2_PROTO(FNPGMPHYSHANDLER) pgmPhysMmio2WriteHandler;
     3660DECLCALLBACK(FNPGMPHYSHANDLER)      pgmPhysRomWriteHandler;
     3661DECLCALLBACK(FNPGMPHYSHANDLER)      pgmPhysMmio2WriteHandler;
    36103662#ifndef IN_RING3
    3611 DECLEXPORT(FNPGMPHYSHANDLER)        pgmPhysHandlerRedirectToHC;
    3612 DECLEXPORT(FNPGMRZPHYSPFHANDLER)    pgmPhysPfHandlerRedirectToHC;
    3613 DECLEXPORT(FNPGMRZPHYSPFHANDLER)    pgmPhysRomWritePfHandler;
    3614 DECLEXPORT(FNPGMRZPHYSPFHANDLER)    pgmPhysMmio2WritePfHandler;
     3663DECLCALLBACK(FNPGMRZPHYSPFHANDLER)  pgmPhysRomWritePfHandler;
     3664DECLCALLBACK(FNPGMRZPHYSPFHANDLER)  pgmPhysMmio2WritePfHandler;
    36153665#endif
    36163666int             pgmPhysFreePage(PVM pVM, PGMMFREEPAGESREQ pReq, uint32_t *pcPendingPages, PPGMPAGE pPage, RTGCPHYS GCPhys,
     
    36483698
    36493699#endif /* IN_RING3 */
     3700#ifdef IN_RING0
     3701int             pgmR0PoolInitVM(PGVM pGVM);
     3702#endif
    36503703int             pgmPoolAlloc(PVMCC pVM, RTGCPHYS GCPhys, PGMPOOLKIND enmKind, PGMPOOLACCESS enmAccess, bool fA20Enabled,
    36513704                             uint16_t iUser, uint32_t iUserTable, bool fLockPage, PPPGMPOOLPAGE ppPage);
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