VirtualBox

Changeset 101016 in vbox for trunk/src/VBox/Devices/Storage


Ignore:
Timestamp:
Sep 5, 2023 9:08:39 AM (18 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
158973
Message:

BusLogic: Avoid needlessly looping over an invalid mailbox (see bugref:5112).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/DevBusLogic.cpp

    r100986 r101016  
    11481148DECLINLINE(void) buslogicR3OutgoingMailboxAdvance(PBUSLOGIC pThis)
    11491149{
    1150     pThis->uMailboxOutgoingPositionCurrent = (pThis->uMailboxOutgoingPositionCurrent + 1) % pThis->cMailbox;
     1150    uint32_t    uNextPos = pThis->uMailboxOutgoingPositionCurrent + 1;
     1151    Assert(uNextPos <= pThis->cMailbox);
     1152    pThis->uMailboxOutgoingPositionCurrent = uNextPos >= pThis->cMailbox ? 0 : uNextPos;
    11511153}
    11521154
     
    34143416    }
    34153417    else
     3418    {
    34163419        AssertMsgFailed(("Invalid outgoing mailbox action code %u\n", MailboxGuest.u.out.uActionCode));
     3420        /** @todo We ought to report an error in the incoming mailbox here */
     3421        rc = VINF_NOT_SUPPORTED;    /* Not immediately an error, keep going. */
     3422    }
    34173423
    34183424    AssertRC(rc);
     
    38213827        if (ASMAtomicXchgU32(&pThis->cMailboxesReady, 0))
    38223828        {
    3823             /* Process mailboxes. */
     3829            /* Process mailboxes as long as there are new entries. The loop can potentially
     3830             * keep going for a while if the guest keeps supplying new entries.
     3831             * If there are too many invalid mailbox entries, abort processing because
     3832             * we're just wasting time. This might happen if the guest keeps supplying
     3833             * new invalid entries (extremely unlikely), or if the mailbox memory is not
     3834             * writable for whatever reason.
     3835             */
     3836            uint32_t cMaxInvalid = pThis->cMailbox * 2; /* NB: cMailbox can't be more than 255. */
    38243837            do
    38253838            {
    38263839                rc = buslogicR3ProcessMailboxNext(pDevIns, pThis, pThisCC);
     3840                if (RT_UNLIKELY(rc == VINF_NOT_SUPPORTED))
     3841                {
     3842                    if (cMaxInvalid-- == 0)
     3843                    {
     3844                        LogRelMax(10, ("BusLogic: Too many invalid entries, aborting maibox processing!\n"));
     3845                        break;
     3846                    }
     3847                }
    38273848                AssertMsg(RT_SUCCESS(rc) || rc == VERR_NO_DATA, ("Processing mailbox failed rc=%Rrc\n", rc));
    38283849            } while (RT_SUCCESS(rc));
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