Changeset 65531 in vbox for trunk/src/VBox/VMM/VMMAll/PGMAllGst.h
- Timestamp:
- Jan 31, 2017 10:26:35 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/PGMAllGst.h
r65504 r65531 74 74 * @param pWalk Where to return the walk result. This is always set. 75 75 */ 76 static intPGM_GST_NAME(Walk)(PVMCPU pVCpu, RTGCPTR GCPtr, PGSTPTWALK pWalk)76 DECLINLINE(int) PGM_GST_NAME(Walk)(PVMCPU pVCpu, RTGCPTR GCPtr, PGSTPTWALK pWalk) 77 77 { 78 78 int rc; … … 93 93 # endif 94 94 95 uint32_t register fEffective = X86_PTE_RW | X86_PTE_US | X86_PTE_PWT | X86_PTE_PCD | X86_PTE_A | 1; 95 96 { 96 97 # if PGM_GST_TYPE == PGM_TYPE_AMD64 … … 99 100 */ 100 101 rc = pgmGstGetLongModePML4PtrEx(pVCpu, &pWalk->pPml4); 101 if (RT_FAILURE(rc)) 102 return PGM_GST_NAME(WalkReturnBadPhysAddr)(pVCpu, pWalk, 4, rc); 103 104 PX86PML4 register pPml4 = pWalk->pPml4; 102 if (RT_SUCCESS(rc)) { /* probable */ } 103 else return PGM_GST_NAME(WalkReturnBadPhysAddr)(pVCpu, pWalk, 4, rc); 104 105 PX86PML4E register pPml4e; 106 pWalk->pPml4e = pPml4e = &pWalk->pPml4->a[(GCPtr >> X86_PML4_SHIFT) & X86_PML4_MASK]; 105 107 X86PML4E register Pml4e; 106 PX86PML4E register pPml4e;107 108 pWalk->pPml4e = pPml4e = &pPml4->a[(GCPtr >> X86_PML4_SHIFT) & X86_PML4_MASK];109 108 pWalk->Pml4e.u = Pml4e.u = pPml4e->u; 110 if (!Pml4e.n.u1Present) 111 return PGM_GST_NAME(WalkReturnNotPresent)(pVCpu, pWalk, 4); 112 if (RT_UNLIKELY(!GST_IS_PML4E_VALID(pVCpu, Pml4e))) 113 return PGM_GST_NAME(WalkReturnRsvdError)(pVCpu, pWalk, 4); 109 110 if (Pml4e.n.u1Present) { /* probable */ } 111 else return PGM_GST_NAME(WalkReturnNotPresent)(pVCpu, pWalk, 4); 112 113 if (RT_LIKELY(GST_IS_PML4E_VALID(pVCpu, Pml4e))) { /* likely */ } 114 else return PGM_GST_NAME(WalkReturnRsvdError)(pVCpu, pWalk, 4); 115 116 pWalk->Core.fEffective = fEffective = ((uint32_t)Pml4e.u & (X86_PML4E_RW | X86_PML4E_US | X86_PML4E_PWT | X86_PML4E_PCD | X86_PML4E_A)) 117 | ((uint32_t)(Pml4e.u >> 63) ^ 1) /*NX */; 114 118 115 119 /* … … 117 121 */ 118 122 rc = PGM_GCPHYS_2_PTR_BY_VMCPU(pVCpu, Pml4e.u & X86_PML4E_PG_MASK, &pWalk->pPdpt); 119 if (RT_ FAILURE(rc))120 123 if (RT_SUCCESS(rc)) { /* probable */ } 124 else return PGM_GST_NAME(WalkReturnBadPhysAddr)(pVCpu, pWalk, 3, rc); 121 125 122 126 # elif PGM_GST_TYPE == PGM_TYPE_PAE 123 127 rc = pgmGstGetPaePDPTPtrEx(pVCpu, &pWalk->pPdpt); 124 if (RT_ FAILURE(rc))125 128 if (RT_SUCCESS(rc)) { /* probable */ } 129 else return PGM_GST_NAME(WalkReturnBadPhysAddr)(pVCpu, pWalk, 8, rc); 126 130 # endif 127 131 } 128 132 { 129 133 # if PGM_GST_TYPE == PGM_TYPE_AMD64 || PGM_GST_TYPE == PGM_TYPE_PAE 130 PX86PDPT register pPdpt = pWalk->pPdpt;131 134 PX86PDPE register pPdpe; 135 pWalk->pPdpe = pPdpe = &pWalk->pPdpt->a[(GCPtr >> GST_PDPT_SHIFT) & GST_PDPT_MASK]; 132 136 X86PDPE register Pdpe; 133 134 pWalk->pPdpe = pPdpe = &pPdpt->a[(GCPtr >> GST_PDPT_SHIFT) & GST_PDPT_MASK];135 137 pWalk->Pdpe.u = Pdpe.u = pPdpe->u; 136 if (!Pdpe.n.u1Present) 137 return PGM_GST_NAME(WalkReturnNotPresent)(pVCpu, pWalk, 3); 138 if (RT_UNLIKELY(!GST_IS_PDPE_VALID(pVCpu, Pdpe))) 139 return PGM_GST_NAME(WalkReturnRsvdError)(pVCpu, pWalk, 3); 138 139 if (Pdpe.n.u1Present) { /* probable */ } 140 else return PGM_GST_NAME(WalkReturnNotPresent)(pVCpu, pWalk, 3); 141 142 if (RT_LIKELY(GST_IS_PDPE_VALID(pVCpu, Pdpe))) { /* likely */ } 143 else return PGM_GST_NAME(WalkReturnRsvdError)(pVCpu, pWalk, 3); 144 145 # if PGM_GST_TYPE == PGM_TYPE_AMD64 146 pWalk->Core.fEffective = fEffective &= ((uint32_t)Pdpe.u & (X86_PDPE_RW | X86_PDPE_US | X86_PDPE_PWT | X86_PDPE_PCD | X86_PDPE_A)) 147 | ((uint32_t)(Pdpe.u >> 63) ^ 1) /*NX */; 148 # else 149 pWalk->Core.fEffective = fEffective = X86_PDPE_RW | X86_PDPE_US | X86_PDPE_A 150 | ((uint32_t)Pdpe.u & (X86_PDPE_PWT | X86_PDPE_PCD)) 151 | ((uint32_t)(Pdpe.u >> 63) ^ 1) /*NX */; 152 # endif 140 153 141 154 /* … … 143 156 */ 144 157 rc = PGM_GCPHYS_2_PTR_BY_VMCPU(pVCpu, Pdpe.u & X86_PDPE_PG_MASK, &pWalk->pPd); 145 if (RT_ FAILURE(rc))146 158 if (RT_SUCCESS(rc)) { /* probable */ } 159 else return PGM_GST_NAME(WalkReturnBadPhysAddr)(pVCpu, pWalk, 2, rc); 147 160 # elif PGM_GST_TYPE == PGM_TYPE_32BIT 148 161 rc = pgmGstGet32bitPDPtrEx(pVCpu, &pWalk->pPd); 149 if (RT_ FAILURE(rc))150 162 if (RT_SUCCESS(rc)) { /* probable */ } 163 else return PGM_GST_NAME(WalkReturnBadPhysAddr)(pVCpu, pWalk, 8, rc); 151 164 # endif 152 165 } 153 166 { 154 PGSTPD register pPd = pWalk->pPd;155 167 PGSTPDE register pPde; 168 pWalk->pPde = pPde = &pWalk->pPd->a[(GCPtr >> GST_PD_SHIFT) & GST_PD_MASK]; 156 169 GSTPDE Pde; 157 158 pWalk->pPde = pPde = &pPd->a[(GCPtr >> GST_PD_SHIFT) & GST_PD_MASK];159 170 pWalk->Pde.u = Pde.u = pPde->u; 160 if ( !Pde.n.u1Present)161 171 if (Pde.n.u1Present) { /* probable */ } 172 else return PGM_GST_NAME(WalkReturnNotPresent)(pVCpu, pWalk, 2); 162 173 if (Pde.n.u1Size && GST_IS_PSE_ACTIVE(pVCpu)) 163 174 { 164 if (RT_UNLIKELY(!GST_IS_BIG_PDE_VALID(pVCpu, Pde))) 165 return PGM_GST_NAME(WalkReturnRsvdError)(pVCpu, pWalk, 2); 175 if (RT_LIKELY(GST_IS_BIG_PDE_VALID(pVCpu, Pde))) { /* likely */ } 176 else return PGM_GST_NAME(WalkReturnRsvdError)(pVCpu, pWalk, 2); 177 178 /* 179 * We're done. 180 */ 181 # if PGM_GST_TYPE == PGM_TYPE_32BIT 182 fEffective &= Pde.u & (X86_PDE4M_RW | X86_PDE4M_US | X86_PDE4M_PWT | X86_PDE4M_PCD | X86_PDE4M_A); 183 # else 184 fEffective &= ((uint32_t)Pde.u & (X86_PDE4M_RW | X86_PDE4M_US | X86_PDE4M_PWT | X86_PDE4M_PCD | X86_PDE4M_A)) 185 | ((uint32_t)(Pde.u >> 63) ^ 1) /*NX */; 186 # endif 187 fEffective |= (uint32_t)Pde.u & (X86_PDE4M_D | X86_PDE4M_G); 188 fEffective |= (uint32_t)(Pde.u & X86_PDE4M_PAT) >> X86_PDE4M_PAT_SHIFT; 189 pWalk->Core.fEffective = fEffective; 190 191 pWalk->Core.fEffectiveRW = !!(fEffective & X86_PTE_RW); 192 pWalk->Core.fEffectiveUS = !!(fEffective & X86_PTE_US); 193 # if PGM_GST_TYPE == PGM_TYPE_AMD64 || PGM_GST_TYPE == PGM_TYPE_PAE 194 pWalk->Core.fEffectiveNX = !(fEffective & 1) && GST_IS_NX_ACTIVE(pVCpu); 195 # else 196 pWalk->Core.fEffectiveNX = false; 197 # endif 198 pWalk->Core.fBigPage = true; 199 pWalk->Core.fSucceeded = true; 166 200 167 201 pWalk->Core.GCPhys = GST_GET_BIG_PDE_GCPHYS(pVCpu->CTX_SUFF(pVM), Pde) 168 202 | (GCPtr & GST_BIG_PAGE_OFFSET_MASK); 169 203 PGM_A20_APPLY_TO_VAR(pVCpu, pWalk->Core.GCPhys); 170 uint8_t fEffectiveXX = (uint8_t)pWalk->Pde.u171 # if PGM_GST_TYPE == PGM_TYPE_AMD64172 & (uint8_t)pWalk->Pdpe.u173 & (uint8_t)pWalk->Pml4e.u174 # endif175 ;176 pWalk->Core.fEffectiveRW = !!(fEffectiveXX & X86_PTE_RW);177 pWalk->Core.fEffectiveUS = !!(fEffectiveXX & X86_PTE_US);178 # if PGM_GST_TYPE == PGM_TYPE_AMD64 || PGM_GST_TYPE == PGM_TYPE_PAE179 pWalk->Core.fEffectiveNX = ( pWalk->Pde.n.u1NoExecute180 # if PGM_GST_TYPE == PGM_TYPE_AMD64181 || pWalk->Pdpe.lm.u1NoExecute182 || pWalk->Pml4e.n.u1NoExecute183 # endif184 ) && GST_IS_NX_ACTIVE(pVCpu);185 # else186 pWalk->Core.fEffectiveNX = false;187 # endif188 pWalk->Core.fBigPage = true;189 pWalk->Core.fSucceeded = true;190 204 return VINF_SUCCESS; 191 205 } … … 193 207 if (RT_UNLIKELY(!GST_IS_PDE_VALID(pVCpu, Pde))) 194 208 return PGM_GST_NAME(WalkReturnRsvdError)(pVCpu, pWalk, 2); 209 # if PGM_GST_TYPE == PGM_TYPE_32BIT 210 pWalk->Core.fEffective = fEffective &= Pde.u & (X86_PDE_RW | X86_PDE_US | X86_PDE_PWT | X86_PDE_PCD | X86_PDE_A); 211 # else 212 pWalk->Core.fEffective = fEffective &= ((uint32_t)Pde.u & (X86_PDE_RW | X86_PDE_US | X86_PDE_PWT | X86_PDE_PCD | X86_PDE_A)) 213 | ((uint32_t)(Pde.u >> 63) ^ 1) /*NX */; 214 # endif 195 215 196 216 /* … … 198 218 */ 199 219 rc = PGM_GCPHYS_2_PTR_BY_VMCPU(pVCpu, GST_GET_PDE_GCPHYS(Pde), &pWalk->pPt); 200 if (RT_ FAILURE(rc))201 220 if (RT_SUCCESS(rc)) { /* probable */ } 221 else return PGM_GST_NAME(WalkReturnBadPhysAddr)(pVCpu, pWalk, 1, rc); 202 222 } 203 223 { 204 PGSTPT register pPt = pWalk->pPt;205 224 PGSTPTE register pPte; 225 pWalk->pPte = pPte = &pWalk->pPt->a[(GCPtr >> GST_PT_SHIFT) & GST_PT_MASK]; 206 226 GSTPTE register Pte; 207 208 pWalk->pPte = pPte = &pPt->a[(GCPtr >> GST_PT_SHIFT) & GST_PT_MASK];209 227 pWalk->Pte.u = Pte.u = pPte->u; 210 if (!Pte.n.u1Present) 211 return PGM_GST_NAME(WalkReturnNotPresent)(pVCpu, pWalk, 1); 212 if (RT_UNLIKELY(!GST_IS_PTE_VALID(pVCpu, Pte))) 213 return PGM_GST_NAME(WalkReturnRsvdError)(pVCpu, pWalk, 1); 228 229 if (Pte.n.u1Present) { /* probable */ } 230 else return PGM_GST_NAME(WalkReturnNotPresent)(pVCpu, pWalk, 1); 231 232 if (RT_LIKELY(GST_IS_PTE_VALID(pVCpu, Pte))) { /* likely */ } 233 else return PGM_GST_NAME(WalkReturnRsvdError)(pVCpu, pWalk, 1); 214 234 215 235 /* 216 236 * We're done. 217 237 */ 238 # if PGM_GST_TYPE == PGM_TYPE_32BIT 239 fEffective &= Pte.u & (X86_PTE_RW | X86_PTE_US | X86_PTE_PWT | X86_PTE_PCD | X86_PTE_A); 240 # else 241 fEffective &= ((uint32_t)Pte.u & (X86_PTE_RW | X86_PTE_US | X86_PTE_PWT | X86_PTE_PCD | X86_PTE_A)) 242 | ((uint32_t)(Pte.u >> 63) ^ 1) /*NX */; 243 # endif 244 fEffective |= (uint32_t)Pte.u & (X86_PTE_D | X86_PTE_PAT | X86_PTE_G); 245 pWalk->Core.fEffective = fEffective; 246 247 pWalk->Core.fEffectiveRW = !!(fEffective & X86_PTE_RW); 248 pWalk->Core.fEffectiveUS = !!(fEffective & X86_PTE_US); 249 # if PGM_GST_TYPE == PGM_TYPE_AMD64 || PGM_GST_TYPE == PGM_TYPE_PAE 250 pWalk->Core.fEffectiveNX = !(fEffective & 1) && GST_IS_NX_ACTIVE(pVCpu); 251 # else 252 pWalk->Core.fEffectiveNX = false; 253 # endif 254 pWalk->Core.fSucceeded = true; 255 218 256 pWalk->Core.GCPhys = GST_GET_PDE_GCPHYS(Pte) 219 257 | (GCPtr & PAGE_OFFSET_MASK); 220 uint8_t fEffectiveXX = (uint8_t)pWalk->Pte.u221 & (uint8_t)pWalk->Pde.u222 # if PGM_GST_TYPE == PGM_TYPE_AMD64223 & (uint8_t)pWalk->Pdpe.u224 & (uint8_t)pWalk->Pml4e.u225 # endif226 ;227 pWalk->Core.fEffectiveRW = !!(fEffectiveXX & X86_PTE_RW);228 pWalk->Core.fEffectiveUS = !!(fEffectiveXX & X86_PTE_US);229 # if PGM_GST_TYPE == PGM_TYPE_AMD64 || PGM_GST_TYPE == PGM_TYPE_PAE230 pWalk->Core.fEffectiveNX = ( pWalk->Pte.n.u1NoExecute231 || pWalk->Pde.n.u1NoExecute232 # if PGM_GST_TYPE == PGM_TYPE_AMD64233 || pWalk->Pdpe.lm.u1NoExecute234 || pWalk->Pml4e.n.u1NoExecute235 # endif236 ) && GST_IS_NX_ACTIVE(pVCpu);237 # else238 pWalk->Core.fEffectiveNX = false;239 # endif240 pWalk->Core.fSucceeded = true;241 258 return VINF_SUCCESS; 242 259 }
Note:
See TracChangeset
for help on using the changeset viewer.