VirtualBox

Changeset 66334 in vbox


Ignore:
Timestamp:
Mar 29, 2017 2:26:23 PM (8 years ago)
Author:
vboxsync
Message:

IEM: Fixed UD1 / grp 10 decoding (intel eats modr/m after it).

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/disopcode.h

    r66331 r66334  
    690690    OP_PAVGUSB,
    691691    OP_PFNACC,
     692/** @}  */
    692693    OP_ROL,
    693694    OP_ROR,
     
    734735    OP_MOV_TR,
    735736    OP_SWAPGS,
    736 /** @}  */
     737    OP_UD1,
     738    OP_UD2,
    737739/** @name VT-x instructions
    738 * @{ */
     740 * @{ */
    739741    OP_VMREAD,
    740742    OP_VMWRITE,
  • trunk/src/VBox/VMM/Makefile.kmk

    r66125 r66334  
    357357        $(QUIET)$(MKDIR) -p -- "$(dir $@)"
    358358        $(QUIET)$(SED) \
    359                 -e '/IEMOP_MNEMONIC[01234]*(/!d' \
    360                -e 's/^.*IEMOP_MNEMONIC\([01234]*\)(/IEM_DO_INSTR_STAT\1(/' \
     359                -e '/IEMOP_MNEMONIC\(\|[01234]\|[01234]EX\)(/!d' \
     360               -e 's/^.*IEMOP_MNEMONIC\(\|[01234]\|[01234]EX\)(/IEM_DO_INSTR_STAT\1(/' \
    361361               -e 's/;.*$(DOLLAR)//' \
    362362                --output "[email protected]" $(filter %.cpp.h,$^)
     
    384384                '#undef IEM_DO_INSTR_STAT3' \
    385385                '#undef IEM_DO_INSTR_STAT4' \
     386                '#undef IEM_DO_INSTR_STAT0EX' \
     387                '#undef IEM_DO_INSTR_STAT1EX' \
     388                '#undef IEM_DO_INSTR_STAT2EX' \
     389                '#undef IEM_DO_INSTR_STAT3EX' \
     390                '#undef IEM_DO_INSTR_STAT4EX' \
    386391               ''
    387392        $(QUIET)$(RM) -f -- "[email protected]" "[email protected]"
    388393        $(QUIET)$(CP) -v -f --changed -- "$@" "$(patsubst %.ts,%,$@)"
    389394
     395foobar: $$(VBoxVMM_0_OUTDIR)/CommonGenIncs/IEMInstructionStatisticsTmpl.h
    390396
    391397if "$(KBUILD_TARGET)" == "win" && !defined(VBOX_ONLY_EXTPACKS_USE_IMPLIBS)
  • trunk/src/VBox/VMM/VMMAll/IEMAllInstructionsPython.py

    r66331 r66334  
    448448        'byte':     [ 256, ], ##< next opcode byte selects the instruction (default).
    449449        '/r':       [   8, ], ##< modrm.reg selects the instruction.
     450        'memreg /r':[  16, ], ##< modrm.reg and (modrm.mod == 3) selects the instruction.
    450451        'mod /r':   [  32, ], ##< modrm.reg and modrm.mod selects the instruction.
    451452        '!11 /r':   [   8, ], ##< modrm.reg selects the instruction with modrm.mod != 0y11.
     
    494495        if self.sSelector == 'mod /r':
    495496            return (bOpcode >> 3) & 0x1f;
     497
     498        if self.sSelector == 'memreg /r':
     499            return ((bOpcode >> 3) & 0x7) | (int((bOpcode >> 6) == 3) << 3);
    496500
    497501        if self.sSelector == '!11 /r':
     
    12071211    'grp13':        InstructionMap('grp13',     asLeadOpcodes = ['0x0f', '0x72',], sSelector = 'mod /r'),
    12081212    'grp14':        InstructionMap('grp14',     asLeadOpcodes = ['0x0f', '0x73',], sSelector = 'mod /r'),
    1209     'grp15':        InstructionMap('grp15',     asLeadOpcodes = ['0x0f', '0xae',], sSelector = 'mod /r'),
     1213    'grp15':        InstructionMap('grp15',     asLeadOpcodes = ['0x0f', '0xae',], sSelector = 'memreg /r'),
    12101214    'grp16':        InstructionMap('grp16',     asLeadOpcodes = ['0x0f', '0x18',], sSelector = 'mod /r'),
    12111215    'grpA17':       InstructionMap('grpA17',    asLeadOpcodes = ['0x0f', '0x78',], sSelector = '/r'), # AMD: EXTRQ weirdness
  • trunk/src/VBox/VMM/VMMAll/IEMAllInstructionsTwoByte0f.cpp.h

    r66332 r66334  
    65556555
    65566556
    6557 /** Opcode 0x0f 0xb9. */
     6557/**
     6558 * @opcode      0xb9
     6559 * @opinvalid   intel-modrm
     6560 * @optest      op1=1 op2=2 ->
     6561 * @oponlytest
     6562 */
    65586563FNIEMOP_DEF(iemOp_Grp10)
    65596564{
    6560     Log(("iemOp_Grp10 -> #UD\n"));
    6561     return IEMOP_RAISE_INVALID_OPCODE();
     6565    /*
     6566     * AMD does not decode beyond the 0xb9 whereas intel does the modr/m bit
     6567     * too. See bs3-cpu-decoder-1.c32.  So, we can forward to iemOp_InvalidNeedRM.
     6568     */
     6569    /** @todo fix bs3-cpu-generated-1 to deal with this on AMD! */
     6570    Log(("iemOp_Grp10 aka UD1 -> #UD\n"));
     6571    IEMOP_MNEMONIC2EX(ud1, "ud1", RM, UD1, ud1, Gb, Eb, DISOPTYPE_INVALID, IEMOPHINT_IGNORES_OP_SIZE); /* just picked Gb,Eb here. */
     6572    return FNIEMOP_CALL(iemOp_InvalidNeedRM);
    65626573}
    65636574
  • trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-decoding-1.c32

    r66331 r66334  
    355355
    356356#define UD_T_EXACT          0
     357#define UD_T_NOAMD          0x80        /**< AMD does not decode unnecessary bytes, Intel does. */
    357358#define UD_T_MODRM          1
    358359#define UD_T_MODRM_I8       2
     
    397398CPUDECODE1UDTST const g_aUdTest2Byte_0f[] =
    398399{
    399 #if 1
     400#if 0
    400401    {  UD_T_EXACT, 2, { 0x0f, 0x04 }, UD_F_ANY_PFX },
    401402    {  UD_T_EXACT, 2, { 0x0f, 0x0a }, UD_F_ANY_PFX },
     
    508509    {  UD_T_MODRM_RR7, 2, { 0x0f, 0xae }, UD_F_NOT_NO_PFX }, /* 00=sfence */
    509510    {  UD_T_MODRM, 2, { 0x0f, 0xb8 }, UD_F_NOT_RN_PFX },
     511#endif
     512    {  UD_T_MODRM | UD_T_NOAMD, 2, { 0x0f, 0xb9 }, UD_F_ANY_PFX }, /* UD1 */
     513#if 0
    510514    /** @todo f3 0f bb rm and f2 0f bb rm does stuff on skylake even if their are blank in intel and AMD tables! */
    511515    //{  UD_T_MODRM, 2, { 0x0f, 0xbb }, UD_F_NOT_NO_PFX | UD_F_NOT_OZ_PFX },
     
    843847void DecodeUdEdgeTest(PCCPUDECODE1UDTST paTests, unsigned cTests)
    844848{
     849    uint8_t BS3_FAR *pbPages;
     850
     851    /*
     852     * Detect AMD.
     853     */
     854    bool fIsAmd = false;
     855    if (g_uBs3CpuDetected & BS3CPU_F_CPUID)
     856        fIsAmd = ASMIsAmdCpu();
     857    Bs3TestPrintf("fIsAmd=%d\n", fIsAmd);
     858
    845859    /*
    846860     * Allocate and initialize a page pair
    847861     */
    848     uint8_t BS3_FAR *pbPages;
    849862    pbPages  = Bs3MemGuardedTestPageAlloc(BS3MEMKIND_FLAT32);
    850863    if (pbPages)
     
    10241037            {
    10251038                case UD_T_EXACT:
     1039                l_case_exact:
    10261040                    cSuffixes   = RT_ELEMENTS(s_aExact);
    10271041                    paSuffixes  = s_aExact;
    10281042                    break;
     1043                case UD_T_MODRM | UD_T_NOAMD:
     1044                    if (fIsAmd)
     1045                        goto l_case_exact;
    10291046                case UD_T_MODRM:
    10301047                    cSuffixes   = RT_ELEMENTS(s_aModRm);
     
    15571574    Bs3TestPrintf("g_uBs3CpuDetected=%#x\n", g_uBs3CpuDetected);
    15581575
     1576#if 1
    15591577    Bs3TestSub("CMPPS, CMPPD, CMPSS, CMPSD");
    15601578    DecodeCmppsCmppdCmpssCmpsd();
     
    15621580    Bs3TestSub("MOVBE vs CRC32");
    15631581    DecodeMovbeVsCrc32();
     1582#endif
    15641583
    15651584#if 1
     
    15721591#endif
    15731592
    1574 #if 0
     1593#if 1
    15751594    Bs3TestSub("misc");
    15761595    DecodeEdgeTest();
  • trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-generated-1-data.py

    r66313 r66334  
    313313        if oInstr.fUnused:
    314314            self.asFlags.append('BS3CG1INSTR_F_UNUSED');
     315        elif oInstr.fInvalid:
     316            self.asFlags.append('BS3CG1INSTR_F_INVALID');
    315317
    316318        self.fAdvanceMnemonic   = True; ##< Set by the caller.
  • trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-generated-1-template.c

    r66331 r66334  
    31283128         */
    31293129        if (   !Bs3Cg1CpuSetupFirst(pThis)
    3130             || (pThis->fFlags & BS3CG1INSTR_F_UNUSED))
     3130            || (pThis->fFlags & (BS3CG1INSTR_F_UNUSED | BS3CG1INSTR_F_INVALID)))
    31313131        {
    31323132            fInvalidInstr = true;
     
    32503250            if (!Bs3Cg1CpuSetupNext(pThis, iCpuSetup, &fInvalidInstr))
    32513251                break;
    3252             if (pThis->fFlags & BS3CG1INSTR_F_UNUSED)
     3252            if (pThis->fFlags & (BS3CG1INSTR_F_UNUSED | BS3CG1INSTR_F_INVALID))
    32533253                fInvalidInstr = true;
    32543254            if (fInvalidInstr)
  • trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-generated-1.h

    r66331 r66334  
    242242/** Unused instruction. */
    243243#define BS3CG1INSTR_F_UNUSED            UINT32_C(0x00000004)
     244/** Invalid instruction. */
     245#define BS3CG1INSTR_F_INVALID           UINT32_C(0x00000008)
    244246/** @} */
    245247
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/Makefile.kmk

    r66240 r66334  
    200200       ../../../Runtime/common/asm/ASMSerializeInstruction-rdtscp.asm \
    201201       ../../../Runtime/common/asm/ASMCpuIdExSlow.asm \
     202       ../../../Runtime/common/asm/ASMCpuId.asm \
    202203       ../../../Runtime/common/asm/ASMGetXcr0.asm \
    203204       ../../../Runtime/common/asm/ASMSetXcr0.asm \
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