VirtualBox

Ignore:
Timestamp:
Apr 8, 2024 11:47:37 AM (10 months ago)
Author:
vboxsync
Message:

Devices/Serial/DevPcieOx958: Be more strict with what the emulation allows for access sizes, fix status code checks, bugref:10635

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Serial/DevOxPcie958.cpp

    r104224 r104225  
    251251    }
    252252    else /* Access UART registers. */
    253         rc = uartRegRead(pDevIns, &pUart->UartCore, &pUartCC->UartCore, offUartReg, (uint32_t *)pv, cb);
     253    {
     254        AssertReturn(cb == 1, VINF_IOM_MMIO_UNUSED_00);
     255
     256        uint32_t u32 = 0;
     257        rc = uartRegRead(pDevIns, &pUart->UartCore, &pUartCC->UartCore, offUartReg, &u32, 1);
     258        Assert(rc == VINF_SUCCESS || rc == VINF_IOM_R3_IOPORT_READ);
     259
     260        if (rc == VINF_SUCCESS)
     261            *(uint8_t *)pv = (uint8_t)u32;
     262        else if (rc == VERR_IOM_IOPORT_UNUSED)
     263            rc = VINF_IOM_MMIO_UNUSED_00;
     264        else if (rc == VINF_IOM_R3_IOPORT_READ)
     265            rc = VINF_IOM_R3_MMIO_READ;
     266    }
    254267
    255268    return rc;
     
    281294    }
    282295    else /* Access UART registers. */
    283         rc = uartRegWrite(pDevIns, &pUart->UartCore, &pUartCC->UartCore, offUartReg, *(const uint32_t *)pv, cb);
     296    {
     297        AssertReturn(cb == 1, VINF_SUCCESS);
     298
     299        rc = uartRegWrite(pDevIns, &pUart->UartCore, &pUartCC->UartCore, offUartReg, *(const uint8_t *)pv, 1);
     300        Assert(rc == VINF_SUCCESS || rc == VINF_IOM_R3_IOPORT_WRITE);
     301
     302        if (rc == VINF_IOM_R3_IOPORT_WRITE)
     303            rc = VINF_IOM_R3_MMIO_WRITE;
     304    }
    284305
    285306    return rc;
     
    320341    if (off < OX958_REG_UART_REGION_OFFSET)
    321342    {
     343        AssertReturn(cb == 4, VINF_IOM_MMIO_UNUSED_00);
    322344        uint32_t *pu32 = (uint32_t *)pv;
    323         Assert(cb == 4);
    324345
    325346        switch ((uint32_t)off)
     
    361382            POX958UARTCC pUartCC = &pThisCC->aUarts[iUart];
    362383            rc = ox958UartRegRead(pDevIns, pThis, pUart, pUartCC, offUartReg, pv, cb);
    363             if (rc == VINF_IOM_R3_IOPORT_READ)
    364                 rc = VINF_IOM_R3_MMIO_READ;
    365384        }
    366385        else
     
    384403    if (off < OX958_REG_UART_REGION_OFFSET)
    385404    {
     405        AssertReturn(cb == 4, VINF_SUCCESS);
    386406        const uint32_t u32 = *(const uint32_t *)pv;
    387         Assert(cb == 4);
    388407
    389408        switch ((uint32_t)off)
     
    421440            POX958UARTCC pUartCC = &pThisCC->aUarts[iUart];
    422441            rc = ox958UartRegWrite(pDevIns, pThis, pUart, pUartCC, offUartReg, pv, cb);
    423             if (rc == VINF_IOM_R3_IOPORT_WRITE)
    424                 rc = VINF_IOM_R3_MMIO_WRITE;
    425442        }
    426443    }
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