Changeset 66342 in vbox
- Timestamp:
- Mar 29, 2017 4:22:31 PM (8 years ago)
- svn:sync-xref-src-repo-rev:
- 114278
- Location:
- trunk/src/VBox
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/IEMAllInstructionsTwoByte0f.cpp.h
r66336 r66342 7372 7372 } 7373 7373 7374 FNIEMOP_DEF_1(iemOp_Grp9_cmpxchg8bOr16b, uint8_t, bRm) 7375 { 7376 if (pVCpu->iem.s.fPrefixes & IEM_OP_PRF_SIZE_REX_W) 7377 return FNIEMOP_CALL_1(iemOp_Grp9_cmpxchg16b_Mdq, bRm); 7378 return FNIEMOP_CALL_1(iemOp_Grp9_cmpxchg8b_Mq, bRm); 7379 } 7374 7380 7375 7381 /** Opcode 0x0f 0xc7 11/6. */ … … 7388 7394 FNIEMOP_UD_STUB_1(iemOp_Grp9_vmptrst_Mq, uint8_t, bRm); 7389 7395 7396 /** Opcode 0x0f 0xc7 11/7. */ 7397 FNIEMOP_UD_STUB_1(iemOp_Grp9_rdseed_Rv, uint8_t, bRm); 7398 7399 7400 /** 7401 * Group 9 jump table for register variant. 7402 */ 7403 IEM_STATIC const PFNIEMOPRM g_apfnGroup9RegReg[] = 7404 { /* pfx: none, 066h, 0f3h, 0f2h */ 7405 /* /0 */ IEMOP_X4(iemOp_InvalidWithRM), 7406 /* /1 */ IEMOP_X4(iemOp_InvalidWithRM), 7407 /* /2 */ IEMOP_X4(iemOp_InvalidWithRM), 7408 /* /3 */ IEMOP_X4(iemOp_InvalidWithRM), 7409 /* /4 */ IEMOP_X4(iemOp_InvalidWithRM), 7410 /* /5 */ IEMOP_X4(iemOp_InvalidWithRM), 7411 /* /6 */ iemOp_Grp9_rdrand_Rv, iemOp_Grp9_rdrand_Rv, iemOp_InvalidWithRM, iemOp_InvalidWithRM, 7412 /* /7 */ iemOp_Grp9_rdseed_Rv, iemOp_Grp9_rdseed_Rv, iemOp_InvalidWithRM, iemOp_InvalidWithRM, 7413 }; 7414 AssertCompile(RT_ELEMENTS(g_apfnGroup9RegReg) == 8*4); 7415 7416 7417 /** 7418 * Group 9 jump table for memory variant. 7419 */ 7420 IEM_STATIC const PFNIEMOPRM g_apfnGroup9MemReg[] = 7421 { /* pfx: none, 066h, 0f3h, 0f2h */ 7422 /* /0 */ IEMOP_X4(iemOp_InvalidWithRM), 7423 /* /1 */ iemOp_Grp9_cmpxchg8bOr16b, iemOp_Grp9_cmpxchg8bOr16b, iemOp_Grp9_cmpxchg8bOr16b, iemOp_Grp9_cmpxchg8bOr16b, /* see bs3-cpu-decoding-1 */ 7424 /* /2 */ IEMOP_X4(iemOp_InvalidWithRM), 7425 /* /3 */ IEMOP_X4(iemOp_InvalidWithRM), 7426 /* /4 */ IEMOP_X4(iemOp_InvalidWithRM), 7427 /* /5 */ IEMOP_X4(iemOp_InvalidWithRM), 7428 /* /6 */ iemOp_Grp9_vmptrld_Mq, iemOp_Grp9_vmclear_Mq, iemOp_Grp9_vmxon_Mq, iemOp_InvalidWithRM, 7429 /* /7 */ iemOp_Grp9_vmptrst_Mq, iemOp_InvalidWithRM, iemOp_InvalidWithRM, iemOp_InvalidWithRM, 7430 }; 7431 AssertCompile(RT_ELEMENTS(g_apfnGroup9MemReg) == 8*4); 7432 7390 7433 7391 7434 /** Opcode 0x0f 0xc7. */ 7392 7435 FNIEMOP_DEF(iemOp_Grp9) 7393 7436 { 7394 /** @todo Testcase: Check mixing 0x66 and 0xf3. Check the effect of 0xf2. */ 7395 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm); 7396 switch ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) 7397 { 7398 case 0: case 2: case 3: case 4: case 5: 7399 return IEMOP_RAISE_INVALID_OPCODE(); 7400 case 1: 7401 /** @todo Testcase: Check prefix effects on cmpxchg8b/16b. */ 7402 if ( (bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT) 7403 || (pVCpu->iem.s.fPrefixes & (IEM_OP_PRF_SIZE_OP | IEM_OP_PRF_REPZ))) /** @todo Testcase: AMD seems to express a different idea here wrt prefixes. */ 7404 return IEMOP_RAISE_INVALID_OPCODE(); 7405 if (pVCpu->iem.s.fPrefixes & IEM_OP_PRF_SIZE_REX_W) 7406 return FNIEMOP_CALL_1(iemOp_Grp9_cmpxchg16b_Mdq, bRm); 7407 return FNIEMOP_CALL_1(iemOp_Grp9_cmpxchg8b_Mq, bRm); 7408 case 6: 7409 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT)) 7410 return FNIEMOP_CALL_1(iemOp_Grp9_rdrand_Rv, bRm); 7411 switch (pVCpu->iem.s.fPrefixes & (IEM_OP_PRF_SIZE_OP | IEM_OP_PRF_REPZ)) 7412 { 7413 case 0: 7414 return FNIEMOP_CALL_1(iemOp_Grp9_vmptrld_Mq, bRm); 7415 case IEM_OP_PRF_SIZE_OP: 7416 return FNIEMOP_CALL_1(iemOp_Grp9_vmclear_Mq, bRm); 7417 case IEM_OP_PRF_REPZ: 7418 return FNIEMOP_CALL_1(iemOp_Grp9_vmxon_Mq, bRm); 7419 default: 7420 return IEMOP_RAISE_INVALID_OPCODE(); 7421 } 7422 case 7: 7423 switch (pVCpu->iem.s.fPrefixes & (IEM_OP_PRF_SIZE_OP | IEM_OP_PRF_REPZ)) 7424 { 7425 case 0: 7426 case IEM_OP_PRF_REPZ: 7427 return FNIEMOP_CALL_1(iemOp_Grp9_vmptrst_Mq, bRm); 7428 default: 7429 return IEMOP_RAISE_INVALID_OPCODE(); 7430 } 7431 IEM_NOT_REACHED_DEFAULT_CASE_RET(); 7432 } 7437 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm); 7438 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT)) 7439 /* register, register */ 7440 return FNIEMOP_CALL_1(g_apfnGroup9RegReg[ ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) * 4 7441 + pVCpu->iem.s.idxPrefix], bRm); 7442 /* memory, register */ 7443 return FNIEMOP_CALL_1(g_apfnGroup9MemReg[ ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) * 4 7444 + pVCpu->iem.s.idxPrefix], bRm); 7433 7445 } 7434 7446 -
trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-decoding-1.c32
r66341 r66342 406 406 CPUDECODE1UDTST const g_aUdTest2Byte_0f[] = 407 407 { 408 #if 1408 #if 0 409 409 { UD_T_EXACT, 2, { 0x0f, 0x04 }, UD_F_ANY_PFX }, 410 410 { UD_T_EXACT, 2, { 0x0f, 0x0a }, UD_F_ANY_PFX }, … … 536 536 { UD_T_MODRM_MR0, 2, { 0x0f, 0xc7 }, UD_F_ANY_PFX }, 537 537 { UD_T_MODRM_RR0, 2, { 0x0f, 0xc7 }, UD_F_ANY_PFX }, 538 //{ UD_T_MODRM_MR1, 2, { 0x0f, 0xc7 }, xxxx }, - cmpxchg8b/16b is weird, needs special testcase.538 //{ UD_T_MODRM_MR1, 2, { 0x0f, 0xc7 }, UD_F_NOT_NO_PFX | UD_F_NOT_OZ_PFX | UD_F_NOT_RN_PFX | UD_F_NOT_RZ_PFX | UD_F_NOT_LK_PFX }, - cmpxchg8b ignores everything. @ 539 539 { UD_T_MODRM_RR1, 2, { 0x0f, 0xc7 }, UD_F_ANY_PFX }, 540 540 { UD_T_MODRM_MR2, 2, { 0x0f, 0xc7 }, UD_F_ANY_PFX }, … … 546 546 { UD_T_MODRM_MR5, 2, { 0x0f, 0xc7 }, UD_F_ANY_PFX }, 547 547 { UD_T_MODRM_RR5, 2, { 0x0f, 0xc7 }, UD_F_ANY_PFX }, 548 //{ UD_T_MODRM_MR0, 2, { 0x0f, 0xc7 }, UD_F_NOT_OZ_PFX | UD_F_NOT_RN_PFX | }, 549 { UD_T_MODRM_RR0, 2, { 0x0f, 0xc7 }, UD_F_ANY_PFX }, 550 #if 1 548 { UD_T_MODRM_MR6, 2, { 0x0f, 0xc7 }, UD_F_NOT_NO_PFX | UD_F_NOT_OZ_PFX | UD_F_NOT_RZ_PFX }, /* f2? */ 549 { UD_T_MODRM_RR6, 2, { 0x0f, 0xc7 }, UD_F_NOT_NO_PFX | UD_F_NOT_OZ_PFX }, /* (rdrand Rv) */ 550 { UD_T_MODRM_MR7, 2, { 0x0f, 0xc7 }, UD_F_NOT_NO_PFX }, /* vmptrst Mq (f2?); */ 551 { UD_T_MODRM_RR7, 2, { 0x0f, 0xc7 }, UD_F_NOT_NO_PFX | UD_F_NOT_OZ_PFX | UD_F_NOT_RZ_PFX }, /* rdrand Rv; rdpid Rd/q (f2,66??); */ 552 #if 0 551 553 { UD_T_MODRM, 2, { 0x0f, 0xd0 }, UD_F_NOT_OZ_PFX | UD_F_NOT_RN_PFX }, 552 554 { UD_T_MODRM, 2, { 0x0f, 0xd1 }, UD_F_NOT_NO_PFX | UD_F_NOT_OZ_PFX }, … … 1290 1292 1291 1293 1294 #if 0 1295 /** 1296 * Checks how prefixes affects cmpxchg8b and cmpxchg16b 1297 * 1298 * The thing here is that the intel opcode tables indicates that the 66 and f3 1299 * prefixes encodings are reserved and causes \#UD, where AMD doesn't. Seems 1300 * though that the f2, f3 and 66 prefixes are ignored on skylake intel. Need to 1301 * make sure this is the case, also in 64-bit mode and for the 16b version. 1302 */ 1303 static void DecodeCmpXchg8bVs16b(void) 1304 { 1305 uint8_t BS3_FAR *pbPages; 1306 1307 /* Check that the instructions are supported. */ 1308 if ( !(g_uBs3CpuDetected & BS3CPU_F_CPUID) 1309 || !(ASMCpuId_EDX(1) & X86_CPUID_FEATURE_EDX_CX8)) 1310 { 1311 Bs3TestSkipped("not supported"); 1312 return; 1313 } 1314 1315 /* Setup a guarded page. */ 1316 pbPages = Bs3MemGuardedTestPageAlloc(BS3MEMKIND_FLAT32); 1317 if (pbPages) 1318 { 1319 1320 Bs3MemGuardedTestPageFree(pbPages); 1321 } 1322 else 1323 Bs3TestFailed("Failed to allocate two pages!\n"); 1324 } 1325 #endif 1326 1327 1292 1328 /** 1293 1329 * Checks various prefix encodings with the MOVBE and CRC32 instructions to try … … 1661 1697 Bs3TestPrintf("g_uBs3CpuDetected=%#x\n", g_uBs3CpuDetected); 1662 1698 1663 #if 11699 #if 0 1664 1700 Bs3TestSub("CMPPS, CMPPD, CMPSS, CMPSD"); 1665 1701 DecodeCmppsCmppdCmpssCmpsd(); … … 1668 1704 DecodeMovbeVsCrc32(); 1669 1705 #endif 1706 1707 //Bs3TestSub("CMPXCHG8B/16B"); 1708 //DecodeCmpXchg8bVs16b(); 1670 1709 1671 1710 #if 1 … … 1673 1712 DecodeUdEdgeTest(g_aUdTest2Byte_0f, RT_ELEMENTS(g_aUdTest2Byte_0f)); 1674 1713 #endif 1675 #if 11714 #if 0 1676 1715 Bs3TestSub("3 byte undefined opcodes 0f 38"); 1677 1716 DecodeUdEdgeTest(g_aUdTest3Byte_0f_38, RT_ELEMENTS(g_aUdTest3Byte_0f_38)); -
trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-instr-2-template.c
r65507 r66342 54 54 extern FNBS3FAR BS3_CMN_NM(bs3CpuInstr2_cmpxchg16b_rdi_ud2); 55 55 extern FNBS3FAR BS3_CMN_NM(bs3CpuInstr2_lock_cmpxchg16b_rdi_ud2); 56 extern FNBS3FAR BS3_CMN_NM(bs3CpuInstr2_o16_cmpxchg16b_rdi_ud2); 57 extern FNBS3FAR BS3_CMN_NM(bs3CpuInstr2_lock_o16_cmpxchg16b_rdi_ud2); 58 extern FNBS3FAR BS3_CMN_NM(bs3CpuInstr2_repz_cmpxchg16b_rdi_ud2); 59 extern FNBS3FAR BS3_CMN_NM(bs3CpuInstr2_lock_repz_cmpxchg16b_rdi_ud2); 60 extern FNBS3FAR BS3_CMN_NM(bs3CpuInstr2_repnz_cmpxchg16b_rdi_ud2); 61 extern FNBS3FAR BS3_CMN_NM(bs3CpuInstr2_lock_repnz_cmpxchg16b_rdi_ud2); 56 62 # endif 57 63 #endif … … 550 556 PRTUINT128U pau128 = RT_ALIGN_PT(&au128[0], sizeof(RTUINT128U), PRTUINT128U); 551 557 bool const fSupportCX16 = RT_BOOL(ASMCpuId_ECX(1) & X86_CPUID_FEATURE_ECX_CX16); 552 unsigned iLocked;553 558 unsigned iFlags; 554 559 unsigned offBuf; 555 560 unsigned iMatch; 561 unsigned iWorker; 562 static struct 563 { 564 bool fLocked; 565 uint8_t offUd2; 566 FNBS3FAR *pfnWorker; 567 } const s_aWorkers[] = 568 { 569 { false, 4, BS3_CMN_NM(bs3CpuInstr2_cmpxchg16b_rdi_ud2) }, 570 { false, 5, BS3_CMN_NM(bs3CpuInstr2_o16_cmpxchg16b_rdi_ud2) }, 571 { false, 5, BS3_CMN_NM(bs3CpuInstr2_repz_cmpxchg16b_rdi_ud2) }, 572 { false, 5, BS3_CMN_NM(bs3CpuInstr2_repnz_cmpxchg16b_rdi_ud2) }, 573 { true, 1+4, BS3_CMN_NM(bs3CpuInstr2_lock_cmpxchg16b_rdi_ud2) }, 574 { true, 1+5, BS3_CMN_NM(bs3CpuInstr2_lock_o16_cmpxchg16b_rdi_ud2) }, 575 { true, 1+5, BS3_CMN_NM(bs3CpuInstr2_lock_repz_cmpxchg16b_rdi_ud2) }, 576 { true, 1+5, BS3_CMN_NM(bs3CpuInstr2_lock_repnz_cmpxchg16b_rdi_ud2) }, 577 }; 556 578 557 579 /* Ensure the structures are allocated before we sample the stack pointer. */ … … 572 594 */ 573 595 g_usBs3TestStep = 0; 574 Bs3RegCtxSetRipCsFromCurPtr(&Ctx, BS3_CMN_NM(bs3CpuInstr2_cmpxchg16b_rdi_ud2)); 575 for (iLocked = 0; iLocked < 2; iLocked++) 576 { 596 for (iWorker = 0; iWorker < RT_ELEMENTS(s_aWorkers); iWorker++) 597 { 598 Bs3RegCtxSetRipCsFromCurPtr(&Ctx, s_aWorkers[iWorker].pfnWorker); 599 577 600 /* 578 601 * One loop with all status flags set, and one with them clear. … … 604 627 Bs3TrapSetJmpAndRestore(&Ctx, &TrapFrame); 605 628 g_usBs3TestStep++; 606 //Bs3TestPrintf("Test: iFlags=%d offBuf=%d iMatch=%u \n", iFlags, offBuf, iMatch);629 //Bs3TestPrintf("Test: iFlags=%d offBuf=%d iMatch=%u iWorker=%u\n", iFlags, offBuf, iMatch, iWorker); 607 630 bExpectXcpt = X86_XCPT_UD; 608 631 if (fSupportCX16) … … 622 645 else 623 646 ExpectCtx.rflags.u32 = Ctx.rflags.u32 & ~X86_EFL_ZF; 624 ExpectCtx.rip.u = Ctx.rip.u + 4 + (iLocked & 1);647 ExpectCtx.rip.u = Ctx.rip.u + s_aWorkers[iWorker].offUd2; 625 648 } 626 649 ExpectCtx.rflags.u32 |= X86_EFL_RF; … … 632 655 if (TrapFrame.bXcpt != bExpectXcpt) 633 656 Bs3TestFailedF("Expected bXcpt=#%x, got %#x (%#x)", bExpectXcpt, TrapFrame.bXcpt, TrapFrame.uErrCd); 634 Bs3TestFailedF("^^^ i Locked=%d iFlags=%d offBuf=%d iMatch=%u\n", iLocked, iFlags, offBuf, iMatch);657 Bs3TestFailedF("^^^ iWorker=%d iFlags=%d offBuf=%d iMatch=%u\n", iWorker, iFlags, offBuf, iMatch); 635 658 ASMHalt(); 636 659 } … … 642 665 Ctx.rflags.u16 &= ~X86_EFL_STATUS_BITS; 643 666 } 644 Bs3RegCtxSetRipCsFromCurPtr(&Ctx, BS3_CMN_NM(bs3CpuInstr2_lock_cmpxchg16b_rdi_ud2));645 667 } 646 668 647 669 return 0; 648 649 670 } 650 671 # endif /* ARCH_BITS == 64 */ -
trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-instr-2-template.mac
r65507 r66342 101 101 AssertCompile(.again - BS3_LAST_LABEL == 5) 102 102 BS3_PROC_END_CMN bs3CpuInstr2_lock_cmpxchg16b_rdi_ud2 103 104 105 BS3_PROC_BEGIN_CMN bs3CpuInstr2_o16_cmpxchg16b_rdi_ud2, BS3_PBC_NEAR 106 o16 cmpxchg16b [rdi] 107 .again: 108 ud2 109 jmp .again 110 AssertCompile(.again - BS3_LAST_LABEL == 5) 111 BS3_PROC_END_CMN bs3CpuInstr2_o16_cmpxchg16b_rdi_ud2 112 113 114 BS3_PROC_BEGIN_CMN bs3CpuInstr2_lock_o16_cmpxchg16b_rdi_ud2, BS3_PBC_NEAR 115 db 0f0h, 066h 116 cmpxchg16b [rdi] 117 .again: 118 ud2 119 jmp .again 120 AssertCompile(.again - BS3_LAST_LABEL == 6) 121 BS3_PROC_END_CMN bs3CpuInstr2_lock_o16_cmpxchg16b_rdi_ud2 122 123 124 BS3_PROC_BEGIN_CMN bs3CpuInstr2_repz_cmpxchg16b_rdi_ud2, BS3_PBC_NEAR 125 repz cmpxchg16b [rdi] 126 .again: 127 ud2 128 jmp .again 129 AssertCompile(.again - BS3_LAST_LABEL == 5) 130 BS3_PROC_END_CMN bs3CpuInstr2_repz_cmpxchg16b_rdi_ud2 131 132 133 BS3_PROC_BEGIN_CMN bs3CpuInstr2_lock_repz_cmpxchg16b_rdi_ud2, BS3_PBC_NEAR 134 db 0f0h, 0f3h 135 cmpxchg16b [rdi] 136 .again: 137 ud2 138 jmp .again 139 AssertCompile(.again - BS3_LAST_LABEL == 6) 140 BS3_PROC_END_CMN bs3CpuInstr2_lock_repz_cmpxchg16b_rdi_ud2 141 142 BS3_PROC_BEGIN_CMN bs3CpuInstr2_repnz_cmpxchg16b_rdi_ud2, BS3_PBC_NEAR 143 repnz cmpxchg16b [rdi] 144 .again: 145 ud2 146 jmp .again 147 AssertCompile(.again - BS3_LAST_LABEL == 5) 148 BS3_PROC_END_CMN bs3CpuInstr2_repnz_cmpxchg16b_rdi_ud2 149 150 151 BS3_PROC_BEGIN_CMN bs3CpuInstr2_lock_repnz_cmpxchg16b_rdi_ud2, BS3_PBC_NEAR 152 db 0f0h, 0f2h 153 cmpxchg16b [rdi] 154 .again: 155 ud2 156 jmp .again 157 AssertCompile(.again - BS3_LAST_LABEL == 6) 158 BS3_PROC_END_CMN bs3CpuInstr2_lock_repnz_cmpxchg16b_rdi_ud2 159 160 ;; @todo figure out this fudge. sigh. 161 times (348) db 0cch ; fudge to avoid 'rderr' during boot. 162 103 163 %endif ; TMPL_BITS == 64 104 164
Note:
See TracChangeset
for help on using the changeset viewer.