VirtualBox

Changeset 49019 in vbox for trunk/src/VBox/VMM/VMMAll


Ignore:
Timestamp:
Oct 10, 2013 8:45:11 AM (11 years ago)
Author:
vboxsync
Message:

VMM: FPU cleanup.

Location:
trunk/src/VBox/VMM/VMMAll
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/CPUMAllA.asm

    r48673 r49019  
    3838
    3939BEGINCODE
     40
     41;; Macro for FXSAVE/FXRSTOR leaky behaviour on AMD CPUs, see cpumR3CheckLeakyFpu().
     42; Cleans the FPU state, if necessary, before restoring the FPU.
     43;
     44; This macro ASSUMES CR0.TS is not set!
     45; @remarks Trashes xAX!!
     46; Changes here should also be reflected in CPUMR0A.asm's copy!
     47%macro CLEANFPU 0
     48    test    dword [xDX + CPUMCPU.fUseFlags], CPUM_USE_FFXSR_LEAKY
     49    jz      .nothing_to_clean
     50
     51    xor     eax, eax
     52    fnstsw  ax               ; Get FSW
     53    test    eax, RT_BIT(7)   ; If FSW.ES (bit 7) is set, clear it to not cause FPU exceptions
     54                             ; while clearing & loading the FPU bits in 'clean_fpu'
     55    jz      clean_fpu
     56    fnclex
     57
     58.clean_fpu:
     59    ffree   st7              ; Clear FPU stack register(7)'s tag entry to prevent overflow if a wraparound occurs
     60                             ; for the upcoming push (load)
     61    fild    dword [xDX + CPUMCPU.Guest.fpu] ; Explicit FPU load to overwrite FIP, FOP, FDP registers in the FPU.
     62
     63.nothing_to_clean:
     64%endmacro
     65
    4066
    4167;;
     
    172198
    173199    ; Load new CR0 value.
    174     ; IN_RING0 the caller saves/restores CR0 anyway, so avoid the extra CR0 write.
    175     ; Currently the only caller in ring-0 is CPUMR0LoadGuestFPU()->CPUMHandleLazyFPU().
    176200    ;; @todo Optimize the many unconditional CR0 writes.
    177 %ifdef IN_RC
     201%ifndef IN_RING3
    178202    mov     cr0, xCX                            ; load the new cr0 flags.
    179203%endif
  • trunk/src/VBox/VMM/VMMAll/CPUMAllRegs.cpp

    r48697 r49019  
    30903090}
    30913091
    3092 #ifndef IN_RING3
     3092#ifdef IN_RC
    30933093
    30943094/**
     
    31033103}
    31043104
    3105 #endif /* !IN_RING3 */
     3105#endif /* !IN_RC */
    31063106
    31073107/**
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