VirtualBox

Changeset 106181 in vbox for trunk/src


Ignore:
Timestamp:
Sep 30, 2024 3:24:34 PM (2 months ago)
Author:
vboxsync
Message:

VMM/IEM: Check that IEM_MC_REF_EFLAGS is used correctly and won't cause trouble for EFLAGS calculation postponing. bugref:10720

File:
1 edited

Legend:

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

    r106180 r106181  
    29252925        return None;
    29262926
     2927    koReRefEflIllegalMemRough   = re.compile(r'^IEM_MC_.*(MEM|PUSH_U|POP_GREG|RETN|IND_CALL|REL_CALL)');
     2928    koReRefEflIllegalMemExclude = re.compile(r'^IEM_MC_.*(MEM_COMMIT|MEM_OP|FPU_|UPDATE_FSW)');
     2929    koReRefEflIllegalRaise      = re.compile(r'^IEM_MC_(RAISE|MAYBE_RAISE)');
     2930
     2931    def checkRefEFlagsUse(self, aoStmts, asState):
     2932        """
     2933        Checks that EFLAGS references comes after memory fetches and that there
     2934        are no memory stores or conditional raises afterwards.
     2935
     2936        The problem is postponed EFLAGS calculation management.  This gets a
     2937        lot easier if we can jettison any postponements when EFLAGS are
     2938        referenced.  If we had to deal with potential TB exits / exceptions
     2939        after they are referenced, this means it would have to delay the
     2940        cleanup until the IEM_MC_..._AND_FINISH statement which is kind of
     2941        complicated and not very efficient.
     2942        """
     2943        fSeenIt = asState.get('fSeenIt', False);
     2944        for iStmt, oStmt in enumerate(aoStmts):
     2945            if not oStmt.isCppStmt():
     2946                if oStmt.sName in ('IEM_MC_REF_EFLAGS', 'IEM_MC_REF_EFLAGS_EX',):
     2947                    fSeenIt = True;
     2948                elif (    fSeenIt
     2949                      and (    (    self.koReRefEflIllegalMemRough.match(oStmt.sName)
     2950                                and not self.koReRefEflIllegalMemExclude.match(oStmt.sName))
     2951                           or self.koReRefEflIllegalRaise.match(oStmt.sName) )):
     2952                    return "statement #%u: %s following REF_EFLAGS! That'll mess up EFLAGS calculation postponing" \
     2953                         % (iStmt + 1, oStmt.sName,);
     2954
     2955            # Go into branches.
     2956            if isinstance(oStmt, McStmtCond):
     2957                asState['fSeenIt'] = fSeenIt;
     2958                sRet = self.checkRefEFlagsUse(oStmt.aoIfBranch, asState);
     2959                if sRet:
     2960                    return sRet;
     2961                sRet = self.checkRefEFlagsUse(oStmt.aoElseBranch, asState);
     2962                if sRet:
     2963                    return sRet;
     2964                fSeenIt = asState['fSeenIt'];
     2965        return None;
     2966
    29272967    def check(self):
    29282968        """
     
    29452985            asRet.append(sRet);
    29462986
    2947         ## @todo Check that IEM_MC_REF_EFLAGS isn't used before memory fetches and does
    2948         # not have any stores or conditional raises afterwards.
     2987        sRet = self.checkRefEFlagsUse(aoStmts, {});
     2988        if sRet:
     2989            asRet.append(sRet);
    29492990
    29502991        return asRet;
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