VirtualBox

Changeset 60852 in vbox for trunk


Ignore:
Timestamp:
May 5, 2016 5:47:40 PM (9 years ago)
Author:
vboxsync
Message:

IOM: New way of defer RC+R0 MMIO writes (only used for IEM accesses).

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/IOMAll.cpp

    r60847 r60852  
    439439static VBOXSTRICTRC iomIOPortRing3WritePending(PVMCPU pVCpu, RTIOPORT Port, uint32_t u32Value, size_t cbValue)
    440440{
     441    Log(("iomIOPortRing3WritePending: %#x LB %u -> %RTiop\n", u32Value, cbValue, Port));
    441442    AssertReturn(pVCpu->iom.s.PendingIOPortWrite.cbValue == 0, VERR_IOM_IOPORT_IPE_1);
    442443    pVCpu->iom.s.PendingIOPortWrite.IOPort   = Port;
  • trunk/src/VBox/VMM/VMMAll/IOMAllMMIO.cpp

    r59073 r60852  
    234234    return false;
    235235}
     236
     237
     238#ifndef IN_RING3
     239/**
     240 * Defers a pending MMIO write to ring-3.
     241 *
     242 * @returns VINF_IOM_R3_MMIO_COMMIT_WRITE
     243 * @param   pVCpu       The cross context virtual CPU structure of the calling EMT.
     244 * @param   GCPhys      The write address.
     245 * @param   pvBuf       The bytes being written.
     246 * @param   cbBuf       How many bytes.
     247 * @param   pRange      The range, if resolved.
     248 */
     249static VBOXSTRICTRC iomMmioRing3WritePending(PVMCPU pVCpu, RTGCPHYS GCPhys, void const *pvBuf, size_t cbBuf, PIOMMMIORANGE pRange)
     250{
     251    Log3(("iomMmioRing3WritePending: %RGp LB %#x\n", GCPhys, cbBuf));
     252    AssertReturn(pVCpu->iom.s.PendingMmioWrite.cbValue == 0, VERR_IOM_MMIO_IPE_1);
     253    pVCpu->iom.s.PendingMmioWrite.GCPhys  = GCPhys;
     254    AssertReturn(cbBuf <= sizeof(pVCpu->iom.s.PendingMmioWrite.abValue), VERR_IOM_MMIO_IPE_2);
     255    pVCpu->iom.s.PendingMmioWrite.cbValue = (uint32_t)cbBuf;
     256    memcpy(pVCpu->iom.s.PendingMmioWrite.abValue, pvBuf, cbBuf);
     257    VMCPU_FF_SET(pVCpu, VMCPU_FF_IOM);
     258    return VINF_IOM_R3_MMIO_COMMIT_WRITE;
     259}
     260#endif
    236261
    237262
     
    331356                     * could be kind of screwed here...
    332357                     *
    333                      * Fix: Save the current state and resume it in ring-3. Requires EM to not go
    334                      *      to REM for MMIO accesses (like may currently do). */
    335 
     358                     * Fix: VINF_IOM_R3_IOPORT_COMMIT_WRITE (part 2) */
    336359                    LogFlow(("iomMMIODoComplicatedWrite: GCPhys=%RGp GCPhysStart=%RGp cbValue=%u rc=%Rrc [read]\n", GCPhys, GCPhysStart, cbValue, rc2));
    337360                    return rc2;
     
    401424                 * kind of screwed here...
    402425                 *
    403                  * Fix: Save the current state and resume it in ring-3. Requires EM to not go
    404                  *      to REM for MMIO accesses (like may currently do). */
     426                 * Fix: VINF_IOM_R3_IOPORT_COMMIT_WRITE (part 2) */
    405427                LogFlow(("iomMMIODoComplicatedWrite: GCPhys=%RGp GCPhysStart=%RGp cbValue=%u rc=%Rrc [write]\n", GCPhys, GCPhysStart, cbValue, rc2));
    406428                return rc2;
     
    19992021#ifndef IN_RING3
    20002022    if (rc == VERR_SEM_BUSY)
    2001         return VINF_IOM_R3_MMIO_READ_WRITE;
     2023    {
     2024        if (enmAccessType == PGMACCESSTYPE_READ)
     2025            return VINF_IOM_R3_MMIO_READ;
     2026        Assert(enmAccessType == PGMACCESSTYPE_WRITE);
     2027        return iomMmioRing3WritePending(pVCpu, GCPhysFault, pvBuf, cbBuf, NULL /*pRange*/);
     2028    }
    20022029#endif
    20032030    AssertRC(rc);
     
    20192046            rcStrict = iomMMIODoRead(pVM, pVCpu, pRange, GCPhysFault, pvBuf, (unsigned)cbBuf);
    20202047        else
     2048        {
    20212049            rcStrict = iomMMIODoWrite(pVM, pVCpu, pRange, GCPhysFault, pvBuf, (unsigned)cbBuf);
     2050#ifndef IN_RING3
     2051            if (rcStrict == VINF_IOM_R3_MMIO_WRITE)
     2052                rcStrict = iomMmioRing3WritePending(pVCpu, GCPhysFault, pvBuf, cbBuf, pRange);
     2053#endif
     2054        }
    20222055
    20232056        /* Check the return code. */
     
    20272060        AssertMsg(   rcStrict == VINF_SUCCESS
    20282061                  || rcStrict == (enmAccessType == PGMACCESSTYPE_READ ? VINF_IOM_R3_MMIO_READ :  VINF_IOM_R3_MMIO_WRITE)
     2062                  || (rcStrict == VINF_IOM_R3_MMIO_COMMIT_WRITE && enmAccessType == PGMACCESSTYPE_WRITE)
    20292063                  || rcStrict == VINF_IOM_R3_MMIO_READ_WRITE
    20302064                  || rcStrict == VINF_EM_DBG_STOP
     
    20432077        PDMCritSectLeave(pDevIns->CTX_SUFF(pCritSectRo));
    20442078    }
     2079#ifdef IN_RING3
    20452080    else
    20462081        iomMmioReleaseRange(pVM, pRange);
     2082#else
     2083    else
     2084    {
     2085        if (rcStrict == VINF_IOM_R3_MMIO_READ_WRITE)
     2086        {
     2087            if (enmAccessType == PGMACCESSTYPE_READ)
     2088                rcStrict = VINF_IOM_R3_MMIO_READ;
     2089            else
     2090            {
     2091                Assert(enmAccessType == PGMACCESSTYPE_WRITE);
     2092                rcStrict = iomMmioRing3WritePending(pVCpu, GCPhysFault, pvBuf, cbBuf, pRange);
     2093            }
     2094        }
     2095        iomMmioReleaseRange(pVM, pRange);
     2096    }
     2097#endif
    20472098    return rcStrict;
    20482099}
     
    20642115VMMDECL(VBOXSTRICTRC) IOMMMIORead(PVM pVM, PVMCPU pVCpu, RTGCPHYS GCPhys, uint32_t *pu32Value, size_t cbValue)
    20652116{
     2117    Assert(pVCpu->iom.s.PendingMmioWrite.cbValue == 0);
    20662118    /* Take the IOM lock before performing any MMIO. */
    20672119    VBOXSTRICTRC rc = IOM_LOCK_SHARED(pVM);
     
    21962248VMMDECL(VBOXSTRICTRC) IOMMMIOWrite(PVM pVM, PVMCPU pVCpu, RTGCPHYS GCPhys, uint32_t u32Value, size_t cbValue)
    21972249{
     2250    Assert(pVCpu->iom.s.PendingMmioWrite.cbValue == 0);
    21982251    /* Take the IOM lock before performing any MMIO. */
    21992252    VBOXSTRICTRC rc = IOM_LOCK_SHARED(pVM);
     
    23212374{
    23222375    STAM_COUNTER_INC(&pVM->iom.s.StatInstIns);
     2376    Assert(pVCpu->iom.s.PendingMmioWrite.cbValue == 0);
    23232377
    23242378    /*
     
    24872541{
    24882542    STAM_COUNTER_INC(&pVM->iom.s.StatInstOuts);
     2543    Assert(pVCpu->iom.s.PendingMmioWrite.cbValue == 0);
    24892544
    24902545    /*
  • trunk/src/VBox/VMM/VMMR3/IOM.cpp

    r60847 r60852  
    8686 * mapped into the physical memory address space, it can be accessed in a number
    8787 * of ways thru PGM.
     88 *
     89 *
     90 * @section sec_iom_logging     Logging Levels
     91 *
     92 * Following assignments:
     93 *      - Level 5 is used for defering I/O port and MMIO writes to ring-3.
    8894 *
    8995 */
     
    17311737    if (pVCpu->iom.s.PendingIOPortWrite.cbValue)
    17321738    {
     1739        Log5(("IOM: Dispatching pending I/O port write: %#x LB %u -> %RTiop\n", pVCpu->iom.s.PendingIOPortWrite.u32Value,
     1740              pVCpu->iom.s.PendingMmioWrite.cbValue, pVCpu->iom.s.PendingIOPortWrite.IOPort));
    17331741        VBOXSTRICTRC rcStrictCommit = IOMIOPortWrite(pVM, pVCpu, pVCpu->iom.s.PendingIOPortWrite.IOPort,
    17341742                                                     pVCpu->iom.s.PendingIOPortWrite.u32Value,
     
    17411749    if (pVCpu->iom.s.PendingMmioWrite.cbValue)
    17421750    {
     1751        Log5(("IOM: Dispatching pending MMIO write: %RGp LB %#x\n",
     1752              pVCpu->iom.s.PendingMmioWrite.GCPhys, pVCpu->iom.s.PendingMmioWrite.cbValue));
    17431753        /** @todo Try optimize this some day?  Currently easier and correcter to
    17441754         *        involve PGM here since we never know if the MMIO area is still mapped
     
    17471757                                                   pVCpu->iom.s.PendingMmioWrite.abValue, pVCpu->iom.s.PendingMmioWrite.cbValue,
    17481758                                                   PGMACCESSORIGIN_IOM);
    1749         pVCpu->iom.s.PendingIOPortWrite.cbValue = 0;
     1759        pVCpu->iom.s.PendingMmioWrite.cbValue = 0;
    17501760        rcStrict = iomR3MergeStatus(rcStrict, rcStrictCommit, VINF_IOM_R3_MMIO_COMMIT_WRITE, pVCpu);
    17511761    }
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