Changeset 80571 in vbox for trunk/src/VBox/Devices/VirtIO
- Timestamp:
- Sep 4, 2019 12:06:41 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/VirtIO/Virtio_1_0.cpp
r80528 r80571 196 196 pDescChain->cSegsIn = pDescChain->cSegsOut = 0; 197 197 198 199 198 pDescChain->uHeadIdx = virtioReadAvailDescIdx(pVirtio, qIdx, pVirtqProxy->uAvailIdx); 200 199 uint16_t uDescIdx = pDescChain->uHeadIdx; … … 206 205 pVirtqProxy->uAvailIdx++; 207 206 207 uint32_t cbIn = 0, cbOut = 0; 208 208 VIRTQ_DESC_T desc; 209 209 do … … 212 212 213 213 /** 214 * Malicious or ineptguests may go beyond aSegsIn or aSegsOut boundaries by linking214 * Malicious guests may go beyond aSegsIn or aSegsOut boundaries by linking 215 215 * several descriptors into a loop. Since there is no legitimate way to get a sequences of 216 216 * linked descriptors exceeding the total number of descriptors in the ring (see @bugref{8620}), … … 240 240 Log3Func(("%s IN desc_idx=%u seg=%u addr=%RGp cb=%u\n", 241 241 QUEUENAME(qIdx), uDescIdx, pDescChain->cSegsIn, desc.pGcPhysBuf, desc.cb)); 242 242 cbIn += desc.cb; 243 243 pSeg = &(pDescChain->aSegsIn[pDescChain->cSegsIn++]); 244 244 } … … 247 247 Log3Func(("%s OUT desc_idx=%u seg=%u addr=%RGp cb=%u\n", 248 248 QUEUENAME(qIdx), uDescIdx, pDescChain->cSegsOut, desc.pGcPhysBuf, desc.cb)); 249 cbOut += desc.cb; 249 250 pSeg = &(pDescChain->aSegsOut[pDescChain->cSegsOut++]); 250 251 } … … 256 257 } while (desc.fFlags & VIRTQ_DESC_F_NEXT); 257 258 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); 260 261 261 262 if (ppInSegs) 262 263 *ppInSegs = &pVirtqProxy->inSgBuf; 264 263 265 if (ppOutSegs) 264 266 *ppOutSegs = &pVirtqProxy->outSgBuf; 265 267 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)); 268 270 269 271 return VINF_SUCCESS; … … 289 291 290 292 size_t cbRemain = RTSgBufCalcTotalLength(pBufSrc); 291 uint16_t uUsedIdx 293 uint16_t uUsedIdx = virtioReadUsedRingIdx(pVirtio, qIdx); 292 294 Log3Func(("Copying client data to %s, desc chain (head desc_idx %d)\n", 293 295 QUEUENAME(qIdx), uUsedIdx)); … … 309 311 RT_UNTRUSTED_NONVOLATILE_COPY_FENCE(); 310 312 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 316 313 /** If this write-ahead crosses threshold where the driver wants to get an event flag it */ 317 314 if (pVirtio->uDriverFeatures & VIRTIO_F_EVENT_IDX) … … 326 323 pDescChain->uHeadIdx, 327 324 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 330 336 return VINF_SUCCESS; 331 337 }
Note:
See TracChangeset
for help on using the changeset viewer.