VirtualBox

Changeset 82210 in vbox


Ignore:
Timestamp:
Nov 26, 2019 12:27:40 AM (5 years ago)
Author:
vboxsync
Message:

GIM,GIMDev: Converted GIMDev to new style. bugref:9218

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vmm/gim.h

    r80281 r82210  
    9292    /** The guest-physical address of the first page in the region. */
    9393    RTGCPHYS            GCPhysPage;
     94    /** The MMIO2 handle. */
     95    PGMMMIO2HANDLE      hMmio2;
    9496    /** The description of the region. */
    9597    char                szDescription[32];
     
    182184VMMR3DECL(void)             GIMR3GimDeviceRegister(PVM pVM, PPDMDEVINS pDevInsR3, PGIMDEBUG pDbg);
    183185VMMR3DECL(int)              GIMR3GetDebugSetup(PVM pVM, PGIMDEBUGSETUP pDbgSetup);
    184 VMMR3DECL(PGIMMMIO2REGION)  GIMR3GetMmio2Regions(PVM pVM, uint32_t *pcRegions);
    185186/** @} */
    186187#endif /* IN_RING3 */
     
    188189VMMDECL(bool)               GIMIsEnabled(PVM pVM);
    189190VMMDECL(GIMPROVIDERID)      GIMGetProvider(PVM pVM);
     191VMMDECL(PGIMMMIO2REGION)    GIMGetMmio2Regions(PVMCC pVM, uint32_t *pcRegions);
    190192VMM_INT_DECL(bool)          GIMIsParavirtTscEnabled(PVMCC pVM);
    191193VMM_INT_DECL(bool)          GIMAreHypercallsEnabled(PVMCPUCC pVCpu);
  • trunk/src/VBox/Devices/GIMDev/GIMDev.cpp

    r82209 r82210  
    206206    PDMDEV_CHECK_VERSIONS_RETURN_QUIET(pDevIns);
    207207    PGIMDEV  pThis    = PDMDEVINS_2_DATA(pDevIns, PGIMDEV);
    208     PVM      pVM      = PDMDevHlpGetVM(pDevIns);
    209 
    210     uint32_t cRegions = 0;
    211     PGIMMMIO2REGION pCur = GIMR3GetMmio2Regions(pVM, &cRegions);
    212     for (uint32_t i = 0; i < cRegions; i++, pCur++)
    213     {
    214         int rc = PDMDevHlpMMIOExDeregister(pDevIns, NULL, pCur->iRegion);
    215         if (RT_FAILURE(rc))
    216             return rc;
    217     }
    218208
    219209    /*
     
    260250{
    261251    PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);
     252    PGIMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PGIMDEV);
    262253    RT_NOREF2(iInstance, pCfg);
     254
    263255    Assert(iInstance == 0);
    264     PGIMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PGIMDEV);
    265256
    266257    /*
     
    274265     * Get debug setup requirements from GIM.
    275266     */
    276     PVM pVM = PDMDevHlpGetVM(pDevIns);
     267    PVMCC pVM = PDMDevHlpGetVM(pDevIns);
    277268    int rc = GIMR3GetDebugSetup(pVM, &pThis->DbgSetup);
    278269    if (   RT_SUCCESS(rc)
     
    348339
    349340    /*
    350      * Get the MMIO2 regions from the GIM provider.
    351      */
    352     uint32_t cRegions = 0;
    353     PGIMMMIO2REGION pRegionsR3 = GIMR3GetMmio2Regions(pVM, &cRegions);
     341     * Get the MMIO2 regions from the GIM provider and make the registrations.
     342     */
     343/** @todo r=bird: consider ditching this as GIM doesn't actually make use of it */
     344    uint32_t        cRegions  = 0;
     345    PGIMMMIO2REGION paRegions = GIMGetMmio2Regions(pVM, &cRegions);
    354346    if (   cRegions
    355         && pRegionsR3)
    356     {
    357         /*
    358          * Register the MMIO2 regions.
    359          */
    360         PGIMMMIO2REGION pCur = pRegionsR3;
    361         for (uint32_t i = 0; i < cRegions; i++, pCur++)
    362         {
    363             Assert(!pCur->fRegistered);
    364             rc = PDMDevHlpMMIO2Register(pDevIns, NULL, pCur->iRegion, pCur->cbRegion, 0 /* fFlags */, &pCur->pvPageR3,
    365                                         pCur->szDescription);
    366             if (RT_FAILURE(rc))
    367                 return rc;
    368 
     347        && paRegions)
     348    {
     349        for (uint32_t i = 0; i < cRegions; i++)
     350        {
     351            PGIMMMIO2REGION pCur = &paRegions[i];
     352            Assert(pCur->iRegion < 8);
     353            rc = PDMDevHlpMmio2Create(pDevIns, NULL, pCur->iRegion << 16, pCur->cbRegion, 0 /* fFlags */, pCur->szDescription,
     354                                      &pCur->pvPageR3, &pCur->hMmio2);
     355            AssertLogRelMsgRCReturn(rc, ("rc=%Rrc iRegion=%u cbRegion=%#x %s\n",
     356                                         rc, pCur->iRegion, pCur->cbRegion, pCur->szDescription),
     357                                    rc);
    369358            pCur->fRegistered = true;
    370 
    371 #if defined(VBOX_WITH_2X_4GB_ADDR_SPACE)
    372             RTR0PTR pR0Mapping = 0;
    373             rc = PDMDevHlpMMIO2MapKernel(pDevIns, NULL, pCur->iRegion, 0 /* off */, pCur->cbRegion, pCur->szDescription,
    374                                          &pR0Mapping);
    375             AssertLogRelMsgRCReturn(rc, ("PDMDevHlpMapMMIO2IntoR0(%#x,) -> %Rrc\n", pCur->cbRegion, rc), rc);
    376             pCur->pvPageR0 = pR0Mapping;
    377 #else
    378             pCur->pvPageR0 = (RTR0PTR)pCur->pvPageR3;
    379 #endif
    380 
    381 #ifdef VBOX_WITH_RAW_MODE_KEEP
    382             /*
    383              * Map into RC if required.
    384              */
    385             if (pCur->fRCMapping)
    386             {
    387                 RTRCPTR pRCMapping = 0;
    388                 rc = PDMDevHlpMMHyperMapMMIO2(pDevIns, NULL, pCur->iRegion, 0 /* off */, pCur->cbRegion, pCur->szDescription,
    389                                               &pRCMapping);
    390                 AssertLogRelMsgRCReturn(rc, ("PDMDevHlpMMHyperMapMMIO2(%#x,) -> %Rrc\n", pCur->cbRegion, rc), rc);
    391                 pCur->pvPageRC = pRCMapping;
    392             }
    393             else
    394                 pCur->pvPageRC = NIL_RTRCPTR;
    395 #endif
     359            pCur->pvPageR0 = NIL_RTR0PTR;
     360# ifdef VBOX_WITH_RAW_MODE_KEEP
     361            pCur->pvPageRC = NIL_RTRCPTR;
     362# endif
    396363
    397364            LogRel(("GIMDev: Registered %s\n", pCur->szDescription));
    398365        }
    399366    }
     367    else
     368        Assert(cRegions == 0);
    400369
    401370    /** @todo Register SSM: PDMDevHlpSSMRegister(). */
     
    407376
    408377
    409 #endif /* IN_RING3 */
     378#else  /* !IN_RING3 */
     379
     380/**
     381 * @callback_method_impl{PDMDEVREGR0,pfnConstruct}
     382 */
     383static DECLCALLBACK(int) gimdevRZConstruct(PPDMDEVINS pDevIns)
     384{
     385    PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);
     386    //PGIMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PGIMDEV);
     387
     388    /*
     389     * Map the MMIO2 regions into the context.
     390     */
     391/** @todo r=bird: consider ditching this as GIM doesn't actually make use of it */
     392    PVMCC           pVM       = PDMDevHlpGetVM(pDevIns);
     393    uint32_t        cRegions  = 0;
     394    PGIMMMIO2REGION paRegions = GIMGetMmio2Regions(pVM, &cRegions);
     395    if (   cRegions
     396        && paRegions)
     397    {
     398        for (uint32_t i = 0; i < cRegions; i++)
     399        {
     400            PGIMMMIO2REGION pCur = &paRegions[i];
     401            int rc = PDMDevHlpMmio2SetUpContext(pDevIns, pCur->hMmio2, 0,  0, &pCur->CTX_SUFF(pvPage));
     402            AssertLogRelMsgRCReturn(rc, ("rc=%Rrc iRegion=%u cbRegion=%#x %s\n",
     403                                         rc, pCur->iRegion, pCur->cbRegion, pCur->szDescription),
     404                                    rc);
     405            Assert(pCur->fRegistered);
     406        }
     407    }
     408    else
     409        Assert(cRegions == 0);
     410
     411    return VINF_SUCCESS;
     412}
     413
     414#endif /* !IN_RING3 */
    410415
    411416/**
     
    417422    /* .uReserved0 = */             0,
    418423    /* .szName = */                 "GIMDev",
    419     /* .fFlags = */                 PDM_DEVREG_FLAGS_DEFAULT_BITS | PDM_DEVREG_FLAGS_RZ,
     424    /* .fFlags = */                 PDM_DEVREG_FLAGS_DEFAULT_BITS | PDM_DEVREG_FLAGS_RZ | PDM_DEVREG_FLAGS_REQUIRE_R0
     425                                    | PDM_DEVREG_FLAGS_NEW_STYLE,
    420426    /* .fClass = */                 PDM_DEVREG_CLASS_MISC,
    421427    /* .cMaxInstances = */          1,
     
    454460#elif defined(IN_RING0)
    455461    /* .pfnEarlyConstruct = */      NULL,
    456     /* .pfnConstruct = */           NULL,
     462    /* .pfnConstruct = */           gimdevRZConstruct,
    457463    /* .pfnDestruct = */            NULL,
    458464    /* .pfnFinalDestruct = */       NULL,
     
    467473    /* .pfnReserved7 = */           NULL,
    468474#elif defined(IN_RC)
    469     /* .pfnConstruct = */           NULL,
     475    /* .pfnConstruct = */           gimdevRZConstruct,
    470476    /* .pfnReserved0 = */           NULL,
    471477    /* .pfnReserved1 = */           NULL,
  • trunk/src/VBox/VMM/VMMAll/GIMAll.cpp

    r81605 r82210  
    5858{
    5959    return pVM->gim.s.enmProviderId;
     60}
     61
     62
     63/**
     64 * Returns the array of MMIO2 regions that are expected to be registered and
     65 * later mapped into the guest-physical address space for the GIM provider
     66 * configured for the VM.
     67 *
     68 * @returns Pointer to an array of GIM MMIO2 regions, may return NULL.
     69 * @param   pVM         The cross context VM structure.
     70 * @param   pcRegions   Where to store the number of items in the array.
     71 *
     72 * @remarks The caller does not own and therefore must -NOT- try to free the
     73 *          returned pointer.
     74 */
     75VMMDECL(PGIMMMIO2REGION) GIMGetMmio2Regions(PVMCC pVM, uint32_t *pcRegions)
     76{
     77    Assert(pVM);
     78    Assert(pcRegions);
     79
     80    *pcRegions = 0;
     81    switch (pVM->gim.s.enmProviderId)
     82    {
     83        case GIMPROVIDERID_HYPERV:
     84            return gimHvGetMmio2Regions(pVM, pcRegions);
     85
     86        default:
     87            break;
     88    }
     89
     90    return NULL;
    6091}
    6192
  • trunk/src/VBox/VMM/VMMAll/GIMAllHv.cpp

    r81605 r82210  
    406406
    407407/**
     408 * Returns a pointer to the MMIO2 regions supported by Hyper-V.
     409 *
     410 * @returns Pointer to an array of MMIO2 regions.
     411 * @param   pVM         The cross context VM structure.
     412 * @param   pcRegions   Where to store the number of regions in the array.
     413 */
     414VMM_INT_DECL(PGIMMMIO2REGION) gimHvGetMmio2Regions(PVM pVM, uint32_t *pcRegions)
     415{
     416    Assert(GIMIsEnabled(pVM));
     417    PGIMHV pHv = &pVM->gim.s.u.Hv;
     418
     419    AssertCompile(RT_ELEMENTS(pHv->aMmio2Regions) <= 8);
     420    *pcRegions = RT_ELEMENTS(pHv->aMmio2Regions);
     421    return pHv->aMmio2Regions;
     422}
     423
     424
     425/**
    408426 * Returns whether the guest has configured and enabled the use of Hyper-V's
    409427 * hypercall interface.
  • trunk/src/VBox/VMM/VMMR0/VMMR0.def

    r82094 r82210  
    2020
    2121    ; code
     22    GIMGetMmio2Regions
    2223    PDMCritSectEnter
    2324    PDMCritSectEnterDebug
  • trunk/src/VBox/VMM/VMMR3/GIM.cpp

    r80597 r82210  
    526526    }
    527527    return VERR_GIM_NO_DEBUG_CONNECTION;
    528 }
    529 
    530 
    531 /**
    532  * Returns the array of MMIO2 regions that are expected to be registered and
    533  * later mapped into the guest-physical address space for the GIM provider
    534  * configured for the VM.
    535  *
    536  * @returns Pointer to an array of GIM MMIO2 regions, may return NULL.
    537  * @param   pVM         The cross context VM structure.
    538  * @param   pcRegions   Where to store the number of items in the array.
    539  *
    540  * @remarks The caller does not own and therefore must -NOT- try to free the
    541  *          returned pointer.
    542  */
    543 VMMR3DECL(PGIMMMIO2REGION) GIMR3GetMmio2Regions(PVM pVM, uint32_t *pcRegions)
    544 {
    545     Assert(pVM);
    546     Assert(pcRegions);
    547 
    548     *pcRegions = 0;
    549     switch (pVM->gim.s.enmProviderId)
    550     {
    551         case GIMPROVIDERID_HYPERV:
    552             return gimR3HvGetMmio2Regions(pVM, pcRegions);
    553 
    554         default:
    555             break;
    556     }
    557 
    558     return NULL;
    559528}
    560529
  • trunk/src/VBox/VMM/VMMR3/GIMHv.cpp

    r81766 r82210  
    304304     * Populate the required fields in MMIO2 region records for registering.
    305305     */
     306    for (size_t i = 0; i < RT_ELEMENTS(pHv->aMmio2Regions); i++)
     307        pHv->aMmio2Regions[i].hMmio2 = NIL_PGMMMIO2HANDLE;
     308
    306309    AssertCompile(GIM_HV_PAGE_SIZE == PAGE_SIZE);
    307310    PGIMMMIO2REGION pRegion = &pHv->aMmio2Regions[GIM_HV_HYPERCALL_PAGE_REGION_IDX];
     
    688691        }
    689692    }
    690 }
    691 
    692 
    693 /**
    694  * Returns a pointer to the MMIO2 regions supported by Hyper-V.
    695  *
    696  * @returns Pointer to an array of MMIO2 regions.
    697  * @param   pVM         The cross context VM structure.
    698  * @param   pcRegions   Where to store the number of regions in the array.
    699  */
    700 VMMR3_INT_DECL(PGIMMMIO2REGION) gimR3HvGetMmio2Regions(PVM pVM, uint32_t *pcRegions)
    701 {
    702     Assert(GIMIsEnabled(pVM));
    703     PGIMHV pHv = &pVM->gim.s.u.Hv;
    704 
    705     *pcRegions = RT_ELEMENTS(pHv->aMmio2Regions);
    706     Assert(*pcRegions <= UINT8_MAX);    /* See PGMR3PhysMMIO2Register(). */
    707     return pHv->aMmio2Regions;
    708693}
    709694
  • trunk/src/VBox/VMM/include/GIMHvInternal.h

    r81369 r82210  
    13321332VMMR3_INT_DECL(void)            gimR3HvRelocate(PVM pVM, RTGCINTPTR offDelta);
    13331333VMMR3_INT_DECL(void)            gimR3HvReset(PVM pVM);
    1334 VMMR3_INT_DECL(PGIMMMIO2REGION) gimR3HvGetMmio2Regions(PVM pVM, uint32_t *pcRegions);
    13351334VMMR3_INT_DECL(int)             gimR3HvSave(PVM pVM, PSSMHANDLE pSSM);
    13361335VMMR3_INT_DECL(int)             gimR3HvLoad(PVM pVM, PSSMHANDLE pSSM);
     
    13591358#endif /* IN_RING3 */
    13601359
     1360VMM_INT_DECL(PGIMMMIO2REGION)   gimHvGetMmio2Regions(PVM pVM, uint32_t *pcRegions);
    13611361VMM_INT_DECL(bool)              gimHvIsParavirtTscEnabled(PVM pVM);
    13621362VMM_INT_DECL(bool)              gimHvAreHypercallsEnabled(PCVM pVM);
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