VirtualBox

Changeset 80647 in vbox


Ignore:
Timestamp:
Sep 6, 2019 9:20:04 PM (5 years ago)
Author:
vboxsync
Message:

Storage/DevVirtioSCSI.cpp: Fixed problem with Assert closing VM in semaphore. Other small cleanups

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

Legend:

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

    r80639 r80647  
    131131
    132132#define SCSI_CONFIG_ACCESSOR(member) \
     133    do \
    133134    { \
    134135        uint32_t uIntraOffset = uOffset - RT_UOFFSETOF(VIRTIOSCSI_CONFIG_T, member); \
     
    138139            memcpy((char *)pv, (const char *)(((char *)&pThis->virtioScsiConfig.member) + uIntraOffset), cb); \
    139140        LOG_ACCESSOR(member); \
    140     }
     141    } while(0)
    141142
    142143#define SCSI_CONFIG_ACCESSOR_READONLY(member) \
     144    do \
    143145    { \
    144146        uint32_t uIntraOffset = uOffset - RT_UOFFSETOF(VIRTIOSCSI_CONFIG_T, member); \
     
    150152            LOG_ACCESSOR(member); \
    151153        } \
    152     }
     154    } while(0)
    153155
    154156#define VIRTIO_IN_DIRECTION(pMediaExTxDirEnumValue) \
     
    14501452    int rc = VINF_SUCCESS;
    14511453    if (MATCH_SCSI_CONFIG(uNumQueues))
    1452     {
    14531454        SCSI_CONFIG_ACCESSOR_READONLY(uNumQueues);
    1454     }
    14551455    else
    14561456    if (MATCH_SCSI_CONFIG(uSegMax))
    1457     {
    14581457        SCSI_CONFIG_ACCESSOR_READONLY(uSegMax);
    1459     }
    14601458    else
    14611459    if (MATCH_SCSI_CONFIG(uMaxSectors))
    1462     {
    14631460        SCSI_CONFIG_ACCESSOR_READONLY(uMaxSectors);
    1464     }
    14651461    else
    14661462    if (MATCH_SCSI_CONFIG(uCmdPerLun))
    1467     {
    14681463        SCSI_CONFIG_ACCESSOR_READONLY(uCmdPerLun);
    1469     }
    14701464    else
    14711465    if (MATCH_SCSI_CONFIG(uEventInfoSize))
    1472     {
    14731466        SCSI_CONFIG_ACCESSOR_READONLY(uEventInfoSize);
    1474     }
    14751467    else
    14761468    if (MATCH_SCSI_CONFIG(uSenseSize))
    1477     {
    14781469        SCSI_CONFIG_ACCESSOR(uSenseSize);
    1479     }
    14801470    else
    14811471    if (MATCH_SCSI_CONFIG(uCdbSize))
    1482     {
    14831472        SCSI_CONFIG_ACCESSOR(uCdbSize);
    1484     }
    14851473    else
    14861474    if (MATCH_SCSI_CONFIG(uMaxChannel))
    1487     {
    14881475        SCSI_CONFIG_ACCESSOR_READONLY(uMaxChannel);
    1489     }
    14901476    else
    14911477    if (MATCH_SCSI_CONFIG(uMaxTarget))
    1492     {
    14931478        SCSI_CONFIG_ACCESSOR_READONLY(uMaxTarget);
    1494     }
    14951479    else
    14961480    if (MATCH_SCSI_CONFIG(uMaxLun))
    1497     {
    14981481        SCSI_CONFIG_ACCESSOR_READONLY(uMaxLun);
    1499     }
    15001482    else
    15011483    {
     
    21102092    PVIRTIOSCSI  pThis = PDMINS_2_DATA(pDevIns, PVIRTIOSCSI);
    21112093
    2112     for (int qIdx = 0; qIdx < VIRTQ_MAX_CNT; qIdx++)
     2094    for (int qIdx = 0; qIdx < VIRTIOSCSI_QUEUE_CNT; qIdx++)
    21132095    {
    21142096        PWORKER pWorker = &pThis->aWorker[qIdx];
  • trunk/src/VBox/Devices/VirtIO/Virtio_1_0.cpp

    r80639 r80647  
    3636#define QUEUENAME(qIdx) (pVirtio->virtqProxy[qIdx].szVirtqName)
    3737
    38 /**
    39  * Formats the logging of a memory-mapped I/O input or output value
    40  *
    41  * @param   pszFunc     - To avoid displaying this function's name via __FUNCTION__ or Log2Func()
    42  * @param   pszMember   - Name of struct member
    43  * @param   pv          - Pointer to value
    44  * @param   cb          - Size of value
    45  * @param   uOffset     - Offset into member where value starts
    46  * @param   fWrite      - True if write I/O
    47  * @param   fHasIndex   - True if the member is indexed
    48  * @param   idx         - The index, if fHasIndex is true
    49  */
    50 void virtioLogMappedIoValue(const char *pszFunc, const char *pszMember, size_t uMemberSize,
    51                         const void *pv, uint32_t cb, uint32_t uOffset, bool fWrite,
    52                         bool fHasIndex, uint32_t idx)
    53 {
    54 
    55 #define FMTHEX(fmtout, val, cNybbles) \
    56     fmtout[cNybbles] = '\0'; \
    57     for (uint8_t i = 0; i < cNybbles; i++) \
    58         fmtout[(cNybbles - i) - 1] = "0123456789abcdef"[(val >> (i * 4)) & 0xf];
    59 
    60 #define MAX_STRING   64
    61     char pszIdx[MAX_STRING] = { 0 };
    62     char pszDepiction[MAX_STRING] = { 0 };
    63     char pszFormattedVal[MAX_STRING] = { 0 };
    64     if (fHasIndex)
    65         RTStrPrintf(pszIdx, sizeof(pszIdx), "[%d]", idx);
    66     if (cb == 1 || cb == 2 || cb == 4 || cb == 8)
    67     {
    68         /* manually padding with 0's instead of \b due to different impl of %x precision than printf() */
    69         uint64_t val = 0;
    70         memcpy((char *)&val, pv, cb);
    71         FMTHEX(pszFormattedVal, val, cb * 2);
    72         if (uOffset != 0 || cb != uMemberSize) /* display bounds if partial member access */
    73             RTStrPrintf(pszDepiction, sizeof(pszDepiction), "%s%s[%d:%d]",
    74                         pszMember, pszIdx, uOffset, uOffset + cb - 1);
    75         else
    76             RTStrPrintf(pszDepiction, sizeof(pszDepiction), "%s%s", pszMember, pszIdx);
    77         RTStrPrintf(pszDepiction, sizeof(pszDepiction), "%-30s", pszDepiction);
    78         uint32_t first = 0;
    79         for (uint8_t i = 0; i < sizeof(pszDepiction); i++)
    80             if (pszDepiction[i] == ' ' && first++)
    81                 pszDepiction[i] = '.';
    82         Log6Func(("%s: Guest %s %s 0x%s\n",
    83                   pszFunc, fWrite ? "wrote" : "read ", pszDepiction, pszFormattedVal));
    84     }
    85     else /* odd number or oversized access, ... log inline hex-dump style */
    86     {
    87         Log6Func(("%s: Guest %s %s%s[%d:%d]: %.*Rhxs\n",
    88               pszFunc, fWrite ? "wrote" : "read ", pszMember,
    89               pszIdx, uOffset, uOffset + cb, cb, pv));
    90     }
    91 }
    9238
    9339/**
     
    664610        }
    665611    }
    666     else if (MATCH_COMMON_CFG(uMsixConfig))
    667     {
     612    else
     613    if (MATCH_COMMON_CFG(uMsixConfig))
    668614        COMMON_CFG_ACCESSOR(uMsixConfig);
    669     }
    670     else if (MATCH_COMMON_CFG(uDeviceFeaturesSelect))
    671     {
     615    else
     616    if (MATCH_COMMON_CFG(uDeviceFeaturesSelect))
    672617        COMMON_CFG_ACCESSOR(uDeviceFeaturesSelect);
    673     }
    674     else if (MATCH_COMMON_CFG(uDriverFeaturesSelect))
    675     {
     618    else
     619    if (MATCH_COMMON_CFG(uDriverFeaturesSelect))
    676620        COMMON_CFG_ACCESSOR(uDriverFeaturesSelect);
    677     }
    678     else if (MATCH_COMMON_CFG(uConfigGeneration))
    679     {
     621    else
     622    if (MATCH_COMMON_CFG(uConfigGeneration))
    680623        COMMON_CFG_ACCESSOR_READONLY(uConfigGeneration);
    681     }
    682     else if (MATCH_COMMON_CFG(uQueueSelect))
    683     {
     624    else
     625    if (MATCH_COMMON_CFG(uQueueSelect))
    684626        COMMON_CFG_ACCESSOR(uQueueSelect);
    685     }
    686     else if (MATCH_COMMON_CFG(uQueueSize))
    687     {
     627    else
     628    if (MATCH_COMMON_CFG(uQueueSize))
    688629        COMMON_CFG_ACCESSOR_INDEXED(uQueueSize, pVirtio->uQueueSelect);
    689     }
    690     else if (MATCH_COMMON_CFG(uQueueMsixVector))
    691     {
     630    else
     631    if (MATCH_COMMON_CFG(uQueueMsixVector))
    692632        COMMON_CFG_ACCESSOR_INDEXED(uQueueMsixVector, pVirtio->uQueueSelect);
    693     }
    694     else if (MATCH_COMMON_CFG(uQueueEnable))
    695     {
     633    else
     634    if (MATCH_COMMON_CFG(uQueueEnable))
    696635        COMMON_CFG_ACCESSOR_INDEXED(uQueueEnable, pVirtio->uQueueSelect);
    697     }
    698     else if (MATCH_COMMON_CFG(uQueueNotifyOff))
    699     {
     636    else
     637    if (MATCH_COMMON_CFG(uQueueNotifyOff))
    700638        COMMON_CFG_ACCESSOR_INDEXED_READONLY(uQueueNotifyOff, pVirtio->uQueueSelect);
    701     }
    702     else if (MATCH_COMMON_CFG(pGcPhysQueueDesc))
    703     {
     639    else
     640    if (MATCH_COMMON_CFG(pGcPhysQueueDesc))
    704641        COMMON_CFG_ACCESSOR_INDEXED(pGcPhysQueueDesc, pVirtio->uQueueSelect);
    705     }
    706     else if (MATCH_COMMON_CFG(pGcPhysQueueAvail))
    707     {
     642    else
     643    if (MATCH_COMMON_CFG(pGcPhysQueueAvail))
    708644        COMMON_CFG_ACCESSOR_INDEXED(pGcPhysQueueAvail, pVirtio->uQueueSelect);
    709     }
    710     else if (MATCH_COMMON_CFG(pGcPhysQueueUsed))
    711     {
     645    else
     646    if (MATCH_COMMON_CFG(pGcPhysQueueUsed))
    712647        COMMON_CFG_ACCESSOR_INDEXED(pGcPhysQueueUsed, pVirtio->uQueueSelect);
    713     }
    714648    else
    715649    {
     
    14581392
    14591393    return rc;
    1460 
    14611394}
    14621395
     
    14921425 }
    14931426
     1427
     1428/**
     1429 * Formats the logging of a memory-mapped I/O input or output value
     1430 *
     1431 * @param   pszFunc     - To avoid displaying this function's name via __FUNCTION__ or Log2Func()
     1432 * @param   pszMember   - Name of struct member
     1433 * @param   pv          - Pointer to value
     1434 * @param   cb          - Size of value
     1435 * @param   uOffset     - Offset into member where value starts
     1436 * @param   fWrite      - True if write I/O
     1437 * @param   fHasIndex   - True if the member is indexed
     1438 * @param   idx         - The index, if fHasIndex is true
     1439 */
     1440void virtioLogMappedIoValue(const char *pszFunc, const char *pszMember, size_t uMemberSize,
     1441                        const void *pv, uint32_t cb, uint32_t uOffset, bool fWrite,
     1442                        bool fHasIndex, uint32_t idx)
     1443{
     1444
     1445#define FMTHEX(fmtout, val, cNybbles) \
     1446    fmtout[cNybbles] = '\0'; \
     1447    for (uint8_t i = 0; i < cNybbles; i++) \
     1448        fmtout[(cNybbles - i) - 1] = "0123456789abcdef"[(val >> (i * 4)) & 0xf];
     1449
     1450#define MAX_STRING   64
     1451    char pszIdx[MAX_STRING] = { 0 };
     1452    char pszDepiction[MAX_STRING] = { 0 };
     1453    char pszFormattedVal[MAX_STRING] = { 0 };
     1454    if (fHasIndex)
     1455        RTStrPrintf(pszIdx, sizeof(pszIdx), "[%d]", idx);
     1456    if (cb == 1 || cb == 2 || cb == 4 || cb == 8)
     1457    {
     1458        /* manually padding with 0's instead of \b due to different impl of %x precision than printf() */
     1459        uint64_t val = 0;
     1460        memcpy((char *)&val, pv, cb);
     1461        FMTHEX(pszFormattedVal, val, cb * 2);
     1462        if (uOffset != 0 || cb != uMemberSize) /* display bounds if partial member access */
     1463            RTStrPrintf(pszDepiction, sizeof(pszDepiction), "%s%s[%d:%d]",
     1464                        pszMember, pszIdx, uOffset, uOffset + cb - 1);
     1465        else
     1466            RTStrPrintf(pszDepiction, sizeof(pszDepiction), "%s%s", pszMember, pszIdx);
     1467        RTStrPrintf(pszDepiction, sizeof(pszDepiction), "%-30s", pszDepiction);
     1468        uint32_t first = 0;
     1469        for (uint8_t i = 0; i < sizeof(pszDepiction); i++)
     1470            if (pszDepiction[i] == ' ' && first++)
     1471                pszDepiction[i] = '.';
     1472        Log6Func(("%s: Guest %s %s 0x%s\n",
     1473                  pszFunc, fWrite ? "wrote" : "read ", pszDepiction, pszFormattedVal));
     1474    }
     1475    else /* odd number or oversized access, ... log inline hex-dump style */
     1476    {
     1477        Log6Func(("%s: Guest %s %s%s[%d:%d]: %.*Rhxs\n",
     1478              pszFunc, fWrite ? "wrote" : "read ", pszMember,
     1479              pszIdx, uOffset, uOffset + cb, cb, pv));
     1480    }
     1481}
     1482
    14941483#endif /* IN_RING3 */
    14951484
  • trunk/src/VBox/Devices/VirtIO/Virtio_1_0_impl.h

    r80596 r80647  
    300300
    301301#define COMMON_CFG_ACCESSOR(member) \
     302    do \
    302303    { \
    303304        uint32_t uIntraOff = uOffset - RT_OFFSETOF(VIRTIO_PCI_COMMON_CFG_T, member); \
     
    307308            memcpy((char *)pv, (const char *)(((char *)&pVirtio->member) + uIntraOff), cb); \
    308309        LOG_COMMON_CFG_ACCESS(member); \
    309     }
     310    } while(0)
    310311
    311312#define COMMON_CFG_ACCESSOR_INDEXED(member, idx) \
     313    do \
    312314    { \
    313315        uint32_t uIntraOff = uOffset - RT_OFFSETOF(VIRTIO_PCI_COMMON_CFG_T, member); \
     
    317319            memcpy((char *)pv, (const char *)(((char *)(pVirtio->member + idx)) + uIntraOff), cb); \
    318320        LOG_COMMON_CFG_ACCESS_INDEXED(member, idx); \
    319     }
     321    } while(0)
    320322
    321323#define COMMON_CFG_ACCESSOR_READONLY(member) \
     324    do \
    322325    { \
    323326        uint32_t uIntraOff = uOffset - RT_OFFSETOF(VIRTIO_PCI_COMMON_CFG_T, member); \
     
    329332            LOG_COMMON_CFG_ACCESS(member); \
    330333        } \
    331     }
     334    } while(0)
    332335
    333336#define COMMON_CFG_ACCESSOR_INDEXED_READONLY(member, idx) \
     337    do \
    334338    { \
    335339        uint32_t uIntraOff = uOffset - RT_OFFSETOF(VIRTIO_PCI_COMMON_CFG_T, member); \
     
    341345            LOG_COMMON_CFG_ACCESS_INDEXED(member, idx); \
    342346        } \
    343     }
     347    } while(0)
    344348
    345349#define DRIVER_OK(pVirtio) (pVirtio->uDeviceStatus & VIRTIO_STATUS_DRIVER_OK)
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