VirtualBox

Changeset 93650 in vbox for trunk/include


Ignore:
Timestamp:
Feb 8, 2022 10:43:53 AM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
149804
Message:

VMM/PGM,*: Split the physical access handler type registration into separate ring-0 and ring-3 steps, expanding the type to 64-bit. bugref:10094

Location:
trunk/include/VBox/vmm
Files:
9 edited

Legend:

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

    r93609 r93650  
    255255        struct PGMR0PERVM   s;
    256256#endif
    257         uint8_t             padding[640];
     257        uint8_t             padding[1920];
    258258    } pgmr0;
    259259
     
    300300    /** Padding so aCpus starts on a page boundrary.  */
    301301#ifdef VBOX_WITH_NEM_R0
    302     uint8_t         abPadding2[16384 - 64 - 4352 - 1024 - 256 - 256 - 64 - 3008 - 640 - 512 - 64 - 1024 - 128 - 704 - sizeof(PGVMCPU) * VMM_MAX_CPU_COUNT];
     302    uint8_t         abPadding2[16384 - 64 - 4352 - 1024 - 256 - 256 - 64 - 3008 - 1920 - 512 - 64 - 1024 - 128 - 704 - sizeof(PGVMCPU) * VMM_MAX_CPU_COUNT];
    303303#else
    304     uint8_t         abPadding2[16384 - 64 - 4352 - 1024 - 256 -       64 - 3008 - 640 - 512 - 64 - 1024 - 128 - 704 - sizeof(PGVMCPU) * VMM_MAX_CPU_COUNT];
     304    uint8_t         abPadding2[16384 - 64 - 4352 - 1024 - 256 -       64 - 3008 - 1920 - 512 - 64 - 1024 - 128 - 704 - sizeof(PGVMCPU) * VMM_MAX_CPU_COUNT];
    305305#endif
    306306
  • trunk/include/VBox/vmm/gvm.mac

    r93609 r93650  
    8585        .pdmr0              resb 3008
    8686        alignb 64
    87         .pgmr0              resb 640
     87        .pgmr0              resb 1920
    8888        alignb 64
    8989        .iomr0              resb 512
  • trunk/include/VBox/vmm/iem.h

    r93198 r93650  
    387387/** @}  */
    388388
     389/** @defgroup grp_iem_r3     The IEM Host Context Ring-3 API.
     390 * @{
     391 */
     392VMMR0_INT_DECL(int) IEMR0InitVM(PGVM pGVM);
     393/** @} */
     394
    389395
    390396/** @defgroup grp_iem_r3     The IEM Host Context Ring-3 API.
  • trunk/include/VBox/vmm/iom.h

    r93115 r93650  
    514514 * @{ */
    515515VMMR0_INT_DECL(void) IOMR0InitPerVMData(PGVM pGVM);
     516VMMR0_INT_DECL(int)  IOMR0InitVM(PGVM pGVM);
    516517VMMR0_INT_DECL(void) IOMR0CleanupVM(PGVM pGVM);
    517518
  • trunk/include/VBox/vmm/mm.h

    r93628 r93650  
    177177#endif
    178178VMMDECL(size_t)     MMHyperHeapGetFreeSize(PVM pVM);
    179 VMMDECL(void *)     MMHyperHeapOffsetToPtr(PVM pVM, uint32_t offHeap);
    180 VMMDECL(uint32_t)   MMHyperHeapPtrToOffset(PVM pVM, void *pv);
    181179VMMDECL(bool)       MMHyperIsInsideArea(PVM pVM, RTGCPTR GCPtr);
    182180
  • trunk/include/VBox/vmm/pdmdev.h

    r93635 r93650  
    48594859     *
    48604860     * @returns VBox status code.
    4861      * @param   pDevIns             The device instance.
    4862      * @param   enmKind             The kind of access handler.
    4863      * @param   pfnHandlerR3        Pointer to the ring-3 handler callback.
    4864      * @param   pszHandlerR0        The name of the ring-0 handler, NULL if the ring-3
    4865      *                              handler should be called.
    4866      * @param   pszPfHandlerR0      The name of the ring-0 \#PF handler, NULL if the
    4867      *                              ring-3 handler should be called.
    4868      * @param   pszHandlerRC        The name of the raw-mode context handler, NULL if
    4869      *                              the ring-3 handler should be called.
    4870      * @param   pszPfHandlerRC      The name of the raw-mode context \#PF handler, NULL
    4871      *                              if the ring-3 handler should be called.
    4872      * @param   pszDesc             The type description.
    4873      * @param   phType              Where to return the type handle (cross context
    4874      *                              safe).
     4861     * @param   pDevIns     The device instance.
     4862     * @param   enmKind     The kind of access handler.
     4863     * @param   pfnHandler  Pointer to the ring-3 handler callback.
     4864     * @param   pszDesc     The type description.
     4865     * @param   phType      Where to return the type handle (cross context safe).
     4866     * @sa      PDMDevHlpPGMHandlerPhysicalTypeSetUpContext
    48754867     */
    48764868    DECLR3CALLBACKMEMBER(int, pfnPGMHandlerPhysicalTypeRegister, (PPDMDEVINS pDevIns, PGMPHYSHANDLERKIND enmKind,
    4877                                                                   R3PTRTYPE(PFNPGMPHYSHANDLER) pfnHandlerR3,
    4878                                                                   const char *pszHandlerR0, const char *pszPfHandlerR0,
    4879                                                                   const char *pszHandlerRC, const char *pszPfHandlerRC,
     4869                                                                  PFNPGMPHYSHANDLER pfnHandler,
    48804870                                                                  const char *pszDesc, PPGMPHYSHANDLERTYPE phType));
    48814871
     
    59645954
    59655955    /**
     5956     * Sets up a physical page access handler type for ring-0 callbacks.
     5957     *
     5958     * @returns VBox status code.
     5959     * @param   pDevIns         The device instance.
     5960     * @param   enmKind         The kind of access handler.
     5961     * @param   pfnHandler      Pointer to the ring-0 handler callback. NULL if
     5962     *                          the ring-3 handler should be called.
     5963     * @param   pfnPfHandler    The name of the ring-0 \#PF handler, NULL if the
     5964     *                          ring-3 handler should be called.
     5965     * @param   pszDesc         The type description.
     5966     * @param   hType           The type handle registered in ring-3 already.
     5967     * @sa      PDMDevHlpPGMHandlerPhysicalTypeRegister
     5968     */
     5969    DECLR0CALLBACKMEMBER(int, pfnPGMHandlerPhysicalTypeSetUpContext, (PPDMDEVINS pDevIns, PGMPHYSHANDLERKIND enmKind,
     5970                                                                      PFNPGMPHYSHANDLER pfnHandler,
     5971                                                                      PFNPGMRZPHYSPFHANDLER pfnPfHandler,
     5972                                                                      const char *pszDesc, PGMPHYSHANDLERTYPE hType));
     5973
     5974    /**
    59665975     * Temporarily turns off the access monitoring of a page within a monitored
    59675976     * physical write/all page access handler region.
     
    60596068
    60606069/** Current PDMDEVHLP version number. */
    6061 #define PDM_DEVHLPR0_VERSION                    PDM_VERSION_MAKE(0xffe5, 26, 0)
     6070#define PDM_DEVHLPR0_VERSION                    PDM_VERSION_MAKE(0xffe5, 27, 0)
    60626071
    60636072
     
    94609469 */
    94619470DECLINLINE(int) PDMDevHlpPGMHandlerPhysicalTypeRegister(PPDMDEVINS pDevIns, PGMPHYSHANDLERKIND enmKind,
    9462                                                         R3PTRTYPE(PFNPGMPHYSHANDLER) pfnHandlerR3,
    9463                                                         const char *pszHandlerR0, const char *pszPfHandlerR0,
    9464                                                         const char *pszHandlerRC, const char *pszPfHandlerRC,
    9465                                                         const char *pszDesc, PPGMPHYSHANDLERTYPE phType)
    9466 {
    9467     return pDevIns->pHlpR3->pfnPGMHandlerPhysicalTypeRegister(pDevIns, enmKind, pfnHandlerR3,
    9468                                                               pszHandlerR0, pszPfHandlerR0,
    9469                                                               pszHandlerRC, pszPfHandlerRC,
    9470                                                               pszDesc, phType);
    9471 }
     9471                                                        PFNPGMPHYSHANDLER pfnHandler, const char *pszDesc,
     9472                                                        PPGMPHYSHANDLERTYPE phType)
     9473{
     9474    return pDevIns->pHlpR3->pfnPGMHandlerPhysicalTypeRegister(pDevIns, enmKind, pfnHandler, pszDesc, phType);
     9475}
     9476
     9477#elif defined(IN_RING0)
     9478
     9479/**
     9480 * @copydoc PDMDEVHLPR0::pfnPGMHandlerPhysicalTypeSetUpContext
     9481 */
     9482DECLINLINE(int) PDMDevHlpPGMHandlerPhysicalTypeSetUpContext(PPDMDEVINS pDevIns, PGMPHYSHANDLERKIND enmKind,
     9483                                                            PFNPGMPHYSHANDLER pfnHandler, PFNPGMRZPHYSPFHANDLER pfnPfHandler,
     9484                                                            const char *pszDesc, PGMPHYSHANDLERTYPE hType)
     9485{
     9486    return pDevIns->pHlpR0->pfnPGMHandlerPhysicalTypeSetUpContext(pDevIns, enmKind, pfnHandler, pfnPfHandler, pszDesc, hType);
     9487}
     9488
     9489#endif
     9490#ifdef IN_RING3
    94729491
    94739492/**
  • trunk/include/VBox/vmm/pgm.h

    r93635 r93650  
    116116typedef enum PGMPHYSHANDLERKIND
    117117{
     118    /** Invalid zero value. */
     119    PGMPHYSHANDLERKIND_INVALID = 0,
    118120    /** MMIO range. Pages are not present, all access is done in interpreter or recompiler. */
    119     PGMPHYSHANDLERKIND_MMIO = 1,
     121    PGMPHYSHANDLERKIND_MMIO,
    120122    /** Handler all write access to a physical page range. */
    121123    PGMPHYSHANDLERKIND_WRITE,
    122124    /** Handler all access to a physical page range. */
    123     PGMPHYSHANDLERKIND_ALL
    124 
     125    PGMPHYSHANDLERKIND_ALL,
     126    /** End of the valid values. */
     127    PGMPHYSHANDLERKIND_END,
     128    /** Type size hack. */
     129    PGMPHYSHANDLERKIND_32BIT_HACK = 0x7fffffff,
    125130} PGMPHYSHANDLERKIND;
    126131
     
    625630 * cross contexts without needing fixing up).  Callbacks and handler type is
    626631 * associated with this and it is shared by all handler registrations. */
    627 typedef uint32_t PGMPHYSHANDLERTYPE;
     632typedef uint64_t PGMPHYSHANDLERTYPE;
    628633/** Pointer to a PGM physical handler type registration handle. */
    629634typedef PGMPHYSHANDLERTYPE *PPGMPHYSHANDLERTYPE;
    630635/** NIL value for PGM physical access handler type handle. */
    631 #define NIL_PGMPHYSHANDLERTYPE  UINT32_MAX
    632 VMMDECL(uint32_t)   PGMHandlerPhysicalTypeRelease(PVMCC pVM, PGMPHYSHANDLERTYPE hType);
    633 VMMDECL(uint32_t)   PGMHandlerPhysicalTypeRetain(PVM pVM, PGMPHYSHANDLERTYPE hType);
    634 
     636#define NIL_PGMPHYSHANDLERTYPE  UINT64_MAX
    635637VMMDECL(int)        PGMHandlerPhysicalRegister(PVMCC pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysLast, PGMPHYSHANDLERTYPE hType,
    636638                                               uint64_t uUser, R3PTRTYPE(const char *) pszDesc);
     
    646648VMMDECL(int)        PGMHandlerPhysicalReset(PVMCC pVM, RTGCPHYS GCPhys);
    647649VMMDECL(bool)       PGMHandlerPhysicalIsRegistered(PVMCC pVM, RTGCPHYS GCPhys);
     650
     651/** @name PGMPHYSHANDLER_F_XXX - flags for PGMR3HandlerPhysicalTypeRegister and PGMR0HandlerPhysicalTypeRegister
     652 * @{ */
     653/** Whether to hold the PGM lock while calling the handler or not.
     654 *  Mainly an optimization for PGM callers. */
     655#define PGMPHYSHANDLER_F_KEEP_PGM_LOCK  RT_BIT_32(0)
     656/** The uUser value is a ring-0 device instance index that needs translating
     657 * into a PDMDEVINS pointer before calling the handler.  This is a hack to make
     658 * it possible to use access handlers in devices. */
     659#define PGMPHYSHANDLER_F_R0_DEVINS_IDX  RT_BIT_32(1)
     660/** Mask of valid bits.   */
     661#define PGMPHYSHANDLER_F_VALID_MASK     UINT32_C(3)
     662/** @} */
    648663
    649664
     
    914929VMMR0_INT_DECL(int)  PGMR0InitPerVMData(PGVM pGVM, RTR0MEMOBJ hMemObj);
    915930VMMR0_INT_DECL(int)  PGMR0InitVM(PGVM pGVM);
     931VMMR0_INT_DECL(void) PGMR0DoneInitVM(PGVM pGVM);
    916932VMMR0_INT_DECL(void) PGMR0CleanupVM(PGVM pGVM);
    917933VMMR0_INT_DECL(int)  PGMR0PhysAllocateHandyPages(PGVM pGVM, VMCPUID idCpu);
     
    921937                                             size_t offSub, size_t cbSub, void **ppvMapping);
    922938VMMR0_INT_DECL(int)  PGMR0PhysSetupIoMmu(PGVM pGVM);
     939VMMR0_INT_DECL(int)  PGMR0HandlerPhysicalTypeSetUpContext(PGVM pGVM, PGMPHYSHANDLERKIND enmKind, uint32_t fFlags,
     940                                                          PFNPGMPHYSHANDLER pfnHandler, PFNPGMRZPHYSPFHANDLER pfnPfHandler,
     941                                                          const char *pszDesc, PGMPHYSHANDLERTYPE hType);
     942
    923943VMMR0DECL(int)       PGMR0SharedModuleCheck(PVMCC pVM, PGVM pGVM, VMCPUID idCpu, PGMMSHAREDMODULE pModule,
    924944                                            PCRTGCPTR64 paRegionsGCPtrs);
     
    10051025VMMDECL(void)       PGMR3PhysSetA20(PVMCPU pVCpu, bool fEnable);
    10061026
    1007 VMMR3_INT_DECL(int) PGMR3HandlerPhysicalTypeRegisterEx(PVM pVM, PGMPHYSHANDLERKIND enmKind, uint32_t fFlags,
    1008                                                        PFNPGMPHYSHANDLER pfnHandlerR3,
    1009                                                        R0PTRTYPE(PFNPGMPHYSHANDLER)     pfnHandlerR0,
    1010                                                        R0PTRTYPE(PFNPGMRZPHYSPFHANDLER) pfnPfHandlerR0,
    1011                                                        const char *pszDesc, PPGMPHYSHANDLERTYPE phType);
    1012 VMMR3DECL(int)      PGMR3HandlerPhysicalTypeRegister(PVM pVM, PGMPHYSHANDLERKIND enmKind, uint32_t fFlags,
    1013                                                      R3PTRTYPE(PFNPGMPHYSHANDLER) pfnHandlerR3,
    1014                                                      const char *pszModR0, const char *pszHandlerR0, const char *pszPfHandlerR0,
    1015                                                      const char *pszModRC, const char *pszHandlerRC, const char *pszPfHandlerRC,
    1016                                                      const char *pszDesc,
     1027VMMR3_INT_DECL(int) PGMR3HandlerPhysicalTypeRegister(PVM pVM, PGMPHYSHANDLERKIND enmKind, uint32_t fFlags,
     1028                                                     PFNPGMPHYSHANDLER pfnHandlerR3, const char *pszDesc,
    10171029                                                     PPGMPHYSHANDLERTYPE phType);
    1018 /** @name PGMPHYSHANDLER_F_XXX - flags for PGMR3HandlerPhysicalTypeRegister
    1019  * @{ */
    1020 /** Whether to hold the PGM lock while calling the handler or not.
    1021  *  Mainly an optimization for PGM callers. */
    1022 #define PGMPHYSHANDLER_F_KEEP_PGM_LOCK  RT_BIT_32(0)
    1023 /** The uUser value is a ring-0 device instance index that needs translating
    1024  * into a PDMDEVINS pointer before calling the handler.  This is a hack to make
    1025  * it possible to use access handlers in devices. */
    1026 #define PGMPHYSHANDLER_F_R0_DEVINS_IDX  RT_BIT_32(1)
    1027 /** Mask of valid bits.   */
    1028 #define PGMPHYSHANDLER_F_VALID_MASK     UINT32_C(3)
    1029 /** @} */
    10301030
    10311031VMMR3_INT_DECL(int) PGMR3PoolGrow(PVM pVM, PVMCPU pVCpu);
  • trunk/include/VBox/vmm/vm.h

    r93635 r93650  
    14431443    } cfgm;
    14441444
     1445    /** IEM part. */
     1446    union
     1447    {
     1448#ifdef VMM_INCLUDED_SRC_include_IEMInternal_h
     1449        struct IEM  s;
     1450#endif
     1451        uint8_t     padding[8];         /* multiple of 8 */
     1452    } iem;
     1453
    14451454    /** Statistics for ring-0 only components. */
    14461455    struct
     
    14581467
    14591468    /** Padding for aligning the structure size on a page boundrary. */
    1460     uint8_t         abAlignment2[8920 - sizeof(PVMCPUR3) * VMM_MAX_CPU_COUNT];
     1469    uint8_t         abAlignment2[8912 - sizeof(PVMCPUR3) * VMM_MAX_CPU_COUNT];
    14611470
    14621471    /* ---- end small stuff ---- */
  • trunk/include/VBox/vmm/vm.mac

    r93635 r93650  
    163163    .vm                     resb 32
    164164    .cfgm                   resb 8
     165    .iem                    resb 8
    165166    .R0Stats                resb 64
    166167
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette