VirtualBox

Changeset 100633 in vbox for trunk/src/VBox/VMM/VMMAll


Ignore:
Timestamp:
Jul 18, 2023 2:05:10 PM (19 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
158464
Message:

VMM/IEM: Check for too early IEMCPU::iEffSeg use during recompiler code generation. bugref:10369

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

Legend:

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

    r100588 r100633  
    24502450            self.aoStmts = self.decodeCode(''.join(self.asLines));
    24512451        return self.aoStmts;
     2452
     2453
     2454    def checkForTooEarlyEffSegUse(self, aoStmts):
     2455        """
     2456        Checks if iEffSeg is used before the effective address has been decoded.
     2457        Returns None on success, error string on failure.
     2458
     2459        See r158454 for an example of this issue.
     2460        """
     2461
     2462        # Locate the IEM_MC_CALC_RM_EFF_ADDR statement, if found, scan backwards
     2463        # for IEMCPU::iEffSeg references. No need to check conditional branches,
     2464        # as we're ASSUMING these will not occur before address calculation.
     2465        for iStmt, oStmt in enumerate(aoStmts):
     2466            if oStmt.sName == 'IEM_MC_CALC_RM_EFF_ADDR':
     2467                while iStmt > 0:
     2468                    iStmt -= 1;
     2469                    oStmt  = aoStmts[iStmt];
     2470                    for sArg in oStmt.asParams:
     2471                        if sArg.find('pVCpu->iem.s.iEffSeg') >= 0:
     2472                            return "statement #%u: pVCpu->iem.s.iEffSeg is used prior to IEM_MC_CALC_RM_EFF_ADDR!" % (iStmt + 1,);
     2473                break;
     2474        return None;
     2475
     2476    def check(self):
     2477        """
     2478        Performs some sanity checks on the block.
     2479        Returns error string list, empty if all is fine.
     2480        """
     2481        aoStmts = self.decode();
     2482        asRet   = [];
     2483
     2484        sRet = self.checkForTooEarlyEffSegUse(aoStmts);
     2485        if sRet:
     2486            asRet.append(sRet);
     2487
     2488        return asRet;
     2489
    24522490
    24532491
  • trunk/src/VBox/VMM/VMMAll/IEMAllThreadedPython.py

    r100587 r100633  
    952952        """
    953953
     954        # Check the block for errors before we proceed (will decode it).
     955        asErrors = self.oMcBlock.check();
     956        if asErrors:
     957            raise Exception('\n'.join(['%s:%s: error: %s' % (self.oMcBlock.sSrcFile, self.oMcBlock.iBeginLine, sError, )
     958                                       for sError in asErrors]));
     959
    954960        # Decode the block into a list/tree of McStmt objects.
    955961        aoStmts = self.oMcBlock.decode();
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