Changeset 18927 in vbox for trunk/src/VBox/VMM/CPUM.cpp
- Timestamp:
- Apr 16, 2009 11:41:38 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/CPUM.cpp
r17034 r18927 122 122 * Assert alignment and sizes. 123 123 */ 124 AssertRelease(!(RT_OFFSETOF(VM, cpum.s) & 31)); 125 AssertRelease(sizeof(pVM->cpum.s) <= sizeof(pVM->cpum.padding)); 126 127 /* 128 * Setup any fixed pointers and offsets. 129 */ 130 pVM->cpum.s.pHyperCoreR3 = CPUMCTX2CORE(&pVM->cpum.s.Hyper); 131 pVM->cpum.s.pHyperCoreR0 = VM_R0_ADDR(pVM, CPUMCTX2CORE(&pVM->cpum.s.Hyper)); 132 133 /* Hidden selector registers are invalid by default. */ 134 pVM->cpum.s.fValidHiddenSelRegs = false; 124 AssertCompile(!(RT_OFFSETOF(VM, cpum.s) & 31)); 125 AssertCompile(sizeof(pVM->cpum.s) <= sizeof(pVM->cpum.padding)); 126 AssertCompile(!(sizeof(CPUMCTX) & 63)); 127 AssertCompile(!(sizeof(CPUMCTXMSR) & 63)); 128 AssertCompile(!(sizeof(CPUMHOSTCTX) & 63)); 129 AssertCompile(!(RT_OFFSETOF(VM, cpum) & 63)); 130 AssertCompile(!(RT_OFFSETOF(VM, aCpus) & 63)); 131 AssertCompile(!(RT_OFFSETOF(VMCPU, cpum.s) & 63)); 132 AssertCompile(!(sizeof(pVM->aCpus[0].cpum.s) & 63)); 135 133 136 134 /* Calculate the offset from CPUM to CPUMCPU for the first CPU. */ … … 141 139 for (unsigned i=0;i<pVM->cCPUs;i++) 142 140 { 143 pVM->aCpus[i].cpum.s.ulOffCPUM = RT_OFFSETOF(VM, aCpus[i].cpum) - RT_OFFSETOF(VM, cpum); 144 Assert((uintptr_t)&pVM->aCpus[i].cpum - pVM->aCpus[i].cpum.s.ulOffCPUM == (uintptr_t)&pVM->cpum); 141 PVMCPU pVCpu = &pVM->aCpus[i]; 142 143 /* 144 * Setup any fixed pointers and offsets. 145 */ 146 pVCpu->cpum.s.pHyperCoreR3 = CPUMCTX2CORE(&pVCpu->cpum.s.Hyper); 147 pVCpu->cpum.s.pHyperCoreR0 = VM_R0_ADDR(pVM, CPUMCTX2CORE(&pVCpu->cpum.s.Hyper)); 148 149 pVCpu->cpum.s.ulOffCPUM = RT_OFFSETOF(VM, aCpus[i].cpum) - RT_OFFSETOF(VM, cpum); 150 Assert((uintptr_t)&pVCpu->cpum - pVCpu->cpum.s.ulOffCPUM == (uintptr_t)&pVM->cpum); 145 151 } 146 152 … … 637 643 { 638 644 LogFlow(("CPUMR3Relocate\n")); 639 /* 640 * Switcher pointers. 641 */ 642 pVM->cpum.s.pHyperCoreRC = MMHyperCCToRC(pVM, pVM->cpum.s.pHyperCoreR3); 643 Assert(pVM->cpum.s.pHyperCoreRC != NIL_RTRCPTR); 645 for (unsigned i=0;i<pVM->cCPUs;i++) 646 { 647 PVMCPU pVCpu = &pVM->aCpus[i]; 648 /* 649 * Switcher pointers. 650 */ 651 pVCpu->cpum.s.pHyperCoreRC = MMHyperCCToRC(pVM, pVCpu->cpum.s.pHyperCoreR3); 652 Assert(pVCpu->cpum.s.pHyperCoreRC != NIL_RTRCPTR); 653 } 644 654 } 645 655 … … 675 685 for (unsigned i=0;i<pVM->cCPUs;i++) 676 686 { 677 PCPUMCTX pCtx = CPUMQueryGuestCtxPtrEx(pVM, &pVM->aCpus[i]); 678 679 memset(pVM->aCpus[i].cpum.s.aMagic, 0, sizeof(pVM->aCpus[i].cpum.s.aMagic)); 680 pVM->aCpus[i].cpum.s.uMagic = 0; 681 pCtx->dr[5] = 0; 687 PVMCPU pVCpu = &pVM->aCpus[i]; 688 PCPUMCTX pCtx = CPUMQueryGuestCtxPtr(pVCpu); 689 690 memset(pVCpu->cpum.s.aMagic, 0, sizeof(pVCpu->cpum.s.aMagic)); 691 pVCpu->cpum.s.uMagic = 0; 692 pCtx->dr[5] = 0; 682 693 } 683 694 #endif … … 697 708 for (unsigned i=0;i<pVM->cCPUs;i++) 698 709 { 699 PCPUMCTX pCtx = CPUMQueryGuestCtxPtr Ex(pVM,&pVM->aCpus[i]);710 PCPUMCTX pCtx = CPUMQueryGuestCtxPtr(&pVM->aCpus[i]); 700 711 701 712 /* … … 793 804 * Save. 794 805 */ 795 SSMR3PutMem(pSSM, &pVM->cpum.s.Hyper, sizeof(pVM->cpum.s.Hyper)); 806 for (unsigned i=0;i<pVM->cCPUs;i++) 807 { 808 PVMCPU pVCpu = &pVM->aCpus[i]; 809 810 SSMR3PutMem(pSSM, &pVCpu->cpum.s.Hyper, sizeof(pVCpu->cpum.s.Hyper)); 811 } 796 812 797 813 SSMR3PutU32(pSSM, pVM->cCPUs); 798 814 for (unsigned i=0;i<pVM->cCPUs;i++) 799 815 { 800 SSMR3PutMem(pSSM, &pVM->aCpus[i].cpum.s.Guest, sizeof(pVM->aCpus[i].cpum.s.Guest)); 801 SSMR3PutU32(pSSM, pVM->aCpus[i].cpum.s.fUseFlags); 802 SSMR3PutU32(pSSM, pVM->aCpus[i].cpum.s.fChanged); 803 SSMR3PutMem(pSSM, &pVM->aCpus[i].cpum.s.GuestMsr, sizeof(pVM->aCpus[i].cpum.s.GuestMsr)); 816 PVMCPU pVCpu = &pVM->aCpus[i]; 817 818 SSMR3PutMem(pSSM, &pVCpu->cpum.s.Guest, sizeof(pVCpu->cpum.s.Guest)); 819 SSMR3PutU32(pSSM, pVCpu->cpum.s.fUseFlags); 820 SSMR3PutU32(pSSM, pVCpu->cpum.s.fChanged); 821 SSMR3PutMem(pSSM, &pVCpu->cpum.s.GuestMsr, sizeof(pVCpu->cpum.s.GuestMsr)); 804 822 } 805 823 … … 949 967 * Restore. 950 968 */ 951 uint32_t uCR3 = pVM->cpum.s.Hyper.cr3; 952 uint32_t uESP = pVM->cpum.s.Hyper.esp; /* see VMMR3Relocate(). */ 953 SSMR3GetMem(pSSM, &pVM->cpum.s.Hyper, sizeof(pVM->cpum.s.Hyper)); 954 pVM->cpum.s.Hyper.cr3 = uCR3; 955 pVM->cpum.s.Hyper.esp = uESP; 969 for (unsigned i=0;i<pVM->cCPUs;i++) 970 { 971 PVMCPU pVCpu = &pVM->aCpus[i]; 972 uint32_t uCR3 = pVCpu->cpum.s.Hyper.cr3; 973 uint32_t uESP = pVCpu->cpum.s.Hyper.esp; /* see VMMR3Relocate(). */ 974 975 SSMR3GetMem(pSSM, &pVCpu->cpum.s.Hyper, sizeof(pVCpu->cpum.s.Hyper)); 976 pVCpu->cpum.s.Hyper.cr3 = uCR3; 977 pVCpu->cpum.s.Hyper.esp = uESP; 978 } 979 956 980 if (u32Version == CPUM_SAVED_STATE_VERSION_VER1_6) 957 981 { … … 1133 1157 { 1134 1158 case CPUMDUMPTYPE_TERSE: 1135 if (CPUMIsGuestIn64BitCode (pVM, pCtxCore))1159 if (CPUMIsGuestIn64BitCodeEx(pCtx)) 1136 1160 pHlp->pfnPrintf(pHlp, 1137 1161 "%srax=%016RX64 %srbx=%016RX64 %srcx=%016RX64 %srdx=%016RX64\n" … … 1159 1183 1160 1184 case CPUMDUMPTYPE_DEFAULT: 1161 if (CPUMIsGuestIn64BitCode (pVM, pCtxCore))1185 if (CPUMIsGuestIn64BitCodeEx(pCtx)) 1162 1186 pHlp->pfnPrintf(pHlp, 1163 1187 "%srax=%016RX64 %srbx=%016RX64 %srcx=%016RX64 %srdx=%016RX64\n" … … 1193 1217 1194 1218 case CPUMDUMPTYPE_VERBOSE: 1195 if (CPUMIsGuestIn64BitCode (pVM, pCtxCore))1219 if (CPUMIsGuestIn64BitCodeEx(pCtx)) 1196 1220 pHlp->pfnPrintf(pHlp, 1197 1221 "%srax=%016RX64 %srbx=%016RX64 %srcx=%016RX64 %srdx=%016RX64\n" … … 1361 1385 cpumR3InfoParseArg(pszArgs, &enmType, &pszComment); 1362 1386 pHlp->pfnPrintf(pHlp, "Guest CPUM state: %s\n", pszComment); 1363 /* @todo SMP */ 1364 PCPUMCTX pCtx = CPUMQueryGuestCtxPtr(pVM); 1387 1388 /* @todo SMP support! */ 1389 PVMCPU pVCpu = &pVM->aCpus[0]; 1390 PCPUMCTX pCtx = CPUMQueryGuestCtxPtr(pVCpu); 1365 1391 cpumR3InfoOne(pVM, pCtx, CPUMCTX2CORE(pCtx), pHlp, enmType, ""); 1366 1392 } … … 1394 1420 CPUMDUMPTYPE enmType; 1395 1421 const char *pszComment; 1422 /* @todo SMP */ 1423 PVMCPU pVCpu = &pVM->aCpus[0]; 1424 1396 1425 cpumR3InfoParseArg(pszArgs, &enmType, &pszComment); 1397 1426 pHlp->pfnPrintf(pHlp, "Hypervisor CPUM state: %s\n", pszComment); 1398 cpumR3InfoOne(pVM, &pV M->cpum.s.Hyper, pVM->cpum.s.pHyperCoreR3, pHlp, enmType, ".");1427 cpumR3InfoOne(pVM, &pVCpu->cpum.s.Hyper, pVCpu->cpum.s.pHyperCoreR3, pHlp, enmType, "."); 1399 1428 pHlp->pfnPrintf(pHlp, "CR4OrMask=%#x CR4AndMask=%#x\n", pVM->cpum.s.CR4.OrMask, pVM->cpum.s.CR4.AndMask); 1400 1429 } … … 2136 2165 /** The VM handle. */ 2137 2166 PVM pVM; 2167 /** The VMCPU handle. */ 2168 PVMCPU pVCpu; 2138 2169 /** Pointer to the first byte in the segemnt. */ 2139 2170 RTGCUINTPTR GCPtrSegBase; … … 2195 2226 if (pState->fLocked) 2196 2227 PGMPhysReleasePageMappingLock(pState->pVM, &pState->PageMapLock); 2197 rc = PGMPhysGCPtr2CCPtrReadOnly(pState->pV M, pState->pvPageGC, &pState->pvPageR3, &pState->PageMapLock);2228 rc = PGMPhysGCPtr2CCPtrReadOnly(pState->pVCpu, pState->pvPageGC, &pState->pvPageR3, &pState->PageMapLock); 2198 2229 pState->fLocked = RT_SUCCESS_NP(rc); 2199 2230 } … … 2236 2267 * @returns VBox status code. 2237 2268 * @param pVM VM Handle 2269 * @param pVCpu VMCPU Handle 2238 2270 * @param pCtx CPU context 2239 2271 * @param GCPtrPC Program counter (relative to CS) to disassemble from. … … 2242 2274 * 2243 2275 */ 2244 VMMR3DECL(int) CPUMR3DisasmInstrCPU(PVM pVM, P CPUMCTX pCtx, RTGCPTR GCPtrPC, PDISCPUSTATE pCpu, const char *pszPrefix)2276 VMMR3DECL(int) CPUMR3DisasmInstrCPU(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx, RTGCPTR GCPtrPC, PDISCPUSTATE pCpu, const char *pszPrefix) 2245 2277 { 2246 2278 CPUMDISASSTATE State; 2247 2279 int rc; 2248 2280 2249 const PGMMODE enmMode = PGMGetGuestMode(pV M);2281 const PGMMODE enmMode = PGMGetGuestMode(pVCpu); 2250 2282 State.pCpu = pCpu; 2251 2283 State.pvPageGC = 0; 2252 2284 State.pvPageR3 = NULL; 2253 2285 State.pVM = pVM; 2286 State.pVCpu = pVCpu; 2254 2287 State.fLocked = false; 2255 2288 State.f64Bits = false; … … 2349 2382 * @returns VBox status code. 2350 2383 * @param pVM VM Handle 2384 * @param pVCpu VMCPU Handle 2351 2385 * @param pCtx CPU context 2352 2386 * @param pc GC instruction pointer … … 2355 2389 * @deprecated Use DBGFR3DisasInstrCurrentLog(). 2356 2390 */ 2357 VMMR3DECL(void) CPUMR3DisasmInstr(PVM pVM, P CPUMCTX pCtx, RTGCPTR pc, const char *pszPrefix)2391 VMMR3DECL(void) CPUMR3DisasmInstr(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx, RTGCPTR pc, const char *pszPrefix) 2358 2392 { 2359 2393 DISCPUSTATE Cpu; 2360 CPUMR3DisasmInstrCPU(pVM, pCtx, pc, &Cpu, pszPrefix); 2361 } 2362 2363 2364 /** 2365 * Disassemble an instruction and dump it to the log 2366 * 2367 * @returns VBox status code. 2368 * @param pVM VM Handle 2369 * @param pCtx CPU context 2370 * @param pc GC instruction pointer 2371 * @param pszPrefix String prefix for logging 2372 * @param nrInstructions 2373 * 2374 * @deprecated Create new DBGFR3Disas function to do this. 2375 */ 2376 VMMR3DECL(void) CPUMR3DisasmBlock(PVM pVM, PCPUMCTX pCtx, RTGCPTR pc, const char *pszPrefix, int nrInstructions) 2377 { 2378 for (int i = 0; i < nrInstructions; i++) 2379 { 2380 DISCPUSTATE cpu; 2381 2382 CPUMR3DisasmInstrCPU(pVM, pCtx, pc, &cpu, pszPrefix); 2383 pc += cpu.opsize; 2384 } 2394 CPUMR3DisasmInstrCPU(pVM, pVCpu, pCtx, pc, &Cpu, pszPrefix); 2385 2395 } 2386 2396 … … 2393 2403 VMMR3DECL(void) CPUMR3SaveEntryCtx(PVM pVM) 2394 2404 { 2395 /* @todo SMP */2396 pVM->cpum.s.GuestEntry = *CPUMQueryGuestCtxPtr( pVM);2405 /* @todo SMP support!! */ 2406 pVM->cpum.s.GuestEntry = *CPUMQueryGuestCtxPtr(VMMGetCpu(pVM)); 2397 2407 } 2398 2408
Note:
See TracChangeset
for help on using the changeset viewer.