VirtualBox

Changeset 80571 in vbox for trunk/src/VBox/Devices/VirtIO


Ignore:
Timestamp:
Sep 4, 2019 12:06:41 AM (5 years ago)
Author:
vboxsync
Message:

Storage/DevVirtioSCSI.cpp: Cleaned up the req submit code. Trying to chase down a problem that occurs when bringing in 1.3Mb or so worth of data from the guest into a new request allocated into virtual memory

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/VirtIO/Virtio_1_0.cpp

    r80528 r80571  
    196196    pDescChain->cSegsIn = pDescChain->cSegsOut = 0;
    197197
    198 
    199198    pDescChain->uHeadIdx = virtioReadAvailDescIdx(pVirtio, qIdx, pVirtqProxy->uAvailIdx);
    200199    uint16_t uDescIdx = pDescChain->uHeadIdx;
     
    206205        pVirtqProxy->uAvailIdx++;
    207206
     207    uint32_t cbIn = 0, cbOut = 0;
    208208    VIRTQ_DESC_T desc;
    209209    do
     
    212212
    213213        /**
    214         * Malicious or inept guests may go beyond aSegsIn or aSegsOut boundaries by linking
     214        * Malicious guests may go beyond aSegsIn or aSegsOut boundaries by linking
    215215        * several descriptors into a loop. Since there is no legitimate way to get a sequences of
    216216        * linked descriptors exceeding the total number of descriptors in the ring (see @bugref{8620}),
     
    240240            Log3Func(("%s IN  desc_idx=%u seg=%u addr=%RGp cb=%u\n",
    241241                QUEUENAME(qIdx), uDescIdx, pDescChain->cSegsIn, desc.pGcPhysBuf, desc.cb));
    242 
     242            cbIn += desc.cb;
    243243            pSeg = &(pDescChain->aSegsIn[pDescChain->cSegsIn++]);
    244244        }
     
    247247            Log3Func(("%s OUT desc_idx=%u seg=%u addr=%RGp cb=%u\n",
    248248                QUEUENAME(qIdx), uDescIdx, pDescChain->cSegsOut, desc.pGcPhysBuf, desc.cb));
     249            cbOut += desc.cb;
    249250            pSeg = &(pDescChain->aSegsOut[pDescChain->cSegsOut++]);
    250251        }
     
    256257    } while (desc.fFlags & VIRTQ_DESC_F_NEXT);
    257258
    258     RTSgBufInit(&pVirtqProxy->inSgBuf, (PCRTSGSEG)&pDescChain->aSegsIn,  pDescChain->cSegsIn);
    259     RTSgBufInit(&pVirtqProxy->outSgBuf,(PCRTSGSEG)&pDescChain->aSegsOut, pDescChain->cSegsOut);
     259    RTSgBufInit(&pVirtqProxy->inSgBuf,  (PCRTSGSEG)&pDescChain->aSegsIn,  pDescChain->cSegsIn);
     260    RTSgBufInit(&pVirtqProxy->outSgBuf, (PCRTSGSEG)&pDescChain->aSegsOut, pDescChain->cSegsOut);
    260261
    261262    if (ppInSegs)
    262263        *ppInSegs  = &pVirtqProxy->inSgBuf;
     264
    263265    if (ppOutSegs)
    264266        *ppOutSegs = &pVirtqProxy->outSgBuf;
    265267
    266     Log3Func(("%s -- segs out: %u,  segs in: %u --\n",
    267               pVirtqProxy->szVirtqName, pDescChain->cSegsOut, pDescChain->cSegsIn));
     268    Log3Func(("%s -- segs OUT: %u (%u bytes)   IN: %u (%u bytes) --\n",
     269              pVirtqProxy->szVirtqName, pDescChain->cSegsOut, cbOut, pDescChain->cSegsIn, cbIn));
    268270
    269271    return VINF_SUCCESS;
     
    289291
    290292    size_t cbRemain = RTSgBufCalcTotalLength(pBufSrc);
    291     uint16_t uUsedIdx  = virtioReadUsedRingIdx(pVirtio, qIdx);
     293    uint16_t uUsedIdx = virtioReadUsedRingIdx(pVirtio, qIdx);
    292294    Log3Func(("Copying client data to %s, desc chain (head desc_idx %d)\n",
    293295               QUEUENAME(qIdx), uUsedIdx));
     
    309311        RT_UNTRUSTED_NONVOLATILE_COPY_FENCE();
    310312
    311     /** TBD to avoid wasting cycles how do we wrap this in test for Log2* enabled? */
    312     size_t   cbInSgBuf = RTSgBufCalcTotalLength(pBufDst);
    313     size_t   cbWritten = cbInSgBuf  - RTSgBufCalcLengthLeft(pBufDst);
    314 
    315 
    316313    /** If this write-ahead crosses threshold where the driver wants to get an event flag it */
    317314    if (pVirtio->uDriverFeatures & VIRTIO_F_EVENT_IDX)
     
    326323                        pDescChain->uHeadIdx,
    327324                        pDescChain->cSegsIn);
    328     Log3Func(("Copied %u bytes to %u byte buffer\n                Write ahead used_idx=%d, %s used_idx=%d\n",
    329              cbWritten, cbInSgBuf, pVirtqProxy->uUsedIdx,  QUEUENAME(qIdx), uUsedIdx));
     325
     326    if (LogIs2Enabled())
     327    {
     328        size_t cbInSgBuf = RTSgBufCalcTotalLength(pBufDst);
     329        size_t cbWritten = cbInSgBuf - RTSgBufCalcLengthLeft(pBufDst);
     330        Log2Func(("Copied %u bytes to %u byte buffer, residual=%d\n",
     331             cbWritten, cbInSgBuf, cbInSgBuf - cbWritten));
     332    }
     333    Log3Func(("Write ahead used_idx=%d, %s used_idx=%d\n",
     334         pVirtqProxy->uUsedIdx,  QUEUENAME(qIdx), uUsedIdx));
     335
    330336    return VINF_SUCCESS;
    331337}
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