VirtualBox

Changeset 1210 in vbox


Ignore:
Timestamp:
Mar 5, 2007 12:36:53 PM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
19136
Message:

Added PGMR3ChangeShwPDMappings.
Added VMX/SVM test case.

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

Legend:

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

    r914 r1210  
    251251
    252252    /* Disable mapping of the hypervisor into the shadow page table. */
    253     PGMR3RemoveMappingsFromShwPD(pVM);
     253    PGMR3ChangeShwPDMappings(pVM, false);
     254
     255    /* Disable the switcher */
     256    VMMR3DisableSwitcher(pVM);
    254257}
    255258
  • trunk/src/VBox/VMM/PGM.cpp

    r873 r1210  
    33843384
    33853385/**
    3386  * Inform PGM we don't wish any mapping to be put into the shadow page table. (necessary for e.g. VMX)
     3386 * Inform PGM if we want all mappings to be put into the shadow page table. (necessary for e.g. VMX)
    33873387 *
    33883388 * @returns VBox status code.
    33893389 * @param   pVM         VM handle.
    3390  */
    3391 PGMR3DECL(int) PGMR3RemoveMappingsFromShwPD(PVM pVM)
    3392 {
    3393 
    3394     pVM->pgm.s.fDisableMappings = true;
     3390 * @param   fEnable     Enable or disable shadow mappings
     3391 */
     3392PGMR3DECL(int) PGMR3ChangeShwPDMappings(PVM pVM, bool fEnable)
     3393{
     3394    pVM->pgm.s.fDisableMappings = fEnable;
    33953395
    33963396    size_t cb;
     
    34023402    AssertRCReturn(rc, rc);
    34033403
    3404     VMMR3DisableSwitcher(pVM);
    34053404    return VINF_SUCCESS;
    34063405}
  • trunk/src/VBox/VMM/VMM.cpp

    r1027 r1210  
    149149#include <VBox/version.h>
    150150#include <VBox/x86.h>
     151#include <VBox/hwaccm.h>
    151152#include <iprt/assert.h>
    152153#include <iprt/alloc.h>
     
    29132914}
    29142915
     2916/* execute the switch. */
     2917VMMR3DECL(int) VMMDoHwAccmTest(PVM pVM)
     2918{
     2919    uint32_t i;
     2920
     2921    if (!HWACCMR3IsAllowed(pVM))
     2922    {
     2923        RTPrintf("VMM: Hardware accelerated test now available!\n");
     2924        return VERR_ACCESS_DENIED;
     2925    }
     2926
     2927    /*
     2928     * These forced actions are not necessary for the test and trigger breakpoints too.
     2929     */
     2930    VM_FF_CLEAR(pVM, VM_FF_TRPM_SYNC_IDT);
     2931    VM_FF_CLEAR(pVM, VM_FF_SELM_SYNC_TSS);
     2932
     2933    /* Enable mapping of the hypervisor into the shadow page table. */
     2934    PGMR3ChangeShwPDMappings(pVM, true);
     2935
     2936    /*
     2937     * Setup stack for calling VMMGCEntry().
     2938     */
     2939    RTGCPTR GCPtrEP;
     2940    int rc = PDMR3GetSymbolGC(pVM, VMMGC_MAIN_MODULE_NAME, "VMMGCEntry", &GCPtrEP);
     2941    if (VBOX_SUCCESS(rc))
     2942    {
     2943        RTPrintf("VMM: VMMGCEntry=%VGv\n", GCPtrEP);
     2944        /*
     2945         * Profile switching.
     2946         */
     2947        RTPrintf("VMM: profiling switcher...\n");
     2948        Log(("VMM: profiling switcher...\n"));
     2949        uint64_t TickMin = ~0;
     2950        uint64_t tsBegin = RTTimeNanoTS();
     2951        uint64_t TickStart = ASMReadTSC();
     2952        for (i = 0; i < 1000000; i++)
     2953        {
     2954            CPUMHyperSetCtxCore(pVM, NULL);
     2955            CPUMSetHyperESP(pVM, pVM->vmm.s.pbGCStackBottom); /* Clear the stack. */
     2956            CPUMPushHyper(pVM, 0);
     2957            CPUMPushHyper(pVM, VMMGC_DO_TESTCASE_HWACCM_NOP);
     2958            CPUMPushHyper(pVM, pVM->pVMGC);
     2959            CPUMPushHyper(pVM, 3 * sizeof(RTGCPTR));    /* stack frame size */
     2960            CPUMPushHyper(pVM, GCPtrEP);                /* what to call */
     2961            CPUMSetHyperEIP(pVM, pVM->vmm.s.pfnGCCallTrampoline);
     2962
     2963            PCPUMCTX pHyperCtx, pGuestCtx;
     2964           
     2965            CPUMQueryHyperCtxPtr(pVM, &pHyperCtx);
     2966            CPUMQueryGuestCtxPtr(pVM, &pGuestCtx);
     2967
     2968            /* Copy the hypervisor context to make sure we have a valid guest context. */
     2969            *pGuestCtx = *pHyperCtx;
     2970
     2971            uint64_t TickThisStart = ASMReadTSC();
     2972            rc = SUPCallVMMR0(pVM->pVMR0, VMMR0_DO_HWACC_RUN, NULL);
     2973            uint64_t TickThisElapsed = ASMReadTSC() - TickThisStart;
     2974            if (VBOX_FAILURE(rc))
     2975            {
     2976                Log(("VMM: GC returned fatal %Vra in iteration %d\n", rc, i));
     2977                VMMR3FatalDump(pVM, rc);
     2978                return rc;
     2979            }
     2980            if (TickThisElapsed < TickMin)
     2981                TickMin = TickThisElapsed;
     2982        }
     2983        uint64_t TickEnd = ASMReadTSC();
     2984        uint64_t tsEnd = RTTimeNanoTS();
     2985
     2986        uint64_t Elapsed = tsEnd - tsBegin;
     2987        uint64_t PerIteration = Elapsed / (uint64_t)i;
     2988        uint64_t cTicksElapsed = TickEnd - TickStart;
     2989        uint64_t cTicksPerIteration = cTicksElapsed / (uint64_t)i;
     2990
     2991        RTPrintf("VMM: %8d cycles     in %11llu ns (%11lld ticks),  %10llu ns/iteration (%11lld ticks)  Min %11lld ticks\n",
     2992                 i, Elapsed, cTicksElapsed, PerIteration, cTicksPerIteration, TickMin);
     2993        Log(("VMM: %8d cycles     in %11llu ns (%11lld ticks),  %10llu ns/iteration (%11lld ticks)  Min %11lld ticks\n",
     2994             i, Elapsed, cTicksElapsed, PerIteration, cTicksPerIteration, TickMin));
     2995
     2996        rc = VINF_SUCCESS;
     2997    }
     2998    else
     2999        AssertMsgFailed(("Failed to resolved VMMGC.gc::VMMGCEntry(), rc=%Vrc\n", rc));
     3000
     3001    return rc;
     3002}
  • trunk/src/VBox/VMM/VMMGC/VMMGC.cpp

    r1027 r1210  
    9898
    9999        /*
     100         * Testcase executes a privileged instruction to force a world switch. (in both SVM & VMX)
     101         */
     102        case VMMGC_DO_TESTCASE_HWACCM_NOP:
     103            ASMRdMsr_Low(MSR_IA32_SYSENTER_CS);
     104            return 0;
     105
     106        /*
    100107         * Delay for ~100us.
    101108         */
  • trunk/src/VBox/VMM/VMMInternal.h

    r988 r1210  
    360360    /** Testcase for checking interrupt masking.. */
    361361    VMMGC_DO_TESTCASE_INTERRUPT_MASKING,
     362    /** Switching testing and profiling stub. */
     363    VMMGC_DO_TESTCASE_HWACCM_NOP,
    362364
    363365    /** The usual 32-bit hack. */
  • trunk/src/VBox/VMM/testcase/Makefile

    r167 r1210  
    3131PROGRAMS        += tstAsmStructs tstAsmStructsGC
    3232endif
    33 PROGRAMS        += tstVMM
     33PROGRAMS        += tstVMM tstVMM-HwAccm
    3434ifdef VBOX_WITH_TESTCASES
    3535PROGRAMS        += tstCFGM tstSSM tstMMHyperHeap tstVMM-2 tstVMREQ tstMicro tstCompiler tstVMMR0CallHost-1
     
    120120tstVMM_TEMPLATE         = VBOXR3EXE
    121121tstVMM_LIBS             = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
     122
     123tstVMM-HwAccm_SOURCES   = tstVMM-HwAccm.cpp
     124tstVMM-HwAccm_TEMPLATE  = VBOXR3EXE
     125tstVMM-HwAccm_LIBS      = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
    122126
    123127tstVMM-2_SOURCES        = tstVMM-2.cpp
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