VirtualBox

Ignore:
Timestamp:
Aug 3, 2021 5:41:36 AM (3 years ago)
Author:
vboxsync
Message:

VMM/CPUM: Simplify dumping of nested hardware-virtualization state and also dump CPUMIsGuestInNestedHwvirtMode.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR3/CPUM.cpp

    r87773 r90487  
    40424042        pVCpu = pVM->apCpusR3[0];
    40434043
    4044     /*
    4045      * Figure out what to dump.
    4046      */
    4047     /** @todo perhaps make this configurable through pszArgs, depending on how much
    4048      *        noise we wish to accept when nested hwvirt. isn't used. */
    4049 #define CPUMHWVIRTDUMP_NONE     (0)
    4050 #define CPUMHWVIRTDUMP_SVM      RT_BIT(0)
    4051 #define CPUMHWVIRTDUMP_VMX      RT_BIT(1)
    4052 #define CPUMHWVIRTDUMP_COMMON   RT_BIT(2)
    4053 #define CPUMHWVIRTDUMP_LAST     CPUMHWVIRTDUMP_VMX
    4054 
    4055     PCPUMCTX pCtx = &pVCpu->cpum.s.Guest;
    4056     static const char *const s_aHwvirtModes[] = { "No/inactive", "SVM", "VMX", "Common" };
     4044    PCCPUMCTX pCtx = &pVCpu->cpum.s.Guest;
    40574045    bool const fSvm = pVM->cpum.s.GuestFeatures.fSvm;
    40584046    bool const fVmx = pVM->cpum.s.GuestFeatures.fVmx;
    4059     uint8_t const idxHwvirtState = fSvm ? CPUMHWVIRTDUMP_SVM : (fVmx ? CPUMHWVIRTDUMP_VMX : CPUMHWVIRTDUMP_NONE);
    4060     AssertCompile(CPUMHWVIRTDUMP_LAST <= RT_ELEMENTS(s_aHwvirtModes));
    4061     Assert(idxHwvirtState < RT_ELEMENTS(s_aHwvirtModes));
    4062     const char *pcszHwvirtMode   = s_aHwvirtModes[idxHwvirtState];
    4063     uint32_t fDumpState          = idxHwvirtState | CPUMHWVIRTDUMP_COMMON;
    4064 
    4065     /*
    4066      * Dump it.
    4067      */
     4047
    40684048    pHlp->pfnPrintf(pHlp, "VCPU[%u] hardware virtualization state:\n", pVCpu->idCpu);
    4069 
    4070     if (fDumpState & CPUMHWVIRTDUMP_COMMON)
    4071         pHlp->pfnPrintf(pHlp, "fLocalForcedActions          = %#RX32\n",  pCtx->hwvirt.fLocalForcedActions);
    4072 
    4073     pHlp->pfnPrintf(pHlp, "%s hwvirt state%s\n", pcszHwvirtMode, (fDumpState & (CPUMHWVIRTDUMP_SVM | CPUMHWVIRTDUMP_VMX)) ?
    4074                                                                  ":" : "");
    4075     if (fDumpState & CPUMHWVIRTDUMP_SVM)
    4076     {
     4049    pHlp->pfnPrintf(pHlp, "fLocalForcedActions          = %#RX32\n",  pCtx->hwvirt.fLocalForcedActions);
     4050    pHlp->pfnPrintf(pHlp, "In nested-guest hwvirt mode  = %RTbool\n", CPUMIsGuestInNestedHwvirtMode(pCtx));
     4051
     4052    if (fSvm)
     4053    {
     4054        pHlp->pfnPrintf(pHlp, "SVM hwvirt state:\n");
    40774055        pHlp->pfnPrintf(pHlp, "  fGif                       = %RTbool\n", pCtx->hwvirt.fGif);
    40784056
     
    40944072        pHlp->pfnPrintf(pHlp, "    uRax                       = %#RX64\n",  pCtx->hwvirt.svm.HostState.uRax);
    40954073        pHlp->pfnPrintf(pHlp, "    rflags                     = %#RX64 %31s\n", pCtx->hwvirt.svm.HostState.rflags.u64, szEFlags);
    4096         PCPUMSELREG pSel = &pCtx->hwvirt.svm.HostState.es;
     4074        PCCPUMSELREG pSelEs = &pCtx->hwvirt.svm.HostState.es;
    40974075        pHlp->pfnPrintf(pHlp, "    es                         = {%04x base=%016RX64 limit=%08x flags=%08x}\n",
    4098                         pSel->Sel, pSel->u64Base, pSel->u32Limit, pSel->Attr.u);
    4099         pSel = &pCtx->hwvirt.svm.HostState.cs;
     4076                        pSelEs->Sel, pSelEs->u64Base, pSelEs->u32Limit, pSelEs->Attr.u);
     4077        PCCPUMSELREG pSelCs = &pCtx->hwvirt.svm.HostState.cs;
    41004078        pHlp->pfnPrintf(pHlp, "    cs                         = {%04x base=%016RX64 limit=%08x flags=%08x}\n",
    4101                         pSel->Sel, pSel->u64Base, pSel->u32Limit, pSel->Attr.u);
    4102         pSel = &pCtx->hwvirt.svm.HostState.ss;
     4079                        pSelCs->Sel, pSelCs->u64Base, pSelCs->u32Limit, pSelCs->Attr.u);
     4080        PCCPUMSELREG pSelSs = &pCtx->hwvirt.svm.HostState.ss;
    41034081        pHlp->pfnPrintf(pHlp, "    ss                         = {%04x base=%016RX64 limit=%08x flags=%08x}\n",
    4104                         pSel->Sel, pSel->u64Base, pSel->u32Limit, pSel->Attr.u);
    4105         pSel = &pCtx->hwvirt.svm.HostState.ds;
     4082                        pSelSs->Sel, pSelSs->u64Base, pSelSs->u32Limit, pSelSs->Attr.u);
     4083        PCCPUMSELREG pSelDs = &pCtx->hwvirt.svm.HostState.ds;
    41064084        pHlp->pfnPrintf(pHlp, "    ds                         = {%04x base=%016RX64 limit=%08x flags=%08x}\n",
    4107                         pSel->Sel, pSel->u64Base, pSel->u32Limit, pSel->Attr.u);
     4085                        pSelDs->Sel, pSelDs->u64Base, pSelDs->u32Limit, pSelDs->Attr.u);
    41084086        pHlp->pfnPrintf(pHlp, "    gdtr                       = %016RX64:%04x\n", pCtx->hwvirt.svm.HostState.gdtr.pGdt,
    41094087                        pCtx->hwvirt.svm.HostState.gdtr.cbGdt);
     
    41184096        pHlp->pfnPrintf(pHlp, "  pvIoBitmapR0               = %RKv\n",      pCtx->hwvirt.svm.pvIoBitmapR0);
    41194097    }
    4120 
    4121     if (fDumpState & CPUMHWVIRTDUMP_VMX)
    4122     {
     4098    else if (fVmx)
     4099    {
     4100        pHlp->pfnPrintf(pHlp, "VMX hwvirt state:\n");
    41234101        pHlp->pfnPrintf(pHlp, "  GCPhysVmxon                = %#RGp\n",     pCtx->hwvirt.vmx.GCPhysVmxon);
    41244102        pHlp->pfnPrintf(pHlp, "  GCPhysVmcs                 = %#RGp\n",     pCtx->hwvirt.vmx.GCPhysVmcs);
     
    41404118        cpumR3InfoVmxVmcs(pVCpu, pHlp, pCtx->hwvirt.vmx.pVmcsR3, "  " /* pszPrefix */);
    41414119    }
     4120    else
     4121        pHlp->pfnPrintf(pHlp, "Hwvirt state disabled.\n");
    41424122
    41434123#undef CPUMHWVIRTDUMP_NONE
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