VirtualBox

Changeset 41976 in vbox for trunk/src/VBox/VMM/VMMSwitcher


Ignore:
Timestamp:
Jul 1, 2012 2:16:40 PM (12 years ago)
Author:
vboxsync
Message:

VMM: Switcher and TRPM fixes wrt hypervisor traps and tstVMM.

Location:
trunk/src/VBox/VMM/VMMSwitcher
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMSwitcher/AMD64andLegacy.mac

    r41933 r41976  
    2828%include "VBox/vmm/stam.mac"
    2929%include "VBox/vmm/vm.mac"
     30%include "VBox/err.mac"
    3031%include "CPUMInternal.mac"
    3132%include "VMMSwitcher.mac"
     
    5455; @param    pVM  GCC: rdi  MSC:rcx  The VM handle.
    5556;
    56 BEGINPROC vmmR0HostToGuest
     57BEGINPROC vmmR0ToRawMode
    5758%ifdef DEBUG_STUFF
    5859    COM64_S_NEWLINE
     
    9697    mov     eax, cs
    9798    push    rax
    98     call    NAME(vmmR0HostToGuestAsm)
     99    call    NAME(vmmR0ToRawModeAsm)
    99100
    100101 %ifdef VBOX_WITH_VMMR0_DISABLE_LAPIC_NMI
     
    130131
    131132    ret
    132 ENDPROC vmmR0HostToGuest
     133ENDPROC vmmR0ToRawMode
    133134
    134135
     
    141142; The C interface.
    142143;
    143 BEGINPROC vmmR0HostToGuest
     144BEGINPROC vmmR0ToRawMode
    144145 %ifdef DEBUG_STUFF
    145146    COM32_S_NEWLINE
     
    164165    push    cs
    165166    push    0
    166     FIXUP FIX_HC_32BIT, 1, .vmmR0HostToGuestReturn - NAME(Start)
     167    FIXUP FIX_HC_32BIT, 1, .vmmR0ToRawModeReturn - NAME(Start)
    167168    push    0ffffffffh
    168169
    169170    FIXUP FIX_HC_64BIT_CS, 1
    170171    push    0ffffh
    171     FIXUP FIX_HC_32BIT, 1, NAME(vmmR0HostToGuestAsm) - NAME(Start)
     172    FIXUP FIX_HC_32BIT, 1, NAME(vmmR0ToRawModeAsm) - NAME(Start)
    172173    push    0ffffffffh
    173174    retf
    174 .vmmR0HostToGuestReturn:
     175.vmmR0ToRawModeReturn:
    175176
    176177    ;
     
    200201
    201202    ret
    202 ENDPROC vmmR0HostToGuest
     203ENDPROC vmmR0ToRawMode
    203204
    204205BITS 64
     
    208209
    209210; *****************************************************************************
    210 ; vmmR0HostToGuestAsm
     211; vmmR0ToRawModeAsm
    211212;
    212213; Phase one of the switch from host to guest context (host MMU context)
     
    223224; *****************************************************************************
    224225ALIGNCODE(16)
    225 BEGINPROC vmmR0HostToGuestAsm
     226BEGINPROC vmmR0ToRawModeAsm
    226227    ;; Store the offset from CPUM to CPUMCPU in r8
    227228    mov     r8d, [rdx + CPUM.offCPUMCPU0]
     
    330331    mov     [rdx + CPUM.fApicDisVectors], edi
    331332htg_noapic:
    332 %endif
     333%endif ; VBOX_WITH_VMMR0_DISABLE_LAPIC_NMI
    333334
    334335    FIXUP FIX_NO_SYSENTER_JMP, 0, htg_no_sysenter - NAME(Start) ; this will insert a jmp htg_no_sysenter if host doesn't use sysenter.
     
    457458
    458459
    459     ; We're now on an identity mapped pages! in 32-bit compatibility mode.
     460    ; We're now on identity mapped pages in 32-bit compatibility mode.
    460461BITS 32
    461462ALIGNCODE(16)
     
    542543    lidt    [edx + CPUMCPU.Hyper.idtr]
    543544
    544     ; Setup stack.
     545    ; Setup the stack.
    545546    DEBUG_CHAR('3')
    546547    mov     ax, [edx + CPUMCPU.Hyper.ss.Sel]
     
    549550
    550551    ; Restore TSS selector; must mark it as not busy before using ltr (!)
    551     DEBUG_CHAR('4')
     552    DEBUG_S_CHAR('4')
    552553    FIXUP FIX_GC_TSS_GDTE_DW2, 2
    553554    and     dword [0ffffffffh], ~0200h      ; clear busy flag (2nd type2 bit)
    554     DEBUG_CHAR('5')
     555    DEBUG_S_CHAR('5')
    555556    ltr     word [edx + CPUMCPU.Hyper.tr.Sel]
    556     DEBUG_CHAR('6')
     557    DEBUG_S_CHAR('6')
    557558
    558559    ; Activate the ldt (now we can safely crash).
    559560    lldt    [edx + CPUMCPU.Hyper.ldtr.Sel]
    560     DEBUG_CHAR('7')
    561 
    562     ;; use flags.
     561    DEBUG_S_CHAR('7')
     562
     563    ;; Use flags.
    563564    mov     esi, [edx + CPUMCPU.fUseFlags]
    564565
    565566    ; debug registers
    566567    test    esi, CPUM_USE_DEBUG_REGS
    567     jz      htg_debug_regs_guest_no
    568     jmp     htg_debug_regs_guest
    569 htg_debug_regs_guest_no:
    570     DEBUG_CHAR('9')
    571 
    572     ; General registers.
     568    jnz     htg_debug_regs_guest
     569htg_debug_regs_guest_done:
     570    DEBUG_S_CHAR('9')
     571
     572    ; General registers (sans edx).
     573    mov     eax, [edx + CPUMCPU.Hyper.eax]
    573574    mov     ebx, [edx + CPUMCPU.Hyper.ebx]
     575    mov     ecx, [edx + CPUMCPU.Hyper.ecx]
    574576    mov     ebp, [edx + CPUMCPU.Hyper.ebp]
    575577    mov     esi, [edx + CPUMCPU.Hyper.esi]
    576578    mov     edi, [edx + CPUMCPU.Hyper.edi]
    577     push    dword [edx + CPUMCPU.Hyper.eflags]
    578     popfd
    579     DEBUG_CHAR('!')
     579    DEBUG_S_CHAR('!')
    580580
    581581    ;;
     
    583583    ;; the code set up to run by HC.
    584584    ;;
     585    push    dword [edx + CPUMCPU.Hyper.eip]
     586    push    dword [edx + CPUMCPU.Hyper.eflags]
     587    mov     edx, [edx + CPUMCPU.Hyper.edx]      ; !! edx is no longer pointing to CPUMCPU here !!
     588
    585589%ifdef DEBUG_STUFF
    586590    COM32_S_PRINT ';eip='
    587     mov     eax, [edx + CPUMCPU.Hyper.eip]
     591    push    eax
     592    mov     eax, [esp + 8]
    588593    COM32_S_DWORD_REG eax
     594    pop     eax
    589595    COM32_S_CHAR ';'
    590596%endif
    591     mov     eax, [edx + CPUMCPU.Hyper.eip]
    592     ; callees expect CPUM ptr
    593     CPUM_FROM_CPUMCPU(edx)
    594 
    595597%ifdef VBOX_WITH_STATISTICS
     598    push    eax
    596599    FIXUP FIX_GC_VM_OFF, 1, VM.StatSwitcherToGC
    597     mov     edx, 0ffffffffh
    598     STAM32_PROFILE_ADV_STOP edx
    599     FIXUP FIX_GC_CPUM_OFF, 1, 0
    600     mov     edx, 0ffffffffh
    601 %endif
    602     jmp     eax
     600    mov     eax, 0ffffffffh
     601    STAM32_PROFILE_ADV_STOP eax
     602    pop     eax
     603%endif
     604
     605    popfd
     606    ret
    603607
    604608;;
     
    623627    mov     eax, [edx + CPUMCPU.Hyper.dr + 8*7]
    624628    mov     dr7, eax
    625     jmp     htg_debug_regs_guest_no
    626 
    627 ENDPROC vmmR0HostToGuestAsm
     629    jmp     htg_debug_regs_guest_done
     630
     631ENDPROC vmmR0ToRawModeAsm
    628632
    629633
     
    638642;
    639643ALIGNCODE(16)
    640 BEGINPROC vmmGCCallTrampoline
     644BEGINPROC vmmRCCallTrampoline
    641645%ifdef DEBUG_STUFF
    642646    COM32_S_CHAR 'c'
     
    647651    ; call routine
    648652    pop     eax                         ; call address
    649     mov     esi, edx                    ; save edx
    650653    pop     edi                         ; argument count.
    651654%ifdef DEBUG_STUFF
     
    657660    add     esp, edi                    ; cleanup stack
    658661
    659     ; return to the host context.
    660     push    byte 0                      ; eip
    661     mov     edx, esi                    ; CPUM pointer
    662 
     662    ; return to the host context (eax = C returncode).
    663663%ifdef DEBUG_STUFF
    664664    COM32_S_CHAR '`'
    665665%endif
    666     jmp     NAME(VMMGCGuestToHostAsm)   ; eax = returncode.
    667 ENDPROC vmmGCCallTrampoline
     666.to_host_again:
     667    call    NAME(vmmRCToHostAsm)
     668    mov     eax, VERR_VMM_SWITCHER_IPE_1
     669    jmp     .to_host_again
     670ENDPROC vmmRCCallTrampoline
    668671
    669672
     
    673676;
    674677ALIGNCODE(16)
    675 BEGINPROC vmmGCGuestToHost
     678BEGINPROC vmmRCToHost
    676679%ifdef DEBUG_STUFF
    677680    push    esi
     
    686689%endif
    687690    mov     eax, [esp + 4]
    688     jmp     NAME(VMMGCGuestToHostAsm)
    689 ENDPROC vmmGCGuestToHost
     691    jmp     NAME(vmmRCToHostAsm)
     692ENDPROC vmmRCToHost
    690693
    691694
    692695;;
    693 ; VMMGCGuestToHostAsm
    694 ;
    695 ; This is an alternative entry point which we'll be using
    696 ; when the we have saved the guest state already or we haven't
    697 ; been messing with the guest at all.
     696; vmmRCToHostAsmNoReturn
     697;
     698; This is an entry point used by TRPM when dealing with raw-mode traps,
     699; i.e. traps in the hypervisor code.  This will not return and saves no
     700; state, because the caller has already saved the state.
     701;
     702; @param    eax     Return code.
     703;
     704ALIGNCODE(16)
     705BEGINPROC vmmRCToHostAsmNoReturn
     706    DEBUG_S_CHAR('%')
     707
     708%ifdef VBOX_WITH_STATISTICS
     709    FIXUP FIX_GC_VM_OFF, 1, VM.StatTotalInGC
     710    mov     edx, 0ffffffffh
     711    STAM32_PROFILE_ADV_STOP edx
     712
     713    FIXUP FIX_GC_VM_OFF, 1, VM.StatTotalGCToQemu
     714    mov     edx, 0ffffffffh
     715    STAM32_PROFILE_ADV_START edx
     716
     717    FIXUP FIX_GC_VM_OFF, 1, VM.StatSwitcherToHC
     718    mov     edx, 0ffffffffh
     719    STAM32_PROFILE_ADV_START edx
     720%endif
     721
     722    FIXUP FIX_GC_CPUMCPU_OFF, 1, 0
     723    mov     edx, 0ffffffffh
     724
     725    jmp     vmmRCToHostAsm_SaveNoGeneralRegs
     726ENDPROC vmmRCToHostAsmNoReturn
     727
     728
     729;;
     730; vmmRCToHostAsm
     731;
     732; This is an entry point used by TRPM to return to host context when an
     733; interrupt occured or an guest trap needs handling in host context.  It
     734; is also used by the C interface above.
     735;
     736; The hypervisor context is saved and it will return to the caller if
     737; host context so desires.
    698738;
    699739; @param    eax     Return code.
     
    701741;
    702742ALIGNCODE(16)
    703 BEGINPROC VMMGCGuestToHostAsm
    704     DEBUG_CHAR('%')
     743BEGINPROC vmmRCToHostAsm
     744    DEBUG_S_CHAR('%')
     745    push    edx
    705746
    706747%ifdef VBOX_WITH_STATISTICS
     
    724765    mov     edx, 0ffffffffh
    725766
     767    ; Save register context.
     768    pop     dword [edx + CPUMCPU.Hyper.edx]
    726769    pop     dword [edx + CPUMCPU.Hyper.eip] ; call return from stack
    727 
    728     ; general registers which we care about.
     770    mov     dword [edx + CPUMCPU.Hyper.esp], esp
     771    mov     dword [edx + CPUMCPU.Hyper.eax], eax
    729772    mov     dword [edx + CPUMCPU.Hyper.ebx], ebx
     773    mov     dword [edx + CPUMCPU.Hyper.ecx], ecx
    730774    mov     dword [edx + CPUMCPU.Hyper.esi], esi
    731775    mov     dword [edx + CPUMCPU.Hyper.edi], edi
    732776    mov     dword [edx + CPUMCPU.Hyper.ebp], ebp
    733     mov     dword [edx + CPUMCPU.Hyper.esp], esp
    734777
    735778    ; special registers which may change.
     779vmmRCToHostAsm_SaveNoGeneralRegs:
    736780%ifdef STRICT_IF
    737781    pushf
     
    10251069    jmp     gth_debug_regs_no
    10261070
    1027 ENDPROC VMMGCGuestToHostAsm
     1071ENDPROC vmmRCToHostAsm
    10281072
    10291073
     
    10561100        at VMMSWITCHERDEF.enmType,                      dd SWITCHER_TYPE
    10571101        at VMMSWITCHERDEF.cbCode,                       dd NAME(End)                        - NAME(Start)
    1058         at VMMSWITCHERDEF.offR0HostToGuest,             dd NAME(vmmR0HostToGuest)           - NAME(Start)
    1059         at VMMSWITCHERDEF.offGCGuestToHost,             dd NAME(vmmGCGuestToHost)           - NAME(Start)
    1060         at VMMSWITCHERDEF.offGCCallTrampoline,          dd NAME(vmmGCCallTrampoline)        - NAME(Start)
    1061         at VMMSWITCHERDEF.offGCGuestToHostAsm,          dd NAME(VMMGCGuestToHostAsm)        - NAME(Start)
     1102        at VMMSWITCHERDEF.offR0ToRawMode,               dd NAME(vmmR0ToRawMode)             - NAME(Start)
     1103        at VMMSWITCHERDEF.offRCToHost,                  dd NAME(vmmRCToHost)                - NAME(Start)
     1104        at VMMSWITCHERDEF.offRCCallTrampoline,          dd NAME(vmmRCCallTrampoline)        - NAME(Start)
     1105        at VMMSWITCHERDEF.offRCToHostAsm,               dd NAME(vmmRCToHostAsm)             - NAME(Start)
     1106        at VMMSWITCHERDEF.offRCToHostAsmNoReturn,       dd NAME(vmmRCToHostAsmNoReturn)     - NAME(Start)
    10621107        ; disasm help
    10631108        at VMMSWITCHERDEF.offHCCode0,                   dd 0
  • trunk/src/VBox/VMM/VMMSwitcher/LegacyandAMD64.mac

    r41936 r41976  
    5656; @param    [esp + 08h]  Param 2 - VMCPU offset
    5757;
    58 BEGINPROC vmmR0HostToGuest
     58BEGINPROC vmmR0ToRawMode
    5959%ifdef DEBUG_STUFF
    6060    COM32_S_NEWLINE
     
    8484    mov     edx, 0ffffffffh
    8585    push    cs                          ; allow for far return and restore cs correctly.
    86     call    NAME(vmmR0HostToGuestAsm)
     86    call    NAME(vmmR0ToRawModeAsm)
    8787
    8888%ifdef VBOX_WITH_VMMR0_DISABLE_LAPIC_NMI
     
    124124    ret
    125125
    126 ENDPROC vmmR0HostToGuest
     126ENDPROC vmmR0ToRawMode
    127127
    128128; *****************************************************************************
    129 ; vmmR0HostToGuestAsm
     129; vmmR0ToRawModeAsm
    130130;
    131131; Phase one of the switch from host to guest context (host MMU context)
     
    143143; *****************************************************************************
    144144ALIGNCODE(16)
    145 BEGINPROC vmmR0HostToGuestAsm
     145BEGINPROC vmmR0ToRawModeAsm
    146146    ;;
    147147    ;; Save CPU host context
     
    457457
    458458    ; now let's switch back
    459     jmp     NAME(VMMGCGuestToHostAsm)   ; rax = returncode.
    460 
    461 ENDPROC vmmR0HostToGuestAsm
     459    jmp     NAME(vmmRCToHostAsm)   ; rax = returncode.
     460
     461ENDPROC vmmR0ToRawModeAsm
    462462
    463463
     
    473473BITS 64
    474474ALIGNCODE(16)
    475 BEGINPROC vmmGCCallTrampoline
     475BEGINPROC vmmRCCallTrampoline
    476476%ifdef DEBUG_STUFF
    477477    COM64_S_CHAR 'c'
     
    480480%endif
    481481    int3
    482 ENDPROC vmmGCCallTrampoline
     482ENDPROC vmmRCCallTrampoline
    483483
    484484
     
    488488BITS 64
    489489ALIGNCODE(16)
    490 BEGINPROC vmmGCGuestToHost
     490BEGINPROC vmmRCToHost
    491491%ifdef DEBUG_STUFF
    492492    push    rsi
     
    501501%endif
    502502    int3
    503 ENDPROC vmmGCGuestToHost
     503ENDPROC vmmRCToHost
    504504
    505505;;
    506 ; VMMGCGuestToHostAsm
     506; vmmRCToHostAsm
    507507;
    508508; This is an alternative entry point which we'll be using
     
    515515BITS 64
    516516ALIGNCODE(16)
    517 BEGINPROC VMMGCGuestToHostAsm
     517BEGINPROC vmmRCToHostAsm
     518NAME(vmmRCToHostAsmNoReturn):
    518519    ;; We're still in the intermediate memory context!
    519520
     
    658659    mov     eax, [edx + CPUMCPU.u32RetCode]
    659660    retf
    660 ENDPROC VMMGCGuestToHostAsm
     661ENDPROC vmmRCToHostAsm
    661662
    662663
     
    689690        at VMMSWITCHERDEF.enmType,                      dd SWITCHER_TYPE
    690691        at VMMSWITCHERDEF.cbCode,                       dd NAME(End)                        - NAME(Start)
    691         at VMMSWITCHERDEF.offR0HostToGuest,             dd NAME(vmmR0HostToGuest)           - NAME(Start)
    692         at VMMSWITCHERDEF.offGCGuestToHost,             dd NAME(vmmGCGuestToHost)           - NAME(Start)
    693         at VMMSWITCHERDEF.offGCCallTrampoline,          dd NAME(vmmGCCallTrampoline)        - NAME(Start)
    694         at VMMSWITCHERDEF.offGCGuestToHostAsm,          dd NAME(VMMGCGuestToHostAsm)        - NAME(Start)
     692        at VMMSWITCHERDEF.offR0ToRawMode,               dd NAME(vmmR0ToRawMode)             - NAME(Start)
     693        at VMMSWITCHERDEF.offRCToHost,                  dd NAME(vmmRCToHost)                - NAME(Start)
     694        at VMMSWITCHERDEF.offRCCallTrampoline,          dd NAME(vmmRCCallTrampoline)        - NAME(Start)
     695        at VMMSWITCHERDEF.offRCToHostAsm,               dd NAME(vmmRCToHostAsm)             - NAME(Start)
     696        at VMMSWITCHERDEF.offRCToHostAsmNoReturn,       dd NAME(vmmRCToHostAsmNoReturn)     - NAME(Start)
    695697        ; disasm help
    696698        at VMMSWITCHERDEF.offHCCode0,                   dd 0
  • trunk/src/VBox/VMM/VMMSwitcher/PAEand32Bit.mac

    r41933 r41976  
    2727%include "VBox/vmm/stam.mac"
    2828%include "VBox/vmm/vm.mac"
     29%include "VBox/err.mac"
    2930%include "CPUMInternal.mac"
    3031%include "VMMSwitcher.mac"
     
    5758; The C interface.
    5859;
    59 BEGINPROC vmmR0HostToGuest
     60BEGINPROC vmmR0ToRawMode
    6061
    6162%ifdef DEBUG_STUFF
     
    7980    mov     edx, 0ffffffffh
    8081    push    cs                          ; allow for far return and restore cs correctly.
    81     call    NAME(vmmR0HostToGuestAsm)
     82    call    NAME(vmmR0ToRawModeAsm)
    8283
    8384%ifdef VBOX_WITH_VMMR0_DISABLE_LAPIC_NMI
     
    115116
    116117    ret
    117 ENDPROC vmmR0HostToGuest
     118ENDPROC vmmR0ToRawMode
    118119
    119120
    120121
    121122; *****************************************************************************
    122 ; vmmR0HostToGuestAsm
     123; vmmR0ToRawModeAsm
    123124;
    124125; Phase one of the switch from host to guest context (host MMU context)
     
    135136; *****************************************************************************
    136137ALIGNCODE(16)
    137 BEGINPROC vmmR0HostToGuestAsm
     138BEGINPROC vmmR0ToRawModeAsm
    138139    ;;
    139140    ;; Save CPU host context
     
    256257    ; debug registers.
    257258    test    esi, CPUM_USE_DEBUG_REGS | CPUM_USE_DEBUG_REGS_HOST
    258     jz      htg_debug_regs_no
    259     jmp     htg_debug_regs_save_dr7and6
     259    jnz     htg_debug_regs_save_dr7and6
    260260htg_debug_regs_no:
    261261
     
    408408    ; debug registers
    409409    test    esi, CPUM_USE_DEBUG_REGS
    410     jz      htg_debug_regs_guest_no
    411     jmp     htg_debug_regs_guest
    412 htg_debug_regs_guest_no:
     410    jnz     htg_debug_regs_guest
     411htg_debug_regs_guest_done:
    413412    DEBUG_CHAR('9')
    414413
     
    451450%endif
    452451
    453     ; General registers.
     452    ; General registers (sans edx).
     453    mov     eax, [edx + CPUMCPU.Hyper.eax]
    454454    mov     ebx, [edx + CPUMCPU.Hyper.ebx]
     455    mov     ecx, [edx + CPUMCPU.Hyper.ecx]
    455456    mov     ebp, [edx + CPUMCPU.Hyper.ebp]
    456457    mov     esi, [edx + CPUMCPU.Hyper.esi]
    457458    mov     edi, [edx + CPUMCPU.Hyper.edi]
    458     push    dword [edx + CPUMCPU.Hyper.eflags]
    459     popfd
    460     DEBUG_CHAR('!')
     459    DEBUG_S_CHAR('!')
    461460
    462461    ;;
     
    464463    ;; the code set up to run by HC.
    465464    ;;
     465    push    dword [edx + CPUMCPU.Hyper.eip]
     466    push    dword [edx + CPUMCPU.Hyper.eflags]
     467    mov     edx, [edx + CPUMCPU.Hyper.edx]      ; !! edx is no longer pointing to CPUMCPU here !!
     468
    466469%ifdef DEBUG_STUFF
    467470    COM_S_PRINT ';eip='
    468     mov     eax, [edx + CPUMCPU.Hyper.eip]
     471    push    eax
     472    mov     eax, [esp + 8]
    469473    COM_S_DWORD_REG eax
     474    pop     eax
    470475    COM_S_CHAR ';'
    471476%endif
    472     mov     eax, [edx + CPUMCPU.Hyper.eip]
    473     ; callees expect CPUM ptr
    474     CPUM_FROM_CPUMCPU(edx)
    475 
    476477%ifdef VBOX_WITH_STATISTICS
     478    push    edx
    477479    FIXUP FIX_GC_VM_OFF, 1, VM.StatSwitcherToGC
    478480    mov     edx, 0ffffffffh
    479481    STAM_PROFILE_ADV_STOP edx
    480     FIXUP FIX_GC_CPUM_OFF, 1, 0
    481     mov     edx, 0ffffffffh
    482 %endif
    483     jmp     eax
     482    pop     edx
     483%endif
     484
     485    popfd
     486    ret
    484487
    485488;;
     
    527530    mov     eax, [edx + CPUMCPU.Hyper.dr + 8*7]
    528531    mov     dr7, eax
    529     jmp     htg_debug_regs_guest_no
    530 
    531 ENDPROC vmmR0HostToGuestAsm
     532    jmp     htg_debug_regs_guest_done
     533
     534ENDPROC vmmR0ToRawModeAsm
    532535
    533536
     
    542545;
    543546ALIGNCODE(16)
    544 BEGINPROC vmmGCCallTrampoline
     547BEGINPROC vmmRCCallTrampoline
    545548%ifdef DEBUG_STUFF
    546549    COM_S_CHAR 'c'
     
    551554    ; call routine
    552555    pop     eax                         ; call address
    553     mov     esi, edx                    ; save edx
    554556    pop     edi                         ; argument count.
    555557%ifdef DEBUG_STUFF
     
    562564
    563565    ; return to the host context.
    564     push    byte 0                      ; eip
    565     mov     edx, esi                    ; CPUM pointer
    566 
    567566%ifdef DEBUG_STUFF
    568567    COM_S_CHAR '`'
    569568%endif
    570     jmp     NAME(VMMGCGuestToHostAsm)   ; eax = returncode.
    571 ENDPROC vmmGCCallTrampoline
     569.to_host_again:
     570    call    NAME(vmmRCToHostAsm)
     571    mov     eax, VERR_VMM_SWITCHER_IPE_1
     572    jmp     .to_host_again
     573ENDPROC vmmRCCallTrampoline
    572574
    573575
     
    577579;
    578580ALIGNCODE(16)
    579 BEGINPROC vmmGCGuestToHost
     581BEGINPROC vmmRCToHost
    580582%ifdef DEBUG_STUFF
    581583    push    esi
     
    590592%endif
    591593    mov     eax, [esp + 4]
    592     jmp     NAME(VMMGCGuestToHostAsm)
    593 ENDPROC vmmGCGuestToHost
     594    jmp     NAME(vmmRCToHostAsm)
     595ENDPROC vmmRCToHost
    594596
    595597
    596598;;
    597 ; VMMGCGuestToHostAsm
    598 ;
    599 ; This is an alternative entry point which we'll be using
    600 ; when the we have saved the guest state already or we haven't
    601 ; been messing with the guest at all.
     599; vmmRCToHostAsmNoReturn
     600;
     601; This is an entry point used by TRPM when dealing with raw-mode traps,
     602; i.e. traps in the hypervisor code.  This will not return and saves no
     603; state, because the caller has already saved the state.
     604;
     605; @param    eax     Return code.
     606;
     607ALIGNCODE(16)
     608BEGINPROC vmmRCToHostAsmNoReturn
     609    DEBUG_S_CHAR('%')
     610
     611%ifdef VBOX_WITH_STATISTICS
     612    FIXUP FIX_GC_VM_OFF, 1, VM.StatTotalInGC
     613    mov     edx, 0ffffffffh
     614    STAM32_PROFILE_ADV_STOP edx
     615
     616    FIXUP FIX_GC_VM_OFF, 1, VM.StatTotalGCToQemu
     617    mov     edx, 0ffffffffh
     618    STAM32_PROFILE_ADV_START edx
     619
     620    FIXUP FIX_GC_VM_OFF, 1, VM.StatSwitcherToHC
     621    mov     edx, 0ffffffffh
     622    STAM32_PROFILE_ADV_START edx
     623%endif
     624
     625    FIXUP FIX_GC_CPUMCPU_OFF, 1, 0
     626    mov     edx, 0ffffffffh
     627
     628    jmp     vmmRCToHostAsm_SaveNoGeneralRegs
     629ENDPROC vmmRCToHostAsmNoReturn
     630
     631
     632;;
     633; vmmRCToHostAsm
     634;
     635; This is an entry point used by TRPM to return to host context when an
     636; interrupt occured or an guest trap needs handling in host context.  It
     637; is also used by the C interface above.
     638;
     639; The hypervisor context is saved and it will return to the caller if
     640; host context so desires.
    602641;
    603642; @param    eax     Return code.
     
    605644;
    606645ALIGNCODE(16)
    607 BEGINPROC VMMGCGuestToHostAsm
    608     DEBUG_CHAR('%')
     646BEGINPROC vmmRCToHostAsm
     647    DEBUG_S_CHAR('%')
     648    push    edx
    609649
    610650%ifdef VBOX_WITH_STATISTICS
     
    628668    mov     edx, 0ffffffffh
    629669
     670    ; Save register context.
     671    pop     dword [edx + CPUMCPU.Hyper.edx]
    630672    pop     dword [edx + CPUMCPU.Hyper.eip] ; call return from stack
    631 
    632     ; general registers which we care about.
     673    mov     dword [edx + CPUMCPU.Hyper.esp], esp
     674    mov     dword [edx + CPUMCPU.Hyper.eax], eax
    633675    mov     dword [edx + CPUMCPU.Hyper.ebx], ebx
     676    mov     dword [edx + CPUMCPU.Hyper.ecx], ecx
    634677    mov     dword [edx + CPUMCPU.Hyper.esi], esi
    635678    mov     dword [edx + CPUMCPU.Hyper.edi], edi
    636679    mov     dword [edx + CPUMCPU.Hyper.ebp], ebp
    637     mov     dword [edx + CPUMCPU.Hyper.esp], esp
    638680
    639681    ; special registers which may change.
     682vmmRCToHostAsm_SaveNoGeneralRegs:
    640683    ; str     [edx + CPUMCPU.Hyper.tr] - double fault only, and it won't be right then either.
    641684    sldt    [edx + CPUMCPU.Hyper.ldtr.Sel]
     
    888931    jmp     gth_debug_regs_no
    889932
    890 ENDPROC VMMGCGuestToHostAsm
     933ENDPROC vmmRCToHostAsm
    891934
    892935
     
    919962        at VMMSWITCHERDEF.enmType,                      dd SWITCHER_TYPE
    920963        at VMMSWITCHERDEF.cbCode,                       dd NAME(End)                        - NAME(Start)
    921         at VMMSWITCHERDEF.offR0HostToGuest,             dd NAME(vmmR0HostToGuest)           - NAME(Start)
    922         at VMMSWITCHERDEF.offGCGuestToHost,             dd NAME(vmmGCGuestToHost)           - NAME(Start)
    923         at VMMSWITCHERDEF.offGCCallTrampoline,          dd NAME(vmmGCCallTrampoline)        - NAME(Start)
    924         at VMMSWITCHERDEF.offGCGuestToHostAsm,          dd NAME(VMMGCGuestToHostAsm)        - NAME(Start)
     964        at VMMSWITCHERDEF.offR0ToRawMode,               dd NAME(vmmR0ToRawMode)             - NAME(Start)
     965        at VMMSWITCHERDEF.offRCToHost,                  dd NAME(vmmRCToHost)                - NAME(Start)
     966        at VMMSWITCHERDEF.offRCCallTrampoline,          dd NAME(vmmRCCallTrampoline)        - NAME(Start)
     967        at VMMSWITCHERDEF.offRCToHostAsm,               dd NAME(vmmRCToHostAsm)             - NAME(Start)
     968        at VMMSWITCHERDEF.offRCToHostAsmNoReturn,       dd NAME(vmmRCToHostAsmNoReturn)     - NAME(Start)
    925969        ; disasm help
    926970        at VMMSWITCHERDEF.offHCCode0,                   dd 0
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