Changeset 66342 in vbox for trunk/src/VBox/ValidationKit
- Timestamp:
- Mar 29, 2017 4:22:31 PM (8 years ago)
- svn:sync-xref-src-repo-rev:
- 114278
- Location:
- trunk/src/VBox/ValidationKit/bootsectors
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
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.