VirtualBox

Changeset 14993 in vbox for trunk


Ignore:
Timestamp:
Dec 4, 2008 3:39:41 PM (16 years ago)
Author:
vboxsync
Message:

Switcher updates

Location:
trunk/src/VBox/VMM
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/CPUMInternal.mac

    r14987 r14993  
    2828%define CPUM_USE_DEBUG_REGS_HOST        RT_BIT(4)
    2929%define CPUM_USE_DEBUG_REGS             RT_BIT(5)
     30%define CPUM_SYNC_FPU_STATE             RT_BIT(7)
     31%define CPUM_SYNC_DEBUG_STATE           RT_BIT(8)
    3032
    3133%define CPUM_HANDLER_DS                 1
  • trunk/src/VBox/VMM/VMMGC/HWACCMGCA.asm

    r14900 r14993  
    170170; *
    171171; * @returns VBox status code
    172 ; * @param   pCtx       Guest context
     172; * @param   pCtx       Guest context (rsi)
    173173; */
    174174BEGINPROC VMXGCStartVM64
     
    371371; *
    372372; * @returns VBox status code
    373 ; * @param   HCPhysVMCB     Physical address of host VMCB
    374 ; * @param   HCPhysVMCB     Physical address of guest VMCB
    375 ; * @param   pCtx           Guest context
     373; * @param   HCPhysVMCB     Physical address of host VMCB       (rsp+8)
     374; * @param   HCPhysVMCB     Physical address of guest VMCB      (rsp+16)
     375; * @param   pCtx           Guest context                       (rsi)
    376376; */
    377377BEGINPROC SVMGCVMRun64
    378     ; fake a cdecl stack frame
    379  %ifdef ASM_CALL64_GCC
    380     push    rdx
    381     push    rsi
    382     push    rdi
    383  %else
    384     push    r8
    385     push    rdx
    386     push    rcx
    387  %endif
    388     push    0
    389378    push    rbp
    390379    mov     rbp, rsp
     
    405394
    406395    ;/* Save the Guest CPU context pointer. */
    407     mov     rsi, [rbp + 8*2 + RTHCPHYS_CB*2]   ; pCtx
    408396    push    rsi                     ; push for saving the state at the end
    409397
     
    413401
    414402    ; save host fs, gs, sysenter msr etc
    415     mov     rax, [rbp + 8*2]       ; pVMCBHostPhys (64 bits physical address; x86: take low dword only)
    416     push    rax                     ; save for the vmload after vmrun
     403    mov     rax, [rbp + 8]                  ; pVMCBHostPhys (64 bits physical address)
     404    push    rax                             ; save for the vmload after vmrun
    417405    vmsave
    418406
    419407    ; setup eax for VMLOAD
    420     mov     rax, [rbp + 8*2 + RTHCPHYS_CB]     ; pVMCBPhys (64 bits physical address; take low dword only)
     408    mov     rax, [rbp + 8 + RTHCPHYS_CB]    ; pVMCBPhys (64 bits physical address)
    421409
    422410    ;/* Restore Guest's general purpose registers. */
     
    483471    popf
    484472    pop     rbp
    485     add     rsp, 4*8
    486473    ret
    487474ENDPROC SVMGCVMRun64
  • trunk/src/VBox/VMM/VMMR0/HWSVMR0.cpp

    r14945 r14993  
    22842284DECLASM(int) SVMR0VMSwitcherRun64(RTHCPHYS pVMCBHostPhys, RTHCPHYS pVMCBPhys, PCPUMCTX pCtx, PVM pVM, PVMCPU pVCpu)
    22852285{
    2286     return SVMR0Execute64BitsHandler(pVM, pVCpu, pCtx, pVM->hwaccm.s.pfnVMXGCStartVM64);
     2286    int             rc;
     2287    RTCCUINTREG     uFlags;
     2288
     2289    /* @todo This code is not guest SMP safe (hyper context) */
     2290    AssertReturn(pVM->cCPUs == 1, VERR_ACCESS_DENIED);
     2291
     2292    uFlags = ASMIntDisableFlags();
     2293
     2294    CPUMSetHyperESP(pVM, VMMGetStackRC(pVM));
     2295    CPUMPushHyper(pVM, (uint32_t)(pVMCBHostPhys >> 32));    /* Param 2: pVMCBHostPhys - Hi. */
     2296    CPUMPushHyper(pVM, (uint32_t)pVMCBHostPhys);            /* Param 2: pVMCBHostPhys - Lo. */
     2297    CPUMPushHyper(pVM, (uint32_t)(pVMCBPhys >> 32));        /* Param 1: pVMCBPhys - Hi. */
     2298    CPUMPushHyper(pVM, (uint32_t)pVMCBPhys);                /* Param 1: pVMCBPhys - Lo. */
     2299    CPUMSetHyperEIP(pVM, pVM->hwaccm.s.pfnVMXGCStartVM64);
     2300
     2301    /* Call switcher. */
     2302    rc = pVM->hwaccm.s.pfnHost32ToGuest64R0(pVM);
     2303
     2304    ASMSetFlags(uFlags);
     2305    return rc;
    22872306}
    22882307
  • trunk/src/VBox/VMM/VMMSwitcher/LegacyandAMD64.mac

    r14988 r14993  
    136136    pop     dword [edx + CPUMCPU.Host.eflags]
    137137
    138     ;; handle use flags.
    139     mov     esi, [edx + CPUMCPU.fUseFlags] ; esi == use flags.
    140     and     esi, ~CPUM_USED_FPU         ; Clear CPUM_USED_* flags. ;;@todo FPU check can be optimized to use cr0 flags!
    141     mov     [edx + CPUMCPU.fUseFlags], esi
    142 
    143138    ; control registers.
    144139    mov     eax, cr0
     
    240235    mov     ds, rax
    241236    mov     es, rax
    242    
     237
    243238    ; Setup stack; use the lss_esp, ss pair for lss
    244239    DEBUG_CHAR('7')
     
    248243    lss     esp, [rdx + CPUM.Hyper.lss_esp]
    249244
    250     ; call the hypervisor function with rdx=pCpumCpu
    251     mov     eax, [rdx + CPUM.Hyper.eip]
     245    ; load the hypervisor function address
     246    mov     r9, [rdx + CPUM.Hyper.eip]
     247
    252248    CPUMCPU_FROM_CPUM(edx)
     249   
     250    ; Check if we need to restore the guest FPU state
     251    mov     esi, [rdx + CPUMCPU.fUseFlags] ; esi == use flags.
     252    test    esi, CPUM_SYNC_FPU_STATE
     253    jz      near gth_fpu_no 
     254
     255    mov     rax, cr0
     256    mov     rcx, rax                    ; save old CR0
     257    and     rax, ~(X86_CR0_TS | X86_CR0_EM)
     258    mov     cr0, rax
     259    fxrstor [rdx + CPUMCPU.Guest.fpu]
     260    mov     cr0, rcx                    ; and restore old CR0 again
     261
     262gth_fpu_no:
     263    ; Check if we need to restore the guest debug state
     264    test    esi, CPUM_SYNC_DEBUG_STATE
     265    jz      near gth_debug_no
     266   
     267    mov rax, qword [rdx + CPUMCPU.Guest.dr + 0*8]
     268    mov dr0, rax
     269    mov rax, qword [rdx + CPUMCPU.Guest.dr + 1*8]
     270    mov dr1, rax
     271    mov rax, qword [rdx + CPUMCPU.Guest.dr + 2*8]
     272    mov dr2, rax
     273    mov rax, qword [rdx + CPUMCPU.Guest.dr + 3*8]
     274    mov dr3, rax
     275    mov rax, qword [rdx + CPUMCPU.Guest.dr + 6*8]
     276    mov dr6, rax    ; not required for AMD-V
     277
     278gth_debug_no:
    253279
    254280    ; parameter for all helper functions (pCtx)   
    255281    lea     rsi, [rdx + CPUMCPU.Guest.fpu]
    256     call    rax
     282    call    r9
    257283   
    258284    ; Load CPUM pointer into rdx
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