VirtualBox

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


Ignore:
Timestamp:
Sep 5, 2019 7:12:46 AM (5 years ago)
Author:
vboxsync
Message:

Storage/DevVirtioSCSI.cpp: Added code to incorporate aeichner's changes (see bugref:9440, Comment #72). Tested new response status code and discovered it's more accurate to trust sense over rcReq values. Also changed some logging levels to reinstate the option to get hexdumps (with some filtering)

Location:
trunk/src/VBox/Devices/VirtIO
Files:
3 edited

Legend:

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

    r80575 r80596  
    8181            if (pszDepiction[i] == ' ' && first++)
    8282                pszDepiction[i] = '.';
    83         Log3Func(("%s: Guest %s %s 0x%s\n",
     83        Log6Func(("%s: Guest %s %s 0x%s\n",
    8484                  pszFunc, fWrite ? "wrote" : "read ", pszDepiction, pszFormattedVal));
    8585    }
    8686    else /* odd number or oversized access, ... log inline hex-dump style */
    8787    {
    88         Log3Func(("%s: Guest %s %s%s[%d:%d]: %.*Rhxs\n",
     88        Log6Func(("%s: Guest %s %s%s[%d:%d]: %.*Rhxs\n",
    8989              pszFunc, fWrite ? "wrote" : "read ", pszMember,
    9090              pszIdx, uOffset, uOffset + cb, cb, pv));
     
    199199    uint16_t uDescIdx = pDescChain->uHeadIdx;
    200200
    201     Log3Func(("%s DESC CHAIN: (head) desc_idx=%u [avail_idx=%u]\n",
     201    Log6Func(("%s DESC CHAIN: (head) desc_idx=%u [avail_idx=%u]\n",
    202202            pVirtqProxy->szVirtqName, pDescChain->uHeadIdx, pVirtqProxy->uAvailIdx));
    203203
     
    238238        if (desc.fFlags & VIRTQ_DESC_F_WRITE)
    239239        {
    240             Log3Func(("%s IN  desc_idx=%u seg=%u addr=%RGp cb=%u\n",
     240            Log6Func(("%s IN  desc_idx=%u seg=%u addr=%RGp cb=%u\n",
    241241                QUEUENAME(qIdx), uDescIdx, pDescChain->cSegsIn, desc.pGcPhysBuf, desc.cb));
    242242            cbIn += desc.cb;
     
    245245        else
    246246        {
    247             Log3Func(("%s OUT desc_idx=%u seg=%u addr=%RGp cb=%u\n",
     247            Log6Func(("%s OUT desc_idx=%u seg=%u addr=%RGp cb=%u\n",
    248248                QUEUENAME(qIdx), uDescIdx, pDescChain->cSegsOut, desc.pGcPhysBuf, desc.cb));
    249249            cbOut += desc.cb;
     
    261261
    262262    if (ppInSegs)
    263         *ppInSegs  = &pVirtqProxy->inSgBuf;
     263        *ppInSegs = &pVirtqProxy->inSgBuf;
    264264
    265265    if (ppOutSegs)
    266266        *ppOutSegs = &pVirtqProxy->outSgBuf;
    267267
    268     Log3Func(("%s -- segs OUT: %u (%u bytes)   IN: %u (%u bytes) --\n",
     268    Log6Func(("%s -- segs OUT: %u (%u bytes)   IN: %u (%u bytes) --\n",
    269269              pVirtqProxy->szVirtqName, pDescChain->cSegsOut, cbOut, pDescChain->cSegsIn, cbIn));
    270270
     
    292292    size_t cbRemain = RTSgBufCalcTotalLength(pBufSrc);
    293293    uint16_t uUsedIdx = virtioReadUsedRingIdx(pVirtio, qIdx);
    294     Log3Func(("Copying client data to %s, desc chain (head desc_idx %d)\n",
     294    Log6Func(("Copying client data to %s, desc chain (head desc_idx %d)\n",
    295295               QUEUENAME(qIdx), uUsedIdx));
    296296
     
    328328        size_t cbInSgBuf = RTSgBufCalcTotalLength(pBufDst);
    329329        size_t cbWritten = cbInSgBuf - RTSgBufCalcLengthLeft(pBufDst);
    330         Log2Func(("Copied %u bytes to %u byte buffer, residual=%d\n",
     330        Log2Func((".... Copied %u bytes to %u byte buffer, residual=%d\n",
    331331             cbWritten, cbInSgBuf, cbInSgBuf - cbWritten));
    332332    }
    333     Log3Func(("Write ahead used_idx=%d, %s used_idx=%d\n",
     333    Log6Func(("Write ahead used_idx=%d, %s used_idx=%d\n",
    334334         pVirtqProxy->uUsedIdx,  QUEUENAME(qIdx), uUsedIdx));
    335335
     
    351351
    352352    uint16_t uIdx = virtioReadUsedRingIdx(pVirtio, qIdx);
    353     Log3Func(("Updating %s used_idx from %u to %u\n",
     353    Log6Func(("Updating %s used_idx from %u to %u\n",
    354354              QUEUENAME(qIdx), uIdx, pVirtqProxy->uUsedIdx));
    355355
     
    368368
    369369    PVIRTQ_PROXY_T pVirtqProxy = &pVirtio->virtqProxy[qIdx];
    370     Log3Func(("%s\n", pVirtqProxy->szVirtqName));
     370    Log6Func(("%s\n", pVirtqProxy->szVirtqName));
    371371
    372372
     
    398398                return;
    399399            }
    400             Log3Func(("...skipping interrupt: VIRTIO_F_EVENT_IDX set but threshold not reached\n"));
     400            Log6Func(("...skipping interrupt: VIRTIO_F_EVENT_IDX set but threshold not reached\n"));
    401401        }
    402402        else
     
    408408                return;
    409409            }
    410             Log3Func(("...skipping interrupt. Guest flagged VIRTQ_AVAIL_F_NO_INTERRUPT for queue\n"));
     410            Log6Func(("...skipping interrupt. Guest flagged VIRTQ_AVAIL_F_NO_INTERRUPT for queue\n"));
    411411
    412412        }
     
    456456{
    457457   if (uCause == VIRTIO_ISR_VIRTQ_INTERRUPT)
    458        Log3Func(("reason: buffer added to 'used' ring.\n"));
     458       Log6Func(("reason: buffer added to 'used' ring.\n"));
    459459   else
    460460   if (uCause == VIRTIO_ISR_DEVICE_CONFIG)
    461        Log3Func(("reason: device config change\n"));
     461       Log6Func(("reason: device config change\n"));
    462462
    463463    pVirtio->uISR |= uCause;
     
    642642        {
    643643            pVirtio->uDeviceStatus = *(uint8_t *)pv;
    644             Log3Func(("Guest wrote uDeviceStatus ................ ("));
     644            Log6Func(("Guest wrote uDeviceStatus ................ ("));
    645645            virtioLogDeviceStatus(pVirtio->uDeviceStatus);
    646             Log3((")\n"));
     646            Log6((")\n"));
    647647            if (pVirtio->uDeviceStatus == 0)
    648648                virtioGuestResetted(pVirtio);
     
    659659        else /* Guest READ pCommonCfg->uDeviceStatus */
    660660        {
    661             Log3Func(("Guest read  uDeviceStatus ................ ("));
     661            Log6Func(("Guest read  uDeviceStatus ................ ("));
    662662            *(uint32_t *)pv = pVirtio->uDeviceStatus;
    663663            virtioLogDeviceStatus(pVirtio->uDeviceStatus);
    664             Log3((")\n"));
     664            Log6((")\n"));
    665665        }
    666666    }
     
    764764        {
    765765            ++pVirtio->uConfigGeneration;
    766             Log3Func(("Bumped cfg. generation to %d because %s%s\n",
     766            Log6Func(("Bumped cfg. generation to %d because %s%s\n",
    767767                pVirtio->uConfigGeneration,
    768768                fDevSpecificFieldChanged ? "<dev cfg changed> " : "",
     
    781781    {
    782782        *(uint8_t *)pv = pVirtio->uISR;
    783         Log3Func(("Read and clear ISR\n"));
     783        Log6Func(("Read and clear ISR\n"));
    784784        pVirtio->uISR = 0; /** VirtIO specification requires reads of ISR to clear it */
    785785        virtioLowerInterrupt(pVirtio);
     
    832832    {
    833833        pVirtio->uISR = *(uint8_t *)pv;
    834         Log3Func(("Setting uISR = 0x%02x (virtq interrupt: %d, dev confg interrupt: %d)\n",
     834        Log6Func(("Setting uISR = 0x%02x (virtq interrupt: %d, dev confg interrupt: %d)\n",
    835835              pVirtio->uISR & 0xff,
    836836              pVirtio->uISR & VIRTIO_ISR_VIRTQ_INTERRUPT,
     
    10451045
    10461046    int rc = VINF_SUCCESS;
    1047 
    10481047
    10491048    PVIRTIOSTATE pVirtio = (PVIRTIOSTATE)RTMemAllocZ(sizeof(VIRTIOSTATE));
     
    14631462}
    14641463
     1464 /**
     1465  * Do a hex dump of a buffer.
     1466  *
     1467  * @param   pv       Pointer to array to dump
     1468  * @param   cb       Number of characters to dump
     1469  * @param   uBase    Base address of offset addresses displayed
     1470  * @param   pszTitle Header line/title for the dump
     1471  *
     1472  */
     1473 void virtioHexDump(uint8_t *pv, size_t cb, uint32_t uBase, const char *pszTitle)
     1474 {
     1475     if (pszTitle)
     1476         Log(("%s [%d bytes]:\n", pszTitle, cb));
     1477     for (uint32_t row = 0; row < RT_MAX(1, (cb / 16) + 1); row++)
     1478     {
     1479         uint32_t uAddr = row * 16 + uBase;
     1480         Log(("%x%x%x%x: ", (uAddr >> 12) & 0xf, (uAddr >> 8) & 0xf, (uAddr >> 4) & 0xf, uAddr & 0xf));
     1481         for (int col = 0; col < 16; col++)
     1482         {
     1483            uint32_t idx = row * 16 + col;
     1484            uint8_t u8 = pv[idx];
     1485            if (idx >= cb)
     1486                Log(("-- %s", (col + 1) % 8 ? "" : "  "));
     1487            else
     1488                Log(("%x%x %s", u8 >> 4 & 0xf, u8 & 0xf, (col + 1) % 8 ? "" : "  "));
     1489         }
     1490         for (int col = 0; col < 16; col++)
     1491         {
     1492            uint32_t idx = row * 16 + col;
     1493            uint8_t u8 = pv[idx];
     1494            if (idx >= cb)
     1495                Log((" "));
     1496            else
     1497                Log(("%c", u8 >= 0x20 && u8 <= 0x7e ? u8 : '.'));
     1498         }
     1499         Log(("\n"));
     1500    }
     1501    Log(("\n"));
     1502 }
    14651503
    14661504#endif /* IN_RING3 */
  • trunk/src/VBox/Devices/VirtIO/Virtio_1_0.h

    r80522 r80596  
    4141#define VIRTIOSCSI_REGION_PORT_IO           1                    /**< BAR for PORT I/O (impl specific)         */
    4242#define VIRTIOSCSI_REGION_PCI_CAP           2                    /**< BAR for VirtIO Cap. MMIO (impl specific) */
     43
     44#define VIRTIO_HEX_DUMP(logLevel, pv, cb, base, title) \
     45    do { \
     46        if (LogIsItEnabled(logLevel, LOG_GROUP)) \
     47            virtioHexDump((pv), (cb), (base), (title)); \
     48    } while (0)
    4349
    4450/**
     
    320326                            bool fWrite, bool fHasIndex, uint32_t idx);
    321327
     328/**
     329 * Does a formatted hex dump using Log(()), recommend using VIRTIO_HEX_DUMP() macro to
     330 * control enabling of logging efficiently.
     331 *
     332 * @param   pv          - pointer to buffer to dump contents of
     333 * @param   cb          - count of characters to dump from buffer
     334 * @param   uBase       - base address of per-row address prefixing of hex output
     335 * @param   pszTitle    - Optional title. If present displays title that lists
     336 *                        provided text with value of cb to indicate size next to it.
     337 */
     338void virtioHexDump(uint8_t *pv, size_t cb, uint32_t uBase, const char *pszTitle);
    322339
    323340#endif /* !VBOX_INCLUDED_SRC_VirtIO_Virtio_1_0_h */
  • trunk/src/VBox/Devices/VirtIO/Virtio_1_0_impl.h

    r80527 r80596  
    409409                      pVirtio->pGcPhysQueueAvail[qIdx] + RT_UOFFSETOF(VIRTQ_AVAIL_T, uIdx),
    410410                      &uIdx, sizeof(uIdx));
    411     Log3Func(("%s actual avail_idx=%d\n", pVirtio->virtqProxy[qIdx].szVirtqName, uIdx));
    412411    return uIdx;
    413412}
     
    512511{
    513512    if (status == 0)
    514         Log3(("RESET"));
     513        Log6(("RESET"));
    515514    else
    516515    {
    517516        int primed = 0;
    518517        if (status & VIRTIO_STATUS_ACKNOWLEDGE)
    519             Log3(("ACKNOWLEDGE",   primed++));
     518            Log6(("ACKNOWLEDGE",   primed++));
    520519        if (status & VIRTIO_STATUS_DRIVER)
    521             Log3(("%sDRIVER",      primed++ ? " | " : ""));
     520            Log6(("%sDRIVER",      primed++ ? " | " : ""));
    522521        if (status & VIRTIO_STATUS_FEATURES_OK)
    523             Log3(("%sFEATURES_OK", primed++ ? " | " : ""));
     522            Log6(("%sFEATURES_OK", primed++ ? " | " : ""));
    524523        if (status & VIRTIO_STATUS_DRIVER_OK)
    525             Log3(("%sDRIVER_OK",   primed++ ? " | " : ""));
     524            Log6(("%sDRIVER_OK",   primed++ ? " | " : ""));
    526525        if (status & VIRTIO_STATUS_FAILED)
    527             Log3(("%sFAILED",      primed++ ? " | " : ""));
     526            Log6(("%sFAILED",      primed++ ? " | " : ""));
    528527        if (status & VIRTIO_STATUS_DEVICE_NEEDS_RESET)
    529             Log3(("%sNEEDS_RESET", primed++ ? " | " : ""));
     528            Log6(("%sNEEDS_RESET", primed++ ? " | " : ""));
    530529    }
    531530}
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