VirtualBox

Changeset 80931 in vbox for trunk


Ignore:
Timestamp:
Sep 22, 2019 9:56:37 AM (5 years ago)
Author:
vboxsync
Message:

Storage/DevVirtioSCSI.cpp: Fixed errors that prevented it from building on Windows and tested. See bugref:9440, Comment #93

Location:
trunk/src/VBox/Devices
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/DevVirtioSCSI.cpp

    r80928 r80931  
    4747#include "VBoxDD.h"
    4848
    49 
    5049/*
    5150 * RT log-levels used:
     
    327326    uint8_t  uResponse;                                        /** response                                          */
    328327} VIRTIOSCSI_CTRL_TMF_T, *PVIRTIOSCSI_CTRL_TMF_T;
    329 #pragma pack(0)
     328#pragma pack()
    330329
    331330/**
     
    514513
    515514    /** True if the guest/driver and VirtIO framework are in the ready state */
    516     bool                            fVirtioReady;
     515    unsigned                         fVirtioReady;
    517516
    518517    /** True if VIRTIO_SCSI_F_T10_PI was negotiated */
    519     bool                            fHasT10pi;
     518    unsigned                         fHasT10pi;
    520519
    521520    /** True if VIRTIO_SCSI_F_T10_PI was negotiated */
    522     bool                            fHasHotplug;
     521    unsigned                         fHasHotplug;
    523522
    524523    /** True if VIRTIO_SCSI_F_T10_PI was negotiated */
    525     bool                            fHasInOutBufs;
     524    unsigned                         fHasInOutBufs;
    526525
    527526    /** True if VIRTIO_SCSI_F_T10_PI was negotiated */
    528     bool                            fHasLunChange;
     527    unsigned                         fHasLunChange;
    529528
    530529    /** True if in the process of resetting */
    531     bool                            fResetting;
     530    unsigned                         fResetting;
    532531
    533532    /** True if in the process of quiescing I/O */
    534     bool                            fQuiescing;
     533    unsigned                         fQuiescing;
    535534
    536535} VIRTIOSCSI, *PVIRTIOSCSI;
     
    861860    respHdr.uSenseLen = pReq->pbSense[2] == SCSI_SENSE_NONE ? 0 : (uint32_t)pReq->uSenseLen;
    862861    AssertMsg(!(cbResidual & 0xffffffff00000000),
    863             ("WARNING: Residual size larger than uint32_t holds, truncating"));
     862            ("WARNING: Residual size larger than sizeof(uint32_t), truncating"));
    864863    respHdr.uResidual = (uint32_t)(cbResidual & 0xffffffff);
    865864    respHdr.uStatus   = pReq->uStatus;
     
    938937    if (LogIs12Enabled())
    939938    {
    940         uint32_t cb = RT_MIN(cbXfer, 256);
     939        Assert(!(cbXfer & 0xffffffff00000000));
     940        uint32_t cbXfer32 = cbXfer & 0xffffffff;
     941        uint32_t cb = RT_MIN(cbXfer32, 256);
    941942        if (VIRTIO_IN_DIRECTION(pReq->enmTxDir))
    942943        {
     
    10031004         * (phys. memory) with the Req response data in virtual memory.
    10041005         */
    1005         uint32_t cbReqSgBuf = RTSgBufCalcTotalLength(&reqSegBuf);
     1006        size_t cbReqSgBuf = RTSgBufCalcTotalLength(&reqSegBuf);
    10061007        AssertMsgReturn(cbReqSgBuf <= pReq->pDescChain->cbPhysDst,
    1007                        ("Guest expected less req data (space needed: %d, avail: %d)\n",
     1008                       ("Guest expected less req data (space needed: %ld, avail: %d)\n",
    10081009                         cbReqSgBuf, pReq->pDescChain->cbPhysDst),
    10091010                       VERR_BUFFER_OVERFLOW);
     
    13491350    while (pThread->enmState == PDMTHREADSTATE_RUNNING)
    13501351    {
    1351         if (pThis->fQuiescing || !pThis->fQueueAttached[qIdx])
    1352         {
    1353             Log6Func(("Skipping wakeup (quiescing or reset)\n"));
    1354             continue;
    1355         }
    1356 
    13571352        if (virtioQueueIsEmpty(pThis->hVirtio, qIdx))
    13581353        {
     
    13731368            ASMAtomicWriteBool(&pWorker->fSleeping, false);
    13741369        }
    1375         Log6Func(("fetching next descriptor chain from %s\n", QUEUENAME(qIdx)));
    1376         PVIRTIO_DESC_CHAIN_T pDescChain;
    1377         rc = virtioQueueGet(pThis->hVirtio, qIdx, &pDescChain, true);
    1378         if (rc == VERR_NOT_AVAILABLE)
     1370
     1371        if (!pThis->fQueueAttached[qIdx])
    13791372        {
    1380             Log6Func(("Nothing found in %s\n", QUEUENAME(qIdx)));
    1381             continue;
     1373            LogFunc(("%s queue not attached, worker aborting...\n", QUEUENAME(qIdx)));
     1374            break;
     1375        } else {
     1376            LogFunc(("%s queue is still attached!\n", QUEUENAME(qIdx)));
    13821377        }
    13831378
    1384         AssertRC(rc);
    1385         if (qIdx == CONTROLQ_IDX)
    1386             virtioScsiCtrl(pThis, qIdx, pDescChain);
    1387         else /* request queue index */
     1379        if (!pThis->fQuiescing)
    13881380        {
    1389             rc = virtioScsiReqSubmit(pThis, qIdx, pDescChain);
    1390             if (RT_FAILURE(rc))
    1391             {
    1392                 LogRel(("Error submitting req packet, resetting %Rrc", rc));
    1393             }
     1381             Log6Func(("fetching next descriptor chain from %s\n", QUEUENAME(qIdx)));
     1382             PVIRTIO_DESC_CHAIN_T pDescChain;
     1383             rc = virtioQueueGet(pThis->hVirtio, qIdx, &pDescChain, true);
     1384             if (rc == VERR_NOT_AVAILABLE)
     1385             {
     1386                Log6Func(("Nothing found in %s\n", QUEUENAME(qIdx)));
     1387                continue;
     1388             }
     1389
     1390             AssertRC(rc);
     1391             if (qIdx == CONTROLQ_IDX)
     1392                 virtioScsiCtrl(pThis, qIdx, pDescChain);
     1393             else /* request queue index */
     1394             {
     1395                  rc = virtioScsiReqSubmit(pThis, qIdx, pDescChain);
     1396                  if (RT_FAILURE(rc))
     1397                  {
     1398                     LogRel(("Error submitting req packet, resetting %Rrc", rc));
     1399                  }
     1400             }
    13941401        }
    13951402    }
     
    15131520}
    15141521
    1515 static DECLCALLBACK(void) virtioScsiStatusChanged(VIRTIOHANDLE hVirtio, void *pClient,  bool fVirtioReady)
     1522static DECLCALLBACK(void) virtioScsiStatusChanged(VIRTIOHANDLE hVirtio, void *pClient,  uint32_t fVirtioReady)
    15161523{
    15171524    RT_NOREF(hVirtio);
     
    18271834
    18281835static int virtioScsiCfgAccessed(PVIRTIOSCSI pThis, uint32_t uOffset,
    1829                                     const void *pv, uint32_t cb, uint8_t fWrite)
     1836                                    const void *pv, uint32_t cb, bool fWrite)
    18301837{
    18311838    int rc = VINF_SUCCESS;
  • trunk/src/VBox/Devices/VirtIO/Virtio_1_0.cpp

    r80928 r80931  
    3535#define INSTANCE(pVirtio) pVirtio->szInstance
    3636#define QUEUENAME(qIdx) (pVirtio->virtqState[qIdx].szVirtqName)
     37
    3738
    3839/**
     
    246247    Log3Func(("Copying client data to %s, desc chain (head desc_idx %d)\n",
    247248               QUEUENAME(qIdx), uUsedIdx));
     249    (void)uUsedIdx;
    248250
    249251    /*
     
    252254     * (pulled from avail ring of queue), essentially giving result back to the guest driver.
    253255     */
    254     uint32_t cbRemain = RTSgBufCalcTotalLength(pSgVirtReturn);
    255     uint32_t cbCopy = 0;
     256    size_t cbCopy = 0;
     257    size_t cbRemain = RTSgBufCalcTotalLength(pSgVirtReturn);
    256258    while (cbRemain)
    257259    {
     
    260262        uint64_t dstSgLen   = (uint64_t)paSeg->cbSeg;
    261263        uint64_t dstSgCur   = (uint64_t)pSgPhysReturn->pvSegCur;
    262         cbCopy = RT_MIN(pSgVirtReturn->cbSegLeft, dstSgLen - (dstSgCur - dstSgStart));
     264        cbCopy = RT_MIN((uint64_t)pSgVirtReturn->cbSegLeft, dstSgLen - (dstSgCur - dstSgStart));
    263265        PDMDevHlpPhysWrite(pVirtio->CTX_SUFF(pDevIns),
    264266                          (RTGCPHYS)pSgPhysReturn->pvSegCur, pSgVirtReturn->pvSegCur, cbCopy);
     
    276278            pVirtq->fEventThresholdReached = true;
    277279
     280    Assert(!(cbCopy & 0xffffffff00000000));
    278281    /**
    279282     * Place used buffer's descriptor in used ring but don't update used ring's slot index.
    280283     * That will be done with a subsequent client call to virtioQueueSync() */
    281     virtioWriteUsedElem(pVirtio, qIdx, pVirtq->uUsedIdx++, pDescChain->uHeadIdx, cbCopy);
    282 
    283     Log2Func((".... Copied %u bytes to %u byte buffer, residual=%d\n",
     284    virtioWriteUsedElem(pVirtio, qIdx, pVirtq->uUsedIdx++, pDescChain->uHeadIdx,
     285            (uint32_t)(cbCopy & 0xffffffff));
     286
     287    Log2Func((".... Copied %ul bytes to %ul byte buffer, residual=%ul\n",
    284288         cbCopy, pDescChain->cbPhysDst, pDescChain->cbPhysDst - cbCopy));
    285289
     
    310314    Log6Func(("Updating %s used_idx from %u to %u\n",
    311315              QUEUENAME(qIdx), uIdx, pVirtq->uUsedIdx));
     316    (void)uIdx;
    312317
    313318    virtioWriteUsedRingIdx(pVirtio, qIdx, pVirtq->uUsedIdx);
     
    323328{
    324329    Assert(uNotifyIdx == qIdx);
     330    (void)uNotifyIdx;
    325331
    326332    PVIRTQSTATE pVirtq = &pVirtio->virtqState[qIdx];
    327333    Log6Func(("%s\n", pVirtq->szVirtqName));
     334    (void)pVirtq;
    328335
    329336    /** Inform client */
     
    488495{
    489496    PVIRTIOSTATE pVirtio = (PVIRTIOSTATE)hVirtio;
    490     return pVirtio->uQueueEnable[qIdx];
     497    return pVirtio->uQueueEnable[qIdx] != 0;
    491498}
    492499
     
    528535
    529536    /** Let the client know */
    530     pVirtio->virtioCallbacks.pfnVirtioStatusChanged((VIRTIOHANDLE)pVirtio, pVirtio->pClientContext, false);
     537    pVirtio->virtioCallbacks.pfnVirtioStatusChanged((VIRTIOHANDLE)pVirtio, pVirtio->pClientContext, 0);
    531538    virtioResetDevice(pVirtio);
    532539}
     
    645652             * Notify client only if status actually changed from last time.
    646653             */
    647             bool fOkayNow = pVirtio->uDeviceStatus & VIRTIO_STATUS_DRIVER_OK;
    648             bool fWasOkay = pVirtio->uPrevDeviceStatus & VIRTIO_STATUS_DRIVER_OK;
     654            uint32_t fOkayNow = pVirtio->uDeviceStatus & VIRTIO_STATUS_DRIVER_OK;
     655            uint32_t fWasOkay = pVirtio->uPrevDeviceStatus & VIRTIO_STATUS_DRIVER_OK;
     656            uint32_t fDrvOk = pVirtio->uDeviceStatus & VIRTIO_STATUS_DRIVER_OK;
    649657            if ((fOkayNow && !fWasOkay) || (!fOkayNow && fWasOkay))
    650                 pVirtio->virtioCallbacks.pfnVirtioStatusChanged((VIRTIOHANDLE)pVirtio, pVirtio->pClientContext,
    651                        pVirtio->uDeviceStatus & VIRTIO_STATUS_DRIVER_OK);
     658                pVirtio->virtioCallbacks.pfnVirtioStatusChanged((VIRTIOHANDLE)pVirtio, pVirtio->pClientContext, fDrvOk);
    652659            pVirtio->uPrevDeviceStatus = pVirtio->uDeviceStatus;
    653660        }
     
    758765    {
    759766        uint32_t uOffset = GCPhysAddr - pVirtio->pGcPhysCommonCfg;
    760         virtioCommonCfgAccessed(pVirtio, 0 /* fWrite */, uOffset, cb, pv);
     767        virtioCommonCfgAccessed(pVirtio, 0 /* fWrite */, uOffset, cb, (void const *)pv);
    761768    }
    762769    else
     
    10721079    pVirtio->virtioCallbacks.pfnSSMDevLoadExec      = ssmLoadExecCallback;
    10731080    pVirtio->virtioCallbacks.pfnSSMDevLoadDone      = ssmLoadDoneCallback;
    1074 
    10751081
    10761082    /* Set PCI config registers (assume 32-bit mode) */
     
    13081314
    13091315    int rc = VINF_SUCCESS;
    1310     virtioDumpState(pVirtio, "virtioSaveExec");
    1311 
     1316
     1317#ifdef DEBUG
     1318    virtioDumpState(pVirtio, (const char *)"virtioSaveExec");
     1319#endif
    13121320    rc = SSMR3PutBool(pSSM,   pVirtio->fGenUpdatePending);
    13131321    rc = SSMR3PutU8(pSSM,     pVirtio->uDeviceStatus);
     
    13651373
    13661374    int rc = VINF_SUCCESS;
     1375
     1376#ifdef DEBUG
    13671377    virtioDumpState(pVirtio, "virtioLoadExec");
     1378#endif
    13681379
    13691380    if (uPass == SSM_PASS_FINAL)
     
    14241435
    14251436    int rc = VINF_SUCCESS;
     1437#ifdef DEBUG
    14261438    virtioDumpState(pVirtio, "virtioLoadDone");
    1427 
     1439#endif
    14281440    rc = pVirtio->virtioCallbacks.pfnSSMDevLoadDone(pDevIns, pSSM);
    14291441
     
    14371449
    14381450    int rc = VINF_SUCCESS;
     1451
     1452#ifdef DEBUG
    14391453    virtioDumpState(pVirtio, "virtioLiveExec");
    1440 
     1454#endif
    14411455    rc = pVirtio->virtioCallbacks.pfnSSMDevLiveExec(pDevIns, pSSM, uPass);
    14421456
     
    14731487    }
    14741488    Log(("\n"));
     1489    RT_NOREF2(uBase, pv);
    14751490 }
    14761491
     
    14891504 */
    14901505void virtioLogMappedIoValue(const char *pszFunc, const char *pszMember, uint32_t uMemberSize,
    1491                         const void *pv, uint32_t cb, uint32_t uOffset, bool fWrite,
    1492                         bool fHasIndex, uint32_t idx)
     1506                        const void *pv, uint32_t cb, uint32_t uOffset, int fWrite,
     1507                        int fHasIndex, uint32_t idx)
    14931508{
    14941509
     
    15291544              pszIdx, uOffset, uOffset + cb, cb, pv));
    15301545    }
     1546    RT_NOREF2(fWrite, pszFunc);
    15311547}
    15321548
  • trunk/src/VBox/Devices/VirtIO/Virtio_1_0.h

    r80928 r80931  
    6565{
    6666    uint32_t  uHeadIdx;                                    /**< Head idx of associated desc chain        */
    67     uint32_t    cbVirtSrc;                                   /**< Size of virt source buffer               */
     67    uint32_t  cbVirtSrc;                                   /**< Size of virt source buffer               */
    6868    void     *pVirtSrc;                                    /**< Virt mem buf holding out data from guest */
    69     uint32_t    cbPhysDst;                                   /**< Total size of dst buffer                 */
     69    uint32_t  cbPhysDst;                                   /**< Total size of dst buffer                 */
    7070    PRTSGBUF  pSgPhysDst;                                  /**< Phys S/G buf to store result for guest   */
    7171} VIRTIO_DESC_CHAIN_T, *PVIRTIO_DESC_CHAIN_T, **PPVIRTIO_DESC_CHAIN_T;
     
    9696 * @param pClient       Pointer to opaque client data (state)
    9797 */
    98 typedef DECLCALLBACK(void)   FNVIRTIOSTATUSCHANGED(VIRTIOHANDLE hVirtio, void *pClient, bool fDriverOk);
     98typedef DECLCALLBACK(void)   FNVIRTIOSTATUSCHANGED(VIRTIOHANDLE hVirtio, void *pClient, uint32_t fDriverOk);
    9999typedef FNVIRTIOSTATUSCHANGED *PFNVIRTIOSTATUSCHANGED;
    100100
     
    140140{
    141141     DECLCALLBACKMEMBER(void, pfnVirtioStatusChanged)
    142                                   (VIRTIOHANDLE hVirtio, void *pClient, bool fDriverOk);
     142                                  (VIRTIOHANDLE hVirtio, void *pClient, uint32_t fDriverOk);
    143143     DECLCALLBACKMEMBER(void, pfnVirtioQueueNotified)
    144144                                  (VIRTIOHANDLE hVirtio, void *pClient, uint16_t qIdx);
     
    320320 */
    321321uint64_t virtioGetNegotiatedFeatures(VIRTIOHANDLE hVirtio);
    322 
    323322
    324323/** CLIENT MUST CALL ON RELOCATE CALLBACK! */
     
    383382void virtioLogMappedIoValue(const char *pszFunc, const char *pszMember, uint32_t uMemberSize,
    384383                            const void *pv, uint32_t cb, uint32_t uOffset,
    385                             bool fWrite, bool fHasIndex, uint32_t idx);
    386 
     384                            int fWrite, int fHasIndex, uint32_t idx);
    387385/**
    388386 * Does a formatted hex dump using Log(()), recommend using VIRTIO_HEX_DUMP() macro to
  • trunk/src/VBox/Devices/VirtIO/Virtio_1_0_impl.h

    r80928 r80931  
    240240/**
    241241* This macro returns true if the implied parameter GCPhysAddr address and access length are
    242 * within mapped capability struct specified with the explicit parameters.
     242* within the range of the mapped capability struct specified with the explicit parameters.
    243243*
    244244* Actual Parameters:
     
    283283#define LOG_COMMON_CFG_ACCESS_INDEXED(member, idx) \
    284284        virtioLogMappedIoValue(__FUNCTION__, #member, RT_SIZEOFMEMB(VIRTIO_PCI_COMMON_CFG_T, member), \
    285                                pv, cb, uIntraOff, fWrite, true, idx);
     285                                pv, cb, uIntraOff, fWrite, true, idx);
    286286
    287287#define COMMON_CFG_ACCESSOR(member) \
     
    521521}
    522522
     523static int  virtioCommonCfgAccessed (PVIRTIOSTATE pVirtio, int fWrite, off_t uOffset, unsigned cb, void const *pv);
    523524static void virtioResetQueue        (PVIRTIOSTATE pVirtio, uint16_t qIdx);
    524525static void virtioNotifyGuestDriver (PVIRTIOSTATE pVirtio, uint16_t qIdx, bool fForce);
     
    526527static void virtioLowerInterrupt    (PVIRTIOSTATE pVirtio);
    527528static void virtioQueueNotified     (PVIRTIOSTATE pVirtio, uint16_t qidx, uint16_t uDescIdx);
    528 static int  virtioCommonCfgAccessed (PVIRTIOSTATE pVirtio, int fWrite, off_t uOffset, unsigned cb, void const *pv);
    529529static void virtioGuestResetted     (PVIRTIOSTATE pVirtio);
    530530
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