Changeset 61144 in vbox for trunk/src/VBox/VMM/VMMRZ
- Timestamp:
- May 23, 2016 10:16:26 PM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 107425
- Location:
- trunk/src/VBox/VMM/VMMRZ
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMRZ/CPUMRZ.cpp
r61068 r61144 50 50 case 0: 51 51 cpumRZSaveHostFPUState(&pVCpu->cpum.s); 52 #ifdef IN_RC 53 VMCPU_FF_SET(pVCpu, VMCPU_FF_CPUM); /* Must recalc CR0 before executing more code! */ 54 #endif 52 55 break; 53 56 … … 57 60 { 58 61 pVCpu->cpum.s.fUseFlags &= ~CPUM_SYNC_FPU_STATE; 59 /** @todo tell HM! */ 62 HMR0NotifyCpumUnloadedGuestFpuState(pVCpu); 60 63 } 61 64 #endif … … 63 66 64 67 case CPUM_USED_FPU_GUEST | CPUM_USED_FPU_HOST: 65 /** @todo tell HM! */66 68 #if defined(IN_RING0) && ARCH_BITS == 32 && defined(VBOX_WITH_64_BITS_GUESTS) 67 69 Assert(!(pVCpu->cpum.s.fUseFlags & CPUM_SYNC_FPU_STATE)); … … 70 72 else 71 73 #endif 72 cpumRZSaveGuestFpuState(&pVCpu->cpum.s); 73 74 cpumRZSaveGuestFpuState(&pVCpu->cpum.s, true /*fLeaveFpuAccessible*/); 75 #ifdef IN_RING0 76 HMR0NotifyCpumUnloadedGuestFpuState(pVCpu); 77 #endif 74 78 break; 75 79 … … 112 116 else 113 117 #endif 114 cpumRZSaveGuestFpuState(&pVCpu->cpum.s );118 cpumRZSaveGuestFpuState(&pVCpu->cpum.s, false /*fLeaveFpuAccessible*/); 115 119 pVCpu->cpum.s.fUseFlags |= CPUM_USED_FPU_GUEST; 116 120 } … … 129 133 #if defined(VBOX_WITH_KERNEL_USING_XMM) && HC_ARCH_BITS == 64 130 134 NOREF(pVCpu); 135 #error "do NOT commit this" 131 136 #else 132 137 if (pVCpu->cpum.s.fUseFlags & CPUM_USED_FPU_GUEST) … … 141 146 else 142 147 # endif 148 { 149 RTLogPrintf("calling cpumRZSaveGuestSseRegisters\n"); 143 150 cpumRZSaveGuestSseRegisters(&pVCpu->cpum.s); 151 } 144 152 } 145 153 #endif -
trunk/src/VBox/VMM/VMMRZ/CPUMRZA.asm
r61112 r61144 34 34 ; Saves the host FPU/SSE/AVX state. 35 35 ; 36 ; Will return with CR0.EM and CR0.TS cleared! This is the normal state in 37 ; ring-0, whereas in raw-mode the caller will probably set VMCPU_FF_CPUM to 38 ; re-evaluate the situation before executing more guest code. 39 ; 36 40 ; @returns VINF_SUCCESS (0) in EAX 37 41 ; @param pCpumCpu x86:[ebp+8] gcc:rdi msc:rcx CPUMCPU pointer … … 66 70 pushf ; The darwin kernel can get upset or upset things if an 67 71 cli ; interrupt occurs while we're doing fxsave/fxrstor/cr0. 68 %ifdef VBOX_WITH_KERNEL_USING_XMM 72 73 %ifndef CPUM_CAN_USE_FPU_IN_R0 74 ; 75 ; In raw-mode context and on systems where the kernel doesn't necessarily 76 ; allow us to use the FPU in ring-0 context, we have to disable FPU traps 77 ; before doing fxsave/xsave here. (xCX is 0 if no CR0 was necessary.) We 78 ; leave it like that so IEM can use the FPU/SSE/AVX host CPU features directly. 79 ; 80 SAVE_CR0_CLEAR_FPU_TRAPS xCX, xAX 81 ;; @todo What about XCR0? 69 82 %ifdef IN_RING0 70 movaps xmm0, xmm0 ; Make 100% sure it's used before we save it or mess with CR0/XCR0. 71 %endif 72 %endif 73 SAVE_CR0_CLEAR_FPU_TRAPS xCX, xAX ; xCX is now old CR0 value, don't use! 74 83 mov [pCpumCpu + CPUMCPU.Host.cr0Fpu], xCX 84 %else 85 %error "Huh?" 86 %endif 87 %endif 88 ; 89 ; Save the host state (xsave/fxsave will cause thread FPU state to be 90 ; loaded on systems where we are allowed to use it in ring-0. 91 ; 75 92 CPUMR0_SAVE_HOST 76 ;; @todo Save CR0 + XCR0 bits related to FPU, SSE and AVX*, leaving these register sets accessible to IEM. 77 78 RESTORE_CR0 xCX 93 79 94 or dword [pCpumCpu + CPUMCPU.fUseFlags], (CPUM_USED_FPU_HOST | CPUM_USED_FPU_SINCE_REM) ; Latter is not necessarily true, but normally yes. 80 95 popf … … 95 110 ; 96 111 ; @param pCpumCpu x86:[ebp+8] gcc:rdi msc:rcx CPUMCPU pointer 112 ; @param fLeaveFpuAccessible x86:[ebp+c] gcc:sil msc:dl Whether to restore CR0 and XCR0 on 113 ; the way out. Only really applicable to RC. 97 114 ; 98 115 align 16 … … 124 141 pushf ; The darwin kernel can get upset or upset things if an 125 142 cli ; interrupt occurs while we're doing fxsave/fxrstor/cr0. 126 SAVE_CR0_CLEAR_FPU_TRAPS xCX, xAX ; xCX is now old CR0 value, don't use! 127 143 144 %ifdef IN_RC 145 SAVE_CR0_CLEAR_FPU_TRAPS xCX, xAX ; xCX must be preserved until CR0 is restored! 146 %endif 128 147 129 148 %ifndef VBOX_WITH_KERNEL_USING_XMM … … 185 204 %endif 186 205 206 and dword [pCpumCpu + CPUMCPU.fUseFlags], ~CPUM_USED_FPU_GUEST 207 %ifdef IN_RC 208 test byte [ebp + 0ch], 1 ; fLeaveFpuAccessible 209 jz .no_cr0_restore 187 210 RESTORE_CR0 xCX 188 and dword [pCpumCpu + CPUMCPU.fUseFlags], ~CPUM_USED_FPU_GUEST 189 211 .no_cr0_restore: 212 %endif 190 213 popf 191 214 %ifdef RT_ARCH_X86 … … 202 225 ;; 203 226 ; Saves the guest XMM0..15 registers. 227 ; 228 ; The purpose is to actualize the register state for read-only use, so CR0 is 229 ; restored in raw-mode context (so, the FPU/SSE/AVX CPU features can be 230 ; inaccessible upon return). 204 231 ; 205 232 ; @param pCpumCpu x86:[ebp+8] gcc:rdi msc:rcx CPUMCPU pointer … … 228 255 %else 229 256 %error "Invalid context!" 257 %endif 258 259 %ifdef IN_RC 260 ; Temporarily grant access to the SSE state. xDX must be preserved until CR0 is restored! 261 SAVE_CR0_CLEAR_FPU_TRAPS xDX, xAX 230 262 %endif 231 263 … … 251 283 movdqa [xCX + X86FXSTATE.xmm15], xmm15 252 284 %endif 285 286 %ifdef IN_RC 287 RESTORE_CR0 xDX ; Restore CR0 if we changed it above. 288 %endif 289 253 290 %endif ; !VBOX_WITH_KERNEL_USING_XMM 254 291
Note:
See TracChangeset
for help on using the changeset viewer.