VirtualBox

Changeset 14845 in vbox for trunk/src/VBox/VMM


Ignore:
Timestamp:
Dec 1, 2008 10:12:25 AM (16 years ago)
Author:
vboxsync
Message:

Switcher updates

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/HWACCM.cpp

    r14806 r14845  
    819819    }
    820820
     821#if RT_ARCH_BITS == 32 && defined(VBOX_ENABLE_64_BITS_GUESTS)
     822    if (pVM->fHWACCMEnabled)
     823    {
     824        switch(PGMGetHostMode(pVM))
     825        {
     826        case PGMMODE_32_BIT:
     827            pVM->hwaccm.s.pfnHost32ToGuest64R0 = VMMR3GetHostToGuestSwitcher(pVM, VMMSWITCHER_32_TO_AMD64);
     828            break;
     829
     830        case PGMMODE_PAE:
     831        case PGMMODE_PAE_NX:
     832            pVM->hwaccm.s.pfnHost32ToGuest64R0 = VMMR3GetHostToGuestSwitcher(pVM, VMMSWITCHER_PAE_TO_AMD64);
     833            break;
     834
     835        default:
     836            AssertFailed();
     837            break;
     838        }
     839
     840        rc = PDMR3LdrGetSymbolRC(pVM, NULL,       "VMXGCStartVM64", &pVM->hwaccm.pfnVMXGCStartVM64);
     841        AssertMsgRCReturn(rc, ("VMXGCStartVM64 -> rc=%Rrc\n", rc), rc);
     842
     843        rc = PDMR3LdrGetSymbolRC(pVM, NULL,       "SVMGCVMRun64",   &pVM->hwaccm.pfnSVMGCVMRun64);
     844        AssertMsgRCReturn(rc, ("SVMGCVMRun64 -> rc=%Rrc\n", rc), rc);
     845    }
     846#endif
    821847    return VINF_SUCCESS;
    822848}
  • trunk/src/VBox/VMM/HWACCMInternal.h

    r14804 r14845  
    200200
    201201#if HC_ARCH_BITS == 32
     202    /** 32 to 64 bits switcher entrypoint. */
     203    RTR0PTR                     pfnHost32ToGuest64R0;
     204
     205    /* AMD-V 64 bits vmrun handler */
     206    RTRCPTR                     pfnSVMGCVMRun64;
     207
     208    /* VT-x 64 bits vmlaunch handler */
     209    RTRCPTR                     pfnVMXGCStartVM64;
     210
    202211    uint32_t                    Alignment0;
    203212#endif
     
    383392
    384393        /** Ring 0 handlers for VT-x. */
    385         DECLR0CALLBACKMEMBER(int,  pfnStartVM,(RTHCUINT fResume, PCPUMCTX pCtx));
     394        DECLR0CALLBACKMEMBER(int,  pfnStartVM,(RTHCUINT fResume, PCPUMCTX pCtx, PVM pVM, PVMCPU pVCpu));
    386395
    387396        /** Current VMX_VMCS_CTRL_PROC_EXEC_CONTROLS. */
     
    515524
    516525VMMR0DECL(PHWACCM_CPUINFO) HWACCMR0GetCurrentCpu();
     526VMMR0DECL(PHWACCM_CPUINFO) HWACCMR0GetCurrentCpuEx(RTCPUID idCpu);
    517527
    518528
  • trunk/src/VBox/VMM/VMMR0/HWACCMR0.cpp

    r14804 r14845  
    10141014 *
    10151015 * @returns cpu structure pointer
    1016  * @param   pVM         The VM to operate on.
    10171016 */
    10181017VMMR0DECL(PHWACCM_CPUINFO) HWACCMR0GetCurrentCpu()
     
    10201019    RTCPUID  idCpu = RTMpCpuId();
    10211020
     1021    return &HWACCMR0Globals.aCpuInfo[idCpu];
     1022}
     1023
     1024/**
     1025 * Returns the cpu structure for the current cpu.
     1026 * Keep in mind that there is no guarantee it will stay the same (long jumps to ring 3!!!).
     1027 *
     1028 * @returns cpu structure pointer
     1029 * @param   idCpu       id of the VCPU
     1030 */
     1031VMMR0DECL(PHWACCM_CPUINFO) HWACCMR0GetCurrentCpuEx(RTCPUID idCpu)
     1032{
    10221033    return &HWACCMR0Globals.aCpuInfo[idCpu];
    10231034}
  • trunk/src/VBox/VMM/VMMR0/HWVMXR0.cpp

    r14805 r14845  
    15021502    if (pCtx->msrEFER & MSR_K6_EFER_LMA)
    15031503    {
    1504 #if !defined(VBOX_WITH_64_BITS_GUESTS) || HC_ARCH_BITS != 64
     1504#if !defined(VBOX_WITH_64_BITS_GUESTS)
    15051505        return VERR_PGM_UNSUPPORTED_SHADOW_PAGING_MODE;
     1506#elif HC_ARCH_BITS == 32
     1507        pVCpu->hwaccm.s.vmx.pfnStartVM  = VMXR0SwitcherStartVM64;
    15061508#else
    15071509        pVCpu->hwaccm.s.vmx.pfnStartVM  = VMXR0StartVM64;
     
    20412043#endif
    20422044    TMNotifyStartOfExecution(pVM);
    2043     rc = pVCpu->hwaccm.s.vmx.pfnStartVM(pVCpu->hwaccm.s.fResumeVM, pCtx);
     2045    rc = pVCpu->hwaccm.s.vmx.pfnStartVM(pVCpu->hwaccm.s.fResumeVM, pCtx, pVM, pVCpu);
    20442046    TMNotifyEndOfExecution(pVM);
    20452047
     
    34223424 * @param   fResume     vmlauch/vmresume
    34233425 * @param   pCtx        Guest context
     3426 * @param   pVM         The VM to operate on.
     3427 * @param   pVCpu       The VMCPU to operate on.
    34243428 */
    3425 DECLASM(int) VMXR0SwitcherStartVM64(RTHCUINT fResume, PCPUMCTX pCtx)
     3429DECLASM(int) VMXR0SwitcherStartVM64(RTHCUINT fResume, PCPUMCTX pCtx, PVM pVM, PVMCPU pVCpu)
    34263430{
    3427     return VERR_NOT_IMPLEMENTED;
     3431    int             rc, rc2;
     3432    RTCCUINTREG     uFlags;
     3433    PHWACCM_CPUINFO pCpu;
     3434    RTHCPHYS        pPageCpuPhys;
     3435
     3436    pCpu = HWACCMR0GetCurrentCpuEx(pVCpu->idCpu);
     3437    pPageCpuPhys = RTR0MemObjGetPagePhysAddr(pCpu->pMemObj, 0);
     3438
     3439    /* Clear VM Control Structure. Marking it inactive, clearing implementation specific data and writing back VMCS data to memory. */
     3440    VMXClearVMCS(pVCpu->hwaccm.s.vmx.pVMCSPhys);
     3441
     3442    /* Leave VMX Root Mode. */
     3443    VMXDisable();
     3444
     3445    uFlags = ASMIntDisableFlags();
     3446    /* Call switcher. */
     3447    rc = VERR_ACCESS_DENIED;
     3448
     3449    ASMSetFlags(uFlags);
     3450
     3451    /* Make sure the VMX instructions don't cause #UD faults. */
     3452    ASMSetCR4(ASMGetCR4() | X86_CR4_VMXE);
     3453
     3454    /* Enter VMX Root Mode */
     3455    rc2 = VMXEnable(pPageCpuPhys);
     3456    if (RT_FAILURE(rc2))
     3457    {
     3458        if (pVM)
     3459            VMXR0CheckError(pVM, pVCpu, rc2);
     3460        ASMSetCR4(ASMGetCR4() & ~X86_CR4_VMXE);
     3461        return VERR_VMX_VMXON_FAILED;
     3462    }
     3463
     3464    VMXActivateVMCS(pVCpu->hwaccm.s.vmx.pVMCSPhys);
     3465    return rc;
    34283466}
    34293467#endif
  • trunk/src/VBox/VMM/VMMR0/HWVMXR0.h

    r14649 r14845  
    196196 * @param   fResume     vmlauch/vmresume
    197197 * @param   pCtx        Guest context
    198  */
    199 DECLASM(int) VMXR0StartVM32(RTHCUINT fResume, PCPUMCTX pCtx);
     198 * @param   pVM         The VM to operate on.
     199 * @param   pVCpu       The VMCPU to operate on.
     200 */
     201DECLASM(int) VMXR0StartVM32(RTHCUINT fResume, PCPUMCTX pCtx, PVM pVM, PVMCPU pVCpu);
    200202
    201203/**
     
    205207 * @param   fResume     vmlauch/vmresume
    206208 * @param   pCtx        Guest context
    207  */
    208 DECLASM(int) VMXR0StartVM64(RTHCUINT fResume, PCPUMCTX pCtx);
     209 * @param   pVM         The VM to operate on.
     210 * @param   pVCpu       The VMCPU to operate on.
     211 */
     212DECLASM(int) VMXR0StartVM64(RTHCUINT fResume, PCPUMCTX pCtx, PVM pVM, PVMCPU pVCpu);
    209213
    210214/**
     
    214218 * @param   fResume     vmlauch/vmresume
    215219 * @param   pCtx        Guest context
    216  */
    217 DECLASM(int) VMXR0SwitcherStartVM64(RTHCUINT fResume, PCPUMCTX pCtx);
     220 * @param   pVM         The VM to operate on.
     221 * @param   pVCpu       The VMCPU to operate on.
     222 */
     223DECLASM(int) VMXR0SwitcherStartVM64(RTHCUINT fResume, PCPUMCTX pCtx, PVM pVM, PVMCPU pVCpu);
    218224
    219225#endif /* IN_RING0 */
  • trunk/src/VBox/VMM/VMMSwitcher.cpp

    r14771 r14845  
    982982}
    983983
     984/**
     985 * Gets the switcher to be used for switching to GC.
     986 *
     987 * @returns host to guest ring 0 switcher entrypoint
     988 * @param   pVM             VM handle.
     989 * @param   enmSwitcher     The new switcher.
     990 */
     991VMMR3DECL(RTR0PTR) VMMR3GetHostToGuestSwitcher(PVM pVM, VMMSWITCHER enmSwitcher)
     992{
     993    /*
     994     * Validate input.
     995     */
     996    if (    enmSwitcher < VMMSWITCHER_INVALID
     997        ||  enmSwitcher >= VMMSWITCHER_MAX)
     998    {
     999        AssertMsgFailed(("Invalid input enmSwitcher=%d\n", enmSwitcher));
     1000        return VERR_INVALID_PARAMETER;
     1001    }
     1002
     1003    /*
     1004     * Select the new switcher.
     1005     */
     1006    PVMMSWITCHERDEF pSwitcher = s_apSwitchers[enmSwitcher];
     1007    if (pSwitcher)
     1008    {
     1009        RTR0PTR     pbCodeR0 = (RTR0PTR)pVM->vmm.s.pvCoreCodeR0 + pVM->vmm.s.aoffSwitchers[enmSwitcher]; /** @todo fix the pvCoreCodeR0 type */
     1010        return pbCodeR0 + pSwitcher->offR0HostToGuest;
     1011    }
     1012    return (RTR0PTR)0;
     1013}
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