VirtualBox

Changeset 20142 in vbox


Ignore:
Timestamp:
May 29, 2009 10:14:02 AM (16 years ago)
Author:
vboxsync
Message:

VT-x/AMD-V: Keep statistics for injected traps & interrupts.

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

Legend:

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

    r20132 r20142  
    542542        Assert(pVCpu->hwaccm.s.paStatExitReasonR0 != NIL_RTR0PTR);
    543543# endif
     544
     545    rc = MMHyperAlloc(pVM, sizeof(STAMCOUNTER) * 255, 8, MM_TAG_HWACCM, (void **)&pVCpu->hwaccm.s.paStatInjectedIrqs);
     546    AssertRCReturn(rc, rc);
     547    pVCpu->hwaccm.s.paStatInjectedIrqsR0 = MMHyperR3ToR0(pVM, pVCpu->hwaccm.s.paStatInjectedIrqs);
     548    for (unsigned j = 0; j < 255; j++)
     549        STAMR3RegisterF(pVM, &pVCpu->hwaccm.s.paStatInjectedIrqs[i], STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_OCCURENCES, "Forwarded interrupts.",
     550                        j < 0x20 ? "/HWACCM/CPU%d/Interrupt/Trap/%02X" : "/TRPM/CPU%d/Interrupt/IRQ/%02X", i, j);
     551
    544552    }
    545553#endif /* VBOX_WITH_STATISTICS */
     
    12961304        PVMCPU pVCpu = &pVM->aCpus[i];
    12971305
     1306#ifdef VBOX_WITH_STATISTICS
    12981307        if (pVCpu->hwaccm.s.paStatExitReason)
    12991308        {
     
    13021311            pVCpu->hwaccm.s.paStatExitReasonR0 = NIL_RTR0PTR;
    13031312        }
     1313        if (pVCpu->hwaccm.s.paStatInjectedIrqs)
     1314        {
     1315            MMHyperFree(pVM, pVCpu->hwaccm.s.paStatInjectedIrqs);
     1316            pVCpu->hwaccm.s.paStatInjectedIrqs   = NULL;
     1317            pVCpu->hwaccm.s.paStatInjectedIrqsR0 = NIL_RTR0PTR;
     1318        }
     1319#endif
     1320
    13041321#ifdef VBOX_WITH_CRASHDUMP_MAGIC
    13051322        memset(pVCpu->hwaccm.s.vmx.VMCSCache.aMagic, 0, sizeof(pVCpu->hwaccm.s.vmx.VMCSCache.aMagic));
  • trunk/src/VBox/VMM/HWACCMInternal.h

    r20133 r20142  
    5858#define MAX_EXITREASON_STAT        0x100
    5959#define MASK_EXITREASON_STAT       0xff
     60#define MASK_INJECT_IRQ_STAT       0xff
    6061
    6162/** @name Changed flags
     
    673674
    674675
     676#ifdef VBOX_WITH_STATISTICS
    675677    R3PTRTYPE(PSTAMCOUNTER) paStatExitReason;
    676678    R0PTRTYPE(PSTAMCOUNTER) paStatExitReasonR0;
     679    R3PTRTYPE(PSTAMCOUNTER) paStatInjectedIrqs;
     680    R0PTRTYPE(PSTAMCOUNTER) paStatInjectedIrqsR0;
     681#endif
    677682} HWACCMCPU;
    678683/** Pointer to HWACCM VM instance data. */
  • trunk/src/VBox/VMM/VMMR0/HWSVMR0.cpp

    r20132 r20142  
    362362 * Injects an event (trap or external interrupt)
    363363 *
    364  * @param   pVM         The VM to operate on.
     364 * @param   pVCpu       The VMCPU to operate on.
    365365 * @param   pVMCB       SVM control block
    366366 * @param   pCtx        CPU Context
    367367 * @param   pIntInfo    SVM interrupt info
    368368 */
    369 inline void SVMR0InjectEvent(PVM pVM, SVM_VMCB *pVMCB, CPUMCTX *pCtx, SVM_EVENT* pEvent)
     369inline void SVMR0InjectEvent(PVMCPU pVCpu, SVM_VMCB *pVMCB, CPUMCTX *pCtx, SVM_EVENT* pEvent)
    370370{
     371#ifdef VBOX_WITH_STATISTICS
     372    STAM_COUNTER_INC(&pVCpu->hwaccm.s.paStatInjectedIrqsR0[pEvent->n.u8Vector & MASK_INJECT_IRQ_STAT]);
     373#endif
     374
    371375#ifdef VBOX_STRICT
    372376    if (pEvent->n.u8Vector == 0xE)
     
    378382    {
    379383        Log(("INJ-EI: %x at %RGv\n", pEvent->n.u8Vector, (RTGCPTR)pCtx->rip));
    380         Assert(!VMCPU_FF_ISSET(VMMGetCpu(pVM), VMCPU_FF_INHIBIT_INTERRUPTS));
     384        Assert(!VMCPU_FF_ISSET(pVCpu, VMCPU_FF_INHIBIT_INTERRUPTS));
    381385        Assert(pCtx->eflags.u32 & X86_EFL_IF);
    382386    }
     
    409413        STAM_COUNTER_INC(&pVCpu->hwaccm.s.StatIntReinject);
    410414        Event.au64[0] = pVCpu->hwaccm.s.Event.intInfo;
    411         SVMR0InjectEvent(pVM, pVMCB, pCtx, &Event);
     415        SVMR0InjectEvent(pVCpu, pVMCB, pCtx, &Event);
    412416
    413417        pVCpu->hwaccm.s.Event.fPending = false;
     
    424428        Event.n.u3Type       = SVM_EVENT_NMI;
    425429
    426         SVMR0InjectEvent(pVM, pVMCB, pCtx, &Event);
     430        SVMR0InjectEvent(pVCpu, pVMCB, pCtx, &Event);
    427431        pVM->hwaccm.s.fInjectNMI = false;
    428432        return VINF_SUCCESS;
     
    531535
    532536        STAM_COUNTER_INC(&pVCpu->hwaccm.s.StatIntInject);
    533         SVMR0InjectEvent(pVM, pVMCB, pCtx, &Event);
     537        SVMR0InjectEvent(pVCpu, pVMCB, pCtx, &Event);
    534538    } /* if (interrupts can be dispatched) */
    535539
     
    13921396                Event.n.u8Vector = X86_XCPT_DB;
    13931397
    1394                 SVMR0InjectEvent(pVM, pVMCB, pCtx, &Event);
     1398                SVMR0InjectEvent(pVCpu, pVMCB, pCtx, &Event);
    13951399
    13961400                STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatExit1, x);
     
    14281432            Event.n.u8Vector = X86_XCPT_NM;
    14291433
    1430             SVMR0InjectEvent(pVM, pVMCB, pCtx, &Event);
     1434            SVMR0InjectEvent(pVCpu, pVMCB, pCtx, &Event);
    14311435            STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatExit1, x);
    14321436            goto ResumeExecution;
     
    14561460                Event.n.u32ErrorCode        = errCode;
    14571461
    1458                 SVMR0InjectEvent(pVM, pVMCB, pCtx, &Event);
     1462                SVMR0InjectEvent(pVCpu, pVMCB, pCtx, &Event);
    14591463
    14601464                STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatExit1, x);
     
    15761580                Event.n.u32ErrorCode        = errCode;
    15771581
    1578                 SVMR0InjectEvent(pVM, pVMCB, pCtx, &Event);
     1582                SVMR0InjectEvent(pVCpu, pVMCB, pCtx, &Event);
    15791583
    15801584                STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatExit1, x);
     
    16071611            Event.n.u8Vector = X86_XCPT_MF;
    16081612
    1609             SVMR0InjectEvent(pVM, pVMCB, pCtx, &Event);
     1613            SVMR0InjectEvent(pVCpu, pVMCB, pCtx, &Event);
    16101614
    16111615            STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatExit1, x);
     
    16511655            }
    16521656            Log(("Trap %x at %04x:%RGv esi=%x\n", vector, pCtx->cs, (RTGCPTR)pCtx->rip, pCtx->esi));
    1653             SVMR0InjectEvent(pVM, pVMCB, pCtx, &Event);
     1657            SVMR0InjectEvent(pVCpu, pVMCB, pCtx, &Event);
    16541658
    16551659            STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatExit1, x);
     
    21102114                            Event.n.u8Vector = X86_XCPT_DB;
    21112115
    2112                             SVMR0InjectEvent(pVM, pVMCB, pCtx, &Event);
     2116                            SVMR0InjectEvent(pVCpu, pVMCB, pCtx, &Event);
    21132117
    21142118                            STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatExit1, x);
     
    21882192
    21892193        Log(("Forced #UD trap at %RGv\n", (RTGCPTR)pCtx->rip));
    2190         SVMR0InjectEvent(pVM, pVMCB, pCtx, &Event);
     2194        SVMR0InjectEvent(pVCpu, pVMCB, pCtx, &Event);
    21912195
    21922196        STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatExit1, x);
  • trunk/src/VBox/VMM/VMMR0/HWVMXR0.cpp

    r20132 r20142  
    627627    int         rc;
    628628    uint32_t    iGate = VMX_EXIT_INTERRUPTION_INFO_VECTOR(intInfo);
     629
     630#ifdef VBOX_WITH_STATISTICS
     631    STAM_COUNTER_INC(&pVCpu->hwaccm.s.paStatInjectedIrqsR0[iGate & MASK_INJECT_IRQ_STAT]);
     632#endif
    629633
    630634#ifdef VBOX_STRICT
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