VirtualBox

Changeset 83263 in vbox for trunk/src/VBox/VMM


Ignore:
Timestamp:
Mar 11, 2020 4:34:33 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
136414
Message:

AMD IOMMU: bugref:9654 Skeletal bits.

Location:
trunk/src/VBox/VMM
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR3/PDMDevHlp.cpp

    r82968 r83263  
    32453245    return VINF_SUCCESS;
    32463246}
     3247
     3248
     3249/** @interface_method_impl{PDMDEVHLPR3,pfnIommuRegister} */
     3250static DECLCALLBACK(int) pdmR3DevHlp_IommuRegister(PPDMDEVINS pDevIns, PPDMIOMMUREGR3 pIommuReg, PCPDMIOMMUHLPR3 *ppIommuHlp)
     3251{
     3252    PDMDEV_ASSERT_DEVINS(pDevIns);
     3253    VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3);
     3254    LogFlow(("pdmR3DevHlp_IommuRegister: caller='%s'/%d: pIommuReg=%p:{.u32Version=%#x, .u32TheEnd=%#x } ppIommuHlp=%p\n",
     3255             pDevIns->pReg->szName, pDevIns->iInstance, pIommuReg, pIommuReg->u32Version, pIommuReg->u32TheEnd, ppIommuHlp));
     3256    PVM pVM = pDevIns->Internal.s.pVMR3;
     3257
     3258    /*
     3259     * Validate input.
     3260     */
     3261    AssertMsgReturn(pIommuReg->u32Version == PDM_IOMMUREGR3_VERSION,
     3262                    ("%s/%d: u32Version=%#x expected %#x\n", pDevIns->pReg->szName, pDevIns->iInstance, pIommuReg->u32Version, PDM_IOMMUREGR3_VERSION),
     3263                    VERR_INVALID_PARAMETER);
     3264    /** @todo IOMMU: Validate other parameters, see also tstDevicePdmDevHlp.cpp. */
     3265    AssertMsgReturn(pIommuReg->u32TheEnd == PDM_IOMMUREGR3_VERSION,
     3266                    ("%s/%d: u32TheEnd=%#x expected %#x\n", pDevIns->pReg->szName, pDevIns->iInstance, pIommuReg->u32TheEnd, PDM_IOMMUREGR3_VERSION),
     3267                    VERR_INVALID_PARAMETER);
     3268    AssertPtrReturn(ppIommuHlp, VERR_INVALID_POINTER);
     3269
     3270    VM_ASSERT_STATE_RETURN(pVM, VMSTATE_CREATING, VERR_WRONG_ORDER);
     3271    VM_ASSERT_EMT0_RETURN(pVM, VERR_VM_THREAD_NOT_EMT);
     3272
     3273    /*
     3274     * Find free IOMMU slot.
     3275     */
     3276    unsigned idxIommu = 0;
     3277    for (idxIommu = 0; idxIommu < RT_ELEMENTS(pVM->pdm.s.aIommus); idxIommu++)
     3278        if (!pVM->pdm.s.aIommus[idxIommu].pDevInsR3)
     3279            break;
     3280    AssertLogRelMsgReturn(idxIommu < RT_ELEMENTS(pVM->pdm.s.aIommus),
     3281                          ("Too many IOMMUs. Max=%u\n", RT_ELEMENTS(pVM->pdm.s.aIommus)),
     3282                          VERR_OUT_OF_RESOURCES);
     3283    PPDMIOMMU pIommu = &pVM->pdm.s.aIommus[idxIommu];
     3284
     3285    /*
     3286     * Init the R3 bits.
     3287     */
     3288    pIommu->idxIommu = idxIommu;
     3289    pIommu->pDevInsR3 = pDevIns;
     3290    Log(("PDM: Registered IOMMU device '%s'/%d pDevIns=%p\n", pDevIns->pReg->szName, pDevIns->iInstance, pDevIns));
     3291
     3292    /* Set the helper pointer and return. */
     3293    *ppIommuHlp = &g_pdmR3DevIommuHlp;
     3294    LogFlow(("pdmR3DevHlp_IommuRegister: caller='%s'/%d: returns %Rrc\n", pDevIns->pReg->szName, pDevIns->iInstance, VINF_SUCCESS));
     3295    return VINF_SUCCESS;
     3296}
     3297
    32473298
    32483299
     
    41184169    pdmR3DevHlp_RTCRegister,
    41194170    pdmR3DevHlp_PCIBusRegister,
     4171    pdmR3DevHlp_IommuRegister,
    41204172    pdmR3DevHlp_PICRegister,
    41214173    pdmR3DevHlp_ApicRegister,
     
    46024654    pdmR3DevHlp_RTCRegister,
    46034655    pdmR3DevHlp_PCIBusRegister,
     4656    pdmR3DevHlp_IommuRegister,
    46044657    pdmR3DevHlp_PICRegister,
    46054658    pdmR3DevHlp_ApicRegister,
  • trunk/src/VBox/VMM/VMMR3/PDMDevMiscHlp.cpp

    r82968 r83263  
    236236
    237237
     238/**
     239 * IOMMU Device Helpers.
     240 */
     241const PDMIOMMUHLPR3 g_pdmR3DevIommuHlp =
     242{
     243    PDM_IOMMUHLPR3_VERSION,
     244    PDM_IOMMUHLPR3_VERSION /* the end */
     245};
    238246
    239247
  • trunk/src/VBox/VMM/include/PDMInternal.h

    r82968 r83263  
    107107/** Pointer to a PDM PCI Bus instance. */
    108108typedef struct PDMPCIBUS *PPDMPCIBUS;
     109/** Pointer to a PDM IOMMU instance. */
     110typedef struct PDMIOMMU *PPDMIOMMU;
    109111/** Pointer to a DMAC instance. */
    110112typedef struct PDMDMAC *PPDMDMAC;
     
    617619
    618620/**
     621 * PDM registered IOMMU device.
     622 */
     623typedef struct PDMIOMMU
     624{
     625    /** IOMMU index. */
     626    uint32_t                        idxIommu;
     627    uint32_t                        uPadding0; /**< Alignment padding.*/
     628
     629    /** Pointer to the IOMMU device instance - R3. */
     630    PPDMDEVINSR3                    pDevInsR3;
     631
     632    /** Pointer to the IOMMU device instance - R0. */
     633    PPDMDEVINSR0                    pDevInsR0;
     634
     635    /** Pointer to the IOMMU device instance - RC. */
     636    PPDMDEVINSRC                    pDevInsRC;
     637    RTRCPTR                         RCPtrPadding;
     638} PDMIOMMU;
     639
     640
     641/**
    619642 * PDM registered PIC device.
    620643 */
     
    695718
    696719/** Maximum number of PCI busses for a VM. */
    697 #define PDM_PCI_BUSSES_MAX 8
     720#define PDM_PCI_BUSSES_MAX  8
     721/** Maximum number of IOMMUs (at most one per PCI bus). */
     722#define PDM_IOMMUS_MAX      PDM_PCI_BUSSES_MAX
    698723
    699724
     
    12251250    /** PCI Buses. */
    12261251    PDMPCIBUS                       aPciBuses[PDM_PCI_BUSSES_MAX];
     1252    /** IOMMU devices. */
     1253    PDMIOMMU                        aIommus[PDM_IOMMUS_MAX];
    12271254    /** The register PIC device. */
    12281255    PDMPIC                          Pic;
     
    13941421extern const PDMFWHLPR3     g_pdmR3DevFirmwareHlp;
    13951422extern const PDMPCIHLPR3    g_pdmR3DevPciHlp;
     1423extern const PDMIOMMUHLPR3  g_pdmR3DevIommuHlp;
    13961424extern const PDMDMACHLP     g_pdmR3DevDmacHlp;
    13971425extern const PDMRTCHLP      g_pdmR3DevRtcHlp;
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