Changeset 73262 in vbox
- Timestamp:
- Jul 20, 2018 11:10:04 AM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 123869
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/PGMAll.cpp
r73261 r73262 679 679 # define PGMMODEDATABTH_NULL_ENTRY() { UINT32_MAX, UINT32_MAX, NULL, NULL, NULL, NULL, NULL, NULL, NULL } 680 680 # define PGMMODEDATABTH_ENTRY(uShwT, uGstT, Nm) \ 681 { uShwT, uGstT, Nm(InvalidatePage), Nm(SyncCR3), Nm(PrefetchPage), Nm(VerifyAccessSyncPage), Nm(MapCR3), Nm(UnmapCR3), /*Nm(Enter)*/ NULL, Nm(Trap0eHandler) }681 { uShwT, uGstT, Nm(InvalidatePage), Nm(SyncCR3), Nm(PrefetchPage), Nm(VerifyAccessSyncPage), Nm(MapCR3), Nm(UnmapCR3), Nm(Enter), Nm(Trap0eHandler) } 682 682 683 683 #elif !defined(IN_RING3) && defined(VBOX_STRICT) 684 684 # define PGMMODEDATABTH_NULL_ENTRY() { UINT32_MAX, UINT32_MAX, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL } 685 685 # define PGMMODEDATABTH_ENTRY(uShwT, uGstT, Nm) \ 686 { uShwT, uGstT, Nm(InvalidatePage), Nm(SyncCR3), Nm(PrefetchPage), Nm(VerifyAccessSyncPage), Nm(MapCR3), Nm(UnmapCR3), /*Nm(Enter)*/ NULL, Nm(Trap0eHandler), Nm(AssertCR3) }686 { uShwT, uGstT, Nm(InvalidatePage), Nm(SyncCR3), Nm(PrefetchPage), Nm(VerifyAccessSyncPage), Nm(MapCR3), Nm(UnmapCR3), Nm(Enter), Nm(Trap0eHandler), Nm(AssertCR3) } 687 687 688 688 #elif defined(IN_RING3) && !defined(VBOX_STRICT) -
trunk/src/VBox/VMM/VMMAll/PGMAllBth.h
r73249 r73262 33 33 *******************************************************************************/ 34 34 RT_C_DECLS_BEGIN 35 PGM_BTH_DECL(int, Enter)(PVMCPU pVCpu, RTGCPHYS GCPhysCR3); 35 36 #ifndef IN_RING3 36 37 PGM_BTH_DECL(int, Trap0eHandler)(PVMCPU pVCpu, RTGCUINT uErr, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, bool *pfLockTaken); … … 54 55 PGM_BTH_DECL(int, UnmapCR3)(PVMCPU pVCpu); 55 56 56 /* currently ring-3 */57 PGM_BTH_DECL(int, Enter)(PVMCPU pVCpu, RTGCPHYS GCPhysCR3);58 57 #ifdef IN_RING3 59 58 PGM_BTH_DECL(int, Relocate)(PVMCPU pVCpu, RTGCPTR offDelta); … … 86 85 # error "Invalid combination; AMD64 guest implies AMD64 shadow and vice versa" 87 86 #endif 87 88 89 /** 90 * Enters the shadow+guest mode. 91 * 92 * @returns VBox status code. 93 * @param pVCpu The cross context virtual CPU structure. 94 * @param GCPhysCR3 The physical address from the CR3 register. 95 */ 96 PGM_BTH_DECL(int, Enter)(PVMCPU pVCpu, RTGCPHYS GCPhysCR3) 97 { 98 /* Here we deal with allocation of the root shadow page table for real and protected mode during mode switches; 99 * Other modes rely on MapCR3/UnmapCR3 to setup the shadow root page tables. 100 */ 101 #if ( ( PGM_SHW_TYPE == PGM_TYPE_32BIT \ 102 || PGM_SHW_TYPE == PGM_TYPE_PAE \ 103 || PGM_SHW_TYPE == PGM_TYPE_AMD64) \ 104 && ( PGM_GST_TYPE == PGM_TYPE_REAL \ 105 || PGM_GST_TYPE == PGM_TYPE_PROT)) 106 107 PVM pVM = pVCpu->CTX_SUFF(pVM); 108 109 Assert((HMIsNestedPagingActive(pVM) || VM_IS_NEM_ENABLED(pVM)) == pVM->pgm.s.fNestedPaging); 110 Assert(!pVM->pgm.s.fNestedPaging); 111 112 pgmLock(pVM); 113 /* Note: we only really need shadow paging in real and protected mode for VT-x and AMD-V (excluding nested paging/EPT modes), 114 * but any calls to GC need a proper shadow page setup as well. 115 */ 116 /* Free the previous root mapping if still active. */ 117 PPGMPOOL pPool = pVM->pgm.s.CTX_SUFF(pPool); 118 PPGMPOOLPAGE pOldShwPageCR3 = pVCpu->pgm.s.CTX_SUFF(pShwPageCR3); 119 if (pOldShwPageCR3) 120 { 121 Assert(pOldShwPageCR3->enmKind != PGMPOOLKIND_FREE); 122 123 /* Mark the page as unlocked; allow flushing again. */ 124 pgmPoolUnlockPage(pPool, pVCpu->pgm.s.CTX_SUFF(pShwPageCR3)); 125 126 # ifndef PGM_WITHOUT_MAPPINGS 127 /* Remove the hypervisor mappings from the shadow page table. */ 128 pgmMapDeactivateCR3(pVM, pVCpu->pgm.s.CTX_SUFF(pShwPageCR3)); 129 # endif 130 131 pgmPoolFreeByPage(pPool, pOldShwPageCR3, NIL_PGMPOOL_IDX, UINT32_MAX); 132 pVCpu->pgm.s.pShwPageCR3R3 = NIL_RTR3PTR; 133 pVCpu->pgm.s.pShwPageCR3RC = NIL_RTRCPTR; 134 pVCpu->pgm.s.pShwPageCR3R0 = NIL_RTR0PTR; 135 } 136 137 /* construct a fake address. */ 138 GCPhysCR3 = RT_BIT_64(63); 139 PPGMPOOLPAGE pNewShwPageCR3; 140 int rc = pgmPoolAlloc(pVM, GCPhysCR3, BTH_PGMPOOLKIND_ROOT, PGMPOOLACCESS_DONTCARE, PGM_A20_IS_ENABLED(pVCpu), 141 NIL_PGMPOOL_IDX, UINT32_MAX, false /*fLockPage*/, 142 &pNewShwPageCR3); 143 if (rc == VERR_PGM_POOL_FLUSHED) 144 { 145 Log(("Bth-Enter: PGM pool flushed -> signal sync cr3\n")); 146 Assert(VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_PGM_SYNC_CR3)); 147 pgmUnlock(pVM); 148 return VINF_PGM_SYNC_CR3; 149 } 150 AssertRCReturn(rc, rc); 151 152 pVCpu->pgm.s.pShwPageCR3R3 = (R3PTRTYPE(PPGMPOOLPAGE))MMHyperCCToR3(pVM, pNewShwPageCR3); 153 pVCpu->pgm.s.pShwPageCR3RC = (RCPTRTYPE(PPGMPOOLPAGE))MMHyperCCToRC(pVM, pNewShwPageCR3); 154 pVCpu->pgm.s.pShwPageCR3R0 = (R0PTRTYPE(PPGMPOOLPAGE))MMHyperCCToR0(pVM, pNewShwPageCR3); 155 156 /* Mark the page as locked; disallow flushing. */ 157 pgmPoolLockPage(pPool, pNewShwPageCR3); 158 159 /* Set the current hypervisor CR3. */ 160 CPUMSetHyperCR3(pVCpu, PGMGetHyperCR3(pVCpu)); 161 162 # ifndef PGM_WITHOUT_MAPPINGS 163 /* Apply all hypervisor mappings to the new CR3. */ 164 rc = pgmMapActivateCR3(pVM, pNewShwPageCR3); 165 # endif 166 167 pgmUnlock(pVM); 168 return rc; 169 #else 170 NOREF(pVCpu); NOREF(GCPhysCR3); 171 return VINF_SUCCESS; 172 #endif 173 } 174 88 175 89 176 #ifndef IN_RING3 -
trunk/src/VBox/VMM/VMMR3/PGMBth.h
r73250 r73262 21 21 *******************************************************************************/ 22 22 RT_C_DECLS_BEGIN 23 PGM_BTH_DECL(int, Enter)(PVMCPU pVCpu, RTGCPHYS GCPhysCR3);24 23 PGM_BTH_DECL(int, Relocate)(PVMCPU pVCpu, RTGCPTR offDelta); 25 24 25 PGM_BTH_DECL(int, Enter)(PVMCPU pVCpu, RTGCPHYS GCPhysCR3); 26 26 PGM_BTH_DECL(int, Trap0eHandler)(PVMCPU pVCpu, RTGCUINT uErr, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, bool *pfLockTaken); 27 27 PGM_BTH_DECL(int, SyncCR3)(PVMCPU pVCpu, uint64_t cr0, uint64_t cr3, uint64_t cr4, bool fGlobal); … … 33 33 PGM_BTH_DECL(int, UnmapCR3)(PVMCPU pVCpu); 34 34 RT_C_DECLS_END 35 36 37 38 /**39 * Enters the shadow+guest mode.40 *41 * @returns VBox status code.42 * @param pVCpu The cross context virtual CPU structure.43 * @param GCPhysCR3 The physical address from the CR3 register.44 */45 PGM_BTH_DECL(int, Enter)(PVMCPU pVCpu, RTGCPHYS GCPhysCR3)46 {47 /* Here we deal with allocation of the root shadow page table for real and protected mode during mode switches;48 * Other modes rely on MapCR3/UnmapCR3 to setup the shadow root page tables.49 */50 #if ( ( PGM_SHW_TYPE == PGM_TYPE_32BIT \51 || PGM_SHW_TYPE == PGM_TYPE_PAE \52 || PGM_SHW_TYPE == PGM_TYPE_AMD64) \53 && ( PGM_GST_TYPE == PGM_TYPE_REAL \54 || PGM_GST_TYPE == PGM_TYPE_PROT))55 56 PVM pVM = pVCpu->pVMR3;57 58 Assert((HMIsNestedPagingActive(pVM) || VM_IS_NEM_ENABLED(pVM)) == pVM->pgm.s.fNestedPaging);59 Assert(!pVM->pgm.s.fNestedPaging);60 61 pgmLock(pVM);62 /* Note: we only really need shadow paging in real and protected mode for VT-x and AMD-V (excluding nested paging/EPT modes),63 * but any calls to GC need a proper shadow page setup as well.64 */65 /* Free the previous root mapping if still active. */66 PPGMPOOL pPool = pVM->pgm.s.CTX_SUFF(pPool);67 if (pVCpu->pgm.s.CTX_SUFF(pShwPageCR3))68 {69 Assert(pVCpu->pgm.s.pShwPageCR3R3->enmKind != PGMPOOLKIND_FREE);70 71 /* Mark the page as unlocked; allow flushing again. */72 pgmPoolUnlockPage(pPool, pVCpu->pgm.s.CTX_SUFF(pShwPageCR3));73 74 # ifndef PGM_WITHOUT_MAPPINGS75 /* Remove the hypervisor mappings from the shadow page table. */76 pgmMapDeactivateCR3(pVM, pVCpu->pgm.s.CTX_SUFF(pShwPageCR3));77 # endif78 79 pgmPoolFreeByPage(pPool, pVCpu->pgm.s.pShwPageCR3R3, NIL_PGMPOOL_IDX, UINT32_MAX);80 pVCpu->pgm.s.pShwPageCR3R3 = 0;81 pVCpu->pgm.s.pShwPageCR3RC = 0;82 pVCpu->pgm.s.pShwPageCR3R0 = 0;83 }84 85 /* construct a fake address. */86 GCPhysCR3 = RT_BIT_64(63);87 int rc = pgmPoolAlloc(pVM, GCPhysCR3, BTH_PGMPOOLKIND_ROOT, PGMPOOLACCESS_DONTCARE, PGM_A20_IS_ENABLED(pVCpu),88 NIL_PGMPOOL_IDX, UINT32_MAX, false /*fLockPage*/,89 &pVCpu->pgm.s.pShwPageCR3R3);90 if (rc == VERR_PGM_POOL_FLUSHED)91 {92 Log(("Bth-Enter: PGM pool flushed -> signal sync cr3\n"));93 Assert(VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_PGM_SYNC_CR3));94 pgmUnlock(pVM);95 return VINF_PGM_SYNC_CR3;96 }97 AssertRCReturn(rc, rc);98 99 /* Mark the page as locked; disallow flushing. */100 pgmPoolLockPage(pPool, pVCpu->pgm.s.pShwPageCR3R3);101 102 pVCpu->pgm.s.pShwPageCR3R0 = MMHyperCCToR0(pVM, pVCpu->pgm.s.pShwPageCR3R3);103 pVCpu->pgm.s.pShwPageCR3RC = MMHyperCCToRC(pVM, pVCpu->pgm.s.pShwPageCR3R3);104 105 /* Set the current hypervisor CR3. */106 CPUMSetHyperCR3(pVCpu, PGMGetHyperCR3(pVCpu));107 108 # ifndef PGM_WITHOUT_MAPPINGS109 /* Apply all hypervisor mappings to the new CR3. */110 rc = pgmMapActivateCR3(pVM, pVCpu->pgm.s.CTX_SUFF(pShwPageCR3));111 # endif112 113 pgmUnlock(pVM);114 return rc;115 #else116 NOREF(pVCpu); NOREF(GCPhysCR3);117 return VINF_SUCCESS;118 #endif119 }120 35 121 36
Note:
See TracChangeset
for help on using the changeset viewer.