VirtualBox

Changeset 71344 in vbox


Ignore:
Timestamp:
Mar 15, 2018 9:15:57 AM (7 years ago)
Author:
vboxsync
Message:

VMM/HM: Add nested-guest exit reason stat array for SVM R0 execution.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR0/HMSVMR0.cpp

    r71313 r71344  
    5858            STAM_COUNTER_INC(&pVCpu->hm.s.paStatExitReasonR0[(u64ExitCode) & MASK_EXITREASON_STAT]); \
    5959        } while (0)
     60
     61# ifdef VBOX_WITH_NESTED_HWVIRT
     62#  define HMSVM_NESTED_EXITCODE_STAM_COUNTER_INC(u64ExitCode) do { \
     63        STAM_COUNTER_INC(&pVCpu->hm.s.StatExitAll); \
     64        if ((u64ExitCode) == SVM_EXIT_NPF) \
     65            STAM_COUNTER_INC(&pVCpu->hm.s.StatNestedExitReasonNpf); \
     66        else \
     67            STAM_COUNTER_INC(&pVCpu->hm.s.paStatNestedExitReasonR0[(u64ExitCode) & MASK_EXITREASON_STAT]); \
     68        } while (0)
     69# endif
    6070#else
    61 # define HMSVM_EXITCODE_STAM_COUNTER_INC(u64ExitCode) do { } while (0)
    62 #endif
     71# define HMSVM_EXITCODE_STAM_COUNTER_INC(u64ExitCode)           do { } while (0)
     72# ifdef VBOX_WITH_NESTED_HWVIRT
     73#  define HMSVM_NESTED_EXITCODE_STAM_COUNTER_INC(u64ExitCode)   do { } while (0)
     74# endif
     75#endif /* !VBOX_WITH_STATISTICS */
     76
    6377
    6478/** If we decide to use a function table approach this can be useful to
     
    25382552     * Guest Virtual GIF (Global Interrupt Flag).
    25392553     */
    2540     if (   pVmcb->ctrl.IntCtrl.n.u1VGifEnable == 1
    2541         && !CPUMIsGuestInSvmNestedHwVirtMode(pMixedCtx))
     2554    if (pVmcb->ctrl.IntCtrl.n.u1VGifEnable == 1)
    25422555    {
    25432556        Assert(pVCpu->CTX_SUFF(pVM)->hm.s.svm.fVGif);
     2557        Assert(!CPUMIsGuestInSvmNestedHwVirtMode(pMixedCtx));
    25442558        pMixedCtx->hwvirt.fGif = pVmcb->ctrl.IntCtrl.n.u1VGif;
    25452559    }
     
    48794893
    48804894        /* Handle the #VMEXIT. */
    4881         HMSVM_EXITCODE_STAM_COUNTER_INC(SvmTransient.u64ExitCode);
     4895        HMSVM_NESTED_EXITCODE_STAM_COUNTER_INC(SvmTransient.u64ExitCode);
    48824896        STAM_PROFILE_ADV_STOP_START(&pVCpu->hm.s.StatExit1, &pVCpu->hm.s.StatExit2, x);
    48834897        VBOXVMM_R0_HMSVM_VMEXIT(pVCpu, pCtx, SvmTransient.u64ExitCode, pCtx->hwvirt.svm.CTX_SUFF(pVmcb));
  • trunk/src/VBox/VMM/VMMR3/HM.cpp

    r71108 r71344  
    10431043#undef HM_REG_COUNTER
    10441044
     1045        const char *const *papszDesc = ASMIsIntelCpu() || ASMIsViaCentaurCpu() ? &g_apszVTxExitReasons[0]
     1046                                                                               : &g_apszAmdVExitReasons[0];
     1047
     1048        /*
     1049         * Guest Exit reason stats.
     1050         */
    10451051        pVCpu->hm.s.paStatExitReason = NULL;
    1046 
    10471052        rc = MMHyperAlloc(pVM, MAX_EXITREASON_STAT * sizeof(*pVCpu->hm.s.paStatExitReason), 0 /* uAlignment */, MM_TAG_HM,
    10481053                          (void **)&pVCpu->hm.s.paStatExitReason);
    1049         AssertRC(rc);
    1050         if (RT_SUCCESS(rc))
    1051         {
    1052             const char *const *papszDesc = ASMIsIntelCpu() || ASMIsViaCentaurCpu() ?
    1053                                            &g_apszVTxExitReasons[0] : &g_apszAmdVExitReasons[0];
    1054             for (int j = 0; j < MAX_EXITREASON_STAT; j++)
     1054        AssertRCReturn(rc, rc);
     1055        for (int j = 0; j < MAX_EXITREASON_STAT; j++)
     1056        {
     1057            if (papszDesc[j])
    10551058            {
    1056                 if (papszDesc[j])
    1057                 {
    1058                     rc = STAMR3RegisterF(pVM, &pVCpu->hm.s.paStatExitReason[j], STAMTYPE_COUNTER, STAMVISIBILITY_USED,
    1059                                          STAMUNIT_OCCURENCES, papszDesc[j], "/HM/CPU%d/Exit/Reason/%02x", i, j);
    1060                     AssertRC(rc);
    1061                 }
     1059                rc = STAMR3RegisterF(pVM, &pVCpu->hm.s.paStatExitReason[j], STAMTYPE_COUNTER, STAMVISIBILITY_USED,
     1060                                     STAMUNIT_OCCURENCES, papszDesc[j], "/HM/CPU%d/Exit/Reason/%02x", i, j);
     1061                AssertRCReturn(rc, rc);
    10621062            }
    1063             rc = STAMR3RegisterF(pVM, &pVCpu->hm.s.StatExitReasonNpf, STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_OCCURENCES,
    1064                                  "Nested page fault", "/HM/CPU%d/Exit/Reason/#NPF", i);
    1065             AssertRC(rc);
    1066         }
     1063        }
     1064        rc = STAMR3RegisterF(pVM, &pVCpu->hm.s.StatExitReasonNpf, STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_OCCURENCES,
     1065                             "Nested page fault", "/HM/CPU%d/Exit/Reason/#NPF", i);
     1066        AssertRCReturn(rc, rc);
    10671067        pVCpu->hm.s.paStatExitReasonR0 = MMHyperR3ToR0(pVM, pVCpu->hm.s.paStatExitReason);
    10681068# ifdef VBOX_WITH_2X_4GB_ADDR_SPACE
     
    10721072# endif
    10731073
     1074#ifdef VBOX_WITH_NESTED_HWVIRT
     1075        /*
     1076         * Nested-guest Exit reason stats.
     1077         */
     1078        pVCpu->hm.s.paStatNestedExitReason = NULL;
     1079        rc = MMHyperAlloc(pVM, MAX_EXITREASON_STAT * sizeof(*pVCpu->hm.s.paStatNestedExitReason), 0 /* uAlignment */, MM_TAG_HM,
     1080                          (void **)&pVCpu->hm.s.paStatNestedExitReason);
     1081        AssertRCReturn(rc, rc);
     1082        for (int j = 0; j < MAX_EXITREASON_STAT; j++)
     1083        {
     1084            if (papszDesc[j])
     1085            {
     1086                rc = STAMR3RegisterF(pVM, &pVCpu->hm.s.paStatNestedExitReason[j], STAMTYPE_COUNTER, STAMVISIBILITY_USED,
     1087                                     STAMUNIT_OCCURENCES, papszDesc[j], "/HM/CPU%d/NestedExit/Reason/%02x", i, j);
     1088                AssertRC(rc);
     1089            }
     1090        }
     1091        rc = STAMR3RegisterF(pVM, &pVCpu->hm.s.StatNestedExitReasonNpf, STAMTYPE_COUNTER, STAMVISIBILITY_USED,
     1092                             STAMUNIT_OCCURENCES, "Nested page fault", "/HM/CPU%d/NestedExit/Reason/#NPF", i);
     1093        AssertRCReturn(rc, rc);
     1094        pVCpu->hm.s.paStatNestedExitReasonR0 = MMHyperR3ToR0(pVM, pVCpu->hm.s.paStatNestedExitReason);
     1095# ifdef VBOX_WITH_2X_4GB_ADDR_SPACE
     1096        Assert(pVCpu->hm.s.paStatNestedExitReasonR0 != NIL_RTR0PTR || !HMIsEnabled(pVM));
     1097# else
     1098        Assert(pVCpu->hm.s.paStatNestedExitReasonR0 != NIL_RTR0PTR);
     1099# endif
     1100#endif
     1101
     1102        /*
     1103         * Injected events stats.
     1104         */
    10741105        rc = MMHyperAlloc(pVM, sizeof(STAMCOUNTER) * 256, 8, MM_TAG_HM, (void **)&pVCpu->hm.s.paStatInjectedIrqs);
    10751106        AssertRCReturn(rc, rc);
  • trunk/src/VBox/VMM/include/HMInternal.h

    r71108 r71344  
    10951095    STAMCOUNTER             StatVmxCheckPmOk;
    10961096
     1097    STAMCOUNTER             StatNestedExitReasonNpf;
     1098
    10971099#if HC_ARCH_BITS == 32 && defined(VBOX_ENABLE_64_BITS_GUESTS)
    10981100    STAMCOUNTER             StatFpu64SwitchBack;
     
    11051107    R3PTRTYPE(PSTAMCOUNTER) paStatInjectedIrqs;
    11061108    R0PTRTYPE(PSTAMCOUNTER) paStatInjectedIrqsR0;
     1109    R3PTRTYPE(PSTAMCOUNTER) paStatNestedExitReason;
     1110    R0PTRTYPE(PSTAMCOUNTER) paStatNestedExitReasonR0;
    11071111#endif
    11081112#ifdef HM_PROFILE_EXIT_DISPATCH
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