VirtualBox

Changeset 39887 in vbox


Ignore:
Timestamp:
Jan 26, 2012 5:56:17 PM (13 years ago)
Author:
vboxsync
Message:

DevVGA_VBVA: fixed guest SMP unsafe code. Fixed a case when loaded saved state data was incorrectly discarded.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Graphics/DevVGA_VBVA.cpp

    r39603 r39887  
    173173    }
    174174
    175     VBVARECORD *pRecord = &pVBVA->aRecords[indexRecordFirst];
    176 
    177     LOGVBVABUFFER(("cbRecord = 0x%08X\n", pRecord->cbRecord));
    178 
    179     uint32_t cbRecord = pRecord->cbRecord & ~VBVA_F_RECORD_PARTIAL;
     175    uint32_t cbRecordCurrent = ASMAtomicReadU32(&pVBVA->aRecords[indexRecordFirst].cbRecord);
     176
     177    LOGVBVABUFFER(("cbRecord = 0x%08X, pPartialRecord->cb = 0x%08X\n", cbRecordCurrent, pPartialRecord->cb));
     178
     179    uint32_t cbRecord = cbRecordCurrent & ~VBVA_F_RECORD_PARTIAL;
    180180
    181181    if (pPartialRecord->cb)
     
    185185
    186186        LOGVBVABUFFER(("continue partial record cb = %d cbRecord 0x%08X, first = %d, free = %d\n",
    187                       pPartialRecord->cb, pRecord->cbRecord, indexRecordFirst, indexRecordFree));
     187                      pPartialRecord->cb, cbRecordCurrent, indexRecordFirst, indexRecordFree));
    188188
    189189        if (cbRecord > pPartialRecord->cb)
     
    196196        }
    197197
    198         if (!(pRecord->cbRecord & VBVA_F_RECORD_PARTIAL))
     198        if (!(cbRecordCurrent & VBVA_F_RECORD_PARTIAL))
    199199        {
    200200            /* The record is completed by guest. Return it to the caller. */
     
    216216
    217217    /* A new record need to be processed. */
    218     if (pRecord->cbRecord & VBVA_F_RECORD_PARTIAL)
     218    if (cbRecordCurrent & VBVA_F_RECORD_PARTIAL)
    219219    {
    220220        /* Current record is being written by guest. '=' is important here,
     
    232232
    233233            LOGVBVABUFFER(("started partial record cb = 0x%08X cbRecord 0x%08X, first = %d, free = %d\n",
    234                           pPartialRecord->cb, pRecord->cbRecord, indexRecordFirst, indexRecordFree));
     234                          pPartialRecord->cb, cbRecordCurrent, indexRecordFirst, indexRecordFree));
    235235        }
    236236
     
    468468}
    469469
    470 static int vbvaEnable (unsigned uScreenId, PVGASTATE pVGAState, VBVACONTEXT *pCtx, VBVABUFFER *pVBVA, uint32_t u32Offset)
     470static int vbvaEnable (unsigned uScreenId, PVGASTATE pVGAState, VBVACONTEXT *pCtx, VBVABUFFER *pVBVA, uint32_t u32Offset, bool fRestored)
    471471{
    472472    /* @todo old code did a UpdateDisplayAll at this place. */
     
    492492                     pVBVA->hostFlags.u32HostEvents, pVBVA->hostFlags.u32SupportedOrders));
    493493
    494         pCtx->aViews[uScreenId].partialRecord.pu8 = NULL;
    495         pCtx->aViews[uScreenId].partialRecord.cb = 0;
     494        if (!fRestored)
     495        {
     496            /* @todo Actually this function must not touch the partialRecord structure at all,
     497             * because initially it is a zero and when VBVA is disabled this should be set to zero.
     498             * But I'm not sure that no code depends on zeroing partialRecord here.
     499             * So for now (a quick fix for 4.1) just do not do this if the VM was restored,
     500             * when partialRecord might be loaded already from the saved state.
     501             */
     502            pCtx->aViews[uScreenId].partialRecord.pu8 = NULL;
     503            pCtx->aViews[uScreenId].partialRecord.cb = 0;
     504        }
    496505
    497506        pCtx->aViews[uScreenId].pVBVA = pVBVA;
     
    16001609            if (pView->pVBVA)
    16011610            {
    1602                 vbvaEnable (iView, pVGAState, pCtx, pView->pVBVA, pView->u32VBVAOffset);
     1611                vbvaEnable (iView, pVGAState, pCtx, pView->pVBVA, pView->u32VBVAOffset, true /* fRestored */);
    16031612                vbvaResize (pVGAState, pView, &pView->screen);
    16041613            }
     
    18921901                    vbvaFlush (pVGAState, pCtx);
    18931902
    1894                     rc = vbvaEnable (uScreenId, pVGAState, pCtx, pVBVA, u32Offset);
     1903                    rc = vbvaEnable (uScreenId, pVGAState, pCtx, pVBVA, u32Offset, false /* fRestored */);
    18951904                }
    18961905                else
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