VirtualBox

Ignore:
Timestamp:
Jul 12, 2017 5:02:12 AM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
116908
Message:

VMM: Comments, clean up.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR0/HMR0A.asm

    r67136 r67916  
    805805; load the guest ones when necessary.
    806806;
    807 ; @cproto       DECLASM(int) HMR0VMXStartVMhmR0DumpDescriptorM(RTHCUINT fResume, PCPUMCTX pCtx, PVMCSCACHE pCache, PVM pVM, PVMCPU pVCpu, PFNHMVMXSTARTVM pfnStartVM);
     807; @cproto       DECLASM(int) HMR0VMXStartVMhmR0DumpDescriptorM(RTHCUINT fResume, PCPUMCTX pCtx, PVMCSCACHE pCache, PVM pVM,
     808;                                                              PVMCPU pVCpu, PFNHMVMXSTARTVM pfnStartVM);
    808809;
    809810; @returns      eax
     
    984985; load the guest ones when necessary.
    985986;
    986 ; @cproto       DECLASM(int) hmR0SVMRunWrapXMM(RTHCPHYS pVMCBHostPhys, RTHCPHYS pVMCBPhys, PCPUMCTX pCtx, PVM pVM, PVMCPU pVCpu, PFNHMSVMVMRUN pfnVMRun);
     987; @cproto       DECLASM(int) hmR0SVMRunWrapXMM(RTHCPHYS HCPhysVmcbHost, RTHCPHYS HCPhysVmcb, PCPUMCTX pCtx, PVM pVM, PVMCPU pVCpu,
     988;                                              PFNHMSVMVMRUN pfnVMRun);
    987989;
    988990; @returns      eax
    989991;
    990 ; @param        pVMCBHostPhys   msc:rcx
    991 ; @param        pVMCBPhys       msc:rdx
     992; @param        HCPhysVmcbHost  msc:rcx
     993; @param        HCPhysVmcb      msc:rdx
    992994; @param        pCtx            msc:r8
    993995; @param        pVM             msc:r9
     
    10111013
    10121014        ; spill input parameters.
    1013         mov     [xBP + 010h], rcx       ; pVMCBHostPhys
    1014         mov     [xBP + 018h], rdx       ; pVMCBPhys
     1015        mov     [xBP + 010h], rcx       ; HCPhysVmcbHost
     1016        mov     [xBP + 018h], rdx       ; HCPhysVmcb
    10151017        mov     [xBP + 020h], r8        ; pCtx
    10161018        mov     [xBP + 028h], r9        ; pVM
     
    10261028        mov     r10, [xBP + 30h]        ; pVCpu
    10271029        mov     [xSP + 020h], r10
    1028         mov     rcx, [xBP + 010h]       ; pVMCBHostPhys
    1029         mov     rdx, [xBP + 018h]       ; pVMCBPhys
     1030        mov     rcx, [xBP + 010h]       ; HCPhysVmcbHost
     1031        mov     rdx, [xBP + 018h]       ; HCPhysVmcb
    10301032        mov     r8,  [xBP + 020h]       ; pCtx
    10311033        mov     r9,  [xBP + 028h]       ; pVM
     
    10671069        mov     r10, [xBP + 30h]        ; pVCpu
    10681070        mov     [xSP + 020h], r10
    1069         mov     rcx, [xBP + 010h]       ; pVMCBHostPhys
    1070         mov     rdx, [xBP + 018h]       ; pVMCBPhys
     1071        mov     rcx, [xBP + 010h]       ; HCPhysVmcbHost
     1072        mov     rdx, [xBP + 018h]       ; HCPhysVmcb
    10711073        mov     r8,  [xBP + 020h]       ; pCtx
    10721074        mov     r9,  [xBP + 028h]       ; pVM
     
    11291131        mov     r10, [xBP + 30h]        ; pVCpu
    11301132        mov     [xSP + 020h], r10
    1131         mov     rcx, [xBP + 010h]       ; pVMCBHostPhys
    1132         mov     rdx, [xBP + 018h]       ; pVMCBPhys
     1133        mov     rcx, [xBP + 010h]       ; HCPhysVmcbHost
     1134        mov     rdx, [xBP + 018h]       ; HCPhysVmcb
    11331135        mov     r8,  [xBP + 020h]       ; pCtx
    11341136        mov     r9,  [xBP + 028h]       ; pVM
     
    17651767;
    17661768; @returns  VBox status code
    1767 ; @param    HCPhysVMCB      Physical address of host VMCB.
    1768 ; @param    HCPhysVMCB      Physical address of guest VMCB.
    1769 ; @param    pCtx            Pointer to the guest CPU-context.
    1770 ; @param    pVM             msc:r9, gcc:rcx     The cross context VM structure.
     1769; @param    HCPhysVmcbHost  msc:rcx,gcc:rdi     Physical address of host VMCB.
     1770; @param    HCPhysVmcb      msc:rdx,gcc:rsi     Physical address of guest VMCB.
     1771; @param    pCtx            msc:r8,gcc:rdx      Pointer to the guest CPU-context.
     1772; @param    pVM             msc:r9,gcc:rcx      The cross context VM structure.
    17711773; @param    pVCpu           msc:[rsp+28],gcc:r8 The cross context virtual CPU structure of the calling EMT.
    17721774;
     
    17751777%ifdef RT_ARCH_AMD64 ; fake a cdecl stack frame
    17761778 %ifdef ASM_CALL64_GCC
    1777     push    r8
    1778     push    rcx
    1779     push    rdx
    1780     push    rsi
    1781     push    rdi
     1779    push    r8                ; pVCpu
     1780    push    rcx               ; pVM
     1781    push    rdx               ; pCtx
     1782    push    rsi               ; HCPhysVmcb
     1783    push    rdi               ; HCPhysVmcbHost
    17821784 %else
    17831785    mov     rax, [rsp + 28h]
    1784     push    rax                         ; pVCpu
    1785     push    r9                          ; pVM
    1786     push    r8                          ; pCtx
    1787     push    rdx                         ; HCPHYSGuestVMCB
    1788     push    rcx                         ; HCPhysHostVMCB
     1786    push    rax               ; pVCpu
     1787    push    r9                ; pVM
     1788    push    r8                ; pCtx
     1789    push    rdx               ; HCPhysVmcb
     1790    push    rcx               ; HCPhysVmcbHost
    17891791 %endif
    17901792    push    0
     
    17941796    pushf
    17951797
    1796     ;
    17971798    ; Save all general purpose host registers.
    1798     ;
    17991799    MYPUSHAD
    18001800
    1801     ;
    18021801    ; Load pCtx into xSI.
    1803     ;
    18041802    mov     xSI, [xBP + xCB * 2 + RTHCPHYS_CB * 2]  ; pCtx
    18051803
    1806     ;
    18071804    ; Save the host XCR0 and load the guest one if necessary.
    1808     ;
    18091805    mov     xAX, [xBP + xCB * 2 + RTHCPHYS_CB * 2 + xCB * 2] ; pVCpu
    18101806    test    byte [xAX + VMCPU.hm + HMCPU.fLoadSaveGuestXcr0], 1
     
    18121808
    18131809    xor     ecx, ecx
    1814     xgetbv                              ; Save the host one on the stack.
     1810    xgetbv                                  ; Save the host XCR0 on the stack
    18151811    push    xDX
    18161812    push    xAX
    18171813
    18181814    mov     xSI, [xBP + xCB * 2 + RTHCPHYS_CB * 2]  ; pCtx
    1819     mov     eax, [xSI + CPUMCTX.aXcr]   ; Load the guest one.
     1815    mov     eax, [xSI + CPUMCTX.aXcr]       ; load the guest XCR0
    18201816    mov     edx, [xSI + CPUMCTX.aXcr + 4]
    1821     xor     ecx, ecx                    ; paranoia
     1817    xor     ecx, ecx                        ; paranoia
    18221818    xsetbv
    18231819
    1824     push    0                           ; Indicate that we must restore XCR0 (popped into ecx, thus 0).
     1820    push    0                               ; indicate that we must restore XCR0 (popped into ecx, thus 0)
    18251821    jmp     .xcr0_before_done
    18261822
    18271823.xcr0_before_skip:
    1828     push    3fh                         ; indicate that we need not.
     1824    push    3fh                             ; indicate that we need not restore XCR0
    18291825.xcr0_before_done:
    18301826
    1831     ;
    18321827    ; Save guest CPU-context pointer for simplifying saving of the GPRs afterwards.
    1833     ;
    18341828    push    xSI
    18351829
    18361830    ; Save host fs, gs, sysenter msr etc.
    1837     mov     xAX, [xBP + xCB * 2]                    ; pVMCBHostPhys (64 bits physical address; x86: take low dword only)
     1831    mov     xAX, [xBP + xCB * 2]                    ; HCPhysVmcbHost (64 bits physical address; x86: take low dword only)
    18381832    push    xAX                                     ; save for the vmload after vmrun
    18391833    vmsave
    18401834
    18411835    ; Setup xAX for VMLOAD.
    1842     mov     xAX, [xBP + xCB * 2 + RTHCPHYS_CB]      ; pVMCBPhys (64 bits physical address; take low dword only)
     1836    mov     xAX, [xBP + xCB * 2 + RTHCPHYS_CB]      ; HCPhysVmcb (64 bits physical address; x86: take low dword only)
    18431837
    18441838    ; Load guest general purpose registers.
     
    18571851    ; Load guest fs, gs, sysenter msr etc.
    18581852    vmload
     1853
    18591854    ; Run the VM.
    18601855    vmrun
    18611856
    1862     ; eax is in the VMCB already; we can use it here.
    1863 
    18641857    ; Save guest fs, gs, sysenter msr etc.
    18651858    vmsave
    18661859
    18671860    ; Load host fs, gs, sysenter msr etc.
    1868     pop     xAX                     ; Pushed above
     1861    pop     rax                             ; load HCPhysVmcbHost (pushed above)
    18691862    vmload
    18701863
     
    18731866    stgi
    18741867
    1875     ;
    18761868    ; Pop the context pointer (pushed above) and save the guest GPRs (sans RSP and RAX).
    1877     ;
    18781869    pop     xAX
    18791870
     
    18851876    mov     [ss:xAX + CPUMCTX.ebp], ebp
    18861877
    1887     ;
    18881878    ; Restore the host xcr0 if necessary.
    1889     ;
    18901879    pop     xCX
    18911880    test    ecx, ecx
     
    18931882    pop     xAX
    18941883    pop     xDX
    1895     xsetbv                              ; ecx is already zero.
     1884    xsetbv                              ; ecx is already zero
    18961885.xcr0_after_skip:
    18971886
    1898     ;
    18991887    ; Restore host general purpose registers.
    1900     ;
    19011888    MYPOPAD
    19021889
     
    19171904;
    19181905; @returns  VBox status code
    1919 ; @param    HCPhysVMCB      Physical address of host VMCB.
    1920 ; @param    HCPhysVMCB      Physical address of guest VMCB.
    1921 ; @param    pCtx            Pointer to the guest-CPU context.
    1922 ; @param    pVM             msc:r9, gcc:rcx     The cross context VM structure.
     1906; @param    HCPhysVmcbHost  msc:rcx,gcc:rdi     Physical address of host VMCB.
     1907; @param    HCPhysVmcb      msc:rdx,gcc:rsi     Physical address of guest VMCB.
     1908; @param    pCtx            msc:r8,gcc:rdx      Pointer to the guest-CPU context.
     1909; @param    pVM             msc:r9,gcc:rcx      The cross context VM structure.
    19231910; @param    pVCpu           msc:[rsp+28],gcc:r8 The cross context virtual CPU structure of the calling EMT.
    19241911;
     
    19271914    ; Fake a cdecl stack frame
    19281915 %ifdef ASM_CALL64_GCC
    1929     push    r8
    1930     push    rcx
    1931     push    rdx
    1932     push    rsi
    1933     push    rdi
     1916    push    r8                ;pVCpu
     1917    push    rcx               ;pVM
     1918    push    rdx               ;pCtx
     1919    push    rsi               ;HCPhysVmcb
     1920    push    rdi               ;HCPhysVmcbHost
    19341921 %else
    19351922    mov     rax, [rsp + 28h]
    1936     push    rax                         ; rbp + 30h pVCpu
    1937     push    r9                          ; rbp + 28h pVM
    1938     push    r8                          ; rbp + 20h pCtx
    1939     push    rdx                         ; rbp + 18h HCPHYSGuestVMCB
    1940     push    rcx                         ; rbp + 10h HCPhysHostVMCB
    1941  %endif
    1942     push    0                           ; rbp + 08h "fake ret addr"
    1943     push    rbp                         ; rbp + 00h
     1923    push    rax               ; rbp + 30h pVCpu
     1924    push    r9                ; rbp + 28h pVM
     1925    push    r8                ; rbp + 20h pCtx
     1926    push    rdx               ; rbp + 18h HCPhysVmcb
     1927    push    rcx               ; rbp + 10h HCPhysVmcbHost
     1928 %endif
     1929    push    0                 ; rbp + 08h "fake ret addr"
     1930    push    rbp               ; rbp + 00h
    19441931    mov     rbp, rsp
    19451932    pushf
     
    19531940    ;  - DRx (presumably not changed at all)
    19541941    ;  - DR7 (reset to 0x400)
    1955     ;
    1956 
    1957     ;
     1942
    19581943    ; Save all general purpose host registers.
    1959     ;
    19601944    MYPUSHAD
    19611945
    1962     ;
    19631946    ; Load pCtx into xSI.
    1964     ;
    19651947    mov     xSI, [rbp + xCB * 2 + RTHCPHYS_CB * 2]
    19661948
    1967     ;
    19681949    ; Save the host XCR0 and load the guest one if necessary.
    1969     ;
    1970     mov     rax, [xBP + 30h]            ; pVCpu
     1950    mov     rax, [xBP + 30h]                ; pVCpu
    19711951    test    byte [xAX + VMCPU.hm + HMCPU.fLoadSaveGuestXcr0], 1
    19721952    jz      .xcr0_before_skip
    19731953
    19741954    xor     ecx, ecx
    1975     xgetbv                              ; Save the host one on the stack.
     1955    xgetbv                                  ; save the host XCR0 on the stack.
    19761956    push    xDX
    19771957    push    xAX
    19781958
    19791959    mov     xSI, [xBP + xCB * 2 + RTHCPHYS_CB * 2]  ; pCtx
    1980     mov     eax, [xSI + CPUMCTX.aXcr]   ; Load the guest one.
     1960    mov     eax, [xSI + CPUMCTX.aXcr]       ; load the guest XCR0
    19811961    mov     edx, [xSI + CPUMCTX.aXcr + 4]
    1982     xor     ecx, ecx                    ; paranoia
     1962    xor     ecx, ecx                        ; paranoia
    19831963    xsetbv
    19841964
    1985     push    0                           ; Indicate that we must restore XCR0 (popped into ecx, thus 0).
     1965    push    0                               ; indicate that we must restore XCR0 (popped into ecx, thus 0)
    19861966    jmp     .xcr0_before_done
    19871967
    19881968.xcr0_before_skip:
    1989     push    3fh                         ; indicate that we need not.
     1969    push    3fh                             ; indicate that we need not restore XCR0
    19901970.xcr0_before_done:
    19911971
    1992     ;
    19931972    ; Save guest CPU-context pointer for simplifying saving of the GPRs afterwards.
    1994     ;
    19951973    push    rsi
    19961974
    1997     ;
    19981975    ; Save host fs, gs, sysenter msr etc.
    1999     ;
    2000     mov     rax, [rbp + xCB * 2]                    ; pVMCBHostPhys (64 bits physical address; x86: take low dword only)
    2001     push    rax                                     ; Save for the vmload after vmrun
     1976    mov     rax, [rbp + xCB * 2]                    ; HCPhysVmcbHost (64 bits physical address; x86: take low dword only)
     1977    push    rax                                     ; save for the vmload after vmrun
    20021978    vmsave
    20031979
    20041980    ; Setup rax for VMLOAD.
    2005     mov     rax, [rbp + xCB * 2 + RTHCPHYS_CB]      ; pVMCBPhys (64 bits physical address; take low dword only)
    2006 
    2007     ; Load guest general purpose registers.
    2008     ; rax is loaded from the VMCB by VMRUN.
     1981    mov     rax, [rbp + xCB * 2 + RTHCPHYS_CB]      ; HCPhysVmcb (64 bits physical address; take low dword only)
     1982
     1983    ; Load guest general purpose registers (rax is loaded from the VMCB by VMRUN).
    20091984    mov     rbx, qword [xSI + CPUMCTX.ebx]
    20101985    mov     rcx, qword [xSI + CPUMCTX.ecx]
     
    20262001    sti
    20272002
    2028     ; Load guest fs, gs, sysenter msr etc.
     2003    ; Load guest FS, GS, Sysenter MSRs etc.
    20292004    vmload
     2005
    20302006    ; Run the VM.
    20312007    vmrun
    20322008
    2033     ; rax is in the VMCB already; we can use it here.
    2034 
    20352009    ; Save guest fs, gs, sysenter msr etc.
    20362010    vmsave
    20372011
    2038     ;
    20392012    ; Load host fs, gs, sysenter msr etc.
    2040     ;
    2041     pop     rax                     ; pushed above
     2013    pop     rax                         ; load HCPhysVmcbHost (pushed above)
    20422014    vmload
    20432015
    2044     ;
    20452016    ; Set the global interrupt flag again, but execute cli to make sure IF=0.
    2046     ;
    20472017    cli
    20482018    stgi
    20492019
    2050     ;
    20512020    ; Pop the context pointer (pushed above) and save the guest GPRs (sans RSP and RAX).
    2052     ;
    20532021    pop     rax
    20542022
     
    20682036    mov     qword [rax + CPUMCTX.r15], r15
    20692037
    2070     ;
    20712038    ; Restore the host xcr0 if necessary.
    2072     ;
    20732039    pop     xCX
    20742040    test    ecx, ecx
     
    20762042    pop     xAX
    20772043    pop     xDX
    2078     xsetbv                              ; ecx is already zero.
     2044    xsetbv                              ; ecx is already zero
    20792045.xcr0_after_skip:
    20802046
    2081     ;
    20822047    ; Restore host general purpose registers.
    2083     ;
    20842048    MYPOPAD
    20852049
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