VirtualBox

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


Ignore:
Timestamp:
Jun 15, 2018 1:30:01 PM (7 years ago)
Author:
vboxsync
Message:

EM,TRPM: Record TSC with exit history in raw-mode. Added the exit history counter to the statistic (/PROF/CPUx/EM/RecordedExits). bugref:9044

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/EMAll.cpp

    r72564 r72565  
    450450 * @param   uCs             The CS.
    451451 * @param   uEip            The EIP.
     452 * @param   uTimestamp      The TSC value for the exit, 0 if not available.
    452453 * @thread  EMT(0)
    453454 */
    454 VMMRC_INT_DECL(void) EMRCHistoryAddExitNoTs(PVMCPU pVCpu, uint32_t uFlagsAndType, uint16_t uCs, uint32_t uEip)
     455VMMRC_INT_DECL(void) EMRCHistoryAddExitCsEip(PVMCPU pVCpu, uint32_t uFlagsAndType, uint16_t uCs, uint32_t uEip, uint64_t uTimestamp)
    455456{
    456457    AssertCompile(RT_ELEMENTS(pVCpu->em.s.aExitHistory) == 256);
    457458    PEMEXITENTRY pHistEntry = &pVCpu->em.s.aExitHistory[(uintptr_t)(pVCpu->em.s.iNextExit++) & 0xff];
    458459    pHistEntry->uFlatPC       = ((uint64_t)uCs << 32) |  uEip;
    459     pHistEntry->uTimestamp    = 0;
     460    pHistEntry->uTimestamp    = uTimestamp;
    460461    pHistEntry->uFlagsAndType = uFlagsAndType | EMEXIT_F_CS_EIP;
    461462    pHistEntry->idxSlot       = UINT32_MAX;
  • trunk/src/VBox/VMM/VMMR3/EM.cpp

    r72490 r72565  
    449449
    450450        EM_REG_PROFILE_ADV(&pVCpu->em.s.StatTotal,          "/PROF/CPU%d/EM/Total",             "Profiling EMR3ExecuteVM.");
     451
     452        rc = STAMR3RegisterF(pVM, &pVCpu->em.s.iNextExit, STAMTYPE_U64, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES,
     453                             "Number of recorded exits (R0/RC).", "/PROF/CPU%u/EM/RecordedExits", i);
     454        AssertRC(rc);
     455
    451456    }
    452457
  • trunk/src/VBox/VMM/VMMRC/TRPMRCHandlers.cpp

    r72564 r72565  
    333333    LogFlow(("TRPMGC01: cs:eip=%04x:%08x uDr6=%RTreg EFL=%x\n", pRegFrame->cs.Sel, pRegFrame->eip, uDr6, CPUMRawGetEFlags(pVCpu)));
    334334    TRPM_ENTER_DBG_HOOK(1);
    335     EMRCHistoryAddExitNoTs(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_XCPT, X86_XCPT_DB), pRegFrame->cs.Sel, pRegFrame->eip);
     335    EMRCHistoryAddExitCsEip(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_XCPT, X86_XCPT_DB),
     336                            pRegFrame->cs.Sel, pRegFrame->eip, ASMReadTSC());
    336337
    337338    /*
     
    387388    PVMCPU      pVCpu = TRPMCPU_2_VMCPU(pTrpmCpu);
    388389    TRPM_ENTER_DBG_HOOK_HYPER(1);
    389     EMRCHistoryAddExitNoTs(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_XCPT, X86_XCPT_DB), pRegFrame->cs.Sel, pRegFrame->eip);
     390    EMRCHistoryAddExitCsEip(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_XCPT, X86_XCPT_DB),
     391                            pRegFrame->cs.Sel, pRegFrame->eip, ASMReadTSC());
    390392    LogFlow(("TRPMGCHyper01: cs:eip=%04x:%08x uDr6=%RTreg\n", pRegFrame->cs.Sel, pRegFrame->eip, uDr6));
    391393
     
    428430{
    429431    LogFlow(("TRPMGCTrap02Handler: cs:eip=%04x:%08x\n", pRegFrame->cs.Sel, pRegFrame->eip));
    430     EMRCHistoryAddExitNoTs(TRPMCPU_2_VMCPU(pTrpmCpu), EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_XCPT, X86_XCPT_NMI),
    431                            pRegFrame->cs.Sel, pRegFrame->eip);
     432    EMRCHistoryAddExitCsEip(TRPMCPU_2_VMCPU(pTrpmCpu), EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_XCPT, X86_XCPT_NMI),
     433                           pRegFrame->cs.Sel, pRegFrame->eip, ASMReadTSC());
    432434#if 0 /* Enable this iff you have a COM port and really want this debug info. */
    433435    RTLogComPrintf("TRPMGCTrap02Handler: cs:eip=%04x:%08x\n", pRegFrame->cs.Sel, pRegFrame->eip);
     
    456458{
    457459    LogFlow(("TRPMGCHyperTrap02Handler: cs:eip=%04x:%08x\n", pRegFrame->cs.Sel, pRegFrame->eip));
    458     EMRCHistoryAddExitNoTs(TRPMCPU_2_VMCPU(pTrpmCpu), EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_XCPT, X86_XCPT_NMI),
    459                            pRegFrame->cs.Sel, pRegFrame->eip);
     460    EMRCHistoryAddExitCsEip(TRPMCPU_2_VMCPU(pTrpmCpu), EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_XCPT, X86_XCPT_NMI),
     461                           pRegFrame->cs.Sel, pRegFrame->eip, ASMReadTSC());
    460462#if 0 /* Enable this iff you have a COM port and really want this debug info. */
    461463    RTLogComPrintf("TRPMGCHyperTrap02Handler: cs:eip=%04x:%08x\n", pRegFrame->cs.Sel, pRegFrame->eip);
     
    484486    LogFlow(("TRPMGC03: %04x:%08x EFL=%x\n", pRegFrame->cs.Sel, pRegFrame->eip, CPUMRawGetEFlags(pVCpu)));
    485487    TRPM_ENTER_DBG_HOOK(3);
    486     EMRCHistoryAddExitNoTs(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_XCPT, X86_XCPT_BP), pRegFrame->cs.Sel, pRegFrame->eip);
     488    EMRCHistoryAddExitCsEip(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_XCPT, X86_XCPT_BP),
     489                            pRegFrame->cs.Sel, pRegFrame->eip, ASMReadTSC());
    487490    PGMRZDynMapStartAutoSet(pVCpu);
    488491
     
    537540    LogFlow(("TRPMGCHyper03: %04x:%08x EFL=%x\n", pRegFrame->cs.Sel, pRegFrame->eip, CPUMRawGetEFlags(pVCpu)));
    538541    TRPM_ENTER_DBG_HOOK_HYPER(3);
    539     EMRCHistoryAddExitNoTs(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_XCPT, X86_XCPT_BP), pRegFrame->cs.Sel, pRegFrame->eip);
     542    EMRCHistoryAddExitCsEip(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_XCPT, X86_XCPT_BP),
     543                            pRegFrame->cs.Sel, pRegFrame->eip, ASMReadTSC());
    540544
    541545    /*
     
    569573    LogFlow(("TRPMGC06: %04x:%08x EFL=%#x/%#x\n", pRegFrame->cs.Sel, pRegFrame->eip, pRegFrame->eflags.u32, CPUMRawGetEFlags(pVCpu)));
    570574    TRPM_ENTER_DBG_HOOK(6);
    571     EMRCHistoryAddExitNoTs(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_XCPT, X86_XCPT_UD), pRegFrame->cs.Sel, pRegFrame->eip);
     575    EMRCHistoryAddExitCsEip(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_XCPT, X86_XCPT_UD),
     576                            pRegFrame->cs.Sel, pRegFrame->eip, ASMReadTSC());
    572577    PGMRZDynMapStartAutoSet(pVCpu);
    573578
     
    706711    LogFlow(("TRPMGC07: %04x:%08x EFL=%x\n", pRegFrame->cs.Sel, pRegFrame->eip, CPUMRawGetEFlags(pVCpu)));
    707712    TRPM_ENTER_DBG_HOOK(7);
    708     EMRCHistoryAddExitNoTs(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_XCPT, X86_XCPT_NM), pRegFrame->cs.Sel, pRegFrame->eip);
     713    EMRCHistoryAddExitCsEip(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_XCPT, X86_XCPT_NM),
     714                            pRegFrame->cs.Sel, pRegFrame->eip, ASMReadTSC());
    709715    PGMRZDynMapStartAutoSet(pVCpu);
    710716
     
    733739    LogFlow(("TRPMGC0b: %04x:%08x EFL=%x\n", pRegFrame->cs.Sel, pRegFrame->eip, CPUMRawGetEFlags(pVCpu)));
    734740    TRPM_ENTER_DBG_HOOK(0xb);
    735     EMRCHistoryAddExitNoTs(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_XCPT, X86_XCPT_NP), pRegFrame->cs.Sel, pRegFrame->eip);
     741    EMRCHistoryAddExitCsEip(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_XCPT, X86_XCPT_NP),
     742                            pRegFrame->cs.Sel, pRegFrame->eip, ASMReadTSC());
    736743    PGMRZDynMapStartAutoSet(pVCpu);
    737744
     
    12501257    LogFlow(("TRPMGC0d: %04x:%08x err=%x EFL=%x\n", pRegFrame->cs.Sel, pRegFrame->eip, (uint32_t)pVCpu->trpm.s.uActiveErrorCode, CPUMRawGetEFlags(pVCpu)));
    12511258    TRPM_ENTER_DBG_HOOK(0xd);
    1252     EMRCHistoryAddExitNoTs(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_XCPT, X86_XCPT_GP), pRegFrame->cs.Sel, pRegFrame->eip);
     1259    EMRCHistoryAddExitCsEip(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_XCPT, X86_XCPT_GP),
     1260                            pRegFrame->cs.Sel, pRegFrame->eip, ASMReadTSC());
    12531261
    12541262    PGMRZDynMapStartAutoSet(pVCpu);
     
    13161324    LogFlow(("TRPMGC0e: %04x:%08x err=%x cr2=%08x EFL=%x\n", pRegFrame->cs.Sel, pRegFrame->eip, (uint32_t)pVCpu->trpm.s.uActiveErrorCode, (uint32_t)pVCpu->trpm.s.uActiveCR2, CPUMRawGetEFlags(pVCpu)));
    13171325    TRPM_ENTER_DBG_HOOK(0xe);
    1318     EMRCHistoryAddExitNoTs(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_XCPT, X86_XCPT_PF), pRegFrame->cs.Sel, pRegFrame->eip);
     1326    EMRCHistoryAddExitCsEip(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_XCPT, X86_XCPT_PF),
     1327                            pRegFrame->cs.Sel, pRegFrame->eip, ASMReadTSC());
    13191328
    13201329    /*
     
    14321441DECLASM(int) TRPMGCHyperTrap0bHandler(PTRPMCPU pTrpmCpu, PCPUMCTXCORE pRegFrame)
    14331442{
    1434     EMRCHistoryAddExitNoTs(TRPMCPU_2_VMCPU(pTrpmCpu), EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_XCPT, X86_XCPT_NP),
    1435                            pRegFrame->cs.Sel, pRegFrame->eip);
     1443    EMRCHistoryAddExitCsEip(TRPMCPU_2_VMCPU(pTrpmCpu), EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_XCPT, X86_XCPT_NP),
     1444                            pRegFrame->cs.Sel, pRegFrame->eip, ASMReadTSC());
    14361445    return trpmGCHyperGeneric(TRPMCPU_2_VM(pTrpmCpu), pRegFrame, g_aTrap0bHandlers, g_aTrap0bHandlersEnd);
    14371446}
     
    14531462DECLASM(int) TRPMGCHyperTrap0dHandler(PTRPMCPU pTrpmCpu, PCPUMCTXCORE pRegFrame)
    14541463{
    1455     EMRCHistoryAddExitNoTs(TRPMCPU_2_VMCPU(pTrpmCpu), EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_XCPT, X86_XCPT_GP),
    1456                            pRegFrame->cs.Sel, pRegFrame->eip);
     1464    EMRCHistoryAddExitCsEip(TRPMCPU_2_VMCPU(pTrpmCpu), EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_XCPT, X86_XCPT_GP),
     1465                            pRegFrame->cs.Sel, pRegFrame->eip, ASMReadTSC());
    14571466    return trpmGCHyperGeneric(TRPMCPU_2_VM(pTrpmCpu), pRegFrame, g_aTrap0dHandlers, g_aTrap0dHandlersEnd);
    14581467}
     
    14741483DECLASM(int) TRPMGCHyperTrap0eHandler(PTRPMCPU pTrpmCpu, PCPUMCTXCORE pRegFrame)
    14751484{
    1476     EMRCHistoryAddExitNoTs(TRPMCPU_2_VMCPU(pTrpmCpu), EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_XCPT, X86_XCPT_PF),
    1477                            pRegFrame->cs.Sel, pRegFrame->eip);
     1485    EMRCHistoryAddExitCsEip(TRPMCPU_2_VMCPU(pTrpmCpu), EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_XCPT, X86_XCPT_PF),
     1486                            pRegFrame->cs.Sel, pRegFrame->eip, ASMReadTSC());
    14781487    return trpmGCHyperGeneric(TRPMCPU_2_VM(pTrpmCpu), pRegFrame, g_aTrap0dHandlers, g_aTrap0dHandlersEnd);
    14791488}
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