VirtualBox

Changeset 66134 in vbox


Ignore:
Timestamp:
Mar 16, 2017 3:45:31 PM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
114037
Message:

bs3-cpu-generated-1: Deal with instructions not available in 64-bit mode (invalid) and fixed form instruction w/o any operands (e.g. AAA).

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

Legend:

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

    r66127 r66134  
    304304        for oOp in oInstr.aoOperands:
    305305            self.sEncoding     += '_' + oOp.sType;
     306
    306307        self.asFlags            = [];
     308        if 'invalid_64' in oInstr.dHints:
     309            self.asFlags.append('BS3CG1INSTR_F_INVALID_64BIT')
     310
    307311        self.fAdvanceMnemonic   = True; ##< Set by the caller.
    308312        if self.sEncoding == 'ModR/M':
     
    467471            '{',
    468472        ];
     473        cOperands = 0;
    469474        for oInstr in self.aoInstructions:
    470             asLines.append('    ' + oInstr.getOperands() + ',');
     475            if oInstr.oInstr.aoOperands:
     476                cOperands += len(oInstr.oInstr.aoOperands);
     477                asLines.append('    ' + oInstr.getOperands() + ', /* %s */' % (oInstr.oInstr.sStats,));
     478            else:
     479                asLines.append('    /* none */');
     480        if not cOperands:
     481            asLines.append('    0 /* dummy */');
    471482        asLines += [
    472483            '};',
  • TabularUnified trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-generated-1-template.c

    r66124 r66134  
    646646            break;
    647647
     648        case BS3CG1ENC_FIXED:
     649            if (iEncoding == 0)
     650            {
     651                off = Bs3Cg1InsertOpcodes(pThis, 0);
     652                pThis->cbCurInstr = off;
     653                iEncoding++;
     654            }
     655            break;
     656
    648657        case BS3CG1ENC_FIXED_AL_Ib:
    649658            if (iEncoding == 0)
     
    822831            pThis->aOperands[0].enmLocation = BS3CG1OPLOC_CTX;
    823832            pThis->aOperands[1].enmLocation = BS3CG1OPLOC_CTX;
     833            break;
     834
     835        case BS3CG1ENC_FIXED:
     836            /* nothing to do here */
    824837            break;
    825838
     
    12901303        unsigned iEncoding;
    12911304        unsigned iEncodingNext;
     1305        bool     fInvalidInstr = false;
     1306        uint8_t  bXcptExpected = BS3_MODE_IS_PAGED(bMode) ? X86_XCPT_PF : X86_XCPT_UD;
    12921307
    12931308        /*
     
    13221337        }
    13231338
     1339        if ((This.fFlags & BS3CG1INSTR_F_INVALID_64BIT) && BS3_MODE_IS_64BIT_CODE(bMode))
     1340        {
     1341            fInvalidInstr = true;
     1342            bXcptExpected = X86_XCPT_UD;
     1343        }
     1344
    13241345        /*
    13251346         * Prep the operands and encoding handling.
     
    13831404
    13841405                            /* Check the control exception result first. */
    1385                             if (   This.TrapFrame.bXcpt     == (BS3_MODE_IS_PAGED(bMode) ? X86_XCPT_PF : X86_XCPT_UD)
    1386                                 && This.TrapFrame.Ctx.rip.u == This.Ctx.rip.u + This.cbCurInstr)
     1406                            if (   This.TrapFrame.bXcpt     == bXcptExpected
     1407                                && This.TrapFrame.Ctx.rip.u == This.Ctx.rip.u + (!fInvalidInstr ? This.cbCurInstr : 0))
    13871408                            {
    13881409                                /* Apply output modifications and compare the contexts. */
    1389                                 if (BS3_MODE_IS_PAGED(bMode))
     1410                                if (bXcptExpected == X86_XCPT_PF)
    13901411                                    This.Ctx.cr2.u = This.uCodePgFlat + X86_PAGE_SIZE;
    13911412                                This.Ctx.rflags.u32 &= ~X86_EFL_RF;
    13921413                                This.Ctx.rflags.u32 |= This.TrapFrame.Ctx.rflags.u32 & X86_EFL_RF;
    1393                                 if (Bs3Cg1RunContextModifier(&This, &This.Ctx, pHdr,
    1394                                                              pHdr->cbSelector + pHdr->cbInput, pHdr->cbOutput,
    1395                                                              &This.TrapFrame.Ctx, NULL /*pbCode*/))
     1414                                if (   fInvalidInstr
     1415                                    || Bs3Cg1RunContextModifier(&This, &This.Ctx, pHdr,
     1416                                                                pHdr->cbSelector + pHdr->cbInput, pHdr->cbOutput,
     1417                                                                &This.TrapFrame.Ctx, NULL /*pbCode*/))
    13961418                                {
    1397                                     if (!Bs3TestCheckRegCtxEx(&This.TrapFrame.Ctx, &This.Ctx, This.cbCurInstr,  0 /*cbSpAdjust*/,
     1419                                    if (!Bs3TestCheckRegCtxEx(&This.TrapFrame.Ctx, &This.Ctx,
     1420                                                              !fInvalidInstr ? This.cbCurInstr : 0,  0 /*cbSpAdjust*/,
    13981421                                                              0 /*fExtraEfl*/, pszMode, iEncoding))
    13991422                                        Bs3TestFailedF("encoding#%u: %.*Rhxs", iEncoding, This.cbCurInstr, This.abCurInstr);
     
    14021425                            else
    14031426                            {
    1404                                 Bs3TestFailedF("bXcpt=%#x expected %#x; rip=%RX64 expected %RX64; encoding#u: %.*Rhxs",
    1405                                                This.TrapFrame.bXcpt, BS3_MODE_IS_PAGED(bMode) ? X86_XCPT_PF : X86_XCPT_UD,
    1406                                                This.TrapFrame.Ctx.rip.u, This.Ctx.rip.u + This.cbCurInstr,
     1427                                Bs3TestFailedF("bXcpt=%#x expected %#x; rip=%RX64 expected %RX64; encoding#%u: %.*Rhxs",
     1428                                               This.TrapFrame.bXcpt, bXcptExpected,
     1429                                               This.TrapFrame.Ctx.rip.u, This.Ctx.rip.u + (!fInvalidInstr ? This.cbCurInstr : 0),
    14071430                                               iEncoding, This.cbCurInstr, This.abCurInstr);
    14081431                            }
  • TabularUnified trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-generated-1.h

    r66116 r66134  
    7676    BS3CG1ENC_MODRM_Gv_Ev,
    7777
     78    BS3CG1ENC_FIXED,
    7879    BS3CG1ENC_FIXED_AL_Ib,
    7980    BS3CG1ENC_FIXED_rAX_Iz,
     
    130131/** Defaults to SS rather than DS. */
    131132#define BS3CG1INSTR_F_DEF_SS            UINT32_C(0x00000001)
     133/** Invalid instruction in 64-bit mode. */
     134#define BS3CG1INSTR_F_INVALID_64BIT     UINT32_C(0x00000002)
    132135/** @} */
    133136
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