Changeset 71836 in vbox
- Timestamp:
- Apr 12, 2018 8:13:03 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR0/HMSVMR0.cpp
r71833 r71836 1147 1147 * Flushes the appropriate tagged-TLB entries. 1148 1148 * 1149 * @param pVCpu The cross context virtual CPU structure. 1150 * @param pCtx Pointer to the guest-CPU or nested-guest-CPU context. 1151 * @param pVmcb Pointer to the VM control block. 1152 */ 1153 static void hmR0SvmFlushTaggedTlb(PVMCPU pVCpu, PCPUMCTX pCtx, PSVMVMCB pVmcb) 1149 * @param pVCpu The cross context virtual CPU structure. 1150 * @param pCtx Pointer to the guest-CPU or nested-guest-CPU context. 1151 * @param pVmcb Pointer to the VM control block. 1152 * @param pHostCpu Pointer to the HM host-CPU info. 1153 */ 1154 static void hmR0SvmFlushTaggedTlb(PVMCPU pVCpu, PCPUMCTX pCtx, PSVMVMCB pVmcb, PHMGLOBALCPUINFO pHostCpu) 1154 1155 { 1155 1156 #ifndef VBOX_WITH_NESTED_HWVIRT 1156 1157 RT_NOREF(pCtx); 1157 1158 #endif 1158 1159 PVM pVM = pVCpu->CTX_SUFF(pVM); 1160 PHMGLOBALCPUINFO pCpu = hmR0GetCurrentCpu(); 1159 PVM pVM = pVCpu->CTX_SUFF(pVM); 1161 1160 1162 1161 /* … … 1171 1170 */ 1172 1171 bool fNewAsid = false; 1173 Assert(p Cpu->idCpu != NIL_RTCPUID);1174 if ( pVCpu->hm.s.idLastCpu != p Cpu->idCpu1175 || pVCpu->hm.s.cTlbFlushes != p Cpu->cTlbFlushes1172 Assert(pHostCpu->idCpu != NIL_RTCPUID); 1173 if ( pVCpu->hm.s.idLastCpu != pHostCpu->idCpu 1174 || pVCpu->hm.s.cTlbFlushes != pHostCpu->cTlbFlushes 1176 1175 #ifdef VBOX_WITH_NESTED_HWVIRT 1177 1176 || CPUMIsGuestInSvmNestedHwVirtMode(pCtx) … … 1200 1199 if (pVM->hm.s.svm.fAlwaysFlushTLB) 1201 1200 { 1202 p Cpu->uCurrentAsid= 1;1201 pHostCpu->uCurrentAsid = 1; 1203 1202 pVCpu->hm.s.uCurrentAsid = 1; 1204 pVCpu->hm.s.cTlbFlushes = pCpu->cTlbFlushes; 1203 pVCpu->hm.s.cTlbFlushes = pHostCpu->cTlbFlushes; 1204 pVCpu->hm.s.idLastCpu = pHostCpu->idCpu; 1205 1205 pVmcb->ctrl.TLBCtrl.n.u8TLBFlush = SVM_TLB_FLUSH_ENTIRE; 1206 1206 1207 1207 /* Clear the VMCB Clean Bit for NP while flushing the TLB. See @bugref{7152}. */ 1208 1208 pVmcb->ctrl.u32VmcbCleanBits &= ~HMSVM_VMCB_CLEAN_NP; 1209 1210 /* Keep track of last CPU ID even when flushing all the time. */1211 if (fNewAsid)1212 pVCpu->hm.s.idLastCpu = pCpu->idCpu;1213 1209 } 1214 1210 else … … 1222 1218 if (fNewAsid) 1223 1219 { 1224 ++p Cpu->uCurrentAsid;1220 ++pHostCpu->uCurrentAsid; 1225 1221 1226 1222 bool fHitASIDLimit = false; 1227 if (p Cpu->uCurrentAsid >= pVM->hm.s.uMaxAsid)1223 if (pHostCpu->uCurrentAsid >= pVM->hm.s.uMaxAsid) 1228 1224 { 1229 p Cpu->uCurrentAsid = 1; /* Wraparound at 1; host uses 0 */1230 p Cpu->cTlbFlushes++; /* All VCPUs that run on this host CPU must use a new ASID. */1225 pHostCpu->uCurrentAsid = 1; /* Wraparound at 1; host uses 0 */ 1226 pHostCpu->cTlbFlushes++; /* All VCPUs that run on this host CPU must use a new ASID. */ 1231 1227 fHitASIDLimit = true; 1232 1228 } 1233 1229 1234 1230 if ( fHitASIDLimit 1235 || p Cpu->fFlushAsidBeforeUse)1231 || pHostCpu->fFlushAsidBeforeUse) 1236 1232 { 1237 1233 pVmcb->ctrl.TLBCtrl.n.u8TLBFlush = SVM_TLB_FLUSH_ENTIRE; 1238 p Cpu->fFlushAsidBeforeUse = false;1234 pHostCpu->fFlushAsidBeforeUse = false; 1239 1235 } 1240 1236 1241 pVCpu->hm.s.uCurrentAsid = p Cpu->uCurrentAsid;1242 pVCpu->hm.s.idLastCpu = p Cpu->idCpu;1243 pVCpu->hm.s.cTlbFlushes = p Cpu->cTlbFlushes;1237 pVCpu->hm.s.uCurrentAsid = pHostCpu->uCurrentAsid; 1238 pVCpu->hm.s.idLastCpu = pHostCpu->idCpu; 1239 pVCpu->hm.s.cTlbFlushes = pHostCpu->cTlbFlushes; 1244 1240 } 1245 1241 else … … 1262 1258 } 1263 1259 1264 AssertMsg(pVCpu->hm.s.idLastCpu == p Cpu->idCpu,1265 ("vcpu idLastCpu=%u pcpu idCpu=%u\n", pVCpu->hm.s.idLastCpu, pCpu->idCpu));1266 AssertMsg(pVCpu->hm.s.cTlbFlushes == p Cpu->cTlbFlushes,1267 ("Flush count mismatch for cpu %u (%u vs %u)\n", p Cpu->idCpu, pVCpu->hm.s.cTlbFlushes, pCpu->cTlbFlushes));1268 AssertMsg(p Cpu->uCurrentAsid >= 1 && pCpu->uCurrentAsid < pVM->hm.s.uMaxAsid,1269 ("cpu%d uCurrentAsid = %x\n", p Cpu->idCpu, pCpu->uCurrentAsid));1260 AssertMsg(pVCpu->hm.s.idLastCpu == pHostCpu->idCpu, 1261 ("vcpu idLastCpu=%u hostcpu idCpu=%u\n", pVCpu->hm.s.idLastCpu, pHostCpu->idCpu)); 1262 AssertMsg(pVCpu->hm.s.cTlbFlushes == pHostCpu->cTlbFlushes, 1263 ("Flush count mismatch for cpu %u (%u vs %u)\n", pHostCpu->idCpu, pVCpu->hm.s.cTlbFlushes, pHostCpu->cTlbFlushes)); 1264 AssertMsg(pHostCpu->uCurrentAsid >= 1 && pHostCpu->uCurrentAsid < pVM->hm.s.uMaxAsid, 1265 ("cpu%d uCurrentAsid = %x\n", pHostCpu->idCpu, pHostCpu->uCurrentAsid)); 1270 1266 AssertMsg(pVCpu->hm.s.uCurrentAsid >= 1 && pVCpu->hm.s.uCurrentAsid < pVM->hm.s.uMaxAsid, 1271 ("cpu%d VM uCurrentAsid = %x\n", p Cpu->idCpu, pVCpu->hm.s.uCurrentAsid));1267 ("cpu%d VM uCurrentAsid = %x\n", pHostCpu->idCpu, pVCpu->hm.s.uCurrentAsid)); 1272 1268 1273 1269 #ifdef VBOX_WITH_STATISTICS … … 4355 4351 AssertMsg(!HMCPU_CF_VALUE(pVCpu), ("fContextUseFlags=%#RX32\n", HMCPU_CF_VALUE(pVCpu))); 4356 4352 4357 PHMGLOBALCPUINFO pHostCpu = hmR0GetCurrentCpu();4358 RTCPUID const id CurrentCpu= pHostCpu->idCpu;4359 bool const fMigrated Cpu = idCurrentCpu != pVCpu->hm.s.idLastCpu;4353 PHMGLOBALCPUINFO pHostCpu = hmR0GetCurrentCpu(); 4354 RTCPUID const idHostCpu = pHostCpu->idCpu; 4355 bool const fMigratedHostCpu = idHostCpu != pVCpu->hm.s.idLastCpu; 4360 4356 4361 4357 /* Setup TSC offsetting. */ 4362 4358 if ( pSvmTransient->fUpdateTscOffsetting 4363 || fMigrated Cpu)4359 || fMigratedHostCpu) 4364 4360 { 4365 4361 hmR0SvmUpdateTscOffsettingNested(pVM, pVCpu, pCtx, pVmcbNstGst); … … 4368 4364 4369 4365 /* If we've migrating CPUs, mark the VMCB Clean bits as dirty. */ 4370 if (fMigrated Cpu)4366 if (fMigratedHostCpu) 4371 4367 pVmcbNstGst->ctrl.u32VmcbCleanBits = 0; 4372 4368 … … 4394 4390 /* The TLB flushing would've already been setup by the nested-hypervisor. */ 4395 4391 ASMAtomicWriteBool(&pVCpu->hm.s.fCheckedTLBFlush, true); /* Used for TLB flushing, set this across the world switch. */ 4396 hmR0SvmFlushTaggedTlb(pVCpu, pCtx, pVmcbNstGst );4397 Assert( hmR0GetCurrentCpu()->idCpu == pVCpu->hm.s.idLastCpu);4392 hmR0SvmFlushTaggedTlb(pVCpu, pCtx, pVmcbNstGst, pHostCpu); 4393 Assert(pVCpu->hm.s.idLastCpu == idHostCpu); 4398 4394 4399 4395 STAM_PROFILE_ADV_STOP_START(&pVCpu->hm.s.StatEntry, &pVCpu->hm.s.StatInGC, x); … … 4481 4477 AssertMsg(!HMCPU_CF_VALUE(pVCpu), ("fContextUseFlags=%#RX32\n", HMCPU_CF_VALUE(pVCpu))); 4482 4478 4479 PHMGLOBALCPUINFO pHostCpu = hmR0GetCurrentCpu(); 4480 RTCPUID const idHostCpu = pHostCpu->idCpu; 4481 bool const fMigratedHostCpu = idHostCpu != pVCpu->hm.s.idLastCpu; 4482 4483 4483 /* Setup TSC offsetting. */ 4484 RTCPUID idCurrentCpu = hmR0GetCurrentCpu()->idCpu;4485 4484 if ( pSvmTransient->fUpdateTscOffsetting 4486 || idCurrentCpu != pVCpu->hm.s.idLastCpu)4485 || fMigratedHostCpu) 4487 4486 { 4488 4487 hmR0SvmUpdateTscOffsetting(pVM, pVCpu, pVmcb); … … 4491 4490 4492 4491 /* If we've migrating CPUs, mark the VMCB Clean bits as dirty. */ 4493 if ( idCurrentCpu != pVCpu->hm.s.idLastCpu)4492 if (fMigratedHostCpu) 4494 4493 pVmcb->ctrl.u32VmcbCleanBits = 0; 4495 4494 … … 4511 4510 /* Flush the appropriate tagged-TLB entries. */ 4512 4511 ASMAtomicWriteBool(&pVCpu->hm.s.fCheckedTLBFlush, true); /* Used for TLB flushing, set this across the world switch. */ 4513 hmR0SvmFlushTaggedTlb(pVCpu, pCtx, pVmcb );4514 Assert( hmR0GetCurrentCpu()->idCpu == pVCpu->hm.s.idLastCpu);4512 hmR0SvmFlushTaggedTlb(pVCpu, pCtx, pVmcb, pHostCpu); 4513 Assert(pVCpu->hm.s.idLastCpu == idHostCpu); 4515 4514 4516 4515 STAM_PROFILE_ADV_STOP_START(&pVCpu->hm.s.StatEntry, &pVCpu->hm.s.StatInGC, x);
Note:
See TracChangeset
for help on using the changeset viewer.