VirtualBox

Changeset 66313 in vbox


Ignore:
Timestamp:
Mar 28, 2017 7:28:08 PM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
114242
Message:

bs3-cpu-generated-1,IEM: Introducing @opcodesub to more effectively deal with mod=3 vs mod!=3 encoding different instructions; hacked stuff to test unused mod encodings.

Location:
trunk/src/VBox
Files:
5 edited

Legend:

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

    r66309 r66313  
    257257    '11 mr/reg':    [],
    258258    '!11 mr/reg':   [],
     259};
     260
     261## Special \@opcodesub tag values.
     262g_kdSubOpcodes = {
     263    'none':         [ None,         ],
     264    '11 mr/reg':    [ '11 mr/reg',  ],
     265    '11':           [ '11 mr/reg',  ],      ##< alias
     266    '!11 mr/reg':   [ '!11 mr/reg', ],
     267    '!11':          [ '!11 mr/reg', ],      ##< alias
    259268};
    260269
     
    9971006        self.sPrefix        = None;     ##< Single prefix: None, 'none', 0x66, 0xf3, 0xf2
    9981007        self.sOpcode        = None;     # type: str
     1008        self.sSubOpcode     = None;     # type: str
    9991009        self.sEncoding      = None;
    10001010        self.asFlTest       = None;
     
    12731283            '@opmaps':      self.parseTagOpMaps,
    12741284            '@opcode':      self.parseTagOpcode,
     1285            '@opcodesub':   self.parseTagOpcodeSub,
    12751286            '@openc':       self.parseTagOpEnc,
    12761287            '@opfltest':    self.parseTagOpEFlags,
     
    14331444        if oInstr.sEncoding is None:
    14341445            if not oInstr.aoOperands:
    1435                 oInstr.sEncoding = 'fixed';
     1446                if oInstr.fUnused and oInstr.sSubOpcode:
     1447                    oInstr.sEncoding = 'ModR/M';
     1448                else:
     1449                    oInstr.sEncoding = 'fixed';
    14361450            elif oInstr.aoOperands[0].usesModRM():
    14371451                if len(oInstr.aoOperands) >= 2 and oInstr.aoOperands[1].sWhere == 'vvvv':
     
    17811795            return self.errorComment(iTagLine, '%s: attempting to overwrite "%s" with "%s"' % ( sTag, oInstr.sOpcode, sOpcode,));
    17821796        oInstr.sOpcode = sOpcode;
     1797
     1798        _ = iEndLine;
     1799        return True;
     1800
     1801    def parseTagOpcodeSub(self, sTag, aasSections, iTagLine, iEndLine):
     1802        """
     1803        Tag:        \@opcodesub
     1804        Value:      none | 11 mr/reg | !11 mr/reg
     1805
     1806        This is a simple way of dealing with encodings where the mod=3 and mod!=3
     1807        represents exactly two different instructions.  The more proper way would
     1808        be to go via maps with two members, but this is faster.
     1809        """
     1810        oInstr = self.ensureInstructionForOpTag(iTagLine);
     1811
     1812        # Flatten and validate the value.
     1813        sSubOpcode = self.flattenAllSections(aasSections);
     1814        if sSubOpcode not in g_kdSubOpcodes:
     1815            return self.errorComment(iTagLine, '%s: invalid sub opcode: %s  (valid: 11, !11, none)' % (sTag, sSubOpcode,));
     1816        sSubOpcode = g_kdSubOpcodes[sSubOpcode][0];
     1817
     1818        # Set it.
     1819        if oInstr.sSubOpcode is not None:
     1820            return self.errorComment(iTagLine, '%s: attempting to overwrite "%s" with "%s"'
     1821                                               % ( sTag, oInstr.sSubOpcode, sSubOpcode,));
     1822        oInstr.sSubOpcode = sSubOpcode;
    17831823
    17841824        _ = iEndLine;
  • trunk/src/VBox/VMM/VMMAll/IEMAllInstructionsTwoByte0f.cpp.h

    r66311 r66313  
    12931293        /**
    12941294         * @opcode      0x12
     1295         * @opcodesub   11 mr/reg
    12951296         * @oppfx       none
    12961297         * @opcpuid     sse
     
    12991300         * @optest      op1=1 op2=2 -> op1=2
    13001301         * @optest      op1=0 op2=-42 -> op1=-42
    1301          * @oponlytest
    13021302         */
    13031303        IEMOP_MNEMONIC2(RM_REG, MOVHLPS, movhlps, Vq, UqHi, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZE);
     
    13201320         * @opdone
    13211321         * @opcode      0x12
     1322         * @opcodesub   !11 mr/reg
    13221323         * @oppfx       none
    13231324         * @opcpuid     sse
     
    13271328         * @optest      op1=0 op2=-42 -> op1=-42
    13281329         * @opfunction  iemOp_vmovlps_Vq_Hq_Mq__vmovhlps
    1329          * @oponlytest
    13301330         */
    13311331        IEMOP_MNEMONIC2(RM_MEM, MOVLPS, movlps, Vq, Mq, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZE);
     
    13501350
    13511351
     1352/**
     1353 * @opcode      0x12
     1354 * @opcodesub   !11 mr/reg
     1355 * @oppfx       0x66
     1356 * @opcpuid     sse2
     1357 * @opgroup     og_sse2_pcksclr_datamove
     1358 * @opxcpttype  5
     1359 * @optest      op1=1 op2=2 -> op1=2
     1360 * @optest      op1=0 op2=-42 -> op1=-42
     1361 */
    13521362FNIEMOP_DEF(iemOp_vmovlpd_Vq_Hq_Mq)
    13531363{
    13541364    uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
    1355     if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
    1356     {
    1357         /**
    1358          * @todo figure this out!
    1359          * opcode      0x12
    1360          * todo        11 /reg
    1361          * oppfx       0x66
    1362          * openc       ModR/M
    1363          * opcpuid     sse2
    1364          * opgroup     og_sse_simdfp_datamove
    1365          * opunused    immediate
    1366          * optest      op1=1 op2=2 -> op1=2
    1367          * oponlytest
    1368          */
    1369         return IEMOP_RAISE_INVALID_OPCODE();
    1370     }
    1371     else
    1372     {
    1373         /**
    1374          * @opdone
    1375          * @opcode      0x12
    1376          * @oppfx       0x66
    1377          * @opcpuid     sse2
    1378          * @opgroup     og_sse2_pcksclr_datamove
    1379          * @opxcpttype  5
    1380          * @optest      op1=1 op2=2 -> op1=2
    1381          * @optest      op1=0 op2=-42 -> op1=-42
    1382          * @opfunction  iemOp_vmovlpd_Vq_Hq_Mq
    1383          * @oponlytest
    1384          */
     1365    if ((bRm & X86_MODRM_MOD_MASK) != (3 << X86_MODRM_MOD_SHIFT))
     1366    {
    13851367        IEMOP_MNEMONIC2(RM_MEM, MOVLPD, movlpd, Vq, Mq, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZE);
    13861368
     
    13991381        IEM_MC_ADVANCE_RIP();
    14001382        IEM_MC_END();
    1401     }
    1402     return VINF_SUCCESS;
     1383        return VINF_SUCCESS;
     1384    }
     1385
     1386    /**
     1387     * @opdone
     1388     * @opmnemonic  ud660f12m3
     1389     * @opcode      0x12
     1390     * @opcodesub   11 mr/reg
     1391     * @oppfx       0x66
     1392     * @opunused    immediate
     1393     * @opcpuid     sse
     1394     * @optest      ->
     1395     */
     1396    return IEMOP_RAISE_INVALID_OPCODE();
    14031397}
    14041398
  • trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-generated-1-data.py

    r66286 r66313  
    304304        for oOp in oInstr.aoOperands:
    305305            self.sEncoding     += '_' + oOp.sType;
     306        if oInstr.fUnused:
     307            if oInstr.sInvalidStyle == 'immediate' and oInstr.sSubOpcode:
     308                self.sEncoding += '_MOD_EQ_3' if oInstr.sSubOpcode == '11 mr/reg' else '_MOD_NE_3';
    306309
    307310        self.asFlags            = [];
    308311        if 'invalid_64' in oInstr.dHints:
    309             self.asFlags.append('BS3CG1INSTR_F_INVALID_64BIT')
     312            self.asFlags.append('BS3CG1INSTR_F_INVALID_64BIT');
     313        if oInstr.fUnused:
     314            self.asFlags.append('BS3CG1INSTR_F_UNUSED');
    310315
    311316        self.fAdvanceMnemonic   = True; ##< Set by the caller.
  • trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-generated-1-template.c

    r66309 r66313  
    15241524            break;
    15251525
     1526        case BS3CG1ENC_MODRM_MOD_EQ_3:
     1527            if (iEncoding < 8)
     1528            {
     1529                off = Bs3Cg1InsertReqPrefix(pThis, 0);
     1530                off = Bs3Cg1InsertOpcodes(pThis, off);
     1531                pThis->abCurInstr[off++] = X86_MODRM_MAKE(3, iEncoding, 1);
     1532            }
     1533            else if (iEncoding < 16)
     1534            {
     1535                off = Bs3Cg1InsertReqPrefix(pThis, 0);
     1536                off = Bs3Cg1InsertOpcodes(pThis, off);
     1537                pThis->abCurInstr[off++] = X86_MODRM_MAKE(3, 0, iEncoding);
     1538            }
     1539            else
     1540                break;
     1541            pThis->cbCurInstr = off;
     1542            iEncoding++;
     1543            break;
     1544
     1545        case BS3CG1ENC_MODRM_MOD_NE_3:
     1546            if (iEncoding < 3)
     1547            {
     1548                off = Bs3Cg1InsertReqPrefix(pThis, 0);
     1549                off = Bs3Cg1InsertOpcodes(pThis, off);
     1550                pThis->abCurInstr[off++] = X86_MODRM_MAKE(iEncoding, 0, 1);
     1551                if (iEncoding >= 1)
     1552                    pThis->abCurInstr[off++] = 0x7f;
     1553                if (iEncoding == 2)
     1554                {
     1555                    pThis->abCurInstr[off++] = 0x5f;
     1556                    if (!BS3_MODE_IS_16BIT_CODE(pThis->bMode))
     1557                    {
     1558                        pThis->abCurInstr[off++] = 0x3f;
     1559                        pThis->abCurInstr[off++] = 0x1f;
     1560                    }
     1561                }
     1562            }
     1563            else
     1564                break;
     1565            pThis->cbCurInstr = off;
     1566            iEncoding++;
     1567            break;
     1568
    15261569        default:
    15271570            Bs3TestFailedF("Internal error! BS3CG1ENC_XXX = %u not implemented", pThis->enmEncoding);
     
    16721715            pThis->aOperands[0].idxField    = BS3CG1DST_OZ_RAX;
    16731716            pThis->aOperands[1].idxField    = BS3CG1DST_INVALID;
     1717            break;
     1718
     1719        case BS3CG1ENC_MODRM_MOD_EQ_3:
     1720        case BS3CG1ENC_MODRM_MOD_NE_3:
     1721            /* Unused or invalid instructions mostly. */
    16741722            break;
    16751723
     
    29252973         * Check if the CPU supports the instruction.
    29262974         */
    2927         if (!Bs3Cg1CpuSetupFirst(pThis))
     2975        if (   !Bs3Cg1CpuSetupFirst(pThis)
     2976            || (pThis->fFlags & BS3CG1INSTR_F_UNUSED))
    29282977        {
    29292978            fInvalidInstr = true;
     
    30453094            if (!Bs3Cg1CpuSetupNext(pThis, iCpuSetup, &fInvalidInstr))
    30463095                break;
     3096            if (pThis->fFlags & BS3CG1INSTR_F_UNUSED)
     3097                fInvalidInstr = true;
     3098            if (fInvalidInstr)
     3099                bTestXcptExpected = X86_XCPT_UD;
    30473100        }
    30483101    }
  • trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-generated-1.h

    r66309 r66313  
    100100    BS3CG1ENC_FIXED_AL_Ib,
    101101    BS3CG1ENC_FIXED_rAX_Iz,
     102
     103    BS3CG1ENC_MODRM_MOD_EQ_3, /**< Unused or invalid instruction. */
     104    BS3CG1ENC_MODRM_MOD_NE_3, /**< Unused or invalid instruction. */
    102105
    103106    BS3CG1ENC_END
     
    198201    uint32_t    cOperands : 2;
    199202    /** The length of the mnemonic. */
    200     uint32_t    cchMnemonic : 3;
     203    uint32_t    cchMnemonic : 4;
    201204    /** Whether to advance the mnemonic array pointer. */
    202205    uint32_t    fAdvanceMnemonic : 1;
     
    212215    uint32_t    enmXcptType : 5;
    213216    /** Currently unused bits. */
    214     uint32_t    uUnused : 7;
     217    uint32_t    uUnused : 6;
    215218    /** BS3CG1INSTR_F_XXX. */
    216219    uint32_t    fFlags;
     
    227230/** Invalid instruction in 64-bit mode. */
    228231#define BS3CG1INSTR_F_INVALID_64BIT     UINT32_C(0x00000002)
     232/** Unused instruction. */
     233#define BS3CG1INSTR_F_UNUSED            UINT32_C(0x00000004)
    229234/** @} */
    230235
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