Changeset 66878 in vbox
- Timestamp:
- May 12, 2017 12:40:17 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/vmm/cpum.h
r66581 r66878 1674 1674 VMMRZ_INT_DECL(void) CPUMRZFpuStateActualizeForChange(PVMCPU pVCpu); 1675 1675 VMMRZ_INT_DECL(void) CPUMRZFpuStateActualizeSseForRead(PVMCPU pVCpu); 1676 VMMRZ_INT_DECL(void) CPUMRZFpuStateActualizeAvxForRead(PVMCPU pVCpu); 1676 1677 /** @} */ 1677 1678 -
trunk/src/VBox/VMM/VMMR0/CPUMR0A.asm
r61348 r66878 66 66 ; @uses nothing (well, maybe cr0) 67 67 ; 68 %ifndef RT_ASM_WITH_SEH64 ; workaround for yasm 1.3.0 bug (error: prologue -1 bytes, must be <256) 68 69 ALIGNCODE(16) 70 %endif 69 71 BEGINPROC CPUMR0TouchHostFpu 70 72 push xBP … … 88 90 ; @param pCpumCpu x86:[ebp+8] gcc:rdi msc:rcx CPUMCPU pointer 89 91 ; 92 ; @remarks 64-bit Windows drivers shouldn't use AVX registers without saving+loading: 93 ; https://msdn.microsoft.com/en-us/library/windows/hardware/ff545910%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396 94 ; However the compiler docs have different idea: 95 ; https://msdn.microsoft.com/en-us/library/9z1stfyw.aspx 96 ; We'll go with the former for now. 97 ; 98 %ifndef RT_ASM_WITH_SEH64 ; workaround for yasm 1.3.0 bug (error: prologue -1 bytes, must be <256) 90 99 ALIGNCODE(16) 100 %endif 91 101 BEGINPROC cpumR0SaveHostRestoreGuestFPUState 92 102 push xBP … … 135 145 ; If we didn't save the host state, we must save the non-volatile XMM registers. 136 146 mov pXState, [pCpumCpu + CPUMCPU.Host.pXStateR0] 147 stmxcsr [pXState + X86FXSTATE.MXCSR] 137 148 movdqa [pXState + X86FXSTATE.xmm6 ], xmm6 138 149 movdqa [pXState + X86FXSTATE.xmm7 ], xmm7 … … 166 177 movdqa xmm14, [pXState + X86FXSTATE.xmm14] 167 178 movdqa xmm15, [pXState + X86FXSTATE.xmm15] 179 ldmxcsr [pXState + X86FXSTATE.MXCSR] 168 180 %endif 169 181 … … 187 199 ; @param pCpumCpu x86:[ebp+8] gcc:rdi msc:rcx CPUMCPU pointer 188 200 ; 201 ; @remarks 64-bit Windows drivers shouldn't use AVX registers without saving+loading: 202 ; https://msdn.microsoft.com/en-us/library/windows/hardware/ff545910%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396 203 ; However the compiler docs have different idea: 204 ; https://msdn.microsoft.com/en-us/library/9z1stfyw.aspx 205 ; We'll go with the former for now. 206 ; 207 %ifndef RT_ASM_WITH_SEH64 ; workaround for yasm 1.3.0 bug (error: prologue -1 bytes, must be <256) 189 208 ALIGNCODE(16) 209 %endif 190 210 BEGINPROC cpumR0SaveGuestRestoreHostFPUState 191 211 push xBP … … 222 242 ; 223 243 mov pXState, [pCpumCpu + CPUMCPU.Host.pXStateR0] 244 stmxcsr [pXState + X86FXSTATE.MXCSR] 224 245 movdqa [pXState + X86FXSTATE.xmm6], xmm6 225 246 movdqa [pXState + X86FXSTATE.xmm7], xmm7 … … 259 280 movdqa xmm14, [pXState + X86FXSTATE.xmm14] 260 281 movdqa xmm15, [pXState + X86FXSTATE.xmm15] 282 ldmxcsr [pXState + X86FXSTATE.MXCSR] 261 283 %endif 262 284 CPUMR0_SAVE_GUEST … … 293 315 ; @param pCpumCpu x86:[ebp+8] gcc:rdi msc:rcx CPUMCPU pointer 294 316 ; 317 %ifndef RT_ASM_WITH_SEH64 ; workaround for yasm 1.3.0 bug (error: prologue -1 bytes, must be <256) 295 318 ALIGNCODE(16) 319 %endif 296 320 BEGINPROC cpumR0RestoreHostFPUState 297 321 ; -
trunk/src/VBox/VMM/VMMR0/HMR0A.asm
r65932 r66878 808 808 ; @remarks This is essentially the same code as hmR0SVMRunWrapXMM, only the parameters differ a little bit. 809 809 ; 810 ; @remarks Drivers shouldn't use AVX registers without saving+loading: 811 ; https://msdn.microsoft.com/en-us/library/windows/hardware/ff545910%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396 812 ; However the compiler docs have different idea: 813 ; https://msdn.microsoft.com/en-us/library/9z1stfyw.aspx 814 ; We'll go with the former for now. 815 ; 810 816 ; ASSUMING 64-bit and windows for now. 817 ; 811 818 ALIGNCODE(16) 812 819 BEGINPROC hmR0VMXStartVMWrapXMM 813 820 push xBP 814 821 mov xBP, xSP 815 sub xSP, 0 a0h + 040h; Don't bother optimizing the frame size.822 sub xSP, 0b0h + 040h ; Don't bother optimizing the frame size. 816 823 817 824 ; spill input parameters. … … 853 860 movdqa [rsp + 040h + 080h], xmm14 854 861 movdqa [rsp + 040h + 090h], xmm15 862 stmxcsr [rsp + 040h + 0a0h] 855 863 856 864 mov r10, [xBP + 018h] ; pCtx … … 901 909 movdqa xmm14, [rsp + 040h + 080h] 902 910 movdqa xmm15, [rsp + 040h + 090h] 911 ldmxcsr [rsp + 040h + 0a0h] 903 912 leave 904 913 ret … … 926 935 movdqa xmm14, [r10 + XMM_OFF_IN_X86FXSTATE + 0e0h] 927 936 movdqa xmm15, [r10 + XMM_OFF_IN_X86FXSTATE + 0f0h] 937 ldmxcsr [r10 + X86FXSTATE.MXCSR] 928 938 929 939 ; Make the call (same as in the other case ). … … 940 950 mov r10, [xBP + 018h] ; pCtx 941 951 mov r10, [r10 + CPUMCTX.pXStateR0] 952 stmxcsr [r10 + X86FXSTATE.MXCSR] 942 953 movdqa [r10 + XMM_OFF_IN_X86FXSTATE + 000h], xmm0 943 954 movdqa [r10 + XMM_OFF_IN_X86FXSTATE + 010h], xmm1 … … 976 987 ; @remarks This is essentially the same code as hmR0VMXStartVMWrapXMM, only the parameters differ a little bit. 977 988 ; 989 ; @remarks Drivers shouldn't use AVX registers without saving+loading: 990 ; https://msdn.microsoft.com/en-us/library/windows/hardware/ff545910%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396 991 ; However the compiler docs have different idea: 992 ; https://msdn.microsoft.com/en-us/library/9z1stfyw.aspx 993 ; We'll go with the former for now. 994 ; 978 995 ; ASSUMING 64-bit and windows for now. 979 996 ALIGNCODE(16) … … 981 998 push xBP 982 999 mov xBP, xSP 983 sub xSP, 0 a0h + 040h ; Don't bother optimizing the frame size.1000 sub xSP, 0b0h + 040h ; Don't bother optimizing the frame size. 984 1001 985 1002 ; spill input parameters. … … 1021 1038 movdqa [rsp + 040h + 080h], xmm14 1022 1039 movdqa [rsp + 040h + 090h], xmm15 1040 stmxcsr [rsp + 040h + 0a0h] 1023 1041 1024 1042 mov r10, [xBP + 020h] ; pCtx … … 1069 1087 movdqa xmm14, [rsp + 040h + 080h] 1070 1088 movdqa xmm15, [rsp + 040h + 090h] 1089 ldmxcsr [rsp + 040h + 0a0h] 1071 1090 leave 1072 1091 ret … … 1094 1113 movdqa xmm14, [r10 + XMM_OFF_IN_X86FXSTATE + 0e0h] 1095 1114 movdqa xmm15, [r10 + XMM_OFF_IN_X86FXSTATE + 0f0h] 1115 ldmxcsr [r10 + X86FXSTATE.MXCSR] 1096 1116 1097 1117 ; Make the call (same as in the other case ). … … 1108 1128 mov r10, [xBP + 020h] ; pCtx 1109 1129 mov r10, [r10 + CPUMCTX.pXStateR0] 1130 stmxcsr [r10 + X86FXSTATE.MXCSR] 1110 1131 movdqa [r10 + XMM_OFF_IN_X86FXSTATE + 000h], xmm0 1111 1132 movdqa [r10 + XMM_OFF_IN_X86FXSTATE + 010h], xmm1 -
trunk/src/VBox/VMM/VMMRZ/CPUMRZ.cpp
r61392 r66878 134 134 135 135 /** 136 * Makes sure the XMM0..XMM15 state in CPUMCPU::Guest is up to date.136 * Makes sure the XMM0..XMM15 and MXCSR state in CPUMCPU::Guest is up to date. 137 137 * 138 138 * This will not cause CPUM_USED_FPU_GUEST to change. … … 162 162 } 163 163 164 165 /** 166 * Makes sure the YMM0..YMM15 and MXCSR state in CPUMCPU::Guest is up to date. 167 * 168 * This will not cause CPUM_USED_FPU_GUEST to change. 169 * 170 * @param pVCpu The cross context virtual CPU structure. 171 */ 172 VMMRZ_INT_DECL(void) CPUMRZFpuStateActualizeAvxForRead(PVMCPU pVCpu) 173 { 174 if (pVCpu->cpum.s.fUseFlags & CPUM_USED_FPU_GUEST) 175 { 176 #if defined(IN_RING0) && ARCH_BITS == 32 && defined(VBOX_WITH_64_BITS_GUESTS) 177 if (CPUMIsGuestInLongModeEx(&pVCpu->cpum.s.Guest)) 178 { 179 Assert(!(pVCpu->cpum.s.fUseFlags & CPUM_SYNC_FPU_STATE)); 180 HMR0SaveFPUState(pVCpu->CTX_SUFF(pVM), pVCpu, &pVCpu->cpum.s.Guest); 181 pVCpu->cpum.s.fUseFlags |= CPUM_USED_FPU_GUEST; 182 } 183 else 184 #endif 185 cpumRZSaveGuestAvxRegisters(&pVCpu->cpum.s); 186 Log7(("CPUMRZFpuStateActualizeAvxForRead\n")); 187 } 188 } 189 -
trunk/src/VBox/VMM/VMMRZ/CPUMRZA.asm
r61368 r66878 105 105 ; @param fLeaveFpuAccessible x86:[ebp+c] gcc:sil msc:dl Whether to restore CR0 and XCR0 on 106 106 ; the way out. Only really applicable to RC. 107 ; 108 ; @remarks 64-bit Windows drivers shouldn't use AVX registers without saving+loading: 109 ; https://msdn.microsoft.com/en-us/library/windows/hardware/ff545910%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396 110 ; However the compiler docs have different idea: 111 ; https://msdn.microsoft.com/en-us/library/9z1stfyw.aspx 112 ; We'll go with the former for now. 107 113 ; 108 114 align 16 … … 166 172 movdqa [pXState + X86FXSTATE.xmm14], xmm14 167 173 movdqa [pXState + X86FXSTATE.xmm15], xmm15 174 stmxcsr [pXState + X86FXSTATE.MXCSR] 168 175 169 176 ; Load the guest XMM register values we already saved in HMR0VMXStartVMWrapXMM. … … 185 192 movdqa xmm14, [pXState + X86FXSTATE.xmm14] 186 193 movdqa xmm15, [pXState + X86FXSTATE.xmm15] 194 ldmxcsr [pXState + X86FXSTATE.MXCSR] 187 195 188 196 CPUMR0_SAVE_GUEST … … 200 208 movdqa xmm14, [pXState + X86FXSTATE.xmm14] 201 209 movdqa xmm15, [pXState + X86FXSTATE.xmm15] 210 ldmxcsr [pXState + X86FXSTATE.MXCSR] 202 211 203 212 %endif … … 223 232 224 233 ;; 225 ; Saves the guest XMM0..15 registers .234 ; Saves the guest XMM0..15 registers and MXCSR. 226 235 ; 227 236 ; The purpose is to actualize the register state for read-only use, so CR0 is … … 270 279 ; Do the job. 271 280 ; 281 stmxcsr [xCX + X86FXSTATE.MXCSR] 272 282 movdqa [xCX + X86FXSTATE.xmm0 ], xmm0 273 283 movdqa [xCX + X86FXSTATE.xmm1 ], xmm1 … … 299 309 ENDPROC cpumRZSaveGuestSseRegisters 300 310 311 ;; 312 ; Saves the guest YMM0..15 registers. 313 ; 314 ; The purpose is to actualize the register state for read-only use, so CR0 is 315 ; restored in raw-mode context (so, the FPU/SSE/AVX CPU features can be 316 ; inaccessible upon return). 317 ; 318 ; @param pCpumCpu x86:[ebp+8] gcc:rdi msc:rcx CPUMCPU pointer 319 ; 320 align 16 321 BEGINPROC cpumRZSaveGuestAvxRegisters 322 push xBP 323 SEH64_PUSH_xBP 324 mov xBP, xSP 325 SEH64_SET_FRAME_xBP 0 326 %ifdef IN_RC 327 push xBX 328 %endif 329 SEH64_END_PROLOGUE 330 331 ; 332 ; Load xCX with the guest pXStateR0. 333 ; 334 %ifdef ASM_CALL64_GCC 335 mov xCX, rdi 336 %elifdef RT_ARCH_X86 337 mov xCX, dword [ebp + 8] 338 %endif 339 %ifdef IN_RING0 340 mov xCX, [xCX + CPUMCPU.Guest.pXStateR0] 341 %elifdef IN_RC 342 mov xCX, [xCX + CPUMCPU.Guest.pXStateRC] 343 %else 344 %error "Invalid context!" 345 %endif 346 347 %ifdef IN_RC 348 ; Temporarily grant access to the SSE state. xBX must be preserved until CR0 is restored! 349 mov ebx, cr0 350 test ebx, X86_CR0_TS | X86_CR0_EM 351 jz .skip_cr0_write 352 mov eax, ebx 353 and eax, ~(X86_CR0_TS | X86_CR0_EM) 354 mov cr0, eax 355 .skip_cr0_write: 356 %endif 357 358 ; 359 ; Use XSAVE to do the job. 360 ; 361 ; Drivers shouldn't use AVX registers without saving+loading: 362 ; https://msdn.microsoft.com/en-us/library/windows/hardware/ff545910%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396 363 ; However the compiler docs have different idea: 364 ; https://msdn.microsoft.com/en-us/library/9z1stfyw.aspx 365 ; We'll go with the former for now. 366 ; 367 %ifdef VBOX_WITH_KERNEL_USING_XMM 368 mov eax, XSAVE_C_YMM 369 %else 370 mov eax, XSAVE_C_YMM | XSAVE_C_SSE ; The SSE component includes MXCSR. 371 %endif 372 xor edx, edx 373 %if ARCH_BITS == 64 374 o64 xsave [xCX] 375 %else 376 xsave [xCX] 377 %endif 378 379 %ifdef IN_RC 380 CPUMRZ_RESTORE_CR0_IF_TS_OR_EM_SET ebx ; Restore CR0 if we changed it above. 381 pop xBX 382 %endif 383 leave 384 ret 385 ENDPROC cpumRZSaveGuestAvxRegisters 386 -
trunk/src/VBox/VMM/include/CPUMInternal.h
r66403 r66878 559 559 DECLASM(void) cpumRZSaveGuestFpuState(PCPUMCPU pCPUM, bool fLeaveFpuAccessible); 560 560 DECLASM(void) cpumRZSaveGuestSseRegisters(PCPUMCPU pCPUM); 561 DECLASM(void) cpumRZSaveGuestAvxRegisters(PCPUMCPU pCPUM); 561 562 # endif 562 563
Note:
See TracChangeset
for help on using the changeset viewer.