VirtualBox

Ignore:
Timestamp:
Jul 19, 2018 3:51:20 PM (6 years ago)
Author:
vboxsync
Message:

PGM: Working on eliminating PGMMODEDATA and the corresponding PGMCPU section so we can do mode switching in ring-0. This second part deals with shadow paging pointers and expands PGM_TYPE_NESTED & PGMMODE_NESTED into 32BIT, PAE and AMD64 variants to better map to reality at the expense of a little bit of more code. bugref:9044

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR3/PGMShw.h

    r71222 r73246  
    111111RT_C_DECLS_BEGIN
    112112/* r3 */
    113 PGM_SHW_DECL(int, InitData)(PVM pVM, PPGMMODEDATA pModeData, bool fResolveGCAndR0);
    114113PGM_SHW_DECL(int, Enter)(PVMCPU pVCpu, bool fIs64BitsPagingMode);
    115114PGM_SHW_DECL(int, Relocate)(PVMCPU pVCpu, RTGCPTR offDelta);
     
    123122
    124123/**
    125  * Initializes the guest bit of the paging mode data.
    126  *
    127  * @returns VBox status code.
    128  * @param   pVM             The cross context VM structure.
    129  * @param   pModeData       The pointer table to initialize (our members only).
    130  * @param   fResolveGCAndR0 Indicate whether or not GC and Ring-0 symbols can be resolved now.
    131  *                          This is used early in the init process to avoid trouble with PDM
    132  *                          not being initialized yet.
    133  */
    134 PGM_SHW_DECL(int, InitData)(PVM pVM, PPGMMODEDATA pModeData, bool fResolveGCAndR0)
    135 {
    136 #if PGM_SHW_TYPE != PGM_TYPE_NESTED
    137     Assert(pModeData->uShwType == PGM_SHW_TYPE || pModeData->uShwType == PGM_TYPE_NESTED);
    138 #else
    139     Assert(pModeData->uShwType == PGM_SHW_TYPE);
    140 #endif
    141 
    142     /* Ring-3 */
    143     pModeData->pfnR3ShwRelocate          = PGM_SHW_NAME(Relocate);
    144     pModeData->pfnR3ShwExit              = PGM_SHW_NAME(Exit);
    145     pModeData->pfnR3ShwGetPage           = PGM_SHW_NAME(GetPage);
    146     pModeData->pfnR3ShwModifyPage        = PGM_SHW_NAME(ModifyPage);
    147 
    148     if (fResolveGCAndR0)
    149     {
    150         int rc;
    151 
    152         if (VM_IS_RAW_MODE_ENABLED(pVM))
    153         {
    154 #if PGM_SHW_TYPE != PGM_TYPE_AMD64 && PGM_SHW_TYPE != PGM_TYPE_NESTED && PGM_SHW_TYPE != PGM_TYPE_EPT /* No AMD64 for traditional virtualization, only VT-x and AMD-V. */
    155             /* GC */
    156             rc = PDMR3LdrGetSymbolRC(pVM, NULL,       PGM_SHW_NAME_RC_STR(GetPage),    &pModeData->pfnRCShwGetPage);
    157             AssertMsgRCReturn(rc, ("%s -> rc=%Rrc\n", PGM_SHW_NAME_RC_STR(GetPage),  rc), rc);
    158             rc = PDMR3LdrGetSymbolRC(pVM, NULL,       PGM_SHW_NAME_RC_STR(ModifyPage), &pModeData->pfnRCShwModifyPage);
    159             AssertMsgRCReturn(rc, ("%s -> rc=%Rrc\n", PGM_SHW_NAME_RC_STR(ModifyPage), rc), rc);
    160 #endif /* Not AMD64 shadow paging. */
    161         }
    162 
    163         /* Ring-0 */
    164         rc = PDMR3LdrGetSymbolR0(pVM, NULL,       PGM_SHW_NAME_R0_STR(GetPage),    &pModeData->pfnR0ShwGetPage);
    165         AssertMsgRCReturn(rc, ("%s -> rc=%Rrc\n", PGM_SHW_NAME_R0_STR(GetPage),  rc), rc);
    166         rc = PDMR3LdrGetSymbolR0(pVM, NULL,       PGM_SHW_NAME_R0_STR(ModifyPage), &pModeData->pfnR0ShwModifyPage);
    167         AssertMsgRCReturn(rc, ("%s -> rc=%Rrc\n", PGM_SHW_NAME_R0_STR(ModifyPage), rc), rc);
    168     }
    169     return VINF_SUCCESS;
    170 }
    171 
    172 /**
    173124 * Enters the shadow mode.
    174125 *
     
    179130PGM_SHW_DECL(int, Enter)(PVMCPU pVCpu, bool fIs64BitsPagingMode)
    180131{
    181 #if PGM_SHW_TYPE == PGM_TYPE_NESTED || PGM_SHW_TYPE == PGM_TYPE_EPT
    182 
    183 # if PGM_SHW_TYPE == PGM_TYPE_NESTED && HC_ARCH_BITS == 32
     132#if PGM_TYPE_IS_NESTED_OR_EPT(PGM_SHW_TYPE)
     133
     134# if PGM_TYPE_IS_NESTED(PGM_SHW_TYPE) && HC_ARCH_BITS == 32
    184135    /* Must distinguish between 32 and 64 bits guest paging modes as we'll use
    185136       a different shadow paging root/mode in both cases. */
     
    239190PGM_SHW_DECL(int, Exit)(PVMCPU pVCpu)
    240191{
     192#if PGM_TYPE_IS_NESTED_OR_EPT(PGM_SHW_TYPE)
    241193    PVM pVM = pVCpu->pVMR3;
    242 
    243     if (    (   pVCpu->pgm.s.enmShadowMode == PGMMODE_NESTED
    244              || pVCpu->pgm.s.enmShadowMode == PGMMODE_EPT)
    245         &&  pVCpu->pgm.s.CTX_SUFF(pShwPageCR3))
     194    if (pVCpu->pgm.s.CTX_SUFF(pShwPageCR3))
    246195    {
    247196        PPGMPOOL pPool = pVM->pgm.s.CTX_SUFF(pPool);
     
    265214        Log(("Leave nested shadow paging mode\n"));
    266215    }
     216#else
     217    RT_NOREF_PV(pVCpu);
     218#endif
    267219    return VINF_SUCCESS;
    268220}
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