VirtualBox

Changeset 88327 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Mar 31, 2021 3:00:55 AM (4 years ago)
Author:
vboxsync
Message:

Intel IOMMU: bugref:9967 WIP.

Location:
trunk/src/VBox/Devices/Bus
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Bus/DevIommuIntel.cpp

    r88322 r88327  
    3030*   Defined Constants And Macros                                                                                                 *
    3131*********************************************************************************************************************************/
    32 /** @def VTD_LO_U32
    33  * Gets the low uint32_t of a uint64_t or something equivalent.
     32/** Gets the low uint32_t of a uint64_t or something equivalent.
    3433 *
    3534 * This is suitable for casting constants outside code (since RT_LO_U32 can't be
     
    3736#define VTD_LO_U32(a)       (uint32_t)(UINT32_MAX & (a))
    3837
    39 /** @def VTD_HI_U32
    40  * Gets the high uint32_t of a uint64_t or something equivalent.
     38/** Gets the high uint32_t of a uint64_t or something equivalent.
    4139 *
    4240 * This is suitable for casting constants outside code (since RT_HI_U32 can't be
     
    4442#define VTD_HI_U32(a)       (uint32_t)((a) >> 32)
    4543
    46 /** @def VTD_ASSERT_MMIO_ACCESS
    47  * Asserts MMIO access' offset and size are valid or returns appropriate error
     44/** Asserts MMIO access' offset and size are valid or returns appropriate error
    4845 * code suitable for returning from MMIO access handlers. */
    4946#define VTD_ASSERT_MMIO_ACCESS_RET(a_off, a_cb) \
     
    5350    } while (0);
    5451
    55 /** @def VTD_IS_MMIO_OFF_VALID
    56  * Returns @c true if the MMIO offset is valid, or @c false otherwise. */
     52/** Checks whether the MMIO offset is valid. */
    5753#define VTD_IS_MMIO_OFF_VALID(a_off)                (   (a_off) < VTD_MMIO_GROUP_0_OFF_END \
    5854                                                     || (a_off) - VTD_MMIO_GROUP_1_OFF_FIRST < VTD_MMIO_GROUP_1_SIZE)
     
    8379#define VTD_MMIO_GROUP_1_OFF_FIRST                  VTD_MMIO_OFF_VCCAP_REG
    8480/** Offset of last register in group 1 (inclusive). */
    85 #define VTD_MMIO_GROUP_1_OFF_LAST                   VTD_MMIO_OFF_FRCD_LO_REG + 8 * VTD_FRCD_REG_COUNT
     81#define VTD_MMIO_GROUP_1_OFF_LAST                   (VTD_MMIO_OFF_FRCD_LO_REG + 8) * VTD_FRCD_REG_COUNT
    8682/** Last valid offset in group 1 (exclusive). */
    8783#define VTD_MMIO_GROUP_1_OFF_END                    (VTD_MMIO_GROUP_1_OFF_LAST + 8 /* sizeof FRCD_HI_REG */)
     
    428424    AssertMsg(VTD_IS_MMIO_OFF_VALID(offLast), ("off=%#x cb=%u\n", offReg, cbReg));
    429425
    430     uint8_t *apbRegs[] = { &pThis->abRegs0[0], &pThis->abRegs1[0] };
     426    uint8_t *const apbRegs[] = { &pThis->abRegs0[0], &pThis->abRegs1[0] };
    431427    *pIdxGroup = !(offLast < VTD_MMIO_GROUP_0_OFF_END);
    432428    return apbRegs[*pIdxGroup];
     
    771767    AssertRCReturn(rc, rc);
    772768
     769    /*
     770     * Initialize PCI configuration registers.
     771     */
     772    PPDMPCIDEV pPciDev = pDevIns->apPciDevs[0];
     773    PDMPCIDEV_ASSERT_VALID(pDevIns, pPciDev);
     774
     775    /* Header. */
     776    PDMPciDevSetVendorId(pPciDev,          VTD_PCI_VENDOR_ID);         /* Intel */
     777    PDMPciDevSetDeviceId(pPciDev,          VTD_PCI_DEVICE_ID);         /* VirtualBox DMAR device */
     778    PDMPciDevSetRevisionId(pPciDev,        VTD_PCI_REVISION_ID);       /* VirtualBox specific device implementation revision */
     779    PDMPciDevSetClassBase(pPciDev,         VBOX_PCI_CLASS_SYSTEM);     /* System Base Peripheral */
     780    PDMPciDevSetClassSub(pPciDev,          VBOX_PCI_SUB_SYSTEM_OTHER); /* Other */
     781    PDMPciDevSetHeaderType(pPciDev,        0x0);                       /* Single function, type 0 */
     782    PDMPciDevSetSubSystemId(pPciDev,       VTD_PCI_DEVICE_ID);         /* VirtualBox DMAR device */
     783    PDMPciDevSetSubSystemVendorId(pPciDev, VTD_PCI_VENDOR_ID);         /* Intel */
     784
     785    /** @todo VTD: Chipset spec says PCI Express Capability Id. Relevant for us? */
     786    PDMPciDevSetStatus(pPciDev,            0);
     787    PDMPciDevSetCapabilityList(pPciDev,    0);
     788
     789    /** @todo VTD: VTBAR at 0x180? */
     790
     791    /*
     792     * Register the PCI function with PDM.
     793     */
     794    rc = PDMDevHlpPCIRegister(pDevIns, pPciDev);
     795    AssertLogRelRCReturn(rc, rc);
     796
     797    /** @todo VTD: Register MSI but what's the MSI capability offset? */
     798#if 0
     799    /*
     800     * Register MSI support for the PCI device.
     801     * This must be done -after- registering it as a PCI device!
     802     */
     803#endif
    773804
    774805    return VERR_NOT_IMPLEMENTED;
  • trunk/src/VBox/Devices/Bus/DevIommuIntel.h

    r88310 r88327  
    2424#include <VBox/iommu-intel.h>
    2525
     26/** Intel vendor ID for the DMAR unit. */
     27#define VTD_PCI_VENDOR_ID                           0x8086
     28/** VirtualBox DMAR unit's device ID. */
     29#define VTD_PCI_DEVICE_ID                           0xc0de
     30/** VirtualBox DMAR unit's device revision ID. */
     31#define VTD_PCI_REVISION_ID                         0x01
     32
    2633/** Feature/capability flags exposed to the guest (x2APIC Opt Out until we get
    2734 *  regular APIC setup working). */
    2835#define VTD_ACPI_DMAR_FLAGS                         (ACPI_DMAR_F_INTR_REMAP | ACPI_DMAR_F_X2APIC_OPT_OUT)
     36
    2937/** The MMIO base address of the DMAR unit (taken from real hardware). */
    3038#define VTD_MMIO_BASE_ADDR                          0xfed90000
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