VirtualBox

Changeset 46905 in vbox for trunk/src


Ignore:
Timestamp:
Jul 2, 2013 1:11:06 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
86900
Message:

VMM/HMR0: World-switch assembly cleanup.

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

Legend:

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

    r46548 r46905  
    7070; Use define because I'm too lazy to convert the struct.
    7171%define XMM_OFF_IN_X86FXSTATE   160
    72 
    73 
    74 ;; This is too risky wrt. stability, performance and correctness.
    75 ;%define VBOX_WITH_DR6_EXPERIMENT 1
    7672
    7773;; @def MYPUSHAD
  • trunk/src/VBox/VMM/VMMR0/HMR0Mixed.mac

    r46548 r46905  
    5656    ; Manual save and restore:
    5757    ;  - General purpose registers except RIP, RSP.
    58     ; 
     58    ;
    5959    ; Trashed:
    6060    ;  - CR2 (we don't care).
     
    122122    ; VT-x only saves the base of the GDTR & IDTR and resets the limit to 0xffff; we must restore the limit correctly!
    123123%ifdef VMX_SKIP_GDTR_IDTR
    124     sub     xSP, xCB*2
     124    sub     xSP, xCB * 2
    125125    sgdt    [xSP]
    126126
    127     sub     xSP, xCB*2
     127    sub     xSP, xCB * 2
    128128    sidt    [xSP]
    129 %endif
    130 
    131 %ifdef VBOX_WITH_DR6_EXPERIMENT
    132     ; Load DR6 - experiment, not safe!
    133     mov     xBX, [xSI + CPUMCTX.dr6]
    134     mov     dr6, xBX
    135129%endif
    136130
     
    182176%ifdef VMX_SKIP_GDTR_IDTR
    183177    lidt    [xSP]
    184     add     xSP, xCB*2
     178    add     xSP, xCB * 2
    185179    lgdt    [xSP]
    186     add     xSP, xCB*2
     180    add     xSP, xCB * 2
    187181%endif
    188182
     
    208202%endif
    209203
    210 %ifdef VBOX_WITH_DR6_EXPERIMENT
    211     ; Restore DR6 - experiment, not safe!
    212     mov     xAX, dr6
    213     mov     [ss:xDI + CPUMCTX.dr6], xAX
    214 %endif
    215 
    216204    ; Restore TSS selector; must mark it as not busy before using ltr (!)
    217205    ; ASSUME that this is supposed to be 'BUSY'. (saves 20-30 ticks on the T42p)
    218206    ; @todo get rid of sgdt
    219207    pop     xBX         ; Saved TR
    220     sub     xSP, xCB*2
     208    sub     xSP, xCB * 2
    221209    sgdt    [xSP]
    222210    mov     xAX, xBX
     
    225213    and     dword [ss:xAX + 4], ~0200h              ; Clear busy flag (2nd type2 bit).
    226214    ltr     bx
    227     add     xSP, xCB*2
     215    add     xSP, xCB * 2
    228216
    229217    pop     xAX         ; Saved LDTR
     
    236224
    237225    mov     ecx, [ss:xDX + VMCSCACHE.Read.cValidEntries]
    238     cmp     ecx, 0      ; Can't happen
     226    cmp     ecx, 0      ; Can't happen
    239227    je      .no_cached_reads
    240228    jmp     .cached_read
     
    274262%ifdef VMX_SKIP_GDTR_IDTR
    275263    lidt    [xSP]
    276     add     xSP, xCB*2
     264    add     xSP, xCB * 2
    277265    lgdt    [xSP]
    278     add     xSP, xCB*2
     266    add     xSP, xCB * 2
    279267%endif
    280268
     
    283271    ; @todo get rid of sgdt
    284272    pop     xBX         ; Saved TR
    285     sub     xSP, xCB*2
     273    sub     xSP, xCB * 2
    286274    sgdt    [xSP]
    287275    mov     xAX, xBX
     
    290278    and     dword [ss:xAX + 4], ~0200h              ; Clear busy flag (2nd type2 bit).
    291279    ltr     bx
    292     add     xSP, xCB*2
     280    add     xSP, xCB * 2
    293281
    294282    pop     xAX         ; Saved LDTR
     
    296284
    297285%ifdef VMX_USE_CACHED_VMCS_ACCESSES
    298     add     xSP, xCB*2  ; pCtx + pCache
     286    add     xSP, xCB * 2  ; pCtx + pCache
    299287%else
    300288    add     xSP, xCB     ; pCtx
     
    313301%ifdef VMX_SKIP_GDTR_IDTR
    314302    lidt    [xSP]
    315     add     xSP, xCB*2
     303    add     xSP, xCB * 2
    316304    lgdt    [xSP]
    317     add     xSP, xCB*2
     305    add     xSP, xCB * 2
    318306%endif
    319307
     
    322310    ; @todo get rid of sgdt
    323311    pop     xBX         ; Saved TR
    324     sub     xSP, xCB*2
     312    sub     xSP, xCB * 2
    325313    sgdt    [xSP]
    326314    mov     xAX, xBX
     
    329317    and     dword [ss:xAX + 4], ~0200h              ; Clear busy flag (2nd type2 bit).
    330318    ltr     bx
    331     add     xSP, xCB*2
     319    add     xSP, xCB * 2
    332320
    333321    pop     xAX         ; Saved LDTR
     
    335323
    336324%ifdef VMX_USE_CACHED_VMCS_ACCESSES
    337     add     xSP, xCB*2  ; pCtx + pCache
     325    add     xSP, xCB * 2  ; pCtx + pCache
    338326%else
    339327    add     xSP, xCB    ; pCtx
     
    372360    ; First we have to save some final CPU context registers.
    373361    lea     r10, [.vmlaunch64_done wrt rip]
    374     mov     rax, VMX_VMCS_HOST_RIP      ; Return address (too difficult to continue after VMLAUNCH?).
     362    mov     rax, VMX_VMCS_HOST_RIP      ; Return address (too difficult to continue after VMLAUNCH?).
    375363    vmwrite rax, r10
    376364    ; Note: assumes success!
     
    378366    ; Manual save and restore:
    379367    ;  - General purpose registers except RIP, RSP.
    380     ; 
     368    ;
    381369    ; Trashed:
    382370    ;  - CR2 (we don't care).
     
    451439    ; VT-x only saves the base of the GDTR & IDTR and resets the limit to 0xffff; we must restore the limit correctly!
    452440%ifdef VMX_SKIP_GDTR_IDTR
    453     sub     xSP, xCB*2
     441    sub     xSP, xCB * 2
    454442    sgdt    [xSP]
    455443
    456     sub     xSP, xCB*2
     444    sub     xSP, xCB * 2
    457445    sidt    [xSP]
    458 %endif
    459 
    460 %ifdef VBOX_WITH_DR6_EXPERIMENT
    461     ; Load DR6 - experiment, not safe!
    462     mov     xBX, [xSI + CPUMCTX.dr6]
    463     mov     dr6, xBX
    464446%endif
    465447
     
    519501%ifdef VMX_SKIP_GDTR_IDTR
    520502    lidt    [xSP]
    521     add     xSP, xCB*2
     503    add     xSP, xCB * 2
    522504    lgdt    [xSP]
    523     add     xSP, xCB*2
     505    add     xSP, xCB * 2
    524506%endif
    525507
     
    549531    mov     qword [xDI + CPUMCTX.edi], rax
    550532
    551 %ifdef VBOX_WITH_DR6_EXPERIMENT
    552     ; Restore DR6 - experiment, not safe!
    553     mov     xAX, dr6
    554     mov     [xDI + CPUMCTX.dr6], xAX
    555 %endif
    556 
    557533    ; Restore TSS selector; must mark it as not busy before using ltr (!)
    558534    ; ASSUME that this is supposed to be 'BUSY'. (saves 20-30 ticks on the T42p).
    559535    ; @todo get rid of sgdt
    560536    pop     xBX         ; Saved TR
    561     sub     xSP, xCB*2
     537    sub     xSP, xCB * 2
    562538    sgdt    [xSP]
    563539    mov     xAX, xBX
     
    566542    and     dword [xAX + 4], ~0200h                 ; Clear busy flag (2nd type2 bit).
    567543    ltr     bx
    568     add     xSP, xCB*2
     544    add     xSP, xCB * 2
    569545
    570546    pop     xAX         ; Saved LDTR
     
    590566
    591567    mov     ecx, [xDX + VMCSCACHE.Read.cValidEntries]
    592     cmp     ecx, 0      ; Can't happen
     568    cmp     ecx, 0      ; Can't happen
    593569    je      .no_cached_reads
    594570    jmp     .cached_read
     
    628604%ifdef VMX_SKIP_GDTR_IDTR
    629605    lidt    [xSP]
    630     add     xSP, xCB*2
     606    add     xSP, xCB * 2
    631607    lgdt    [xSP]
    632     add     xSP, xCB*2
     608    add     xSP, xCB * 2
    633609%endif
    634610
     
    637613    ; @todo get rid of sgdt
    638614    pop     xBX         ; Saved TR
    639     sub     xSP, xCB*2
     615    sub     xSP, xCB * 2
    640616    sgdt    [xSP]
    641617    mov     xAX, xBX
     
    644620    and     dword [xAX + 4], ~0200h                 ; Clear busy flag (2nd type2 bit).
    645621    ltr     bx
    646     add     xSP, xCB*2
     622    add     xSP, xCB * 2
    647623
    648624    pop     xAX         ; Saved LDTR
     
    680656%ifdef VMX_SKIP_GDTR_IDTR
    681657    lidt    [xSP]
    682     add     xSP, xCB*2
     658    add     xSP, xCB * 2
    683659    lgdt    [xSP]
    684     add     xSP, xCB*2
     660    add     xSP, xCB * 2
    685661%endif
    686662
     
    689665    ; @todo get rid of sgdt
    690666    pop     xBX         ; Saved TR
    691     sub     xSP, xCB*2
     667    sub     xSP, xCB * 2
    692668    sgdt    [xSP]
    693669    mov     xAX, xBX
     
    696672    and     dword [xAX + 4], ~0200h                 ; Clear busy flag (2nd type2 bit).
    697673    ltr     bx
    698     add     xSP, xCB*2
     674    add     xSP, xCB * 2
    699675
    700676    pop     xAX         ; Saved LDTR
     
    759735    ; Manual save and restore:
    760736    ;  - General purpose registers except RIP, RSP, RAX
    761     ; 
     737    ;
    762738    ; Trashed:
    763739    ;  - CR2 (we don't care)
     
    770746
    771747    ; Save the Guest CPU context pointer.
    772     mov     xSI, [xBP + xCB*2 + RTHCPHYS_CB*2] ; pCtx
    773     push    xSI                                 ; push for saving the state at the end
     748    mov     xSI, [xBP + xCB * 2]                ; pCtx
     749    push    xSI                                  ; push for saving the state at the end
    774750
    775751    ; Save host fs, gs, sysenter msr etc.
    776     mov     xAX, [xBP + xCB*2]      ; pVMCBHostPhys (64 bits physical address; x86: take low dword only)
    777     push    xAX                     ; save for the vmload after vmrun
     752    mov     xAX, [xBP + xCB * 2]                 ; pVMCBHostPhys (64 bits physical address; x86: take low dword only)
     753    push    xAX                                  ; save for the vmload after vmrun
    778754    vmsave
    779755
    780756    ; Setup eax for VMLOAD.
    781     mov     xAX, [xBP + xCB*2 + RTHCPHYS_CB]     ; pVMCBPhys (64 bits physical address; take low dword only)
     757    mov     xAX, [xBP + xCB * 2 + RTHCPHYS_CB]    ; pVMCBPhys (64 bits physical address; take low dword only)
    782758
    783759    ; Restore Guest's general purpose registers.
     
    862838    ; Manual save and restore:
    863839    ;  - General purpose registers except RIP, RSP, RAX
    864     ; 
     840    ;
    865841    ; Trashed:
    866842    ;  - CR2 (we don't care)
     
    868844    ;  - DRx (presumably not changed at all)
    869845    ;  - DR7 (reset to 0x400)
    870     ; 
     846    ;
    871847
    872848    ; Save all general purpose host registers.
     
    874850
    875851    ; Save the Guest CPU context pointer.
    876     mov     rsi, [rbp + xCB*2 + RTHCPHYS_CB*2]  ; pCtx
    877     push    rsi                     ; push for saving the state at the end
     852    mov     rsi, [rbp + xCB * 2]                  ; pCtx
     853    push    rsi                                   ; push for saving the state at the end
    878854
    879855    ; Save host fs, gs, sysenter msr etc.
    880     mov     rax, [rbp + xCB*2]      ; pVMCBHostPhys (64 bits physical address; x86: take low dword only)
    881     push    rax                     ; Save for the vmload after vmrun
     856    mov     rax, [rbp + xCB * 2]                  ; pVMCBHostPhys (64 bits physical address; x86: take low dword only)
     857    push    rax                                   ; Save for the vmload after vmrun
    882858    vmsave
    883859
    884860    ; Setup eax for VMLOAD.
    885     mov     rax, [rbp + xCB*2 + RTHCPHYS_CB]    ; pVMCBPhys (64 bits physical address; take low dword only)
     861    mov     rax, [rbp + xCB * 2 + RTHCPHYS_CB]    ; pVMCBPhys (64 bits physical address; take low dword only)
    886862
    887863    ; Restore Guest's general purpose registers.
Note: See TracChangeset for help on using the changeset viewer.

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