VirtualBox

Changeset 105209 in vbox for trunk/src/VBox/Devices/USB


Ignore:
Timestamp:
Jul 9, 2024 7:19:57 AM (5 months ago)
Author:
vboxsync
Message:

Devices/USB/DevEHCI: Adjust padding for the ITD, bugref:10709

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/USB/DevEHCI.cpp

    r104838 r105209  
    162162    RTGCPHYS        TdAddr;
    163163    /** A copy of the TD. */
    164     uint32_t        TdCopy[16];
     164    uint32_t        TdCopy[18];
    165165} VUSBURBHCITDINT;
    166166
     
    527527/** @} */
    528528
    529 /* ITD with extra padding to add 8th 'Buffer' entry. The PG member of
     529/* ITD with extra padding to add 8th and 9th 'Buffer' entry. The PG member of
    530530 * EHCI_ITD_TRANSACTION can contain values in the 0-7 range, but only values
    531531 * 0-6 are valid. The extra padding is added to avoid cluttering the code
    532532 * with range checks; ehciR3ReadItd() initializes the pad with a safe value.
    533533 * The EHCI 1.0 specification explicitly says using PG value of 7 yields
    534  * undefined behavior.
     534 * undefined behavior. Two pad entries are needed because initial PG value
     535 * of 7 (already 'wrong') can cross to the next page (8).
    535536 */
    536537typedef struct
    537538{
    538     EHCI_ITD         itd;
    539     EHCI_BUFFER_PTR  pad;
     539    EHCI_TD_PTR             Next;
     540    EHCI_ITD_TRANSACTION    Transaction[EHCI_NUM_ITD_TRANSACTIONS];
     541    union
     542    {
     543        EHCI_ITD_MISC       Misc;
     544        EHCI_BUFFER_PTR     Buffer[EHCI_NUM_ITD_PAGES + 2];
     545    } Buffer;
    540546} EHCI_ITD_PAD, *PEHCI_ITD_PAD;
    541 AssertCompileSize(EHCI_ITD_PAD, 0x44);
     547AssertCompileSize(EHCI_ITD_PAD, 0x48);
    542548
    543549/** @name Split Transaction Isochronous Transfer Descriptor (siTD)
     
    14721478{
    14731479    ehciGetDWords(pDevIns, GCPhys, (uint32_t *)pPItd, sizeof(EHCI_ITD) >> 2);
    1474     pPItd->pad.Pointer = 0xFFFFF;   /* Direct accesses at the last page under 4GB (ROM). */
     1480    pPItd->Buffer.Buffer[7].Pointer = 0xFFFFF;  /* Direct ill-defined accesses to the last page under 4GB (ROM). */
     1481    pPItd->Buffer.Buffer[8].Pointer = 0xFFFFF;
    14751482}
    14761483
     
    14801487}
    14811488
    1482 DECLINLINE(void) ehciR3WriteItd(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, PEHCI_ITD pItd)
     1489DECLINLINE(void) ehciR3WriteItd(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, PEHCI_ITD_PAD pItd)
    14831490{
    14841491    /** @todo might need to be careful about write order in async io thread */
     
    14911498    Assert(!(offWrite % sizeof(uint32_t)));
    14921499
    1493     ehciPutDWords(pDevIns, GCPhys + offWrite, (uint32_t *)pItd + offDWordsWrite,  (sizeof(*pItd) >> 2) - offDWordsWrite);
     1500    ehciPutDWords(pDevIns, GCPhys + offWrite, (uint32_t *)pItd + offDWordsWrite,  (sizeof(EHCI_ITD) >> 2) - offDWordsWrite);
    14941501}
    14951502
     
    17591766        /* Read the whole ITD */
    17601767        EHCI_ITD_PAD    PaddedItd;
    1761         PEHCI_ITD       pItd = &PaddedItd.itd;
     1768        PEHCI_ITD_PAD   pItd = &PaddedItd;
    17621769        ehciR3ReadItd(pDevIns, GCPhys, &PaddedItd);
    17631770
     
    20292036 * @param   pItd        The ITD pointer.
    20302037 */
    2031 static bool ehciR3ItdHasUrbBeenCanceled(PEHCICC pThisCC, PVUSBURB pUrb, PEHCI_ITD pItd)
     2038static bool ehciR3ItdHasUrbBeenCanceled(PEHCICC pThisCC, PVUSBURB pUrb, PEHCI_ITD_PAD pItd)
    20322039{
    20332040    RT_NOREF(pThisCC);
     
    22532260    /* Read the whole ITD */
    22542261    EHCI_ITD_PAD  PaddedItd;
    2255     PEHCI_ITD     pItd = &PaddedItd.itd;
     2262    PEHCI_ITD_PAD pItd = &PaddedItd;
    22562263    ehciR3ReadItd(pDevIns, pUrb->paTds[0].TdAddr, &PaddedItd);
    22572264
     
    23242331                            ehciPhysWrite(pDevIns, GCPhysBuf, pb, cb1);
    23252332                            if ((pg + 1) >= EHCI_NUM_ITD_PAGES)
    2326                                LogRelMax(10, ("EHCI: Crossing to undefined page %d in iTD at %RGp on completion.\n", pg + 1, pUrb->paTds[0].TdAddr));
     2333                               LogRelMax(10, ("EHCI: Crossing to nonstandard page %d in iTD at %RGp on completion.\n", pg + 1, pUrb->paTds[0].TdAddr));
    23272334
    23282335                            GCPhysBuf = (RTGCPHYS)pItd->Buffer.Buffer[pg + 1].Pointer << EHCI_BUFFER_PTR_SHIFT;
     
    27912798 */
    27922799static bool ehciR3SubmitITD(PPDMDEVINS pDevIns, PEHCI pThis, PEHCICC pThisCC,
    2793                             PEHCI_ITD pItd, RTGCPHYS ITdAddr, const unsigned iFrame)
     2800                            PEHCI_ITD_PAD pItd, RTGCPHYS ITdAddr, const unsigned iFrame)
    27942801{
    27952802    /*
     
    28762883                    ehciPhysRead(pDevIns, GCPhysBuf, &pUrb->abData[curOffset], cb1);
    28772884                    if ((pg + 1) >= EHCI_NUM_ITD_PAGES)
    2878                        LogRelMax(10, ("EHCI: Crossing to undefined page %d in iTD at %RGp on submit.\n", pg + 1, pUrb->paTds[0].TdAddr));
     2885                       LogRelMax(10, ("EHCI: Crossing to nonstandard page %d in iTD at %RGp on submit.\n", pg + 1, pUrb->paTds[0].TdAddr));
    28792886
    28802887                    GCPhysBuf = (RTGCPHYS)pItd->Buffer.Buffer[pg + 1].Pointer << EHCI_BUFFER_PTR_SHIFT;
     
    29332940    bool          fAnyActive = false;
    29342941    EHCI_ITD_PAD  PaddedItd;
    2935     PEHCI_ITD     pItd = &PaddedItd.itd;
     2942    PEHCI_ITD_PAD pItd = &PaddedItd;
    29362943
    29372944    if (ehciR3IsTdInFlight(pThisCC, GCPhys))
     
    29542961                 * the last page below 4GB (which is ROM, not writable).
    29552962                 */
    2956                 LogRelMax(10, ("EHCI: Illegal page value %d in iTD at %RGp.\n", pItd->Transaction[i].PG, (RTGCPHYS)GCPhys));
     2963                LogRelMax(10, ("EHCI: Nonstandard page value %d in iTD at %RGp.\n", pItd->Transaction[i].PG, (RTGCPHYS)GCPhys));
    29572964            }
    29582965
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