VirtualBox

Changeset 41931 in vbox for trunk/src/VBox/VMM/VMMR3


Ignore:
Timestamp:
Jun 27, 2012 4:12:16 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
78796
Message:

TRPM: Save state directly to the CPUMCPU context member instead of putting on the stack. this avoid copying the state around before returning to host context to service an IRQ, or before using IEM.

Location:
trunk/src/VBox/VMM/VMMR3
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR3/CPUM.cpp

    r41906 r41931  
    426426        PVMCPU pVCpu = &pVM->aCpus[i];
    427427
    428         /*
    429          * Setup any fixed pointers and offsets.
    430          */
    431         pVCpu->cpum.s.pHyperCoreR3 = CPUMCTX2CORE(&pVCpu->cpum.s.Hyper);
    432         pVCpu->cpum.s.pHyperCoreR0 = VM_R0_ADDR(pVM, CPUMCTX2CORE(&pVCpu->cpum.s.Hyper));
    433 
    434         pVCpu->cpum.s.offCPUM      = RT_OFFSETOF(VM, aCpus[i].cpum) - RT_OFFSETOF(VM, cpum);
     428        pVCpu->cpum.s.offCPUM = RT_OFFSETOF(VM, aCpus[i].cpum) - RT_OFFSETOF(VM, cpum);
    435429        Assert((uintptr_t)&pVCpu->cpum - pVCpu->cpum.s.offCPUM == (uintptr_t)&pVM->cpum);
    436430    }
     
    12691263{
    12701264    LogFlow(("CPUMR3Relocate\n"));
    1271     for (VMCPUID i = 0; i < pVM->cCpus; i++)
    1272     {
    1273         /*
    1274          * Switcher pointers.
    1275          */
    1276         PVMCPU pVCpu = &pVM->aCpus[i];
    1277         pVCpu->cpum.s.pHyperCoreRC = MMHyperCCToRC(pVM, pVCpu->cpum.s.pHyperCoreR3);
    1278         Assert(pVCpu->cpum.s.pHyperCoreRC != NIL_RTRCPTR);
    1279 
    1280     }
     1265    /* nothing to do any more. */
    12811266}
    12821267
     
    29232908    cpumR3InfoParseArg(pszArgs, &enmType, &pszComment);
    29242909    pHlp->pfnPrintf(pHlp, "Hypervisor CPUM state: %s\n", pszComment);
    2925     cpumR3InfoOne(pVM, &pVCpu->cpum.s.Hyper, pVCpu->cpum.s.pHyperCoreR3, pHlp, enmType, ".");
     2910    cpumR3InfoOne(pVM, &pVCpu->cpum.s.Hyper, CPUMCTX2CORE(&pVCpu->cpum.s.Hyper), pHlp, enmType, ".");
    29262911    pHlp->pfnPrintf(pHlp, "CR4OrMask=%#x CR4AndMask=%#x\n", pVM->cpum.s.CR4.OrMask, pVM->cpum.s.CR4.AndMask);
    29272912}
  • trunk/src/VBox/VMM/VMMR3/PDMLdr.cpp

    r41800 r41931  
    2525#include <VBox/vmm/pdm.h>
    2626#include <VBox/vmm/mm.h>
     27#include <VBox/vmm/trpm.h>
    2728#include <VBox/vmm/vmm.h>
    2829#include <VBox/vmm/vm.h>
     
    355356        else if (!strcmp(pszSymbol, "g_CPUM"))
    356357            *pValue = VM_RC_ADDR(pVM, &pVM->cpum);
    357         else if (!strcmp(pszSymbol, "g_TRPM"))
    358             *pValue = VM_RC_ADDR(pVM, &pVM->trpm);
    359         else if (!strcmp(pszSymbol, "g_TRPMCPU"))
    360             *pValue = VM_RC_ADDR(pVM, &pVM->aCpus[0].trpm);
     358        else if (   !strncmp(pszSymbol, "g_TRPM", 6)
     359                 || !strncmp(pszSymbol, "g_trpm", 6)
     360                 || !strncmp(pszSymbol, "TRPM", 4))
     361        {
     362            RTRCPTR RCPtr = 0;
     363            rc = TRPMR3GetImportRC(pVM, pszSymbol, &RCPtr);
     364            if (RT_SUCCESS(rc))
     365                *pValue = RCPtr;
     366        }
    361367        else if (   !strncmp(pszSymbol, "VMM", 3)
    362368                 || !strcmp(pszSymbol, "g_Logger")
  • trunk/src/VBox/VMM/VMMR3/TRPM.cpp

    r41803 r41931  
    782782
    783783/**
     784 * Resolve a builtin RC symbol.
     785 *
     786 * Called by PDM when loading or relocating RC modules.
     787 *
     788 * @returns VBox status
     789 * @param   pVM             Pointer to the VM.
     790 * @param   pszSymbol       Symbol to resolv
     791 * @param   pRCPtrValue     Where to store the symbol value.
     792 *
     793 * @remark  This has to work before VMMR3Relocate() is called.
     794 */
     795VMMR3_INT_DECL(int) TRPMR3GetImportRC(PVM pVM, const char *pszSymbol, PRTRCPTR pRCPtrValue)
     796{
     797    if (!strcmp(pszSymbol, "g_TRPM"))
     798        *pRCPtrValue = VM_RC_ADDR(pVM, &pVM->trpm);
     799    else if (!strcmp(pszSymbol, "g_TRPMCPU"))
     800        *pRCPtrValue = VM_RC_ADDR(pVM, &pVM->aCpus[0].trpm);
     801    else if (!strcmp(pszSymbol, "g_trpmGuestCtxCore"))
     802    {
     803        PCPUMCTX pCtx = CPUMQueryGuestCtxPtr(VMMGetCpu0(pVM));
     804        *pRCPtrValue = VM_RC_ADDR(pVM, CPUMCTX2CORE(pCtx));
     805    }
     806    else if (!strcmp(pszSymbol, "g_trpmHyperCtxCore"))
     807    {
     808        PCPUMCTX pCtx = CPUMGetHyperCtxPtr(VMMGetCpu0(pVM));
     809        *pRCPtrValue = VM_RC_ADDR(pVM, CPUMCTX2CORE(pCtx));
     810    }
     811    else
     812        return VERR_SYMBOL_NOT_FOUND;
     813    return VINF_SUCCESS;
     814}
     815
     816
     817/**
    784818 * Execute state save operation.
    785819 *
  • trunk/src/VBox/VMM/VMMR3/VMM.cpp

    r41906 r41931  
    561561    if (RT_SUCCESS(rc))
    562562    {
    563         CPUMHyperSetCtxCore(pVCpu, NULL);
    564563        CPUMSetHyperESP(pVCpu, pVCpu->vmm.s.pbEMTStackBottomRC); /* Clear the stack. */
    565564        uint64_t u64TS = RTTimeProgramStartNanoTS();
     
    18741873     * Setup the call frame using the trampoline.
    18751874     */
    1876     CPUMHyperSetCtxCore(pVCpu, NULL);
    18771875    memset(pVCpu->vmm.s.pbEMTStackR3, 0xaa, VMM_STACK_SIZE); /* Clear the stack. */
    18781876    CPUMSetHyperESP(pVCpu, pVCpu->vmm.s.pbEMTStackBottomRC - cArgs * sizeof(RTGCUINTPTR32));
  • trunk/src/VBox/VMM/VMMR3/VMMTests.cpp

    r41906 r41931  
    6161        return rc;
    6262
    63     CPUMHyperSetCtxCore(pVCpu, NULL);
    6463    memset(pVCpu->vmm.s.pbEMTStackR3, 0xaa, VMM_STACK_SIZE);
    6564    CPUMSetHyperESP(pVCpu, pVCpu->vmm.s.pbEMTStackBottomRC); /* Clear the stack. */
     
    101100        return rc;
    102101
    103     CPUMHyperSetCtxCore(pVCpu, NULL);
    104102    memset(pVCpu->vmm.s.pbEMTStackR3, 0xaa, VMM_STACK_SIZE);
    105103    CPUMSetHyperESP(pVCpu, pVCpu->vmm.s.pbEMTStackBottomRC); /* Clear the stack. */
     
    339337         * Interrupt forwarding.
    340338         */
    341         CPUMHyperSetCtxCore(pVCpu, NULL);
    342339        CPUMSetHyperESP(pVCpu, pVCpu->vmm.s.pbEMTStackBottomRC); /* Clear the stack. */
    343340        CPUMPushHyper(pVCpu, 0);
     
    403400        for (i = 0; i < 1000000; i++)
    404401        {
    405             CPUMHyperSetCtxCore(pVCpu, NULL);
    406402            CPUMSetHyperESP(pVCpu, pVCpu->vmm.s.pbEMTStackBottomRC); /* Clear the stack. */
    407403            CPUMPushHyper(pVCpu, 0);
     
    495491    AssertRCReturn(rc, rc);
    496492
    497     CPUMQueryHyperCtxPtr(pVCpu, &pHyperCtx);
     493    pHyperCtx = CPUMGetHyperCtxPtr(pVCpu);
    498494
    499495    pHyperCtx->cr0 = X86_CR0_PE | X86_CR0_WP | X86_CR0_PG | X86_CR0_TS | X86_CR0_ET | X86_CR0_NE | X86_CR0_MP;
     
    516512        RTPrintf("VMM: VMMGCEntry=%RRv\n", RCPtrEP);
    517513
    518         CPUMQueryHyperCtxPtr(pVCpu, &pHyperCtx);
     514        pHyperCtx = CPUMGetHyperCtxPtr(pVCpu);
    519515
    520516        /* Fill in hidden selector registers for the hypervisor state. */
     
    537533        for (i = 0; i < 1000000; i++)
    538534        {
    539             CPUMHyperSetCtxCore(pVCpu, NULL);
    540 
    541535            CPUMSetHyperESP(pVCpu, pVCpu->vmm.s.pbEMTStackBottomRC); /* Clear the stack. */
    542536            CPUMPushHyper(pVCpu, 0);
     
    547541            CPUMSetHyperEIP(pVCpu, pVM->vmm.s.pfnCallTrampolineRC);
    548542
    549             CPUMQueryHyperCtxPtr(pVCpu, &pHyperCtx);
     543            pHyperCtx = CPUMGetHyperCtxPtr(pVCpu);
    550544            pGuestCtx = CPUMQueryGuestCtxPtr(pVCpu);
    551545
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