VirtualBox

Ignore:
Timestamp:
Mar 25, 2024 12:56:46 PM (8 months ago)
Author:
vboxsync
Message:

VMM/IEM: Add some more detailed debug info when a guest register becomes dirty and is flushed, bugref:10629

File:
1 edited

Legend:

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

    r104034 r104036  
    37283728     */
    37293729    uint32_t idx     = pDbgInfo->cEntries;
    3730     uint32_t idxStop = idx > 8 ? idx - 8 : 0;
     3730    uint32_t idxStop = idx > 16 ? idx - 16 : 0;
    37313731    while (idx-- > idxStop)
    37323732        if (pDbgInfo->aEntries[idx].Gen.uType == kIemTbDbgEntryType_NativeOffset)
     
    37953795    PIEMTBDBGENTRY const pEntry = iemNativeDbgInfoAddNewEntry(pReNative, pReNative->pDbgInfo);
    37963796    pEntry->GuestRegShadowing.uType         = kIemTbDbgEntryType_GuestRegShadowing;
    3797 #ifdef IEMNATIVE_WITH_DELAYED_REGISTER_WRITEBACK
    3798     pEntry->GuestRegShadowing.fDirty        = (pReNative->Core.bmGstRegShadowDirty & RT_BIT_64(enmGstReg)) ? 1 : 0;
    3799 #endif
    38003797    pEntry->GuestRegShadowing.uUnused       = 0;
    38013798    pEntry->GuestRegShadowing.idxGstReg     = enmGstReg;
     
    38373834    pEntry->DelayedPcUpdate.offPc         = offPc;
    38383835    pEntry->DelayedPcUpdate.cInstrSkipped = cInstrSkipped;
     3836}
     3837# endif
     3838
     3839
     3840# ifdef IEMNATIVE_WITH_DELAYED_REGISTER_WRITEBACK
     3841/**
     3842 * Debug Info: Record info about a dirty guest register.
     3843 */
     3844DECL_HIDDEN_THROW(void) iemNaitveDbgInfoAddGuestRegDirty(PIEMRECOMPILERSTATE pReNative, bool fSimdReg,
     3845                                                         uint8_t idxGstReg, uint8_t idxHstReg)
     3846{
     3847    PIEMTBDBGENTRY const pEntry = iemNativeDbgInfoAddNewEntry(pReNative, pReNative->pDbgInfo);
     3848    pEntry->GuestRegDirty.uType         = kIemTbDbgEntryType_GuestRegDirty;
     3849    pEntry->GuestRegDirty.fSimdReg      = fSimdReg ? 1 : 0;
     3850    pEntry->GuestRegDirty.idxGstReg     = idxGstReg;
     3851    pEntry->GuestRegDirty.idxHstReg     = idxHstReg;
     3852}
     3853
     3854
     3855/**
     3856 * Debug Info: Record info about a dirty guest register writeback operation.
     3857 */
     3858DECL_HIDDEN_THROW(void) iemNaitveDbgInfoAddGuestRegWriteback(PIEMRECOMPILERSTATE pReNative, bool fSimdReg, uint64_t fGstReg)
     3859{
     3860    PIEMTBDBGENTRY const pEntry = iemNativeDbgInfoAddNewEntry(pReNative, pReNative->pDbgInfo);
     3861    pEntry->GuestRegWriteback.uType         = kIemTbDbgEntryType_GuestRegWriteback;
     3862    pEntry->GuestRegWriteback.fSimdReg      = fSimdReg ? 1 : 0;
     3863    pEntry->GuestRegWriteback.fGstReg       = (uint32_t)fGstReg;
     3864    /** @todo r=aeichner Can't fit the whole register mask in the debug info entry, deal with it when it becomes necessary. */
     3865    Assert((uint64_t)pEntry->GuestRegWriteback.fGstReg == fGstReg);
    38393866}
    38403867# endif
     
    41054132    if (pReNative->Core.bmGstRegShadowDirty & fFlushGstReg)
    41064133    {
     4134# ifdef IEMNATIVE_WITH_TB_DEBUG_INFO
     4135        iemNativeDbgInfoAddNativeOffset(pReNative, off);
     4136        iemNaitveDbgInfoAddGuestRegWriteback(pReNative, false /*fSimdReg*/, pReNative->Core.bmGstRegShadowDirty & fFlushGstReg);
     4137# endif
     4138
    41074139        uint64_t bmGstRegShadowDirty = pReNative->Core.bmGstRegShadowDirty & fFlushGstReg;
    41084140        uint32_t idxGstReg = 0;
     
    41404172    if (pReNative->Core.bmGstRegShadowDirty & fGstRegShadows)
    41414173    {
     4174# ifdef IEMNATIVE_WITH_TB_DEBUG_INFO
     4175        iemNativeDbgInfoAddNativeOffset(pReNative, off);
     4176        iemNaitveDbgInfoAddGuestRegWriteback(pReNative, false /*fSimdReg*/, pReNative->Core.bmGstRegShadowDirty & fGstRegShadows);
     4177# endif
     4178
    41424179        uint64_t bmGstRegShadowDirty = pReNative->Core.bmGstRegShadowDirty & fGstRegShadows;
    41434180        uint32_t idxGstReg = 0;
     
    46354672                            ? IEMNATIVE_HST_GREG_MASK & ~IEMNATIVE_REG_FIXED_MASK
    46364673                            : IEMNATIVE_HST_GREG_MASK & ~IEMNATIVE_REG_FIXED_MASK & ~IEMNATIVE_CALL_VOLATILE_GREG_MASK;
    4637 
    4638 #ifdef IEMNATIVE_WITH_DELAYED_REGISTER_WRITEBACK
    4639     /** @todo r=aeichner Implement for registers other than GPR as well. */
    4640     if (   (   enmIntendedUse == kIemNativeGstRegUse_ForFullWrite
    4641             || enmIntendedUse == kIemNativeGstRegUse_ForUpdate)
    4642         && enmGstReg >= kIemNativeGstReg_GprFirst
    4643         && enmGstReg <= kIemNativeGstReg_GprLast
    4644         )
    4645         pReNative->Core.bmGstRegShadowDirty |= RT_BIT_64(enmGstReg);
    4646 #endif
    46474674
    46484675    /*
     
    47634790#endif
    47644791
     4792#ifdef IEMNATIVE_WITH_DELAYED_REGISTER_WRITEBACK
     4793        /** @todo r=aeichner Implement for registers other than GPR as well. */
     4794        if (   (   enmIntendedUse == kIemNativeGstRegUse_ForFullWrite
     4795                || enmIntendedUse == kIemNativeGstRegUse_ForUpdate)
     4796            && enmGstReg >= kIemNativeGstReg_GprFirst
     4797            && enmGstReg <= kIemNativeGstReg_GprLast
     4798            )
     4799        {
     4800# ifdef IEMNATIVE_WITH_TB_DEBUG_INFO
     4801            iemNativeDbgInfoAddNativeOffset(pReNative, *poff);
     4802            iemNaitveDbgInfoAddGuestRegDirty(pReNative, false /*fSimdReg*/, enmGstReg, idxReg);
     4803# endif
     4804
     4805            pReNative->Core.bmGstRegShadowDirty |= RT_BIT_64(enmGstReg);
     4806        }
     4807#endif
     4808
    47654809        return idxReg;
    47664810    }
     
    47784822    Log12(("iemNativeRegAllocTmpForGuestReg: Allocated %s for guest %s %s\n",
    47794823           g_apszIemNativeHstRegNames[idxRegNew], g_aGstShadowInfo[enmGstReg].pszName, s_pszIntendedUse[enmIntendedUse]));
     4824
     4825#ifdef IEMNATIVE_WITH_DELAYED_REGISTER_WRITEBACK
     4826    /** @todo r=aeichner Implement for registers other than GPR as well. */
     4827    if (   (   enmIntendedUse == kIemNativeGstRegUse_ForFullWrite
     4828            || enmIntendedUse == kIemNativeGstRegUse_ForUpdate)
     4829        && enmGstReg >= kIemNativeGstReg_GprFirst
     4830        && enmGstReg <= kIemNativeGstReg_GprLast
     4831        )
     4832    {
     4833# ifdef IEMNATIVE_WITH_TB_DEBUG_INFO
     4834        iemNativeDbgInfoAddNativeOffset(pReNative, *poff);
     4835        iemNaitveDbgInfoAddGuestRegDirty(pReNative, false /*fSimdReg*/, enmGstReg, idxRegNew);
     4836# endif
     4837
     4838        pReNative->Core.bmGstRegShadowDirty |= RT_BIT_64(enmGstReg);
     4839    }
     4840#endif
    47804841
    47814842    return idxRegNew;
     
    62476308
    62486309#ifdef IEMNATIVE_WITH_SIMD_REG_ALLOCATOR
     6310# ifdef IEMNATIVE_WITH_TB_DEBUG_INFO
     6311    if (pReNative->Core.bmGstSimdRegShadowDirtyLo128 | pReNative->Core.bmGstSimdRegShadowDirtyHi128)
     6312    {
     6313        iemNativeDbgInfoAddNativeOffset(pReNative, off);
     6314        iemNaitveDbgInfoAddGuestRegWriteback(pReNative, true /*fSimdReg*/,
     6315                                               pReNative->Core.bmGstSimdRegShadowDirtyLo128
     6316                                             | pReNative->Core.bmGstSimdRegShadowDirtyHi128);
     6317    }
     6318# endif
    62496319    /** @todo r=bird: There must be a quicker way to check if anything needs
    62506320     *        doing and then call simd function to do the flushing */
     
    80918161#ifdef IEMNATIVE_WITH_DELAYED_REGISTER_WRITEBACK
    80928162        if (enmGstReg >= kIemNativeGstReg_GprFirst && enmGstReg <= kIemNativeGstReg_GprLast)
     8163        {
     8164# ifdef IEMNATIVE_WITH_TB_DEBUG_INFO
     8165            iemNativeDbgInfoAddNativeOffset(pReNative, *poff);
     8166            iemNaitveDbgInfoAddGuestRegDirty(pReNative, false /*fSimdReg*/, enmGstReg, idxReg);
     8167# endif
     8168
    80938169            pReNative->Core.bmGstRegShadowDirty |= RT_BIT_64(enmGstReg);
     8170        }
    80948171#endif
    80958172
     
    94469523                            const char * const    pszGstReg = g_aGstShadowInfo[pEntry->GuestRegShadowing.idxGstReg].pszName;
    94479524                            if (pEntry->GuestRegShadowing.idxHstReg == UINT8_MAX)
    9448                                 pHlp->pfnPrintf(pHlp, "  Guest register %s != host register %s (Dirty: %RTbool)\n", pszGstReg,
    9449                                                 g_apszIemNativeHstRegNames[pEntry->GuestRegShadowing.idxHstRegPrev],
    9450                                                 RT_BOOL(pEntry->GuestRegShadowing.fDirty));
     9525                                pHlp->pfnPrintf(pHlp, "  Guest register %s != host register %s\n", pszGstReg,
     9526                                                g_apszIemNativeHstRegNames[pEntry->GuestRegShadowing.idxHstRegPrev]);
    94519527                            else if (pEntry->GuestRegShadowing.idxHstRegPrev == UINT8_MAX)
    9452                                 pHlp->pfnPrintf(pHlp, "  Guest register %s == host register %s (Dirty: %RTbool)\n", pszGstReg,
     9528                                pHlp->pfnPrintf(pHlp, "  Guest register %s == host register %s \n", pszGstReg,
     9529                                                g_apszIemNativeHstRegNames[pEntry->GuestRegShadowing.idxHstReg]);
     9530                            else
     9531                                pHlp->pfnPrintf(pHlp, "  Guest register %s == host register %s (previously in %s)\n", pszGstReg,
    94539532                                                g_apszIemNativeHstRegNames[pEntry->GuestRegShadowing.idxHstReg],
    9454                                                 RT_BOOL(pEntry->GuestRegShadowing.fDirty));
    9455                             else
    9456                                 pHlp->pfnPrintf(pHlp, "  Guest register %s == host register %s (previously in %s, Dirty: %RTbool)\n", pszGstReg,
    9457                                                 g_apszIemNativeHstRegNames[pEntry->GuestRegShadowing.idxHstReg],
    9458                                                 g_apszIemNativeHstRegNames[pEntry->GuestRegShadowing.idxHstRegPrev],
    9459                                                 RT_BOOL(pEntry->GuestRegShadowing.fDirty));
     9533                                                g_apszIemNativeHstRegNames[pEntry->GuestRegShadowing.idxHstRegPrev]);
    94609534                            continue;
    94619535                        }
     
    95579631#endif
    95589632
     9633#ifdef IEMNATIVE_WITH_DELAYED_REGISTER_WRITEBACK
     9634                        case kIemTbDbgEntryType_GuestRegDirty:
     9635                        {
     9636                            PCIEMTBDBGENTRY const pEntry    = &pDbgInfo->aEntries[iDbgEntry];
     9637                            const char * const    pszGstReg =   pEntry->GuestRegDirty.fSimdReg
     9638                                                              ? g_aGstSimdShadowInfo[pEntry->GuestRegDirty.idxGstReg].pszName
     9639                                                              : g_aGstShadowInfo[pEntry->GuestRegDirty.idxGstReg].pszName;
     9640                            const char * const    pszHstReg =   pEntry->GuestRegDirty.fSimdReg
     9641                                                              ? g_apszIemNativeHstSimdRegNames[pEntry->GuestRegDirty.idxHstReg]
     9642                                                              : g_apszIemNativeHstRegNames[pEntry->GuestRegDirty.idxHstReg];
     9643                            pHlp->pfnPrintf(pHlp,
     9644                                            "  Guest register %s (shadowed by %s) is now dirty\n",
     9645                                            pszGstReg, pszHstReg);
     9646                            continue;
     9647                        }
     9648
     9649                        case kIemTbDbgEntryType_GuestRegWriteback:
     9650                            pHlp->pfnPrintf(pHlp,
     9651                                            "  Writing dirty %s registers (gst %#RX64)\n",
     9652                                            pDbgInfo->aEntries[iDbgEntry].GuestRegWriteback.fSimdReg ? "SIMD" : "general",
     9653                                            pDbgInfo->aEntries[iDbgEntry].GuestRegWriteback.fGstReg);
     9654                            continue;
     9655#endif
     9656
    95599657                        default:
    95609658                            AssertFailed();
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