VirtualBox

Changeset 66286 in vbox


Ignore:
Timestamp:
Mar 28, 2017 10:17:15 AM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
114211
Message:

bs3-cpu-generated-1: 16 byte SSE alignment check.

Location:
trunk/src/VBox/ValidationKit/bootsectors
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-generated-1-data.py

    r66283 r66286  
    312312        if oInstr.sPrefix:
    313313            if oInstr.sPrefix == 'none':
    314                 self.sPfxKind = 'BS3CGPFXKIND_NO_F2_F3_66';
     314                self.sPfxKind = 'BS3CG1PFXKIND_NO_F2_F3_66';
    315315            else:
    316                 self.sPfxKind = 'BS3CGPFXKIND_REQ_' + oInstr.sPrefix[-2:].upper();
     316                self.sPfxKind = 'BS3CG1PFXKIND_REQ_' + oInstr.sPrefix[-2:].upper();
    317317        elif oInstr.sEncoding == 'ModR/M':
    318318            if 'ignores_op_size' not in oInstr.dHints:
    319                 self.sPfxKind   = 'BS3CGPFXKIND_MODRM';
     319                self.sPfxKind   = 'BS3CG1PFXKIND_MODRM';
    320320            else:
    321                 self.sPfxKind   = 'BS3CGPFXKIND_MODRM_NO_OP_SIZES';
     321                self.sPfxKind   = 'BS3CG1PFXKIND_MODRM_NO_OP_SIZES';
    322322        else:
    323323            self.sPfxKind       = '0';
     
    332332            self.sCpu += 'ANY';
    333333
     334        if oInstr.sXcptType:
     335            self.sXcptType = 'BS3CG1XCPTTYPE_' + oInstr.sXcptType.upper();
     336        else:
     337            self.sXcptType = 'BS3CG1XCPTTYPE_NONE';
    334338
    335339    def getOperands(self):
     
    348352            '        /* enmPrefixKind = */    (unsigned)%s,' % (self.sPfxKind,),
    349353            '        /* enmCpuTest = */       (unsigned)%s,' % (self.sCpu,),
     354            '        /* enmXcptType = */      (unsigned)%s,' % (self.sXcptType,),
    350355            '        /* uUnused = */          0,',
    351356            '        /* fFlags = */           %s' % (' | '.join(self.asFlags) if self.asFlags else '0'),
  • trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-generated-1-template.c

    r66283 r66286  
    123123    BS3CG1CPU               enmCpuTest;
    124124    /** Prefix sensitivity and requirements. */
    125     BS3CGPFXKIND            enmPrefixKind;
     125    BS3CG1PFXKIND           enmPrefixKind;
     126    /** Exception type (SSE, AVX). */
     127    BS3CG1XCPTTYPE          enmXcptType;
    126128    /** Per operand flags. */
    127129    BS3CG1OP                aenmOperands[4];
     
    224226    uint8_t                 bValueXcpt;
    225227    /** @} */
     228    /** Alignment exception expected by the encoder.
     229     * UINT8_MAX if no special exception expected. */
     230    uint8_t                 bAlignmentXcpt;
    226231
    227232    /** The context we're working on. */
     
    918923};
    919924
    920 static const uint16_t g_afPfxKindToIgnoredFlags[BS3CGPFXKIND_END] =
     925static const uint16_t g_afPfxKindToIgnoredFlags[BS3CG1PFXKIND_END] =
    921926{
    922     /* [BS3CGPFXKIND_INVALID] = */              UINT16_MAX,
    923     /* [BS3CGPFXKIND_MODRM] = */                0,
    924     /* [BS3CGPFXKIND_MODRM_NO_OP_SIZES] = */    BS3CG1_PF_OZ | BS3CG1_PF_W,
     927    /* [BS3CG1PFXKIND_INVALID] = */              UINT16_MAX,
     928    /* [BS3CG1PFXKIND_MODRM] = */                0,
     929    /* [BS3CG1PFXKIND_MODRM_NO_OP_SIZES] = */    BS3CG1_PF_OZ | BS3CG1_PF_W,
    925930};
    926931
    927932#endif
     933
     934
     935/**
     936 * Checks if >= 16 byte SSE/AVX alignment are exempted for the exception type.
     937 *
     938 * @returns true / false.
     939 * @param   enmXcptType         The type to check.
     940 */
     941static bool Bs3Cg1XcptTypeIsUnaligned(BS3CG1XCPTTYPE enmXcptType)
     942{
     943    switch (enmXcptType)
     944    {
     945        case BS3CG1XCPTTYPE_4UA:
     946        case BS3CG1XCPTTYPE_5:
     947            return true;
     948        default:
     949            return false;
     950    }
     951}
    928952
    929953
     
    932956    switch (pThis->enmPrefixKind)
    933957    {
    934         case BS3CGPFXKIND_REQ_66:
     958        case BS3CG1PFXKIND_REQ_66:
    935959            pThis->abCurInstr[offDst] = 0x66;
    936960            break;
    937         case BS3CGPFXKIND_REQ_F2:
     961        case BS3CG1PFXKIND_REQ_F2:
    938962            pThis->abCurInstr[offDst] = 0xf2;
    939963            break;
    940         case BS3CGPFXKIND_REQ_F3:
     964        case BS3CG1PFXKIND_REQ_F3:
    941965            pThis->abCurInstr[offDst] = 0xf3;
    942966            break;
     
    10531077    unsigned off;
    10541078    unsigned cbOp;
     1079
     1080    pThis->bAlignmentXcpt = UINT8_MAX;
     1081
    10551082    switch (pThis->enmEncoding)
    10561083    {
     
    12271254                off = Bs3Cfg1EncodeMemMod0Disp(pThis, false, off, 2 /*iReg*/, 16, 0, BS3CG1OPLOC_MEM_RW);
    12281255            }
    1229             //else if (iEncoding == 2)
    1230             //{
    1231             //    pThis->aOperands[pThis->iRegOp].idxField = BS3CG1DST_XMM3;
    1232             //    off = Bs3Cg1InsertOpcodes(pThis, Bs3Cg1InsertReqPrefix(pThis, 0));
    1233             //    off = Bs3Cfg1EncodeMemMod0Disp(pThis, false, off, 3 /*iReg*/, 16, 1 /*cbMissalign*/, BS3CG1OPLOC_MEM_RW);
    1234             //}
     1256            else if (iEncoding == 2)
     1257            {
     1258                pThis->aOperands[pThis->iRegOp].idxField = BS3CG1DST_XMM3;
     1259                off = Bs3Cg1InsertOpcodes(pThis, Bs3Cg1InsertReqPrefix(pThis, 0));
     1260                off = Bs3Cfg1EncodeMemMod0Disp(pThis, false, off, 3 /*iReg*/, 16, 1 /*cbMissalign*/, BS3CG1OPLOC_MEM_RW);
     1261                if (!Bs3Cg1XcptTypeIsUnaligned(pThis->enmXcptType))
     1262                    pThis->bAlignmentXcpt = X86_XCPT_GP;
     1263            }
    12351264            else
    12361265                break;
     
    21842213    if (!fInvalidInstr)
    21852214    {
    2186         bExpectedXcpt = pThis->bValueXcpt;
     2215        bExpectedXcpt = pThis->bAlignmentXcpt;
     2216        if (bExpectedXcpt == UINT8_MAX)
     2217            bExpectedXcpt = pThis->bValueXcpt;
    21872218        if (bExpectedXcpt == UINT8_MAX)
    21882219        {
     
    27062737        pThis->enmEncoding     = (BS3CG1ENC)pInstr->enmEncoding;
    27072738        pThis->enmCpuTest      = (BS3CG1CPU)pInstr->enmCpuTest;
    2708         pThis->enmPrefixKind   = (BS3CG1CPU)pInstr->enmPrefixKind;
     2739        pThis->enmPrefixKind   = (BS3CG1PFXKIND)pInstr->enmPrefixKind;
     2740        pThis->enmXcptType     = (BS3CG1XCPTTYPE)pInstr->enmXcptType;
    27092741        pThis->cchMnemonic     = pInstr->cchMnemonic;
    27102742        if (pThis->fAdvanceMnemonic)
  • trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-generated-1.h

    r66283 r66286  
    9696 * Prefix sensitivitiy kind.
    9797 */
    98 typedef enum BS3CGPFXKIND
    99 {
    100     BS3CGPFXKIND_INVALID = 0,
    101 
    102     BS3CGPFXKIND_NO_F2_F3_66,           /**< No 66, F2 or F3 prefixes allowed as that would alter the meaning. */
    103     BS3CGPFXKIND_REQ_F2,                /**< Requires F2 (REPNE) prefix as part of the instr encoding. */
    104     BS3CGPFXKIND_REQ_F3,                /**< Requires F3 (REPE) prefix as part of the instr encoding. */
    105     BS3CGPFXKIND_REQ_66,                /**< Requires 66 (OP SIZE) prefix as part of the instr encoding.  */
     98typedef enum BS3CG1PFXKIND
     99{
     100    BS3CG1PFXKIND_INVALID = 0,
     101
     102    BS3CG1PFXKIND_NO_F2_F3_66,           /**< No 66, F2 or F3 prefixes allowed as that would alter the meaning. */
     103    BS3CG1PFXKIND_REQ_F2,                /**< Requires F2 (REPNE) prefix as part of the instr encoding. */
     104    BS3CG1PFXKIND_REQ_F3,                /**< Requires F3 (REPE) prefix as part of the instr encoding. */
     105    BS3CG1PFXKIND_REQ_66,                /**< Requires 66 (OP SIZE) prefix as part of the instr encoding.  */
    106106
    107107    /** @todo more work to be done here...   */
    108     BS3CGPFXKIND_MODRM,
    109     BS3CGPFXKIND_MODRM_NO_OP_SIZES,
    110 
    111     BS3CGPFXKIND_END
    112 } BS3CGPFXKIND;
     108    BS3CG1PFXKIND_MODRM,
     109    BS3CG1PFXKIND_MODRM_NO_OP_SIZES,
     110
     111    BS3CG1PFXKIND_END
     112} BS3CG1PFXKIND;
    113113
    114114/**
     
    132132    BS3CG1CPU_END
    133133} BS3CG1CPU;
     134
     135
     136/**
     137 * SSE & AVX exception types.
     138 */
     139typedef enum BS3CG1XCPTTYPE
     140{
     141    BS3CG1XCPTTYPE_NONE = 0,
     142    /* SSE: */
     143    BS3CG1XCPTTYPE_1,
     144    BS3CG1XCPTTYPE_2,
     145    BS3CG1XCPTTYPE_3,
     146    BS3CG1XCPTTYPE_4,
     147    BS3CG1XCPTTYPE_4UA,
     148    BS3CG1XCPTTYPE_5,
     149    BS3CG1XCPTTYPE_6,
     150    BS3CG1XCPTTYPE_7,
     151    BS3CG1XCPTTYPE_8,
     152    BS3CG1XCPTTYPE_11,
     153    BS3CG1XCPTTYPE_12,
     154    /* EVEX: */
     155    BS3CG1XCPTTYPE_E1,
     156    BS3CG1XCPTTYPE_E1NF,
     157    BS3CG1XCPTTYPE_E2,
     158    BS3CG1XCPTTYPE_E3,
     159    BS3CG1XCPTTYPE_E3NF,
     160    BS3CG1XCPTTYPE_E4,
     161    BS3CG1XCPTTYPE_E4NF,
     162    BS3CG1XCPTTYPE_E5,
     163    BS3CG1XCPTTYPE_E5NF,
     164    BS3CG1XCPTTYPE_E6,
     165    BS3CG1XCPTTYPE_E6NF,
     166    BS3CG1XCPTTYPE_E7NF,
     167    BS3CG1XCPTTYPE_E9,
     168    BS3CG1XCPTTYPE_E9NF,
     169    BS3CG1XCPTTYPE_E10,
     170    BS3CG1XCPTTYPE_E11,
     171    BS3CG1XCPTTYPE_E12,
     172    BS3CG1XCPTTYPE_E12NF,
     173    BS3CG1XCPTTYPE_END
     174} BS3CG1XCPTTYPE;
     175AssertCompile(BS3CG1XCPTTYPE_END <= 32);
     176
    134177
    135178/**
     
    150193    /** BS3CG1ENC values. */
    151194    uint32_t    enmEncoding : 10;
    152     /** BS3CGPFXKIND values. */
     195    /** BS3CG1PFXKIND values. */
    153196    uint32_t    enmPrefixKind : 4;
    154197    /** CPU test / CPU ID bit test (BS3CG1CPU). */
    155198    uint32_t    enmCpuTest : 6;
     199    /** Exception type (BS3CG1XCPTTYPE)   */
     200    uint32_t    enmXcptType : 5;
    156201    /** Currently unused bits. */
    157     uint32_t    uUnused : 12;
     202    uint32_t    uUnused : 7;
    158203    /** BS3CG1INSTR_F_XXX. */
    159204    uint32_t    fFlags;
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