VirtualBox

Changeset 104767 in vbox for trunk/src


Ignore:
Timestamp:
May 23, 2024 12:03:04 PM (8 months ago)
Author:
vboxsync
Message:

VMM/PGM,IOM,PDM: MMIO cleanups. bugref:10687

Location:
trunk/src/VBox/VMM
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/PGMAllBth.h

    r103374 r104767  
    23122312                else /* MMIO or invalid page: emulated in #PF handler. */
    23132313                {
    2314                     LogFlow(("PGM_GCPHYS_2_PTR %RGp failed with %Rrc\n", GCPhys, rc));
     2314                    LogFlow(("PGM_GCPHYS_2_PTR_V2 %RGp failed with %Rrc\n", GCPhys, rc));
    23152315                    Assert(!SHW_PTE_IS_P(pPTDst->a[(GCPtrPage >> SHW_PT_SHIFT) & SHW_PT_MASK]));
    23162316                }
     
    24092409                else
    24102410                {
    2411                     LogFlow(("PGM_GCPHYS_2_PTR %RGp (big) failed with %Rrc\n", GCPhys, rc));
     2411                    LogFlow(("pgmPhysGetPageEx %RGp (big) failed with %Rrc\n", GCPhys, rc));
    24122412                    /** @todo must wipe the shadow page table entry in this
    24132413                     *        case. */
  • trunk/src/VBox/VMM/VMMAll/PGMAllGst.h

    r104548 r104767  
    123123 * @param   pWalk       The page walk info.
    124124 * @param   pGstWalk    The guest mode specific page walk info.
     125 * @thread  EMT(pVCpu)
    125126 */
    126127DECLINLINE(int) PGM_GST_NAME(Walk)(PVMCPUCC pVCpu, RTGCPTR GCPtr, PPGMPTWALK pWalk, PGSTPTWALK pGstWalk)
     
    361362 * Gets effective Guest OS page information.
    362363 *
    363  * When GCPtr is in a big page, the function will return as if it was a normal
    364  * 4KB page. If the need for distinguishing between big and normal page becomes
    365  * necessary at a later point, a PGMGstGetPage Ex() will be created for that
    366  * purpose.
    367  *
    368364 * @returns VBox status code.
    369365 * @param   pVCpu       The cross context virtual CPU structure.
    370366 * @param   GCPtr       Guest Context virtual address of the page.
    371367 * @param   pWalk       Where to store the page walk info.
     368 * @thread  EMT(pVCpu)
    372369 */
    373370PGM_GST_DECL(int, GetPage)(PVMCPUCC pVCpu, RTGCPTR GCPtr, PPGMPTWALK pWalk)
     
    376373 || PGM_GST_TYPE == PGM_TYPE_PROT
    377374
    378     RT_ZERO(*pWalk);
    379375# ifdef VBOX_WITH_NESTED_HWVIRT_VMX_EPT
    380376    if (pVCpu->pgm.s.enmGuestSlatMode == PGMSLAT_EPT)
     
    385381        if (RT_SUCCESS(rc))
    386382        {
     383            RT_ZERO(*pWalk);
    387384            pWalk->fSucceeded = true;
    388385            pWalk->GCPtr      = GCPtr;
     
    399396     * Fake it.
    400397     */
     398    RT_ZERO(*pWalk);
    401399    pWalk->fSucceeded = true;
    402400    pWalk->GCPtr      = GCPtr;
     
    427425                 ;
    428426    else
    429     {
    430427        fFlags = (GstWalk.Pde.u & ~(GST_PTE_PG_MASK | X86_PDE4M_RW | X86_PDE4M_US | X86_PDE4M_PS))   /* NX not needed */
    431428               | (pWalk->fEffective & (PGM_PTATTRS_W_MASK | PGM_PTATTRS_US_MASK | PGM_PTATTRS_PAT_MASK))
     
    434431# endif
    435432               ;
    436     }
    437433
    438434    pWalk->GCPhys    &= ~(RTGCPHYS)GUEST_PAGE_OFFSET_MASK;
  • trunk/src/VBox/VMM/VMMR3/IOMR3Mmio.cpp

    r98103 r104767  
    355355 * Worker for PDMDEVHLPR3::pfnMmioMap.
    356356 */
    357 VMMR3_INT_DECL(int)  IOMR3MmioMap(PVM pVM, PPDMDEVINS pDevIns, IOMMMIOHANDLE hRegion, RTGCPHYS GCPhys)
     357VMMR3_INT_DECL(int)  IOMR3MmioMap(PVM pVM, PVMCPU pVCpu, PPDMDEVINS pDevIns, IOMMMIOHANDLE hRegion, RTGCPHYS GCPhys)
    358358{
    359359    /*
    360360     * Validate input and state.
    361361     */
     362    VMCPU_ASSERT_EMT_RETURN(pVCpu, VERR_VM_THREAD_NOT_EMT);
    362363    AssertPtrReturn(pDevIns, VERR_INVALID_HANDLE);
    363364    AssertReturn(hRegion < pVM->iom.s.cMmioRegs, VERR_IOM_INVALID_MMIO_HANDLE);
     
    408409                        /* Register with PGM before we shuffle the array: */
    409410                        ASMAtomicWriteU64(&pRegEntry->GCPhysMapping, GCPhys);
    410                         rc = PGMR3PhysMMIORegister(pVM, GCPhys, cbRegion, pVM->iom.s.hNewMmioHandlerType,
     411                        rc = PGMR3PhysMmioRegister(pVM, pVCpu, GCPhys, cbRegion, pVM->iom.s.hNewMmioHandlerType,
    411412                                                   hRegion, pRegEntry->pszDesc);
    412413                        AssertRCReturnStmt(rc, ASMAtomicWriteU64(&pRegEntry->GCPhysMapping, NIL_RTGCPHYS); IOM_UNLOCK_EXCL(pVM), rc);
     
    427428                        /* Register with PGM before we shuffle the array: */
    428429                        ASMAtomicWriteU64(&pRegEntry->GCPhysMapping, GCPhys);
    429                         rc = PGMR3PhysMMIORegister(pVM, GCPhys, cbRegion, pVM->iom.s.hNewMmioHandlerType,
     430                        rc = PGMR3PhysMmioRegister(pVM, pVCpu, GCPhys, cbRegion, pVM->iom.s.hNewMmioHandlerType,
    430431                                                   hRegion, pRegEntry->pszDesc);
    431432                        AssertRCReturnStmt(rc, ASMAtomicWriteU64(&pRegEntry->GCPhysMapping, NIL_RTGCPHYS); IOM_UNLOCK_EXCL(pVM), rc);
     
    454455            /* First entry in the lookup table: */
    455456            ASMAtomicWriteU64(&pRegEntry->GCPhysMapping, GCPhys);
    456             rc = PGMR3PhysMMIORegister(pVM, GCPhys, cbRegion, pVM->iom.s.hNewMmioHandlerType, hRegion, pRegEntry->pszDesc);
     457            rc = PGMR3PhysMmioRegister(pVM, pVCpu, GCPhys, cbRegion, pVM->iom.s.hNewMmioHandlerType, hRegion, pRegEntry->pszDesc);
    457458            AssertRCReturnStmt(rc, ASMAtomicWriteU64(&pRegEntry->GCPhysMapping, NIL_RTGCPHYS); IOM_UNLOCK_EXCL(pVM), rc);
    458459
     
    507508 * Worker for PDMDEVHLPR3::pfnMmioUnmap.
    508509 */
    509 VMMR3_INT_DECL(int)  IOMR3MmioUnmap(PVM pVM, PPDMDEVINS pDevIns, IOMMMIOHANDLE hRegion)
     510VMMR3_INT_DECL(int) IOMR3MmioUnmap(PVM pVM, PVMCPU pVCpu, PPDMDEVINS pDevIns, IOMMMIOHANDLE hRegion)
    510511{
    511512    /*
    512513     * Validate input and state.
    513514     */
     515    VMCPU_ASSERT_EMT_RETURN(pVCpu, VERR_VM_THREAD_NOT_EMT);
    514516    AssertPtrReturn(pDevIns, VERR_INVALID_HANDLE);
    515517    AssertReturn(hRegion < pVM->iom.s.cMmioRegs, VERR_IOM_INVALID_MMIO_HANDLE);
     
    570572                pVM->iom.s.cMmioLookupEntries = cEntries - 1;
    571573
    572                 rc = PGMR3PhysMMIODeregister(pVM, GCPhys, pRegEntry->cbRegion);
     574                rc = PGMR3PhysMmioDeregister(pVM, pVCpu, GCPhys, pRegEntry->cbRegion);
    573575                AssertRC(rc);
    574576
  • trunk/src/VBox/VMM/VMMR3/PDMDevHlp.cpp

    r100399 r104767  
    218218    PDMDEV_ASSERT_DEVINS(pDevIns);
    219219    LogFlow(("pdmR3DevHlp_MmioMap: caller='%s'/%d: hRegion=%#x GCPhys=%#RGp\n", pDevIns->pReg->szName, pDevIns->iInstance, hRegion, GCPhys));
    220     PVM pVM = pDevIns->Internal.s.pVMR3;
    221     VM_ASSERT_EMT_RETURN(pVM, VERR_VM_THREAD_NOT_EMT);
    222 
    223     int rc = IOMR3MmioMap(pVM, pDevIns, hRegion, GCPhys);
     220
     221    PVM    const pVM   = pDevIns->Internal.s.pVMR3;
     222    PVMCPU const pVCpu = VMMGetCpu(pVM);
     223    AssertReturn(pVCpu, VERR_VM_THREAD_NOT_EMT);
     224
     225    int rc = IOMR3MmioMap(pVM, pVCpu, pDevIns, hRegion, GCPhys);
    224226
    225227    LogFlow(("pdmR3DevHlp_MmioMap: caller='%s'/%d: returns %Rrc\n", pDevIns->pReg->szName, pDevIns->iInstance, rc));
     
    233235    PDMDEV_ASSERT_DEVINS(pDevIns);
    234236    LogFlow(("pdmR3DevHlp_MmioUnmap: caller='%s'/%d: hRegion=%#x\n", pDevIns->pReg->szName, pDevIns->iInstance, hRegion));
    235     PVM pVM = pDevIns->Internal.s.pVMR3;
    236     VM_ASSERT_EMT_RETURN(pVM, VERR_VM_THREAD_NOT_EMT);
    237 
    238     int rc = IOMR3MmioUnmap(pVM, pDevIns, hRegion);
     237
     238    PVM    const pVM   = pDevIns->Internal.s.pVMR3;
     239    PVMCPU const pVCpu = VMMGetCpu(pVM);
     240    AssertReturn(pVCpu, VERR_VM_THREAD_NOT_EMT);
     241
     242    int rc = IOMR3MmioUnmap(pVM, pVCpu, pDevIns, hRegion);
    239243
    240244    LogFlow(("pdmR3DevHlp_MmioUnmap: caller='%s'/%d: returns %Rrc\n", pDevIns->pReg->szName, pDevIns->iInstance, rc));
  • trunk/src/VBox/VMM/VMMR3/PDMDevHlpTracing.cpp

    r98103 r104767  
    306306    PDMDEV_ASSERT_DEVINS(pDevIns);
    307307    LogFlow(("pdmR3DevHlp_MmioMap: caller='%s'/%d: hRegion=%#x GCPhys=%#RGp\n", pDevIns->pReg->szName, pDevIns->iInstance, hRegion, GCPhys));
    308     PVM pVM = pDevIns->Internal.s.pVMR3;
    309     VM_ASSERT_EMT_RETURN(pVM, VERR_VM_THREAD_NOT_EMT);
    310 
    311     int rc = IOMR3MmioMap(pVM, pDevIns, hRegion, GCPhys);
     308
     309    PVM    const pVM   = pDevIns->Internal.s.pVMR3;
     310    PVMCPU const pVCpu = VMMGetCpu(pVM);
     311    AssertReturn(pVCpu, VERR_VM_THREAD_NOT_EMT);
     312
     313    int rc = IOMR3MmioMap(pVM, pVCpu, pDevIns, hRegion, GCPhys);
    312314    DBGFTracerEvtMmioMap(pVM, pDevIns->Internal.s.hDbgfTraceEvtSrc, hRegion, GCPhys);
    313315
     
    322324    PDMDEV_ASSERT_DEVINS(pDevIns);
    323325    LogFlow(("pdmR3DevHlp_MmioUnmap: caller='%s'/%d: hRegion=%#x\n", pDevIns->pReg->szName, pDevIns->iInstance, hRegion));
    324     PVM pVM = pDevIns->Internal.s.pVMR3;
    325     VM_ASSERT_EMT_RETURN(pVM, VERR_VM_THREAD_NOT_EMT);
    326 
    327     int rc = IOMR3MmioUnmap(pVM, pDevIns, hRegion);
     326
     327    PVM    const pVM   = pDevIns->Internal.s.pVMR3;
     328    PVMCPU const pVCpu = VMMGetCpu(pVM);
     329    AssertReturn(pVCpu, VERR_VM_THREAD_NOT_EMT);
     330
     331    int rc = IOMR3MmioUnmap(pVM, pVCpu, pDevIns, hRegion);
    328332    DBGFTracerEvtMmioUnmap(pVM, pDevIns->Internal.s.hDbgfTraceEvtSrc, hRegion);
    329333
  • trunk/src/VBox/VMM/VMMR3/PGMPhys.cpp

    r103299 r104767  
    22762276 *
    22772277 * @param   pVM             The cross context VM structure.
     2278 * @param   pVCpu           The cross context virtual CPU structure of the calling EMT.
    22782279 * @param   GCPhys          The start of the MMIO region.
    22792280 * @param   cb              The size of the MMIO region.
     
    22812282 * @param   uUser           The user argument.
    22822283 * @param   pszDesc         The description of the MMIO region.
    2283  */
    2284 VMMR3DECL(int) PGMR3PhysMMIORegister(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, PGMPHYSHANDLERTYPE hType,
    2285                                      uint64_t uUser, const char *pszDesc)
     2284 * @thread  EMT(pVCpu)
     2285 */
     2286VMMR3_INT_DECL(int) PGMR3PhysMmioRegister(PVM pVM, PVMCPU pVCpu, RTGCPHYS GCPhys, RTGCPHYS cb, PGMPHYSHANDLERTYPE hType,
     2287                                          uint64_t uUser, const char *pszDesc)
    22862288{
    22872289    /*
    22882290     * Assert on some assumption.
    22892291     */
    2290     VM_ASSERT_EMT(pVM);
     2292    VMCPU_ASSERT_EMT(pVCpu);
    22912293    AssertReturn(!(cb & GUEST_PAGE_OFFSET_MASK), VERR_INVALID_PARAMETER);
    22922294    AssertReturn(!(GCPhys & GUEST_PAGE_OFFSET_MASK), VERR_INVALID_PARAMETER);
     
    23632365         *   care of this internally (not touch mapped mmio while changing the
    23642366         *   mapping). */
    2365         PVMCPU pVCpu = VMMGetCpu(pVM);
    23662367        pVCpu->pgm.s.fSyncFlags |= PGM_SYNC_CLEAR_PGM_POOL;
    23672368        VMCPU_FF_SET(pVCpu, VMCPU_FF_PGM_SYNC_CR3);
     
    23752376         * PGMHandlerPhysicalRegisterEx will do that for us.
    23762377         */
    2377         Log(("PGMR3PhysMMIORegister: Adding ad hoc MMIO range for %RGp-%RGp %s\n", GCPhys, GCPhysLast, pszDesc));
     2378        Log(("PGMR3PhysMmioRegister: Adding ad hoc MMIO range for %RGp-%RGp %s\n", GCPhys, GCPhysLast, pszDesc));
    23782379
    23792380        /* Alloc. */
     
    24692470 * @returns VBox status code.
    24702471 * @param   pVM             The cross context VM structure.
     2472 * @param   pVCpu           The cross context virtual CPU structure of the calling EMT.
    24712473 * @param   GCPhys          The start of the MMIO region.
    24722474 * @param   cb              The size of the MMIO region.
    2473  */
    2474 VMMR3DECL(int) PGMR3PhysMMIODeregister(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb)
    2475 {
    2476     VM_ASSERT_EMT(pVM);
     2475 * @thread  EMT(pVCpu)
     2476 */
     2477VMMR3_INT_DECL(int) PGMR3PhysMmioDeregister(PVM pVM, PVMCPU pVCpu, RTGCPHYS GCPhys, RTGCPHYS cb)
     2478{
     2479    VMCPU_ASSERT_EMT(pVCpu);
    24772480
    24782481    int rc = PGM_LOCK(pVM);
     
    25232526                     * Ad-hoc range, unlink and free it.
    25242527                     */
    2525                     Log(("PGMR3PhysMMIODeregister: Freeing ad hoc MMIO range for %RGp-%RGp %s\n",
     2528                    Log(("PGMR3PhysMmioDeregister: Freeing ad hoc MMIO range for %RGp-%RGp %s\n",
    25262529                         GCPhys, GCPhysLast, pRam->pszDesc));
    25272530                    /** @todo check the ad-hoc flags? */
     
    26002603    /** @todo Not entirely SMP safe; assuming for now the guest takes care of
    26012604     *       this internally (not touch mapped mmio while changing the mapping). */
    2602     PVMCPU pVCpu = VMMGetCpu(pVM);
    26032605    pVCpu->pgm.s.fSyncFlags |= PGM_SYNC_CLEAR_PGM_POOL;
    26042606    VMCPU_FF_SET(pVCpu, VMCPU_FF_PGM_SYNC_CR3);
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