VirtualBox

Changeset 810 in vbox


Ignore:
Timestamp:
Feb 9, 2007 2:24:48 PM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
18486
Message:

Paranoid own bit checks in TMD & RMD reads.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/DevPCNet.cpp

    r808 r810  
    589589/**
    590590 * Load transmit message descriptor
     591 * Make sure we read the own flag first.
    591592 */
    592593DECLINLINE(void) pcnetTmdLoad(PCNetState *pData, TMD *tmd, RTGCPHYS addr)
    593594{
    594595    PPDMDEVINS pDevIns = PCNETSTATE_2_DEVINS(pData);
     596    uint8_t    ownbyte;
     597
    595598    if (!BCR_SWSTYLE(pData))
    596599    {
    597600        uint16_t xda[4];
     601
     602        PDMDevHlpPhysRead(pDevIns, addr+3, &ownbyte, 1);
    598603        PDMDevHlpPhysRead(pDevIns, addr, (void*)&xda[0], sizeof(xda));
    599604        ((uint32_t *)tmd)[0] = (uint32_t)xda[0] | ((uint32_t)(xda[1] & 0x00ff) << 16);
     
    603608    }
    604609    else if (BCR_SWSTYLE(pData) != 3)
     610    {
     611        PDMDevHlpPhysRead(pDevIns, addr+7, &ownbyte, 1);
    605612        PDMDevHlpPhysRead(pDevIns, addr, (void*)tmd, 16);
     613    }
    606614    else
    607615    {
    608616        uint32_t xda[4];
     617        PDMDevHlpPhysRead(pDevIns, addr+7, &ownbyte, 1);
    609618        PDMDevHlpPhysRead(pDevIns, addr, (void*)&xda[0], sizeof(xda));
    610619        ((uint32_t *)tmd)[0] = xda[2];
     
    613622        ((uint32_t *)tmd)[3] = xda[3];
    614623    }
     624    /* Double check the own bit; guest drivers might be buggy and lock prefixes in the recompiler are ignored by other threads. */
     625#ifdef DEBUG
     626    if (tmd->tmd1.own == 0 && (ownbyte & 0x80))
     627        Log(("pcnetTmdLoad: own bit flipped while reading!!\n"));
     628#endif
     629    if (ownbyte & 0x80)
     630        tmd->tmd1.own = 1;
    615631}
    616632
     
    663679{
    664680    PPDMDEVINS pDevIns = PCNETSTATE_2_DEVINS(pData);
     681    uint8_t    ownbyte;
     682
    665683    if (!BCR_SWSTYLE(pData))
    666684    {
    667685        uint16_t rda[4];
     686        PDMDevHlpPhysRead(pDevIns, addr+3, &ownbyte, 1);
    668687        PDMDevHlpPhysRead(pDevIns, addr, (void*)&rda[0], sizeof(rda));
    669688        ((uint32_t *)rmd)[0] = (uint32_t)rda[0] | ((rda[1] & 0x00ff) << 16);
     
    673692    }
    674693    else if (BCR_SWSTYLE(pData) != 3)
     694    {
     695        PDMDevHlpPhysRead(pDevIns, addr+7, &ownbyte, 1);
    675696        PDMDevHlpPhysRead(pDevIns, addr, (void*)rmd, 16);
     697    }
    676698    else
    677699    {
    678700        uint32_t rda[4];
     701        PDMDevHlpPhysRead(pDevIns, addr+7, &ownbyte, 1);
    679702        PDMDevHlpPhysRead(pDevIns, addr, (void*)&rda[0], sizeof(rda));
    680703        ((uint32_t *)rmd)[0] = rda[2];
     
    683706        ((uint32_t *)rmd)[3] = rda[3];
    684707    }
     708    /* Double check the own bit; guest drivers might be buggy and lock prefixes in the recompiler are ignored by other threads. */
     709#ifdef DEBUG
     710    if (rmd->rmd1.own == 0 && (ownbyte & 0x80))
     711        Log(("pcnetTmdLoad: own bit flipped while reading!!\n"));
     712#endif
     713    if (ownbyte & 0x80)
     714        rmd->rmd1.own = 1;
    685715}
    686716
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette