Changeset 12657 in vbox for trunk/src/VBox/VMM/CPUM.cpp
- Timestamp:
- Sep 22, 2008 6:29:06 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/CPUM.cpp
r12600 r12657 28 28 * There are three CPU contexts, the most important one is the guest one (GC). 29 29 * When running in raw-mode (RC) there is a special hyper context for the VMM 30 * that floats around inside the guest address space. When running in raw-mode31 * or when using 64-bit guests on a 32-bit host, CPUM also maintains a host32 * context for saving and restoring registers accross world switches. This latter33 * is done in cooperation with theworld switcher (@see pg_vmm).30 * part that floats around inside the guest address space. When running in 31 * raw-mode, CPUM also maintains a host context for saving and restoring 32 * registers accross world switches. This latter is done in cooperation with the 33 * world switcher (@see pg_vmm). 34 34 */ 35 35 … … 65 65 *******************************************************************************/ 66 66 /** The saved state version. */ 67 #define CPUM_SAVED_STATE_VERSION 8 68 /** The saved state version of 1.6, used for backwards compatability. */ 67 69 #define CPUM_SAVED_STATE_VERSION_VER1_6 6 68 #define CPUM_SAVED_STATE_VERSION 869 70 70 71 … … 85 86 /** Pointer to a cpu info dump type. */ 86 87 typedef CPUMDUMPTYPE *PCPUMDUMPTYPE; 88 87 89 88 90 /******************************************************************************* … … 119 121 * Setup any fixed pointers and offsets. 120 122 */ 121 pVM->cpum.s.offVM = RT_OFFSETOF(VM, cpum);122 pVM->cpum.s.pCPUMHC = &pVM->cpum.s;123 123 pVM->cpum.s.pHyperCoreR3 = CPUMCTX2CORE(&pVM->cpum.s.Hyper); 124 124 pVM->cpum.s.pHyperCoreR0 = VM_R0_ADDR(pVM, CPUMCTX2CORE(&pVM->cpum.s.Hyper)); … … 130 130 * Check that the CPU supports the minimum features we require. 131 131 */ 132 /** @todo check the contract! */133 132 if (!ASMHasCpuId()) 134 133 { … … 510 509 * Load CPUID overrides from configuration. 511 510 */ 511 /** @cfgm{CPUM/CPUID/[000000xx|800000xx|c000000x]/[eax|ebx|ecx|edx],32-bit} 512 * Overloads the CPUID leaf values. */ 512 513 PCPUMCPUID pCpuId = &pCPUM->aGuestCpuIdStd[0]; 513 514 uint32_t cElements = RT_ELEMENTS(pCPUM->aGuestCpuIdStd); … … 603 604 * Switcher pointers. 604 605 */ 605 pVM->cpum.s.pCPUMGC = VM_GUEST_ADDR(pVM, &pVM->cpum.s); 606 pVM->cpum.s.pHyperCoreGC = MMHyperCCToRC(pVM, pVM->cpum.s.pHyperCoreR3); 607 Assert(pVM->cpum.s.pHyperCoreGC != NIL_RTGCPTR); 606 pVM->cpum.s.pHyperCoreRC = MMHyperCCToRC(pVM, pVM->cpum.s.pHyperCoreR3); 607 Assert(pVM->cpum.s.pHyperCoreRC != NIL_RTRCPTR); 608 608 } 609 609 … … 714 714 pCtx->fpu.FCW = 0x37f; 715 715 716 /* Intel ® 64 and IA-32 Architectures Software Developers Manual Volume 3A, Table 8-1. IA-32 Processor States Following Power-up, Reset, or INIT */716 /* Intel 64 and IA-32 Architectures Software Developer's Manual Volume 3A, Table 8-1. IA-32 Processor States Following Power-up, Reset, or INIT */ 717 717 pCtx->fpu.MXCSR = 0x1F80; 718 718 … … 765 765 } 766 766 767 767 768 /** 768 769 * Load a version 1.6 CPUMCTX structure. … … 774 775 static void cpumR3LoadCPUM1_6(PVM pVM, CPUMCTX_VER1_6 *pCpumctx16) 775 776 { 776 #define CPUMCTX16_LOADREG(regname) pVM->cpum.s.Guest.regname = pCpumctx16->regname; 777 778 #define CPUMCTX16_LOADDRXREG(regname) pVM->cpum.s.Guest.dr[regname] = pCpumctx16->dr##regname; 779 780 #define CPUMCTX16_LOADHIDREG(regname) \ 781 pVM->cpum.s.Guest.regname##Hid.u64Base = pCpumctx16->regname##Hid.u32Base; \ 782 pVM->cpum.s.Guest.regname##Hid.u32Limit = pCpumctx16->regname##Hid.u32Limit; \ 783 pVM->cpum.s.Guest.regname##Hid.Attr = pCpumctx16->regname##Hid.Attr; 784 785 #define CPUMCTX16_LOADSEGREG(regname) \ 786 pVM->cpum.s.Guest.regname = pCpumctx16->regname; \ 787 CPUMCTX16_LOADHIDREG(regname); 788 789 pVM->cpum.s.Guest.fpu = pCpumctx16->fpu; 777 #define CPUMCTX16_LOADREG(RegName) \ 778 pVM->cpum.s.Guest.RegName = pCpumctx16->RegName; 779 780 #define CPUMCTX16_LOADDRXREG(RegName) \ 781 pVM->cpum.s.Guest.dr[RegName] = pCpumctx16->dr##RegName; 782 783 #define CPUMCTX16_LOADHIDREG(RegName) \ 784 pVM->cpum.s.Guest.RegName##Hid.u64Base = pCpumctx16->RegName##Hid.u32Base; \ 785 pVM->cpum.s.Guest.RegName##Hid.u32Limit = pCpumctx16->RegName##Hid.u32Limit; \ 786 pVM->cpum.s.Guest.RegName##Hid.Attr = pCpumctx16->RegName##Hid.Attr; 787 788 #define CPUMCTX16_LOADSEGREG(RegName) \ 789 pVM->cpum.s.Guest.RegName = pCpumctx16->RegName; \ 790 CPUMCTX16_LOADHIDREG(RegName); 791 792 pVM->cpum.s.Guest.fpu = pCpumctx16->fpu; 790 793 791 794 CPUMCTX16_LOADREG(rax); … … 851 854 CPUMCTX16_LOADHIDREG(tr); 852 855 856 #undef CPUMCTX16_LOADSEGREG 853 857 #undef CPUMCTX16_LOADHIDREG 854 #undef CPUMCTX16_LOAD SEGREG858 #undef CPUMCTX16_LOADDRXREG 855 859 #undef CPUMCTX16_LOADREG 856 860 } 861 857 862 858 863 /** … … 977 982 * Format the flags. 978 983 */ 979 static struct984 static const struct 980 985 { 981 986 const char *pszSet; const char *pszClear; uint32_t fFlag; … … 1039 1044 case CPUMDUMPTYPE_TERSE: 1040 1045 if (CPUMIsGuestIn64BitCode(pVM, pCtxCore)) 1041 {1042 1046 pHlp->pfnPrintf(pHlp, 1043 1047 "%srax=%016RX64 %srbx=%016RX64 %srcx=%016RX64 %srdx=%016RX64\n" … … 1053 1057 pszPrefix, (RTSEL)pCtxCore->cs, pszPrefix, (RTSEL)pCtxCore->ss, pszPrefix, (RTSEL)pCtxCore->ds, pszPrefix, (RTSEL)pCtxCore->es, 1054 1058 pszPrefix, (RTSEL)pCtxCore->fs, pszPrefix, (RTSEL)pCtxCore->gs, pszPrefix, efl); 1055 }1056 1059 else 1057 1060 pHlp->pfnPrintf(pHlp, … … 1067 1070 case CPUMDUMPTYPE_DEFAULT: 1068 1071 if (CPUMIsGuestIn64BitCode(pVM, pCtxCore)) 1069 {1070 1072 pHlp->pfnPrintf(pHlp, 1071 1073 "%srax=%016RX64 %srbx=%016RX64 %srcx=%016RX64 %srdx=%016RX64\n" … … 1085 1087 pszPrefix, pCtx->cr0, pszPrefix, pCtx->cr2, pszPrefix, pCtx->cr3, pszPrefix, pCtx->cr4, 1086 1088 pszPrefix, pCtx->gdtr.pGdt, pCtx->gdtr.cbGdt, pszPrefix, (RTSEL)pCtx->ldtr); 1087 }1088 1089 else 1089 1090 pHlp->pfnPrintf(pHlp, … … 1103 1104 case CPUMDUMPTYPE_VERBOSE: 1104 1105 if (CPUMIsGuestIn64BitCode(pVM, pCtxCore)) 1105 {1106 1106 pHlp->pfnPrintf(pHlp, 1107 1107 "%srax=%016RX64 %srbx=%016RX64 %srcx=%016RX64 %srdx=%016RX64\n" … … 1141 1141 pszPrefix, (RTSEL)pCtx->tr, pCtx->trHid.u64Base, pCtx->trHid.u32Limit, pCtx->trHid.Attr.u, 1142 1142 pszPrefix, pCtx->SysEnter.cs, pCtx->SysEnter.eip, pCtx->SysEnter.esp); 1143 }1144 1143 else 1145 1144 pHlp->pfnPrintf(pHlp, … … 1181 1180 pszPrefix, pCtx->fpu.MXCSR, pszPrefix, pCtx->fpu.MXCSR_MASK); 1182 1181 1183 1184 1182 pHlp->pfnPrintf(pHlp, 1185 1183 "MSR:\n" … … 1198 1196 pszPrefix, pCtx->msrSFMASK, 1199 1197 pszPrefix, pCtx->msrKERNELGSBASE); 1200 1201 1198 break; 1202 1199 } … … 1276 1273 cpumR3InfoOne(pVM, &pVM->cpum.s.Guest, CPUMCTX2CORE(&pVM->cpum.s.Guest), pHlp, enmType, ""); 1277 1274 } 1275 1278 1276 1279 1277 /** … … 2260 2258 * @param pc GC instruction pointer 2261 2259 * @param prefix String prefix for logging 2260 * 2262 2261 * @deprecated Use DBGFR3DisasInstrCurrentLog(). 2263 *2264 2262 */ 2265 2263 CPUMR3DECL(void) CPUMR3DisasmInstr(PVM pVM, PCPUMCTX pCtx, RTGCPTR pc, char *prefix) 2266 2264 { 2267 DISCPUSTATE cpu;2268 2269 CPUMR3DisasmInstrCPU(pVM, pCtx, pc, &cpu, prefix); 2270 } 2265 DISCPUSTATE Cpu; 2266 CPUMR3DisasmInstrCPU(pVM, pCtx, pc, &Cpu, prefix); 2267 } 2268 2271 2269 2272 2270 /** … … 2280 2278 * @param nrInstructions 2281 2279 * 2280 * @deprecated Create new DBGFR3Disas function to do this. 2282 2281 */ 2283 2282 CPUMR3DECL(void) CPUMR3DisasmBlock(PVM pVM, PCPUMCTX pCtx, RTGCPTR pc, char *prefix, int nrInstructions) 2284 2283 { 2285 for (int i=0;i<nrInstructions;i++)2284 for (int i = 0; i < nrInstructions; i++) 2286 2285 { 2287 2286 DISCPUSTATE cpu; … … 2292 2291 } 2293 2292 2293 2294 /** 2295 * Debug helper - Saves guest context on raw mode entry (for fatal dump) 2296 * 2297 * @internal 2298 */ 2299 CPUMR3DECL(void) CPUMR3SaveEntryCtx(PVM pVM) 2300 { 2301 pVM->cpum.s.GuestEntry = pVM->cpum.s.Guest; 2302 } 2303 2294 2304 #endif /* DEBUG */ 2295 2296 #ifdef DEBUG2297 /**2298 * Debug helper - Saves guest context on raw mode entry (for fatal dump)2299 *2300 * @internal2301 */2302 CPUMR3DECL(void) CPUMR3SaveEntryCtx(PVM pVM)2303 {2304 pVM->cpum.s.GuestEntry = pVM->cpum.s.Guest;2305 }2306 #endif /* DEBUG */2307 2308 2305 2309 2306 /**
Note:
See TracChangeset
for help on using the changeset viewer.