VirtualBox

Ignore:
Timestamp:
May 17, 2015 6:01:37 PM (10 years ago)
Author:
vboxsync
Message:

VMM: Split up virtual handlers just like the physical ones, such that the kind+callbacks are stored seprately from the actual handler registration. This should hopefully save a byte or two when adding more callbacks. Implemented the pvUser for ring-3 callbacks.

File:
1 edited

Legend:

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

    r55000 r55889  
    455455{
    456456    LogFlow(("TRPMR3Init\n"));
     457    int rc;
    457458
    458459    /*
     
    490491    {
    491492        bool f;
    492         int rc = CFGMR3QueryBool(pTRPMNode, "SafeToDropGuestIDTMonitoring", &f);
     493        rc = CFGMR3QueryBool(pTRPMNode, "SafeToDropGuestIDTMonitoring", &f);
    493494        if (RT_SUCCESS(rc))
    494495            pVM->trpm.s.fSafeToDropGuestIDTMonitoring = f;
     
    507508
    508509    /*
     510     * Register virtual access handlers.
     511     */
     512    pVM->trpm.s.hShadowIdtWriteHandlerType = NIL_PGMVIRTHANDLERTYPE;
     513    pVM->trpm.s.hGuestIdtWriteHandlerType  = NIL_PGMVIRTHANDLERTYPE;
     514#ifdef VBOX_WITH_RAW_MODE
     515    if (!HMIsEnabled(pVM))
     516    {
     517# ifdef TRPM_TRACK_SHADOW_IDT_CHANGES
     518        rc = PGMR3HandlerVirtualTypeRegister(pVM, PGMVIRTHANDLERKIND_HYPERVISOR, false /*fRelocUserRC*/,
     519                                             NULL /*pfnInvalidateR3*/, NULL /*pfnHandlerR3*/,
     520                                             "trpmRCShadowIDTWriteHandler", NULL /*pszModRC*/,
     521                                             "Shadow IDT write access handler", &pVM->trpm.s.hShadowIdtWriteHandlerType);
     522        AssertRCReturn(rc, rc);
     523# endif
     524        rc = PGMR3HandlerVirtualTypeRegister(pVM, PGMVIRTHANDLERKIND_WRITE, false /*fRelocUserRC*/,
     525                                             NULL /*pfnInvalidateR3*/, trpmR3GuestIDTWriteHandler,
     526                                             "trpmRCGuestIDTWriteHandler", NULL /*pszModRC*/,
     527                                             "Guest IDT write access handler", &pVM->trpm.s.hGuestIdtWriteHandlerType);
     528        AssertRCReturn(rc, rc);
     529    }
     530#endif /* VBOX_WITH_RAW_MODE */
     531
     532    /*
    509533     * Register the saved state data unit.
    510534     */
    511     int rc = SSMR3RegisterInternal(pVM, "trpm", 1, TRPM_SAVED_STATE_VERSION, sizeof(TRPM),
    512                                    NULL, NULL, NULL,
    513                                    NULL, trpmR3Save, NULL,
    514                                    NULL, trpmR3Load, NULL);
     535    rc = SSMR3RegisterInternal(pVM, "trpm", 1, TRPM_SAVED_STATE_VERSION, sizeof(TRPM),
     536                               NULL, NULL, NULL,
     537                               NULL, trpmR3Save, NULL,
     538                               NULL, trpmR3Load, NULL);
    515539    if (RT_FAILURE(rc))
    516540        return rc;
     
    692716    if (pVM->trpm.s.pvMonShwIdtRC != RTRCPTR_MAX)
    693717    {
    694         rc = PGMHandlerVirtualDeregister(pVM, pVM->trpm.s.pvMonShwIdtRC);
     718        rc = PGMHandlerVirtualDeregister(pVM, pVCpu, pVM->trpm.s.pvMonShwIdtRC, true /*fHypervisor*/);
    695719        AssertRC(rc);
    696720    }
    697721    pVM->trpm.s.pvMonShwIdtRC = VM_RC_ADDR(pVM, &pVM->trpm.s.aIdt[0]);
    698     rc = PGMR3HandlerVirtualRegister(pVM, PGMVIRTHANDLERTYPE_HYPERVISOR, pVM->trpm.s.pvMonShwIdtRC, pVM->trpm.s.pvMonShwIdtRC + sizeof(pVM->trpm.s.aIdt) - 1,
    699                                      0, 0, "trpmRCShadowIDTWriteHandler", 0, "Shadow IDT write access handler");
     722    rc = PGMR3HandlerVirtualRegister(pVM, pVCpu, pVM->trpm.s.hShadowIdtWriteHandlerType,
     723                                     pVM->trpm.s.pvMonShwIdtRC, pVM->trpm.s.pvMonShwIdtRC + sizeof(pVM->trpm.s.aIdt) - 1,
     724                                     NULL /*pvUserR3*/, NIL_RTR0PTR /*pvUserRC*/, NULL /*pszDesc*/);
    700725    AssertRC(rc);
    701726# endif
     
    775800        if (!pVM->trpm.s.fSafeToDropGuestIDTMonitoring)
    776801        {
    777             int rc = PGMHandlerVirtualDeregister(pVM, pVM->trpm.s.GuestIdtr.pIdt);
     802            int rc = PGMHandlerVirtualDeregister(pVM, VMMGetCpu(pVM), pVM->trpm.s.GuestIdtr.pIdt, false /*fHypervisor*/);
    778803            AssertRC(rc);
    779804        }
     
    10901115             * [Re]Register write virtual handler for guest's IDT.
    10911116             */
     1117            PVMCPU pVCpu = VMMGetCpu(pVM);
    10921118            if (pVM->trpm.s.GuestIdtr.pIdt != RTRCPTR_MAX)
    10931119            {
    1094                 rc = PGMHandlerVirtualDeregister(pVM, pVM->trpm.s.GuestIdtr.pIdt);
     1120                rc = PGMHandlerVirtualDeregister(pVM, pVCpu, pVM->trpm.s.GuestIdtr.pIdt, false /*fHypervisor*/);
    10951121                AssertRCReturn(rc, rc);
    10961122            }
    10971123            /* limit is including */
    1098             rc = PGMR3HandlerVirtualRegister(pVM, PGMVIRTHANDLERTYPE_WRITE, IDTR.pIdt, IDTR.pIdt + IDTR.cbIdt /* already inclusive */,
    1099                                              0, trpmR3GuestIDTWriteHandler, "trpmRCGuestIDTWriteHandler", 0, "Guest IDT write access handler");
     1124            rc = PGMR3HandlerVirtualRegister(pVM, pVCpu, pVM->trpm.s.hGuestIdtWriteHandlerType,
     1125                                             IDTR.pIdt, IDTR.pIdt + IDTR.cbIdt /* already inclusive */,
     1126                                             NULL /*pvUserR3*/, NIL_RTR0PTR /*pvUserRC*/, NULL /*pszDesc*/);
    11001127
    11011128            if (rc == VERR_PGM_HANDLER_VIRTUAL_CONFLICT)
     
    11061133                    CSAMR3RemovePage(pVM, IDTR.pIdt + IDTR.cbIdt);
    11071134
    1108                 rc = PGMR3HandlerVirtualRegister(pVM, PGMVIRTHANDLERTYPE_WRITE, IDTR.pIdt, IDTR.pIdt + IDTR.cbIdt /* already inclusive */,
    1109                                                  0, trpmR3GuestIDTWriteHandler, "trpmRCGuestIDTWriteHandler", 0, "Guest IDT write access handler");
     1135                rc = PGMR3HandlerVirtualRegister(pVM, pVCpu, pVM->trpm.s.hGuestIdtWriteHandlerType,
     1136                                                 IDTR.pIdt, IDTR.pIdt + IDTR.cbIdt /* already inclusive */,
     1137                                                 NULL /*pvUserR3*/, NIL_RTR0PTR /*pvUserRC*/, NULL /*pszDesc*/);
    11101138            }
    11111139
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