VirtualBox

Changeset 86485 in vbox for trunk/src


Ignore:
Timestamp:
Oct 8, 2020 6:56:12 AM (4 years ago)
Author:
vboxsync
Message:

AMD IOMMU: bugref:9654 PCNet: Use PCI interfaces while reading/writing guest physical memory.

File:
1 edited

Legend:

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

    r85955 r86485  
    759759}
    760760
     761
     762/**
     763 * Memory read helper to handle PCI/ISA differences.
     764 *
     765 * @returns nothing.
     766 * @param   pDevIns     The device instance.
     767 * @param   pThis       Pointer to the PCNet device instance.
     768 * @param   GCPhys      Guest physical memory address.
     769 * @param   pvBuf       Host side buffer address.
     770 * @param   cbRead      Number of bytes to read.
     771 */
     772static void pcnetPhysRead(PPDMDEVINS pDevIns, PPCNETSTATE pThis, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)
     773{
     774    if (!PCNET_IS_ISA(pThis))
     775        PDMDevHlpPCIPhysRead(pDevIns, GCPhys, pvBuf, cbRead);
     776    else
     777        PDMDevHlpPhysRead(pDevIns, GCPhys, pvBuf, cbRead);
     778}
     779
     780
    761781/**
    762782 * Load transmit message descriptor (TMD) if we own it.
     
    779799
    780800        /* For SWSTYLE=0, the OWN bit is in the second WORD we need and must be read before the first WORD. */
    781         PDMDevHlpPhysRead(pDevIns, addr + sizeof(uint16_t), (void*)&xda[1], 2 * sizeof(uint16_t));
     801        pcnetPhysRead(pDevIns, pThis, addr + sizeof(uint16_t), (void*)&xda[1], 2 * sizeof(uint16_t));
    782802        if (!(xda[1] & RT_BIT(15)))
    783803            return false;
    784         PDMDevHlpPhysRead(pDevIns, addr, (void*)&xda[0], sizeof(uint16_t));
     804        pcnetPhysRead(pDevIns, pThis, addr, (void*)&xda[0], sizeof(uint16_t));
    785805        ((uint32_t *)tmd)[0] = (uint32_t)xda[0] | ((uint32_t)(xda[1] & 0x00ff) << 16);  /* TMD0, buffer address. */
    786806        ((uint32_t *)tmd)[1] = (uint32_t)xda[2] | ((uint32_t)(xda[1] & 0xff00) << 16);  /* TMD1, buffer size and control bits. */
     
    792812        /* For SWSTYLE=2, the OWN bit is in the second DWORD we need and must be read first. */
    793813        uint32_t xda[2];
    794         PDMDevHlpPhysRead(pDevIns, addr + sizeof(uint32_t), (void*)&xda[1], sizeof(uint32_t));
     814        pcnetPhysRead(pDevIns, pThis, addr + sizeof(uint32_t), (void*)&xda[1], sizeof(uint32_t));
    795815        if (!(xda[1] & RT_BIT(31)))
    796816            return false;
    797         PDMDevHlpPhysRead(pDevIns, addr, (void*)&xda[0], sizeof(uint32_t));
     817        pcnetPhysRead(pDevIns, pThis, addr, (void*)&xda[0], sizeof(uint32_t));
    798818        ((uint32_t *)tmd)[0] = xda[0];  /* TMD0, buffer address. */
    799819        ((uint32_t *)tmd)[1] = xda[1];  /* TMD1, buffer size and control bits. */
     
    805825        /* For SWSTYLE=3, the OWN bit is in the first DWORD we need, therefore a single read suffices. */
    806826        uint32_t xda[2];
    807         PDMDevHlpPhysRead(pDevIns, addr + sizeof(uint32_t), (void*)&xda, sizeof(xda));
     827        pcnetPhysRead(pDevIns, pThis, addr + sizeof(uint32_t), (void*)&xda, sizeof(xda));
    808828        if (!(xda[0] & RT_BIT(31)))
    809829            return false;
     
    834854
    835855        /* For SWSTYLE=0, we have to do a bit of work. */
    836         PDMDevHlpPhysRead(pDevIns, addr, (void*)&xda, sizeof(xda));
     856        pcnetPhysRead(pDevIns, pThis, addr, (void*)&xda, sizeof(xda));
    837857        ((uint32_t *)tmd)[0] = (uint32_t)xda[0] | ((uint32_t)(xda[1] & 0x00ff) << 16);  /* TMD0, buffer address. */
    838858        ((uint32_t *)tmd)[1] = (uint32_t)xda[2] | ((uint32_t)(xda[1] & 0xff00) << 16);  /* TMD1, buffer size and control bits. */
     
    843863    {
    844864        /* For SWSTYLE=2, simply read the TMD as is. */
    845         PDMDevHlpPhysRead(pDevIns, addr, (void*)tmd, sizeof(*tmd));
     865        pcnetPhysRead(pDevIns, pThis, addr, (void*)tmd, sizeof(*tmd));
    846866    }
    847867    else
     
    849869        /* For SWSTYLE=3, swap the first and third DWORD around. */
    850870        uint32_t xda[4];
    851         PDMDevHlpPhysRead(pDevIns, addr, (void*)&xda, sizeof(xda));
     871        pcnetPhysRead(pDevIns, pThis, addr, (void*)&xda, sizeof(xda));
    852872        ((uint32_t *)tmd)[0] = xda[2];  /* TMD0, buffer address. */
    853873        ((uint32_t *)tmd)[1] = xda[1];  /* TMD1, buffer size and control bits. */
     
    918938    {
    919939        uint16_t rda[4];
    920         PDMDevHlpPhysRead(pDevIns, addr+3, &ownbyte, 1);
     940        pcnetPhysRead(pDevIns, pThis, addr+3, &ownbyte, 1);
    921941        if (!(ownbyte & 0x80) && fRetIfNotOwn)
    922942            return false;
    923         PDMDevHlpPhysRead(pDevIns, addr, (void*)&rda[0], sizeof(rda));
     943        pcnetPhysRead(pDevIns, pThis, addr, (void*)&rda[0], sizeof(rda));
    924944        ((uint32_t *)rmd)[0] = (uint32_t)rda[0] | ((rda[1] & 0x00ff) << 16);
    925945        ((uint32_t *)rmd)[1] = (uint32_t)rda[2] | ((rda[1] & 0xff00) << 16);
     
    929949    else if (RT_LIKELY(BCR_SWSTYLE(pThis) != 3))
    930950    {
    931         PDMDevHlpPhysRead(pDevIns, addr+7, &ownbyte, 1);
     951        pcnetPhysRead(pDevIns, pThis, addr+7, &ownbyte, 1);
    932952        if (!(ownbyte & 0x80) && fRetIfNotOwn)
    933953            return false;
    934         PDMDevHlpPhysRead(pDevIns, addr, (void*)rmd, 16);
     954        pcnetPhysRead(pDevIns, pThis, addr, (void*)rmd, 16);
    935955    }
    936956    else
    937957    {
    938958        uint32_t rda[4];
    939         PDMDevHlpPhysRead(pDevIns, addr+7, &ownbyte, 1);
     959        pcnetPhysRead(pDevIns, pThis, addr+7, &ownbyte, 1);
    940960        if (!(ownbyte & 0x80) && fRetIfNotOwn)
    941961            return false;
    942         PDMDevHlpPhysRead(pDevIns, addr, (void*)&rda[0], sizeof(rda));
     962        pcnetPhysRead(pDevIns, pThis, addr, (void*)&rda[0], sizeof(rda));
    943963        ((uint32_t *)rmd)[0] = rda[2];
    944964        ((uint32_t *)rmd)[1] = rda[1];
     
    10091029    else
    10101030        cbDesc = 16;
    1011     PDMDevHlpPhysRead(pDevIns, addr, aBuf, cbDesc);
     1031    pcnetPhysRead(pDevIns, pThis, addr, aBuf, cbDesc);
    10121032    pcnetPhysWrite(pDevIns, pThis, addr, aBuf, cbDesc);
    10131033}
     
    15771597     *        Software is allowed to write these registers directly. */
    15781598# define PCNET_INIT() do { \
    1579             PDMDevHlpPhysRead(pDevIns, PHYSADDR(pThis, CSR_IADR(pThis)),         \
    1580                               (uint8_t *)&initblk, sizeof(initblk));             \
     1599            pcnetPhysRead(pDevIns, pThis, PHYSADDR(pThis, CSR_IADR(pThis)),      \
     1600                          (uint8_t *)&initblk, sizeof(initblk));                 \
    15811601            pThis->aCSR[15]  = RT_LE2H_U16(initblk.mode);                        \
    15821602            CSR_RCVRL(pThis) = (initblk.rlen < 9) ? (1 << initblk.rlen) : 512;   \
     
    22812301static void pcnetXmitRead1stSlow(PPDMDEVINS pDevIns, RTGCPHYS32 GCPhysFrame, unsigned cbFrame, PPDMSCATTERGATHER pSgBuf)
    22822302{
     2303    PPCNETSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PPCNETSTATE);
    22832304    pSgBuf->cbUsed = cbFrame;
    22842305    for (uint32_t iSeg = 0; ; iSeg++)
     
    22922313
    22932314        uint32_t cbRead = (uint32_t)RT_MIN(cbFrame, pSgBuf->aSegs[iSeg].cbSeg);
    2294         PDMDevHlpPhysRead(pDevIns, GCPhysFrame, pSgBuf->aSegs[iSeg].pvSeg, cbRead);
     2315        pcnetPhysRead(pDevIns, pThis, GCPhysFrame, pSgBuf->aSegs[iSeg].pvSeg, cbRead);
    22952316        cbFrame -= cbRead;
    22962317        if (!cbFrame)
     
    23072328static void pcnetXmitReadMoreSlow(PPDMDEVINS pDevIns, RTGCPHYS32 GCPhysFrame, unsigned cbFrame, PPDMSCATTERGATHER pSgBuf)
    23082329{
     2330    PPCNETSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PPCNETSTATE);
     2331
    23092332    /* Find the segment which we'll put the next byte into. */
    23102333    size_t      off    = pSgBuf->cbUsed;
     
    23312354        size_t   offIntoSeg = off - offSeg;
    23322355        uint32_t cbRead     = (uint32_t)RT_MIN(pSgBuf->aSegs[iSeg].cbSeg - offIntoSeg, cbFrame);
    2333         PDMDevHlpPhysRead(pDevIns, GCPhysFrame,
    2334                           (uint8_t *)pSgBuf->aSegs[iSeg].pvSeg + offIntoSeg, cbRead);
     2356        pcnetPhysRead(pDevIns, pThis, GCPhysFrame,
     2357                      (uint8_t *)pSgBuf->aSegs[iSeg].pvSeg + offIntoSeg, cbRead);
    23352358        cbFrame -= cbRead;
    23362359        if (!cbFrame)
     
    23512374
    23522375        uint32_t cbRead = (uint32_t)RT_MIN(pSgBuf->aSegs[iSeg].cbSeg, cbFrame);
    2353         PDMDevHlpPhysRead(pDevIns, GCPhysFrame, pSgBuf->aSegs[iSeg].pvSeg, cbRead);
     2376        pcnetPhysRead(pDevIns, pThis, GCPhysFrame, pSgBuf->aSegs[iSeg].pvSeg, cbRead);
    23542377        cbFrame -= cbRead;
    23552378        if (!cbFrame)
     
    23722395    {
    23732396        pSgBuf->cbUsed = cbFrame;
    2374         PDMDevHlpPhysRead(pDevIns, GCPhysFrame, pSgBuf->aSegs[0].pvSeg, cbFrame);
     2397        pcnetPhysRead(pDevIns, pThis, GCPhysFrame, pSgBuf->aSegs[0].pvSeg, cbFrame);
    23752398    }
    23762399    else
     
    23892412    {
    23902413        pSgBuf->cbUsed = cbFrame + off;
    2391         PDMDevHlpPhysRead(pDevIns, GCPhysFrame, (uint8_t *)pSgBuf->aSegs[0].pvSeg + off, cbFrame);
     2414        PPCNETSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PPCNETSTATE);
     2415        pcnetPhysRead(pDevIns, pThis, GCPhysFrame, (uint8_t *)pSgBuf->aSegs[0].pvSeg + off, cbFrame);
    23922416    }
    23932417    else
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