VirtualBox

Changeset 101490 in vbox for trunk/src/VBox/VMM


Ignore:
Timestamp:
Oct 18, 2023 9:00:11 AM (18 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
159562
Message:

VMM/IEM: Added missing guest register shadow copy flushing. nop sequence + loop works now. Removed some debugging stuff. bugref:10371

File:
1 edited

Legend:

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

    r101484 r101490  
    12011201    RTCritSectLeave(&g_IemNativeGdbJitLock);
    12021202
    1203     RT_BREAKPOINT();
    1204 #  endif
     1203#  endif /* IEMNATIVE_USE_GDB_JIT */
    12051204
    12061205    return VINF_SUCCESS;
     
    20122011    if (fRegs)
    20132012    {
    2014 fPreferVolatile = false; /// @todo DO NOT COMMIT THIS
    20152013        if (fPreferVolatile)
    20162014            idxReg = (uint8_t)ASMBitFirstSetU32(  fRegs & IEMNATIVE_CALL_VOLATILE_GREG_MASK
     
    27412739
    27422740/**
     2741 * Flushes a set of guest register shadow copies.
     2742 *
     2743 * This is usually done after calling a threaded function or a C-implementation
     2744 * of an instruction.
     2745 *
     2746 * @param   pReNative       The native recompile state.
     2747 * @param   fGstRegs        Set of guest registers to flush.
     2748 */
     2749DECLHIDDEN(void) iemNativeRegFlushGuestShadows(PIEMRECOMPILERSTATE pReNative, uint64_t fGstRegs) RT_NOEXCEPT
     2750{
     2751    /*
     2752     * Reduce the mask by what's currently shadowed
     2753     */
     2754    fGstRegs &= pReNative->bmGstRegShadows;
     2755    if (fGstRegs)
     2756    {
     2757        pReNative->bmGstRegShadows &= ~fGstRegs;
     2758        if (pReNative->bmGstRegShadows)
     2759        {
     2760            /*
     2761             * Partial.
     2762             */
     2763            do
     2764            {
     2765                unsigned const idxGstReg = ASMBitFirstSetU64(fGstRegs) - 1;
     2766                uint8_t const  idxHstReg = pReNative->aidxGstRegShadows[idxGstReg];
     2767                Assert(idxHstReg < RT_ELEMENTS(pReNative->aidxGstRegShadows));
     2768                Assert(pReNative->bmHstRegsWithGstShadow & RT_BIT_32(idxHstReg));
     2769                Assert(pReNative->aHstRegs[idxHstReg].fGstRegShadows & RT_BIT_64(idxGstReg));
     2770
     2771                uint64_t const fInThisHstReg = (pReNative->aHstRegs[idxHstReg].fGstRegShadows & fGstRegs) | RT_BIT_64(idxGstReg);
     2772                fGstRegs &= ~fInThisHstReg;
     2773                pReNative->aHstRegs[idxHstReg].fGstRegShadows &= fInThisHstReg;
     2774                if (!pReNative->aHstRegs[idxHstReg].fGstRegShadows)
     2775                    pReNative->bmHstRegsWithGstShadow &= ~RT_BIT_32(idxHstReg);
     2776            } while (fGstRegs != 0);
     2777        }
     2778        else
     2779        {
     2780            /*
     2781             * Clear all.
     2782             */
     2783            do
     2784            {
     2785                unsigned const idxGstReg = ASMBitFirstSetU64(fGstRegs) - 1;
     2786                uint8_t const  idxHstReg = pReNative->aidxGstRegShadows[idxGstReg];
     2787                Assert(idxHstReg < RT_ELEMENTS(pReNative->aidxGstRegShadows));
     2788                Assert(pReNative->bmHstRegsWithGstShadow & RT_BIT_32(idxHstReg));
     2789                Assert(pReNative->aHstRegs[idxHstReg].fGstRegShadows & RT_BIT_64(idxGstReg));
     2790
     2791                fGstRegs &= ~(pReNative->aHstRegs[idxHstReg].fGstRegShadows | RT_BIT_64(idxGstReg));
     2792                pReNative->aHstRegs[idxHstReg].fGstRegShadows = 0;
     2793            } while (fGstRegs != 0);
     2794            pReNative->bmHstRegsWithGstShadow = 0;
     2795        }
     2796    }
     2797}
     2798
     2799
     2800/**
    27432801 * Emits a code for checking the return code of a call and rcPassUp, returning
    27442802 * from the code if either are non-zero.
     
    28892947    AssertReturn(off != UINT32_MAX, UINT32_MAX);
    28902948#endif
    2891 /** @todo Must flush all shadow guest registers as well. */
     2949    iemNativeRegFlushGuestShadows(pReNative, UINT64_MAX); /** @todo optimize this */
    28922950    off = iemNativeRegMoveAndFreeAndFlushAtCall(pReNative, off, 4, false /*fFreeArgVars*/);
    28932951    uint8_t const cParams = g_acIemThreadedFunctionUsedArgs[pCallEntry->enmFunction];
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette