VirtualBox

Changeset 61348 in vbox for trunk/src/VBox/VMM/VMMRZ


Ignore:
Timestamp:
May 31, 2016 5:59:34 PM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
107643
Message:

CPUM,VMM: Touch the FPU state before doing HM on all platforms which allows us do (VMM_R0_TOUCH_FPU, see Makefile.kmk). No special treatment of win.amd64 (could save a CR0 read, maybe). Cleaned up the fix from this morning.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMRZ/CPUMRZA.asm

    r61317 r61348  
    7272        cli                             ; interrupt occurs while we're doing fxsave/fxrstor/cr0.
    7373
    74 %ifndef CPUM_CAN_USE_FPU_IN_R0
    75         ;
    76         ; In raw-mode context and on systems where the kernel doesn't necessarily
    77         ; allow us to use the FPU in ring-0 context, we have to disable FPU traps
    78         ; before doing fxsave/xsave here.  (xCX is 0 if no CR0 was necessary.)  We
    79         ; leave it like that so IEM can use the FPU/SSE/AVX host CPU features directly.
    80         ;
    81         SAVE_CR0_CLEAR_FPU_TRAPS xCX, xAX               ; xCX must be preserved!
    82         ;; @todo What about XCR0?
    83  %ifdef IN_RING0
    84         mov     [pCpumCpu + CPUMCPU.Host.cr0Fpu], xCX
    85  %endif
    86 %endif
     74        ;
     75        ; We may have to update CR0, indirectly or directly.  We must report any
     76        ; changes to the VT-x code.
     77        ;
     78        CPUMRZ_TOUCH_FPU_CLEAR_CR0_FPU_TRAPS_SET_RC xCX, xAX, pCpumCpu ; xCX is the return value (xAX scratch)
     79
    8780        ;
    8881        ; Save the host state (xsave/fxsave will cause thread FPU state to be
     
    9487        popf
    9588
    96 %ifndef CPUM_CAN_USE_FPU_IN_R0
    97         ; Figure the return code.
    98         test    ecx, ecx
    99         jnz     .modified_cr0
    100 %endif
    101         xor     eax, eax
    102 .return:
    103 
     89        mov     eax, ecx                ; The return value from above.
    10490%ifdef RT_ARCH_X86
    10591        pop     esi
     
    10894        leave
    10995        ret
    110 
    111 %ifndef CPUM_CAN_USE_FPU_IN_R0
    112 .modified_cr0:
    113         mov     eax, VINF_CPUM_HOST_CR0_MODIFIED
    114         jmp     .return
    115 %endif
    11696%undef pCpumCpu
    11797%undef pXState
     
    156136
    157137 %ifdef IN_RC
    158         SAVE_CR0_CLEAR_FPU_TRAPS xCX, xAX ; xCX must be preserved until CR0 is restored!
     138        mov     ecx, cr0                ; ecx = saved cr0
     139        test    ecx, X86_CR0_TS | X86_CR0_EM
     140        jz      .skip_cr0_write
     141        mov     eax, ecx
     142        and     eax, ~(X86_CR0_TS | X86_CR0_EM)
     143        mov     cr0, ecx
     144.skip_cr0_write:
    159145 %endif
    160146
     
    221207        test    byte [ebp + 0ch], 1     ; fLeaveFpuAccessible
    222208        jz      .no_cr0_restore
    223         RESTORE_CR0 xCX
     209        CPUMRZ_RESTORE_CR0_IF_TS_OR_EM_SET ecx
    224210.no_cr0_restore:
    225211 %endif
     
    272258 %ifdef IN_RC
    273259        ; Temporarily grant access to the SSE state. xDX must be preserved until CR0 is restored!
    274         SAVE_CR0_CLEAR_FPU_TRAPS xDX, xAX
     260        mov     edx, cr0
     261        jz      .skip_cr0_write
     262        mov     eax, edx
     263        and     eax, ~(X86_CR0_TS | X86_CR0_EM)
     264        mov     cr0, ecx
     265.skip_cr0_write:
    275266 %endif
    276267
     
    298289
    299290 %ifdef IN_RC
    300         RESTORE_CR0 xDX                 ; Restore CR0 if we changed it above.
     291        CPUMRZ_RESTORE_CR0_IF_TS_OR_EM_SET edx  ; Restore CR0 if we changed it above.
    301292 %endif
    302293
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette