VirtualBox

Changeset 47690 in vbox


Ignore:
Timestamp:
Aug 13, 2013 12:53:48 PM (11 years ago)
Author:
vboxsync
Message:

TRPM: Don't underflow the stack when trapping in the world switcher.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMRC/TRPMRCHandlersA.asm

    r42771 r47690  
    297297    mov     ebx, IMP(g_trpmGuestCtxCore)    ; Assume GC as the most common.
    298298    test    byte [%$STK_CS], 3h             ; check RPL of the cs selector
    299     ;; @todo check this for conforming segments.
    300     jnz     .save_state
     299    jnz     .save_guest_state
    301300    test    dword [%$STK_EFLAGS], X86_EFL_VM; If in V86, then guest.
    302     jnz     .save_state
     301    jnz     .save_guest_state
    303302    mov     ebx, IMP(g_trpmHyperCtxCore)    ; It's raw-mode context, actually.
    304303
     
    306305    ; Save the state.
    307306    ;
    308     ;   ASSUMPTION: If trap in hypervisor, we assume that we can read two dword
    309     ;               under the bottom of the stack. This is atm safe.
    310     ;
    311 .save_state:
     307.save_hyper_state:
     308    mov     [ebx + CPUMCTXCORE.ecx], ecx
     309    lea     eax, [%$STK_ESP]
     310    mov     [ebx + CPUMCTXCORE.esp], eax
     311    mov     cx, ss
     312    mov     [ebx + CPUMCTXCORE.ss.Sel], cx
     313    jmp     .save_state_common
     314
     315.save_guest_state:
     316    mov     [ebx + CPUMCTXCORE.ecx], ecx
     317    mov     eax, [%$STK_ESP]
     318    mov     [ebx + CPUMCTXCORE.esp], eax
     319    mov     cx, [%$STK_SS]
     320    mov     [ebx + CPUMCTXCORE.ss.Sel], cx
     321
     322.save_state_common:
    312323    mov     eax, [%$STK_SAVED_EAX]
    313324    mov     [ebx + CPUMCTXCORE.eax], eax
    314     mov     [ebx + CPUMCTXCORE.ecx], ecx
    315325    mov     [ebx + CPUMCTXCORE.edx], edx
    316326    mov     eax, [%$STK_SAVED_EBX]
     
    319329    mov     [ebx + CPUMCTXCORE.edi], edi
    320330    mov     [ebx + CPUMCTXCORE.ebp], ebp
    321 
    322     mov     eax, [%$STK_ESP]
    323     mov     [ebx + CPUMCTXCORE.esp], eax
    324     mov     cx, [%$STK_SS]
    325     mov     [ebx + CPUMCTXCORE.ss.Sel], cx
    326331
    327332    mov     cx, [%$STK_CS]
     
    792797
    793798    mov     ebx, IMP(g_trpmGuestCtxCore)    ; Assume GC as the most common.
    794     test    byte [%$STK_CS], 3h               ; check RPL of the cs selector
    795     ;; @todo check this for conforming segments.
    796     jnz     .save_state
    797     test    dword [%$STK_EFLAGS], X86_EFL_VM  ; If in V86, then guest.
    798     jnz     .save_state
     799    test    byte [%$STK_CS], 3h             ; check RPL of the cs selector
     800    jnz     .save_guest_state
     801    test    dword [%$STK_EFLAGS], X86_EFL_VM ; If in V86, then guest.
     802    jnz     .save_guest_state
    799803    mov     ebx, IMP(g_trpmHyperCtxCore)    ; It's raw-mode context, actually.
    800804
     
    802806    ; Save the state.
    803807    ;
    804     ;   ASSUMPTION: If trap in hypervisor, we assume that we can read two dword
    805     ;               under the bottom of the stack. This is atm safe.
    806     ;
    807 .save_state:
     808.save_hyper_state:
     809    mov     [ebx + CPUMCTXCORE.ecx], ecx
     810    lea     eax, [%$STK_ESP]
     811    mov     [ebx + CPUMCTXCORE.esp], eax
     812    mov     cx, ss
     813    mov     [ebx + CPUMCTXCORE.ss.Sel], cx
     814    jmp     .save_state_common
     815
     816.save_guest_state:
     817    mov     [ebx + CPUMCTXCORE.ecx], ecx
     818    mov     eax, [%$STK_ESP]
     819    mov     [ebx + CPUMCTXCORE.esp], eax
     820    mov     cx, [%$STK_SS]
     821    mov     [ebx + CPUMCTXCORE.ss.Sel], cx
     822
     823.save_state_common:
    808824    mov     eax, [%$STK_SAVED_EAX]
    809825    mov     [ebx + CPUMCTXCORE.eax], eax
    810     mov     [ebx + CPUMCTXCORE.ecx], ecx
    811826    mov     [ebx + CPUMCTXCORE.edx], edx
    812827    mov     eax, [%$STK_SAVED_EBX]
     
    815830    mov     [ebx + CPUMCTXCORE.edi], edi
    816831    mov     [ebx + CPUMCTXCORE.ebp], ebp
    817 
    818     mov     eax, [%$STK_ESP]
    819     mov     [ebx + CPUMCTXCORE.esp], eax
    820     mov     cx, [%$STK_SS]
    821     mov     [ebx + CPUMCTXCORE.ss.Sel], cx
    822832
    823833    mov     cx, [%$STK_CS]
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