VirtualBox

Changeset 99674 in vbox for trunk/src/VBox/VMM


Ignore:
Timestamp:
May 8, 2023 1:27:47 PM (20 months ago)
Author:
vboxsync
Message:

VMM/PDMQueue: Fix PDMQueueAllocEx() to respect the multiple of 32 cBits input parameter requirement (mainly to fix the tstPDMQueue on ARM which uses a different ASMBitFirstSet() implementation which is not as forgiving), and a small fix to the testcase itself to not crash when allocating an item failed, which is counted as an error anyway

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

Legend:

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

    r98103 r99674  
    172172    for (;;)
    173173    {
    174         int32_t iBit = ASMBitFirstSet(pQueue->bmAlloc, cItems);
     174        /*
     175         * ASMBitFirstSet() mandates a cBits to be a multiple of 32 while cItems can be less (but the bitmap)
     176         * is aligned to 64 bytes and correctly initialized so only the number of items allocated are valid
     177         * and can be marked as free.
     178         */
     179        int32_t iBit = ASMBitFirstSet(pQueue->bmAlloc, RT_ALIGN(cItems, 32));
    175180        if (iBit >= 0)
    176181        {
  • trunk/src/VBox/VMM/testcase/tstPDMQueue.cpp

    r98644 r99674  
    313313    PTEST1ITEM pMyItem = (PTEST1ITEM)PDMQueueAlloc(pVM, hQueue, pVM);
    314314    RTTEST_CHECK(g_hTest, pMyItem);
    315     pMyItem->iSeqNo = 1;
    316     RTTEST_CHECK_RC(g_hTest, PDMQueueInsert(pVM, hQueue, pVM, &pMyItem->Core), VINF_SUCCESS);
    317 
    318     PDMR3QueueFlushAll(pVM);
    319     RTTEST_CHECK(g_hTest, g_cTest1Callbacks == 1);
     315    if (pMyItem)
     316    {
     317        pMyItem->iSeqNo = 1;
     318        RTTEST_CHECK_RC(g_hTest, PDMQueueInsert(pVM, hQueue, pVM, &pMyItem->Core), VINF_SUCCESS);
     319
     320        PDMR3QueueFlushAll(pVM);
     321        RTTEST_CHECK(g_hTest, g_cTest1Callbacks == 1);
     322    }
    320323
    321324    /*
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