VirtualBox

Changeset 102365 in vbox


Ignore:
Timestamp:
Nov 28, 2023 2:19:35 PM (16 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
160501
Message:

VMM/IEM: Fixed bug in threaded recompiler where we'd emit the CheckMode calls with the *OLD* fExec value. bugref:10371

Location:
trunk/src/VBox/VMM/VMMAll
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/IEMAllThrdPython.py

    r102072 r102365  
    12491249        aoStmts.append(iai.McCppCall('IEM_MC2_EMIT_CALL_%s' % (len(asCallArgs) - 1,), asCallArgs, cchIndent = cchIndent));
    12501250
    1251         # For CIMPL stuff, we need to consult the associated IEM_CIMPL_F_XXX
    1252         # mask and maybe emit additional checks.
    1253         if (   'IEM_CIMPL_F_MODE'   in self.oParent.dsCImplFlags
    1254             or 'IEM_CIMPL_F_XCPT'   in self.oParent.dsCImplFlags
    1255             or 'IEM_CIMPL_F_VMEXIT' in self.oParent.dsCImplFlags):
    1256             aoStmts.append(iai.McCppCall('IEM_MC2_EMIT_CALL_1', ( 'kIemThreadedFunc_BltIn_CheckMode', 'pVCpu->iem.s.fExec', ),
    1257                                          cchIndent = cchIndent));
     1251        # 2023-11-28: This has to be done AFTER the CIMPL call, so we have to
     1252        #             emit this mode check from the compilation loop.  On the
     1253        #             plus side, this means we eliminate unnecessary call at
     1254        #             end of the TB. :-)
     1255        ## For CIMPL stuff, we need to consult the associated IEM_CIMPL_F_XXX
     1256        ## mask and maybe emit additional checks.
     1257        #if (   'IEM_CIMPL_F_MODE'   in self.oParent.dsCImplFlags
     1258        #    or 'IEM_CIMPL_F_XCPT'   in self.oParent.dsCImplFlags
     1259        #    or 'IEM_CIMPL_F_VMEXIT' in self.oParent.dsCImplFlags):
     1260        #    aoStmts.append(iai.McCppCall('IEM_MC2_EMIT_CALL_1', ( 'kIemThreadedFunc_BltIn_CheckMode', 'pVCpu->iem.s.fExec', ),
     1261        #                                 cchIndent = cchIndent));
    12581262
    12591263        sCImplFlags = ' | '.join(self.oParent.dsCImplFlags.keys());
  • trunk/src/VBox/VMM/VMMAll/IEMAllThrdRecompiler.cpp

    r102332 r102365  
    19991999
    20002000/**
     2001 * Called by iemThreadedCompile when a block requires a mode check.
     2002 *
     2003 * @returns true if we should continue, false if we're out of call entries.
     2004 * @param   pVCpu       The cross context virtual CPU structure of the calling
     2005 *                      thread.
     2006 * @param   pTb         The translation block being compiled.
     2007 */
     2008static bool iemThreadedCompileEmitCheckMode(PVMCPUCC pVCpu, PIEMTB pTb)
     2009{
     2010    /* Emit the call. */
     2011    uint32_t const idxCall = pTb->Thrd.cCalls;
     2012    AssertReturn(idxCall < pTb->Thrd.cAllocated, false);
     2013    PIEMTHRDEDCALLENTRY pCall = &pTb->Thrd.paCalls[idxCall];
     2014    pTb->Thrd.cCalls = (uint16_t)(idxCall + 1);
     2015    pCall->enmFunction = kIemThreadedFunc_BltIn_CheckMode;
     2016    pCall->idxInstr    = pTb->cInstructions - 1;
     2017    pCall->uUnused0    = 0;
     2018    pCall->offOpcode   = 0;
     2019    pCall->cbOpcode    = 0;
     2020    pCall->idxRange    = 0;
     2021    pCall->auParams[0] = pVCpu->iem.s.fExec;
     2022    pCall->auParams[1] = 0;
     2023    pCall->auParams[2] = 0;
     2024    LogFunc(("%04x:%08RX64 fExec=%#x\n", pVCpu->cpum.GstCtx.cs.Sel, pVCpu->cpum.GstCtx.rip, pVCpu->iem.s.fExec));
     2025    return true;
     2026}
     2027
     2028
     2029/**
    20012030 * Called by IEM_MC2_BEGIN_EMIT_CALLS() when IEM_CIMPL_F_CHECK_IRQ_BEFORE is
    20022031 * set.
     
    21682197
    21692198            pVCpu->iem.s.cInstructions++;
     2199
     2200            /* Check for mode change _after_ certain CIMPL calls, so check that
     2201               we continue executing with the same mode value. */
     2202            if (!(pVCpu->iem.s.fTbCurInstr & (IEM_CIMPL_F_MODE | IEM_CIMPL_F_XCPT | IEM_CIMPL_F_VMEXIT)))
     2203            { /* probable */ }
     2204            else if (RT_LIKELY(iemThreadedCompileEmitCheckMode(pVCpu, pTb)))
     2205            { /* extremely likely */ }
     2206            else
     2207                break;
    21702208        }
    21712209        else
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