Changeset 12657 in vbox for trunk/src/VBox/VMM/VMMR0/CPUMR0.cpp
- Timestamp:
- Sep 22, 2008 6:29:06 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR0/CPUMR0.cpp
r12600 r12657 36 36 37 37 38 39 38 /** 40 39 * Does Ring-0 CPUM initialization. … … 53 52 * Check CR0 & CR4 flags. 54 53 */ 55 uint32_t 54 uint32_t u32CR0 = ASMGetCR0(); 56 55 if ((u32CR0 & (X86_CR0_PE | X86_CR0_PG)) != (X86_CR0_PE | X86_CR0_PG)) /* a bit paranoid perhaps.. */ 57 56 { … … 99 98 * This ASSUMES that DR7.GD is not set, or that it's handled transparently! 100 99 */ 101 uint32_t 100 uint32_t u32DR7 = ASMGetDR7(); 102 101 if (u32DR7 & X86_DR7_ENABLED_MASK) 103 102 { … … 155 154 */ 156 155 157 switch(pCtx->cr0 & (X86_CR0_MP | X86_CR0_EM | X86_CR0_TS)) 158 { 159 case X86_CR0_MP | X86_CR0_TS: 160 case X86_CR0_MP | X86_CR0_EM | X86_CR0_TS: 161 return VINF_EM_RAW_GUEST_TRAP; 162 163 default: 164 break; 156 switch (pCtx->cr0 & (X86_CR0_MP | X86_CR0_EM | X86_CR0_TS)) 157 { 158 case X86_CR0_MP | X86_CR0_TS: 159 case X86_CR0_MP | X86_CR0_EM | X86_CR0_TS: 160 return VINF_EM_RAW_GUEST_TRAP; 161 default: 162 break; 165 163 } 166 164 … … 172 170 if (pVM->cpum.s.CPUFeaturesExt.edx & X86_CPUID_AMD_FEATURE_EDX_FFXSR) 173 171 { 174 /* @todo Do we really need to read this every time?? The host could change this on the fly though. */ 172 /** @todo Do we really need to read this every time?? The host could change this on the fly though. 173 * bird: what about starting by skipping the ASMWrMsr below if we didn't 174 * change anything? Ditto for the stuff in CPUMR0SaveGuestFPU. */ 175 175 oldMsrEFERHost = ASMRdMsr(MSR_K6_EFER); 176 177 176 if (oldMsrEFERHost & MSR_K6_EFER_FFXSR) 178 177 { … … 193 192 /* CPUMHandleLazyFPU could have changed CR0; restore it. */ 194 193 ASMSetCR0(oldCR0); 195 #else 196 /* Save the FPU control word and MXCSR, so we can restore the state properly afterwards. 194 195 #else /* CPUM_CAN_HANDLE_NM_TRAPS_IN_KERNEL_MODE */ 196 197 /* 198 * Save the FPU control word and MXCSR, so we can restore the state properly afterwards. 197 199 * We don't want the guest to be able to trigger floating point/SSE exceptions on the host. 198 200 */ … … 203 205 CPUMLoadFPUAsm(pCtx); 204 206 205 /* The MSR_K6_EFER_FFXSR feature is AMD only so far, but check the cpuid just in case Intel adds it in the future. 207 /* 208 * The MSR_K6_EFER_FFXSR feature is AMD only so far, but check the cpuid just in case Intel adds it in the future. 206 209 * 207 210 * MSR_K6_EFER_FFXSR changes the behaviour of fxsave and fxrstore: the XMM state isn't saved/restored … … 209 212 if (pVM->cpum.s.CPUFeaturesExt.edx & X86_CPUID_AMD_FEATURE_EDX_FFXSR) 210 213 { 211 /* @todo Do we really need to read this every time?? The host could change this on the fly though. */214 /** @todo Do we really need to read this every time?? The host could change this on the fly though. */ 212 215 uint64_t msrEFERHost = ASMRdMsr(MSR_K6_EFER); 213 216 … … 219 222 } 220 223 } 221 #endif 224 #endif /* CPUM_CAN_HANDLE_NM_TRAPS_IN_KERNEL_MODE */ 222 225 223 226 pVM->cpum.s.fUseFlags |= CPUM_USED_FPU; … … 254 257 ASMWrMsr(MSR_K6_EFER, oldMsrEFERHost | MSR_K6_EFER_FFXSR); 255 258 256 #else 259 #else /* CPUM_CAN_HANDLE_NM_TRAPS_IN_KERNEL_MODE */ 257 260 CPUMSaveFPUAsm(pCtx); 258 261 if (pVM->cpum.s.fUseFlags & CPUM_MANUAL_XMM_RESTORE) … … 261 264 CPUMSaveXMMAsm(pCtx); 262 265 } 263 /* Restore the original FPU control word and MXCSR. 266 267 /* 268 * Restore the original FPU control word and MXCSR. 264 269 * We don't want the guest to be able to trigger floating point/SSE exceptions on the host. 265 270 */ … … 267 272 if (pVM->cpum.s.CPUFeatures.edx.u1SSE) 268 273 CPUMSetMXCSR(pVM->cpum.s.Host.fpu.MXCSR); 269 #endif 270 271 pVM->cpum.s.fUseFlags &= ~(CPUM_USED_FPU |CPUM_MANUAL_XMM_RESTORE);274 #endif /* CPUM_CAN_HANDLE_NM_TRAPS_IN_KERNEL_MODE */ 275 276 pVM->cpum.s.fUseFlags &= ~(CPUM_USED_FPU | CPUM_MANUAL_XMM_RESTORE); 272 277 return VINF_SUCCESS; 273 278 } … … 294 299 pCtx->dr[6] = ASMGetDR6(); 295 300 296 /* Restore the host's debug state. DR0-3, DR6 and only then DR7! 301 /* 302 * Restore the host's debug state. DR0-3, DR6 and only then DR7! 297 303 * DR7 contains 0x400 right now. 298 304 */ … … 325 331 pVM->cpum.s.Host.dr3 = ASMGetDR3(); 326 332 pVM->cpum.s.Host.dr6 = ASMGetDR6(); 327 /* @todo dr7 might already have been changed to 0x400; don't care right now as it's harmless. */333 /** @todo dr7 might already have been changed to 0x400; don't care right now as it's harmless. */ 328 334 pVM->cpum.s.Host.dr7 = ASMGetDR7(); 329 335 /* Make sure DR7 is harmless or else we could trigger breakpoints when restoring dr0-3 (!) */ … … 341 347 return VINF_SUCCESS; 342 348 } 349
Note:
See TracChangeset
for help on using the changeset viewer.