VirtualBox

Changeset 108945 in vbox


Ignore:
Timestamp:
Apr 11, 2025 9:18:48 AM (9 days ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
168456
Message:

VMM/IEM: Check that the encodeset stuff covers the whole 32 bits of the instruction. Optimized parent instruction conditions referring to fixed instruction encoding values. jiraref:VBP-1598

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/target-armv8/bsd-spec-analyze.py

    r108942 r108945  
    12131213
    12141214
    1215 def parseInstructions(oParent, aoJson, ddAsmRules):
     1215def parseInstructions(oInstrSet, oParent, aoJson, ddAsmRules):
    12161216    for oJson in aoJson:
    12171217        sType = oJson['_type'];
    12181218        if sType == 'Instruction.InstructionSet':
    12191219            if oParent: raise Exception("InstructionSet shouldn't have a parent!");
     1220            assert not oInstrSet;
    12201221            oInstrSet = ArmInstructionSet.fromJson(oJson);
    12211222            assert oInstrSet.sName not in g_dArmInstructionSets;
     
    12231224            g_aoArmInstructionSets.append(oInstrSet);
    12241225
    1225             parseInstructions(oInstrSet, oJson['children'], ddAsmRules);
     1226            parseInstructions(oInstrSet, oInstrSet, oJson['children'], ddAsmRules);
    12261227
    12271228        elif sType == 'Instruction.InstructionGroup':
     
    12401241            oParent.aoGroups.append(oInstrGroup);
    12411242
    1242             parseInstructions(oInstrGroup, oJson['children'], ddAsmRules);
     1243            parseInstructions(oInstrSet, oInstrGroup, oJson['children'], ddAsmRules);
    12431244
    12441245        elif sType == "Instruction.Instruction":
     
    12501251            sInstrNm = oJson['name'];
    12511252
     1253            oCondition = ArmAstBase.fromJson(oJson['condition']);
     1254
    12521255            (aoFields, fFields) = ArmEncodesetField.encodesetFromJson(oJson['encoding']);
    1253             oCondition          = ArmAstBase.fromJson(oJson['condition']);
    1254 
    12551256            for oUp in oParent.getUpIterator():
    12561257                if oUp.fFields & ~fFields:
     
    12581259                if not oUp.oCondition.isBoolAndTrue():
    12591260                    oCondition = ArmAstBinaryOp(oCondition, '&&', oUp.oCondition.clone());
     1261            if fFields != (1 << oInstrSet.cBitsWidth) - 1:
     1262                raise Exception('Instruction %s has an incomplete encodingset: fFields=%#010x (missing %#010x)'
     1263                                % (sInstrNm, fFields, fFields ^ ((1 << oInstrSet.cBitsWidth) - 1),))
    12601264
    12611265            #sCondBefore = oCondition.toString();
    12621266            #print('debug transfer: %s: org:  %s' % (sInstrNm, sCondBefore));
    1263             ## @todo fFields isn't updated here!
    12641267            (oCondition, fMod) = transferConditionsToEncoding(oCondition, aoFields, collections.defaultdict(list), sInstrNm);
    12651268            #if fMod:
     
    14821485    global g_oArmInstructionVerInfo;
    14831486    g_oArmInstructionVerInfo = dRawInstructions['_meta']['version'];
    1484     parseInstructions([], dRawInstructions['instructions'], dRawInstructions['assembly_rules']);
     1487    parseInstructions(None, None, dRawInstructions['instructions'], dRawInstructions['assembly_rules']);
    14851488
    14861489    # Sort the instruction array by name.
     
    22422245                    return (sName, oField.cBitsWidth);
    22432246                # Look for the field in groups and sets and generate a name that extracts it from uOpcode:
    2244                 ## @todo eliminate conditions checks from the parent on parent fields that are fixed in the given instr.
    22452247                for oParent in oInstr.oParent.getUpIterator():
    22462248                    oField = oParent.getFieldByName(sName, False);
    22472249                    if oField:
     2250                        fFieldOpMask = oField.getShiftedMask();
     2251                        if (oInstr.fFixedMask & fFieldOpMask) == fFieldOpMask:
     2252                            return ('%#x /*%s@%u*/'
     2253                                    % ((oInstr.fFixedValue & fFieldOpMask) >> oField.iFirstBit, sName, oField.iFirstBit),
     2254                                    oField.cBitsWidth);
    22482255                        return ('((uOpcode >> %u) & %#x)' % (oField.iFirstBit, oField.getMask()), oField.cBitsWidth);
    22492256                raise Exception('Field %s was not found for instruction %s' % (sName, oInstr.sName,));
     
    22592266                    sCpumFeature = g_dSpecFeatToCpumFeat.get(sFeatureNm, None);
    22602267                    if sCpumFeature is None:
    2261                         print('warning: IsFeatureImplemented parameter not known: %s (see g_dSpecFeatToCpumFeat)' % (sFeatureNm));
    2262                         #raise Exception('IsFeatureImplemented parameter not known: %s (see g_dSpecFeatToCpumFeat)'
    2263                         #                % (sFeatureNm));
     2268                        raise Exception('Unknown IsFeatureImplemented parameter: %s (see g_dSpecFeatToCpumFeat)' % (sFeatureNm));
    22642269                    if not isinstance(sCpumFeature, str):
    22652270                        return 'false /** @todo IEM_GET_GUEST_CPU_FEATURES(pVCpu)->%s*/' % (sFeatureNm,);
     
    23262331                '%s    LogFlow(("%%010x: %s%s\\n",%s));' % (sIndent, sCName, sLogFmt, ', '.join(['uOpcode',] + asArgs),),
    23272332                '#ifdef IEM_INSTR_IMPL_%s__%s' % (sInstrSet, sCName,),
    2328                 '%s    IEM_INSTR_IMPL_%s__%s(%s);' % (sInstrSet, sIndent, sCName, ', '.join(asArgs),),
     2333                '%s    IEM_INSTR_IMPL_%s__%s(%s);' % (sIndent, sInstrSet, sCName, ', '.join(asArgs),),
    23292334                '#else',
    23302335                '%s    RT_NOREF(%s);' % (sIndent, ', '.join(asArgs + ['pVCpu', 'uOpcode',]),),
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