VirtualBox

Changeset 72248 in vbox for trunk/src/VBox/VMM/VMMAll


Ignore:
Timestamp:
May 17, 2018 5:32:22 PM (7 years ago)
Author:
vboxsync
Message:

iomMmioRing3WritePending: Deal with fun IEM cross MMIO page scenario.

File:
1 edited

Legend:

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

    r71211 r72248  
    6262{
    6363    Log5(("iomMmioRing3WritePending: %RGp LB %#x\n", GCPhys, cbBuf));
    64     AssertReturn(pVCpu->iom.s.PendingMmioWrite.cbValue == 0, VERR_IOM_MMIO_IPE_1);
    65     pVCpu->iom.s.PendingMmioWrite.GCPhys  = GCPhys;
    66     AssertReturn(cbBuf <= sizeof(pVCpu->iom.s.PendingMmioWrite.abValue), VERR_IOM_MMIO_IPE_2);
    67     pVCpu->iom.s.PendingMmioWrite.cbValue = (uint32_t)cbBuf;
    68     memcpy(pVCpu->iom.s.PendingMmioWrite.abValue, pvBuf, cbBuf);
     64    if (pVCpu->iom.s.PendingMmioWrite.cbValue == 0)
     65    {
     66        pVCpu->iom.s.PendingMmioWrite.GCPhys  = GCPhys;
     67        AssertReturn(cbBuf <= sizeof(pVCpu->iom.s.PendingMmioWrite.abValue), VERR_IOM_MMIO_IPE_2);
     68        pVCpu->iom.s.PendingMmioWrite.cbValue = (uint32_t)cbBuf;
     69        memcpy(pVCpu->iom.s.PendingMmioWrite.abValue, pvBuf, cbBuf);
     70    }
     71    else
     72    {
     73        /*
     74         * Join with pending if adjecent.
     75         *
     76         * This may happen if the stack overflows into MMIO territory and RSP/ESP/SP
     77         * isn't aligned. IEM will bounce buffer the access and do one write for each
     78         * page.  We get here when the 2nd page part is written.
     79         */
     80        uint32_t const cbOldValue = pVCpu->iom.s.PendingMmioWrite.cbValue;
     81        AssertMsgReturn(GCPhys == pVCpu->iom.s.PendingMmioWrite.GCPhys + cbOldValue,
     82                        ("pending %RGp LB %#x; incoming %RGp LB %#x\n",
     83                         pVCpu->iom.s.PendingMmioWrite.GCPhys, cbOldValue, GCPhys, cbBuf),
     84                        VERR_IOM_MMIO_IPE_1);
     85        AssertReturn(cbBuf <= sizeof(pVCpu->iom.s.PendingMmioWrite.abValue) - cbOldValue, VERR_IOM_MMIO_IPE_2);
     86        pVCpu->iom.s.PendingMmioWrite.cbValue = cbOldValue + (uint32_t)cbBuf;
     87        memcpy(&pVCpu->iom.s.PendingMmioWrite.abValue[cbOldValue], pvBuf, cbBuf);
     88    }
     89
    6990    VMCPU_FF_SET(pVCpu, VMCPU_FF_IOM);
    7091    RT_NOREF_PV(pRange);
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