Changeset 10687 in vbox for trunk/src/VBox
- Timestamp:
- Jul 16, 2008 9:22:28 AM (16 years ago)
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/CPUM.cpp
r10571 r10687 83 83 typedef CPUMDUMPTYPE *PCPUMDUMPTYPE; 84 84 85 86 85 /******************************************************************************* 87 86 * Internal Functions * … … 135 134 } 136 135 ASMCpuId_ECX_EDX(1, &pVM->cpum.s.CPUFeatures.ecx, &pVM->cpum.s.CPUFeatures.edx); 136 ASMCpuId_ECX_EDX(0x80000001, &pVM->cpum.s.CPUFeaturesExt.ecx, &pVM->cpum.s.CPUFeaturesExt.edx); 137 137 138 138 /* Setup the CR4 AND and OR masks used in the switcher */ -
trunk/src/VBox/VMM/CPUMInternal.h
r10647 r10687 322 322 X86CPUIDFEATECX ecx; 323 323 } CPUFeatures; 324 /** Host extended CPU features. */ 325 struct 326 { 327 /** edx part */ 328 uint32_t edx; 329 /** ecx part */ 330 uint32_t ecx; 331 } CPUFeaturesExt; 324 332 325 333 /* CPU manufacturer. */ … … 360 368 __BEGIN_DECLS 361 369 362 DECLASM(int) CPUMHandleLazyFPUAsm(PCPUM pCPUM); 363 DECLASM(int) CPUMRestoreHostFPUStateAsm(PCPUM pCPUM); 364 DECLASM(void) CPUMLoadFPUAsm(PCPUMCTX pCtx); 365 DECLASM(void) CPUMSaveFPUAsm(PCPUMCTX pCtx); 366 DECLASM(void) CPUMLoadXMMAsm(PCPUMCTX pCtx); 367 DECLASM(void) CPUMSaveXMMAsm(PCPUMCTX pCtx); 368 370 DECLASM(int) CPUMHandleLazyFPUAsm(PCPUM pCPUM); 371 DECLASM(int) CPUMRestoreHostFPUStateAsm(PCPUM pCPUM); 372 DECLASM(void) CPUMLoadFPUAsm(PCPUMCTX pCtx); 373 DECLASM(void) CPUMSaveFPUAsm(PCPUMCTX pCtx); 374 DECLASM(void) CPUMLoadXMMAsm(PCPUMCTX pCtx); 375 DECLASM(void) CPUMSaveXMMAsm(PCPUMCTX pCtx); 376 DECLASM(void) CPUMSetFCW(uint16_t u16FCW); 377 DECLASM(uint16_t) CPUMGetFCW(); 378 DECLASM(void) CPUMSetMXCSR(uint32_t u32MXCSR); 379 DECLASM(uint32_t) CPUMGetMXCSR(); 369 380 370 381 __END_DECLS -
trunk/src/VBox/VMM/CPUMInternal.mac
r10569 r10687 406 406 .CPUFeatures.ecx resd 1 407 407 408 ; CPUID eax=0x80000001 409 .CPUFeaturesExt.edx resd 1 410 .CPUFeaturesExt.ecx resd 1 411 408 412 .enmCPUVendor resd 1 409 413 -
trunk/src/VBox/VMM/VMMAll/CPUMAllA.asm
r10648 r10687 291 291 ; @param pCtx x86:[esp+4] GCC:rdi MSC:rcx CPUMCTX pointer 292 292 ; 293 align 16 293 294 BEGINPROC CPUMLoadXMMAsm 294 295 %ifdef RT_ARCH_AMD64 … … 334 335 ; @param pCtx x86:[esp+4] GCC:rdi MSC:rcx CPUMCTX pointer 335 336 ; 337 align 16 336 338 BEGINPROC CPUMSaveXMMAsm 337 339 %ifdef RT_ARCH_AMD64 … … 371 373 ENDPROC CPUMSaveXMMAsm 372 374 375 376 ;; 377 ; Set the FPU control word; clearing exceptions first 378 ; 379 ; @param u16FCW x86:[esp+4] GCC:rdi MSC:rcx New FPU control word 380 align 16 381 BEGINPROC CPUMSetFCW 382 %ifdef RT_ARCH_AMD64 383 %ifdef RT_OS_WINDOWS 384 mov xAX, rcx 385 %else 386 mov xAX, rdi 387 %endif 388 %else 389 mov xAX, dword [esp + 4] 390 %endif 391 fnclex 392 push xAX 393 fldcw [xSP] 394 pop xAX 395 ret 396 ENDPROC CPUMSetFCW 397 398 ;; 399 ; Get the FPU control word 400 ; 401 align 16 402 BEGINPROC CPUMGetFCW 403 fnstcw [xSP - 8] 404 mov ax, word [xSP - 8] 405 ret 406 ENDPROC CPUMGetFCW 407 408 409 ;; 410 ; Set the MXCSR; 411 ; 412 ; @param u32MXCSR x86:[esp+4] GCC:rdi MSC:rcx New MXCSR 413 align 16 414 BEGINPROC CPUMSetMXCSR 415 %ifdef RT_ARCH_AMD64 416 %ifdef RT_OS_WINDOWS 417 mov xAX, rcx 418 %else 419 mov xAX, rdi 420 %endif 421 %else 422 mov xAX, dword [esp + 4] 423 %endif 424 push xAX 425 ldmxcsr [xSP] 426 pop xAX 427 ret 428 ENDPROC CPUMSetMXCSR 429 430 ;; 431 ; Get the MXCSR 432 ; 433 align 16 434 BEGINPROC CPUMGetMXCSR 435 stmxcsr [xSP - 8] 436 mov eax, dword [xSP - 8] 437 ret 438 ENDPROC CPUMGetMXCSR -
trunk/src/VBox/VMM/VMMR0/CPUMR0.cpp
r10673 r10687 163 163 break; 164 164 } 165 /* Save the FPU control word and MXCSR, so we can restore the properly afterwards. 166 * We don't want the guest to be able to trigger floating point/SSE exceptions on the host. 167 */ 168 pVM->cpum.s.Host.fpu.FCW = CPUMGetFCW(); 169 if (pVM->cpum.s.CPUFeatures.edx.u1SSE) 170 pVM->cpum.s.Host.fpu.MXCSR = CPUMGetMXCSR(); 171 165 172 CPUMLoadFPUAsm(pCtx); 166 173 … … 169 176 * MSR_K6_EFER_FFXSR changes the behaviour of fxsave and fxrstore: the XMM state isn't saved/restored 170 177 */ 171 if (pVM->cpum.s. aGuestCpuIdExt[1].edx & X86_CPUID_AMD_FEATURE_EDX_FFXSR /* cpuid 0x80000001 */)178 if (pVM->cpum.s.CPUFeaturesExt.edx & X86_CPUID_AMD_FEATURE_EDX_FFXSR) 172 179 { 173 180 /* @todo Do we really need to read this every time?? The host could change this on the fly though. */ 174 /* Note: Solaris sets this bit on a per-process basis, so we do need to check each time. */175 181 uint64_t msrEFERHost = ASMRdMsr(MSR_K6_EFER); 176 182 … … 207 213 CPUMSaveXMMAsm(pCtx); 208 214 } 215 /* Restore the original FPU control word and MXCSR. 216 * We don't want the guest to be able to trigger floating point/SSE exceptions on the host. 217 */ 218 CPUMSetFCW(pVM->cpum.s.Host.fpu.FCW); 219 if (pVM->cpum.s.CPUFeatures.edx.u1SSE) 220 CPUMSetMXCSR(pVM->cpum.s.Host.fpu.MXCSR); 221 209 222 pVM->cpum.s.fUseFlags &= ~(CPUM_USED_FPU|CPUM_MANUAL_XMM_RESTORE); 210 223 return VINF_SUCCESS; -
trunk/src/VBox/VMM/VMMR0/HWACCMR0.cpp
r10683 r10687 770 770 /* We must restore the host FPU here to make absolutely sure we don't leave the guest FPU state active 771 771 * or trash somebody else's FPU state. 772 */773 774 /*775 * @note We are trashing our own FPU state. That could be a problem if some ring 3 code relies on the FPU control776 * word having a specific value (exceptions, precision etc).777 772 */ 778 773 /* Save the guest FPU and XMM state if necessary. */
Note:
See TracChangeset
for help on using the changeset viewer.