VirtualBox

Changeset 81625 in vbox for trunk


Ignore:
Timestamp:
Nov 1, 2019 8:47:17 PM (5 years ago)
Author:
vboxsync
Message:

VMMDev: Converted to the new PDM device style. bugref:9218

Location:
trunk/src/VBox/Devices/VMMDev
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/VMMDev/VMMDev.cpp

    r81571 r81625  
    105105#ifndef IN_RC
    106106# include <iprt/mem.h>
     107# include <iprt/memsafer.h>
    107108#endif
    108109#ifdef IN_RING3
     
    233234 * Sets the IRQ (raise it or lower it) for 1.03 additions.
    234235 *
    235  * @param   pThis       The VMMDev state.
     236 * @param   pDevIns         The device instance.
     237 * @param   pThis           The VMMDev shared instance data.
     238 * @param   pThisCC         The VMMDev ring-3 instance data.
    236239 * @thread  Any.
    237240 * @remarks Must be called owning the critical section.
    238241 */
    239 static void vmmdevSetIRQ_Legacy(PVMMDEV pThis)
     242static void vmmdevSetIRQ_Legacy(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC)
    240243{
    241244    if (pThis->fu32AdditionsOk)
    242245    {
    243246        /* Filter unsupported events */
    244         uint32_t fEvents = pThis->fHostEventFlags & pThis->CTX_SUFF(pVMMDevRAM)->V.V1_03.u32GuestEventMask;
     247        uint32_t fEvents = pThis->fHostEventFlags & pThisCC->CTX_SUFF(pVMMDevRAM)->V.V1_03.u32GuestEventMask;
    245248
    246249        Log(("vmmdevSetIRQ: fEvents=%#010x, fHostEventFlags=%#010x, u32GuestEventMask=%#010x.\n",
    247              fEvents, pThis->fHostEventFlags, pThis->CTX_SUFF(pVMMDevRAM)->V.V1_03.u32GuestEventMask));
     250             fEvents, pThis->fHostEventFlags, pThisCC->CTX_SUFF(pVMMDevRAM)->V.V1_03.u32GuestEventMask));
    248251
    249252        /* Move event flags to VMMDev RAM */
    250         pThis->CTX_SUFF(pVMMDevRAM)->V.V1_03.u32HostEvents = fEvents;
     253        pThisCC->CTX_SUFF(pVMMDevRAM)->V.V1_03.u32HostEvents = fEvents;
    251254
    252255        uint32_t uIRQLevel = 0;
     
    261264        /* Set IRQ level for pin 0 (see NoWait comment in vmmdevMaybeSetIRQ). */
    262265        /** @todo make IRQ pin configurable, at least a symbolic constant */
    263         PDMDevHlpPCISetIrqNoWait(pThis->CTX_SUFF(pDevIns), 0, uIRQLevel);
     266        PDMDevHlpPCISetIrqNoWait(pDevIns, 0, uIRQLevel);
    264267        Log(("vmmdevSetIRQ: IRQ set %d\n", uIRQLevel));
    265268    }
     
    272275 * Sets the IRQ if there are events to be delivered.
    273276 *
    274  * @param   pThis       The VMMDev state.
     277 * @param   pDevIns         The device instance.
     278 * @param   pThis           The VMMDev shared instance data.
     279 * @param   pThisCC         The VMMDev ring-3 instance data.
    275280 * @thread  Any.
    276281 * @remarks Must be called owning the critical section.
    277282 */
    278 static void vmmdevMaybeSetIRQ(PVMMDEV pThis)
     283static void vmmdevMaybeSetIRQ(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC)
    279284{
    280285    Log3(("vmmdevMaybeSetIRQ: fHostEventFlags=%#010x, fGuestFilterMask=%#010x.\n",
     
    288293         *       which has already happened.
    289294         */
    290         pThis->pVMMDevRAMR3->V.V1_04.fHaveEvents = true;
    291         PDMDevHlpPCISetIrqNoWait(pThis->pDevInsR3, 0, 1);
     295        pThisCC->pVMMDevRAMR3->V.V1_04.fHaveEvents = true;
     296        PDMDevHlpPCISetIrqNoWait(pDevIns, 0, 1);
    292297        Log3(("vmmdevMaybeSetIRQ: IRQ set.\n"));
    293298    }
     
    297302 * Notifies the guest about new events (@a fAddEvents).
    298303 *
    299  * @param   pThis           The VMMDev state.
     304 * @param   pDevIns         The device instance.
     305 * @param   pThis           The VMMDev shared instance data.
     306 * @param   pThisCC         The VMMDev ring-3 instance data.
    300307 * @param   fAddEvents      New events to add.
    301308 * @thread  Any.
    302309 * @remarks Must be called owning the critical section.
    303310 */
    304 static void vmmdevNotifyGuestWorker(PVMMDEV pThis, uint32_t fAddEvents)
     311static void vmmdevNotifyGuestWorker(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC, uint32_t fAddEvents)
    305312{
    306313    Log3(("vmmdevNotifyGuestWorker: fAddEvents=%#010x.\n", fAddEvents));
     
    321328
    322329            if (!fHadEvents)
    323                 vmmdevMaybeSetIRQ(pThis);
     330                vmmdevMaybeSetIRQ(pDevIns, pThis, pThisCC);
    324331        }
    325332        else
     
    334341
    335342        pThis->fHostEventFlags |= fAddEvents;
    336         vmmdevSetIRQ_Legacy(pThis);
     343        vmmdevSetIRQ_Legacy(pDevIns, pThis, pThisCC);
    337344    }
    338345}
     
    347354 * This is used by VMMDev.cpp as well as VMMDevHGCM.cpp.
    348355 *
    349  * @param   pThis           The VMMDev state.
     356 * @param   pDevIns         The device instance.
     357 * @param   pThis           The VMMDev shared instance data.
     358 * @param   pThisCC         The VMMDev ring-3 instance data.
    350359 * @param   fAddEvents      New events to add.
    351360 * @thread  Any.
    352361 */
    353 void VMMDevNotifyGuest(PVMMDEV pThis, uint32_t fAddEvents)
     362void VMMDevNotifyGuest(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC, uint32_t fAddEvents)
    354363{
    355364    Log3(("VMMDevNotifyGuest: fAddEvents=%#010x\n", fAddEvents));
     
    358367     * Only notify the VM when it's running.
    359368     */
    360     VMSTATE enmVMState = PDMDevHlpVMState(pThis->pDevInsR3);
     369    VMSTATE enmVMState = PDMDevHlpVMState(pDevIns);
    361370    if (   enmVMState == VMSTATE_RUNNING
    362371        || enmVMState == VMSTATE_RUNNING_LS
     
    370379       )
    371380    {
    372         PDMCritSectEnter(&pThis->CritSect, VERR_IGNORED);
    373         vmmdevNotifyGuestWorker(pThis, fAddEvents);
    374         PDMCritSectLeave(&pThis->CritSect);
     381        PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED);
     382        vmmdevNotifyGuestWorker(pDevIns, pThis, pThisCC, fAddEvents);
     383        PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect);
    375384    }
    376385    else
     
    382391 * events the guest are interested in.
    383392 *
    384  * @param   pThis           The VMMDev state.
     393 * @param   pDevIns         The device instance.
     394 * @param   pThis           The VMMDev shared instance data.
     395 * @param   pThisCC         The VMMDev ring-3 instance data.
    385396 * @param   fOrMask         Events to add (VMMDEV_EVENT_XXX). Pass 0 for no
    386397 *                          change.
     
    392403 *          controlled by the guest.
    393404 */
    394 void VMMDevCtlSetGuestFilterMask(PVMMDEV pThis, uint32_t fOrMask, uint32_t fNotMask)
    395 {
    396     PDMCritSectEnter(&pThis->CritSect, VERR_IGNORED);
     405void VMMDevCtlSetGuestFilterMask(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC, uint32_t fOrMask, uint32_t fNotMask)
     406{
     407    PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED);
    397408
    398409    const bool fHadEvents = (pThis->fHostEventFlags & pThis->fGuestFilterMask) != 0;
     
    412423        pThis->fGuestFilterMask |= fOrMask;
    413424        pThis->fGuestFilterMask &= ~fNotMask;
    414         vmmdevMaybeSetIRQ(pThis);
    415     }
    416 
    417     PDMCritSectLeave(&pThis->CritSect);
     425        vmmdevMaybeSetIRQ(pDevIns, pThis, pThisCC);
     426    }
     427
     428    PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect);
    418429}
    419430
     
    426437 *
    427438 * @returns VBox status code that the guest should see.
    428  * @param   pThis           The VMMDev instance data.
     439 * @param   pDevIns         The device instance.
     440 * @param   pThis           The VMMDev shared instance data.
     441 * @param   pThisCC         The VMMDev ring-3 instance data.
    429442 * @param   pRequestHeader  The header of the request to handle.
    430443 */
    431 static int vmmdevReqHandler_ReportGuestInfo(PVMMDEV pThis, VMMDevRequestHeader *pRequestHeader)
     444static int vmmdevReqHandler_ReportGuestInfo(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC,
     445                                            VMMDevRequestHeader *pRequestHeader)
    432446{
    433447    AssertMsgReturn(pRequestHeader->size == sizeof(VMMDevReportGuestInfo), ("%u\n", pRequestHeader->size), VERR_INVALID_PARAMETER);
     
    444458        vmmdevLogGuestOsInfo(&pThis->guestInfo);
    445459
    446         if (pThis->pDrv && pThis->pDrv->pfnUpdateGuestInfo)
    447             pThis->pDrv->pfnUpdateGuestInfo(pThis->pDrv, &pThis->guestInfo);
     460        if (pThisCC->pDrv && pThisCC->pDrv->pfnUpdateGuestInfo)
     461            pThisCC->pDrv->pfnUpdateGuestInfo(pThisCC->pDrv, &pThis->guestInfo);
    448462    }
    449463
     
    452466
    453467    /* Clear our IRQ in case it was high for whatever reason. */
    454     PDMDevHlpPCISetIrqNoWait(pThis->pDevInsR3, 0, 0);
     468    PDMDevHlpPCISetIrqNoWait(pDevIns, 0, 0);
    455469
    456470    return VINF_SUCCESS;
     
    462476 *
    463477 * @returns VBox status code that the guest should see.
    464  * @param   pThis    The VMMDev instance data.
    465  */
    466 static int vmmDevReqHandler_GuestHeartbeat(PVMMDEV pThis)
     478 * @param   pDevIns         The device instance.
     479 * @param   pThis           The VMMDev shared instance data.
     480 */
     481static int vmmDevReqHandler_GuestHeartbeat(PPDMDEVINS pDevIns, PVMMDEV pThis)
    467482{
    468483    int rc;
    469484    if (pThis->fHeartbeatActive)
    470485    {
    471         uint64_t const nsNowTS = TMTimerGetNano(pThis->pFlatlinedTimer);
     486        uint64_t const nsNowTS = PDMDevHlpTimerGetNano(pDevIns, pThis->hFlatlinedTimer);
    472487        if (!pThis->fFlatlined)
    473488        { /* likely */ }
     
    480495
    481496        /* Postpone (or restart if we missed a beat) the timeout timer. */
    482         rc = TMTimerSetNano(pThis->pFlatlinedTimer, pThis->cNsHeartbeatTimeout);
     497        rc = PDMDevHlpTimerSetNano(pDevIns, pThis->hFlatlinedTimer, pThis->cNsHeartbeatTimeout);
    483498    }
    484499    else
     
    495510static DECLCALLBACK(void) vmmDevHeartbeatFlatlinedTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)
    496511{
    497     RT_NOREF1(pDevIns);
     512    RT_NOREF(pDevIns);
    498513    PVMMDEV pThis = (PVMMDEV)pvUser;
    499514    if (pThis->fHeartbeatActive)
     
    515530 *
    516531 * @returns VBox status code that the guest should see.
    517  * @param   pThis     The VMMDev instance data.
     532 * @param   pDevIns   The device instance.
     533 * @param   pThis     The VMMDev shared instance data.
    518534 * @param   pReqHdr   The header of the request to handle.
    519535 */
    520 static int vmmDevReqHandler_HeartbeatConfigure(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
     536static int vmmDevReqHandler_HeartbeatConfigure(PPDMDEVINS pDevIns, PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
    521537{
    522538    AssertMsgReturn(pReqHdr->size == sizeof(VMMDevReqHeartbeat), ("%u\n", pReqHdr->size), VERR_INVALID_PARAMETER);
     
    534550             * Activate the heartbeat monitor.
    535551             */
    536             pThis->nsLastHeartbeatTS = TMTimerGetNano(pThis->pFlatlinedTimer);
    537             rc = TMTimerSetNano(pThis->pFlatlinedTimer, pThis->cNsHeartbeatTimeout);
     552            pThis->nsLastHeartbeatTS = PDMDevHlpTimerGetNano(pDevIns, pThis->hFlatlinedTimer);
     553            rc = PDMDevHlpTimerSetNano(pDevIns, pThis->hFlatlinedTimer, pThis->cNsHeartbeatTimeout);
    538554            if (RT_SUCCESS(rc))
    539555                LogRel(("VMMDev: Heartbeat flatline timer set to trigger after %'RU64 ns\n", pThis->cNsHeartbeatTimeout));
     
    546562             * Deactivate the heartbeat monitor.
    547563             */
    548             rc = TMTimerStop(pThis->pFlatlinedTimer);
     564            rc = PDMDevHlpTimerStop(pDevIns, pThis->hFlatlinedTimer);
    549565            LogRel(("VMMDev: Heartbeat checking timer has been stopped (rc=%Rrc)\n", rc));
    550566        }
     
    564580 *
    565581 * @returns VBox status code that the guest should see.
    566  * @param   pThis     The VMMDev instance data.
     582 * @param   pDevIns   The device instance.
    567583 * @param   pReqHdr   The header of the request to handle.
    568584 */
    569 static int vmmDevReqHandler_NtBugCheck(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
     585static int vmmDevReqHandler_NtBugCheck(PPDMDEVINS pDevIns, VMMDevRequestHeader *pReqHdr)
    570586{
    571587    if (pReqHdr->size == sizeof(VMMDevReqNtBugCheck))
    572588    {
    573589        VMMDevReqNtBugCheck const *pReq = (VMMDevReqNtBugCheck const *)pReqHdr;
    574         DBGFR3ReportBugCheck(PDMDevHlpGetVM(pThis->pDevInsR3), PDMDevHlpGetVMCPU(pThis->pDevInsR3), DBGFEVENT_BSOD_VMMDEV,
     590        DBGFR3ReportBugCheck(PDMDevHlpGetVM(pDevIns), PDMDevHlpGetVMCPU(pDevIns), DBGFEVENT_BSOD_VMMDEV,
    575591                             pReq->uBugCheck, pReq->auParameters[0], pReq->auParameters[1],
    576592                             pReq->auParameters[2], pReq->auParameters[3]);
     
    579595    {
    580596        LogRel(("VMMDev: NT BugCheck w/o data.\n"));
    581         DBGFR3ReportBugCheck(PDMDevHlpGetVM(pThis->pDevInsR3), PDMDevHlpGetVMCPU(pThis->pDevInsR3), DBGFEVENT_BSOD_VMMDEV,
     597        DBGFR3ReportBugCheck(PDMDevHlpGetVM(pDevIns), PDMDevHlpGetVMCPU(pDevIns), DBGFEVENT_BSOD_VMMDEV,
    582598                             0, 0, 0, 0, 0);
    583599    }
     
    640656 *
    641657 * @returns VBox status code that the guest should see.
    642  * @param   pThis           The VMMDev instance data.
     658 * @param   pDevIns         The device instance.
     659 * @param   pThis           The VMMDev shared instance data.
     660 * @param   pThisCC         The VMMDev ring-3 instance data.
    643661 * @param   pReqHdr         The header of the request to handle.
    644662 */
    645 static int vmmdevReqHandler_ReportGuestInfo2(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
     663static int vmmdevReqHandler_ReportGuestInfo2(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC, VMMDevRequestHeader *pReqHdr)
    646664{
    647665    AssertMsgReturn(pReqHdr->size == sizeof(VMMDevReportGuestInfo2), ("%u\n", pReqHdr->size), VERR_INVALID_PARAMETER);
     
    729747    strcpy(pThis->guestInfo2.szName, pszName);
    730748
    731     if (pThis->pDrv && pThis->pDrv->pfnUpdateGuestInfo2)
    732         pThis->pDrv->pfnUpdateGuestInfo2(pThis->pDrv, uFullVersion, pszName, pInfo2->additionsRevision, pInfo2->additionsFeatures);
     749    if (pThisCC->pDrv && pThisCC->pDrv->pfnUpdateGuestInfo2)
     750        pThisCC->pDrv->pfnUpdateGuestInfo2(pThisCC->pDrv, uFullVersion, pszName, pInfo2->additionsRevision,
     751                                           pInfo2->additionsFeatures);
    733752
    734753    /* Clear our IRQ in case it was high for whatever reason. */
    735     PDMDevHlpPCISetIrqNoWait(pThis->pDevInsR3, 0, 0);
     754    PDMDevHlpPCISetIrqNoWait(pDevIns, 0, 0);
    736755
    737756    return VINF_SUCCESS;
     
    744763 * @returns Pointer to a facility status entry on success, NULL on failure
    745764 *          (table full).
    746  * @param   pThis           The VMMDev instance data.
     765 * @param   pThis           The VMMDev shared instance data.
    747766 * @param   enmFacility     The facility type code.
    748767 * @param   fFixed          This is set when allocating the standard entries
     
    812831 * @returns Pointer to a facility status entry on success, NULL on failure
    813832 *          (table full).
    814  * @param   pThis           The VMMDev instance data.
     833 * @param   pThis           The VMMDev shared instance data.
    815834 * @param   enmFacility     The facility type code.
    816835 */
     
    834853 *
    835854 * @returns VBox status code that the guest should see.
    836  * @param   pThis           The VMMDev instance data.
     855 * @param   pThis           The VMMDev shared instance data.
     856 * @param   pThisCC         The VMMDev ring-3 instance data.
    837857 * @param   pReqHdr         The header of the request to handle.
    838858 */
    839 static int vmmdevReqHandler_ReportGuestStatus(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
     859static int vmmdevReqHandler_ReportGuestStatus(PVMMDEV pThis, PVMMDEVCC pThisCC, VMMDevRequestHeader *pReqHdr)
    840860{
    841861    /*
     
    881901    }
    882902
    883     if (pThis->pDrv && pThis->pDrv->pfnUpdateGuestStatus)
    884         pThis->pDrv->pfnUpdateGuestStatus(pThis->pDrv, pStatus->facility, pStatus->status, pStatus->flags, &Now);
     903    if (pThisCC->pDrv && pThisCC->pDrv->pfnUpdateGuestStatus)
     904        pThisCC->pDrv->pfnUpdateGuestStatus(pThisCC->pDrv, pStatus->facility, pStatus->status, pStatus->flags, &Now);
    885905
    886906    return VINF_SUCCESS;
     
    892912 *
    893913 * @returns VBox status code that the guest should see.
    894  * @param   pThis           The VMMDev instance data.
     914 * @param   pThisCC         The VMMDev ring-3 instance data.
    895915 * @param   pReqHdr         The header of the request to handle.
    896916 */
    897 static int vmmdevReqHandler_ReportGuestUserState(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
     917static int vmmdevReqHandler_ReportGuestUserState(PVMMDEVCC pThisCC, VMMDevRequestHeader *pReqHdr)
    898918{
    899919    /*
     
    903923    AssertMsgReturn(pReq->header.size >= sizeof(*pReq), ("%u\n", pReqHdr->size), VERR_INVALID_PARAMETER);
    904924
    905     if (   pThis->pDrv
    906         && pThis->pDrv->pfnUpdateGuestUserState)
     925    if (   pThisCC->pDrv
     926        && pThisCC->pDrv->pfnUpdateGuestUserState)
    907927    {
    908928        /* Play safe. */
     
    950970            pbDetails = pbDynamic;
    951971
    952         pThis->pDrv->pfnUpdateGuestUserState(pThis->pDrv, pszUser, pszDomain, (uint32_t)pReq->status.state,
    953                                              pbDetails, pReq->status.cbDetails);
     972        pThisCC->pDrv->pfnUpdateGuestUserState(pThisCC->pDrv, pszUser, pszDomain, (uint32_t)pReq->status.state,
     973                                               pbDetails, pReq->status.cbDetails);
    954974    }
    955975
     
    962982 *
    963983 * @returns VBox status code that the guest should see.
    964  * @param   pThis           The VMMDev instance data.
     984 * @param   pThis           The VMMDev shared instance data.
     985 * @param   pThisCC         The VMMDev ring-3 instance data.
    965986 * @param   pReqHdr         The header of the request to handle.
    966987 */
    967 static int vmmdevReqHandler_ReportGuestCapabilities(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
     988static int vmmdevReqHandler_ReportGuestCapabilities(PVMMDEV pThis, PVMMDEVCC pThisCC, VMMDevRequestHeader *pReqHdr)
    968989{
    969990    VMMDevReqGuestCapabilities *pReq = (VMMDevReqGuestCapabilities *)pReqHdr;
     
    9851006                fu32Caps & VMMDEV_GUEST_SUPPORTS_GUEST_HOST_WINDOW_MAPPING ? "yes" : "no"));
    9861007
    987         if (pThis->pDrv && pThis->pDrv->pfnUpdateGuestCapabilities)
    988             pThis->pDrv->pfnUpdateGuestCapabilities(pThis->pDrv, fu32Caps);
     1008        if (pThisCC->pDrv && pThisCC->pDrv->pfnUpdateGuestCapabilities)
     1009            pThisCC->pDrv->pfnUpdateGuestCapabilities(pThisCC->pDrv, fu32Caps);
    9891010    }
    9901011    return VINF_SUCCESS;
     
    9961017 *
    9971018 * @returns VBox status code that the guest should see.
    998  * @param   pThis           The VMMDev instance data.
     1019 * @param   pThis           The VMMDev shared instance data.
     1020 * @param   pThisCC         The VMMDev ring-3 instance data.
    9991021 * @param   pReqHdr         The header of the request to handle.
    10001022 */
    1001 static int vmmdevReqHandler_SetGuestCapabilities(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
     1023static int vmmdevReqHandler_SetGuestCapabilities(PVMMDEV pThis, PVMMDEVCC pThisCC, VMMDevRequestHeader *pReqHdr)
    10021024{
    10031025    VMMDevReqGuestCapabilities2 *pReq = (VMMDevReqGuestCapabilities2 *)pReqHdr;
     
    10161038    pThis->fGuestCaps = fu32Caps;
    10171039
    1018     if (pThis->pDrv && pThis->pDrv->pfnUpdateGuestCapabilities)
    1019         pThis->pDrv->pfnUpdateGuestCapabilities(pThis->pDrv, fu32Caps);
     1040    if (pThisCC->pDrv && pThisCC->pDrv->pfnUpdateGuestCapabilities)
     1041        pThisCC->pDrv->pfnUpdateGuestCapabilities(pThisCC->pDrv, fu32Caps);
    10201042
    10211043    return VINF_SUCCESS;
     
    10271049 *
    10281050 * @returns VBox status code that the guest should see.
    1029  * @param   pThis           The VMMDev instance data.
     1051 * @param   pThis           The VMMDev shared instance data.
    10301052 * @param   pReqHdr         The header of the request to handle.
    10311053 */
     
    10491071 *
    10501072 * @returns VBox status code that the guest should see.
    1051  * @param   pThis           The VMMDev instance data.
     1073 * @param   pThis           The VMMDev shared instance data.
     1074 * @param   pThisCC         The VMMDev ring-3 instance data.
    10521075 * @param   pReqHdr         The header of the request to handle.
    10531076 */
    1054 static int vmmdevReqHandler_SetMouseStatus(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
     1077static int vmmdevReqHandler_SetMouseStatus(PVMMDEV pThis, PVMMDEVCC pThisCC, VMMDevRequestHeader *pReqHdr)
    10551078{
    10561079    VMMDevReqMouseStatus *pReq = (VMMDevReqMouseStatus *)pReqHdr;
     
    10761099    {
    10771100        LogRelFlow(("VMMDev: vmmdevReqHandler_SetMouseStatus: Notifying connector\n"));
    1078         pThis->pDrv->pfnUpdateMouseCapabilities(pThis->pDrv, pThis->fMouseCapabilities);
     1101        pThisCC->pDrv->pfnUpdateMouseCapabilities(pThisCC->pDrv, pThis->fMouseCapabilities);
    10791102    }
    10801103
     
    11001123 *
    11011124 * @returns VBox status code that the guest should see.
    1102  * @param   pThis           The VMMDev instance data.
     1125 * @param   pThis           The VMMDev shared instance data.
     1126 * @param   pThisCC         The VMMDev ring-3 instance data.
    11031127 * @param   pReqHdr         The header of the request to handle.
    11041128 */
    1105 static int vmmdevReqHandler_SetPointerShape(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
     1129static int vmmdevReqHandler_SetPointerShape(PVMMDEV pThis, PVMMDEVCC pThisCC, VMMDevRequestHeader *pReqHdr)
    11061130{
    11071131    VMMDevReqMousePointer *pReq = (VMMDevReqMousePointer *)pReqHdr;
     
    11341158            return rc;
    11351159
    1136         pThis->pDrv->pfnUpdatePointerShape(pThis->pDrv,
    1137                                            fVisible,
    1138                                            fAlpha,
    1139                                            pReq->xHot, pReq->yHot,
    1140                                            pReq->width, pReq->height,
    1141                                            pReq->pointerData);
     1160        pThisCC->pDrv->pfnUpdatePointerShape(pThisCC->pDrv,
     1161                                             fVisible,
     1162                                             fAlpha,
     1163                                             pReq->xHot, pReq->yHot,
     1164                                             pReq->width, pReq->height,
     1165                                             pReq->pointerData);
    11421166    }
    11431167    else
    11441168    {
    1145         pThis->pDrv->pfnUpdatePointerShape(pThis->pDrv,
    1146                                            fVisible,
    1147                                            0,
    1148                                            0, 0,
    1149                                            0, 0,
    1150                                            NULL);
     1169        pThisCC->pDrv->pfnUpdatePointerShape(pThisCC->pDrv,
     1170                                             fVisible,
     1171                                             0,
     1172                                             0, 0,
     1173                                             0, 0,
     1174                                             NULL);
    11511175    }
    11521176
     
    11601184 *
    11611185 * @returns VBox status code that the guest should see.
    1162  * @param   pThis           The VMMDev instance data.
     1186 * @param   pDevIns         The device instance.
     1187 * @param   pThis           The VMMDev shared instance data.
    11631188 * @param   pReqHdr         The header of the request to handle.
    11641189 */
    1165 static int vmmdevReqHandler_GetHostTime(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
     1190static int vmmdevReqHandler_GetHostTime(PPDMDEVINS pDevIns, PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
    11661191{
    11671192    VMMDevReqHostTime *pReq = (VMMDevReqHostTime *)pReqHdr;
     
    11711196    {
    11721197        RTTIMESPEC now;
    1173         pReq->time = RTTimeSpecGetMilli(PDMDevHlpTMUtcNow(pThis->pDevInsR3, &now));
     1198        pReq->time = RTTimeSpecGetMilli(PDMDevHlpTMUtcNow(pDevIns, &now));
    11741199        return VINF_SUCCESS;
    11751200    }
     
    11821207 *
    11831208 * @returns VBox status code that the guest should see.
    1184  * @param   pThis           The VMMDev instance data.
     1209 * @param   pDevIns         The device instance.
    11851210 * @param   pReqHdr         The header of the request to handle.
    11861211 */
    1187 static int vmmdevReqHandler_GetHypervisorInfo(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
     1212static int vmmdevReqHandler_GetHypervisorInfo(PPDMDEVINS pDevIns, VMMDevRequestHeader *pReqHdr)
    11881213{
    11891214    VMMDevReqHypervisorInfo *pReq = (VMMDevReqHypervisorInfo *)pReqHdr;
    11901215    AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
    11911216
    1192     return PGMR3MappingsSize(PDMDevHlpGetVM(pThis->pDevInsR3), &pReq->hypervisorSize);
     1217    return PGMR3MappingsSize(PDMDevHlpGetVM(pDevIns), &pReq->hypervisorSize);
    11931218}
    11941219
     
    11981223 *
    11991224 * @returns VBox status code that the guest should see.
    1200  * @param   pThis           The VMMDev instance data.
     1225 * @param   pDevIns         The device instance.
     1226 * @param   pThis           The VMMDev shared instance data.
    12011227 * @param   pReqHdr         The header of the request to handle.
    12021228 */
    1203 static int vmmdevReqHandler_SetHypervisorInfo(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
     1229static int vmmdevReqHandler_SetHypervisorInfo(PPDMDEVINS pDevIns, VMMDevRequestHeader *pReqHdr)
    12041230{
    12051231    VMMDevReqHypervisorInfo *pReq = (VMMDevReqHypervisorInfo *)pReqHdr;
     
    12071233
    12081234    int rc;
    1209     PVM pVM = PDMDevHlpGetVM(pThis->pDevInsR3);
     1235    PVM pVM = PDMDevHlpGetVM(pDevIns);
    12101236    if (pReq->hypervisorStart == 0)
    12111237        rc = PGMR3MappingsUnfix(pVM);
     
    12331259 *
    12341260 * @returns VBox status code that the guest should see.
    1235  * @param   pThis           The VMMDev instance data.
     1261 * @param   pDevIns         The device instance.
    12361262 * @param   pReqHdr         The header of the request to handle.
    12371263 */
    1238 static int vmmdevReqHandler_RegisterPatchMemory(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
     1264static int vmmdevReqHandler_RegisterPatchMemory(PPDMDEVINS pDevIns, VMMDevRequestHeader *pReqHdr)
    12391265{
    12401266    VMMDevReqPatchMemory *pReq = (VMMDevReqPatchMemory *)pReqHdr;
    12411267    AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
    12421268
    1243     return VMMR3RegisterPatchMemory(PDMDevHlpGetVM(pThis->pDevInsR3), pReq->pPatchMem, pReq->cbPatchMem);
     1269    return VMMR3RegisterPatchMemory(PDMDevHlpGetVM(pDevIns), pReq->pPatchMem, pReq->cbPatchMem);
    12441270}
    12451271
     
    12491275 *
    12501276 * @returns VBox status code that the guest should see.
    1251  * @param   pThis           The VMMDev instance data.
     1277 * @param   pDevIns         The device instance.
    12521278 * @param   pReqHdr         The header of the request to handle.
    12531279 */
    1254 static int vmmdevReqHandler_DeregisterPatchMemory(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
     1280static int vmmdevReqHandler_DeregisterPatchMemory(PPDMDEVINS pDevIns, VMMDevRequestHeader *pReqHdr)
    12551281{
    12561282    VMMDevReqPatchMemory *pReq = (VMMDevReqPatchMemory *)pReqHdr;
    12571283    AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
    12581284
    1259     return VMMR3DeregisterPatchMemory(PDMDevHlpGetVM(pThis->pDevInsR3), pReq->pPatchMem, pReq->cbPatchMem);
     1285    return VMMR3DeregisterPatchMemory(PDMDevHlpGetVM(pDevIns), pReq->pPatchMem, pReq->cbPatchMem);
    12601286}
    12611287
     
    12651291 *
    12661292 * @returns VBox status code that the guest should see.
    1267  * @param   pThis           The VMMDev instance data.
     1293 * @param   pDevIns         The device instance.
     1294 * @param   pThis           The VMMDev shared instance data.
    12681295 * @param   pReqHdr         The header of the request to handle.
    12691296 */
    1270 static int vmmdevReqHandler_SetPowerStatus(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
     1297static int vmmdevReqHandler_SetPowerStatus(PPDMDEVINS pDevIns, PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
    12711298{
    12721299    VMMDevPowerStateRequest *pReq = (VMMDevPowerStateRequest *)pReqHdr;
     
    12781305        {
    12791306            LogRel(("VMMDev: Guest requests the VM to be suspended (paused)\n"));
    1280             return PDMDevHlpVMSuspend(pThis->pDevInsR3);
     1307            return PDMDevHlpVMSuspend(pDevIns);
    12811308        }
    12821309
     
    12841311        {
    12851312            LogRel(("VMMDev: Guest requests the VM to be turned off\n"));
    1286             return PDMDevHlpVMPowerOff(pThis->pDevInsR3);
     1313            return PDMDevHlpVMPowerOff(pDevIns);
    12871314        }
    12881315
    12891316        case VMMDevPowerState_SaveState:
    12901317        {
    1291             if (true /*pThis->fAllowGuestToSaveState*/)
     1318            if (pThis->fAllowGuestToSaveState)
    12921319            {
    12931320                LogRel(("VMMDev: Guest requests the VM to be saved and powered off\n"));
    1294                 return PDMDevHlpVMSuspendSaveAndPowerOff(pThis->pDevInsR3);
     1321                return PDMDevHlpVMSuspendSaveAndPowerOff(pDevIns);
    12951322            }
    12961323            LogRel(("VMMDev: Guest requests the VM to be saved and powered off, declined\n"));
     
    13091336 *
    13101337 * @returns VBox status code that the guest should see.
    1311  * @param   pThis           The VMMDev instance data.
     1338 * @param   pThis           The VMMDev shared instance data.
    13121339 * @param   pReqHdr         The header of the request to handle.
    13131340 * @remarks Deprecated.
     
    13511378 *
    13521379 * @returns VBox status code that the guest should see.
    1353  * @param   pThis           The VMMDev instance data.
     1380 * @param   pDevIns         The device instance.
     1381 * @param   pThis           The VMMDev shared instance data.
     1382 * @param   pThisCC         The VMMDev ring-3 instance data.
    13541383 * @param   pReqHdr         The header of the request to handle.
    13551384 */
    1356 static int vmmdevReqHandler_GetDisplayChangeRequest2(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
     1385static int vmmdevReqHandler_GetDisplayChangeRequest2(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC,
     1386                                                     VMMDevRequestHeader *pReqHdr)
    13571387{
    13581388    VMMDevDisplayChangeRequest2 *pReq = (VMMDevDisplayChangeRequest2 *)pReqHdr;
     
    13831413            if (pThis->displayChangeData.aRequests[i].fPending)
    13841414            {
    1385                 VMMDevNotifyGuest(pThis, VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST);
     1415                VMMDevNotifyGuest(pDevIns, pThis, pThisCC, VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST);
    13861416                Log3(("VMMDev: another pending at %u\n", i));
    13871417                break;
     
    14331463 *
    14341464 * @returns VBox status code that the guest should see.
    1435  * @param   pThis           The VMMDev instance data.
     1465 * @param   pDevIns         The device instance.
     1466 * @param   pThis           The VMMDev shared instance data.
     1467 * @param   pThisCC         The VMMDev ring-3 instance data.
    14361468 * @param   pReqHdr         The header of the request to handle.
    14371469 */
    1438 static int vmmdevReqHandler_GetDisplayChangeRequestEx(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
     1470static int vmmdevReqHandler_GetDisplayChangeRequestEx(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC,
     1471                                                      VMMDevRequestHeader *pReqHdr)
    14391472{
    14401473    VMMDevDisplayChangeRequestEx *pReq = (VMMDevDisplayChangeRequestEx *)pReqHdr;
     
    14661499            if (pThis->displayChangeData.aRequests[i].fPending)
    14671500            {
    1468                 VMMDevNotifyGuest(pThis, VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST);
     1501                VMMDevNotifyGuest(pDevIns, pThis, pThisCC, VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST);
    14691502                Log3(("VMMDev: another pending at %d\n",
    14701503                      i));
     
    15221555 *
    15231556 * @returns VBox status code that the guest should see.
    1524  * @param   pThis           The VMMDev instance data.
     1557 * @param   pThis           The VMMDev shared instance data.
    15251558 * @param   pReqHdr         The header of the request to handle.
    15261559 */
     
    15951628 *
    15961629 * @returns VBox status code that the guest should see.
    1597  * @param   pThis           The VMMDev instance data.
     1630 * @param   pThisCC         The VMMDev ring-3 instance data.
    15981631 * @param   pReqHdr         The header of the request to handle.
    15991632 */
    1600 static int vmmdevReqHandler_VideoModeSupported(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
     1633static int vmmdevReqHandler_VideoModeSupported(PVMMDEVCC pThisCC, VMMDevRequestHeader *pReqHdr)
    16011634{
    16021635    VMMDevVideoModeSupportedRequest *pReq = (VMMDevVideoModeSupportedRequest *)pReqHdr;
     
    16041637
    16051638    /* forward the call */
    1606     return pThis->pDrv->pfnVideoModeSupported(pThis->pDrv,
    1607                                               0, /* primary screen. */
    1608                                               pReq->width,
    1609                                               pReq->height,
    1610                                               pReq->bpp,
    1611                                               &pReq->fSupported);
     1639    return pThisCC->pDrv->pfnVideoModeSupported(pThisCC->pDrv,
     1640                                                0, /* primary screen. */
     1641                                                pReq->width,
     1642                                                pReq->height,
     1643                                                pReq->bpp,
     1644                                                &pReq->fSupported);
    16121645}
    16131646
     
    16191652 *
    16201653 * @returns VBox status code that the guest should see.
    1621  * @param   pThis           The VMMDev instance data.
     1654 * @param   pThisCC         The VMMDev ring-3 instance data.
    16221655 * @param   pReqHdr         The header of the request to handle.
    16231656 */
    1624 static int vmmdevReqHandler_VideoModeSupported2(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
     1657static int vmmdevReqHandler_VideoModeSupported2(PVMMDEVCC pThisCC, VMMDevRequestHeader *pReqHdr)
    16251658{
    16261659    VMMDevVideoModeSupportedRequest2 *pReq = (VMMDevVideoModeSupportedRequest2 *)pReqHdr;
     
    16281661
    16291662    /* forward the call */
    1630     return pThis->pDrv->pfnVideoModeSupported(pThis->pDrv,
    1631                                               pReq->display,
    1632                                               pReq->width,
    1633                                               pReq->height,
    1634                                               pReq->bpp,
    1635                                               &pReq->fSupported);
     1663    return pThisCC->pDrv->pfnVideoModeSupported(pThisCC->pDrv,
     1664                                                pReq->display,
     1665                                                pReq->width,
     1666                                                pReq->height,
     1667                                                pReq->bpp,
     1668                                                &pReq->fSupported);
    16361669}
    16371670
     
    16421675 *
    16431676 * @returns VBox status code that the guest should see.
    1644  * @param   pThis           The VMMDev instance data.
     1677 * @param   pThis           The VMMDev ring-3 instance data.
    16451678 * @param   pReqHdr         The header of the request to handle.
    16461679 */
    1647 static int vmmdevReqHandler_GetHeightReduction(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
     1680static int vmmdevReqHandler_GetHeightReduction(PVMMDEVCC pThisCC, VMMDevRequestHeader *pReqHdr)
    16481681{
    16491682    VMMDevGetHeightReductionRequest *pReq = (VMMDevGetHeightReductionRequest *)pReqHdr;
     
    16511684
    16521685    /* forward the call */
    1653     return pThis->pDrv->pfnGetHeightReduction(pThis->pDrv, &pReq->heightReduction);
     1686    return pThisCC->pDrv->pfnGetHeightReduction(pThisCC->pDrv, &pReq->heightReduction);
    16541687}
    16551688
     
    16591692 *
    16601693 * @returns VBox status code that the guest should see.
    1661  * @param   pThis           The VMMDev instance data.
     1694 * @param   pDevIns         The device instance.
     1695 * @param   pThis           The VMMDev shared instance data.
     1696 * @param   pThisCC         The VMMDev ring-3 instance data.
    16621697 * @param   pReqHdr         The header of the request to handle.
    16631698 */
    1664 static int vmmdevReqHandler_AcknowledgeEvents(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
     1699static int vmmdevReqHandler_AcknowledgeEvents(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC, VMMDevRequestHeader *pReqHdr)
    16651700{
    16661701    VMMDevEvents *pReq = (VMMDevEvents *)pReqHdr;
     
    16821717
    16831718        pThis->fHostEventFlags &= ~pThis->fGuestFilterMask;
    1684         pThis->CTX_SUFF(pVMMDevRAM)->V.V1_04.fHaveEvents = false;
    1685 
    1686         PDMDevHlpPCISetIrqNoWait(pThis->CTX_SUFF(pDevIns), 0, 0);
     1719        pThisCC->CTX_SUFF(pVMMDevRAM)->V.V1_04.fHaveEvents = false;
     1720
     1721        PDMDevHlpPCISetIrqNoWait(pDevIns, 0, 0);
    16871722    }
    16881723    else
    1689         vmmdevSetIRQ_Legacy(pThis);
     1724        vmmdevSetIRQ_Legacy(pDevIns, pThis, pThisCC);
    16901725    return VINF_SUCCESS;
    16911726}
     
    16961731 *
    16971732 * @returns VBox status code that the guest should see.
    1698  * @param   pThis           The VMMDev instance data.
     1733 * @param   pDevIns         The device instance.
     1734 * @param   pThis           The VMMDev shared instance data.
     1735 * @param   pThisCC         The VMMDev ring-3 instance data.
    16991736 * @param   pReqHdr         The header of the request to handle.
    17001737 */
    1701 static int vmmdevReqHandler_CtlGuestFilterMask(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
     1738static int vmmdevReqHandler_CtlGuestFilterMask(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC, VMMDevRequestHeader *pReqHdr)
    17021739{
    17031740    VMMDevCtlGuestFilterMask *pReq = (VMMDevCtlGuestFilterMask *)pReqHdr;
     
    17091746     * automatically when any HGCM command is issued.  The guest
    17101747     * cannot disable these notifications. */
    1711     VMMDevCtlSetGuestFilterMask(pThis, pReq->u32OrMask, pReq->u32NotMask & ~VMMDEV_EVENT_HGCM);
     1748    VMMDevCtlSetGuestFilterMask(pDevIns, pThis, pThisCC, pReq->u32OrMask, pReq->u32NotMask & ~VMMDEV_EVENT_HGCM);
    17121749    return VINF_SUCCESS;
    17131750}
     
    17191756 *
    17201757 * @returns VBox status code that the guest should see.
    1721  * @param   pThis           The VMMDev instance data.
     1758 * @param   pDevIns         The device instance.
     1759 * @param   pThis           The VMMDev shared instance data.
     1760 * @param   pThisCC         The VMMDev ring-3 instance data.
    17221761 * @param   pReqHdr         The header of the request to handle.
    17231762 * @param   GCPhysReqHdr    The guest physical address of the request header.
    17241763 */
    1725 static int vmmdevReqHandler_HGCMConnect(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr, RTGCPHYS GCPhysReqHdr)
     1764static int vmmdevReqHandler_HGCMConnect(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC,
     1765                                        VMMDevRequestHeader *pReqHdr, RTGCPHYS GCPhysReqHdr)
    17261766{
    17271767    VMMDevHGCMConnect *pReq = (VMMDevHGCMConnect *)pReqHdr;
    17281768    AssertMsgReturn(pReq->header.header.size >= sizeof(*pReq), ("%u\n", pReq->header.header.size), VERR_INVALID_PARAMETER); /** @todo Not sure why this is >= ... */
    17291769
    1730     if (pThis->pHGCMDrv)
     1770    if (pThisCC->pHGCMDrv)
    17311771    {
    17321772        Log(("VMMDevReq_HGCMConnect\n"));
    1733         return vmmdevHGCMConnect(pThis, pReq, GCPhysReqHdr);
     1773        return vmmdevR3HgcmConnect(pDevIns, pThis, pThisCC, pReq, GCPhysReqHdr);
    17341774    }
    17351775
     
    17431783 *
    17441784 * @returns VBox status code that the guest should see.
    1745  * @param   pThis           The VMMDev instance data.
     1785 * @param   pDevIns         The device instance.
     1786 * @param   pThis           The VMMDev shared instance data.
     1787 * @param   pThisCC         The VMMDev ring-3 instance data.
    17461788 * @param   pReqHdr         The header of the request to handle.
    17471789 * @param   GCPhysReqHdr    The guest physical address of the request header.
    17481790 */
    1749 static int vmmdevReqHandler_HGCMDisconnect(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr, RTGCPHYS GCPhysReqHdr)
     1791static int vmmdevReqHandler_HGCMDisconnect(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC,
     1792                                           VMMDevRequestHeader *pReqHdr, RTGCPHYS GCPhysReqHdr)
    17501793{
    17511794    VMMDevHGCMDisconnect *pReq = (VMMDevHGCMDisconnect *)pReqHdr;
    17521795    AssertMsgReturn(pReq->header.header.size >= sizeof(*pReq), ("%u\n", pReq->header.header.size), VERR_INVALID_PARAMETER);  /** @todo Not sure why this >= ... */
    17531796
    1754     if (pThis->pHGCMDrv)
     1797    if (pThisCC->pHGCMDrv)
    17551798    {
    17561799        Log(("VMMDevReq_VMMDevHGCMDisconnect\n"));
    1757         return vmmdevHGCMDisconnect(pThis, pReq, GCPhysReqHdr);
     1800        return vmmdevR3HgcmDisconnect(pDevIns, pThis, pThisCC, pReq, GCPhysReqHdr);
    17581801    }
    17591802
     
    17671810 *
    17681811 * @returns VBox status code that the guest should see.
    1769  * @param   pThis           The VMMDev instance data.
     1812 * @param   pDevIns         The device instance.
     1813 * @param   pThis           The VMMDev shared instance data.
     1814 * @param   pThisCC         The VMMDev ring-3 instance data.
    17701815 * @param   pReqHdr         The header of the request to handle.
    17711816 * @param   GCPhysReqHdr    The guest physical address of the request header.
     
    17741819 *                          NULL).  Set to NULL if HGCM takes lock ownership.
    17751820 */
    1776 static int vmmdevReqHandler_HGCMCall(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr, RTGCPHYS GCPhysReqHdr,
    1777                                      uint64_t tsArrival, PVMMDEVREQLOCK *ppLock)
     1821static int vmmdevReqHandler_HGCMCall(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC, VMMDevRequestHeader *pReqHdr,
     1822                                     RTGCPHYS GCPhysReqHdr, uint64_t tsArrival, PVMMDEVREQLOCK *ppLock)
    17781823{
    17791824    VMMDevHGCMCall *pReq = (VMMDevHGCMCall *)pReqHdr;
    17801825    AssertMsgReturn(pReq->header.header.size >= sizeof(*pReq), ("%u\n", pReq->header.header.size), VERR_INVALID_PARAMETER);
    17811826
    1782     if (pThis->pHGCMDrv)
     1827    if (pThisCC->pHGCMDrv)
    17831828    {
    17841829        Log2(("VMMDevReq_HGCMCall: sizeof(VMMDevHGCMRequest) = %04X\n", sizeof(VMMDevHGCMCall)));
    17851830        Log2(("%.*Rhxd\n", pReq->header.header.size, pReq));
    17861831
    1787         return vmmdevHGCMCall(pThis, pReq, pReq->header.header.size, GCPhysReqHdr, pReq->header.header.requestType,
    1788                               tsArrival, ppLock);
     1832        return vmmdevR3HgcmCall(pDevIns, pThis, pThisCC, pReq, pReq->header.header.size, GCPhysReqHdr,
     1833                                pReq->header.header.requestType, tsArrival, ppLock);
    17891834    }
    17901835
     
    17971842 *
    17981843 * @returns VBox status code that the guest should see.
    1799  * @param   pThis           The VMMDev instance data.
     1844 * @param   pThisCC         The VMMDev ring-3 instance data.
    18001845 * @param   pReqHdr         The header of the request to handle.
    18011846 * @param   GCPhysReqHdr    The guest physical address of the request header.
    18021847 */
    1803 static int vmmdevReqHandler_HGCMCancel(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr, RTGCPHYS GCPhysReqHdr)
     1848static int vmmdevReqHandler_HGCMCancel(PVMMDEVCC pThisCC, VMMDevRequestHeader *pReqHdr, RTGCPHYS GCPhysReqHdr)
    18041849{
    18051850    VMMDevHGCMCancel *pReq = (VMMDevHGCMCancel *)pReqHdr;
    18061851    AssertMsgReturn(pReq->header.header.size >= sizeof(*pReq), ("%u\n", pReq->header.header.size), VERR_INVALID_PARAMETER);  /** @todo Not sure why this >= ... */
    18071852
    1808     if (pThis->pHGCMDrv)
     1853    if (pThisCC->pHGCMDrv)
    18091854    {
    18101855        Log(("VMMDevReq_VMMDevHGCMCancel\n"));
    1811         return vmmdevHGCMCancel(pThis, pReq, GCPhysReqHdr);
     1856        return vmmdevR3HgcmCancel(pThisCC, pReq, GCPhysReqHdr);
    18121857    }
    18131858
     
    18211866 *
    18221867 * @returns VBox status code that the guest should see.
    1823  * @param   pThis           The VMMDev instance data.
     1868 * @param   pThisCC         The VMMDev ring-3 instance data.
    18241869 * @param   pReqHdr         The header of the request to handle.
    18251870 */
    1826 static int vmmdevReqHandler_HGCMCancel2(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
     1871static int vmmdevReqHandler_HGCMCancel2(PVMMDEVCC pThisCC, VMMDevRequestHeader *pReqHdr)
    18271872{
    18281873    VMMDevHGCMCancel2 *pReq = (VMMDevHGCMCancel2 *)pReqHdr;
    18291874    AssertMsgReturn(pReq->header.size >= sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);  /** @todo Not sure why this >= ... */
    18301875
    1831     if (pThis->pHGCMDrv)
     1876    if (pThisCC->pHGCMDrv)
    18321877    {
    18331878        Log(("VMMDevReq_HGCMCancel2\n"));
    1834         return vmmdevHGCMCancel2(pThis, pReq->physReqToCancel);
     1879        return vmmdevR3HgcmCancel2(pThisCC, pReq->physReqToCancel);
    18351880    }
    18361881
     
    18461891 *
    18471892 * @returns VBox status code that the guest should see.
    1848  * @param   pThis           The VMMDev instance data.
     1893 * @param   pThis           The VMMDev shared instance data.
     1894 * @param   pThisCC         The VMMDev ring-3 instance data.
    18491895 * @param   pReqHdr         The header of the request to handle.
    18501896 */
    1851 static int vmmdevReqHandler_VideoAccelEnable(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
     1897static int vmmdevReqHandler_VideoAccelEnable(PVMMDEV pThis, PVMMDEVCC pThisCC, VMMDevRequestHeader *pReqHdr)
    18521898{
    18531899    VMMDevVideoAccelEnable *pReq = (VMMDevVideoAccelEnable *)pReqHdr;
    18541900    AssertMsgReturn(pReq->header.size >= sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);  /** @todo Not sure why this >= ... */
    18551901
    1856     if (!pThis->pDrv)
     1902    if (!pThisCC->pDrv)
    18571903    {
    18581904        Log(("VMMDevReq_VideoAccelEnable Connector is NULL!!\n"));
     
    18731919
    18741920    int rc = pReq->u32Enable
    1875            ? pThis->pDrv->pfnVideoAccelEnable(pThis->pDrv, true, &pThis->pVMMDevRAMR3->vbvaMemory)
    1876            : pThis->pDrv->pfnVideoAccelEnable(pThis->pDrv, false, NULL);
     1921           ? pThisCC->pDrv->pfnVideoAccelEnable(pThisCC->pDrv, true, &pThisCC->pVMMDevRAMR3->vbvaMemory)
     1922           : pThisCC->pDrv->pfnVideoAccelEnable(pThisCC->pDrv, false, NULL);
    18771923
    18781924    if (   pReq->u32Enable
     
    18991945 *
    19001946 * @returns VBox status code that the guest should see.
    1901  * @param   pThis           The VMMDev instance data.
     1947 * @param   pThisCC         The VMMDev ring-3 instance data.
    19021948 * @param   pReqHdr         The header of the request to handle.
    19031949 */
    1904 static int vmmdevReqHandler_VideoAccelFlush(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
     1950static int vmmdevReqHandler_VideoAccelFlush(PVMMDEVCC pThisCC, VMMDevRequestHeader *pReqHdr)
    19051951{
    19061952    VMMDevVideoAccelFlush *pReq = (VMMDevVideoAccelFlush *)pReqHdr;
    19071953    AssertMsgReturn(pReq->header.size >= sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);  /** @todo Not sure why this >= ... */
    19081954
    1909     if (!pThis->pDrv)
     1955    if (!pThisCC->pDrv)
    19101956    {
    19111957        Log(("VMMDevReq_VideoAccelFlush: Connector is NULL!!!\n"));
     
    19131959    }
    19141960
    1915     pThis->pDrv->pfnVideoAccelFlush(pThis->pDrv);
     1961    pThisCC->pDrv->pfnVideoAccelFlush(pThisCC->pDrv);
    19161962    return VINF_SUCCESS;
    19171963}
     
    19221968 *
    19231969 * @returns VBox status code that the guest should see.
    1924  * @param   pThis           The VMMDev instance data.
     1970 * @param   pThisCC         The VMMDev ring-3 instance data.
    19251971 * @param   pReqHdr         The header of the request to handle.
    19261972 */
    1927 static int vmmdevReqHandler_VideoSetVisibleRegion(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
     1973static int vmmdevReqHandler_VideoSetVisibleRegion(PVMMDEVCC pThisCC, VMMDevRequestHeader *pReqHdr)
    19281974{
    19291975    VMMDevVideoSetVisibleRegion *pReq = (VMMDevVideoSetVisibleRegion *)pReqHdr;
    19301976    AssertMsgReturn(pReq->header.size + sizeof(RTRECT) >= sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
    19311977
    1932     if (!pThis->pDrv)
     1978    if (!pThisCC->pDrv)
    19331979    {
    19341980        Log(("VMMDevReq_VideoSetVisibleRegion: Connector is NULL!!!\n"));
     
    19461992    Log(("VMMDevReq_VideoSetVisibleRegion %d rectangles\n", pReq->cRect));
    19471993    /* forward the call */
    1948     return pThis->pDrv->pfnSetVisibleRegion(pThis->pDrv, pReq->cRect, &pReq->Rect);
     1994    return pThisCC->pDrv->pfnSetVisibleRegion(pThisCC->pDrv, pReq->cRect, &pReq->Rect);
    19491995}
    19501996
     
    19542000 *
    19552001 * @returns VBox status code that the guest should see.
    1956  * @param   pThis           The VMMDev instance data.
     2002 * @param   pThis           The VMMDev shared instance data.
    19572003 * @param   pReqHdr         The header of the request to handle.
    19582004 */
     
    19832029 *
    19842030 * @returns VBox status code that the guest should see.
    1985  * @param   pThis           The VMMDev instance data.
     2031 * @param   pThis           The VMMDev shared instance data.
    19862032 * @param   pReqHdr         The header of the request to handle.
    19872033 */
     
    20052051 *
    20062052 * @returns VBox status code that the guest should see.
    2007  * @param   pThis           The VMMDev instance data.
     2053 * @param   pThis           The VMMDev shared instance data.
    20082054 * @param   pReqHdr         The header of the request to handle.
    20092055 */
     
    20322078 *
    20332079 * @returns VBox status code that the guest should see.
    2034  * @param   pThis           The VMMDev instance data.
     2080 * @param   pDevIns         The device instance.
     2081 * @param   pThis           The VMMDev shared instance data.
    20352082 * @param   pReqHdr         The header of the request to handle.
    20362083 */
    2037 static int vmmdevReqHandler_ChangeMemBalloon(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
     2084static int vmmdevReqHandler_ChangeMemBalloon(PPDMDEVINS pDevIns, PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
    20382085{
    20392086    VMMDevChangeMemBalloon *pReq = (VMMDevChangeMemBalloon *)pReqHdr;
     
    20442091
    20452092    Log(("VMMDevReq_ChangeMemBalloon\n"));
    2046     int rc = PGMR3PhysChangeMemBalloon(PDMDevHlpGetVM(pThis->pDevInsR3), !!pReq->fInflate, pReq->cPages, pReq->aPhysPage);
     2093    int rc = PGMR3PhysChangeMemBalloon(PDMDevHlpGetVM(pDevIns), !!pReq->fInflate, pReq->cPages, pReq->aPhysPage);
    20472094    if (pReq->fInflate)
    20482095        STAM_REL_U32_INC(&pThis->StatMemBalloonChunks);
     
    20572104 *
    20582105 * @returns VBox status code that the guest should see.
    2059  * @param   pThis           The VMMDev instance data.
     2106 * @param   pThis           The VMMDev shared instance data.
    20602107 * @param   pReqHdr         The header of the request to handle.
    20612108 */
     
    20842131 *
    20852132 * @returns VBox status code that the guest should see.
    2086  * @param   pThis           The VMMDev instance data.
     2133 * @param   pThisCC         The VMMDev ring-3 instance data.
    20872134 * @param   pReqHdr         The header of the request to handle.
    20882135 */
    2089 static int vmmdevReqHandler_ReportGuestStats(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
     2136static int vmmdevReqHandler_ReportGuestStats(PVMMDEVCC pThisCC, VMMDevRequestHeader *pReqHdr)
    20902137{
    20912138    VMMDevReportGuestStats *pReq = (VMMDevReportGuestStats *)pReqHdr;
     
    21522199
    21532200    /* forward the call */
    2154     return pThis->pDrv->pfnReportStatistics(pThis->pDrv, &pReq->guestStats);
     2201    return pThisCC->pDrv->pfnReportStatistics(pThisCC->pDrv, &pReq->guestStats);
    21552202}
    21562203
     
    21602207 *
    21612208 * @returns VBox status code that the guest should see.
    2162  * @param   pThis           The VMMDev instance data.
     2209 * @param   pThis           The VMMDev shared instance data.
     2210 * @param   pThisCC         The VMMDev ring-3 instance data.
    21632211 * @param   pReqHdr         The header of the request to handle.
    21642212 */
    2165 static int vmmdevReqHandler_QueryCredentials(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
     2213static int vmmdevReqHandler_QueryCredentials(PVMMDEV pThis, PVMMDEVCC pThisCC, VMMDevRequestHeader *pReqHdr)
    21662214{
    21672215    VMMDevCredentials *pReq = (VMMDevCredentials *)pReqHdr;
    21682216    AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
     2217    VMMDEVCREDS *pCredentials = pThisCC->pCredentials;
     2218    AssertPtrReturn(pCredentials, VERR_NOT_SUPPORTED);
    21692219
    21702220    /* let's start by nulling out the data */
    2171     memset(pReq->szUserName, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
    2172     memset(pReq->szPassword, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
    2173     memset(pReq->szDomain, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
     2221    RT_ZERO(pReq->szUserName);
     2222    RT_ZERO(pReq->szPassword);
     2223    RT_ZERO(pReq->szDomain);
    21742224
    21752225    /* should we return whether we got credentials for a logon? */
    21762226    if (pReq->u32Flags & VMMDEV_CREDENTIALS_QUERYPRESENCE)
    21772227    {
    2178         if (   pThis->pCredentials->Logon.szUserName[0]
    2179             || pThis->pCredentials->Logon.szPassword[0]
    2180             || pThis->pCredentials->Logon.szDomain[0])
     2228        if (   pCredentials->Logon.szUserName[0]
     2229            || pCredentials->Logon.szPassword[0]
     2230            || pCredentials->Logon.szDomain[0])
    21812231            pReq->u32Flags |= VMMDEV_CREDENTIALS_PRESENT;
    21822232        else
     
    21872237    if (pReq->u32Flags & VMMDEV_CREDENTIALS_READ)
    21882238    {
    2189         if (pThis->pCredentials->Logon.szUserName[0])
    2190             strcpy(pReq->szUserName, pThis->pCredentials->Logon.szUserName);
    2191         if (pThis->pCredentials->Logon.szPassword[0])
    2192             strcpy(pReq->szPassword, pThis->pCredentials->Logon.szPassword);
    2193         if (pThis->pCredentials->Logon.szDomain[0])
    2194             strcpy(pReq->szDomain, pThis->pCredentials->Logon.szDomain);
    2195         if (!pThis->pCredentials->Logon.fAllowInteractiveLogon)
     2239        if (pCredentials->Logon.szUserName[0])
     2240            RTStrCopy(pReq->szUserName, sizeof(pReq->szUserName), pCredentials->Logon.szUserName);
     2241        if (pCredentials->Logon.szPassword[0])
     2242            RTStrCopy(pReq->szPassword, sizeof(pReq->szPassword), pCredentials->Logon.szPassword);
     2243        if (pCredentials->Logon.szDomain[0])
     2244            RTStrCopy(pReq->szDomain, sizeof(pReq->szDomain), pCredentials->Logon.szDomain);
     2245        if (!pCredentials->Logon.fAllowInteractiveLogon)
    21962246            pReq->u32Flags |= VMMDEV_CREDENTIALS_NOLOCALLOGON;
    21972247        else
     
    22042254        if (pReq->u32Flags & VMMDEV_CREDENTIALS_CLEAR)
    22052255        {
    2206             memset(pThis->pCredentials->Logon.szUserName, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
    2207             memset(pThis->pCredentials->Logon.szPassword, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
    2208             memset(pThis->pCredentials->Logon.szDomain, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
     2256            RT_ZERO(pCredentials->Logon.szUserName);
     2257            RT_ZERO(pCredentials->Logon.szPassword);
     2258            RT_ZERO(pCredentials->Logon.szDomain);
    22092259        }
    22102260    }
     
    22132263    if (pReq->u32Flags & VMMDEV_CREDENTIALS_READJUDGE)
    22142264    {
    2215         if (pThis->pCredentials->Judge.szUserName[0])
    2216             strcpy(pReq->szUserName, pThis->pCredentials->Judge.szUserName);
    2217         if (pThis->pCredentials->Judge.szPassword[0])
    2218             strcpy(pReq->szPassword, pThis->pCredentials->Judge.szPassword);
    2219         if (pThis->pCredentials->Judge.szDomain[0])
    2220             strcpy(pReq->szDomain, pThis->pCredentials->Judge.szDomain);
     2265        if (pCredentials->Judge.szUserName[0])
     2266            RTStrCopy(pReq->szUserName, sizeof(pReq->szUserName), pCredentials->Judge.szUserName);
     2267        if (pCredentials->Judge.szPassword[0])
     2268            RTStrCopy(pReq->szPassword, sizeof(pReq->szPassword), pCredentials->Judge.szPassword);
     2269        if (pCredentials->Judge.szDomain[0])
     2270            RTStrCopy(pReq->szDomain, sizeof(pReq->szDomain), pCredentials->Judge.szDomain);
    22212271    }
    22222272
     
    22242274    if (pReq->u32Flags & VMMDEV_CREDENTIALS_CLEARJUDGE)
    22252275    {
    2226         memset(pThis->pCredentials->Judge.szUserName, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
    2227         memset(pThis->pCredentials->Judge.szPassword, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
    2228         memset(pThis->pCredentials->Judge.szDomain, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
     2276        RT_ZERO(pCredentials->Judge.szUserName);
     2277        RT_ZERO(pCredentials->Judge.szPassword);
     2278        RT_ZERO(pCredentials->Judge.szDomain);
    22292279    }
    22302280
     
    22372287 *
    22382288 * @returns VBox status code that the guest should see.
    2239  * @param   pThis           The VMMDev instance data.
     2289 * @param   pThisCC         The VMMDev ring-3 instance data.
    22402290 * @param   pReqHdr         The header of the request to handle.
    22412291 */
    2242 static int vmmdevReqHandler_ReportCredentialsJudgement(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
     2292static int vmmdevReqHandler_ReportCredentialsJudgement(PVMMDEVCC pThisCC, VMMDevRequestHeader *pReqHdr)
    22432293{
    22442294    VMMDevCredentials *pReq = (VMMDevCredentials *)pReqHdr;
     
    22472297    /* what does the guest think about the credentials? (note: the order is important here!) */
    22482298    if (pReq->u32Flags & VMMDEV_CREDENTIALS_JUDGE_DENY)
    2249         pThis->pDrv->pfnSetCredentialsJudgementResult(pThis->pDrv, VMMDEV_CREDENTIALS_JUDGE_DENY);
     2299        pThisCC->pDrv->pfnSetCredentialsJudgementResult(pThisCC->pDrv, VMMDEV_CREDENTIALS_JUDGE_DENY);
    22502300    else if (pReq->u32Flags & VMMDEV_CREDENTIALS_JUDGE_NOJUDGEMENT)
    2251         pThis->pDrv->pfnSetCredentialsJudgementResult(pThis->pDrv, VMMDEV_CREDENTIALS_JUDGE_NOJUDGEMENT);
     2301        pThisCC->pDrv->pfnSetCredentialsJudgementResult(pThisCC->pDrv, VMMDEV_CREDENTIALS_JUDGE_NOJUDGEMENT);
    22522302    else if (pReq->u32Flags & VMMDEV_CREDENTIALS_JUDGE_OK)
    2253         pThis->pDrv->pfnSetCredentialsJudgementResult(pThis->pDrv, VMMDEV_CREDENTIALS_JUDGE_OK);
     2303        pThisCC->pDrv->pfnSetCredentialsJudgementResult(pThisCC->pDrv, VMMDEV_CREDENTIALS_JUDGE_OK);
    22542304    else
    22552305    {
     
    22932343 *
    22942344 * @returns VBox status code that the guest should see.
    2295  * @param   pThis           The VMMDev instance data.
     2345 * @param   pThis           The VMMDev shared instance data.
    22962346 * @param   pReqHdr         The header of the request to handle.
    22972347 */
     
    23182368 *
    23192369 * @returns VBox status code that the guest should see.
    2320  * @param   pThis           The VMMDev instance data.
     2370 * @param   pThis           The VMMDev shared instance data.
    23212371 * @param   pReqHdr         The header of the request to handle.
    23222372 */
     
    23632413 *
    23642414 * @returns VBox status code that the guest should see.
    2365  * @param   pThis           The VMMDev instance data.
     2415 * @param   pThis           The VMMDev shared instance data.
    23662416 * @param   pReqHdr         The header of the request to handle.
    23672417 */
     
    23822432 *
    23832433 * @returns VBox status code that the guest should see.
    2384  * @param   pThis           The VMMDev instance data.
     2434 * @param   pDevIns         The device instance.
    23852435 * @param   pReqHdr         The header of the request to handle.
    23862436 */
    2387 static int vmmdevReqHandler_RegisterSharedModule(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
     2437static int vmmdevReqHandler_RegisterSharedModule(PPDMDEVINS pDevIns, VMMDevRequestHeader *pReqHdr)
    23882438{
    23892439    /*
     
    24062456     * Forward the request to the VMM.
    24072457     */
    2408     return PGMR3SharedModuleRegister(PDMDevHlpGetVM(pThis->pDevInsR3), pReq->enmGuestOS, pReq->szName, pReq->szVersion,
     2458    return PGMR3SharedModuleRegister(PDMDevHlpGetVM(pDevIns), pReq->enmGuestOS, pReq->szName, pReq->szVersion,
    24092459                                     pReq->GCBaseAddr, pReq->cbModule, pReq->cRegions, pReq->aRegions);
    24102460}
     
    24142464 *
    24152465 * @returns VBox status code that the guest should see.
    2416  * @param   pThis           The VMMDev instance data.
     2466 * @param   pDevIns         The device instance.
    24172467 * @param   pReqHdr         The header of the request to handle.
    24182468 */
    2419 static int vmmdevReqHandler_UnregisterSharedModule(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
     2469static int vmmdevReqHandler_UnregisterSharedModule(PPDMDEVINS pDevIns, VMMDevRequestHeader *pReqHdr)
    24202470{
    24212471    /*
     
    24362486     * Forward the request to the VMM.
    24372487     */
    2438     return PGMR3SharedModuleUnregister(PDMDevHlpGetVM(pThis->pDevInsR3), pReq->szName, pReq->szVersion,
     2488    return PGMR3SharedModuleUnregister(PDMDevHlpGetVM(pDevIns), pReq->szName, pReq->szVersion,
    24392489                                       pReq->GCBaseAddr, pReq->cbModule);
    24402490}
     
    24442494 *
    24452495 * @returns VBox status code that the guest should see.
    2446  * @param   pThis           The VMMDev instance data.
     2496 * @param   pDevIns         The device instance.
    24472497 * @param   pReqHdr         The header of the request to handle.
    24482498 */
    2449 static int vmmdevReqHandler_CheckSharedModules(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
     2499static int vmmdevReqHandler_CheckSharedModules(PPDMDEVINS pDevIns, VMMDevRequestHeader *pReqHdr)
    24502500{
    24512501    VMMDevSharedModuleCheckRequest *pReq = (VMMDevSharedModuleCheckRequest *)pReqHdr;
    24522502    AssertMsgReturn(pReq->header.size == sizeof(VMMDevSharedModuleCheckRequest),
    24532503                    ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
    2454     return PGMR3SharedModuleCheckAll(PDMDevHlpGetVM(pThis->pDevInsR3));
     2504    return PGMR3SharedModuleCheckAll(PDMDevHlpGetVM(pDevIns));
    24552505}
    24562506
     
    24592509 *
    24602510 * @returns VBox status code that the guest should see.
    2461  * @param   pThis           The VMMDev instance data.
     2511 * @param   pThisCC         The VMMDev ring-3 instance data.
    24622512 * @param   pReqHdr         The header of the request to handle.
    24632513 */
    2464 static int vmmdevReqHandler_GetPageSharingStatus(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
     2514static int vmmdevReqHandler_GetPageSharingStatus(PVMMDEVCC pThisCC, VMMDevRequestHeader *pReqHdr)
    24652515{
    24662516    VMMDevPageSharingStatusRequest *pReq = (VMMDevPageSharingStatusRequest *)pReqHdr;
     
    24692519
    24702520    pReq->fEnabled = false;
    2471     int rc = pThis->pDrv->pfnIsPageFusionEnabled(pThis->pDrv, &pReq->fEnabled);
     2521    int rc = pThisCC->pDrv->pfnIsPageFusionEnabled(pThisCC->pDrv, &pReq->fEnabled);
    24722522    if (RT_FAILURE(rc))
    24732523        pReq->fEnabled = false;
     
    24802530 *
    24812531 * @returns VBox status code that the guest should see.
    2482  * @param   pThis           The VMMDev instance data.
     2532 * @param   pDevIns         The device instance.
    24832533 * @param   pReqHdr         The header of the request to handle.
    24842534 */
    2485 static int vmmdevReqHandler_DebugIsPageShared(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
     2535static int vmmdevReqHandler_DebugIsPageShared(PPDMDEVINS pDevIns, VMMDevRequestHeader *pReqHdr)
    24862536{
    24872537    VMMDevPageIsSharedRequest *pReq = (VMMDevPageIsSharedRequest *)pReqHdr;
     
    24902540
    24912541# ifdef DEBUG
    2492     return PGMR3SharedModuleGetPageState(PDMDevHlpGetVM(pThis->pDevInsR3), pReq->GCPtrPage, &pReq->fShared, &pReq->uPageFlags);
     2542    return PGMR3SharedModuleGetPageState(PDMDevHlpGetVM(pDevIns), pReq->GCPtrPage, &pReq->fShared, &pReq->uPageFlags);
    24932543# else
    2494     RT_NOREF1(pThis);
     2544    RT_NOREF(pThis);
    24952545    return VERR_NOT_IMPLEMENTED;
    24962546# endif
     
    25042554 *
    25052555 * @returns VBox status code that the guest should see.
    2506  * @param   pThis           The VMMDev instance data.
     2556 * @param   pDevIns         The device instance.
     2557 * @param   pThis           The VMMDev shared instance data.
    25072558 * @param   pReqHdr         Pointer to the request header.
    25082559 */
    2509 static int vmmdevReqHandler_WriteCoreDump(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
     2560static int vmmdevReqHandler_WriteCoreDump(PPDMDEVINS pDevIns, PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
    25102561{
    25112562    VMMDevReqWriteCoreDump *pReq = (VMMDevReqWriteCoreDump *)pReqHdr;
     
    25502601     * Write the core file.
    25512602     */
    2552     PUVM pUVM = PDMDevHlpGetUVM(pThis->pDevInsR3);
     2603    PUVM pUVM = PDMDevHlpGetUVM(pDevIns);
    25532604    return DBGFR3CoreWrite(pUVM, szCorePath, true /*fReplaceFile*/);
    25542605}
     
    25582609 * Sets request status to VINF_HGCM_ASYNC_EXECUTE.
    25592610 *
     2611 * @param   pDevIns         The device instance.
    25602612 * @param   pThis           The VMM device instance data.
    25612613 * @param   GCPhysReqHdr    The guest physical address of the request.
     
    25632615 *                          locked.
    25642616 */
    2565 DECLINLINE(void) vmmdevReqHdrSetHgcmAsyncExecute(PVMMDEV pThis, RTGCPHYS GCPhysReqHdr, PVMMDEVREQLOCK pLock)
     2617DECLINLINE(void) vmmdevReqHdrSetHgcmAsyncExecute(PPDMDEVINS pDevIns, RTGCPHYS GCPhysReqHdr, PVMMDEVREQLOCK pLock)
    25662618{
    25672619    if (pLock)
     
    25702622    {
    25712623        int32_t rcReq = VINF_HGCM_ASYNC_EXECUTE;
    2572         PDMDevHlpPhysWrite(pThis->pDevInsR3, GCPhysReqHdr + RT_UOFFSETOF(VMMDevRequestHeader, rc), &rcReq, sizeof(rcReq));
     2624        PDMDevHlpPhysWrite(pDevIns, GCPhysReqHdr + RT_UOFFSETOF(VMMDevRequestHeader, rc), &rcReq, sizeof(rcReq));
    25732625    }
    25742626}
     
    25852637 *
    25862638 * @returns Port I/O handler exit code.
    2587  * @param   pThis           The VMM device instance data.
     2639 * @param   pDevIns         The device instance.
     2640 * @param   pThis           The VMMDev shared instance data.
     2641 * @param   pThisCC         The VMMDev ring-3 instance data.
    25882642 * @param   pReqHdr         The request header (cached in host memory).
    25892643 * @param   GCPhysReqHdr    The guest physical address of the request (for
     
    25942648 *                          NULL).  Set to NULL if HGCM takes lock ownership.
    25952649 */
    2596 static int vmmdevReqDispatcher(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr, RTGCPHYS GCPhysReqHdr,
    2597                                uint64_t tsArrival, uint32_t *pfPostOptimize, PVMMDEVREQLOCK *ppLock)
     2650static VBOXSTRICTRC vmmdevReqDispatcher(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC, VMMDevRequestHeader *pReqHdr,
     2651                                        RTGCPHYS GCPhysReqHdr, uint64_t tsArrival, uint32_t *pfPostOptimize,
     2652                                        PVMMDEVREQLOCK *ppLock)
    25982653{
    25992654    int rcRet = VINF_SUCCESS;
     
    26032658    {
    26042659        case VMMDevReq_ReportGuestInfo:
    2605             pReqHdr->rc = vmmdevReqHandler_ReportGuestInfo(pThis, pReqHdr);
     2660            pReqHdr->rc = vmmdevReqHandler_ReportGuestInfo(pDevIns, pThis, pThisCC, pReqHdr);
    26062661            break;
    26072662
    26082663        case VMMDevReq_ReportGuestInfo2:
    2609             pReqHdr->rc = vmmdevReqHandler_ReportGuestInfo2(pThis, pReqHdr);
     2664            pReqHdr->rc = vmmdevReqHandler_ReportGuestInfo2(pDevIns, pThis, pThisCC, pReqHdr);
    26102665            break;
    26112666
    26122667        case VMMDevReq_ReportGuestStatus:
    2613             pReqHdr->rc = vmmdevReqHandler_ReportGuestStatus(pThis, pReqHdr);
     2668            pReqHdr->rc = vmmdevReqHandler_ReportGuestStatus(pThis, pThisCC, pReqHdr);
    26142669            break;
    26152670
    26162671        case VMMDevReq_ReportGuestUserState:
    2617             pReqHdr->rc = vmmdevReqHandler_ReportGuestUserState(pThis, pReqHdr);
     2672            pReqHdr->rc = vmmdevReqHandler_ReportGuestUserState(pThisCC, pReqHdr);
    26182673            break;
    26192674
    26202675        case VMMDevReq_ReportGuestCapabilities:
    2621             pReqHdr->rc = vmmdevReqHandler_ReportGuestCapabilities(pThis, pReqHdr);
     2676            pReqHdr->rc = vmmdevReqHandler_ReportGuestCapabilities(pThis, pThisCC, pReqHdr);
    26222677            break;
    26232678
    26242679        case VMMDevReq_SetGuestCapabilities:
    2625             pReqHdr->rc = vmmdevReqHandler_SetGuestCapabilities(pThis, pReqHdr);
     2680            pReqHdr->rc = vmmdevReqHandler_SetGuestCapabilities(pThis, pThisCC, pReqHdr);
    26262681            break;
    26272682
    26282683        case VMMDevReq_WriteCoreDump:
    2629             pReqHdr->rc = vmmdevReqHandler_WriteCoreDump(pThis, pReqHdr);
     2684            pReqHdr->rc = vmmdevReqHandler_WriteCoreDump(pDevIns, pThis, pReqHdr);
    26302685            break;
    26312686
     
    26352690
    26362691        case VMMDevReq_SetMouseStatus:
    2637             pReqHdr->rc = vmmdevReqHandler_SetMouseStatus(pThis, pReqHdr);
     2692            pReqHdr->rc = vmmdevReqHandler_SetMouseStatus(pThis, pThisCC, pReqHdr);
    26382693            break;
    26392694
    26402695        case VMMDevReq_SetPointerShape:
    2641             pReqHdr->rc = vmmdevReqHandler_SetPointerShape(pThis, pReqHdr);
     2696            pReqHdr->rc = vmmdevReqHandler_SetPointerShape(pThis, pThisCC, pReqHdr);
    26422697            break;
    26432698
    26442699        case VMMDevReq_GetHostTime:
    2645             pReqHdr->rc = vmmdevReqHandler_GetHostTime(pThis, pReqHdr);
     2700            pReqHdr->rc = vmmdevReqHandler_GetHostTime(pDevIns, pThis, pReqHdr);
    26462701            break;
    26472702
    26482703        case VMMDevReq_GetHypervisorInfo:
    2649             pReqHdr->rc = vmmdevReqHandler_GetHypervisorInfo(pThis, pReqHdr);
     2704            pReqHdr->rc = vmmdevReqHandler_GetHypervisorInfo(pDevIns, pReqHdr);
    26502705            break;
    26512706
    26522707        case VMMDevReq_SetHypervisorInfo:
    2653             pReqHdr->rc = vmmdevReqHandler_SetHypervisorInfo(pThis, pReqHdr);
     2708            pReqHdr->rc = vmmdevReqHandler_SetHypervisorInfo(pDevIns, pReqHdr);
    26542709            break;
    26552710
    26562711        case VMMDevReq_RegisterPatchMemory:
    2657             pReqHdr->rc = vmmdevReqHandler_RegisterPatchMemory(pThis, pReqHdr);
     2712            pReqHdr->rc = vmmdevReqHandler_RegisterPatchMemory(pDevIns, pReqHdr);
    26582713            break;
    26592714
    26602715        case VMMDevReq_DeregisterPatchMemory:
    2661             pReqHdr->rc = vmmdevReqHandler_DeregisterPatchMemory(pThis, pReqHdr);
     2716            pReqHdr->rc = vmmdevReqHandler_DeregisterPatchMemory(pDevIns, pReqHdr);
    26622717            break;
    26632718
    26642719        case VMMDevReq_SetPowerStatus:
    26652720        {
    2666             int rc = pReqHdr->rc = vmmdevReqHandler_SetPowerStatus(pThis, pReqHdr);
     2721            int rc = pReqHdr->rc = vmmdevReqHandler_SetPowerStatus(pDevIns, pThis, pReqHdr);
    26672722            if (rc != VINF_SUCCESS && RT_SUCCESS(rc))
    26682723                rcRet = rc;
     
    26752730
    26762731        case VMMDevReq_GetDisplayChangeRequest2:
    2677             pReqHdr->rc = vmmdevReqHandler_GetDisplayChangeRequest2(pThis, pReqHdr);
     2732            pReqHdr->rc = vmmdevReqHandler_GetDisplayChangeRequest2(pDevIns, pThis, pThisCC, pReqHdr);
    26782733            break;
    26792734
    26802735        case VMMDevReq_GetDisplayChangeRequestEx:
    2681             pReqHdr->rc = vmmdevReqHandler_GetDisplayChangeRequestEx(pThis, pReqHdr);
     2736            pReqHdr->rc = vmmdevReqHandler_GetDisplayChangeRequestEx(pDevIns, pThis, pThisCC, pReqHdr);
    26822737            break;
    26832738
     
    26872742
    26882743        case VMMDevReq_VideoModeSupported:
    2689             pReqHdr->rc = vmmdevReqHandler_VideoModeSupported(pThis, pReqHdr);
     2744            pReqHdr->rc = vmmdevReqHandler_VideoModeSupported(pThisCC, pReqHdr);
    26902745            break;
    26912746
    26922747        case VMMDevReq_VideoModeSupported2:
    2693             pReqHdr->rc = vmmdevReqHandler_VideoModeSupported2(pThis, pReqHdr);
     2748            pReqHdr->rc = vmmdevReqHandler_VideoModeSupported2(pThisCC, pReqHdr);
    26942749            break;
    26952750
    26962751        case VMMDevReq_GetHeightReduction:
    2697             pReqHdr->rc = vmmdevReqHandler_GetHeightReduction(pThis, pReqHdr);
     2752            pReqHdr->rc = vmmdevReqHandler_GetHeightReduction(pThisCC, pReqHdr);
    26982753            break;
    26992754
    27002755        case VMMDevReq_AcknowledgeEvents:
    2701             pReqHdr->rc = vmmdevReqHandler_AcknowledgeEvents(pThis, pReqHdr);
     2756            pReqHdr->rc = vmmdevReqHandler_AcknowledgeEvents(pDevIns, pThis, pThisCC, pReqHdr);
    27022757            break;
    27032758
    27042759        case VMMDevReq_CtlGuestFilterMask:
    2705             pReqHdr->rc = vmmdevReqHandler_CtlGuestFilterMask(pThis, pReqHdr);
     2760            pReqHdr->rc = vmmdevReqHandler_CtlGuestFilterMask(pDevIns, pThis, pThisCC, pReqHdr);
    27062761            break;
    27072762
    27082763#ifdef VBOX_WITH_HGCM
    27092764        case VMMDevReq_HGCMConnect:
    2710             vmmdevReqHdrSetHgcmAsyncExecute(pThis, GCPhysReqHdr, *ppLock);
    2711             pReqHdr->rc = vmmdevReqHandler_HGCMConnect(pThis, pReqHdr, GCPhysReqHdr);
     2765            vmmdevReqHdrSetHgcmAsyncExecute(pDevIns, GCPhysReqHdr, *ppLock);
     2766            pReqHdr->rc = vmmdevReqHandler_HGCMConnect(pDevIns, pThis, pThisCC, pReqHdr, GCPhysReqHdr);
    27122767            Assert(pReqHdr->rc == VINF_HGCM_ASYNC_EXECUTE || RT_FAILURE_NP(pReqHdr->rc));
    27132768            if (RT_SUCCESS(pReqHdr->rc))
     
    27162771
    27172772        case VMMDevReq_HGCMDisconnect:
    2718             vmmdevReqHdrSetHgcmAsyncExecute(pThis, GCPhysReqHdr, *ppLock);
    2719             pReqHdr->rc = vmmdevReqHandler_HGCMDisconnect(pThis, pReqHdr, GCPhysReqHdr);
     2773            vmmdevReqHdrSetHgcmAsyncExecute(pDevIns, GCPhysReqHdr, *ppLock);
     2774            pReqHdr->rc = vmmdevReqHandler_HGCMDisconnect(pDevIns, pThis, pThisCC, pReqHdr, GCPhysReqHdr);
    27202775            Assert(pReqHdr->rc == VINF_HGCM_ASYNC_EXECUTE || RT_FAILURE_NP(pReqHdr->rc));
    27212776            if (RT_SUCCESS(pReqHdr->rc))
     
    27272782# endif
    27282783        case VMMDevReq_HGCMCall32:
    2729             vmmdevReqHdrSetHgcmAsyncExecute(pThis, GCPhysReqHdr, *ppLock);
    2730             pReqHdr->rc = vmmdevReqHandler_HGCMCall(pThis, pReqHdr, GCPhysReqHdr, tsArrival, ppLock);
     2784            vmmdevReqHdrSetHgcmAsyncExecute(pDevIns, GCPhysReqHdr, *ppLock);
     2785            pReqHdr->rc = vmmdevReqHandler_HGCMCall(pDevIns, pThis, pThisCC, pReqHdr, GCPhysReqHdr, tsArrival, ppLock);
    27312786            Assert(pReqHdr->rc == VINF_HGCM_ASYNC_EXECUTE || RT_FAILURE_NP(pReqHdr->rc));
    27322787            if (RT_SUCCESS(pReqHdr->rc))
     
    27352790
    27362791        case VMMDevReq_HGCMCancel:
    2737             pReqHdr->rc = vmmdevReqHandler_HGCMCancel(pThis, pReqHdr, GCPhysReqHdr);
     2792            pReqHdr->rc = vmmdevReqHandler_HGCMCancel(pThisCC, pReqHdr, GCPhysReqHdr);
    27382793            break;
    27392794
    27402795        case VMMDevReq_HGCMCancel2:
    2741             pReqHdr->rc = vmmdevReqHandler_HGCMCancel2(pThis, pReqHdr);
     2796            pReqHdr->rc = vmmdevReqHandler_HGCMCancel2(pThisCC, pReqHdr);
    27422797            break;
    27432798#endif /* VBOX_WITH_HGCM */
    27442799
    27452800        case VMMDevReq_VideoAccelEnable:
    2746             pReqHdr->rc = vmmdevReqHandler_VideoAccelEnable(pThis, pReqHdr);
     2801            pReqHdr->rc = vmmdevReqHandler_VideoAccelEnable(pThis, pThisCC, pReqHdr);
    27472802            break;
    27482803
    27492804        case VMMDevReq_VideoAccelFlush:
    2750             pReqHdr->rc = vmmdevReqHandler_VideoAccelFlush(pThis, pReqHdr);
     2805            pReqHdr->rc = vmmdevReqHandler_VideoAccelFlush(pThisCC, pReqHdr);
    27512806            break;
    27522807
    27532808        case VMMDevReq_VideoSetVisibleRegion:
    2754             pReqHdr->rc = vmmdevReqHandler_VideoSetVisibleRegion(pThis, pReqHdr);
     2809            pReqHdr->rc = vmmdevReqHandler_VideoSetVisibleRegion(pThisCC, pReqHdr);
    27552810            break;
    27562811
     
    27682823
    27692824        case VMMDevReq_ChangeMemBalloon:
    2770             pReqHdr->rc = vmmdevReqHandler_ChangeMemBalloon(pThis, pReqHdr);
     2825            pReqHdr->rc = vmmdevReqHandler_ChangeMemBalloon(pDevIns, pThis, pReqHdr);
    27712826            break;
    27722827
     
    27762831
    27772832        case VMMDevReq_ReportGuestStats:
    2778             pReqHdr->rc = vmmdevReqHandler_ReportGuestStats(pThis, pReqHdr);
     2833            pReqHdr->rc = vmmdevReqHandler_ReportGuestStats(pThisCC, pReqHdr);
    27792834            break;
    27802835
    27812836        case VMMDevReq_QueryCredentials:
    2782             pReqHdr->rc = vmmdevReqHandler_QueryCredentials(pThis, pReqHdr);
     2837            pReqHdr->rc = vmmdevReqHandler_QueryCredentials(pThis, pThisCC, pReqHdr);
    27832838            break;
    27842839
    27852840        case VMMDevReq_ReportCredentialsJudgement:
    2786             pReqHdr->rc = vmmdevReqHandler_ReportCredentialsJudgement(pThis, pReqHdr);
     2841            pReqHdr->rc = vmmdevReqHandler_ReportCredentialsJudgement(pThisCC, pReqHdr);
    27872842            break;
    27882843
     
    28012856#ifdef VBOX_WITH_PAGE_SHARING
    28022857        case VMMDevReq_RegisterSharedModule:
    2803             pReqHdr->rc = vmmdevReqHandler_RegisterSharedModule(pThis, pReqHdr);
     2858            pReqHdr->rc = vmmdevReqHandler_RegisterSharedModule(pDevIns, pReqHdr);
    28042859            break;
    28052860
    28062861        case VMMDevReq_UnregisterSharedModule:
    2807             pReqHdr->rc = vmmdevReqHandler_UnregisterSharedModule(pThis, pReqHdr);
     2862            pReqHdr->rc = vmmdevReqHandler_UnregisterSharedModule(pDevIns, pReqHdr);
    28082863            break;
    28092864
    28102865        case VMMDevReq_CheckSharedModules:
    2811             pReqHdr->rc = vmmdevReqHandler_CheckSharedModules(pThis, pReqHdr);
     2866            pReqHdr->rc = vmmdevReqHandler_CheckSharedModules(pDevIns, pReqHdr);
    28122867            break;
    28132868
    28142869        case VMMDevReq_GetPageSharingStatus:
    2815             pReqHdr->rc = vmmdevReqHandler_GetPageSharingStatus(pThis, pReqHdr);
     2870            pReqHdr->rc = vmmdevReqHandler_GetPageSharingStatus(pThisCC, pReqHdr);
    28162871            break;
    28172872
    28182873        case VMMDevReq_DebugIsPageShared:
    2819             pReqHdr->rc = vmmdevReqHandler_DebugIsPageShared(pThis, pReqHdr);
     2874            pReqHdr->rc = vmmdevReqHandler_DebugIsPageShared(pDevIns, pReqHdr);
    28202875            break;
    28212876
     
    28452900
    28462901        case VMMDevReq_GuestHeartbeat:
    2847             pReqHdr->rc = vmmDevReqHandler_GuestHeartbeat(pThis);
     2902            pReqHdr->rc = vmmDevReqHandler_GuestHeartbeat(pDevIns, pThis);
    28482903            break;
    28492904
    28502905        case VMMDevReq_HeartbeatConfigure:
    2851             pReqHdr->rc = vmmDevReqHandler_HeartbeatConfigure(pThis, pReqHdr);
     2906            pReqHdr->rc = vmmDevReqHandler_HeartbeatConfigure(pDevIns, pThis, pReqHdr);
    28522907            break;
    28532908
    28542909        case VMMDevReq_NtBugCheck:
    2855             pReqHdr->rc = vmmDevReqHandler_NtBugCheck(pThis, pReqHdr);
     2910            pReqHdr->rc = vmmDevReqHandler_NtBugCheck(pDevIns, pReqHdr);
    28562911            break;
    28572912
     
    28682923
    28692924/**
    2870  * @callback_method_impl{FNIOMIOPORTOUT,
     2925 * @callback_method_impl{FNIOMIOPORTNEWOUT,
    28712926 * Port I/O write andler for the generic request interface.}
    28722927 */
    2873 static DECLCALLBACK(int) vmmdevRequestHandler(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
     2928static DECLCALLBACK(VBOXSTRICTRC)
     2929vmmdevRequestHandler(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t u32, unsigned cb)
    28742930{
    28752931    uint64_t tsArrival;
    28762932    STAM_GET_TS(tsArrival);
    28772933
    2878     RT_NOREF2(Port, cb);
    2879     PVMMDEV pThis = (PVMMDEV)pvUser;
     2934    RT_NOREF(offPort, cb, pvUser);
    28802935
    28812936    /*
     
    29042959    Log2(("VMMDev request issued: %d\n", requestHeader.requestType));
    29052960
    2906     int rcRet = VINF_SUCCESS;
     2961    VBOXSTRICTRC rcRet = VINF_SUCCESS;
    29072962    /* Check that is doesn't exceed the max packet size. */
    29082963    if (requestHeader.size <= VMMDEV_MAX_VMMDEVREQ_SIZE)
    29092964    {
     2965        PVMMDEV   pThis   = PDMDEVINS_2_DATA(pDevIns, PVMMDEV);
     2966        PVMMDEVCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVMMDEVCC);
     2967
    29102968        /*
    29112969         * We require the GAs to report it's information before we let it have
     
    29332991            VMMDevRequestHeader *pRequestHeader     = NULL;
    29342992            if (   requestHeader.size <= _4K
    2935                 && iCpu < RT_ELEMENTS(pThis->apReqBufs))
     2993                && iCpu < RT_ELEMENTS(pThisCC->apReqBufs))
    29362994            {
    2937                 pRequestHeader = pThis->apReqBufs[iCpu];
     2995                pRequestHeader = pThisCC->apReqBufs[iCpu];
    29382996                if (pRequestHeader)
    29392997                { /* likely */ }
    29402998                else
    2941                     pThis->apReqBufs[iCpu] = pRequestHeader = (VMMDevRequestHeader *)RTMemPageAlloc(_4K);
     2999                    pThisCC->apReqBufs[iCpu] = pRequestHeader = (VMMDevRequestHeader *)RTMemPageAlloc(_4K);
    29423000            }
    29433001            else
    29443002            {
    29453003                Assert(iCpu != NIL_VMCPUID);
    2946                 STAM_REL_COUNTER_INC(&pThis->StatReqBufAllocs);
     3004                STAM_REL_COUNTER_INC(&pThisCC->StatReqBufAllocs);
    29473005                pRequestHeaderFree = pRequestHeader = (VMMDevRequestHeader *)RTMemAlloc(RT_MAX(requestHeader.size, 512));
    29483006            }
     
    29783036                 */
    29793037                uint32_t fPostOptimize = 0;
    2980                 PDMCritSectEnter(&pThis->CritSect, VERR_IGNORED);
    2981                 rcRet = vmmdevReqDispatcher(pThis, pRequestHeader, u32, tsArrival, &fPostOptimize, &pLock);
    2982                 PDMCritSectLeave(&pThis->CritSect);
     3038                PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED);
     3039                rcRet = vmmdevReqDispatcher(pDevIns, pThis, pThisCC, pRequestHeader, u32, tsArrival, &fPostOptimize, &pLock);
     3040                PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect);
    29833041
    29843042                /*
     
    30313089 * that can be handled w/o going to ring-3.}
    30323090 */
    3033 PDMBOTHCBDECL(int) vmmdevFastRequestHandler(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
     3091static DECLCALLBACK(VBOXSTRICTRC)
     3092vmmdevFastRequestHandler(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t u32, unsigned cb)
    30343093{
    30353094#ifndef IN_RING3
    30363095# if 0 /* This functionality is offered through reading the port (vmmdevFastRequestIrqAck). Leaving it here for later. */
    3037     PVMMDEV pThis = (PVMMDEV)pvUser;
    3038     Assert(PDMINS_2_DATA(pDevIns, PVMMDEV) == pThis);
    3039     RT_NOREF2(Port, cb);
     3096    PVMMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PVMMDEV);
     3097    RT_NOREF(pvUser, Port, cb);
    30403098
    30413099    /*
     
    30673125                    && uReq.Hdr.size        == sizeof(uReq.Ack)
    30683126                    && cbToRead             == sizeof(uReq.Ack)
    3069                     && pThis->CTX_SUFF(pVMMDevRAM) != NULL)
     3127                    && pThisCC->CTX_SUFF(pVMMDevRAM) != NULL)
    30703128               )
    30713129            {
     
    30753133                 * Try grab the critical section.
    30763134                 */
    3077                 int rc2 = PDMCritSectEnter(&pThis->CritSect, VINF_IOM_R3_IOPORT_WRITE);
     3135                int rc2 = PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VINF_IOM_R3_IOPORT_WRITE);
    30783136                if (rc2 == VINF_SUCCESS)
    30793137                {
     
    30843142
    30853143                    rcStrict = PDMDevHlpPhysWrite(pDevIns, u32, &uReq, uReq.Hdr.size);
    3086                     PDMCritSectLeave(&pThis->CritSect);
     3144                    PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect);
    30873145                    if (rcStrict == VINF_SUCCESS)
    30883146                    { /* likely */ }
     
    31003158            {
    31013159                Log(("vmmdevFastRequestHandler: size=%#x version=%#x requestType=%d (pVMMDevRAM=%p) -> R3\n",
    3102                      uReq.Hdr.size, uReq.Hdr.version, uReq.Hdr.requestType, pThis->CTX_SUFF(pVMMDevRAM) ));
     3160                     uReq.Hdr.size, uReq.Hdr.version, uReq.Hdr.requestType, pThisCC->CTX_SUFF(pVMMDevRAM) ));
    31033161                rcStrict = VINF_IOM_R3_IOPORT_WRITE;
    31043162            }
     
    31153173    return VBOXSTRICTRC_VAL(rcStrict);
    31163174# else
    3117     RT_NOREF(pDevIns, pvUser, Port, u32, cb);
     3175    RT_NOREF(pDevIns, pvUser, offPort, u32, cb);
    31183176    return VINF_IOM_R3_IOPORT_WRITE;
    31193177# endif
    31203178
    31213179#else  /* IN_RING3 */
    3122     return vmmdevRequestHandler(pDevIns, pvUser, Port, u32, cb);
     3180    return vmmdevRequestHandler(pDevIns, pvUser, offPort, u32, cb);
    31233181#endif /* IN_RING3 */
    31243182}
     
    31263184
    31273185/**
    3128  * @callback_method_impl{FNIOMIOPORTIN,
     3186 * @callback_method_impl{FNIOMIOPORTNEWIN,
    31293187 * Port I/O read handler for IRQ acknowledging and getting pending events (same
    31303188 * as VMMDevReq_AcknowledgeEvents - just faster).}
    31313189 */
    3132 PDMBOTHCBDECL(int) vmmdevFastRequestIrqAck(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
    3133 {
    3134     PVMMDEV pThis = (PVMMDEV)pvUser;
    3135     Assert(PDMINS_2_DATA(pDevIns, PVMMDEV) == pThis);
    3136     RT_NOREF(Port);
     3190static DECLCALLBACK(VBOXSTRICTRC)
     3191vmmdevFastRequestIrqAck(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t *pu32, unsigned cb)
     3192{
     3193    PVMMDEV   pThis   = PDMDEVINS_2_DATA(pDevIns, PVMMDEV);
     3194    PVMMDEVCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVMMDEVCC);
     3195    Assert(PDMDEVINS_2_DATA(pDevIns, PVMMDEV) == pThis);
     3196    RT_NOREF(pvUser, offPort);
    31373197
    31383198    /* Only 32-bit accesses. */
     
    31423202    VBOXSTRICTRC rcStrict;
    31433203#ifndef IN_RING3
    3144     if (pThis->CTX_SUFF(pVMMDevRAM) != NULL)
     3204    if (pThisCC->CTX_SUFF(pVMMDevRAM) != NULL)
    31453205#endif
    31463206    {
    31473207        /* Enter critical section and check that the additions has been properly
    31483208           initialized and that we're not in legacy v1.3 device mode. */
    3149         rcStrict = PDMCritSectEnter(&pThis->CritSect, VINF_IOM_R3_IOPORT_READ);
     3209        rcStrict = PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VINF_IOM_R3_IOPORT_READ);
    31503210        if (rcStrict == VINF_SUCCESS)
    31513211        {
     
    31693229
    31703230                pThis->fHostEventFlags &= ~pThis->fGuestFilterMask;
    3171                 pThis->CTX_SUFF(pVMMDevRAM)->V.V1_04.fHaveEvents = false;
     3231                pThisCC->CTX_SUFF(pVMMDevRAM)->V.V1_04.fHaveEvents = false;
    31723232
    31733233                PDMDevHlpPCISetIrqNoWait(pDevIns, 0, 0);
     
    31803240            }
    31813241
    3182             PDMCritSectLeave(&pThis->CritSect);
     3242            PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect);
    31833243        }
    31843244    }
     
    31873247        rcStrict = VINF_IOM_R3_IOPORT_READ;
    31883248#endif
    3189     return VBOXSTRICTRC_VAL(rcStrict);
     3249    return rcStrict;
    31903250}
    31913251
     
    31953255
    31963256/* -=-=-=-=-=- PCI Device -=-=-=-=-=- */
    3197 
    3198 
    3199 /**
    3200  * @callback_method_impl{FNPCIIOREGIONMAP,MMIO/MMIO2 regions}
    3201  */
    3202 static DECLCALLBACK(int) vmmdevIORAMRegionMap(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion,
    3203                                               RTGCPHYS GCPhysAddress, RTGCPHYS cb, PCIADDRESSSPACE enmType)
    3204 {
    3205     PVMMDEV pThis = PDMINS_2_DATA(pDevIns, PVMMDEV);
    3206     LogFlow(("vmmdevR3IORAMRegionMap: iRegion=%d GCPhysAddress=%RGp cb=%RGp enmType=%d\n", iRegion, GCPhysAddress, cb, enmType));
    3207     Assert(pPciDev == pDevIns->apPciDevs[0]);
    3208     RT_NOREF(cb, pPciDev);
    3209 
    3210     int rc;
    3211 
    3212     if (iRegion == 1)
    3213     {
    3214         AssertReturn(enmType == PCI_ADDRESS_SPACE_MEM, VERR_INTERNAL_ERROR);
    3215         Assert(pThis->pVMMDevRAMR3 != NULL);
    3216         if (GCPhysAddress != NIL_RTGCPHYS)
    3217         {
    3218             /*
    3219              * Map the MMIO2 memory.
    3220              */
    3221             pThis->GCPhysVMMDevRAM = GCPhysAddress;
    3222             Assert(pThis->GCPhysVMMDevRAM == GCPhysAddress);
    3223             rc = PDMDevHlpMMIOExMap(pDevIns, pPciDev, iRegion, GCPhysAddress);
    3224         }
    3225         else
    3226         {
    3227             /*
    3228              * It is about to be unmapped, just clean up.
    3229              */
    3230             pThis->GCPhysVMMDevRAM = NIL_RTGCPHYS32;
    3231             rc = VINF_SUCCESS;
    3232         }
    3233     }
    3234     else if (iRegion == 2)
    3235     {
    3236         AssertReturn(enmType == PCI_ADDRESS_SPACE_MEM_PREFETCH, VERR_INTERNAL_ERROR);
    3237         Assert(pThis->pVMMDevHeapR3 != NULL);
    3238         if (GCPhysAddress != NIL_RTGCPHYS)
    3239         {
    3240             /*
    3241              * Map the MMIO2 memory.
    3242              */
    3243             pThis->GCPhysVMMDevHeap = GCPhysAddress;
    3244             Assert(pThis->GCPhysVMMDevHeap == GCPhysAddress);
    3245             rc = PDMDevHlpMMIOExMap(pDevIns, pPciDev, iRegion, GCPhysAddress);
    3246             if (RT_SUCCESS(rc))
    3247                 rc = PDMDevHlpRegisterVMMDevHeap(pDevIns, GCPhysAddress, pThis->pVMMDevHeapR3, VMMDEV_HEAP_SIZE);
    3248         }
    3249         else
    3250         {
    3251             /*
    3252              * It is about to be unmapped, just clean up.
    3253              */
    3254             PDMDevHlpRegisterVMMDevHeap(pDevIns, NIL_RTGCPHYS, pThis->pVMMDevHeapR3, VMMDEV_HEAP_SIZE);
    3255             pThis->GCPhysVMMDevHeap = NIL_RTGCPHYS32;
    3256             rc = VINF_SUCCESS;
    3257         }
    3258     }
    3259     else
    3260     {
    3261         AssertMsgFailed(("%d\n", iRegion));
    3262         rc = VERR_INVALID_PARAMETER;
    3263     }
    3264 
    3265     return rc;
    3266 }
    3267 
    32683257
    32693258/**
     
    32733262                                               RTGCPHYS GCPhysAddress, RTGCPHYS cb, PCIADDRESSSPACE enmType)
    32743263{
    3275     PVMMDEV pThis = PDMINS_2_DATA(pDevIns, PVMMDEV);
     3264    PVMMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PVMMDEV);
    32763265    LogFlow(("vmmdevIOPortRegionMap: iRegion=%d GCPhysAddress=%RGp cb=%RGp enmType=%d\n", iRegion, GCPhysAddress, cb, enmType));
    32773266    RT_NOREF(pPciDev, iRegion, cb, enmType);
     
    32823271    AssertMsg(RT_ALIGN(GCPhysAddress, 8) == GCPhysAddress, ("Expected 8 byte alignment. GCPhysAddress=%#x\n", GCPhysAddress));
    32833272
    3284     /*
    3285      * Register our port IO handlers.
    3286      */
    3287     int rc = PDMDevHlpIOPortRegister(pDevIns, (RTIOPORT)GCPhysAddress + VMMDEV_PORT_OFF_REQUEST, 1,
    3288                                      pThis, vmmdevRequestHandler, NULL, NULL, NULL, "VMMDev Request Handler");
    3289     AssertLogRelRCReturn(rc, rc);
    3290 
    3291     /* The fast one: */
    3292     rc = PDMDevHlpIOPortRegister(pDevIns, (RTIOPORT)GCPhysAddress + VMMDEV_PORT_OFF_REQUEST_FAST, 1,
    3293                                  pThis, vmmdevFastRequestHandler, vmmdevFastRequestIrqAck, NULL, NULL, "VMMDev Fast R0/RC Requests");
    3294     AssertLogRelRCReturn(rc, rc);
    3295     if (pThis->fRZEnabled)
    3296     {
    3297         rc = PDMDevHlpIOPortRegisterR0(pDevIns, (RTIOPORT)GCPhysAddress + VMMDEV_PORT_OFF_REQUEST_FAST, 1,
    3298                                        PDMINS_2_DATA_R0PTR(pDevIns), "vmmdevFastRequestHandler", "vmmdevFastRequestIrqAck",
    3299                                        NULL, NULL, "VMMDev Fast R0/RC Requests");
     3273
     3274    int rc;
     3275    if (GCPhysAddress != NIL_RTGCPHYS)
     3276    {
     3277        AssertMsg(RT_ALIGN(GCPhysAddress, 8) == GCPhysAddress, ("Expected 8 byte alignment. GCPhysAddress=%#x\n", GCPhysAddress));
     3278
     3279        rc = PDMDevHlpIoPortMap(pDevIns, pThis->hIoPortReq, (RTIOPORT)GCPhysAddress + VMMDEV_PORT_OFF_REQUEST);
    33003280        AssertLogRelRCReturn(rc, rc);
    3301         rc = PDMDevHlpIOPortRegisterRC(pDevIns, (RTIOPORT)GCPhysAddress + VMMDEV_PORT_OFF_REQUEST_FAST, 1,
    3302                                        PDMINS_2_DATA_RCPTR(pDevIns), "vmmdevFastRequestHandler", "vmmdevFastRequestIrqAck",
    3303                                        NULL, NULL, "VMMDev Fast R0/RC Requests");
     3281
     3282        rc = PDMDevHlpIoPortMap(pDevIns, pThis->hIoPortFast, (RTIOPORT)GCPhysAddress + VMMDEV_PORT_OFF_REQUEST_FAST);
    33043283        AssertLogRelRCReturn(rc, rc);
    33053284    }
    3306 
     3285    else
     3286    {
     3287        rc = PDMDevHlpIoPortUnmap(pDevIns, pThis->hIoPortReq);
     3288        AssertLogRelRCReturn(rc, rc);
     3289
     3290        rc = PDMDevHlpIoPortUnmap(pDevIns, pThis->hIoPortFast);
     3291        AssertLogRelRCReturn(rc, rc);
     3292    }
    33073293    return rc;
    33083294}
    33093295
    33103296
     3297/**
     3298 * @callback_method_impl{FNPCIIOREGIONMAP,VMMDev heap (MMIO2)}
     3299 */
     3300static DECLCALLBACK(int) vmmdevMmio2HeapRegionMap(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion,
     3301                                                  RTGCPHYS GCPhysAddress, RTGCPHYS cb, PCIADDRESSSPACE enmType)
     3302{
     3303    PVMMDEVCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVMMDEVCC);
     3304    LogFlow(("vmmdevR3IORAMRegionMap: iRegion=%d GCPhysAddress=%RGp cb=%RGp enmType=%d\n", iRegion, GCPhysAddress, cb, enmType));
     3305    RT_NOREF(cb, pPciDev);
     3306
     3307    Assert(pPciDev == pDevIns->apPciDevs[0]);
     3308    AssertReturn(iRegion == 2, VERR_INTERNAL_ERROR_2);
     3309    AssertReturn(enmType == PCI_ADDRESS_SPACE_MEM_PREFETCH, VERR_INTERNAL_ERROR_3);
     3310    Assert(pThisCC->pVMMDevHeapR3 != NULL);
     3311
     3312    int rc;
     3313    if (GCPhysAddress != NIL_RTGCPHYS)
     3314    {
     3315        rc = PDMDevHlpRegisterVMMDevHeap(pDevIns, GCPhysAddress, pThisCC->pVMMDevHeapR3, VMMDEV_HEAP_SIZE);
     3316        AssertRC(rc);
     3317    }
     3318    else
     3319    {
     3320        rc = PDMDevHlpRegisterVMMDevHeap(pDevIns, NIL_RTGCPHYS, pThisCC->pVMMDevHeapR3, VMMDEV_HEAP_SIZE);
     3321        AssertRCStmt(rc, rc = VINF_SUCCESS);
     3322    }
     3323
     3324    return rc;
     3325}
     3326
    33113327
    33123328/* -=-=-=-=-=- Backdoor Logging and Time Sync. -=-=-=-=-=- */
    33133329
    33143330/**
    3315  * @callback_method_impl{FNIOMIOPORTOUT, Backdoor Logging.}
    3316  */
    3317 static DECLCALLBACK(int) vmmdevBackdoorLog(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
    3318 {
    3319     RT_NOREF1(pvUser);
    3320     PVMMDEV pThis = PDMINS_2_DATA(pDevIns, PVMMDEV);
    3321 
    3322     if (!pThis->fBackdoorLogDisabled && cb == 1 && Port == RTLOG_DEBUG_PORT)
     3331 * @callback_method_impl{FNIOMIOPORTNEWOUT, Backdoor Logging.}
     3332 */
     3333static DECLCALLBACK(VBOXSTRICTRC)
     3334vmmdevBackdoorLog(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t u32, unsigned cb)
     3335{
     3336    PVMMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PVMMDEV);
     3337    RT_NOREF(pvUser, offPort);
     3338    Assert(offPort == 0);
     3339
     3340    if (!pThis->fBackdoorLogDisabled && cb == 1)
    33233341    {
    33243342
     
    33613379
    33623380/**
    3363  * @callback_method_impl{FNIOMIOPORTOUT, Alternative time synchronization.}
    3364  */
    3365 static DECLCALLBACK(int) vmmdevAltTimeSyncWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
    3366 {
    3367     RT_NOREF2(pvUser, Port);
    3368     PVMMDEV pThis = PDMINS_2_DATA(pDevIns, PVMMDEV);
     3381 * @callback_method_impl{FNIOMIOPORTNEWOUT, Alternative time synchronization.}
     3382 */
     3383static DECLCALLBACK(VBOXSTRICTRC)
     3384vmmdevAltTimeSyncWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t u32, unsigned cb)
     3385{
     3386    RT_NOREF(pvUser, offPort);
     3387    PVMMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PVMMDEV);
    33693388    if (cb == 4)
    33703389    {
     
    33913410 * @callback_method_impl{FNIOMIOPORTOUT, Alternative time synchronization.}
    33923411 */
    3393 static DECLCALLBACK(int) vmmdevAltTimeSyncRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
    3394 {
    3395     RT_NOREF2(pvUser, Port);
    3396     PVMMDEV pThis = PDMINS_2_DATA(pDevIns, PVMMDEV);
    3397     int     rc;
     3412static DECLCALLBACK(VBOXSTRICTRC)
     3413vmmdevAltTimeSyncRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t *pu32, unsigned cb)
     3414{
     3415    RT_NOREF(pvUser, offPort);
     3416    PVMMDEV      pThis = PDMDEVINS_2_DATA(pDevIns, PVMMDEV);
     3417    VBOXSTRICTRC rc;
    33983418    if (cb == 4)
    33993419    {
     
    34273447static DECLCALLBACK(void *) vmmdevPortQueryInterface(PPDMIBASE pInterface, const char *pszIID)
    34283448{
    3429     PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IBase);
    3430 
    3431     PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThis->IBase);
    3432     PDMIBASE_RETURN_INTERFACE(pszIID, PDMIVMMDEVPORT, &pThis->IPort);
     3449    PVMMDEVCC pThisCC = RT_FROM_MEMBER(pInterface, VMMDEVCC, IBase);
     3450
     3451    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThisCC->IBase);
     3452    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIVMMDEVPORT, &pThisCC->IPort);
    34333453#ifdef VBOX_WITH_HGCM
    3434     PDMIBASE_RETURN_INTERFACE(pszIID, PDMIHGCMPORT, &pThis->IHGCMPort);
     3454    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIHGCMPORT, &pThisCC->IHGCMPort);
    34353455#endif
    34363456    /* Currently only for shared folders. */
    3437     PDMIBASE_RETURN_INTERFACE(pszIID, PDMILEDPORTS, &pThis->SharedFolders.ILeds);
     3457    PDMIBASE_RETURN_INTERFACE(pszIID, PDMILEDPORTS, &pThisCC->SharedFolders.ILeds);
    34383458    return NULL;
    34393459}
     
    34523472static DECLCALLBACK(int) vmmdevQueryStatusLed(PPDMILEDPORTS pInterface, unsigned iLUN, PPDMLED *ppLed)
    34533473{
    3454     PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, SharedFolders.ILeds);
     3474    PVMMDEVCC pThisCC = RT_FROM_MEMBER(pInterface, VMMDEVCC, SharedFolders.ILeds);
    34553475    if (iLUN == 0) /* LUN 0 is shared folders */
    34563476    {
    3457         *ppLed = &pThis->SharedFolders.Led;
     3477        *ppLed = &pThisCC->SharedFolders.Led;
    34583478        return VINF_SUCCESS;
    34593479    }
     
    34693489static DECLCALLBACK(int) vmmdevIPort_QueryAbsoluteMouse(PPDMIVMMDEVPORT pInterface, int32_t *pxAbs, int32_t *pyAbs)
    34703490{
    3471     PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IPort);
     3491    PVMMDEVCC pThisCC = RT_FROM_MEMBER(pInterface, VMMDEVCC, IPort);
     3492    PVMMDEV   pThis   = PDMDEVINS_2_DATA(pThisCC->pDevIns, PVMMDEV);
    34723493
    34733494    /** @todo at the first sign of trouble in this area, just enter the critsect.
     
    34883509static DECLCALLBACK(int) vmmdevIPort_SetAbsoluteMouse(PPDMIVMMDEVPORT pInterface, int32_t xAbs, int32_t yAbs)
    34893510{
    3490     PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IPort);
    3491     PDMCritSectEnter(&pThis->CritSect, VERR_IGNORED);
     3511    PVMMDEVCC  pThisCC = RT_FROM_MEMBER(pInterface, VMMDEVCC, IPort);
     3512    PPDMDEVINS pDevIns = pThisCC->pDevIns;
     3513    PVMMDEV    pThis   = PDMDEVINS_2_DATA(pDevIns, PVMMDEV);
     3514    PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED);
    34923515
    34933516    if (   pThis->xMouseAbs != xAbs
     
    34973520        pThis->xMouseAbs = xAbs;
    34983521        pThis->yMouseAbs = yAbs;
    3499         VMMDevNotifyGuest(pThis, VMMDEV_EVENT_MOUSE_POSITION_CHANGED);
    3500     }
    3501 
    3502     PDMCritSectLeave(&pThis->CritSect);
     3522        VMMDevNotifyGuest(pDevIns, pThis, pThisCC, VMMDEV_EVENT_MOUSE_POSITION_CHANGED);
     3523    }
     3524
     3525    PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect);
    35033526    return VINF_SUCCESS;
    35043527}
     
    35093532static DECLCALLBACK(int) vmmdevIPort_QueryMouseCapabilities(PPDMIVMMDEVPORT pInterface, uint32_t *pfCapabilities)
    35103533{
    3511     PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IPort);
     3534    PVMMDEVCC pThisCC = RT_FROM_MEMBER(pInterface, VMMDEVCC, IPort);
     3535    PVMMDEV   pThis   = PDMDEVINS_2_DATA(pThisCC->pDevIns, PVMMDEV);
    35123536    AssertPtrReturn(pfCapabilities, VERR_INVALID_PARAMETER);
    35133537
     
    35223546vmmdevIPort_UpdateMouseCapabilities(PPDMIVMMDEVPORT pInterface, uint32_t fCapsAdded, uint32_t fCapsRemoved)
    35233547{
    3524     PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IPort);
    3525     PDMCritSectEnter(&pThis->CritSect, VERR_IGNORED);
     3548    PVMMDEVCC  pThisCC = RT_FROM_MEMBER(pInterface, VMMDEVCC, IPort);
     3549    PPDMDEVINS pDevIns = pThisCC->pDevIns;
     3550    PVMMDEV    pThis   = PDMDEVINS_2_DATA(pDevIns, PVMMDEV);
     3551    PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED);
    35263552
    35273553    uint32_t fOldCaps = pThis->fMouseCapabilities;
     
    35353561
    35363562    if (fNotify)
    3537         VMMDevNotifyGuest(pThis, VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED);
    3538 
    3539     PDMCritSectLeave(&pThis->CritSect);
     3563        VMMDevNotifyGuest(pDevIns, pThis, pThisCC, VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED);
     3564
     3565    PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect);
    35403566    return VINF_SUCCESS;
    35413567}
     
    35773603vmmdevIPort_RequestDisplayChange(PPDMIVMMDEVPORT pInterface, uint32_t cDisplays, VMMDevDisplayDef const *paDisplays, bool fForce, bool fMayNotify)
    35783604{
    3579     int rc = VINF_SUCCESS;
    3580 
    3581     PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IPort);
    3582     bool fNotifyGuest = false;
    3583 
    3584     PDMCritSectEnter(&pThis->CritSect, VERR_IGNORED);
     3605    PVMMDEVCC   pThisCC      = RT_FROM_MEMBER(pInterface, VMMDEVCC, IPort);
     3606    PPDMDEVINS  pDevIns      = pThisCC->pDevIns;
     3607    PVMMDEV     pThis        = PDMDEVINS_2_DATA(pDevIns, PVMMDEV);
     3608    int         rc           = VINF_SUCCESS;
     3609    bool        fNotifyGuest = false;
     3610
     3611    PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED);
    35853612
    35863613    uint32_t i;
     
    36323659
    36333660            /* IRQ so the guest knows what's going on */
    3634             VMMDevNotifyGuest(pThis, VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST);
     3661            VMMDevNotifyGuest(pDevIns, pThis, pThisCC, VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST);
    36353662        }
    36363663    }
    36373664
    3638     PDMCritSectLeave(&pThis->CritSect);
     3665    PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect);
    36393666    return rc;
    36403667}
     
    36453672static DECLCALLBACK(int) vmmdevIPort_RequestSeamlessChange(PPDMIVMMDEVPORT pInterface, bool fEnabled)
    36463673{
    3647     PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IPort);
    3648     PDMCritSectEnter(&pThis->CritSect, VERR_IGNORED);
     3674    PVMMDEVCC  pThisCC = RT_FROM_MEMBER(pInterface, VMMDEVCC, IPort);
     3675    PPDMDEVINS pDevIns = pThisCC->pDevIns;
     3676    PVMMDEV    pThis   = PDMDEVINS_2_DATA(pDevIns, PVMMDEV);
     3677    PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED);
    36493678
    36503679    /* Verify that the new resolution is different and that guest does not yet know about it. */
     
    36593688
    36603689        /* IRQ so the guest knows what's going on */
    3661         VMMDevNotifyGuest(pThis, VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST);
    3662     }
    3663 
    3664     PDMCritSectLeave(&pThis->CritSect);
     3690        VMMDevNotifyGuest(pDevIns, pThis, pThisCC, VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST);
     3691    }
     3692
     3693    PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect);
    36653694    return VINF_SUCCESS;
    36663695}
     
    36713700static DECLCALLBACK(int) vmmdevIPort_SetMemoryBalloon(PPDMIVMMDEVPORT pInterface, uint32_t cMbBalloon)
    36723701{
    3673     PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IPort);
    3674     PDMCritSectEnter(&pThis->CritSect, VERR_IGNORED);
     3702    PVMMDEVCC  pThisCC = RT_FROM_MEMBER(pInterface, VMMDEVCC, IPort);
     3703    PPDMDEVINS pDevIns = pThisCC->pDevIns;
     3704    PVMMDEV    pThis   = PDMDEVINS_2_DATA(pDevIns, PVMMDEV);
     3705    PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED);
    36753706
    36763707    /* Verify that the new resolution is different and that guest does not yet know about it. */
     
    36823713
    36833714        /* IRQ so the guest knows what's going on */
    3684         VMMDevNotifyGuest(pThis, VMMDEV_EVENT_BALLOON_CHANGE_REQUEST);
    3685     }
    3686 
    3687     PDMCritSectLeave(&pThis->CritSect);
     3715        VMMDevNotifyGuest(pDevIns, pThis, pThisCC, VMMDEV_EVENT_BALLOON_CHANGE_REQUEST);
     3716    }
     3717
     3718    PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect);
    36883719    return VINF_SUCCESS;
    36893720}
     
    36943725static DECLCALLBACK(int) vmmdevIPort_VRDPChange(PPDMIVMMDEVPORT pInterface, bool fVRDPEnabled, uint32_t uVRDPExperienceLevel)
    36953726{
    3696     PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IPort);
    3697     PDMCritSectEnter(&pThis->CritSect, VERR_IGNORED);
     3727    PVMMDEVCC  pThisCC = RT_FROM_MEMBER(pInterface, VMMDEVCC, IPort);
     3728    PPDMDEVINS pDevIns = pThisCC->pDevIns;
     3729    PVMMDEV    pThis   = PDMDEVINS_2_DATA(pDevIns, PVMMDEV);
     3730    PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED);
    36983731
    36993732    bool fSame = (pThis->fVRDPEnabled == fVRDPEnabled);
     
    37063739        pThis->uVRDPExperienceLevel = uVRDPExperienceLevel;
    37073740
    3708         VMMDevNotifyGuest(pThis, VMMDEV_EVENT_VRDP);
    3709     }
    3710 
    3711     PDMCritSectLeave(&pThis->CritSect);
     3741        VMMDevNotifyGuest(pDevIns, pThis, pThisCC, VMMDEV_EVENT_VRDP);
     3742    }
     3743
     3744    PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect);
    37123745    return VINF_SUCCESS;
    37133746}
     
    37183751static DECLCALLBACK(int) vmmdevIPort_SetStatisticsInterval(PPDMIVMMDEVPORT pInterface, uint32_t cSecsStatInterval)
    37193752{
    3720     PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IPort);
    3721     PDMCritSectEnter(&pThis->CritSect, VERR_IGNORED);
     3753    PVMMDEVCC  pThisCC = RT_FROM_MEMBER(pInterface, VMMDEVCC, IPort);
     3754    PPDMDEVINS pDevIns = pThisCC->pDevIns;
     3755    PVMMDEV    pThis   = PDMDEVINS_2_DATA(pDevIns, PVMMDEV);
     3756    PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED);
    37223757
    37233758    /* Verify that the new resolution is different and that guest does not yet know about it. */
     
    37323767
    37333768        /* IRQ so the guest knows what's going on */
    3734         VMMDevNotifyGuest(pThis, VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST);
    3735     }
    3736 
    3737     PDMCritSectLeave(&pThis->CritSect);
     3769        VMMDevNotifyGuest(pDevIns, pThis, pThisCC, VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST);
     3770    }
     3771
     3772    PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect);
    37383773    return VINF_SUCCESS;
    37393774}
     
    37453780                                                    const char *pszPassword, const char *pszDomain, uint32_t fFlags)
    37463781{
    3747     PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IPort);
     3782    PVMMDEVCC  pThisCC = RT_FROM_MEMBER(pInterface, VMMDEVCC, IPort);
     3783    PPDMDEVINS pDevIns = pThisCC->pDevIns;
     3784    PVMMDEV    pThis   = PDMDEVINS_2_DATA(pDevIns, PVMMDEV);
     3785
    37483786    AssertReturn(fFlags & (VMMDEV_SETCREDENTIALS_GUESTLOGON | VMMDEV_SETCREDENTIALS_JUDGE), VERR_INVALID_PARAMETER);
    37493787    size_t const cchUsername = strlen(pszUsername);
     
    37543792    AssertReturn(cchDomain < VMMDEV_CREDENTIALS_SZ_SIZE, VERR_BUFFER_OVERFLOW);
    37553793
    3756     PDMCritSectEnter(&pThis->CritSect, VERR_IGNORED);
     3794    VMMDEVCREDS *pCredentials = pThisCC->pCredentials;
     3795    AssertPtrReturn(pCredentials, VERR_NOT_SUPPORTED);
     3796
     3797    PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED);
    37573798
    37583799    /*
     
    37623803    {
    37633804        /* memorize the data */
    3764         memcpy(pThis->pCredentials->Logon.szUserName, pszUsername, cchUsername);
    3765         pThis->pCredentials->Logon.szUserName[cchUsername] = '\0';
    3766         memcpy(pThis->pCredentials->Logon.szPassword, pszPassword, cchPassword);
    3767         pThis->pCredentials->Logon.szPassword[cchPassword] = '\0';
    3768         memcpy(pThis->pCredentials->Logon.szDomain,   pszDomain, cchDomain);
    3769         pThis->pCredentials->Logon.szDomain[cchDomain]     = '\0';
    3770         pThis->pCredentials->Logon.fAllowInteractiveLogon = !(fFlags & VMMDEV_SETCREDENTIALS_NOLOCALLOGON);
     3805        memcpy(pCredentials->Logon.szUserName, pszUsername, cchUsername);
     3806        pThisCC->pCredentials->Logon.szUserName[cchUsername] = '\0';
     3807        memcpy(pCredentials->Logon.szPassword, pszPassword, cchPassword);
     3808        pCredentials->Logon.szPassword[cchPassword] = '\0';
     3809        memcpy(pCredentials->Logon.szDomain,   pszDomain, cchDomain);
     3810        pCredentials->Logon.szDomain[cchDomain]     = '\0';
     3811        pCredentials->Logon.fAllowInteractiveLogon = !(fFlags & VMMDEV_SETCREDENTIALS_NOLOCALLOGON);
    37713812    }
    37723813    /*
     
    37763817    {
    37773818        /* memorize the data */
    3778         memcpy(pThis->pCredentials->Judge.szUserName, pszUsername, cchUsername);
    3779         pThis->pCredentials->Judge.szUserName[cchUsername] = '\0';
    3780         memcpy(pThis->pCredentials->Judge.szPassword, pszPassword, cchPassword);
    3781         pThis->pCredentials->Judge.szPassword[cchPassword] = '\0';
    3782         memcpy(pThis->pCredentials->Judge.szDomain,   pszDomain,   cchDomain);
    3783         pThis->pCredentials->Judge.szDomain[cchDomain]     = '\0';
    3784 
    3785         VMMDevNotifyGuest(pThis, VMMDEV_EVENT_JUDGE_CREDENTIALS);
    3786     }
    3787 
    3788     PDMCritSectLeave(&pThis->CritSect);
     3819        memcpy(pCredentials->Judge.szUserName, pszUsername, cchUsername);
     3820        pCredentials->Judge.szUserName[cchUsername] = '\0';
     3821        memcpy(pCredentials->Judge.szPassword, pszPassword, cchPassword);
     3822        pCredentials->Judge.szPassword[cchPassword] = '\0';
     3823        memcpy(pCredentials->Judge.szDomain,   pszDomain,   cchDomain);
     3824        pCredentials->Judge.szDomain[cchDomain]     = '\0';
     3825
     3826        VMMDevNotifyGuest(pDevIns, pThis, pThisCC, VMMDEV_EVENT_JUDGE_CREDENTIALS);
     3827    }
     3828
     3829    PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect);
    37893830    return VINF_SUCCESS;
    37903831}
     
    37983839static DECLCALLBACK(void) vmmdevIPort_VBVAChange(PPDMIVMMDEVPORT pInterface, bool fEnabled)
    37993840{
    3800     PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IPort);
     3841    PVMMDEVCC pThisCC = RT_FROM_MEMBER(pInterface, VMMDEVCC, IPort);
     3842    PVMMDEV   pThis   = PDMDEVINS_2_DATA(pThisCC->pDevIns, PVMMDEV);
    38013843    Log(("vmmdevIPort_VBVAChange: fEnabled = %d\n", fEnabled));
    38023844
     
    38103852static DECLCALLBACK(int) vmmdevIPort_CpuHotUnplug(PPDMIVMMDEVPORT pInterface, uint32_t idCpuCore, uint32_t idCpuPackage)
    38113853{
    3812     PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IPort);
    3813     int     rc    = VINF_SUCCESS;
     3854    PVMMDEVCC   pThisCC = RT_FROM_MEMBER(pInterface, VMMDEVCC, IPort);
     3855    PPDMDEVINS  pDevIns = pThisCC->pDevIns;
     3856    PVMMDEV     pThis   = PDMDEVINS_2_DATA(pDevIns, PVMMDEV);
     3857    int         rc      = VINF_SUCCESS;
    38143858
    38153859    Log(("vmmdevIPort_CpuHotUnplug: idCpuCore=%u idCpuPackage=%u\n", idCpuCore, idCpuPackage));
    38163860
    3817     PDMCritSectEnter(&pThis->CritSect, VERR_IGNORED);
     3861    PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED);
    38183862
    38193863    if (pThis->fCpuHotPlugEventsEnabled)
     
    38223866        pThis->idCpuCore          = idCpuCore;
    38233867        pThis->idCpuPackage       = idCpuPackage;
    3824         VMMDevNotifyGuest(pThis, VMMDEV_EVENT_CPU_HOTPLUG);
     3868        VMMDevNotifyGuest(pDevIns, pThis, pThisCC, VMMDEV_EVENT_CPU_HOTPLUG);
    38253869    }
    38263870    else
    38273871        rc = VERR_VMMDEV_CPU_HOTPLUG_NOT_MONITORED_BY_GUEST;
    38283872
    3829     PDMCritSectLeave(&pThis->CritSect);
     3873    PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect);
    38303874    return rc;
    38313875}
     
    38363880static DECLCALLBACK(int) vmmdevIPort_CpuHotPlug(PPDMIVMMDEVPORT pInterface, uint32_t idCpuCore, uint32_t idCpuPackage)
    38373881{
    3838     PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IPort);
    3839     int     rc    = VINF_SUCCESS;
     3882    PVMMDEVCC   pThisCC = RT_FROM_MEMBER(pInterface, VMMDEVCC, IPort);
     3883    PPDMDEVINS  pDevIns = pThisCC->pDevIns;
     3884    PVMMDEV     pThis   = PDMDEVINS_2_DATA(pDevIns, PVMMDEV);
     3885    int         rc      = VINF_SUCCESS;
    38403886
    38413887    Log(("vmmdevCpuPlug: idCpuCore=%u idCpuPackage=%u\n", idCpuCore, idCpuPackage));
    38423888
    3843     PDMCritSectEnter(&pThis->CritSect, VERR_IGNORED);
     3889    PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED);
    38443890
    38453891    if (pThis->fCpuHotPlugEventsEnabled)
     
    38483894        pThis->idCpuCore          = idCpuCore;
    38493895        pThis->idCpuPackage       = idCpuPackage;
    3850         VMMDevNotifyGuest(pThis, VMMDEV_EVENT_CPU_HOTPLUG);
     3896        VMMDevNotifyGuest(pDevIns, pThis, pThisCC, VMMDEV_EVENT_CPU_HOTPLUG);
    38513897    }
    38523898    else
    38533899        rc = VERR_VMMDEV_CPU_HOTPLUG_NOT_MONITORED_BY_GUEST;
    38543900
    3855     PDMCritSectLeave(&pThis->CritSect);
     3901    PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect);
    38563902    return rc;
    38573903}
     
    38653911static DECLCALLBACK(int) vmmdevLiveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uPass)
    38663912{
    3867     RT_NOREF1(uPass);
    3868     PVMMDEV pThis = PDMINS_2_DATA(pDevIns, PVMMDEV);
     3913    RT_NOREF(uPass);
     3914    PVMMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PVMMDEV);
    38693915
    38703916    SSMR3PutBool(pSSM, pThis->fGetHostTimeDisabled);
     
    38823928static DECLCALLBACK(int) vmmdevSaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
    38833929{
    3884     PVMMDEV pThis = PDMINS_2_DATA(pDevIns, PVMMDEV);
    3885     PDMCritSectEnter(&pThis->CritSect, VERR_IGNORED);
     3930    PVMMDEV         pThis   = PDMDEVINS_2_DATA(pDevIns, PVMMDEV);
     3931    PVMMDEVCC       pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVMMDEVCC);
     3932    PCPDMDEVHLPR3   pHlp    = pDevIns->pHlpR3;
     3933    PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED);
    38863934
    38873935    vmmdevLiveExec(pDevIns, pSSM, SSM_PASS_FINAL);
    38883936
    3889     SSMR3PutU32(pSSM, 0 /*was pThis->hypervisorSize, which was always zero*/);
    3890     SSMR3PutU32(pSSM, pThis->fMouseCapabilities);
    3891     SSMR3PutS32(pSSM, pThis->xMouseAbs);
    3892     SSMR3PutS32(pSSM, pThis->yMouseAbs);
    3893 
    3894     SSMR3PutBool(pSSM, pThis->fNewGuestFilterMaskValid);
    3895     SSMR3PutU32(pSSM, pThis->fNewGuestFilterMask);
    3896     SSMR3PutU32(pSSM, pThis->fGuestFilterMask);
    3897     SSMR3PutU32(pSSM, pThis->fHostEventFlags);
     3937    pHlp->pfnSSMPutU32(pSSM, 0 /*was pThis->hypervisorSize, which was always zero*/);
     3938    pHlp->pfnSSMPutU32(pSSM, pThis->fMouseCapabilities);
     3939    pHlp->pfnSSMPutS32(pSSM, pThis->xMouseAbs);
     3940    pHlp->pfnSSMPutS32(pSSM, pThis->yMouseAbs);
     3941
     3942    pHlp->pfnSSMPutBool(pSSM, pThis->fNewGuestFilterMaskValid);
     3943    pHlp->pfnSSMPutU32(pSSM, pThis->fNewGuestFilterMask);
     3944    pHlp->pfnSSMPutU32(pSSM, pThis->fGuestFilterMask);
     3945    pHlp->pfnSSMPutU32(pSSM, pThis->fHostEventFlags);
    38983946    /* The following is not strictly necessary as PGM restores MMIO2, keeping it for historical reasons. */
    3899     SSMR3PutMem(pSSM, &pThis->pVMMDevRAMR3->V, sizeof(pThis->pVMMDevRAMR3->V));
    3900 
    3901     SSMR3PutMem(pSSM, &pThis->guestInfo, sizeof(pThis->guestInfo));
    3902     SSMR3PutU32(pSSM, pThis->fu32AdditionsOk);
    3903     SSMR3PutU32(pSSM, pThis->u32VideoAccelEnabled);
    3904     SSMR3PutBool(pSSM, pThis->displayChangeData.fGuestSentChangeEventAck);
    3905 
    3906     SSMR3PutU32(pSSM, pThis->fGuestCaps);
     3947    pHlp->pfnSSMPutMem(pSSM, &pThisCC->pVMMDevRAMR3->V, sizeof(pThisCC->pVMMDevRAMR3->V));
     3948
     3949    pHlp->pfnSSMPutMem(pSSM, &pThis->guestInfo, sizeof(pThis->guestInfo));
     3950    pHlp->pfnSSMPutU32(pSSM, pThis->fu32AdditionsOk);
     3951    pHlp->pfnSSMPutU32(pSSM, pThis->u32VideoAccelEnabled);
     3952    pHlp->pfnSSMPutBool(pSSM, pThis->displayChangeData.fGuestSentChangeEventAck);
     3953
     3954    pHlp->pfnSSMPutU32(pSSM, pThis->fGuestCaps);
    39073955
    39083956#ifdef VBOX_WITH_HGCM
    3909     vmmdevHGCMSaveState(pThis, pSSM);
     3957    vmmdevR3HgcmSaveState(pThisCC, pSSM);
    39103958#endif /* VBOX_WITH_HGCM */
    39113959
    3912     SSMR3PutU32(pSSM, pThis->fHostCursorRequested);
    3913 
    3914     SSMR3PutU32(pSSM, pThis->guestInfo2.uFullVersion);
    3915     SSMR3PutU32(pSSM, pThis->guestInfo2.uRevision);
    3916     SSMR3PutU32(pSSM, pThis->guestInfo2.fFeatures);
    3917     SSMR3PutStrZ(pSSM, pThis->guestInfo2.szName);
    3918     SSMR3PutU32(pSSM, pThis->cFacilityStatuses);
     3960    pHlp->pfnSSMPutU32(pSSM, pThis->fHostCursorRequested);
     3961
     3962    pHlp->pfnSSMPutU32(pSSM, pThis->guestInfo2.uFullVersion);
     3963    pHlp->pfnSSMPutU32(pSSM, pThis->guestInfo2.uRevision);
     3964    pHlp->pfnSSMPutU32(pSSM, pThis->guestInfo2.fFeatures);
     3965    pHlp->pfnSSMPutStrZ(pSSM, pThis->guestInfo2.szName);
     3966    pHlp->pfnSSMPutU32(pSSM, pThis->cFacilityStatuses);
    39193967    for (uint32_t i = 0; i < pThis->cFacilityStatuses; i++)
    39203968    {
    3921         SSMR3PutU32(pSSM, pThis->aFacilityStatuses[i].enmFacility);
    3922         SSMR3PutU32(pSSM, pThis->aFacilityStatuses[i].fFlags);
    3923         SSMR3PutU16(pSSM, (uint16_t)pThis->aFacilityStatuses[i].enmStatus);
    3924         SSMR3PutS64(pSSM, RTTimeSpecGetNano(&pThis->aFacilityStatuses[i].TimeSpecTS));
     3969        pHlp->pfnSSMPutU32(pSSM, pThis->aFacilityStatuses[i].enmFacility);
     3970        pHlp->pfnSSMPutU32(pSSM, pThis->aFacilityStatuses[i].fFlags);
     3971        pHlp->pfnSSMPutU16(pSSM, (uint16_t)pThis->aFacilityStatuses[i].enmStatus);
     3972        pHlp->pfnSSMPutS64(pSSM, RTTimeSpecGetNano(&pThis->aFacilityStatuses[i].TimeSpecTS));
    39253973    }
    39263974
    39273975    /* Heartbeat: */
    3928     SSMR3PutBool(pSSM, pThis->fHeartbeatActive);
    3929     SSMR3PutBool(pSSM, pThis->fFlatlined);
    3930     SSMR3PutU64(pSSM, pThis->nsLastHeartbeatTS);
    3931     TMR3TimerSave(pThis->pFlatlinedTimer, pSSM);
    3932 
    3933     PDMCritSectLeave(&pThis->CritSect);
     3976    pHlp->pfnSSMPutBool(pSSM, pThis->fHeartbeatActive);
     3977    pHlp->pfnSSMPutBool(pSSM, pThis->fFlatlined);
     3978    pHlp->pfnSSMPutU64(pSSM, pThis->nsLastHeartbeatTS);
     3979    PDMDevHlpTimerSave(pDevIns, pThis->hFlatlinedTimer, pSSM);
     3980
     3981    PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect);
    39343982    return VINF_SUCCESS;
    39353983}
     
    39403988static DECLCALLBACK(int) vmmdevLoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)
    39413989{
    3942     /** @todo The code load code is assuming we're always loaded into a freshly
    3943      *        constructed VM. */
    3944     PVMMDEV pThis = PDMINS_2_DATA(pDevIns, PVMMDEV);
    3945     int     rc;
     3990    PVMMDEV         pThis   = PDMDEVINS_2_DATA(pDevIns, PVMMDEV);
     3991    PVMMDEVCC       pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVMMDEVCC);
     3992    PCPDMDEVHLPR3   pHlp    = pDevIns->pHlpR3;
     3993    int             rc;
    39463994
    39473995    if (   uVersion > VMMDEV_SAVED_STATE_VERSION
     
    39534001    {
    39544002        bool f;
    3955         rc = SSMR3GetBool(pSSM, &f); AssertRCReturn(rc, rc);
     4003        rc = pHlp->pfnSSMGetBool(pSSM, &f); AssertRCReturn(rc, rc);
    39564004        if (pThis->fGetHostTimeDisabled != f)
    39574005            LogRel(("VMMDev: Config mismatch - fGetHostTimeDisabled: config=%RTbool saved=%RTbool\n", pThis->fGetHostTimeDisabled, f));
    39584006
    3959         rc = SSMR3GetBool(pSSM, &f); AssertRCReturn(rc, rc);
     4007        rc = pHlp->pfnSSMGetBool(pSSM, &f); AssertRCReturn(rc, rc);
    39604008        if (pThis->fBackdoorLogDisabled != f)
    39614009            LogRel(("VMMDev: Config mismatch - fBackdoorLogDisabled: config=%RTbool saved=%RTbool\n", pThis->fBackdoorLogDisabled, f));
    39624010
    3963         rc = SSMR3GetBool(pSSM, &f); AssertRCReturn(rc, rc);
     4011        rc = pHlp->pfnSSMGetBool(pSSM, &f); AssertRCReturn(rc, rc);
    39644012        if (pThis->fKeepCredentials != f)
    3965             return SSMR3SetCfgError(pSSM, RT_SRC_POS, N_("Config mismatch - fKeepCredentials: config=%RTbool saved=%RTbool"),
    3966                                      pThis->fKeepCredentials, f);
    3967         rc = SSMR3GetBool(pSSM, &f); AssertRCReturn(rc, rc);
     4013            return pHlp->pfnSSMSetCfgError(pSSM, RT_SRC_POS, N_("Config mismatch - fKeepCredentials: config=%RTbool saved=%RTbool"),
     4014                                           pThis->fKeepCredentials, f);
     4015        rc = pHlp->pfnSSMGetBool(pSSM, &f); AssertRCReturn(rc, rc);
    39684016        if (pThis->fHeapEnabled != f)
    3969             return SSMR3SetCfgError(pSSM, RT_SRC_POS, N_("Config mismatch - fHeapEnabled: config=%RTbool saved=%RTbool"),
    3970                                     pThis->fHeapEnabled, f);
     4017            return pHlp->pfnSSMSetCfgError(pSSM, RT_SRC_POS, N_("Config mismatch - fHeapEnabled: config=%RTbool saved=%RTbool"),
     4018                                           pThis->fHeapEnabled, f);
    39714019    }
    39724020
     
    39764024    /* state */
    39774025    uint32_t uIgn;
    3978     SSMR3GetU32(pSSM, &uIgn);
    3979     SSMR3GetU32(pSSM, &pThis->fMouseCapabilities);
    3980     SSMR3GetS32(pSSM, &pThis->xMouseAbs);
    3981     SSMR3GetS32(pSSM, &pThis->yMouseAbs);
    3982 
    3983     SSMR3GetBool(pSSM, &pThis->fNewGuestFilterMaskValid);
    3984     SSMR3GetU32(pSSM, &pThis->fNewGuestFilterMask);
    3985     SSMR3GetU32(pSSM, &pThis->fGuestFilterMask);
    3986     SSMR3GetU32(pSSM, &pThis->fHostEventFlags);
    3987 
    3988     //SSMR3GetBool(pSSM, &pThis->pVMMDevRAMR3->fHaveEvents);
     4026    pHlp->pfnSSMGetU32(pSSM, &uIgn);
     4027    pHlp->pfnSSMGetU32(pSSM, &pThis->fMouseCapabilities);
     4028    pHlp->pfnSSMGetS32(pSSM, &pThis->xMouseAbs);
     4029    pHlp->pfnSSMGetS32(pSSM, &pThis->yMouseAbs);
     4030
     4031    pHlp->pfnSSMGetBool(pSSM, &pThis->fNewGuestFilterMaskValid);
     4032    pHlp->pfnSSMGetU32(pSSM, &pThis->fNewGuestFilterMask);
     4033    pHlp->pfnSSMGetU32(pSSM, &pThis->fGuestFilterMask);
     4034    pHlp->pfnSSMGetU32(pSSM, &pThis->fHostEventFlags);
     4035
     4036    //pHlp->pfnSSMGetBool(pSSM, &pThis->pVMMDevRAMR3->fHaveEvents);
    39894037    // here be dragons (probably)
    3990     SSMR3GetMem(pSSM, &pThis->pVMMDevRAMR3->V, sizeof (pThis->pVMMDevRAMR3->V));
    3991 
    3992     SSMR3GetMem(pSSM, &pThis->guestInfo, sizeof (pThis->guestInfo));
    3993     SSMR3GetU32(pSSM, &pThis->fu32AdditionsOk);
    3994     SSMR3GetU32(pSSM, &pThis->u32VideoAccelEnabled);
     4038    pHlp->pfnSSMGetMem(pSSM, &pThisCC->pVMMDevRAMR3->V, sizeof(pThisCC->pVMMDevRAMR3->V));
     4039
     4040    pHlp->pfnSSMGetMem(pSSM, &pThis->guestInfo, sizeof(pThis->guestInfo));
     4041    pHlp->pfnSSMGetU32(pSSM, &pThis->fu32AdditionsOk);
     4042    pHlp->pfnSSMGetU32(pSSM, &pThis->u32VideoAccelEnabled);
    39954043    if (uVersion > 10)
    3996         SSMR3GetBool(pSSM, &pThis->displayChangeData.fGuestSentChangeEventAck);
    3997 
    3998     rc = SSMR3GetU32(pSSM, &pThis->fGuestCaps);
     4044        pHlp->pfnSSMGetBool(pSSM, &pThis->displayChangeData.fGuestSentChangeEventAck);
     4045
     4046    rc = pHlp->pfnSSMGetU32(pSSM, &pThis->fGuestCaps);
    39994047
    40004048    /* Attributes which were temporarily introduced in r30072 */
     
    40024050    {
    40034051        uint32_t temp;
    4004         SSMR3GetU32(pSSM, &temp);
    4005         rc = SSMR3GetU32(pSSM, &temp);
     4052        pHlp->pfnSSMGetU32(pSSM, &temp);
     4053        rc = pHlp->pfnSSMGetU32(pSSM, &temp);
    40064054    }
    40074055    AssertRCReturn(rc, rc);
    40084056
    40094057#ifdef VBOX_WITH_HGCM
    4010     rc = vmmdevHGCMLoadState(pThis, pSSM, uVersion);
     4058    rc = vmmdevR3HgcmLoadState(pDevIns, pThis, pThisCC, pSSM, uVersion);
    40114059    AssertRCReturn(rc, rc);
    40124060#endif /* VBOX_WITH_HGCM */
    40134061
    40144062    if (uVersion >= 10)
    4015         rc = SSMR3GetU32(pSSM, &pThis->fHostCursorRequested);
     4063        rc = pHlp->pfnSSMGetU32(pSSM, &pThis->fHostCursorRequested);
    40164064    AssertRCReturn(rc, rc);
    40174065
    40184066    if (uVersion > VMMDEV_SAVED_STATE_VERSION_MISSING_GUEST_INFO_2)
    40194067    {
    4020         SSMR3GetU32(pSSM, &pThis->guestInfo2.uFullVersion);
    4021         SSMR3GetU32(pSSM, &pThis->guestInfo2.uRevision);
    4022         SSMR3GetU32(pSSM, &pThis->guestInfo2.fFeatures);
    4023         rc = SSMR3GetStrZ(pSSM, &pThis->guestInfo2.szName[0], sizeof(pThis->guestInfo2.szName));
     4068        pHlp->pfnSSMGetU32(pSSM, &pThis->guestInfo2.uFullVersion);
     4069        pHlp->pfnSSMGetU32(pSSM, &pThis->guestInfo2.uRevision);
     4070        pHlp->pfnSSMGetU32(pSSM, &pThis->guestInfo2.fFeatures);
     4071        rc = pHlp->pfnSSMGetStrZ(pSSM, &pThis->guestInfo2.szName[0], sizeof(pThis->guestInfo2.szName));
    40244072        AssertRCReturn(rc, rc);
    40254073    }
     
    40284076    {
    40294077        uint32_t cFacilityStatuses;
    4030         rc = SSMR3GetU32(pSSM, &cFacilityStatuses);
     4078        rc = pHlp->pfnSSMGetU32(pSSM, &cFacilityStatuses);
    40314079        AssertRCReturn(rc, rc);
    40324080
     
    40374085            int64_t  iTimeStampNano;
    40384086
    4039             SSMR3GetU32(pSSM, &uFacility);
    4040             SSMR3GetU32(pSSM, &fFlags);
    4041             SSMR3GetU16(pSSM, &uStatus);
    4042             rc = SSMR3GetS64(pSSM, &iTimeStampNano);
     4087            pHlp->pfnSSMGetU32(pSSM, &uFacility);
     4088            pHlp->pfnSSMGetU32(pSSM, &fFlags);
     4089            pHlp->pfnSSMGetU16(pSSM, &uStatus);
     4090            rc = pHlp->pfnSSMGetS64(pSSM, &iTimeStampNano);
    40434091            AssertRCReturn(rc, rc);
    40444092
     
    40584106    if (uVersion >= VMMDEV_SAVED_STATE_VERSION_HEARTBEAT)
    40594107    {
    4060         SSMR3GetBool(pSSM, (bool *)&pThis->fHeartbeatActive);
    4061         SSMR3GetBool(pSSM, (bool *)&pThis->fFlatlined);
    4062         SSMR3GetU64(pSSM, (uint64_t *)&pThis->nsLastHeartbeatTS);
    4063         rc = TMR3TimerLoad(pThis->pFlatlinedTimer, pSSM);
     4108        pHlp->pfnSSMGetBool(pSSM, (bool *)&pThis->fHeartbeatActive);
     4109        pHlp->pfnSSMGetBool(pSSM, (bool *)&pThis->fFlatlined);
     4110        pHlp->pfnSSMGetU64(pSSM, (uint64_t *)&pThis->nsLastHeartbeatTS);
     4111        rc = PDMDevHlpTimerLoad(pDevIns, pThis->hFlatlinedTimer, pSSM);
    40644112        AssertRCReturn(rc, rc);
    40654113        if (pThis->fFlatlined)
    40664114            LogRel(("vmmdevLoadState: Guest has flatlined. Last heartbeat %'RU64 ns before state was saved.\n",
    4067                     TMTimerGetNano(pThis->pFlatlinedTimer) - pThis->nsLastHeartbeatTS));
     4115                    PDMDevHlpTimerGetNano(pDevIns, pThis->hFlatlinedTimer) - pThis->nsLastHeartbeatTS));
    40684116    }
    40694117
     
    40734121     */
    40744122    Log(("vmmdevLoadState: capabilities changed (%x), informing connector\n", pThis->fMouseCapabilities));
    4075     if (pThis->pDrv)
    4076     {
    4077         pThis->pDrv->pfnUpdateMouseCapabilities(pThis->pDrv, pThis->fMouseCapabilities);
     4123    if (pThisCC->pDrv)
     4124    {
     4125        pThisCC->pDrv->pfnUpdateMouseCapabilities(pThisCC->pDrv, pThis->fMouseCapabilities);
    40784126        if (uVersion >= 10)
    4079             pThis->pDrv->pfnUpdatePointerShape(pThis->pDrv,
     4127            pThisCC->pDrv->pfnUpdatePointerShape(pThisCC->pDrv,
    40804128                                               /*fVisible=*/!!pThis->fHostCursorRequested,
    40814129                                               /*fAlpha=*/false,
     
    40884136    {
    40894137        vmmdevLogGuestOsInfo(&pThis->guestInfo);
    4090         if (pThis->pDrv)
     4138        if (pThisCC->pDrv)
    40914139        {
    4092             if (pThis->guestInfo2.uFullVersion && pThis->pDrv->pfnUpdateGuestInfo2)
    4093                 pThis->pDrv->pfnUpdateGuestInfo2(pThis->pDrv, pThis->guestInfo2.uFullVersion, pThis->guestInfo2.szName,
     4140            if (pThis->guestInfo2.uFullVersion && pThisCC->pDrv->pfnUpdateGuestInfo2)
     4141                pThisCC->pDrv->pfnUpdateGuestInfo2(pThisCC->pDrv, pThis->guestInfo2.uFullVersion, pThis->guestInfo2.szName,
    40944142                                                 pThis->guestInfo2.uRevision, pThis->guestInfo2.fFeatures);
    4095             if (pThis->pDrv->pfnUpdateGuestInfo)
    4096                 pThis->pDrv->pfnUpdateGuestInfo(pThis->pDrv, &pThis->guestInfo);
    4097 
    4098             if (pThis->pDrv->pfnUpdateGuestStatus)
     4143            if (pThisCC->pDrv->pfnUpdateGuestInfo)
     4144                pThisCC->pDrv->pfnUpdateGuestInfo(pThisCC->pDrv, &pThis->guestInfo);
     4145
     4146            if (pThisCC->pDrv->pfnUpdateGuestStatus)
    40994147            {
    41004148                for (uint32_t i = 0; i < pThis->cFacilityStatuses; i++) /* ascending order! */
    41014149                    if (   pThis->aFacilityStatuses[i].enmStatus != VBoxGuestFacilityStatus_Inactive
    41024150                        || !pThis->aFacilityStatuses[i].fFixed)
    4103                         pThis->pDrv->pfnUpdateGuestStatus(pThis->pDrv,
     4151                        pThisCC->pDrv->pfnUpdateGuestStatus(pThisCC->pDrv,
    41044152                                                          pThis->aFacilityStatuses[i].enmFacility,
    41054153                                                          (uint16_t)pThis->aFacilityStatuses[i].enmStatus,
     
    41094157        }
    41104158    }
    4111     if (pThis->pDrv && pThis->pDrv->pfnUpdateGuestCapabilities)
    4112         pThis->pDrv->pfnUpdateGuestCapabilities(pThis->pDrv, pThis->fGuestCaps);
     4159    if (pThisCC->pDrv && pThisCC->pDrv->pfnUpdateGuestCapabilities)
     4160        pThisCC->pDrv->pfnUpdateGuestCapabilities(pThisCC->pDrv, pThis->fGuestCaps);
    41134161
    41144162    return VINF_SUCCESS;
     
    41244172static DECLCALLBACK(int) vmmdevLoadStateDone(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
    41254173{
    4126     RT_NOREF1(pSSM);
    4127     PVMMDEV pThis = PDMINS_2_DATA(pDevIns, PVMMDEV);
     4174    PVMMDEV   pThis = PDMDEVINS_2_DATA(pDevIns, PVMMDEV);
     4175    PVMMDEVCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVMMDEVCC);
     4176    RT_NOREF(pSSM);
    41284177
    41294178#ifdef VBOX_WITH_HGCM
    4130     int rc = vmmdevHGCMLoadStateDone(pThis);
     4179    int rc = vmmdevR3HgcmLoadStateDone(pDevIns, pThis, pThisCC);
    41314180    AssertLogRelRCReturn(rc, rc);
    41324181#endif /* VBOX_WITH_HGCM */
     
    41344183    /* Reestablish the acceleration status. */
    41354184    if (    pThis->u32VideoAccelEnabled
    4136         &&  pThis->pDrv)
    4137     {
    4138         pThis->pDrv->pfnVideoAccelEnable(pThis->pDrv, !!pThis->u32VideoAccelEnabled, &pThis->pVMMDevRAMR3->vbvaMemory);
    4139     }
    4140 
    4141     VMMDevNotifyGuest(pThis, VMMDEV_EVENT_RESTORED);
     4185        &&  pThisCC->pDrv)
     4186        pThisCC->pDrv->pfnVideoAccelEnable(pThisCC->pDrv, !!pThis->u32VideoAccelEnabled, &pThisCC->pVMMDevRAMR3->vbvaMemory);
     4187
     4188    VMMDevNotifyGuest(pDevIns, pThis, pThisCC, VMMDEV_EVENT_RESTORED);
    41424189
    41434190    return VINF_SUCCESS;
     
    41504197 * (Re-)initializes the MMIO2 data.
    41514198 *
    4152  * @param   pThis           Pointer to the VMMDev instance data.
    4153  */
    4154 static void vmmdevInitRam(PVMMDEV pThis)
    4155 {
    4156     memset(pThis->pVMMDevRAMR3, 0, sizeof(VMMDevMemory));
    4157     pThis->pVMMDevRAMR3->u32Size = sizeof(VMMDevMemory);
    4158     pThis->pVMMDevRAMR3->u32Version = VMMDEV_MEMORY_VERSION;
     4199 * @param   pThisCC         The VMMDev ring-3 instance data.
     4200 */
     4201static void vmmdevInitRam(PVMMDEVCC pThisCC)
     4202{
     4203    memset(pThisCC->pVMMDevRAMR3, 0, sizeof(VMMDevMemory));
     4204    pThisCC->pVMMDevRAMR3->u32Size    = sizeof(VMMDevMemory);
     4205    pThisCC->pVMMDevRAMR3->u32Version = VMMDEV_MEMORY_VERSION;
    41594206}
    41604207
     
    41654212static DECLCALLBACK(void) vmmdevReset(PPDMDEVINS pDevIns)
    41664213{
    4167     PVMMDEV pThis = PDMINS_2_DATA(pDevIns, PVMMDEV);
    4168     PDMCritSectEnter(&pThis->CritSect, VERR_IGNORED);
     4214    PVMMDEV   pThis   = PDMDEVINS_2_DATA(pDevIns, PVMMDEV);
     4215    PVMMDEVCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVMMDEVCC);
     4216    PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED);
    41694217
    41704218    /*
     
    41764224        /* notify the connector */
    41774225        Log(("vmmdevReset: capabilities changed (%x), informing connector\n", pThis->fMouseCapabilities));
    4178         pThis->pDrv->pfnUpdateMouseCapabilities(pThis->pDrv, pThis->fMouseCapabilities);
     4226        pThisCC->pDrv->pfnUpdateMouseCapabilities(pThisCC->pDrv, pThis->fMouseCapabilities);
    41794227    }
    41804228    pThis->fHostCursorRequested = false;
    41814229
    41824230    /* re-initialize the VMMDev memory */
    4183     if (pThis->pVMMDevRAMR3)
    4184         vmmdevInitRam(pThis);
     4231    if (pThisCC->pVMMDevRAMR3)
     4232        vmmdevInitRam(pThisCC);
    41854233
    41864234    /* credentials have to go away (by default) */
    4187     if (!pThis->fKeepCredentials)
    4188     {
    4189         memset(pThis->pCredentials->Logon.szUserName, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
    4190         memset(pThis->pCredentials->Logon.szPassword, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
    4191         memset(pThis->pCredentials->Logon.szDomain, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
    4192     }
    4193     memset(pThis->pCredentials->Judge.szUserName, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
    4194     memset(pThis->pCredentials->Judge.szPassword, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
    4195     memset(pThis->pCredentials->Judge.szDomain, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
     4235    VMMDEVCREDS *pCredentials = pThisCC->pCredentials;
     4236    if (pCredentials)
     4237    {
     4238        if (!pThis->fKeepCredentials)
     4239        {
     4240            RT_ZERO(pCredentials->Logon.szUserName);
     4241            RT_ZERO(pCredentials->Logon.szPassword);
     4242            RT_ZERO(pCredentials->Logon.szDomain);
     4243        }
     4244        RT_ZERO(pCredentials->Judge.szUserName);
     4245        RT_ZERO(pCredentials->Judge.szPassword);
     4246        RT_ZERO(pCredentials->Judge.szDomain);
     4247    }
    41964248
    41974249    /* Reset means that additions will report again. */
     
    42394291#ifdef VBOX_WITH_HGCM
    42404292    /* Clear the "HGCM event enabled" flag so the event can be automatically reenabled.  */
    4241     pThis->u32HGCMEnabled = 0;
     4293    pThisCC->u32HGCMEnabled = 0;
    42424294#endif
    42434295
     
    42474299    if (pThis->fHeartbeatActive)
    42484300    {
    4249         TMTimerStop(pThis->pFlatlinedTimer);
     4301        PDMDevHlpTimerStop(pDevIns, pThis->hFlatlinedTimer);
    42504302        pThis->fFlatlined       = false;
    42514303        pThis->fHeartbeatActive = true;
     
    42684320     * Call the update functions as required.
    42694321     */
    4270     if (fVersionChanged && pThis->pDrv && pThis->pDrv->pfnUpdateGuestInfo)
    4271         pThis->pDrv->pfnUpdateGuestInfo(pThis->pDrv, &pThis->guestInfo);
    4272     if (fCapsChanged && pThis->pDrv && pThis->pDrv->pfnUpdateGuestCapabilities)
    4273         pThis->pDrv->pfnUpdateGuestCapabilities(pThis->pDrv, pThis->fGuestCaps);
     4322    if (fVersionChanged && pThisCC->pDrv && pThisCC->pDrv->pfnUpdateGuestInfo)
     4323        pThisCC->pDrv->pfnUpdateGuestInfo(pThisCC->pDrv, &pThis->guestInfo);
     4324    if (fCapsChanged && pThisCC->pDrv && pThisCC->pDrv->pfnUpdateGuestCapabilities)
     4325        pThisCC->pDrv->pfnUpdateGuestCapabilities(pThisCC->pDrv, pThis->fGuestCaps);
    42744326
    42754327    /*
     
    42794331    pThis->idSession = ASMReadTSC();
    42804332
    4281     PDMCritSectLeave(&pThis->CritSect);
     4333    PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect);
    42824334}
    42834335
     
    42914343    if (offDelta)
    42924344    {
    4293         PVMMDEV pThis = PDMINS_2_DATA(pDevIns, PVMMDEV);
     4345        PVMMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PVMMDEV);
    42944346        LogFlow(("vmmdevRelocate: offDelta=%RGv\n", offDelta));
    42954347
     
    43074359static DECLCALLBACK(int) vmmdevDestruct(PPDMDEVINS pDevIns)
    43084360{
    4309     PVMMDEV pThis = PDMINS_2_DATA(pDevIns, PVMMDEV);
    43104361    PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);
     4362    PVMMDEVCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVMMDEVCC);
    43114363
    43124364    /*
    43134365     * Wipe and free the credentials.
    43144366     */
    4315     if (pThis->pCredentials)
    4316     {
    4317         RTMemWipeThoroughly(pThis->pCredentials, sizeof(*pThis->pCredentials), 10);
    4318         RTMemFree(pThis->pCredentials);
    4319         pThis->pCredentials = NULL;
     4367    VMMDEVCREDS *pCredentials = pThisCC->pCredentials;
     4368    pThisCC->pCredentials = NULL;
     4369    if (pCredentials)
     4370    {
     4371        if (pThisCC->fSaferCredentials)
     4372            RTMemSaferFree(pCredentials, sizeof(*pCredentials));
     4373        else
     4374        {
     4375            RTMemWipeThoroughly(pCredentials, sizeof(*pCredentials), 10);
     4376            RTMemFree(pCredentials);
     4377        }
    43204378    }
    43214379
     
    43244382     * Everything HGCM.
    43254383     */
    4326     vmmdevHGCMDestroy(pThis);
     4384    vmmdevR3HgcmDestroy(pDevIns, pThisCC);
    43274385#endif
    43284386
     
    43304388     * Free the request buffers.
    43314389     */
    4332     for (uint32_t iCpu = 0; iCpu < RT_ELEMENTS(pThis->apReqBufs); iCpu++)
    4333     {
    4334         pThis->apReqBufs[iCpu] = NULL;
    4335         RTMemPageFree(pThis->apReqBufs[iCpu], _4K);
     4390    for (uint32_t iCpu = 0; iCpu < RT_ELEMENTS(pThisCC->apReqBufs); iCpu++)
     4391    {
     4392        RTMemPageFree(pThisCC->apReqBufs[iCpu], _4K);
     4393        pThisCC->apReqBufs[iCpu] = NULL;
    43364394    }
    43374395
     
    43524410static DECLCALLBACK(int) vmmdevConstruct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg)
    43534411{
    4354     PVMMDEV pThis = PDMINS_2_DATA(pDevIns, PVMMDEV);
    4355     int rc;
     4412    PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);
     4413    PVMMDEVCC       pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVMMDEVCC);
     4414    PVMMDEV         pThis   = PDMDEVINS_2_DATA(pDevIns, PVMMDEV);
     4415    PCPDMDEVHLPR3   pHlp    = pDevIns->pHlpR3;
     4416    int             rc;
    43564417
    43574418    Assert(iInstance == 0);
    4358     PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);
     4419    RT_NOREF(iInstance);
    43594420
    43604421    /*
    43614422     * Initialize data (most of it anyway).
    43624423     */
    4363     /* Save PDM device instance data for future reference. */
    4364     pThis->pDevInsR3 = pDevIns;
    4365     pThis->pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns);
    4366 #ifdef VBOX_WITH_RAW_MODE_KEEP
    4367     pThis->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);
     4424    pThisCC->pDevIns = pDevIns;
     4425
     4426    pThis->hFlatlinedTimer      = NIL_TMTIMERHANDLE;
     4427    pThis->hIoPortBackdoorLog   = NIL_IOMIOPORTHANDLE;
     4428    pThis->hIoPortAltTimesync   = NIL_IOMIOPORTHANDLE;
     4429    pThis->hIoPortReq           = NIL_IOMIOPORTHANDLE;
     4430    pThis->hIoPortFast          = NIL_IOMIOPORTHANDLE;
     4431    pThis->hMmio2VMMDevRAM      = NIL_PGMMMIO2HANDLE;
     4432    pThis->hMmio2Heap           = NIL_PGMMMIO2HANDLE;
     4433#ifndef VBOX_WITHOUT_TESTING_FEATURES
     4434    pThis->hIoPortTesting       = NIL_IOMIOPORTHANDLE;
     4435    pThis->hMmioTesting         = NIL_IOMMMIOHANDLE;
    43684436#endif
    43694437
     
    43974465     */
    43984466    /* IBase */
    4399     pThis->IBase.pfnQueryInterface          = vmmdevPortQueryInterface;
     4467    pThisCC->IBase.pfnQueryInterface          = vmmdevPortQueryInterface;
    44004468
    44014469    /* VMMDev port */
    4402     pThis->IPort.pfnQueryAbsoluteMouse      = vmmdevIPort_QueryAbsoluteMouse;
    4403     pThis->IPort.pfnSetAbsoluteMouse        = vmmdevIPort_SetAbsoluteMouse ;
    4404     pThis->IPort.pfnQueryMouseCapabilities  = vmmdevIPort_QueryMouseCapabilities;
    4405     pThis->IPort.pfnUpdateMouseCapabilities = vmmdevIPort_UpdateMouseCapabilities;
    4406     pThis->IPort.pfnRequestDisplayChange    = vmmdevIPort_RequestDisplayChange;
    4407     pThis->IPort.pfnSetCredentials          = vmmdevIPort_SetCredentials;
    4408     pThis->IPort.pfnVBVAChange              = vmmdevIPort_VBVAChange;
    4409     pThis->IPort.pfnRequestSeamlessChange   = vmmdevIPort_RequestSeamlessChange;
    4410     pThis->IPort.pfnSetMemoryBalloon        = vmmdevIPort_SetMemoryBalloon;
    4411     pThis->IPort.pfnSetStatisticsInterval   = vmmdevIPort_SetStatisticsInterval;
    4412     pThis->IPort.pfnVRDPChange              = vmmdevIPort_VRDPChange;
    4413     pThis->IPort.pfnCpuHotUnplug            = vmmdevIPort_CpuHotUnplug;
    4414     pThis->IPort.pfnCpuHotPlug              = vmmdevIPort_CpuHotPlug;
     4470    pThisCC->IPort.pfnQueryAbsoluteMouse      = vmmdevIPort_QueryAbsoluteMouse;
     4471    pThisCC->IPort.pfnSetAbsoluteMouse        = vmmdevIPort_SetAbsoluteMouse ;
     4472    pThisCC->IPort.pfnQueryMouseCapabilities  = vmmdevIPort_QueryMouseCapabilities;
     4473    pThisCC->IPort.pfnUpdateMouseCapabilities = vmmdevIPort_UpdateMouseCapabilities;
     4474    pThisCC->IPort.pfnRequestDisplayChange    = vmmdevIPort_RequestDisplayChange;
     4475    pThisCC->IPort.pfnSetCredentials          = vmmdevIPort_SetCredentials;
     4476    pThisCC->IPort.pfnVBVAChange              = vmmdevIPort_VBVAChange;
     4477    pThisCC->IPort.pfnRequestSeamlessChange   = vmmdevIPort_RequestSeamlessChange;
     4478    pThisCC->IPort.pfnSetMemoryBalloon        = vmmdevIPort_SetMemoryBalloon;
     4479    pThisCC->IPort.pfnSetStatisticsInterval   = vmmdevIPort_SetStatisticsInterval;
     4480    pThisCC->IPort.pfnVRDPChange              = vmmdevIPort_VRDPChange;
     4481    pThisCC->IPort.pfnCpuHotUnplug            = vmmdevIPort_CpuHotUnplug;
     4482    pThisCC->IPort.pfnCpuHotPlug              = vmmdevIPort_CpuHotPlug;
    44154483
    44164484    /* Shared folder LED */
    4417     pThis->SharedFolders.Led.u32Magic       = PDMLED_MAGIC;
    4418     pThis->SharedFolders.ILeds.pfnQueryStatusLed = vmmdevQueryStatusLed;
     4485    pThisCC->SharedFolders.Led.u32Magic       = PDMLED_MAGIC;
     4486    pThisCC->SharedFolders.ILeds.pfnQueryStatusLed = vmmdevQueryStatusLed;
    44194487
    44204488#ifdef VBOX_WITH_HGCM
    44214489    /* HGCM port */
    4422     pThis->IHGCMPort.pfnCompleted           = hgcmCompleted;
    4423     pThis->IHGCMPort.pfnIsCmdRestored       = hgcmIsCmdRestored;
    4424     pThis->IHGCMPort.pfnIsCmdCancelled      = hgcmIsCmdCancelled;
    4425     pThis->IHGCMPort.pfnGetRequestor        = hgcmGetRequestor;
    4426     pThis->IHGCMPort.pfnGetVMMDevSessionId  = hgcmGetVMMDevSessionId;
     4490    pThisCC->IHGCMPort.pfnCompleted           = hgcmR3Completed;
     4491    pThisCC->IHGCMPort.pfnIsCmdRestored       = hgcmR3IsCmdRestored;
     4492    pThisCC->IHGCMPort.pfnIsCmdCancelled      = hgcmR3IsCmdCancelled;
     4493    pThisCC->IHGCMPort.pfnGetRequestor        = hgcmR3GetRequestor;
     4494    pThisCC->IHGCMPort.pfnGetVMMDevSessionId  = hgcmR3GetVMMDevSessionId;
    44274495#endif
    44284496
    4429     pThis->pCredentials = (VMMDEVCREDS *)RTMemAllocZ(sizeof(*pThis->pCredentials));
    4430     if (!pThis->pCredentials)
    4431         return VERR_NO_MEMORY;
     4497    pThisCC->pCredentials = (VMMDEVCREDS *)RTMemSaferAllocZ(sizeof(*pThisCC->pCredentials));
     4498    if (pThisCC->pCredentials)
     4499        pThisCC->fSaferCredentials = true;
     4500    else
     4501    {
     4502        pThisCC->pCredentials = (VMMDEVCREDS *)RTMemAllocZ(sizeof(*pThisCC->pCredentials));
     4503        AssertReturn(pThisCC->pCredentials, VERR_NO_MEMORY);
     4504    }
    44324505
    44334506
     
    44364509     */
    44374510    PDMDEV_VALIDATE_CONFIG_RETURN(pDevIns,
     4511                                  "AllowGuestToSaveState|"
    44384512                                  "GetHostTimeDisabled|"
    44394513                                  "BackdoorLogDisabled|"
    44404514                                  "KeepCredentials|"
    44414515                                  "HeapEnabled|"
    4442                                   "RZEnabled|"
    44434516                                  "GuestCoreDumpEnabled|"
    44444517                                  "GuestCoreDumpDir|"
     
    44524525                                  "");
    44534526
    4454     rc = CFGMR3QueryBoolDef(pCfg, "GetHostTimeDisabled", &pThis->fGetHostTimeDisabled, false);
     4527    rc = pHlp->pfnCFGMQueryBoolDef(pCfg, "AllowGuestToSaveState", &pThis->fAllowGuestToSaveState, true);
     4528    if (RT_FAILURE(rc))
     4529        return PDMDEV_SET_ERROR(pDevIns, rc,
     4530                                N_("Configuration error: Failed querying \"AllowGuestToSaveState\" as a boolean"));
     4531
     4532    rc = pHlp->pfnCFGMQueryBoolDef(pCfg, "GetHostTimeDisabled", &pThis->fGetHostTimeDisabled, false);
    44554533    if (RT_FAILURE(rc))
    44564534        return PDMDEV_SET_ERROR(pDevIns, rc,
    44574535                                N_("Configuration error: Failed querying \"GetHostTimeDisabled\" as a boolean"));
    44584536
    4459     rc = CFGMR3QueryBoolDef(pCfg, "BackdoorLogDisabled", &pThis->fBackdoorLogDisabled, false);
     4537    rc = pHlp->pfnCFGMQueryBoolDef(pCfg, "BackdoorLogDisabled", &pThis->fBackdoorLogDisabled, false);
    44604538    if (RT_FAILURE(rc))
    44614539        return PDMDEV_SET_ERROR(pDevIns, rc,
    44624540                                N_("Configuration error: Failed querying \"BackdoorLogDisabled\" as a boolean"));
    44634541
    4464     rc = CFGMR3QueryBoolDef(pCfg, "KeepCredentials", &pThis->fKeepCredentials, false);
     4542    rc = pHlp->pfnCFGMQueryBoolDef(pCfg, "KeepCredentials", &pThis->fKeepCredentials, false);
    44654543    if (RT_FAILURE(rc))
    44664544        return PDMDEV_SET_ERROR(pDevIns, rc,
    44674545                                N_("Configuration error: Failed querying \"KeepCredentials\" as a boolean"));
    44684546
    4469     rc = CFGMR3QueryBoolDef(pCfg, "HeapEnabled", &pThis->fHeapEnabled, true);
     4547    rc = pHlp->pfnCFGMQueryBoolDef(pCfg, "HeapEnabled", &pThis->fHeapEnabled, true);
    44704548    if (RT_FAILURE(rc))
    44714549        return PDMDEV_SET_ERROR(pDevIns, rc,
    44724550                                N_("Configuration error: Failed querying \"HeapEnabled\" as a boolean"));
    44734551
    4474     rc = CFGMR3QueryBoolDef(pCfg, "RZEnabled", &pThis->fRZEnabled, true);
     4552    rc = pHlp->pfnCFGMQueryBoolDef(pCfg, "GuestCoreDumpEnabled", &pThis->fGuestCoreDumpEnabled, false);
    44754553    if (RT_FAILURE(rc))
    4476         return PDMDEV_SET_ERROR(pDevIns, rc,
    4477                                 N_("Configuration error: Failed querying \"RZEnabled\" as a boolean"));
    4478 
    4479     rc = CFGMR3QueryBoolDef(pCfg, "GuestCoreDumpEnabled", &pThis->fGuestCoreDumpEnabled, false);
     4554        return PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Failed querying \"GuestCoreDumpEnabled\" as a boolean"));
     4555
     4556    char *pszGuestCoreDumpDir = NULL;
     4557    rc = pHlp->pfnCFGMQueryStringAllocDef(pCfg, "GuestCoreDumpDir", &pszGuestCoreDumpDir, "");
    44804558    if (RT_FAILURE(rc))
    4481         return PDMDEV_SET_ERROR(pDevIns, rc,
    4482                                 N_("Configuration error: Failed querying \"GuestCoreDumpEnabled\" as a boolean"));
    4483 
    4484     char *pszGuestCoreDumpDir = NULL;
    4485     rc = CFGMR3QueryStringAllocDef(pCfg, "GuestCoreDumpDir", &pszGuestCoreDumpDir, "");
    4486     if (RT_FAILURE(rc))
    4487         return PDMDEV_SET_ERROR(pDevIns, rc,
    4488                                 N_("Configuration error: Failed querying \"GuestCoreDumpDir\" as a string"));
     4559        return PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Failed querying \"GuestCoreDumpDir\" as a string"));
    44894560
    44904561    RTStrCopy(pThis->szGuestCoreDumpDir, sizeof(pThis->szGuestCoreDumpDir), pszGuestCoreDumpDir);
    44914562    MMR3HeapFree(pszGuestCoreDumpDir);
    44924563
    4493     rc = CFGMR3QueryU32Def(pCfg, "GuestCoreDumpCount", &pThis->cGuestCoreDumps, 3);
     4564    rc = pHlp->pfnCFGMQueryU32Def(pCfg, "GuestCoreDumpCount", &pThis->cGuestCoreDumps, 3);
    44944565    if (RT_FAILURE(rc))
    44954566        return PDMDEV_SET_ERROR(pDevIns, rc,
    44964567                                N_("Configuration error: Failed querying \"GuestCoreDumpCount\" as a 32-bit unsigned integer"));
    44974568
    4498     rc = CFGMR3QueryU64Def(pCfg, "HeartbeatInterval", &pThis->cNsHeartbeatInterval, VMMDEV_HEARTBEAT_DEFAULT_INTERVAL);
     4569    rc = pHlp->pfnCFGMQueryU64Def(pCfg, "HeartbeatInterval", &pThis->cNsHeartbeatInterval, VMMDEV_HEARTBEAT_DEFAULT_INTERVAL);
    44994570    if (RT_FAILURE(rc))
    45004571        return PDMDEV_SET_ERROR(pDevIns, rc,
     
    45044575                                N_("Configuration error: Heartbeat interval \"HeartbeatInterval\" too small"));
    45054576
    4506     rc = CFGMR3QueryU64Def(pCfg, "HeartbeatTimeout", &pThis->cNsHeartbeatTimeout, pThis->cNsHeartbeatInterval * 2);
     4577    rc = pHlp->pfnCFGMQueryU64Def(pCfg, "HeartbeatTimeout", &pThis->cNsHeartbeatTimeout, pThis->cNsHeartbeatInterval * 2);
    45074578    if (RT_FAILURE(rc))
    45084579        return PDMDEV_SET_ERROR(pDevIns, rc,
    45094580                                N_("Configuration error: Failed querying \"HeartbeatTimeout\" as a 64-bit unsigned integer"));
    45104581    if (pThis->cNsHeartbeatTimeout < RT_NS_100MS)
    4511         return PDMDEV_SET_ERROR(pDevIns, rc,
    4512                                 N_("Configuration error: Heartbeat timeout \"HeartbeatTimeout\" too small"));
     4582        return PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Heartbeat timeout \"HeartbeatTimeout\" too small"));
    45134583    if (pThis->cNsHeartbeatTimeout <= pThis->cNsHeartbeatInterval + RT_NS_10MS)
    45144584        return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS,
     
    45174587
    45184588#ifndef VBOX_WITHOUT_TESTING_FEATURES
    4519     rc = CFGMR3QueryBoolDef(pCfg, "TestingEnabled", &pThis->fTestingEnabled, false);
     4589    rc = pHlp->pfnCFGMQueryBoolDef(pCfg, "TestingEnabled", &pThis->fTestingEnabled, false);
    45204590    if (RT_FAILURE(rc))
    4521         return PDMDEV_SET_ERROR(pDevIns, rc,
    4522                                 N_("Configuration error: Failed querying \"TestingEnabled\" as a boolean"));
    4523     rc = CFGMR3QueryBoolDef(pCfg, "TestingMMIO", &pThis->fTestingMMIO, false);
     4591        return PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Failed querying \"TestingEnabled\" as a boolean"));
     4592    rc = pHlp->pfnCFGMQueryBoolDef(pCfg, "TestingMMIO", &pThis->fTestingMMIO, false);
    45244593    if (RT_FAILURE(rc))
    4525         return PDMDEV_SET_ERROR(pDevIns, rc,
    4526                                 N_("Configuration error: Failed querying \"TestingMMIO\" as a boolean"));
    4527     rc = CFGMR3QueryStringAllocDef(pCfg, "TestintXmlOutputFile", &pThis->pszTestingXmlOutput, NULL);
     4594        return PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Failed querying \"TestingMMIO\" as a boolean"));
     4595    rc = pHlp->pfnCFGMQueryStringAllocDef(pCfg, "TestintXmlOutputFile", &pThisCC->pszTestingXmlOutput, NULL);
    45284596    if (RT_FAILURE(rc))
    45294597        return PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Failed querying \"TestintXmlOutputFile\" as a string"));
     
    45464614     * Register the backdoor logging port
    45474615     */
    4548     rc = PDMDevHlpIOPortRegister(pDevIns, RTLOG_DEBUG_PORT, 1, NULL, vmmdevBackdoorLog,
    4549                                  NULL, NULL, NULL, "VMMDev backdoor logging");
     4616    rc = PDMDevHlpIoPortCreateAndMap(pDevIns, RTLOG_DEBUG_PORT, 1, vmmdevBackdoorLog, NULL /*pfnIn*/,
     4617                                     "VMMDev backdoor logging", NULL, &pThis->hIoPortBackdoorLog);
    45504618    AssertRCReturn(rc, rc);
    45514619
     
    45584626     * first.  We keep it in case it comes in handy.
    45594627     */
    4560     rc = PDMDevHlpIOPortRegister(pDevIns, 0x505, 1, NULL,
    4561                                  vmmdevAltTimeSyncWrite, vmmdevAltTimeSyncRead,
    4562                                  NULL, NULL, "VMMDev timesync backdoor");
     4628    rc = PDMDevHlpIoPortCreateAndMap(pDevIns, 0x505, 1, vmmdevAltTimeSyncWrite, vmmdevAltTimeSyncRead,
     4629                                     "VMMDev timesync backdoor", NULL /*paExtDescs*/, &pThis->hIoPortAltTimesync);
    45634630    AssertRCReturn(rc, rc);
    45644631#endif
     
    45724639    if (pPciDev->uDevFn != 32 || iInstance != 0)
    45734640        Log(("!!WARNING!!: pThis->PciDev.uDevFn=%d (ignore if testcase or no started by Main)\n", pPciDev->uDevFn));
    4574     rc = PDMDevHlpPCIIORegionRegister(pDevIns, 0, 0x20, PCI_ADDRESS_SPACE_IO, vmmdevIOPortRegionMap);
    4575     if (RT_FAILURE(rc))
    4576         return rc;
    4577     rc = PDMDevHlpPCIIORegionRegister(pDevIns, 1, VMMDEV_RAM_SIZE, PCI_ADDRESS_SPACE_MEM, vmmdevIORAMRegionMap);
    4578     if (RT_FAILURE(rc))
    4579         return rc;
    4580     if (pThis->fHeapEnabled)
    4581     {
    4582         rc = PDMDevHlpPCIIORegionRegister(pDevIns, 2, VMMDEV_HEAP_SIZE, PCI_ADDRESS_SPACE_MEM_PREFETCH, vmmdevIORAMRegionMap);
    4583         if (RT_FAILURE(rc))
    4584             return rc;
    4585     }
    45864641
    45874642    /*
    4588      * Allocate and initialize the MMIO2 memory.
    4589      *
    4590      * We map the first page into raw-mode and kernel contexts so we can handle
    4591      * interrupt acknowledge requests more timely.
    4592      */
    4593     rc = PDMDevHlpMMIO2Register(pDevIns, pPciDev, 1 /*iRegion*/, VMMDEV_RAM_SIZE, 0 /*fFlags*/,
    4594                                 (void **)&pThis->pVMMDevRAMR3, "VMMDev");
     4643     * The I/O ports, PCI region #0.  This has two separate I/O port mappings in it,
     4644     * so we have to do it via the mapper callback.
     4645     */
     4646    rc = PDMDevHlpIoPortCreate(pDevIns, 1 /*cPorts*/, pPciDev, RT_MAKE_U32(0, 0), vmmdevRequestHandler, NULL /*pfnIn*/,
     4647                               NULL /*pvUser*/, "VMMDev Request Handler",  NULL, &pThis->hIoPortReq);
     4648    AssertRCReturn(rc, rc);
     4649
     4650    rc = PDMDevHlpIoPortCreate(pDevIns, 1 /*cPorts*/, pPciDev, RT_MAKE_U32(1, 0),  vmmdevFastRequestHandler,
     4651                               vmmdevFastRequestIrqAck, NULL, "VMMDev Fast R0/RC Requests", NULL /*pvUser*/, &pThis->hIoPortFast);
     4652    AssertRCReturn(rc, rc);
     4653
     4654    rc = PDMDevHlpPCIIORegionRegisterIoCustom(pDevIns, 0, 0x20, vmmdevIOPortRegionMap);
     4655    AssertRCReturn(rc, rc);
     4656
     4657    /*
     4658     * Allocate and initialize the MMIO2 memory, PCI region #1.
     4659     */
     4660    rc = PDMDevHlpPCIIORegionCreateMmio2(pDevIns, 1 /*iPciRegion*/, VMMDEV_RAM_SIZE, PCI_ADDRESS_SPACE_MEM, "VMMDev",
     4661                                         (void **)&pThisCC->pVMMDevRAMR3, &pThis->hMmio2VMMDevRAM);
    45954662    if (RT_FAILURE(rc))
    45964663        return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS,
    4597                                    N_("Failed to allocate %u bytes of memory for the VMM device"), VMMDEV_RAM_SIZE);
    4598     vmmdevInitRam(pThis);
    4599     if (pThis->fRZEnabled)
    4600     {
    4601         rc = PDMDevHlpMMIO2MapKernel(pDevIns, pPciDev, 1 /*iRegion*/, 0 /*off*/, PAGE_SIZE, "VMMDev", &pThis->pVMMDevRAMR0);
     4664                                   N_("Failed to create the %u (%#x) byte MMIO2 region for the VMM device"),
     4665                                   VMMDEV_RAM_SIZE, VMMDEV_RAM_SIZE);
     4666    vmmdevInitRam(pThisCC);
     4667
     4668    /*
     4669     * The MMIO2 heap (used for real-mode VT-x trickery), PCI region #2.
     4670     */
     4671    if (pThis->fHeapEnabled)
     4672    {
     4673        rc = PDMDevHlpPCIIORegionCreateMmio2Ex(pDevIns, 2 /*iPciRegion*/, VMMDEV_HEAP_SIZE, PCI_ADDRESS_SPACE_MEM_PREFETCH,
     4674                                               0 /*fFlags*/, vmmdevMmio2HeapRegionMap, "VMMDev Heap",
     4675                                               (void **)&pThisCC->pVMMDevHeapR3, &pThis->hMmio2Heap);
    46024676        if (RT_FAILURE(rc))
    46034677            return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS,
    4604                                        N_("Failed to map first page of the VMMDev ram into kernel space: %Rrc"), rc);
    4605 
    4606 #ifdef VBOX_WITH_RAW_MODE_KEEP
    4607         rc = PDMDevHlpMMHyperMapMMIO2(pDevIns, pPciDev, 1 /*iRegion*/, 0 /*off*/, PAGE_SIZE, "VMMDev", &pThis->pVMMDevRAMRC);
    4608         if (RT_FAILURE(rc))
    4609             return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS,
    4610                                        N_("Failed to map first page of the VMMDev ram into raw-mode context: %Rrc"), rc);
    4611 #endif
    4612     }
    4613 
    4614     /*
    4615      * Allocate and initialize the MMIO2 heap.
    4616      */
    4617     if (pThis->fHeapEnabled)
    4618     {
    4619         rc = PDMDevHlpMMIO2Register(pDevIns, pPciDev, 2 /*iRegion*/, VMMDEV_HEAP_SIZE, 0 /*fFlags*/,
    4620                                     (void **)&pThis->pVMMDevHeapR3, "VMMDev Heap");
    4621         if (RT_FAILURE(rc))
    4622             return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS,
    4623                                        N_("Failed to allocate %u bytes of memory for the VMM device heap"), PAGE_SIZE);
     4678                                       N_("Failed to create the %u (%#x) bytes MMIO2 heap region for the VMM device"),
     4679                                       VMMDEV_HEAP_SIZE, VMMDEV_HEAP_SIZE);
    46244680
    46254681        /* Register the memory area with PDM so HM can access it before it's mapped. */
    4626         rc = PDMDevHlpRegisterVMMDevHeap(pDevIns, NIL_RTGCPHYS, pThis->pVMMDevHeapR3, VMMDEV_HEAP_SIZE);
     4682        rc = PDMDevHlpRegisterVMMDevHeap(pDevIns, NIL_RTGCPHYS, pThisCC->pVMMDevHeapR3, VMMDEV_HEAP_SIZE);
    46274683        AssertLogRelRCReturn(rc, rc);
    46284684    }
     
    46404696     * Get the corresponding connector interface
    46414697     */
    4642     rc = PDMDevHlpDriverAttach(pDevIns, 0, &pThis->IBase, &pThis->pDrvBase, "VMM Driver Port");
     4698    rc = PDMDevHlpDriverAttach(pDevIns, 0, &pThisCC->IBase, &pThisCC->pDrvBase, "VMM Driver Port");
    46434699    if (RT_SUCCESS(rc))
    46444700    {
    4645         pThis->pDrv = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIVMMDEVCONNECTOR);
    4646         AssertMsgReturn(pThis->pDrv, ("LUN #0 doesn't have a VMMDev connector interface!\n"), VERR_PDM_MISSING_INTERFACE);
     4701        pThisCC->pDrv = PDMIBASE_QUERY_INTERFACE(pThisCC->pDrvBase, PDMIVMMDEVCONNECTOR);
     4702        AssertMsgReturn(pThisCC->pDrv, ("LUN #0 doesn't have a VMMDev connector interface!\n"), VERR_PDM_MISSING_INTERFACE);
    46474703#ifdef VBOX_WITH_HGCM
    4648         pThis->pHGCMDrv = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIHGCMCONNECTOR);
    4649         if (!pThis->pHGCMDrv)
     4704        pThisCC->pHGCMDrv = PDMIBASE_QUERY_INTERFACE(pThisCC->pDrvBase, PDMIHGCMCONNECTOR);
     4705        if (!pThisCC->pHGCMDrv)
    46504706        {
    46514707            Log(("LUN #0 doesn't have a HGCM connector interface, HGCM is not supported. rc=%Rrc\n", rc));
     
    46544710#endif
    46554711        /* Query the initial balloon size. */
    4656         AssertPtr(pThis->pDrv->pfnQueryBalloonSize);
    4657         rc = pThis->pDrv->pfnQueryBalloonSize(pThis->pDrv, &pThis->cMbMemoryBalloon);
     4712        AssertPtr(pThisCC->pDrv->pfnQueryBalloonSize);
     4713        rc = pThisCC->pDrv->pfnQueryBalloonSize(pThisCC->pDrv, &pThis->cMbMemoryBalloon);
    46584714        AssertRC(rc);
    46594715
     
    46724728     */
    46734729    PPDMIBASE pBase;
    4674     rc = PDMDevHlpDriverAttach(pDevIns, PDM_STATUS_LUN, &pThis->IBase, &pBase, "Status Port");
     4730    rc = PDMDevHlpDriverAttach(pDevIns, PDM_STATUS_LUN, &pThisCC->IBase, &pBase, "Status Port");
    46754731    if (RT_SUCCESS(rc))
    4676         pThis->SharedFolders.pLedsConnector = PDMIBASE_QUERY_INTERFACE(pBase, PDMILEDCONNECTORS);
     4732        pThisCC->SharedFolders.pLedsConnector = PDMIBASE_QUERY_INTERFACE(pBase, PDMILEDCONNECTORS);
    46774733    else if (rc != VERR_PDM_NO_ATTACHED_DRIVER)
    46784734    {
     
    46934749     * Create heartbeat checking timer.
    46944750     */
    4695     rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, vmmDevHeartbeatFlatlinedTimer, pThis,
    4696                                 TMTIMER_FLAGS_NO_CRIT_SECT, "Heartbeat flatlined", &pThis->pFlatlinedTimer);
     4751    rc = PDMDevHlpTimerCreate(pDevIns, TMCLOCK_VIRTUAL, vmmDevHeartbeatFlatlinedTimer, pThis,
     4752                              TMTIMER_FLAGS_NO_CRIT_SECT, "Heartbeat flatlined", &pThis->hFlatlinedTimer);
    46974753    AssertRCReturn(rc, rc);
    46984754
    46994755#ifdef VBOX_WITH_HGCM
    4700     rc = vmmdevHGCMInit(pThis);
     4756    rc = vmmdevR3HgcmInit(pThisCC);
    47014757    AssertRCReturn(rc, rc);
    47024758#endif
     
    47114767     * Statistics.
    47124768     */
    4713     PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatMemBalloonChunks, STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
     4769    PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatMemBalloonChunks,    STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
    47144770                           "Memory balloon size",                           "/Devices/VMMDev/BalloonChunks");
    4715     PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatFastIrqAckR3,      STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
     4771    PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatFastIrqAckR3,        STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
    47164772                           "Fast IRQ acknowledgments handled in ring-3.",   "/Devices/VMMDev/FastIrqAckR3");
    4717     PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatFastIrqAckRZ,      STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
     4773    PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatFastIrqAckRZ,        STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
    47184774                           "Fast IRQ acknowledgments handled in ring-0 or raw-mode.", "/Devices/VMMDev/FastIrqAckRZ");
    4719     PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatSlowIrqAck,        STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
     4775    PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatSlowIrqAck,          STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
    47204776                           "Slow IRQ acknowledgments (old style).",         "/Devices/VMMDev/SlowIrqAck");
    4721     PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatReqBufAllocs,      STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
     4777    PDMDevHlpSTAMRegisterF(pDevIns, &pThisCC->StatReqBufAllocs,      STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
    47224778                           "Times a larger request buffer was required.",   "/Devices/VMMDev/LargeReqBufAllocs");
    47234779#ifdef VBOX_WITH_HGCM
    4724     PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatHgcmCmdArrival,    STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL,
     4780    PDMDevHlpSTAMRegisterF(pDevIns, &pThisCC->StatHgcmCmdArrival,    STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL,
    47254781                           "Profiling HGCM call arrival processing",        "/HGCM/MsgArrival");
    4726     PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatHgcmCmdCompletion, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL,
     4782    PDMDevHlpSTAMRegisterF(pDevIns, &pThisCC->StatHgcmCmdCompletion, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL,
    47274783                           "Profiling HGCM call completion processing",     "/HGCM/MsgCompletion");
    4728     PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatHgcmCmdTotal,      STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL,
     4784    PDMDevHlpSTAMRegisterF(pDevIns, &pThisCC->StatHgcmCmdTotal,      STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL,
    47294785                           "Profiling whole HGCM call.",                    "/HGCM/MsgTotal");
    4730     PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatHgcmLargeCmdAllocs,STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
     4786    PDMDevHlpSTAMRegisterF(pDevIns, &pThisCC->StatHgcmLargeCmdAllocs,STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
    47314787                           "Times the allocation cache could not be used.", "/HGCM/LargeCmdAllocs");
    4732     PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatHgcmFailedPageListLocking,STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
     4788    PDMDevHlpSTAMRegisterF(pDevIns, &pThisCC->StatHgcmFailedPageListLocking,STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
    47334789                           "Times no-bounce page list locking failed.", "/HGCM/FailedPageListLocking");
    47344790#endif
     
    47434799}
    47444800
    4745 #endif /* IN_RING3 */
     4801#else  /* !IN_RING3 */
     4802
     4803/**
     4804 * @callback_method_impl{PDMDEVREGR0,pfnConstruct}
     4805 */
     4806static DECLCALLBACK(int) vmmdevRZConstruct(PPDMDEVINS pDevIns)
     4807{
     4808    PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);
     4809    PVMMDEV   pThis   = PDMDEVINS_2_DATA(pDevIns, PVMMDEV);
     4810    PVMMDEVCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVMMDEVCC);
     4811
     4812    int rc = PDMDevHlpSetDeviceCritSect(pDevIns, PDMDevHlpCritSectGetNop(pDevIns));
     4813    AssertRCReturn(rc, rc);
     4814
     4815#if 0
     4816    rc = PDMDevHlpIoPortSetUpContext(pDevIns, pThis->hIoPortBackdoorLog, vmmdevBackdoorLog, NULL /*pfnIn*/, NULL /*pvUser*/);
     4817    AssertRCReturn(rc, rc);
     4818#endif
     4819#if 0 && defined(VMMDEV_WITH_ALT_TIMESYNC)
     4820    rc = PDMDevHlpIoPortSetUpContext(pDevIns, pThis->hIoPortAltTimesync, vmmdevAltTimeSyncWrite, vmmdevAltTimeSyncRead, NULL);
     4821    AssertRCReturn(rc, rc);
     4822#endif
     4823
     4824    /*
     4825     * We map the first page of the VMMDevRAM into raw-mode and kernel contexts so we
     4826     * can handle interrupt acknowledge requests more timely (vmmdevFastRequestIrqAck).
     4827     */
     4828    rc = PDMDevHlpMmio2SetUpContext(pDevIns, pThis->hMmio2VMMDevRAM, 0, PAGE_SIZE, (void **)&pThisCC->CTX_SUFF(pVMMDevRAM));
     4829    AssertRCReturn(rc, rc);
     4830
     4831    rc = PDMDevHlpIoPortSetUpContext(pDevIns, pThis->hIoPortFast, vmmdevFastRequestHandler, vmmdevFastRequestIrqAck, NULL);
     4832    AssertRCReturn(rc, rc);
     4833
     4834    return VINF_SUCCESS;
     4835}
     4836
     4837#endif /* !IN_RING3 */
    47464838
    47474839/**
     
    47584850    /* .uSharedVersion = */         42,
    47594851    /* .cbInstanceShared = */       sizeof(VMMDEV),
    4760     /* .cbInstanceCC = */           0,
    4761     /* .cbInstanceRC = */           0,
     4852    /* .cbInstanceCC = */           sizeof(VMMDEVCC),
     4853    /* .cbInstanceRC = */           sizeof(VMMDEVRC),
    47624854    /* .cMaxPciDevices = */         1,
    47634855    /* .cMaxMsixVectors = */        0,
     
    47944886#elif defined(IN_RING0)
    47954887    /* .pfnEarlyConstruct = */      NULL,
    4796     /* .pfnConstruct = */           NULL,
     4888    /* .pfnConstruct = */           vmmdevRZConstruct,
    47974889    /* .pfnDestruct = */            NULL,
    47984890    /* .pfnFinalDestruct = */       NULL,
     
    48074899    /* .pfnReserved7 = */           NULL,
    48084900#elif defined(IN_RC)
    4809     /* .pfnConstruct = */           NULL,
     4901    /* .pfnConstruct = */           vmmdevRZConstruct,
    48104902    /* .pfnReserved0 = */           NULL,
    48114903    /* .pfnReserved1 = */           NULL,
  • trunk/src/VBox/Devices/VMMDev/VMMDevHGCM.cpp

    r81571 r81625  
    184184    /** The STAM_GET_TS() value when the request arrived. */
    185185    uint64_t            tsArrival;
    186     /** The STAM_GET_TS() value when the hgcmCompleted() is called. */
     186    /** The STAM_GET_TS() value when the hgcmR3Completed() is called. */
    187187    uint64_t            tsComplete;
    188188
     
    242242
    243243
    244 static int vmmdevHGCMCmdListLock(PVMMDEV pThis)
    245 {
    246     int rc = RTCritSectEnter(&pThis->critsectHGCMCmdList);
     244DECLINLINE(int) vmmdevR3HgcmCmdListLock(PVMMDEVCC pThisCC)
     245{
     246    int rc = RTCritSectEnter(&pThisCC->critsectHGCMCmdList);
    247247    AssertRC(rc);
    248248    return rc;
    249249}
    250250
    251 static void vmmdevHGCMCmdListUnlock(PVMMDEV pThis)
    252 {
    253     int rc = RTCritSectLeave(&pThis->critsectHGCMCmdList);
     251DECLINLINE(void) vmmdevR3HgcmCmdListUnlock(PVMMDEVCC pThisCC)
     252{
     253    int rc = RTCritSectLeave(&pThisCC->critsectHGCMCmdList);
    254254    AssertRC(rc);
    255255}
     
    258258 *
    259259 * @returns Pointer to the command on success, NULL otherwise.
    260  * @param   pThis           The VMMDev instance data.
     260 * @param   pThisCC         The VMMDev ring-3 instance data.
    261261 * @param   enmCmdType      Type of the command.
    262262 * @param   GCPhys          The guest physical address of the HGCM request.
     
    265265 * @param   fRequestor      The VMMDevRequestHeader::fRequestor value.
    266266 */
    267 static PVBOXHGCMCMD vmmdevHGCMCmdAlloc(PVMMDEV pThis, VBOXHGCMCMDTYPE enmCmdType, RTGCPHYS GCPhys,
    268                                        uint32_t cbRequest, uint32_t cParms, uint32_t fRequestor)
     267static PVBOXHGCMCMD vmmdevR3HgcmCmdAlloc(PVMMDEVCC pThisCC, VBOXHGCMCMDTYPE enmCmdType, RTGCPHYS GCPhys,
     268                                         uint32_t cbRequest, uint32_t cParms, uint32_t fRequestor)
    269269{
    270270#if 1
     
    276276    if (cParms <= RT_ELEMENTS(pCmdCached->aGuestParms))
    277277    {
    278         int rc = RTMemCacheAllocEx(pThis->hHgcmCmdCache, (void **)&pCmdCached);
     278        int rc = RTMemCacheAllocEx(pThisCC->hHgcmCmdCache, (void **)&pCmdCached);
    279279        if (RT_SUCCESS(rc))
    280280        {
     
    298298        return NULL;
    299299    }
    300     STAM_REL_COUNTER_INC(&pThis->StatHgcmLargeCmdAllocs);
     300    STAM_REL_COUNTER_INC(&pThisCC->StatHgcmLargeCmdAllocs);
    301301
    302302#else
    303     RT_NOREF(pThis);
     303    RT_NOREF(pThisCC);
    304304#endif
    305305
     
    335335/** Deallocate VBOXHGCMCMD memory.
    336336 *
    337  * @param   pThis           The VMMDev instance data.
     337 * @param   pDevIns         The device instance.
     338 * @param   pThisCC         The VMMDev ring-3 instance data.
    338339 * @param   pCmd            Command to deallocate.
    339340 */
    340 static void vmmdevHGCMCmdFree(PVMMDEV pThis, PVBOXHGCMCMD pCmd)
     341static void vmmdevR3HgcmCmdFree(PPDMDEVINS pDevIns, PVMMDEVCC pThisCC, PVBOXHGCMCMD pCmd)
    341342{
    342343    if (pCmd)
     
    367368                    {
    368369                        if (pGuestParm->u.Pages.fLocked)
    369                             PDMDevHlpPhysBulkReleasePageMappingLocks(pThis->pDevInsR3, pGuestParm->u.Pages.cPages,
     370                            PDMDevHlpPhysBulkReleasePageMappingLocks(pDevIns, pGuestParm->u.Pages.cPages,
    370371                                                                     pGuestParm->u.Pages.paPgLocks);
    371372                        RTMemFree(pGuestParm->u.Pages.paPgLocks);
     
    378379        if (pCmd->pvReqLocked)
    379380        {
    380             PDMDevHlpPhysReleasePageMappingLock(pThis->pDevInsR3, &pCmd->ReqMapLock);
     381            PDMDevHlpPhysReleasePageMappingLock(pDevIns, &pCmd->ReqMapLock);
    381382            pCmd->pvReqLocked = NULL;
    382383        }
     
    384385#if 1
    385386        if (pCmd->fMemCache)
    386             RTMemCacheFree(pThis->hHgcmCmdCache, pCmd);
     387            RTMemCacheFree(pThisCC->hHgcmCmdCache, pCmd);
    387388        else
    388389#endif
     
    394395 *
    395396 * @returns VBox status code.
    396  * @param   pThis           The VMMDev instance data.
     397 * @param   pDevIns         The device instance.
     398 * @param   pThis           The VMMDev shared instance data.
     399 * @param   pThisCC         The VMMDev ring-3 instance data.
    397400 * @param   pCmd            Command to add.
    398401 */
    399 static int vmmdevHGCMAddCommand(PVMMDEV pThis, PVBOXHGCMCMD pCmd)
    400 {
    401     int rc = vmmdevHGCMCmdListLock(pThis);
     402static int vmmdevR3HgcmAddCommand(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC, PVBOXHGCMCMD pCmd)
     403{
     404    int rc = vmmdevR3HgcmCmdListLock(pThisCC);
    402405    AssertRCReturn(rc, rc);
    403406
    404407    LogFlowFunc(("%p type %d\n", pCmd, pCmd->enmCmdType));
    405408
    406     RTListPrepend(&pThis->listHGCMCmd, &pCmd->node);
     409    RTListPrepend(&pThisCC->listHGCMCmd, &pCmd->node);
    407410
    408411    /* Automatically enable HGCM events, if there are HGCM commands. */
     
    411414        || pCmd->enmCmdType == VBOXHGCMCMDTYPE_CALL)
    412415    {
    413         LogFunc(("u32HGCMEnabled = %d\n", pThis->u32HGCMEnabled));
    414         if (ASMAtomicCmpXchgU32(&pThis->u32HGCMEnabled, 1, 0))
    415              VMMDevCtlSetGuestFilterMask(pThis, VMMDEV_EVENT_HGCM, 0);
    416     }
    417 
    418     vmmdevHGCMCmdListUnlock(pThis);
     416        LogFunc(("u32HGCMEnabled = %d\n", pThisCC->u32HGCMEnabled));
     417        if (ASMAtomicCmpXchgU32(&pThisCC->u32HGCMEnabled, 1, 0))
     418             VMMDevCtlSetGuestFilterMask(pDevIns, pThis, pThisCC, VMMDEV_EVENT_HGCM, 0);
     419    }
     420
     421    vmmdevR3HgcmCmdListUnlock(pThisCC);
    419422    return rc;
    420423}
     
    423426 *
    424427 * @returns VBox status code.
    425  * @param   pThis           The VMMDev instance data.
     428 * @param   pThisCC         The VMMDev ring-3 instance data.
    426429 * @param   pCmd            Command to remove.
    427430 */
    428 static int vmmdevHGCMRemoveCommand(PVMMDEV pThis, PVBOXHGCMCMD pCmd)
    429 {
    430     int rc = vmmdevHGCMCmdListLock(pThis);
     431static int vmmdevR3HgcmRemoveCommand(PVMMDEVCC pThisCC, PVBOXHGCMCMD pCmd)
     432{
     433    int rc = vmmdevR3HgcmCmdListLock(pThisCC);
    431434    AssertRCReturn(rc, rc);
    432435
     
    435438    RTListNodeRemove(&pCmd->node);
    436439
    437     vmmdevHGCMCmdListUnlock(pThis);
     440    vmmdevR3HgcmCmdListUnlock(pThisCC);
    438441    return rc;
    439442}
     
    449452 * @param   GCPhys          The physical address of the command we're looking for.
    450453 */
    451 DECLINLINE(PVBOXHGCMCMD) vmmdevHGCMFindCommandLocked(PVMMDEV pThis, RTGCPHYS GCPhys)
     454DECLINLINE(PVBOXHGCMCMD) vmmdevR3HgcmFindCommandLocked(PVMMDEVCC pThisCC, RTGCPHYS GCPhys)
    452455{
    453456    PVBOXHGCMCMD pCmd;
    454     RTListForEach(&pThis->listHGCMCmd, pCmd, VBOXHGCMCMD, node)
     457    RTListForEach(&pThisCC->listHGCMCmd, pCmd, VBOXHGCMCMD, node)
    455458    {
    456459        if (pCmd->GCPhys == GCPhys)
     
    465468 * @param   pCmd            Destination command.
    466469 */
    467 static void vmmdevHGCMConnectFetch(const VMMDevHGCMConnect *pHGCMConnect, PVBOXHGCMCMD pCmd)
     470static void vmmdevR3HgcmConnectFetch(const VMMDevHGCMConnect *pHGCMConnect, PVBOXHGCMCMD pCmd)
    468471{
    469472    pCmd->enmRequestType        = pHGCMConnect->header.header.requestType;
     
    474477/** Handle VMMDevHGCMConnect request.
    475478 *
    476  * @param   pThis           The VMMDev instance data.
     479 * @param   pDevIns         The device instance.
     480 * @param   pThis           The VMMDev shared instance data.
     481 * @param   pThisCC         The VMMDev ring-3 instance data.
    477482 * @param   pHGCMConnect    The guest request (cached in host memory).
    478483 * @param   GCPhys          The physical address of the request.
    479484 */
    480 int vmmdevHGCMConnect(PVMMDEV pThis, const VMMDevHGCMConnect *pHGCMConnect, RTGCPHYS GCPhys)
    481 {
    482     int rc = VINF_SUCCESS;
    483 
    484     PVBOXHGCMCMD pCmd = vmmdevHGCMCmdAlloc(pThis, VBOXHGCMCMDTYPE_CONNECT, GCPhys, pHGCMConnect->header.header.size, 0,
    485                                            pHGCMConnect->header.header.fRequestor);
     485int vmmdevR3HgcmConnect(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC,
     486                        const VMMDevHGCMConnect *pHGCMConnect, RTGCPHYS GCPhys)
     487{
     488    int rc;
     489    PVBOXHGCMCMD pCmd = vmmdevR3HgcmCmdAlloc(pThisCC, VBOXHGCMCMDTYPE_CONNECT, GCPhys, pHGCMConnect->header.header.size, 0,
     490                                             pHGCMConnect->header.header.fRequestor);
    486491    if (pCmd)
    487492    {
    488         vmmdevHGCMConnectFetch(pHGCMConnect, pCmd);
     493        vmmdevR3HgcmConnectFetch(pHGCMConnect, pCmd);
    489494
    490495        /* Only allow the guest to use existing services! */
     
    492497        pCmd->u.connect.pLoc->type = VMMDevHGCMLoc_LocalHost_Existing;
    493498
    494         vmmdevHGCMAddCommand(pThis, pCmd);
    495         rc = pThis->pHGCMDrv->pfnConnect(pThis->pHGCMDrv, pCmd, pCmd->u.connect.pLoc, &pCmd->u.connect.u32ClientID);
     499        vmmdevR3HgcmAddCommand(pDevIns, pThis, pThisCC, pCmd);
     500        rc = pThisCC->pHGCMDrv->pfnConnect(pThisCC->pHGCMDrv, pCmd, pCmd->u.connect.pLoc, &pCmd->u.connect.u32ClientID);
    496501        if (RT_FAILURE(rc))
    497             vmmdevHGCMRemoveCommand(pThis, pCmd);
     502            vmmdevR3HgcmRemoveCommand(pThisCC, pCmd);
    498503    }
    499504    else
    500     {
    501505        rc = VERR_NO_MEMORY;
    502     }
    503506
    504507    return rc;
     
    510513 * @param   pCmd            Destination command.
    511514 */
    512 static void vmmdevHGCMDisconnectFetch(const VMMDevHGCMDisconnect *pHGCMDisconnect, PVBOXHGCMCMD pCmd)
     515static void vmmdevR3HgcmDisconnectFetch(const VMMDevHGCMDisconnect *pHGCMDisconnect, PVBOXHGCMCMD pCmd)
    513516{
    514517    pCmd->enmRequestType = pHGCMDisconnect->header.header.requestType;
     
    518521/** Handle VMMDevHGCMDisconnect request.
    519522 *
    520  * @param   pThis           The VMMDev instance data.
     523 * @param   pDevIns         The device instance.
     524 * @param   pThis           The VMMDev shared instance data.
     525 * @param   pThisCC         The VMMDev ring-3 instance data.
    521526 * @param   pHGCMDisconnect The guest request (cached in host memory).
    522527 * @param   GCPhys          The physical address of the request.
    523528 */
    524 int vmmdevHGCMDisconnect(PVMMDEV pThis, const VMMDevHGCMDisconnect *pHGCMDisconnect, RTGCPHYS GCPhys)
    525 {
    526     int rc = VINF_SUCCESS;
    527 
    528     PVBOXHGCMCMD pCmd = vmmdevHGCMCmdAlloc(pThis, VBOXHGCMCMDTYPE_DISCONNECT, GCPhys, pHGCMDisconnect->header.header.size, 0,
    529                                            pHGCMDisconnect->header.header.fRequestor);
     529int vmmdevR3HgcmDisconnect(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC,
     530                           const VMMDevHGCMDisconnect *pHGCMDisconnect, RTGCPHYS GCPhys)
     531{
     532    int rc;
     533    PVBOXHGCMCMD pCmd = vmmdevR3HgcmCmdAlloc(pThisCC, VBOXHGCMCMDTYPE_DISCONNECT, GCPhys, pHGCMDisconnect->header.header.size, 0,
     534                                             pHGCMDisconnect->header.header.fRequestor);
    530535    if (pCmd)
    531536    {
    532         vmmdevHGCMDisconnectFetch(pHGCMDisconnect, pCmd);
    533 
    534         vmmdevHGCMAddCommand(pThis, pCmd);
    535         rc = pThis->pHGCMDrv->pfnDisconnect (pThis->pHGCMDrv, pCmd, pCmd->u.disconnect.u32ClientID);
     537        vmmdevR3HgcmDisconnectFetch(pHGCMDisconnect, pCmd);
     538
     539        vmmdevR3HgcmAddCommand(pDevIns, pThis, pThisCC, pCmd);
     540        rc = pThisCC->pHGCMDrv->pfnDisconnect(pThisCC->pHGCMDrv, pCmd, pCmd->u.disconnect.u32ClientID);
    536541        if (RT_FAILURE(rc))
    537             vmmdevHGCMRemoveCommand(pThis, pCmd);
     542            vmmdevR3HgcmRemoveCommand(pThisCC, pCmd);
    538543    }
    539544    else
     
    548553 * @param   enmType         Type of the LinAddr parameter.
    549554 */
    550 static uint32_t vmmdevHGCMParmTypeToDirection(HGCMFunctionParameterType enmType)
     555static uint32_t vmmdevR3HgcmParmTypeToDirection(HGCMFunctionParameterType enmType)
    551556{
    552557    if (enmType == VMMDevHGCMParmType_LinAddr_In)  return VBOX_HGCM_F_PARM_DIRECTION_TO_HOST;
     
    560565 * @param   pPtr            Information about a pointer HGCM parameter.
    561566 */
    562 DECLINLINE(bool) vmmdevHGCMGuestBufferIsContiguous(const VBOXHGCMPARMPTR *pPtr)
     567DECLINLINE(bool) vmmdevR3HgcmGuestBufferIsContiguous(const VBOXHGCMPARMPTR *pPtr)
    563568{
    564569    if (pPtr->cPages == 1)
     
    589594 * @param   pPtr            Description of the source HGCM pointer parameter.
    590595 */
    591 static int vmmdevHGCMGuestBufferRead(PPDMDEVINSR3 pDevIns, void *pvDst, uint32_t cbDst,
    592                                      const VBOXHGCMPARMPTR *pPtr)
     596static int vmmdevR3HgcmGuestBufferRead(PPDMDEVINSR3 pDevIns, void *pvDst, uint32_t cbDst, const VBOXHGCMPARMPTR *pPtr)
    593597{
    594598    /*
     
    596600     */
    597601    /** @todo We need a flag for indicating this. */
    598     if (vmmdevHGCMGuestBufferIsContiguous(pPtr))
     602    if (vmmdevR3HgcmGuestBufferIsContiguous(pPtr))
    599603        return PDMDevHlpPhysRead(pDevIns, pPtr->paPages[0] | pPtr->offFirstPage, pvDst, cbDst);
    600604
     
    636640 * @param   cbSrc           Size of the source host buffer.
    637641 */
    638 static int vmmdevHGCMGuestBufferWrite(PPDMDEVINSR3 pDevIns, const VBOXHGCMPARMPTR *pPtr,
    639                                       const void *pvSrc,  uint32_t cbSrc)
     642static int vmmdevR3HgcmGuestBufferWrite(PPDMDEVINSR3 pDevIns, const VBOXHGCMPARMPTR *pPtr, const void *pvSrc,  uint32_t cbSrc)
    640643{
    641644    int rc = VINF_SUCCESS;
     
    672675 *
    673676 * @returns VBox status code that the guest should see.
    674  * @param   pThis           The VMMDev instance data.
     677 * @param   pDevIns         The device instance.
    675678 * @param   pCmd            Command structure where host parameters needs initialization.
    676679 * @param   pbReq           The request buffer.
    677680 */
    678 static int vmmdevHGCMInitHostParameters(PVMMDEV pThis, PVBOXHGCMCMD pCmd, uint8_t const *pbReq)
     681static int vmmdevR3HgcmInitHostParameters(PPDMDEVINS pDevIns, PVBOXHGCMCMD pCmd, uint8_t const *pbReq)
    679682{
    680683    AssertReturn(pCmd->enmCmdType == VBOXHGCMCMDTYPE_CALL, VERR_INTERNAL_ERROR);
     
    729732                            if (pGuestParm->enmType != VMMDevHGCMParmType_ContiguousPageList)
    730733                            {
    731                                 int rc = vmmdevHGCMGuestBufferRead(pThis->pDevInsR3, pv, cbData, &pGuestParm->u.ptr);
     734                                int rc = vmmdevR3HgcmGuestBufferRead(pDevIns, pv, cbData, &pGuestParm->u.ptr);
    732735                                ASSERT_GUEST_RETURN(RT_SUCCESS(rc), rc);
    733736                                RT_UNTRUSTED_NONVOLATILE_COPY_FENCE();
     
    735738                            else
    736739                            {
    737                                 int rc = PDMDevHlpPhysRead(pThis->pDevInsR3,
     740                                int rc = PDMDevHlpPhysRead(pDevIns,
    738741                                                           pGuestParm->u.ptr.paPages[0] | pGuestParm->u.ptr.offFirstPage,
    739742                                                           pv, cbData);
     
    779782 *
    780783 * @returns VBox status code that the guest should see.
    781  * @param   pThis           The VMMDev instance data.
     784 * @param   pThisCC         The VMMDev ring-3 instance data.
    782785 * @param   pHGCMCall       The HGCMCall request (cached in host memory).
    783786 * @param   cbHGCMCall      Size of the request.
     
    787790 * @param   pcbHGCMParmStruct Where to store size of used HGCM parameter structure.
    788791 */
    789 static int vmmdevHGCMCallAlloc(PVMMDEV pThis, const VMMDevHGCMCall *pHGCMCall, uint32_t cbHGCMCall, RTGCPHYS GCPhys,
    790                                VMMDevRequestType enmRequestType, PVBOXHGCMCMD *ppCmd, uint32_t *pcbHGCMParmStruct)
     792static int vmmdevR3HgcmCallAlloc(PVMMDEVCC pThisCC, const VMMDevHGCMCall *pHGCMCall, uint32_t cbHGCMCall, RTGCPHYS GCPhys,
     793                                 VMMDevRequestType enmRequestType, PVBOXHGCMCMD *ppCmd, uint32_t *pcbHGCMParmStruct)
    791794{
    792795#ifdef VBOX_WITH_64_BITS_GUESTS
     
    807810    RT_UNTRUSTED_VALIDATED_FENCE();
    808811
    809     PVBOXHGCMCMD pCmd = vmmdevHGCMCmdAlloc(pThis, VBOXHGCMCMDTYPE_CALL, GCPhys, cbHGCMCall, cParms,
    810                                            pHGCMCall->header.header.fRequestor);
     812    PVBOXHGCMCMD pCmd = vmmdevR3HgcmCmdAlloc(pThisCC, VBOXHGCMCMDTYPE_CALL, GCPhys, cbHGCMCall, cParms,
     813                                             pHGCMCall->header.header.fRequestor);
    811814    if (pCmd == NULL)
    812815        return VERR_NO_MEMORY;
     
    825828 *
    826829 * @returns VBox status code that the guest should see.
    827  * @param   pThis           The VMMDev instance data.
     830 * @param   pDevIns         The device instance.
     831 * @param   pThisCC         The VMMDev ring-3 instance data.
    828832 * @param   pCmd            The destination command.
    829833 * @param   pHGCMCall       The HGCMCall request (cached in host memory).
     
    832836 * @param   cbHGCMParmStruct Size of used HGCM parameter structure.
    833837 */
    834 static int vmmdevHGCMCallFetchGuestParms(PVMMDEV pThis, PVBOXHGCMCMD pCmd,
    835                                          const VMMDevHGCMCall *pHGCMCall, uint32_t cbHGCMCall,
    836                                          VMMDevRequestType enmRequestType, uint32_t cbHGCMParmStruct)
     838static int vmmdevR3HgcmCallFetchGuestParms(PPDMDEVINS pDevIns, PVMMDEVCC pThisCC, PVBOXHGCMCMD pCmd,
     839                                           const VMMDevHGCMCall *pHGCMCall, uint32_t cbHGCMCall,
     840                                           VMMDevRequestType enmRequestType, uint32_t cbHGCMParmStruct)
    837841{
    838842    /*
     
    926930                pGuestParm->u.ptr.offFirstPage  = offFirstPage;
    927931                pGuestParm->u.ptr.cPages        = cPages;
    928                 pGuestParm->u.ptr.fu32Direction = vmmdevHGCMParmTypeToDirection(pGuestParm->enmType);
     932                pGuestParm->u.ptr.fu32Direction = vmmdevR3HgcmParmTypeToDirection(pGuestParm->enmType);
    929933
    930934                if (cbData > 0)
     
    948952                         */
    949953                        RTGCPHYS GCPhys;
    950                         int rc2 = PDMDevHlpPhysGCPtr2GCPhys(pThis->pDevInsR3, GCPtr, &GCPhys);
     954                        int rc2 = PDMDevHlpPhysGCPtr2GCPhys(pDevIns, GCPtr, &GCPhys);
    951955                        if (RT_FAILURE(rc2))
    952956                            GCPhys = NIL_RTGCPHYS;
     
    10461050                    void **papvPages = (void **)&pGuestParm->u.Pages.paPgLocks[cPages];
    10471051                    if (pPageListInfo->flags & VBOX_HGCM_F_PARM_DIRECTION_FROM_HOST)
    1048                         rc = PDMDevHlpPhysBulkGCPhys2CCPtr(pThis->pDevInsR3, cPages, pPageListInfo->aPages, 0 /*fFlags*/,
     1052                        rc = PDMDevHlpPhysBulkGCPhys2CCPtr(pDevIns, cPages, pPageListInfo->aPages, 0 /*fFlags*/,
    10491053                                                           papvPages, pGuestParm->u.Pages.paPgLocks);
    10501054                    else
    1051                         rc = PDMDevHlpPhysBulkGCPhys2CCPtrReadOnly(pThis->pDevInsR3, cPages, pPageListInfo->aPages, 0 /*fFlags*/,
     1055                        rc = PDMDevHlpPhysBulkGCPhys2CCPtrReadOnly(pDevIns, cPages, pPageListInfo->aPages, 0 /*fFlags*/,
    10521056                                                                   (void const **)papvPages, pGuestParm->u.Pages.paPgLocks);
    10531057                    if (RT_SUCCESS(rc))
     
    10611065                    RTMemFree(pGuestParm->u.Pages.paPgLocks);
    10621066                    pGuestParm->u.Pages.paPgLocks = NULL;
    1063                     STAM_REL_COUNTER_INC(&pThis->StatHgcmFailedPageListLocking);
     1067                    STAM_REL_COUNTER_INC(&pThisCC->StatHgcmFailedPageListLocking);
    10641068                    ASSERT_GUEST_MSG_RETURN(rc == VERR_PGM_PHYS_PAGE_RESERVED, ("cPages=%u %Rrc\n", cPages, rc), rc);
    10651069                    pGuestParm->enmType = VMMDevHGCMParmType_PageList;
     
    11371141 *
    11381142 * @returns VBox status code that the guest should see.
    1139  * @param   pThis           The VMMDev instance data.
     1143 * @param   pDevIns         The device instance.
     1144 * @param   pThis           The VMMDev shared instance data.
     1145 * @param   pThisCC         The VMMDev ring-3 instance data.
    11401146 * @param   pHGCMCall       The request to handle (cached in host memory).
    11411147 * @param   cbHGCMCall      Size of the entire request (including HGCM parameters).
     
    11461152 *                          NULL).  Set to NULL if HGCM takes lock ownership.
    11471153 */
    1148 int vmmdevHGCMCall(PVMMDEV pThis, const VMMDevHGCMCall *pHGCMCall, uint32_t cbHGCMCall, RTGCPHYS GCPhys,
    1149                    VMMDevRequestType enmRequestType, uint64_t tsArrival, PVMMDEVREQLOCK *ppLock)
     1154int vmmdevR3HgcmCall(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC, const VMMDevHGCMCall *pHGCMCall, uint32_t cbHGCMCall,
     1155                     RTGCPHYS GCPhys, VMMDevRequestType enmRequestType, uint64_t tsArrival, PVMMDEVREQLOCK *ppLock)
    11501156{
    11511157    LogFunc(("client id = %d, function = %d, cParms = %d, enmRequestType = %d, fRequestor = %#x\n", pHGCMCall->u32ClientID,
     
    11691175    PVBOXHGCMCMD pCmd;
    11701176    uint32_t cbHGCMParmStruct;
    1171     int rc = vmmdevHGCMCallAlloc(pThis, pHGCMCall, cbHGCMCall, GCPhys, enmRequestType, &pCmd, &cbHGCMParmStruct);
     1177    int rc = vmmdevR3HgcmCallAlloc(pThisCC, pHGCMCall, cbHGCMCall, GCPhys, enmRequestType, &pCmd, &cbHGCMParmStruct);
    11721178    if (RT_SUCCESS(rc))
    11731179    {
     
    11811187        }
    11821188
    1183         rc = vmmdevHGCMCallFetchGuestParms(pThis, pCmd, pHGCMCall, cbHGCMCall, enmRequestType, cbHGCMParmStruct);
     1189        rc = vmmdevR3HgcmCallFetchGuestParms(pDevIns, pThisCC, pCmd, pHGCMCall, cbHGCMCall, enmRequestType, cbHGCMParmStruct);
    11841190        if (RT_SUCCESS(rc))
    11851191        {
    11861192            /* Copy guest data to host parameters, so HGCM services can use the data. */
    1187             rc = vmmdevHGCMInitHostParameters(pThis, pCmd, (uint8_t const *)pHGCMCall);
     1193            rc = vmmdevR3HgcmInitHostParameters(pDevIns, pCmd, (uint8_t const *)pHGCMCall);
    11881194            if (RT_SUCCESS(rc))
    11891195            {
     
    11911197                 * Pass the function call to HGCM connector for actual processing
    11921198                 */
    1193                 vmmdevHGCMAddCommand(pThis, pCmd);
     1199                vmmdevR3HgcmAddCommand(pDevIns, pThis, pThisCC, pCmd);
    11941200
    11951201#if 0 /* DONT ENABLE - for performance hacking. */
     
    11971203                    &&  pCmd->u.call.cParms      == 5)
    11981204                {
    1199                     vmmdevHGCMRemoveCommand(pThis, pCmd);
     1205                    vmmdevR3HgcmRemoveCommand(pThisCC, pCmd);
    12001206
    12011207                    if (pCmd->pvReqLocked)
     
    12121218                        pHeader->result    = VINF_SUCCESS;
    12131219                        pHeader->fu32Flags |= VBOX_HGCM_REQ_DONE;
    1214                         PDMDevHlpPhysWrite(pThis->pDevInsR3, GCPhys, pHeader,  sizeof(*pHeader));
     1220                        PDMDevHlpPhysWrite(pDevIns, GCPhys, pHeader,  sizeof(*pHeader));
    12151221                    }
    1216                     vmmdevHGCMCmdFree(pThis, pCmd);
     1222                    vmmdevR3HgcmCmdFree(pDevIns, pThisCC, pCmd);
    12171223                    return VINF_HGCM_ASYNC_EXECUTE; /* ignored, but avoids assertions. */
    12181224                }
    12191225#endif
    12201226
    1221                 rc = pThis->pHGCMDrv->pfnCall(pThis->pHGCMDrv, pCmd,
    1222                                               pCmd->u.call.u32ClientID, pCmd->u.call.u32Function,
    1223                                               pCmd->u.call.cParms, pCmd->u.call.paHostParms, tsArrival);
     1227                rc = pThisCC->pHGCMDrv->pfnCall(pThisCC->pHGCMDrv, pCmd,
     1228                                                pCmd->u.call.u32ClientID, pCmd->u.call.u32Function,
     1229                                                pCmd->u.call.cParms, pCmd->u.call.paHostParms, tsArrival);
    12241230
    12251231                if (rc == VINF_HGCM_ASYNC_EXECUTE)
     
    12311237                    uint64_t tsNow;
    12321238                    STAM_GET_TS(tsNow);
    1233                     STAM_REL_PROFILE_ADD_PERIOD(&pThis->StatHgcmCmdArrival, tsNow - tsArrival);
     1239                    STAM_REL_PROFILE_ADD_PERIOD(&pThisCC->StatHgcmCmdArrival, tsNow - tsArrival);
    12341240#endif
    12351241                    return rc;
     
    12401246                 */
    12411247                LogFunc(("pfnCall rc = %Rrc\n", rc));
    1242                 vmmdevHGCMRemoveCommand(pThis, pCmd);
     1248                vmmdevR3HgcmRemoveCommand(pThisCC, pCmd);
    12431249            }
    12441250        }
    1245         vmmdevHGCMCmdFree(pThis, pCmd);
     1251        vmmdevR3HgcmCmdFree(pDevIns, pThisCC, pCmd);
    12461252    }
    12471253    return rc;
     
    12521258 *
    12531259 * @returns VBox status code that the guest should see.
    1254  * @param   pThis           The VMMDev instance data.
     1260 * @param   pThisCC         The VMMDev ring-3 instance data.
    12551261 * @param   pHGCMCancel     The request to handle (cached in host memory).
    12561262 * @param   GCPhys          The address of the request.
     
    12581264 * @thread EMT
    12591265 */
    1260 int vmmdevHGCMCancel(PVMMDEV pThis, const VMMDevHGCMCancel *pHGCMCancel, RTGCPHYS GCPhys)
     1266int vmmdevR3HgcmCancel(PVMMDEVCC pThisCC, const VMMDevHGCMCancel *pHGCMCancel, RTGCPHYS GCPhys)
    12611267{
    12621268    NOREF(pHGCMCancel);
    1263     int rc = vmmdevHGCMCancel2(pThis, GCPhys);
     1269    int rc = vmmdevR3HgcmCancel2(pThisCC, GCPhys);
    12641270    return rc == VERR_NOT_FOUND ? VERR_INVALID_PARAMETER : rc;
    12651271}
     
    12721278 * @retval  VERR_INVALID_PARAMETER if the request address is invalid.
    12731279 *
    1274  * @param   pThis           The VMMDev instance data.
     1280 * @param   pThisCC         The VMMDev ring-3 instance data.
    12751281 * @param   GCPhys          The address of the request that should be cancelled.
    12761282 *
    12771283 * @thread EMT
    12781284 */
    1279 int vmmdevHGCMCancel2(PVMMDEV pThis, RTGCPHYS GCPhys)
     1285int vmmdevR3HgcmCancel2(PVMMDEVCC pThisCC, RTGCPHYS GCPhys)
    12801286{
    12811287    if (    GCPhys == 0
     
    12831289        ||  GCPhys == NIL_RTGCPHYS32)
    12841290    {
    1285         Log(("vmmdevHGCMCancel2: GCPhys=%#x\n", GCPhys));
     1291        Log(("vmmdevR3HgcmCancel2: GCPhys=%#x\n", GCPhys));
    12861292        return VERR_INVALID_PARAMETER;
    12871293    }
     
    12911297     * the lock. hgcmCompletedWorker makes assumptions about this.
    12921298     */
    1293     int rc = vmmdevHGCMCmdListLock(pThis);
     1299    int rc = vmmdevR3HgcmCmdListLock(pThisCC);
    12941300    AssertRCReturn(rc, rc);
    12951301
    1296     PVBOXHGCMCMD pCmd = vmmdevHGCMFindCommandLocked(pThis, GCPhys);
     1302    PVBOXHGCMCMD pCmd = vmmdevR3HgcmFindCommandLocked(pThisCC, GCPhys);
    12971303    if (pCmd)
    12981304    {
    12991305        pCmd->fCancelled = true;
    13001306
    1301         Log(("vmmdevHGCMCancel2: Cancelled pCmd=%p / GCPhys=%#x\n", pCmd, GCPhys));
    1302         if (pThis->pHGCMDrv)
    1303             pThis->pHGCMDrv->pfnCancelled(pThis->pHGCMDrv, pCmd,
    1304                                           pCmd->enmCmdType == VBOXHGCMCMDTYPE_CALL ? pCmd->u.call.u32ClientID
    1305                                           : pCmd->enmCmdType == VBOXHGCMCMDTYPE_CONNECT ? pCmd->u.connect.u32ClientID
    1306                                           : pCmd->enmCmdType == VBOXHGCMCMDTYPE_DISCONNECT ? pCmd->u.disconnect.u32ClientID
    1307                                           : 0);
     1307        Log(("vmmdevR3HgcmCancel2: Cancelled pCmd=%p / GCPhys=%#x\n", pCmd, GCPhys));
     1308        if (pThisCC->pHGCMDrv)
     1309            pThisCC->pHGCMDrv->pfnCancelled(pThisCC->pHGCMDrv, pCmd,
     1310                                            pCmd->enmCmdType == VBOXHGCMCMDTYPE_CALL ? pCmd->u.call.u32ClientID
     1311                                            : pCmd->enmCmdType == VBOXHGCMCMDTYPE_CONNECT ? pCmd->u.connect.u32ClientID
     1312                                            : pCmd->enmCmdType == VBOXHGCMCMDTYPE_DISCONNECT ? pCmd->u.disconnect.u32ClientID
     1313                                            : 0);
    13081314    }
    13091315    else
    13101316        rc = VERR_NOT_FOUND;
    13111317
    1312     vmmdevHGCMCmdListUnlock(pThis);
     1318    vmmdevR3HgcmCmdListUnlock(pThisCC);
    13131319    return rc;
    13141320}
     
    13171323 *
    13181324 * @returns VBox status code that the guest should see.
    1319  * @param   pThis           The VMMDev instance data.
     1325 * @param   pDevIns         The device instance.
    13201326 * @param   pCmd            Completed call command.
    13211327 * @param   pHGCMCall       The guestrequest which needs updating (cached in the host memory).
     
    13231329 *                          embedded buffers.
    13241330 */
    1325 static int vmmdevHGCMCompleteCallRequest(PVMMDEV pThis, PVBOXHGCMCMD pCmd, VMMDevHGCMCall *pHGCMCall, uint8_t *pbReq)
     1331static int vmmdevR3HgcmCompleteCallRequest(PPDMDEVINS pDevIns, PVBOXHGCMCMD pCmd, VMMDevHGCMCall *pHGCMCall, uint8_t *pbReq)
    13261332{
    13271333    AssertReturn(pCmd->enmCmdType == VBOXHGCMCMDTYPE_CALL, VERR_INTERNAL_ERROR);
     
    13761382                    const void *pvSrc = pHostParm->u.pointer.addr;
    13771383                    uint32_t cbSrc = pHostParm->u.pointer.size;
    1378                     int rc = vmmdevHGCMGuestBufferWrite(pThis->pDevInsR3, pPtr, pvSrc, cbSrc);
     1384                    int rc = vmmdevR3HgcmGuestBufferWrite(pDevIns, pPtr, pvSrc, cbSrc);
    13791385                    if (RT_FAILURE(rc))
    13801386                        break;
     
    14221428                    uint32_t    cbSrc    = pHostParm->u.pointer.size;
    14231429                    uint32_t    cbToCopy = RT_MIN(cbSrc, pPtr->cbData);
    1424                     int rc = PDMDevHlpPhysWrite(pThis->pDevInsR3, pGuestParm->u.ptr.paPages[0] | pGuestParm->u.ptr.offFirstPage,
     1430                    int rc = PDMDevHlpPhysWrite(pDevIns, pGuestParm->u.ptr.paPages[0] | pGuestParm->u.ptr.offFirstPage,
    14251431                                                pvSrc, cbToCopy);
    14261432                    if (RT_FAILURE(rc))
     
    14411447                if (pGuestParm->u.Pages.fLocked)
    14421448                {
    1443                     PDMDevHlpPhysBulkReleasePageMappingLocks(pThis->pDevInsR3, pGuestParm->u.Pages.cPages,
     1449                    PDMDevHlpPhysBulkReleasePageMappingLocks(pDevIns, pGuestParm->u.Pages.cPages,
    14441450                                                             pGuestParm->u.Pages.paPgLocks);
    14451451                    pGuestParm->u.Pages.fLocked = false;
     
    14671473static int hgcmCompletedWorker(PPDMIHGCMPORT pInterface, int32_t result, PVBOXHGCMCMD pCmd)
    14681474{
    1469     PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IHGCMPort);
     1475    PVMMDEVCC  pThisCC    = RT_FROM_MEMBER(pInterface, VMMDEVCC, IHGCMPort);
     1476    PPDMDEVINS pDevIns    = pThisCC->pDevIns;
     1477    PVMMDEV    pThis      = PDMDEVINS_2_DATA(pDevIns, PVMMDEV);
    14701478#ifdef VBOX_WITH_DTRACE
    1471     uint32_t idFunction = 0;
    1472     uint32_t idClient   = 0;
     1479    uint32_t   idFunction = 0;
     1480    uint32_t   idClient   = 0;
    14731481#endif
    14741482
     
    14811489         * It it assumed that VMMDev saves state after the HGCM services (VMMDev driver
    14821490         * attached by constructor before it registers its SSM state), and, therefore,
    1483          * VBOXHGCMCMD structures are not removed by vmmdevHGCMSaveState from the list,
     1491         * VBOXHGCMCMD structures are not removed by vmmdevR3HgcmSaveState from the list,
    14841492         * while HGCM uses them.
    14851493         */
     
    14971505     * back to guest memory.
    14981506     */
    1499     vmmdevHGCMRemoveCommand(pThis, pCmd);
     1507    vmmdevR3HgcmRemoveCommand(pThisCC, pCmd);
    15001508
    15011509    if (RT_LIKELY(!pCmd->fCancelled))
     
    15131521                 * The request data is not be used for anything but checking the request type.
    15141522                 */
    1515                 PDMDevHlpPhysRead(pThis->pDevInsR3, pCmd->GCPhys, pHeader, pCmd->cbRequest);
     1523                PDMDevHlpPhysRead(pDevIns, pCmd->GCPhys, pHeader, pCmd->cbRequest);
    15161524                RT_UNTRUSTED_NONVOLATILE_COPY_FENCE();
    15171525
     
    15341542                        {
    15351543                            VMMDevHGCMCall *pHGCMCall = (VMMDevHGCMCall *)pHeader;
    1536                             rc = vmmdevHGCMCompleteCallRequest(pThis, pCmd, pHGCMCall, (uint8_t *)pHeader);
     1544                            rc = vmmdevR3HgcmCompleteCallRequest(pDevIns, pCmd, pHGCMCall, (uint8_t *)pHeader);
    15371545#ifdef VBOX_WITH_DTRACE
    15381546                            idFunction = pCmd->u.call.u32Function;
     
    15711579
    15721580                /* First write back the request. */
    1573                 PDMDevHlpPhysWrite(pThis->pDevInsR3, pCmd->GCPhys, pHeader, pCmd->cbRequest);
     1581                PDMDevHlpPhysWrite(pDevIns, pCmd->GCPhys, pHeader, pCmd->cbRequest);
    15741582
    15751583                /* Mark request as processed. */
     
    15771585
    15781586                /* Second write the flags to mark the request as processed. */
    1579                 PDMDevHlpPhysWrite(pThis->pDevInsR3, pCmd->GCPhys + RT_UOFFSETOF(VMMDevHGCMRequestHeader, fu32Flags),
     1587                PDMDevHlpPhysWrite(pDevIns, pCmd->GCPhys + RT_UOFFSETOF(VMMDevHGCMRequestHeader, fu32Flags),
    15801588                                   &pHeader->fu32Flags, sizeof(pHeader->fu32Flags));
    15811589
    15821590                /* Now, when the command was removed from the internal list, notify the guest. */
    1583                 VMMDevNotifyGuest(pThis, VMMDEV_EVENT_HGCM);
     1591                VMMDevNotifyGuest(pDevIns, pThis, pThisCC, VMMDEV_EVENT_HGCM);
    15841592
    15851593                RTMemFree(pHeader);
     
    16151623                    {
    16161624                        VMMDevHGCMCall *pHGCMCall = (VMMDevHGCMCall *)pHeader;
    1617                         rc = vmmdevHGCMCompleteCallRequest(pThis, pCmd, pHGCMCall, (uint8_t *)pHeader);
     1625                        rc = vmmdevR3HgcmCompleteCallRequest(pDevIns, pCmd, pHGCMCall, (uint8_t *)pHeader);
    16181626#ifdef VBOX_WITH_DTRACE
    16191627                        idFunction = pCmd->u.call.u32Function;
     
    16551663
    16561664            /* Now, when the command was removed from the internal list, notify the guest. */
    1657             VMMDevNotifyGuest(pThis, VMMDEV_EVENT_HGCM);
     1665            VMMDevNotifyGuest(pDevIns, pThis, pThisCC, VMMDEV_EVENT_HGCM);
    16581666        }
    16591667
    16601668        /* Set the status to success for now, though we might consider passing
    1661            along the vmmdevHGCMCompleteCallRequest errors... */
     1669           along the vmmdevR3HgcmCompleteCallRequest errors... */
    16621670        rc = VINF_SUCCESS;
    16631671    }
     
    16761684    /* Deallocate the command memory. */
    16771685    VBOXDD_HGCMCALL_COMPLETED_DONE(pCmd, idFunction, idClient, result);
    1678     vmmdevHGCMCmdFree(pThis, pCmd);
     1686    vmmdevR3HgcmCmdFree(pDevIns, pThisCC, pCmd);
    16791687
    16801688#ifndef VBOX_WITHOUT_RELEASE_STATISTICS
     
    16821690    uint64_t tsNow;
    16831691    STAM_GET_TS(tsNow);
    1684     STAM_REL_PROFILE_ADD_PERIOD(&pThis->StatHgcmCmdCompletion, tsNow - tsComplete);
     1692    STAM_REL_PROFILE_ADD_PERIOD(&pThisCC->StatHgcmCmdCompletion, tsNow - tsComplete);
    16851693    if (tsArrival != 0)
    1686         STAM_REL_PROFILE_ADD_PERIOD(&pThis->StatHgcmCmdTotal,  tsNow - tsArrival);
     1694        STAM_REL_PROFILE_ADD_PERIOD(&pThisCC->StatHgcmCmdTotal,  tsNow - tsArrival);
    16871695#endif
    16881696
     
    16981706 * @param   pCmd            Completed command, which contains updated host parameters.
    16991707 */
    1700 DECLCALLBACK(int) hgcmCompleted(PPDMIHGCMPORT pInterface, int32_t result, PVBOXHGCMCMD pCmd)
     1708DECLCALLBACK(int) hgcmR3Completed(PPDMIHGCMPORT pInterface, int32_t result, PVBOXHGCMCMD pCmd)
    17011709{
    17021710#if 0 /* This seems to be significantly slower.  Half of MsgTotal time seems to be spend here. */
    1703     PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDevState, IHGCMPort);
     1711    PVMMDEVCC pThisCC = RT_FROM_MEMBER(pInterface, VMMDEVCC, IHGCMPort);
    17041712    STAM_GET_TS(pCmd->tsComplete);
    17051713
     
    17091717 *        efficient...? */
    17101718    /* Not safe to execute asynchronously; forward to EMT */
    1711     int rc = VMR3ReqCallVoidNoWait(PDMDevHlpGetVM(pThis->pDevInsR3), VMCPUID_ANY,
     1719    int rc = VMR3ReqCallVoidNoWait(PDMDevHlpGetVM(pDevIns), VMCPUID_ANY,
    17121720                                   (PFNRT)hgcmCompletedWorker, 3, pInterface, result, pCmd);
    17131721    AssertRC(rc);
     
    17231731 * @interface_method_impl{PDMIHGCMPORT,pfnIsCmdRestored}
    17241732 */
    1725 DECLCALLBACK(bool) hgcmIsCmdRestored(PPDMIHGCMPORT pInterface, PVBOXHGCMCMD pCmd)
     1733DECLCALLBACK(bool) hgcmR3IsCmdRestored(PPDMIHGCMPORT pInterface, PVBOXHGCMCMD pCmd)
    17261734{
    17271735    RT_NOREF(pInterface);
     
    17321740 * @interface_method_impl{PDMIHGCMPORT,pfnIsCmdCancelled}
    17331741 */
    1734 DECLCALLBACK(bool) hgcmIsCmdCancelled(PPDMIHGCMPORT pInterface, PVBOXHGCMCMD pCmd)
     1742DECLCALLBACK(bool) hgcmR3IsCmdCancelled(PPDMIHGCMPORT pInterface, PVBOXHGCMCMD pCmd)
    17351743{
    17361744    RT_NOREF(pInterface);
     
    17411749 * @interface_method_impl{PDMIHGCMPORT,pfnGetRequestor}
    17421750 */
    1743 DECLCALLBACK(uint32_t) hgcmGetRequestor(PPDMIHGCMPORT pInterface, PVBOXHGCMCMD pCmd)
    1744 {
    1745     PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IHGCMPort);
     1751DECLCALLBACK(uint32_t) hgcmR3GetRequestor(PPDMIHGCMPORT pInterface, PVBOXHGCMCMD pCmd)
     1752{
     1753    PVMMDEVCC pThisCC = RT_FROM_MEMBER(pInterface, VMMDEVCC, IHGCMPort);
     1754    PVMMDEV   pThis   = PDMDEVINS_2_DATA(pThisCC->pDevIns, PVMMDEV);
    17461755    AssertPtrReturn(pCmd, VMMDEV_REQUESTOR_LOWEST);
    17471756    if (pThis->guestInfo2.fFeatures & VBOXGSTINFO2_F_REQUESTOR_INFO)
     
    17531762 * @interface_method_impl{PDMIHGCMPORT,pfnGetVMMDevSessionId}
    17541763 */
    1755 DECLCALLBACK(uint64_t) hgcmGetVMMDevSessionId(PPDMIHGCMPORT pInterface)
    1756 {
    1757     PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IHGCMPort);
     1764DECLCALLBACK(uint64_t) hgcmR3GetVMMDevSessionId(PPDMIHGCMPORT pInterface)
     1765{
     1766    PVMMDEVCC pThisCC = RT_FROM_MEMBER(pInterface, VMMDEVCC, IHGCMPort);
     1767    PVMMDEV   pThis   = PDMDEVINS_2_DATA(pThisCC->pDevIns, PVMMDEV);
    17581768    return pThis->idSession;
    17591769}
    17601770
    1761 /** Save information about pending HGCM requests from pThis->listHGCMCmd.
     1771/** Save information about pending HGCM requests from pThisCC->listHGCMCmd.
    17621772 *
    17631773 * @returns VBox status code that the guest should see.
    1764  * @param   pThis           The VMMDev instance data.
     1774 * @param   pThisCC         The VMMDev ring-3 instance data.
    17651775 * @param   pSSM            SSM handle for SSM functions.
    17661776 *
    17671777 * @thread EMT
    17681778 */
    1769 int vmmdevHGCMSaveState(PVMMDEV pThis, PSSMHANDLE pSSM)
     1779int vmmdevR3HgcmSaveState(PVMMDEVCC pThisCC, PSSMHANDLE pSSM)
    17701780{
    17711781    LogFlowFunc(("\n"));
     
    17741784    uint32_t cCmds = 0;
    17751785    PVBOXHGCMCMD pCmd;
    1776     RTListForEach(&pThis->listHGCMCmd, pCmd, VBOXHGCMCMD, node)
     1786    RTListForEach(&pThisCC->listHGCMCmd, pCmd, VBOXHGCMCMD, node)
    17771787    {
    17781788        LogFlowFunc(("pCmd %p\n", pCmd));
     
    17871797    if (cCmds > 0)
    17881798    {
    1789         RTListForEach(&pThis->listHGCMCmd, pCmd, VBOXHGCMCMD, node)
     1799        RTListForEach(&pThisCC->listHGCMCmd, pCmd, VBOXHGCMCMD, node)
    17901800        {
    17911801            LogFlowFunc(("Saving %RGp, size %d\n", pCmd->GCPhys, pCmd->cbRequest));
     
    18841894/** Load information about pending HGCM requests.
    18851895 *
    1886  * Allocate VBOXHGCMCMD commands and add them to pThis->listHGCMCmd temporarily.
    1887  * vmmdevHGCMLoadStateDone will process the temporary list.  This includes
    1888  * loading the correct fRequestor fields.
     1896 * Allocate VBOXHGCMCMD commands and add them to pThisCC->listHGCMCmd
     1897 * temporarily. vmmdevR3HgcmLoadStateDone will process the temporary list.  This
     1898 * includes loading the correct fRequestor fields.
    18891899 *
    18901900 * @returns VBox status code that the guest should see.
    1891  * @param   pThis           The VMMDev instance data.
     1901 * @param   pDevIns         The device instance.
     1902 * @param   pThis           The VMMDev shared instance data.
     1903 * @param   pThisCC         The VMMDev ring-3 instance data.
    18921904 * @param   pSSM            SSM handle for SSM functions.
    18931905 * @param   uVersion        Saved state version.
     
    18951907 * @thread EMT
    18961908 */
    1897 int vmmdevHGCMLoadState(PVMMDEV pThis, PSSMHANDLE pSSM, uint32_t uVersion)
     1909int vmmdevR3HgcmLoadState(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC, PSSMHANDLE pSSM, uint32_t uVersion)
    18981910{
    18991911    LogFlowFunc(("\n"));
    19001912
    1901     pThis->u32SSMVersion = uVersion; /* For vmmdevHGCMLoadStateDone */
     1913    pThisCC->uSavedStateVersion = uVersion; /* For vmmdevR3HgcmLoadStateDone */
    19021914
    19031915    /* Read how many commands were pending. */
     
    19341946            AssertRCReturn(rc, rc);
    19351947
    1936             PVBOXHGCMCMD pCmd = vmmdevHGCMCmdAlloc(pThis, enmCmdType, GCPhys, cbRequest, cParms, 0 /*fRequestor*/);
     1948            PVBOXHGCMCMD pCmd = vmmdevR3HgcmCmdAlloc(pThisCC, enmCmdType, GCPhys, cbRequest, cParms, 0 /*fRequestor*/);
    19371949            AssertReturn(pCmd, VERR_NO_MEMORY);
    19381950
     
    20412053            /* See current version above. */
    20422054            if (!fCancelled)
    2043                 vmmdevHGCMAddCommand(pThis, pCmd);
     2055                vmmdevR3HgcmAddCommand(pDevIns, pThis, pThisCC, pCmd);
    20442056            else
    20452057            {
    2046                 Log(("vmmdevHGCMLoadState: Skipping cancelled request: enmCmdType=%d GCPhys=%#RX32 LB %#x\n",
     2058                Log(("vmmdevR3HgcmLoadState: Skipping cancelled request: enmCmdType=%d GCPhys=%#RX32 LB %#x\n",
    20472059                     enmCmdType, GCPhys, cbRequest));
    2048                 vmmdevHGCMCmdFree(pThis, pCmd);
     2060                vmmdevR3HgcmCmdFree(pDevIns, pThisCC, pCmd);
    20492061            }
    20502062        }
     
    20752087
    20762088            /* For uVersion <= 12, this was the size of entire command.
    2077              * Now the command is reconstructed in vmmdevHGCMLoadStateDone.
     2089             * Now the command is reconstructed in vmmdevR3HgcmLoadStateDone.
    20782090             */
    20792091            if (uVersion <= 12)
     
    20872099            AssertRCReturn(rc, rc);
    20882100
    2089             PVBOXHGCMCMD pCmd = vmmdevHGCMCmdAlloc(pThis, enmCmdType, GCPhys, cbRequest, cLinAddrs, 0 /*fRequestor*/);
     2101            PVBOXHGCMCMD pCmd = vmmdevR3HgcmCmdAlloc(pThisCC, enmCmdType, GCPhys, cbRequest, cLinAddrs, 0 /*fRequestor*/);
    20902102            AssertReturn(pCmd, VERR_NO_MEMORY);
    20912103
     
    21252137            /* See current version above. */
    21262138            if (!fCancelled)
    2127                 vmmdevHGCMAddCommand(pThis, pCmd);
     2139                vmmdevR3HgcmAddCommand(pDevIns, pThis, pThisCC, pCmd);
    21282140            else
    21292141            {
    2130                 Log(("vmmdevHGCMLoadState: Skipping cancelled request: enmCmdType=%d GCPhys=%#RX32 LB %#x\n",
     2142                Log(("vmmdevR3HgcmLoadState: Skipping cancelled request: enmCmdType=%d GCPhys=%#RX32 LB %#x\n",
    21312143                     enmCmdType, GCPhys, cbRequest));
    2132                 vmmdevHGCMCmdFree(pThis, pCmd);
     2144                vmmdevR3HgcmCmdFree(pDevIns, pThisCC, pCmd);
    21332145            }
    21342146        }
     
    21532165            LogFlowFunc(("Restoring %RGp size %x bytes\n", GCPhys, cbRequest));
    21542166
    2155             PVBOXHGCMCMD pCmd = vmmdevHGCMCmdAlloc(pThis, VBOXHGCMCMDTYPE_LOADSTATE, GCPhys, cbRequest, 0, 0 /*fRequestor*/);
     2167            PVBOXHGCMCMD pCmd = vmmdevR3HgcmCmdAlloc(pThisCC, VBOXHGCMCMDTYPE_LOADSTATE, GCPhys, cbRequest, 0, 0 /*fRequestor*/);
    21562168            AssertReturn(pCmd, VERR_NO_MEMORY);
    21572169
    2158             vmmdevHGCMAddCommand(pThis, pCmd);
     2170            vmmdevR3HgcmAddCommand(pDevIns, pThis, pThisCC, pCmd);
    21592171        }
    21602172    }
     
    21662178 *
    21672179 * @returns VBox status code that the guest should see.
    2168  * @param   pThis           The VMMDev instance data.
    2169  * @param   u32SSMVersion   The saved state version the command has been loaded from.
     2180 * @param   pThisCC         The VMMDev ring-3 instance data.
     2181 * @param   uSavedStateVersion   The saved state version the command has been loaded from.
    21702182 * @param   pLoadedCmd      Command loaded from saved state, it is imcomplete and needs restoration.
    21712183 * @param   pReq            The guest request (cached in host memory).
     
    21742186 * @param   ppRestoredCmd   Where to store pointer to newly allocated restored command.
    21752187 */
    2176 static int vmmdevHGCMRestoreConnect(PVMMDEV pThis, uint32_t u32SSMVersion, const VBOXHGCMCMD *pLoadedCmd,
    2177                                     VMMDevHGCMConnect *pReq, uint32_t cbReq, VMMDevRequestType enmRequestType,
    2178                                     VBOXHGCMCMD **ppRestoredCmd)
    2179 {
    2180     RT_NOREF(pThis);
    2181 
    2182     int rc = VINF_SUCCESS;
    2183 
     2188static int vmmdevR3HgcmRestoreConnect(PVMMDEVCC pThisCC, uint32_t uSavedStateVersion, const VBOXHGCMCMD *pLoadedCmd,
     2189                                      VMMDevHGCMConnect *pReq, uint32_t cbReq, VMMDevRequestType enmRequestType,
     2190                                      VBOXHGCMCMD **ppRestoredCmd)
     2191{
    21842192    /* Verify the request.  */
    21852193    ASSERT_GUEST_RETURN(cbReq >= sizeof(*pReq), VERR_MISMATCH);
    2186     if (u32SSMVersion >= 9)
     2194    if (uSavedStateVersion >= 9)
    21872195        ASSERT_GUEST_RETURN(pLoadedCmd->enmCmdType == VBOXHGCMCMDTYPE_CONNECT, VERR_MISMATCH);
    21882196
    2189     PVBOXHGCMCMD pCmd = vmmdevHGCMCmdAlloc(pThis, VBOXHGCMCMDTYPE_CONNECT, pLoadedCmd->GCPhys, cbReq, 0,
    2190                                            pReq->header.header.fRequestor);
     2197    PVBOXHGCMCMD pCmd = vmmdevR3HgcmCmdAlloc(pThisCC, VBOXHGCMCMDTYPE_CONNECT, pLoadedCmd->GCPhys, cbReq, 0,
     2198                                             pReq->header.header.fRequestor);
    21912199    AssertReturn(pCmd, VERR_NO_MEMORY);
    21922200
     
    21962204    pCmd->enmRequestType = enmRequestType;
    21972205
    2198     vmmdevHGCMConnectFetch(pReq, pCmd);
    2199 
    2200     if (RT_SUCCESS(rc))
    2201         *ppRestoredCmd = pCmd;
    2202 
    2203     return rc;
     2206    vmmdevR3HgcmConnectFetch(pReq, pCmd);
     2207
     2208    *ppRestoredCmd = pCmd;
     2209    return VINF_SUCCESS;
    22042210}
    22052211
     
    22072213 *
    22082214 * @returns VBox status code that the guest should see.
    2209  * @param   pThis           The VMMDev instance data.
    2210  * @param   u32SSMVersion   The saved state version the command has been loaded from.
     2215 * @param   pThisCC         The VMMDev ring-3 instance data.
     2216 * @param   uSavedStateVersion   The saved state version the command has been loaded from.
    22112217 * @param   pLoadedCmd      Command loaded from saved state, it is imcomplete and needs restoration.
    22122218 * @param   pReq            The guest request (cached in host memory).
     
    22152221 * @param   ppRestoredCmd   Where to store pointer to newly allocated restored command.
    22162222 */
    2217 static int vmmdevHGCMRestoreDisconnect(PVMMDEV pThis, uint32_t u32SSMVersion, const VBOXHGCMCMD *pLoadedCmd,
    2218                                        VMMDevHGCMDisconnect *pReq, uint32_t cbReq, VMMDevRequestType enmRequestType,
    2219                                        VBOXHGCMCMD **ppRestoredCmd)
    2220 {
    2221     RT_NOREF(pThis);
    2222 
    2223     int rc = VINF_SUCCESS;
    2224 
     2223static int vmmdevR3HgcmRestoreDisconnect(PVMMDEVCC pThisCC, uint32_t uSavedStateVersion, const VBOXHGCMCMD *pLoadedCmd,
     2224                                         VMMDevHGCMDisconnect *pReq, uint32_t cbReq, VMMDevRequestType enmRequestType,
     2225                                         VBOXHGCMCMD **ppRestoredCmd)
     2226{
    22252227    /* Verify the request.  */
    22262228    ASSERT_GUEST_RETURN(cbReq >= sizeof(*pReq), VERR_MISMATCH);
    2227     if (u32SSMVersion >= 9)
     2229    if (uSavedStateVersion >= 9)
    22282230        ASSERT_GUEST_RETURN(pLoadedCmd->enmCmdType == VBOXHGCMCMDTYPE_DISCONNECT, VERR_MISMATCH);
    22292231
    2230     PVBOXHGCMCMD pCmd = vmmdevHGCMCmdAlloc(pThis, VBOXHGCMCMDTYPE_DISCONNECT, pLoadedCmd->GCPhys, cbReq, 0,
    2231                                            pReq->header.header.fRequestor);
     2232    PVBOXHGCMCMD pCmd = vmmdevR3HgcmCmdAlloc(pThisCC, VBOXHGCMCMDTYPE_DISCONNECT, pLoadedCmd->GCPhys, cbReq, 0,
     2233                                             pReq->header.header.fRequestor);
    22322234    AssertReturn(pCmd, VERR_NO_MEMORY);
    22332235
     
    22372239    pCmd->enmRequestType = enmRequestType;
    22382240
    2239     vmmdevHGCMDisconnectFetch(pReq, pCmd);
    2240 
    2241     if (RT_SUCCESS(rc))
    2242         *ppRestoredCmd = pCmd;
    2243 
    2244     return rc;
     2241    vmmdevR3HgcmDisconnectFetch(pReq, pCmd);
     2242
     2243    *ppRestoredCmd = pCmd;
     2244    return VINF_SUCCESS;
    22452245}
    22462246
     
    22482248 *
    22492249 * @returns VBox status code that the guest should see.
    2250  * @param   pThis           The VMMDev instance data.
    2251  * @param   u32SSMVersion   The saved state version the command has been loaded from.
     2250 * @param   pDevIns         The device instance.
     2251 * @param   pThisCC         The VMMDev ring-3 instance data.
     2252 * @param   uSavedStateVersion   The saved state version the command has been loaded from.
    22522253 * @param   pLoadedCmd      Command loaded from saved state, it is imcomplete and needs restoration.
    22532254 * @param   pReq            The guest request (cached in host memory).
     
    22562257 * @param   ppRestoredCmd   Where to store pointer to newly allocated restored command.
    22572258 */
    2258 static int vmmdevHGCMRestoreCall(PVMMDEV pThis, uint32_t u32SSMVersion, const VBOXHGCMCMD *pLoadedCmd,
    2259                                  VMMDevHGCMCall *pReq, uint32_t cbReq, VMMDevRequestType enmRequestType,
    2260                                  VBOXHGCMCMD **ppRestoredCmd)
    2261 {
    2262     int rc = VINF_SUCCESS;
    2263 
     2259static int vmmdevR3HgcmRestoreCall(PPDMDEVINS pDevIns, PVMMDEVCC pThisCC, uint32_t uSavedStateVersion, const VBOXHGCMCMD *pLoadedCmd,
     2260                                   VMMDevHGCMCall *pReq, uint32_t cbReq, VMMDevRequestType enmRequestType,
     2261                                   VBOXHGCMCMD **ppRestoredCmd)
     2262{
    22642263    /* Verify the request.  */
    22652264    ASSERT_GUEST_RETURN(cbReq >= sizeof(*pReq), VERR_MISMATCH);
    2266     if (u32SSMVersion >= 9)
     2265    if (uSavedStateVersion >= 9)
    22672266    {
    22682267        ASSERT_GUEST_RETURN(pLoadedCmd->enmCmdType == VBOXHGCMCMDTYPE_CALL, VERR_MISMATCH);
     
    22722271    PVBOXHGCMCMD pCmd;
    22732272    uint32_t cbHGCMParmStruct;
    2274     rc = vmmdevHGCMCallAlloc(pThis, pReq, cbReq, pLoadedCmd->GCPhys, enmRequestType, &pCmd, &cbHGCMParmStruct);
     2273    int rc = vmmdevR3HgcmCallAlloc(pThisCC, pReq, cbReq, pLoadedCmd->GCPhys, enmRequestType, &pCmd, &cbHGCMParmStruct);
    22752274    if (RT_FAILURE(rc))
    22762275        return rc;
     
    22812280    pCmd->enmRequestType = enmRequestType;
    22822281
    2283     rc = vmmdevHGCMCallFetchGuestParms(pThis, pCmd, pReq, cbReq, enmRequestType, cbHGCMParmStruct);
     2282    rc = vmmdevR3HgcmCallFetchGuestParms(pDevIns, pThisCC, pCmd, pReq, cbReq, enmRequestType, cbHGCMParmStruct);
    22842283    if (RT_SUCCESS(rc))
    22852284    {
    22862285        /* Update LinAddr parameters from pLoadedCmd.
    2287          * pLoadedCmd->u.call.cParms is actually the number of LinAddrs, see vmmdevHGCMLoadState.
     2286         * pLoadedCmd->u.call.cParms is actually the number of LinAddrs, see vmmdevR3HgcmLoadState.
    22882287         */
    22892288        uint32_t iLinAddr;
     
    22912290        {
    22922291            VBOXHGCMGUESTPARM * const pLoadedParm = &pLoadedCmd->u.call.paGuestParms[iLinAddr];
    2293             /* pLoadedParm->cbData is actually index of the LinAddr parameter, see vmmdevHGCMLoadState. */
     2292            /* pLoadedParm->cbData is actually index of the LinAddr parameter, see vmmdevR3HgcmLoadState. */
    22942293            const uint32_t iParm = pLoadedParm->u.ptr.cbData;
    22952294            ASSERT_GUEST_STMT_BREAK(iParm < pCmd->u.call.cParms, rc = VERR_MISMATCH);
     
    23102309        *ppRestoredCmd = pCmd;
    23112310    else
    2312         vmmdevHGCMCmdFree(pThis, pCmd);
     2311        vmmdevR3HgcmCmdFree(pDevIns, pThisCC, pCmd);
    23132312
    23142313    return rc;
     
    23192318 *
    23202319 * @returns VBox status code that the guest should see.
    2321  * @param   pThis           The VMMDev instance data.
    2322  * @param   u32SSMVersion   Saved state version.
     2320 * @param   pDevIns         The device instance.
     2321 * @param   pThisCC         The VMMDev ring-3 instance data.
     2322 * @param   uSavedStateVersion   Saved state version.
    23232323 * @param   pLoadedCmd      HGCM command which needs restoration.
    23242324 * @param   pReqHdr         The request (cached in host memory).
     
    23262326 * @param   ppRestoredCmd   Where to store pointer to restored command.
    23272327 */
    2328 static int vmmdevHGCMRestoreCommand(PVMMDEV pThis, uint32_t u32SSMVersion, const VBOXHGCMCMD *pLoadedCmd,
    2329                                     const VMMDevHGCMRequestHeader *pReqHdr, uint32_t cbReq,
    2330                                     VBOXHGCMCMD **ppRestoredCmd)
    2331 {
    2332     int rc = VINF_SUCCESS;
     2328static int vmmdevR3HgcmRestoreCommand(PPDMDEVINS pDevIns, PVMMDEVCC pThisCC, uint32_t uSavedStateVersion,
     2329                                      const VBOXHGCMCMD *pLoadedCmd, const VMMDevHGCMRequestHeader *pReqHdr, uint32_t cbReq,
     2330                                      VBOXHGCMCMD **ppRestoredCmd)
     2331{
     2332    int rc;
    23332333
    23342334    /* Verify the request.  */
     
    23422342        {
    23432343            VMMDevHGCMConnect *pReq = (VMMDevHGCMConnect *)pReqHdr;
    2344             rc = vmmdevHGCMRestoreConnect(pThis, u32SSMVersion, pLoadedCmd, pReq, cbReq, enmRequestType,
    2345                                           ppRestoredCmd);
     2344            rc = vmmdevR3HgcmRestoreConnect(pThisCC, uSavedStateVersion, pLoadedCmd, pReq, cbReq, enmRequestType, ppRestoredCmd);
    23462345            break;
    23472346        }
     
    23502349        {
    23512350            VMMDevHGCMDisconnect *pReq = (VMMDevHGCMDisconnect *)pReqHdr;
    2352             rc = vmmdevHGCMRestoreDisconnect(pThis, u32SSMVersion, pLoadedCmd, pReq, cbReq, enmRequestType,
    2353                                              ppRestoredCmd);
     2351            rc = vmmdevR3HgcmRestoreDisconnect(pThisCC, uSavedStateVersion, pLoadedCmd, pReq, cbReq, enmRequestType, ppRestoredCmd);
    23542352            break;
    23552353        }
     
    23612359        {
    23622360            VMMDevHGCMCall *pReq = (VMMDevHGCMCall *)pReqHdr;
    2363             rc = vmmdevHGCMRestoreCall(pThis, u32SSMVersion, pLoadedCmd, pReq, cbReq, enmRequestType,
    2364                                        ppRestoredCmd);
     2361            rc = vmmdevR3HgcmRestoreCall(pDevIns, pThisCC, uSavedStateVersion, pLoadedCmd, pReq, cbReq, enmRequestType, ppRestoredCmd);
    23652362            break;
    23662363        }
     
    23762373 *
    23772374 * @returns VBox status code.
    2378  * @param   pThis           The VMMDev instance data.
     2375 * @param   pDevIns         The device instance.
     2376 * @param   pThis           The VMMDev shared instance data.
     2377 * @param   pThisCC         The VMMDev ring-3 instance data.
    23792378 *
    23802379 * @thread EMT
    23812380 */
    2382 int vmmdevHGCMLoadStateDone(PVMMDEV pThis)
     2381int vmmdevR3HgcmLoadStateDone(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC)
    23832382{
    23842383    /*
    23852384     * Resubmit pending HGCM commands to services.
    23862385     *
    2387      * pThis->pHGCMCmdList contains commands loaded by vmmdevHGCMLoadState.
     2386     * pThisCC->pHGCMCmdList contains commands loaded by vmmdevR3HgcmLoadState.
    23882387     *
    23892388     * Legacy saved states (pre VMMDEV_SAVED_STATE_VERSION_HGCM_PARAMS)
     
    24032402    /* Get local copy of the list of loaded commands. */
    24042403    RTLISTANCHOR listLoadedCommands;
    2405     RTListMove(&listLoadedCommands, &pThis->listHGCMCmd);
     2404    RTListMove(&listLoadedCommands, &pThisCC->listHGCMCmd);
    24062405
    24072406    /* Resubmit commands. */
     
    24202419         */
    24212420        VMMDevHGCMRequestHeader *pReqHdr = (VMMDevHGCMRequestHeader *)RTMemAlloc(pCmd->cbRequest);
    2422         AssertBreakStmt(pReqHdr, vmmdevHGCMCmdFree(pThis, pCmd); rcFunc = VERR_NO_MEMORY);
    2423 
    2424         PDMDevHlpPhysRead(pThis->pDevInsR3, pCmd->GCPhys, pReqHdr, pCmd->cbRequest);
     2421        AssertBreakStmt(pReqHdr, vmmdevR3HgcmCmdFree(pDevIns, pThisCC, pCmd); rcFunc = VERR_NO_MEMORY);
     2422
     2423        PDMDevHlpPhysRead(pDevIns, pCmd->GCPhys, pReqHdr, pCmd->cbRequest);
    24252424        RT_UNTRUSTED_NONVOLATILE_COPY_FENCE();
    24262425
    2427         if (pThis->pHGCMDrv)
     2426        if (pThisCC->pHGCMDrv)
    24282427        {
    24292428            /*
    24302429             * Reconstruct legacy commands.
    24312430             */
    2432             if (RT_LIKELY(   pThis->u32SSMVersion >= VMMDEV_SAVED_STATE_VERSION_HGCM_PARAMS
     2431            if (RT_LIKELY(   pThisCC->uSavedStateVersion >= VMMDEV_SAVED_STATE_VERSION_HGCM_PARAMS
    24332432                          && !pCmd->fRestoreFromGuestMem))
    24342433            { /* likely */ }
     
    24362435            {
    24372436                PVBOXHGCMCMD pRestoredCmd = NULL;
    2438                 rcCmd = vmmdevHGCMRestoreCommand(pThis, pThis->u32SSMVersion, pCmd,
    2439                                                  pReqHdr, pCmd->cbRequest, &pRestoredCmd);
     2437                rcCmd = vmmdevR3HgcmRestoreCommand(pDevIns, pThisCC, pThisCC->uSavedStateVersion, pCmd,
     2438                                                   pReqHdr, pCmd->cbRequest, &pRestoredCmd);
    24402439                if (RT_SUCCESS(rcCmd))
    24412440                {
    2442                     Assert(pCmd != pRestoredCmd); /* vmmdevHGCMRestoreCommand must allocate restored command. */
    2443                     vmmdevHGCMCmdFree(pThis, pCmd);
     2441                    Assert(pCmd != pRestoredCmd); /* vmmdevR3HgcmRestoreCommand must allocate restored command. */
     2442                    vmmdevR3HgcmCmdFree(pDevIns, pThisCC, pCmd);
    24442443                    pCmd = pRestoredCmd;
    24452444                }
     
    24532452                    case VBOXHGCMCMDTYPE_CONNECT:
    24542453                    {
    2455                         vmmdevHGCMAddCommand(pThis, pCmd);
    2456                         rcCmd = pThis->pHGCMDrv->pfnConnect(pThis->pHGCMDrv, pCmd, pCmd->u.connect.pLoc,
    2457                                                             &pCmd->u.connect.u32ClientID);
     2454                        vmmdevR3HgcmAddCommand(pDevIns, pThis, pThisCC, pCmd);
     2455                        rcCmd = pThisCC->pHGCMDrv->pfnConnect(pThisCC->pHGCMDrv, pCmd, pCmd->u.connect.pLoc,
     2456                                                              &pCmd->u.connect.u32ClientID);
    24582457                        if (RT_FAILURE(rcCmd))
    2459                             vmmdevHGCMRemoveCommand(pThis, pCmd);
     2458                            vmmdevR3HgcmRemoveCommand(pThisCC, pCmd);
    24602459                        break;
    24612460                    }
     
    24632462                    case VBOXHGCMCMDTYPE_DISCONNECT:
    24642463                    {
    2465                         vmmdevHGCMAddCommand(pThis, pCmd);
    2466                         rcCmd = pThis->pHGCMDrv->pfnDisconnect(pThis->pHGCMDrv, pCmd, pCmd->u.disconnect.u32ClientID);
     2464                        vmmdevR3HgcmAddCommand(pDevIns, pThis, pThisCC, pCmd);
     2465                        rcCmd = pThisCC->pHGCMDrv->pfnDisconnect(pThisCC->pHGCMDrv, pCmd, pCmd->u.disconnect.u32ClientID);
    24672466                        if (RT_FAILURE(rcCmd))
    2468                             vmmdevHGCMRemoveCommand(pThis, pCmd);
     2467                            vmmdevR3HgcmRemoveCommand(pThisCC, pCmd);
    24692468                        break;
    24702469                    }
     
    24722471                    case VBOXHGCMCMDTYPE_CALL:
    24732472                    {
    2474                         rcCmd = vmmdevHGCMInitHostParameters(pThis, pCmd, (uint8_t const *)pReqHdr);
     2473                        rcCmd = vmmdevR3HgcmInitHostParameters(pDevIns, pCmd, (uint8_t const *)pReqHdr);
    24752474                        if (RT_SUCCESS(rcCmd))
    24762475                        {
    2477                             vmmdevHGCMAddCommand(pThis, pCmd);
     2476                            vmmdevR3HgcmAddCommand(pDevIns, pThis, pThisCC, pCmd);
    24782477
    24792478                            /* Pass the function call to HGCM connector for actual processing */
    24802479                            uint64_t tsNow;
    24812480                            STAM_GET_TS(tsNow);
    2482                             rcCmd = pThis->pHGCMDrv->pfnCall(pThis->pHGCMDrv, pCmd,
    2483                                                              pCmd->u.call.u32ClientID, pCmd->u.call.u32Function,
    2484                                                              pCmd->u.call.cParms, pCmd->u.call.paHostParms, tsNow);
     2481                            rcCmd = pThisCC->pHGCMDrv->pfnCall(pThisCC->pHGCMDrv, pCmd,
     2482                                                               pCmd->u.call.u32ClientID, pCmd->u.call.u32Function,
     2483                                                               pCmd->u.call.cParms, pCmd->u.call.paHostParms, tsNow);
    24852484                            if (RT_FAILURE(rcCmd))
    24862485                            {
    24872486                                LogFunc(("pfnCall rc = %Rrc\n", rcCmd));
    2488                                 vmmdevHGCMRemoveCommand(pThis, pCmd);
     2487                                vmmdevR3HgcmRemoveCommand(pThisCC, pCmd);
    24892488                            }
    24902489                        }
     
    25102509
    25112510            /* Write back only the header. */
    2512             PDMDevHlpPhysWrite(pThis->pDevInsR3, pCmd->GCPhys, pReqHdr, sizeof(*pReqHdr));
    2513 
    2514             VMMDevNotifyGuest(pThis, VMMDEV_EVENT_HGCM);
     2511            PDMDevHlpPhysWrite(pDevIns, pCmd->GCPhys, pReqHdr, sizeof(*pReqHdr));
     2512
     2513            VMMDevNotifyGuest(pDevIns, pThis, pThisCC, VMMDEV_EVENT_HGCM);
    25152514
    25162515            /* Deallocate the command memory. */
    2517             vmmdevHGCMCmdFree(pThis, pCmd);
     2516            vmmdevR3HgcmCmdFree(pDevIns, pThisCC, pCmd);
    25182517        }
    25192518
     
    25262525        {
    25272526            RTListNodeRemove(&pCmd->node);
    2528             vmmdevHGCMCmdFree(pThis, pCmd);
     2527            vmmdevR3HgcmCmdFree(pDevIns, pThisCC, pCmd);
    25292528        }
    25302529    }
     
    25352534
    25362535/**
    2537  * Counterpart to vmmdevHGCMInit().
    2538  *
    2539  * @param   pThis           The VMMDev instance data.
    2540  */
    2541 void vmmdevHGCMDestroy(PVMMDEV pThis)
     2536 * Counterpart to vmmdevR3HgcmInit().
     2537 *
     2538 * @param   pDevIns         The device instance.
     2539 * @param   pThisCC         The VMMDev ring-3 instance data.
     2540 */
     2541void vmmdevR3HgcmDestroy(PPDMDEVINS pDevIns, PVMMDEVCC pThisCC)
    25422542{
    25432543    LogFlowFunc(("\n"));
    25442544
    2545     if (RTCritSectIsInitialized(&pThis->critsectHGCMCmdList))
     2545    if (RTCritSectIsInitialized(&pThisCC->critsectHGCMCmdList))
    25462546    {
    25472547        PVBOXHGCMCMD pCmd, pNext;
    2548         RTListForEachSafe(&pThis->listHGCMCmd, pCmd, pNext, VBOXHGCMCMD, node)
    2549         {
    2550             vmmdevHGCMRemoveCommand(pThis, pCmd);
    2551             vmmdevHGCMCmdFree(pThis, pCmd);
     2548        RTListForEachSafe(&pThisCC->listHGCMCmd, pCmd, pNext, VBOXHGCMCMD, node)
     2549        {
     2550            vmmdevR3HgcmRemoveCommand(pThisCC, pCmd);
     2551            vmmdevR3HgcmCmdFree(pDevIns, pThisCC, pCmd);
    25522552        }
    25532553
    2554         RTCritSectDelete(&pThis->critsectHGCMCmdList);
     2554        RTCritSectDelete(&pThisCC->critsectHGCMCmdList);
    25552555    }
    25562556
    25572557    AssertCompile(NIL_RTMEMCACHE == (RTMEMCACHE)0);
    2558     if (pThis->hHgcmCmdCache != NIL_RTMEMCACHE)
    2559     {
    2560         RTMemCacheDestroy(pThis->hHgcmCmdCache);
    2561         pThis->hHgcmCmdCache = NIL_RTMEMCACHE;
     2558    if (pThisCC->hHgcmCmdCache != NIL_RTMEMCACHE)
     2559    {
     2560        RTMemCacheDestroy(pThisCC->hHgcmCmdCache);
     2561        pThisCC->hHgcmCmdCache = NIL_RTMEMCACHE;
    25622562    }
    25632563}
     
    25702570 *
    25712571 * @returns VBox status code.
    2572  * @param   pThis           The VMMDev instance data.
    2573  */
    2574 int vmmdevHGCMInit(PVMMDEV pThis)
     2572 * @param   pThisCC         The VMMDev ring-3 instance data.
     2573 */
     2574int vmmdevR3HgcmInit(PVMMDEVCC pThisCC)
    25752575{
    25762576    LogFlowFunc(("\n"));
    25772577
    2578     RTListInit(&pThis->listHGCMCmd);
    2579 
    2580     int rc = RTCritSectInit(&pThis->critsectHGCMCmdList);
     2578    RTListInit(&pThisCC->listHGCMCmd);
     2579
     2580    int rc = RTCritSectInit(&pThisCC->critsectHGCMCmdList);
    25812581    AssertLogRelRCReturn(rc, rc);
    25822582
    2583     rc = RTMemCacheCreate(&pThis->hHgcmCmdCache, sizeof(VBOXHGCMCMDCACHED), 64, _1M, NULL, NULL, NULL, 0);
     2583    rc = RTMemCacheCreate(&pThisCC->hHgcmCmdCache, sizeof(VBOXHGCMCMDCACHED), 64, _1M, NULL, NULL, NULL, 0);
    25842584    AssertLogRelRCReturn(rc, rc);
    25852585
    2586     pThis->u32HGCMEnabled = 0;
     2586    pThisCC->u32HGCMEnabled = 0;
    25872587
    25882588    return VINF_SUCCESS;
  • trunk/src/VBox/Devices/VMMDev/VMMDevHGCM.h

    r81571 r81625  
    2525
    2626RT_C_DECLS_BEGIN
    27 int vmmdevHGCMConnect(PVMMDEV pVMMDevState, const VMMDevHGCMConnect *pHGCMConnect, RTGCPHYS GCPtr);
    28 int vmmdevHGCMDisconnect(PVMMDEV pVMMDevState, const VMMDevHGCMDisconnect *pHGCMDisconnect, RTGCPHYS GCPtr);
    29 int vmmdevHGCMCall(PVMMDEV pVMMDevState, const VMMDevHGCMCall *pHGCMCall, uint32_t cbHGCMCall, RTGCPHYS GCPtr,
    30                    VMMDevRequestType enmRequestType, uint64_t tsArrival, PVMMDEVREQLOCK *ppLock);
    31 int vmmdevHGCMCancel(PVMMDEV pVMMDevState, const VMMDevHGCMCancel *pHGCMCancel, RTGCPHYS GCPtr);
    32 int vmmdevHGCMCancel2(PVMMDEV pVMMDevState, RTGCPHYS GCPtr);
     27int  vmmdevR3HgcmConnect(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC,
     28                         const VMMDevHGCMConnect *pHGCMConnect, RTGCPHYS GCPhys);
     29int  vmmdevR3HgcmDisconnect(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC,
     30                            const VMMDevHGCMDisconnect *pHGCMDisconnect, RTGCPHYS GCPhys);
     31int  vmmdevR3HgcmCall(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC, const VMMDevHGCMCall *pHGCMCall, uint32_t cbHGCMCall,
     32                      RTGCPHYS GCPhys, VMMDevRequestType enmRequestType, uint64_t tsArrival, PVMMDEVREQLOCK *ppLock);
    3333
    34 DECLCALLBACK(int)  hgcmCompleted(PPDMIHGCMPORT pInterface, int32_t result, PVBOXHGCMCMD pCmdPtr);
    35 DECLCALLBACK(bool) hgcmIsCmdRestored(PPDMIHGCMPORT pInterface, PVBOXHGCMCMD pCmd);
    36 DECLCALLBACK(bool) hgcmIsCmdCancelled(PPDMIHGCMPORT pInterface, PVBOXHGCMCMD pCmd);
    37 DECLCALLBACK(uint32_t) hgcmGetRequestor(PPDMIHGCMPORT pInterface, PVBOXHGCMCMD pCmd);
    38 DECLCALLBACK(uint64_t) hgcmGetVMMDevSessionId(PPDMIHGCMPORT pInterface);
     34int  vmmdevR3HgcmCancel(PVMMDEVCC pThisCC, const VMMDevHGCMCancel *pHGCMCancel, RTGCPHYS GCPhys);
     35int  vmmdevR3HgcmCancel2(PVMMDEVCC pThisCC, RTGCPHYS GCPhys);
    3936
    40 int vmmdevHGCMSaveState(PVMMDEV pVMMDevState, PSSMHANDLE pSSM);
    41 int vmmdevHGCMLoadState(PVMMDEV pVMMDevState, PSSMHANDLE pSSM, uint32_t u32Version);
    42 int vmmdevHGCMLoadStateDone(PVMMDEV pVMMDevState);
     37DECLCALLBACK(int)  hgcmR3Completed(PPDMIHGCMPORT pInterface, int32_t result, PVBOXHGCMCMD pCmdPtr);
     38DECLCALLBACK(bool) hgcmR3IsCmdRestored(PPDMIHGCMPORT pInterface, PVBOXHGCMCMD pCmd);
     39DECLCALLBACK(bool) hgcmR3IsCmdCancelled(PPDMIHGCMPORT pInterface, PVBOXHGCMCMD pCmd);
     40DECLCALLBACK(uint32_t) hgcmR3GetRequestor(PPDMIHGCMPORT pInterface, PVBOXHGCMCMD pCmd);
     41DECLCALLBACK(uint64_t) hgcmR3GetVMMDevSessionId(PPDMIHGCMPORT pInterface);
    4342
    44 void vmmdevHGCMDestroy(PVMMDEV pThis);
    45 int  vmmdevHGCMInit(PVMMDEV pThis);
     43int  vmmdevR3HgcmSaveState(PVMMDEVCC pThisCC, PSSMHANDLE pSSM);
     44int  vmmdevR3HgcmLoadState(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC, PSSMHANDLE pSSM, uint32_t uVersion);
     45int  vmmdevR3HgcmLoadStateDone(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC);
     46
     47void vmmdevR3HgcmDestroy(PPDMDEVINS pDevIns, PVMMDEVCC pThisCC);
     48int  vmmdevR3HgcmInit(PVMMDEVCC pThisCC);
    4649RT_C_DECLS_END
    4750
  • trunk/src/VBox/Devices/VMMDev/VMMDevState.h

    r81571 r81625  
    137137    uint32_t            fHostCursorRequested;
    138138
    139     /** Pointer to device instance - R3 poitner. */
    140     PPDMDEVINSR3        pDevInsR3;
    141     /** Pointer to device instance - R0 pointer. */
    142     PPDMDEVINSR0        pDevInsR0;
    143 
    144     /** LUN\#0 + Status: VMMDev port base interface. */
    145     PDMIBASE            IBase;
    146     /** LUN\#0: VMMDev port interface. */
    147     PDMIVMMDEVPORT      IPort;
    148 #ifdef VBOX_WITH_HGCM
    149     /** LUN\#0: HGCM port interface. */
    150     PDMIHGCMPORT        IHGCMPort;
    151 //# if HC_ARCH_BITS == 32
    152 //    RTR3PTR      R3PtrAlignment1;
    153 //# endif
    154 #endif
    155     /** Pointer to base interface of the driver. */
    156     R3PTRTYPE(PPDMIBASE) pDrvBase;
    157     /** VMMDev connector interface */
    158     R3PTRTYPE(PPDMIVMMDEVCONNECTOR) pDrv;
    159 #ifdef VBOX_WITH_HGCM
    160     /** HGCM connector interface */
    161     R3PTRTYPE(PPDMIHGCMCONNECTOR) pHGCMDrv;
    162 #endif
    163139    /** message buffer for backdoor logging. */
    164140    char                szMsg[512];
     
    185161    bool                fNewGuestFilterMaskValid;
    186162    /** Alignment padding. */
    187     bool                afAlignment3[7];
    188 
    189     /** GC physical address of VMMDev RAM area */
    190     RTGCPHYS32                  GCPhysVMMDevRAM;
    191     /** R3 pointer to VMMDev RAM area */
    192     R3PTRTYPE(VMMDevMemory *)   pVMMDevRAMR3;
    193     /** R0 pointer to VMMDev RAM area - first page only, could be NULL! */
    194     R0PTRTYPE(VMMDevMemory *)   pVMMDevRAMR0;
    195 #ifdef VBOX_WITH_RAW_MODE_KEEP
    196     /** R0 pointer to VMMDev RAM area - first page only, could be NULL! */
    197     RCPTRTYPE(VMMDevMemory *)   pVMMDevRAMRC;
    198     RTRCPTR                     RCPtrAlignment3b;
    199 #endif
    200 
    201     /** R3 pointer to VMMDev Heap RAM area. */
    202     R3PTRTYPE(VMMDevMemory *) pVMMDevHeapR3;
    203     /** GC physical address of VMMDev Heap RAM area */
    204     RTGCPHYS32          GCPhysVMMDevHeap;
     163    bool                afAlignment3[3];
    205164
    206165    /** Information reported by guest via VMMDevReportGuestInfo generic request.
     
    236195    DISPLAYCHANGEDATA   displayChangeData;
    237196
    238     /** Pointer to the credentials. */
    239     R3PTRTYPE(VMMDEVCREDS *) pCredentials;
    240 
    241 #if HC_ARCH_BITS == 32
    242     uint32_t            uAlignment4;
    243 #endif
    244 
    245197    /** memory balloon change request */
    246198    uint32_t            cMbMemoryBalloon;
     
    271223    uint64_t            msLatchedHostTime;
    272224    bool                fTimesyncBackdoorLo;
     225    bool                afAlignment6[1];
     226#else
    273227    bool                afAlignment6[2];
    274 #else
    275     bool                afAlignment6[1+2];
    276 #endif
    277 
     228#endif
     229
     230    /** Set if guest should be allowed to trigger state save and power off.  */
     231    bool                fAllowGuestToSaveState;
    278232    /** Set if GetHostTime should fail.
    279233     * Loaded from the GetHostTimeDisabled configuration value. */
     
    292246    /** Number of additional cores to keep around. */
    293247    uint32_t            cGuestCoreDumps;
    294 
    295 #ifdef VBOX_WITH_HGCM
    296     /** List of pending HGCM requests (VBOXHGCMCMD). */
    297     RTLISTANCHORR3      listHGCMCmd;
    298     /** Critical section to protect the list. */
    299     RTCRITSECT          critsectHGCMCmdList;
    300     /** Whether the HGCM events are already automatically enabled. */
    301     uint32_t            u32HGCMEnabled;
    302     /** Saved state version of restored commands. */
    303     uint32_t            u32SSMVersion;
    304     RTMEMCACHE          hHgcmCmdCache;
    305     STAMPROFILE         StatHgcmCmdArrival;
    306     STAMPROFILE         StatHgcmCmdCompletion;
    307     STAMPROFILE         StatHgcmCmdTotal;
    308     STAMCOUNTER         StatHgcmLargeCmdAllocs;
    309     STAMCOUNTER         StatHgcmFailedPageListLocking;
    310 #endif /* VBOX_WITH_HGCM */
    311     STAMCOUNTER         StatReqBufAllocs;
    312 
    313     /** Per CPU request 4K sized buffers, allocated as needed. */
    314     R3PTRTYPE(VMMDevRequestHeader *) apReqBufs[VMM_MAX_CPU_COUNT];
    315 
    316     /** Status LUN: Shared folders LED */
    317     struct
    318     {
    319         /** The LED. */
    320         PDMLED                          Led;
    321         /** The LED ports. */
    322         PDMILEDPORTS                    ILeds;
    323         /** Partner of ILeds. */
    324         R3PTRTYPE(PPDMILEDCONNECTORS)   pLedsConnector;
    325     } SharedFolders;
    326248
    327249    /** FLag whether CPU hotplug events are monitored */
     
    338260    uint32_t            StatMemBalloonChunks;
    339261
    340     /** Set if RC/R0 is enabled. */
    341     bool                fRZEnabled;
    342262    /** Set if testing is enabled. */
    343263    bool                fTestingEnabled;
     
    345265    bool                fTestingMMIO;
    346266    /** Alignment padding. */
    347     bool                afPadding9[HC_ARCH_BITS == 32 ? 1 : 5];
     267    bool                afPadding9[HC_ARCH_BITS == 32 ? 2 : 6];
    348268#ifndef VBOX_WITHOUT_TESTING_FEATURES
    349269    /** The high timestamp value. */
     
    383303        uint8_t         abReadBack[VMMDEV_TESTING_READBACK_SIZE];
    384304    } TestingData;
    385     /** The XML output file name (can be a named pipe, doesn't matter to us). */
    386     R3PTRTYPE(char *)   pszTestingXmlOutput;
    387     /** Testing instance for dealing with the output. */
    388     RTTEST              hTestingTest;
     305
     306    /** Handle for the I/O ports used by the testing component. */
     307    IOMIOPORTHANDLE     hIoPortTesting;
     308    /** Handle for the MMIO region used by the testing component. */
     309    IOMMMIOHANDLE       hMmioTesting;
    389310#endif /* !VBOX_WITHOUT_TESTING_FEATURES */
    390311
     
    406327    uint64_t            cNsHeartbeatTimeout;
    407328    /** Timer for signalling a flatlined guest. */
    408     PTMTIMERR3          pFlatlinedTimer;
     329    TMTIMERHANDLE       hFlatlinedTimer;
    409330    /** @} */
     331
     332    /** Handle for the backdoor logging I/O port. */
     333    IOMIOPORTHANDLE     hIoPortBackdoorLog;
     334    /** Handle for the alternative timesync I/O port. */
     335    IOMIOPORTHANDLE     hIoPortAltTimesync;
     336    /** Handle for the VMM request I/O port (PCI region \#0). */
     337    IOMIOPORTHANDLE     hIoPortReq;
     338    /** Handle for the fast VMM request I/O port (PCI region \#0). */
     339    IOMIOPORTHANDLE     hIoPortFast;
     340    /** Handle for the VMMDev RAM (PCI region \#1). */
     341    PGMMMIO2HANDLE      hMmio2VMMDevRAM;
     342    /** Handle for the VMMDev Heap (PCI region \#2). */
     343    PGMMMIO2HANDLE      hMmio2Heap;
    410344} VMMDEV;
    411 /** Pointer to the VMM device state. */
     345/** Pointer to the shared VMM device state. */
    412346typedef VMMDEV *PVMMDEV;
    413347AssertCompileMemberAlignment(VMMDEV, CritSect, 8);
     
    421355
    422356
    423 void VMMDevNotifyGuest(VMMDEV *pVMMDevState, uint32_t u32EventMask);
    424 void VMMDevCtlSetGuestFilterMask(VMMDEV *pVMMDevState, uint32_t u32OrMask, uint32_t u32NotMask);
     357/**
     358 * State structure for the VMM device, ring-3 edition.
     359 */
     360typedef struct VMMDEVR3
     361{
     362    /** LUN\#0 + Status: VMMDev port base interface. */
     363    PDMIBASE                        IBase;
     364    /** LUN\#0: VMMDev port interface. */
     365    PDMIVMMDEVPORT                  IPort;
     366#ifdef VBOX_WITH_HGCM
     367    /** LUN\#0: HGCM port interface. */
     368    PDMIHGCMPORT                    IHGCMPort;
     369    /** HGCM connector interface */
     370    R3PTRTYPE(PPDMIHGCMCONNECTOR)   pHGCMDrv;
     371#endif
     372    /** Pointer to base interface of the driver. */
     373    R3PTRTYPE(PPDMIBASE)            pDrvBase;
     374    /** VMMDev connector interface */
     375    R3PTRTYPE(PPDMIVMMDEVCONNECTOR) pDrv;
     376    /** Pointer to the device instance.
     377     * @note Only for interface methods to get their bearings. */
     378    PPDMDEVINSR3                    pDevIns;
     379
     380    /** R3 pointer to VMMDev RAM area */
     381    R3PTRTYPE(VMMDevMemory *)       pVMMDevRAMR3;
     382
     383    /** R3 pointer to VMMDev Heap RAM area. */
     384    R3PTRTYPE(VMMDevMemory *)       pVMMDevHeapR3;
     385
     386    /** Pointer to the credentials. */
     387    R3PTRTYPE(VMMDEVCREDS *)        pCredentials;
     388    /** Set if pCredentials is using the RTMemSafer allocator, clear if heap. */
     389    bool                            fSaferCredentials;
     390    bool                            afAlignment[7];
     391
     392#ifdef VBOX_WITH_HGCM
     393    /** Critical section to protect the list. */
     394    RTCRITSECT                      critsectHGCMCmdList;
     395    /** List of pending HGCM requests (VBOXHGCMCMD). */
     396    RTLISTANCHORR3                  listHGCMCmd;
     397    /** Whether the HGCM events are already automatically enabled. */
     398    uint32_t                        u32HGCMEnabled;
     399    /** Saved state version of restored commands. */
     400    uint32_t                        uSavedStateVersion;
     401    RTMEMCACHE                      hHgcmCmdCache;
     402    STAMPROFILE                     StatHgcmCmdArrival;
     403    STAMPROFILE                     StatHgcmCmdCompletion;
     404    STAMPROFILE                     StatHgcmCmdTotal;
     405    STAMCOUNTER                     StatHgcmLargeCmdAllocs;
     406    STAMCOUNTER                     StatHgcmFailedPageListLocking;
     407#endif /* VBOX_WITH_HGCM */
     408    STAMCOUNTER                     StatReqBufAllocs;
     409    /** Per CPU request 4K sized buffers, allocated as needed. */
     410    R3PTRTYPE(VMMDevRequestHeader *) apReqBufs[VMM_MAX_CPU_COUNT];
     411
     412    /** Status LUN: Shared folders LED */
     413    struct
     414    {
     415        /** The LED. */
     416        PDMLED                          Led;
     417        /** The LED ports. */
     418        PDMILEDPORTS                    ILeds;
     419        /** Partner of ILeds. */
     420        R3PTRTYPE(PPDMILEDCONNECTORS)   pLedsConnector;
     421    } SharedFolders;
     422
     423#ifndef VBOX_WITHOUT_TESTING_FEATURES
     424    /** The XML output file name (can be a named pipe, doesn't matter to us). */
     425    R3PTRTYPE(char *)               pszTestingXmlOutput;
     426    /** Testing instance for dealing with the output. */
     427    RTTEST                          hTestingTest;
     428#endif
     429} VMMDEVR3;
     430/** Pointer to the ring-3 VMM device state. */
     431typedef VMMDEVR3 *PVMMDEVR3;
     432
     433
     434/**
     435 * State structure for the VMM device, ring-0 edition.
     436 */
     437typedef struct VMMDEVR0
     438{
     439    /** R0 pointer to VMMDev RAM area - first page only, could be NULL! */
     440    R0PTRTYPE(VMMDevMemory *)   pVMMDevRAMR0;
     441} VMMDEVR0;
     442/** Pointer to the ring-0 VMM device state. */
     443typedef VMMDEVR0 *PVMMDEVR0;
     444
     445
     446/**
     447 * State structure for the VMM device, raw-mode edition.
     448 */
     449typedef struct VMMDEVRC
     450{
     451    /** R0 pointer to VMMDev RAM area - first page only, could be NULL! */
     452    RCPTRTYPE(VMMDevMemory *)   pVMMDevRAMRC;
     453} VMMDEVRC;
     454/** Pointer to the raw-mode VMM device state. */
     455typedef VMMDEVRC *PVMMDEVRC;
     456
     457
     458/** @typedef VMMDEVCC
     459 * The VMMDEV device data for the current context. */
     460typedef CTX_SUFF(VMMDEV) VMMDEVCC;
     461/** @typedef PVMMDEVCC
     462 * Pointer to the VMMDEV device for the current context. */
     463typedef CTX_SUFF(PVMMDEV) PVMMDEVCC;
     464
     465
     466void VMMDevNotifyGuest(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC, uint32_t fAddEvents);
     467void VMMDevCtlSetGuestFilterMask(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC, uint32_t fOrMask, uint32_t fNotMask);
    425468
    426469
  • trunk/src/VBox/Devices/VMMDev/VMMDevTesting.cpp

    r81571 r81625  
    4848
    4949/**
    50  * @callback_method_impl{FNIOMMMIOWRITE}
    51  */
    52 PDMBOTHCBDECL(int) vmmdevTestingMmioWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void const *pv, unsigned cb)
     50 * @callback_method_impl{FNIOMMMIONEWWRITE}
     51 */
     52static DECLCALLBACK(VBOXSTRICTRC) vmmdevTestingMmioWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void const *pv, unsigned cb)
    5353{
    5454    RT_NOREF_PV(pvUser);
    5555
    56     switch (GCPhysAddr)
     56    switch (off)
    5757    {
    58         case VMMDEV_TESTING_MMIO_NOP_R3:
     58        case VMMDEV_TESTING_MMIO_OFF_NOP_R3:
    5959#ifndef IN_RING3
    6060            return VINF_IOM_R3_MMIO_WRITE;
    6161#endif
    62         case VMMDEV_TESTING_MMIO_NOP:
     62        case VMMDEV_TESTING_MMIO_OFF_NOP:
    6363            return VINF_SUCCESS;
    6464
     
    6868             * Readback register (64 bytes wide).
    6969             */
    70             uint32_t off = GCPhysAddr - VMMDEV_TESTING_MMIO_BASE;
    7170            if (   (   off      >= VMMDEV_TESTING_MMIO_OFF_READBACK
    7271                    && off + cb <= VMMDEV_TESTING_MMIO_OFF_READBACK + VMMDEV_TESTING_READBACK_SIZE)
     
    7776                    )
    7877            {
    79                 PVMMDEV pThis = PDMINS_2_DATA(pDevIns, PVMMDEV);
     78                PVMMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PVMMDEV);
    8079                off &= VMMDEV_TESTING_READBACK_SIZE - 1;
    8180                switch (cb)
     
    101100         * Odd NOP accesses.
    102101         */
    103         case VMMDEV_TESTING_MMIO_NOP_R3 + 1:
    104         case VMMDEV_TESTING_MMIO_NOP_R3 + 2:
    105         case VMMDEV_TESTING_MMIO_NOP_R3 + 3:
    106         case VMMDEV_TESTING_MMIO_NOP_R3 + 4:
    107         case VMMDEV_TESTING_MMIO_NOP_R3 + 5:
    108         case VMMDEV_TESTING_MMIO_NOP_R3 + 6:
    109         case VMMDEV_TESTING_MMIO_NOP_R3 + 7:
     102        case VMMDEV_TESTING_MMIO_OFF_NOP_R3 + 1:
     103        case VMMDEV_TESTING_MMIO_OFF_NOP_R3 + 2:
     104        case VMMDEV_TESTING_MMIO_OFF_NOP_R3 + 3:
     105        case VMMDEV_TESTING_MMIO_OFF_NOP_R3 + 4:
     106        case VMMDEV_TESTING_MMIO_OFF_NOP_R3 + 5:
     107        case VMMDEV_TESTING_MMIO_OFF_NOP_R3 + 6:
     108        case VMMDEV_TESTING_MMIO_OFF_NOP_R3 + 7:
    110109#ifndef IN_RING3
    111110            return VINF_IOM_R3_MMIO_WRITE;
    112111#endif
    113         case VMMDEV_TESTING_MMIO_NOP    + 1:
    114         case VMMDEV_TESTING_MMIO_NOP    + 2:
    115         case VMMDEV_TESTING_MMIO_NOP    + 3:
    116         case VMMDEV_TESTING_MMIO_NOP    + 4:
    117         case VMMDEV_TESTING_MMIO_NOP    + 5:
    118         case VMMDEV_TESTING_MMIO_NOP    + 6:
    119         case VMMDEV_TESTING_MMIO_NOP    + 7:
     112        case VMMDEV_TESTING_MMIO_OFF_NOP    + 1:
     113        case VMMDEV_TESTING_MMIO_OFF_NOP    + 2:
     114        case VMMDEV_TESTING_MMIO_OFF_NOP    + 3:
     115        case VMMDEV_TESTING_MMIO_OFF_NOP    + 4:
     116        case VMMDEV_TESTING_MMIO_OFF_NOP    + 5:
     117        case VMMDEV_TESTING_MMIO_OFF_NOP    + 6:
     118        case VMMDEV_TESTING_MMIO_OFF_NOP    + 7:
    120119            return VINF_SUCCESS;
    121120    }
     
    125124
    126125/**
    127  * @callback_method_impl{FNIOMMMIOREAD}
    128  */
    129 PDMBOTHCBDECL(int) vmmdevTestingMmioRead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb)
     126 * @callback_method_impl{FNIOMMMIONEWREAD}
     127 */
     128static DECLCALLBACK(VBOXSTRICTRC) vmmdevTestingMmioRead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void *pv, unsigned cb)
    130129{
    131130    RT_NOREF_PV(pvUser);
    132131
    133     switch (GCPhysAddr)
     132    switch (off)
    134133    {
    135         case VMMDEV_TESTING_MMIO_NOP_R3:
     134        case VMMDEV_TESTING_MMIO_OFF_NOP_R3:
    136135#ifndef IN_RING3
    137136            return VINF_IOM_R3_MMIO_READ;
    138137#endif
    139138            /* fall thru. */
    140         case VMMDEV_TESTING_MMIO_NOP:
     139        case VMMDEV_TESTING_MMIO_OFF_NOP:
    141140            switch (cb)
    142141            {
     
    165164             * Readback register (64 bytes wide).
    166165             */
    167             uint32_t off = GCPhysAddr - VMMDEV_TESTING_MMIO_BASE;
    168166            if (   (   off      >= VMMDEV_TESTING_MMIO_OFF_READBACK
    169167                    && off + cb <= VMMDEV_TESTING_MMIO_OFF_READBACK + 64)
     
    174172                    )
    175173            {
    176                 PVMMDEV pThis = PDMINS_2_DATA(pDevIns, PVMMDEV);
     174                PVMMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PVMMDEV);
    177175                off &= 0x3f;
    178176                switch (cb)
     
    197195         * Odd NOP accesses (for 16-bit code mainly).
    198196         */
    199         case VMMDEV_TESTING_MMIO_NOP_R3 + 1:
    200         case VMMDEV_TESTING_MMIO_NOP_R3 + 2:
    201         case VMMDEV_TESTING_MMIO_NOP_R3 + 3:
    202         case VMMDEV_TESTING_MMIO_NOP_R3 + 4:
    203         case VMMDEV_TESTING_MMIO_NOP_R3 + 5:
    204         case VMMDEV_TESTING_MMIO_NOP_R3 + 6:
    205         case VMMDEV_TESTING_MMIO_NOP_R3 + 7:
     197        case VMMDEV_TESTING_MMIO_OFF_NOP_R3 + 1:
     198        case VMMDEV_TESTING_MMIO_OFF_NOP_R3 + 2:
     199        case VMMDEV_TESTING_MMIO_OFF_NOP_R3 + 3:
     200        case VMMDEV_TESTING_MMIO_OFF_NOP_R3 + 4:
     201        case VMMDEV_TESTING_MMIO_OFF_NOP_R3 + 5:
     202        case VMMDEV_TESTING_MMIO_OFF_NOP_R3 + 6:
     203        case VMMDEV_TESTING_MMIO_OFF_NOP_R3 + 7:
    206204#ifndef IN_RING3
    207205            return VINF_IOM_R3_MMIO_READ;
    208206#endif
    209         case VMMDEV_TESTING_MMIO_NOP    + 1:
    210         case VMMDEV_TESTING_MMIO_NOP    + 2:
    211         case VMMDEV_TESTING_MMIO_NOP    + 3:
    212         case VMMDEV_TESTING_MMIO_NOP    + 4:
    213         case VMMDEV_TESTING_MMIO_NOP    + 5:
    214         case VMMDEV_TESTING_MMIO_NOP    + 6:
    215         case VMMDEV_TESTING_MMIO_NOP    + 7:
     207        case VMMDEV_TESTING_MMIO_OFF_NOP    + 1:
     208        case VMMDEV_TESTING_MMIO_OFF_NOP    + 2:
     209        case VMMDEV_TESTING_MMIO_OFF_NOP    + 3:
     210        case VMMDEV_TESTING_MMIO_OFF_NOP    + 4:
     211        case VMMDEV_TESTING_MMIO_OFF_NOP    + 5:
     212        case VMMDEV_TESTING_MMIO_OFF_NOP    + 6:
     213        case VMMDEV_TESTING_MMIO_OFF_NOP    + 7:
    216214        {
    217215            static uint8_t const s_abNopValue[8] =
     
    228226
    229227            memset(pv, 0xff, cb);
    230             memcpy(pv, &s_abNopValue[GCPhysAddr & 7], RT_MIN(8 - (GCPhysAddr & 7), cb));
     228            memcpy(pv, &s_abNopValue[off & 7], RT_MIN(8 - (off & 7), cb));
    231229            return VINF_SUCCESS;
    232230        }
     
    291289
    292290/**
    293  * @callback_method_impl{FNIOMIOPORTOUT}
    294  */
    295 PDMBOTHCBDECL(int) vmmdevTestingIoWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT uPort, uint32_t u32, unsigned cb)
     291 * @callback_method_impl{FNIOMIOPORTNEWOUT}
     292 */
     293static DECLCALLBACK(VBOXSTRICTRC)
     294vmmdevTestingIoWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t u32, unsigned cb)
    296295{
    297     PVMMDEV pThis = PDMINS_2_DATA(pDevIns, PVMMDEV);
     296    PVMMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PVMMDEV);
     297#ifdef IN_RING3
     298    PVMMDEVCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVMMDEVCC);
     299#endif
    298300    RT_NOREF_PV(pvUser);
    299301
    300     switch (uPort)
     302    switch (offPort)
    301303    {
    302304        /*
    303305         * The NOP I/O ports are used for performance measurements.
    304306         */
    305         case VMMDEV_TESTING_IOPORT_NOP:
     307        case VMMDEV_TESTING_IOPORT_NOP - VMMDEV_TESTING_IOPORT_BASE:
    306308            switch (cb)
    307309            {
     
    316318            return VINF_SUCCESS;
    317319
    318         case VMMDEV_TESTING_IOPORT_NOP_R3:
     320        case VMMDEV_TESTING_IOPORT_NOP_R3 - VMMDEV_TESTING_IOPORT_BASE:
    319321            switch (cb)
    320322            {
     
    333335
    334336        /* The timestamp I/O ports are read-only. */
    335         case VMMDEV_TESTING_IOPORT_TS_LOW:
    336         case VMMDEV_TESTING_IOPORT_TS_HIGH:
     337        case VMMDEV_TESTING_IOPORT_TS_LOW   - VMMDEV_TESTING_IOPORT_BASE:
     338        case VMMDEV_TESTING_IOPORT_TS_HIGH  - VMMDEV_TESTING_IOPORT_BASE:
    337339            break;
    338340
     
    341343         * (We have to allow WORD writes for 286, 186 and 8086 execution modes.)
    342344         */
    343         case VMMDEV_TESTING_IOPORT_CMD:
     345        case VMMDEV_TESTING_IOPORT_CMD - VMMDEV_TESTING_IOPORT_BASE:
    344346            if (cb == 2)
    345347            {
     
    359361         * The data port.  Used of providing data for a command.
    360362         */
    361         case VMMDEV_TESTING_IOPORT_DATA:
     363        case VMMDEV_TESTING_IOPORT_DATA - VMMDEV_TESTING_IOPORT_BASE:
    362364        {
    363365            uint32_t uCmd = pThis->u32TestingCmd;
     
    386388                                case VMMDEV_TESTING_CMD_INIT:
    387389                                    VMMDEV_TESTING_OUTPUT(("testing: INIT '%s'\n", pThis->TestingData.String.sz));
    388                                     if (pThis->hTestingTest != NIL_RTTEST)
     390                                    if (pThisCC->hTestingTest != NIL_RTTEST)
    389391                                    {
    390                                         RTTestChangeName(pThis->hTestingTest, pThis->TestingData.String.sz);
    391                                         RTTestBanner(pThis->hTestingTest);
     392                                        RTTestChangeName(pThisCC->hTestingTest, pThis->TestingData.String.sz);
     393                                        RTTestBanner(pThisCC->hTestingTest);
    392394                                    }
    393395                                    break;
    394396                                case VMMDEV_TESTING_CMD_SUB_NEW:
    395397                                    VMMDEV_TESTING_OUTPUT(("testing: SUB_NEW  '%s'\n", pThis->TestingData.String.sz));
    396                                     if (pThis->hTestingTest != NIL_RTTEST)
    397                                         RTTestSub(pThis->hTestingTest, pThis->TestingData.String.sz);
     398                                    if (pThisCC->hTestingTest != NIL_RTTEST)
     399                                        RTTestSub(pThisCC->hTestingTest, pThis->TestingData.String.sz);
    398400                                    break;
    399401                                case VMMDEV_TESTING_CMD_FAILED:
    400                                     if (pThis->hTestingTest != NIL_RTTEST)
    401                                         RTTestFailed(pThis->hTestingTest, "%s", pThis->TestingData.String.sz);
     402                                    if (pThisCC->hTestingTest != NIL_RTTEST)
     403                                        RTTestFailed(pThisCC->hTestingTest, "%s", pThis->TestingData.String.sz);
    402404                                    VMMDEV_TESTING_OUTPUT(("testing: FAILED '%s'\n", pThis->TestingData.String.sz));
    403405                                    break;
    404406                                case VMMDEV_TESTING_CMD_SKIPPED:
    405                                     if (pThis->hTestingTest != NIL_RTTEST)
     407                                    if (pThisCC->hTestingTest != NIL_RTTEST)
    406408                                    {
    407409                                        if (off)
    408                                             RTTestSkipped(pThis->hTestingTest, "%s", pThis->TestingData.String.sz);
     410                                            RTTestSkipped(pThisCC->hTestingTest, "%s", pThis->TestingData.String.sz);
    409411                                        else
    410                                             RTTestSkipped(pThis->hTestingTest, NULL);
     412                                            RTTestSkipped(pThisCC->hTestingTest, NULL);
    411413                                    }
    412414                                    VMMDEV_TESTING_OUTPUT(("testing: SKIPPED '%s'\n", pThis->TestingData.String.sz));
    413415                                    break;
    414416                                case VMMDEV_TESTING_CMD_PRINT:
    415                                     if (pThis->hTestingTest != NIL_RTTEST && off)
    416                                         RTTestPrintf(pThis->hTestingTest, RTTESTLVL_ALWAYS, "%s", pThis->TestingData.String.sz);
     417                                    if (pThisCC->hTestingTest != NIL_RTTEST && off)
     418                                        RTTestPrintf(pThisCC->hTestingTest, RTTESTLVL_ALWAYS, "%s", pThis->TestingData.String.sz);
    417419                                    VMMDEV_TESTING_OUTPUT(("testing: '%s'\n", pThis->TestingData.String.sz));
    418420                                    break;
     
    454456                        if (uCmd == VMMDEV_TESTING_CMD_TERM)
    455457                        {
    456                             if (pThis->hTestingTest != NIL_RTTEST)
     458                            if (pThisCC->hTestingTest != NIL_RTTEST)
    457459                            {
    458                                 while (RTTestErrorCount(pThis->hTestingTest) < u32)
    459                                     RTTestErrorInc(pThis->hTestingTest); /* A bit stupid, but does the trick. */
    460                                 RTTestSubDone(pThis->hTestingTest);
    461                                 RTTestSummaryAndDestroy(pThis->hTestingTest);
    462                                 pThis->hTestingTest = NIL_RTTEST;
     460                                while (RTTestErrorCount(pThisCC->hTestingTest) < u32)
     461                                    RTTestErrorInc(pThisCC->hTestingTest); /* A bit stupid, but does the trick. */
     462                                RTTestSubDone(pThisCC->hTestingTest);
     463                                RTTestSummaryAndDestroy(pThisCC->hTestingTest);
     464                                pThisCC->hTestingTest = NIL_RTTEST;
    463465                            }
    464466                            VMMDEV_TESTING_OUTPUT(("testing: TERM - %u errors\n", u32));
     
    466468                        else
    467469                        {
    468                             if (pThis->hTestingTest != NIL_RTTEST)
     470                            if (pThisCC->hTestingTest != NIL_RTTEST)
    469471                            {
    470                                 while (RTTestSubErrorCount(pThis->hTestingTest) < u32)
    471                                     RTTestErrorInc(pThis->hTestingTest); /* A bit stupid, but does the trick. */
    472                                 RTTestSubDone(pThis->hTestingTest);
     472                                while (RTTestSubErrorCount(pThisCC->hTestingTest) < u32)
     473                                    RTTestErrorInc(pThisCC->hTestingTest); /* A bit stupid, but does the trick. */
     474                                RTTestSubDone(pThisCC->hTestingTest);
    473475                            }
    474476                            VMMDEV_TESTING_OUTPUT(("testing: SUB_DONE - %u errors\n", u32));
     
    535537                                enmUnit = RTTESTUNIT_NONE;
    536538                            }
    537                             if (pThis->hTestingTest != NIL_RTTEST)
    538                                 RTTestValue(pThis->hTestingTest, pThis->TestingData.Value.szName,
     539                            if (pThisCC->hTestingTest != NIL_RTTEST)
     540                                RTTestValue(pThisCC->hTestingTest, pThis->TestingData.Value.szName,
    539541                                            pThis->TestingData.Value.u64Value.u, enmUnit);
    540542
     
    591593
    592594/**
    593  * @callback_method_impl{FNIOMIOPORTIN}
    594  */
    595 PDMBOTHCBDECL(int) vmmdevTestingIoRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT uPort, uint32_t *pu32, unsigned cb)
     595 * @callback_method_impl{FNIOMIOPORTNEWIN}
     596 */
     597static DECLCALLBACK(VBOXSTRICTRC)
     598vmmdevTestingIoRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t *pu32, unsigned cb)
    596599{
    597     PVMMDEV pThis = PDMINS_2_DATA(pDevIns, PVMMDEV);
     600    PVMMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PVMMDEV);
    598601    RT_NOREF_PV(pvUser);
    599602
    600     switch (uPort)
     603    switch (offPort)
    601604    {
    602605        /*
    603606         * The NOP I/O ports are used for performance measurements.
    604607         */
    605         case VMMDEV_TESTING_IOPORT_NOP:
     608        case VMMDEV_TESTING_IOPORT_NOP - VMMDEV_TESTING_IOPORT_BASE:
    606609            switch (cb)
    607610            {
     
    617620            return VINF_SUCCESS;
    618621
    619         case VMMDEV_TESTING_IOPORT_NOP_R3:
     622        case VMMDEV_TESTING_IOPORT_NOP_R3 - VMMDEV_TESTING_IOPORT_BASE:
    620623            switch (cb)
    621624            {
     
    641644         * gives you a 64-bit timestamp value.
    642645         */
    643         case VMMDEV_TESTING_IOPORT_TS_LOW:
     646        case VMMDEV_TESTING_IOPORT_TS_LOW - VMMDEV_TESTING_IOPORT_BASE:
    644647            if (cb == 4)
    645648            {
     
    651654            break;
    652655
    653         case VMMDEV_TESTING_IOPORT_TS_HIGH:
     656        case VMMDEV_TESTING_IOPORT_TS_HIGH - VMMDEV_TESTING_IOPORT_BASE:
    654657            if (cb == 4)
    655658            {
     
    662665         * The command and data registers are write-only.
    663666         */
    664         case VMMDEV_TESTING_IOPORT_CMD:
    665         case VMMDEV_TESTING_IOPORT_DATA:
     667        case VMMDEV_TESTING_IOPORT_CMD  - VMMDEV_TESTING_IOPORT_BASE:
     668        case VMMDEV_TESTING_IOPORT_DATA - VMMDEV_TESTING_IOPORT_BASE:
    666669            break;
    667670
     
    684687void vmmdevTestingTerminate(PPDMDEVINS pDevIns)
    685688{
    686     PVMMDEV pThis = PDMINS_2_DATA(pDevIns, PVMMDEV);
     689    PVMMDEV   pThis   = PDMDEVINS_2_DATA(pDevIns, PVMMDEV);
     690    PVMMDEVCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVMMDEVCC);
    687691    if (!pThis->fTestingEnabled)
    688692        return;
    689693
    690     if (pThis->hTestingTest != NIL_RTTEST)
     694    if (pThisCC->hTestingTest != NIL_RTTEST)
    691695    {
    692         RTTestFailed(pThis->hTestingTest, "Still open at vmmdev destruction.");
    693         RTTestSummaryAndDestroy(pThis->hTestingTest);
    694         pThis->hTestingTest = NIL_RTTEST;
     696        RTTestFailed(pThisCC->hTestingTest, "Still open at vmmdev destruction.");
     697        RTTestSummaryAndDestroy(pThisCC->hTestingTest);
     698        pThisCC->hTestingTest = NIL_RTTEST;
    695699    }
    696700}
     
    705709int vmmdevTestingInitialize(PPDMDEVINS pDevIns)
    706710{
    707     PVMMDEV pThis = PDMINS_2_DATA(pDevIns, PVMMDEV);
    708     int     rc;
     711    PVMMDEV     pThis   = PDMDEVINS_2_DATA(pDevIns, PVMMDEV);
     712    PVMMDEVCC   pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVMMDEVCC);
     713    int         rc;
    709714
    710715    if (!pThis->fTestingEnabled)
     
    717722         * tests interfaces.  Optional, needs to be explicitly enabled.
    718723         */
    719         rc = PDMDevHlpMMIORegister(pDevIns, VMMDEV_TESTING_MMIO_BASE, VMMDEV_TESTING_MMIO_SIZE, NULL /*pvUser*/,
    720                                    IOMMMIO_FLAGS_READ_PASSTHRU | IOMMMIO_FLAGS_WRITE_PASSTHRU,
    721                                    vmmdevTestingMmioWrite, vmmdevTestingMmioRead, "VMMDev Testing");
     724        rc = PDMDevHlpMmioCreateAndMap(pDevIns, VMMDEV_TESTING_MMIO_BASE, VMMDEV_TESTING_MMIO_SIZE,
     725                                       vmmdevTestingMmioWrite, vmmdevTestingMmioRead,
     726                                       IOMMMIO_FLAGS_READ_PASSTHRU | IOMMMIO_FLAGS_WRITE_PASSTHRU,
     727                                       "VMMDev Testing", &pThis->hMmioTesting);
    722728        AssertRCReturn(rc, rc);
    723         if (pThis->fRZEnabled)
    724         {
    725             rc = PDMDevHlpMMIORegisterR0(pDevIns, VMMDEV_TESTING_MMIO_BASE, VMMDEV_TESTING_MMIO_SIZE, NIL_RTR0PTR /*pvUser*/,
    726                                          "vmmdevTestingMmioWrite", "vmmdevTestingMmioRead");
    727             AssertRCReturn(rc, rc);
    728             rc = PDMDevHlpMMIORegisterRC(pDevIns, VMMDEV_TESTING_MMIO_BASE, VMMDEV_TESTING_MMIO_SIZE, NIL_RTRCPTR /*pvUser*/,
    729                                          "vmmdevTestingMmioWrite", "vmmdevTestingMmioRead");
    730             AssertRCReturn(rc, rc);
    731         }
    732729    }
    733730
     
    736733     * Register the I/O ports used for testing.
    737734     */
    738     rc = PDMDevHlpIOPortRegister(pDevIns, VMMDEV_TESTING_IOPORT_BASE, VMMDEV_TESTING_IOPORT_COUNT, NULL,
    739                                  vmmdevTestingIoWrite,
    740                                  vmmdevTestingIoRead,
    741                                  NULL /*pfnOutStr*/,
    742                                  NULL /*pfnInStr*/,
    743                                  "VMMDev Testing");
     735    rc = PDMDevHlpIoPortCreateAndMap(pDevIns, VMMDEV_TESTING_IOPORT_BASE, VMMDEV_TESTING_IOPORT_COUNT,
     736                                     vmmdevTestingIoWrite, vmmdevTestingIoRead, "VMMDev Testing", NULL /*paExtDescs*/,
     737                                     &pThis->hIoPortTesting);
    744738    AssertRCReturn(rc, rc);
    745     if (pThis->fRZEnabled)
    746     {
    747         rc = PDMDevHlpIOPortRegisterR0(pDevIns, VMMDEV_TESTING_IOPORT_BASE, VMMDEV_TESTING_IOPORT_COUNT, NIL_RTR0PTR /*pvUser*/,
    748                                        "vmmdevTestingIoWrite",
    749                                        "vmmdevTestingIoRead",
    750                                        NULL /*pszOutStr*/,
    751                                        NULL /*pszInStr*/,
    752                                        "VMMDev Testing");
    753         AssertRCReturn(rc, rc);
    754         rc = PDMDevHlpIOPortRegisterRC(pDevIns, VMMDEV_TESTING_IOPORT_BASE, VMMDEV_TESTING_IOPORT_COUNT, NIL_RTRCPTR /*pvUser*/,
    755                                        "vmmdevTestingIoWrite",
    756                                        "vmmdevTestingIoRead",
    757                                        NULL /*pszOutStr*/,
    758                                        NULL /*pszInStr*/,
    759                                        "VMMDev Testing");
    760         AssertRCReturn(rc, rc);
    761     }
    762739
    763740    /*
     
    765742     */
    766743    rc = RTTestCreateEx("VMMDevTesting", RTTEST_C_USE_ENV | RTTEST_C_NO_TLS | RTTEST_C_XML_DELAY_TOP_TEST,
    767                         RTTESTLVL_INVALID, -1 /*iNativeTestPipe*/, pThis->pszTestingXmlOutput, &pThis->hTestingTest);
     744                        RTTESTLVL_INVALID, -1 /*iNativeTestPipe*/, pThisCC->pszTestingXmlOutput, &pThisCC->hTestingTest);
    768745    if (RT_FAILURE(rc))
    769746        return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS, "Error creating testing instance");
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