VirtualBox

Changeset 52125 in vbox


Ignore:
Timestamp:
Jul 22, 2014 10:11:37 AM (11 years ago)
Author:
vboxsync
Message:

VMM/HM: Add tracking of last 30 VM-exits. Can be useful for guru situations even on release builds.
Should not add much overhead to each exit.

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

Legend:

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

    r52099 r52125  
    672672        AssertMsgReturn(pVmcb, ("Invalid pVmcb for vcpu[%u]\n", i), VERR_SVM_INVALID_PVMCB);
    673673
     674       /* Initialize the #VMEXIT history array with end-of-array markers (UINT16_MAX). */
     675        Assert(!pVCpu->hm.s.idxExitHistoryFree);
     676        HMCPU_EXIT_HISTORY_RESET(pVCpu);
     677
    674678        /* Trap exceptions unconditionally (debug purposes). */
    675679#ifdef HMSVM_ALWAYS_TRAP_PF
     
    32153219
    32163220    pSvmTransient->u64ExitCode  = pVmcb->ctrl.u64ExitCode;      /* Save the #VMEXIT reason. */
     3221    HMCPU_EXIT_HISTORY_ADD(pVCpu, pVmcb->ctrl.u64ExitCode);     /* Update the #VMEXIT history array. */
    32173222    pSvmTransient->fVectoringPF = false;                        /* Vectoring page-fault needs to be determined later. */
     3223
    32183224    hmR0SvmSaveGuestState(pVCpu, pMixedCtx);                    /* Save the guest state from the VMCB to the guest-CPU context. */
    32193225
  • trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp

    r52073 r52125  
    2323#include <iprt/asm-amd64-x86.h>
    2424#include <iprt/thread.h>
    25 #include <iprt/string.h>
    2625
    2726#include "HMInternal.h"
     
    27782777        Log4(("VMXR0SetupVM: pVCpu=%p idCpu=%RU32\n", pVCpu, pVCpu->idCpu));
    27792778
     2779       /* Initialize the VM-exit history array with end-of-array markers (UINT16_MAX). */
     2780        Assert(!pVCpu->hm.s.idxExitHistoryFree);
     2781        HMCPU_EXIT_HISTORY_RESET(pVCpu);
     2782
    27802783        /* Set revision dword at the beginning of the VMCS structure. */
    27812784        *(uint32_t *)pVCpu->hm.s.vmx.pvVmcs = MSR_IA32_VMX_BASIC_INFO_VMCS_ID(pVM->hm.s.vmx.Msrs.u64BasicInfo);
     
    61336136    else
    61346137    {
    6135         if (   (uIntrState & VMX_VMCS_GUEST_INTERRUPTIBILITY_STATE_BLOCK_MOVSS)
    6136             || (uIntrState & VMX_VMCS_GUEST_INTERRUPTIBILITY_STATE_BLOCK_STI))
     6138        if (uIntrState & (  VMX_VMCS_GUEST_INTERRUPTIBILITY_STATE_BLOCK_MOVSS
     6139                          | VMX_VMCS_GUEST_INTERRUPTIBILITY_STATE_BLOCK_STI))
    61376140        {
    61386141            rc  = hmR0VmxSaveGuestRip(pVCpu, pMixedCtx);
     
    71187121        pVCpu->hm.s.fLeaveDone = true;
    71197122    }
     7123    Assert(HMVMXCPU_GST_VALUE(pVCpu) == HMVMX_UPDATED_GUEST_ALL);
    71207124
    71217125    /*
     
    87418745    pVmxTransient->uExitReason    = (uint16_t)VMX_EXIT_REASON_BASIC(uExitReason);
    87428746    pVmxTransient->fVMEntryFailed = VMX_ENTRY_INTERRUPTION_INFO_IS_VALID(pVmxTransient->uEntryIntInfo);
     8747
     8748    /* Update the VM-exit history array. */
     8749    HMCPU_EXIT_HISTORY_ADD(pVCpu, pVmxTransient->uExitReason);
    87438750
    87448751    /* If the VMLAUNCH/VMRESUME failed, we can bail out early. This does -not- cover VMX_EXIT_ERR_*. */
     
    99459952    /*
    99469953     * Clear block-by-STI if it's active. The force-flag couldn't have been set by block-by-Mov SS in
    9947      * hmR0VmxSaveGuestIntrState() when this VM-exit happens as Intel CPUs are consistent with
     9954     * hmR0VmxSaveGuestIntrState() when this VM-exit happened, as Intel CPUs are consistent with
    99489955     * block-by-Mov SS and NMIs. See @bugref{7445}.
    99499956     */
  • trunk/src/VBox/VMM/VMMR3/HM.cpp

    r52041 r52125  
    4848#include <iprt/asm.h>
    4949#include <iprt/asm-amd64-x86.h>
    50 #include <iprt/string.h>
    5150#include <iprt/env.h>
    5251#include <iprt/thread.h>
     
    7271    EXIT_REASON(VMX_EXIT_NMI_WINDOW         ,  8, "NMI window."),
    7372    EXIT_REASON(VMX_EXIT_TASK_SWITCH        ,  9, "Task switch."),
    74     EXIT_REASON(VMX_EXIT_CPUID              , 10, "Guest attempted to execute CPUID."),
     73    EXIT_REASON(VMX_EXIT_CPUID              , 10, "CPUID instruction."),
    7574    EXIT_REASON_NIL(),
    76     EXIT_REASON(VMX_EXIT_HLT                , 12, "Guest attempted to execute HLT."),
    77     EXIT_REASON(VMX_EXIT_INVD               , 13, "Guest attempted to execute INVD."),
    78     EXIT_REASON(VMX_EXIT_INVLPG             , 14, "Guest attempted to execute INVLPG."),
    79     EXIT_REASON(VMX_EXIT_RDPMC              , 15, "Guest attempted to execute RDPMC."),
    80     EXIT_REASON(VMX_EXIT_RDTSC              , 16, "Guest attempted to execute RDTSC."),
    81     EXIT_REASON(VMX_EXIT_RSM                , 17, "Guest attempted to execute RSM in SMM."),
    82     EXIT_REASON(VMX_EXIT_VMCALL             , 18, "Guest attempted to execute VMCALL."),
    83     EXIT_REASON(VMX_EXIT_VMCLEAR            , 19, "Guest attempted to execute VMCLEAR."),
    84     EXIT_REASON(VMX_EXIT_VMLAUNCH           , 20, "Guest attempted to execute VMLAUNCH."),
    85     EXIT_REASON(VMX_EXIT_VMPTRLD            , 21, "Guest attempted to execute VMPTRLD."),
    86     EXIT_REASON(VMX_EXIT_VMPTRST            , 22, "Guest attempted to execute VMPTRST."),
    87     EXIT_REASON(VMX_EXIT_VMREAD             , 23, "Guest attempted to execute VMREAD."),
    88     EXIT_REASON(VMX_EXIT_VMRESUME           , 24, "Guest attempted to execute VMRESUME."),
    89     EXIT_REASON(VMX_EXIT_VMWRITE            , 25, "Guest attempted to execute VMWRITE."),
    90     EXIT_REASON(VMX_EXIT_VMXOFF             , 26, "Guest attempted to execute VMXOFF."),
    91     EXIT_REASON(VMX_EXIT_VMXON              , 27, "Guest attempted to execute VMXON."),
     75    EXIT_REASON(VMX_EXIT_HLT                , 12, "HLT instruction."),
     76    EXIT_REASON(VMX_EXIT_INVD               , 13, "INVD instruction."),
     77    EXIT_REASON(VMX_EXIT_INVLPG             , 14, "INVLPG instruction."),
     78    EXIT_REASON(VMX_EXIT_RDPMC              , 15, "RDPMCinstruction."),
     79    EXIT_REASON(VMX_EXIT_RDTSC              , 16, "RDTSC instruction."),
     80    EXIT_REASON(VMX_EXIT_RSM                , 17, "RSM instruction in SMM."),
     81    EXIT_REASON(VMX_EXIT_VMCALL             , 18, "VMCALL instruction."),
     82    EXIT_REASON(VMX_EXIT_VMCLEAR            , 19, "VMCLEAR instruction."),
     83    EXIT_REASON(VMX_EXIT_VMLAUNCH           , 20, "VMLAUNCH instruction."),
     84    EXIT_REASON(VMX_EXIT_VMPTRLD            , 21, "VMPTRLD instruction."),
     85    EXIT_REASON(VMX_EXIT_VMPTRST            , 22, "VMPTRST instruction."),
     86    EXIT_REASON(VMX_EXIT_VMREAD             , 23, "VMREAD instruction."),
     87    EXIT_REASON(VMX_EXIT_VMRESUME           , 24, "VMRESUME instruction."),
     88    EXIT_REASON(VMX_EXIT_VMWRITE            , 25, "VMWRITE instruction."),
     89    EXIT_REASON(VMX_EXIT_VMXOFF             , 26, "VMXOFF instruction."),
     90    EXIT_REASON(VMX_EXIT_VMXON              , 27, "VMXON instruction."),
    9291    EXIT_REASON(VMX_EXIT_MOV_CRX            , 28, "Control-register accesses."),
    9392    EXIT_REASON(VMX_EXIT_MOV_DRX            , 29, "Debug-register accesses."),
     
    9897    EXIT_REASON(VMX_EXIT_ERR_MSR_LOAD       , 34, "VM-entry failure due to MSR loading."),
    9998    EXIT_REASON_NIL(),
    100     EXIT_REASON(VMX_EXIT_MWAIT              , 36, "Guest executed MWAIT."),
     99    EXIT_REASON(VMX_EXIT_MWAIT              , 36, "MWAIT instruction."),
    101100    EXIT_REASON(VMX_EXIT_MTF                , 37, "Monitor Trap Flag."),
    102101    EXIT_REASON_NIL(),
    103     EXIT_REASON(VMX_EXIT_MONITOR            , 39, "Guest attempted to execute MONITOR."),
    104     EXIT_REASON(VMX_EXIT_PAUSE              , 40, "Guest attempted to execute PAUSE."),
     102    EXIT_REASON(VMX_EXIT_MONITOR            , 39, "MONITOR instruction."),
     103    EXIT_REASON(VMX_EXIT_PAUSE              , 40, "PAUSE instruction."),
    105104    EXIT_REASON(VMX_EXIT_ERR_MACHINE_CHECK  , 41, "VM-entry failure due to machine-check."),
    106105    EXIT_REASON_NIL(),
    107106    EXIT_REASON(VMX_EXIT_TPR_BELOW_THRESHOLD, 43, "TPR below threshold. Guest attempted to execute MOV to CR8."),
    108     EXIT_REASON(VMX_EXIT_APIC_ACCESS        , 44, "APIC access. Guest attempted to access memory at a physical address on the APIC-access page."),
     107    EXIT_REASON(VMX_EXIT_APIC_ACCESS        , 44, "APIC access."),
    109108    EXIT_REASON_NIL(),
    110     EXIT_REASON(VMX_EXIT_XDTR_ACCESS        , 46, "Access to GDTR or IDTR. Guest attempted to execute LGDT, LIDT, SGDT, or SIDT."),
    111     EXIT_REASON(VMX_EXIT_TR_ACCESS          , 47, "Access to LDTR or TR. Guest attempted to execute LLDT, LTR, SLDT, or STR."),
    112     EXIT_REASON(VMX_EXIT_EPT_VIOLATION      , 48, "EPT violation. An attempt to access memory with a guest-physical address was disallowed by the configuration of the EPT paging structures."),
    113     EXIT_REASON(VMX_EXIT_EPT_MISCONFIG      , 49, "EPT misconfiguration. An attempt to access memory with a guest-physical address encountered a misconfigured EPT paging-structure entry."),
    114     EXIT_REASON(VMX_EXIT_INVEPT             , 50, "Guest attempted to execute INVEPT."),
    115     EXIT_REASON(VMX_EXIT_RDTSCP             , 51, "Guest attempted to execute RDTSCP."),
     109    EXIT_REASON(VMX_EXIT_XDTR_ACCESS        , 46, "Access to GDTR or IDTR using LGDT, LIDT, SGDT, or SIDT."),
     110    EXIT_REASON(VMX_EXIT_TR_ACCESS          , 47, "Access to LDTR or TR using LLDT, LTR, SLDT, or STR."),
     111    EXIT_REASON(VMX_EXIT_EPT_VIOLATION      , 48, "EPT violation."),
     112    EXIT_REASON(VMX_EXIT_EPT_MISCONFIG      , 49, "EPT misconfiguration."),
     113    EXIT_REASON(VMX_EXIT_INVEPT             , 50, "INVEPT instruction."),
     114    EXIT_REASON(VMX_EXIT_RDTSCP             , 51, "RDTSCP instruction."),
    116115    EXIT_REASON(VMX_EXIT_PREEMPT_TIMER      , 52, "VMX-preemption timer expired."),
    117     EXIT_REASON(VMX_EXIT_INVVPID            , 53, "Guest attempted to execute INVVPID."),
    118     EXIT_REASON(VMX_EXIT_WBINVD             , 54, "Guest attempted to execute WBINVD."),
    119     EXIT_REASON(VMX_EXIT_XSETBV             , 55, "Guest attempted to execute XSETBV."),
     116    EXIT_REASON(VMX_EXIT_INVVPID            , 53, "INVVPID instruction."),
     117    EXIT_REASON(VMX_EXIT_WBINVD             , 54, "WBINVD instruction."),
     118    EXIT_REASON(VMX_EXIT_XSETBV             , 55, "XSETBV instruction."),
    120119    EXIT_REASON_NIL(),
    121     EXIT_REASON(VMX_EXIT_RDRAND             , 57, "Guest attempted to execute RDRAND."),
    122     EXIT_REASON(VMX_EXIT_INVPCID            , 58, "Guest attempted to execute INVPCID."),
    123     EXIT_REASON(VMX_EXIT_VMFUNC             , 59, "Guest attempted to execute VMFUNC.")
     120    EXIT_REASON(VMX_EXIT_RDRAND             , 57, "RDRAND instruction."),
     121    EXIT_REASON(VMX_EXIT_INVPCID            , 58, "INVPCID instruction."),
     122    EXIT_REASON(VMX_EXIT_VMFUNC             , 59, "VMFUNC instruction.")
    124123};
    125124/** Exit reason descriptions for AMD-V, used to describe statistics. */
     
    29502949            {
    29512950                LogRel(("HM: CPU[%u] HM error         %#x (%u)\n", i, pVCpu->hm.s.u32HMError, pVCpu->hm.s.u32HMError));
     2951                LogRel(("HM: CPU[%u] idxExitHistoryFree    %u\n", i, pVCpu->hm.s.idxExitHistoryFree));
     2952                unsigned const idxLast = pVCpu->hm.s.idxExitHistoryFree > 0 ?
     2953                                                                            pVCpu->hm.s.idxExitHistoryFree - 1 :
     2954                                                                            RT_ELEMENTS(pVCpu->hm.s.auExitHistory) - 1;
     2955                for (unsigned k = 0; k < RT_ELEMENTS(pVCpu->hm.s.auExitHistory); k++)
     2956                {
     2957                    LogRel(("HM: CPU[%u] auExitHistory[%2u]   = %#x (%u) %s\n", i, k, pVCpu->hm.s.auExitHistory[k],
     2958                            pVCpu->hm.s.auExitHistory[k], idxLast == k ? "<-- Last" : ""));
     2959                }
    29522960                break;
    29532961            }
  • trunk/src/VBox/VMM/include/HMInternal.h

    r52006 r52125  
    3232#include <iprt/mp.h>
    3333#include <iprt/avl.h>
     34#include <iprt/string.h>
    3435
    3536#if HC_ARCH_BITS == 64 || defined(VBOX_WITH_HYBRID_32BIT_KERNEL) || defined (VBOX_WITH_64_BITS_GUESTS)
     
    121122#define HMCPU_CF_VALUE(pVCpu)                     (ASMAtomicUoReadU32(&(pVCpu)->hm.s.fContextUseFlags))
    122123
     124
     125/** Resets/initializes the VM-exit/#VMEXIT history array. */
     126#define HMCPU_EXIT_HISTORY_RESET(pVCpu)           (memset(&(pVCpu)->hm.s.auExitHistory, sizeof((pVCpu)->hm.s.auExitHistory), 0))
     127
     128/** Updates the VM-exit/#VMEXIT history array. */
     129#define HMCPU_EXIT_HISTORY_ADD(pVCpu, a_ExitReason) \
     130    do { \
     131        AssertMsg((pVCpu)->hm.s.idxExitHistoryFree < RT_ELEMENTS((pVCpu)->hm.s.auExitHistory), ("%u\n", (pVCpu)->hm.s.idxExitHistoryFree)); \
     132        (pVCpu)->hm.s.auExitHistory[(pVCpu)->hm.s.idxExitHistoryFree++] = (uint16_t)(a_ExitReason); \
     133        if ((pVCpu)->hm.s.idxExitHistoryFree == RT_ELEMENTS((pVCpu)->hm.s.auExitHistory)) \
     134            (pVCpu)->hm.s.idxExitHistoryFree = 0; \
     135        (pVCpu)->hm.s.auExitHistory[(pVCpu)->hm.s.idxExitHistoryFree] = UINT16_MAX; \
     136    } while (0)
    123137
    124138/** Maximum number of exit reason statistics counters. */
     
    807821        uint32_t            u32Alignment0; /**< Explicit alignment padding. */
    808822    } TlbShootdown;
     823
     824    /** VT-x/AMD-V VM-exit/#VMXEXIT history, circular array. */
     825    uint16_t                auExitHistory[31];
     826    /** The index of the next free slot in the history array. */
     827    uint16_t                idxExitHistoryFree;
    809828
    810829    /** For saving stack space, the disassembler state is allocated here instead of
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