Changeset 65507 in vbox
- Timestamp:
- Jan 29, 2017 5:32:33 PM (8 years ago)
- Location:
- trunk/src/VBox/ValidationKit/bootsectors
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-instr-2-template.c
r64758 r65507 51 51 extern FNBS3FAR BS3_CMN_NM(bs3CpuInstr2_div_xBX_ud2); 52 52 extern FNBS3FAR BS3_CMN_NM(bs3CpuInstr2_idiv_xBX_ud2); 53 # if ARCH_BITS == 64 54 extern FNBS3FAR BS3_CMN_NM(bs3CpuInstr2_cmpxchg16b_rdi_ud2); 55 extern FNBS3FAR BS3_CMN_NM(bs3CpuInstr2_lock_cmpxchg16b_rdi_ud2); 56 # endif 53 57 #endif 54 58 … … 537 541 538 542 543 # if ARCH_BITS == 64 544 BS3_DECL_FAR(uint8_t) BS3_CMN_NM(bs3CpuInstr2_cmpxchg16b)(uint8_t bMode) 545 { 546 BS3REGCTX Ctx; 547 BS3REGCTX ExpectCtx; 548 BS3TRAPFRAME TrapFrame; 549 RTUINT128U au128[3]; 550 PRTUINT128U pau128 = RT_ALIGN_PT(&au128[0], sizeof(RTUINT128U), PRTUINT128U); 551 bool const fSupportCX16 = RT_BOOL(ASMCpuId_ECX(1) & X86_CPUID_FEATURE_ECX_CX16); 552 unsigned iLocked; 553 unsigned iFlags; 554 unsigned offBuf; 555 unsigned iMatch; 556 557 /* Ensure the structures are allocated before we sample the stack pointer. */ 558 Bs3MemSet(&Ctx, 0, sizeof(Ctx)); 559 Bs3MemSet(&ExpectCtx, 0, sizeof(ExpectCtx)); 560 Bs3MemSet(&TrapFrame, 0, sizeof(TrapFrame)); 561 Bs3MemSet(pau128, 0, sizeof(pau128[0]) * 2); 562 563 /* 564 * Create test context. 565 */ 566 Bs3RegCtxSaveEx(&Ctx, bMode, 512); 567 if (!fSupportCX16) 568 Bs3TestPrintf("Note! CMPXCHG16B is not supported by the CPU!\n"); 569 570 /* 571 * One loop with the normal variant and one with the locked one 572 */ 573 g_usBs3TestStep = 0; 574 Bs3RegCtxSetRipCsFromCurPtr(&Ctx, BS3_CMN_NM(bs3CpuInstr2_cmpxchg16b_rdi_ud2)); 575 for (iLocked = 0; iLocked < 2; iLocked++) 576 { 577 /* 578 * One loop with all status flags set, and one with them clear. 579 */ 580 Ctx.rflags.u16 |= X86_EFL_STATUS_BITS; 581 for (iFlags = 0; iFlags < 2; iFlags++) 582 { 583 Bs3MemCpy(&ExpectCtx, &Ctx, sizeof(ExpectCtx)); 584 585 for (offBuf = 0; offBuf < sizeof(RTUINT128U); offBuf++) 586 { 587 # define CX16_OLD_LO UINT64_C(0xabb6345dcc9c4bbd) 588 # define CX16_OLD_HI UINT64_C(0x7b06ea35749549ab) 589 # define CX16_MISMATCH_LO UINT64_C(0xbace3e3590f18981) 590 # define CX16_MISMATCH_HI UINT64_C(0x9b385e8bfd5b4000) 591 # define CX16_STORE_LO UINT64_C(0x5cbd27d251f6559b) 592 # define CX16_STORE_HI UINT64_C(0x17ff434ed1b54963) 593 594 PRTUINT128U pBuf = (PRTUINT128U)&pau128->au8[offBuf]; 595 596 ExpectCtx.rax.u = Ctx.rax.u = CX16_MISMATCH_LO; 597 ExpectCtx.rdx.u = Ctx.rdx.u = CX16_MISMATCH_HI; 598 for (iMatch = 0; iMatch < 2; iMatch++) 599 { 600 uint8_t bExpectXcpt; 601 pBuf->s.Lo = CX16_OLD_LO; 602 pBuf->s.Hi = CX16_OLD_HI; 603 ExpectCtx.rdi.u = Ctx.rdi.u = (uintptr_t)pBuf; 604 Bs3TrapSetJmpAndRestore(&Ctx, &TrapFrame); 605 g_usBs3TestStep++; 606 //Bs3TestPrintf("Test: iFlags=%d offBuf=%d iMatch=%u\n", iFlags, offBuf, iMatch); 607 bExpectXcpt = X86_XCPT_UD; 608 if (fSupportCX16) 609 { 610 if (offBuf & 15) 611 { 612 bExpectXcpt = X86_XCPT_GP; 613 ExpectCtx.rip.u = Ctx.rip.u; 614 ExpectCtx.rflags.u32 = Ctx.rflags.u32; 615 } 616 else 617 { 618 ExpectCtx.rax.u = CX16_OLD_LO; 619 ExpectCtx.rdx.u = CX16_OLD_HI; 620 if (iMatch & 1) 621 ExpectCtx.rflags.u32 = Ctx.rflags.u32 | X86_EFL_ZF; 622 else 623 ExpectCtx.rflags.u32 = Ctx.rflags.u32 & ~X86_EFL_ZF; 624 ExpectCtx.rip.u = Ctx.rip.u + 4 + (iLocked & 1); 625 } 626 ExpectCtx.rflags.u32 |= X86_EFL_RF; 627 } 628 if ( !Bs3TestCheckRegCtxEx(&TrapFrame.Ctx, &ExpectCtx, 0 /*cbPcAdjust*/, 0 /*cbSpAdjust*/, 629 0 /*fExtraEfl*/, "lm64", 0 /*idTestStep*/) 630 || TrapFrame.bXcpt != bExpectXcpt) 631 { 632 if (TrapFrame.bXcpt != bExpectXcpt) 633 Bs3TestFailedF("Expected bXcpt=#%x, got %#x (%#x)", bExpectXcpt, TrapFrame.bXcpt, TrapFrame.uErrCd); 634 Bs3TestFailedF("^^^ iLocked=%d iFlags=%d offBuf=%d iMatch=%u\n", iLocked, iFlags, offBuf, iMatch); 635 ASMHalt(); 636 } 637 638 ExpectCtx.rax.u = Ctx.rax.u = CX16_OLD_LO; 639 ExpectCtx.rdx.u = Ctx.rdx.u = CX16_OLD_HI; 640 } 641 } 642 Ctx.rflags.u16 &= ~X86_EFL_STATUS_BITS; 643 } 644 Bs3RegCtxSetRipCsFromCurPtr(&Ctx, BS3_CMN_NM(bs3CpuInstr2_lock_cmpxchg16b_rdi_ud2)); 645 } 646 647 return 0; 648 649 } 650 # endif /* ARCH_BITS == 64 */ 651 652 539 653 #endif /* BS3_INSTANTIATING_CMN */ 540 654 -
trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-instr-2-template.mac
r62455 r65507 83 83 BS3_PROC_END_CMN bs3CpuInstr2_idiv_xBX_ud2 84 84 85 86 %if TMPL_BITS == 64 87 BS3_PROC_BEGIN_CMN bs3CpuInstr2_cmpxchg16b_rdi_ud2, BS3_PBC_NEAR 88 cmpxchg16b [rdi] 89 .again: 90 ud2 91 jmp .again 92 AssertCompile(.again - BS3_LAST_LABEL == 4) 93 BS3_PROC_END_CMN bs3CpuInstr2_cmpxchg16b_rdi_ud2 94 95 96 BS3_PROC_BEGIN_CMN bs3CpuInstr2_lock_cmpxchg16b_rdi_ud2, BS3_PBC_NEAR 97 lock cmpxchg16b [rdi] 98 .again: 99 ud2 100 jmp .again 101 AssertCompile(.again - BS3_LAST_LABEL == 5) 102 BS3_PROC_END_CMN bs3CpuInstr2_lock_cmpxchg16b_rdi_ud2 103 %endif ; TMPL_BITS == 64 104 105 85 106 %endif ; BS3_INSTANTIATING_CMN 86 107 -
trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-instr-2.c
r62412 r65507 39 39 BS3TESTMODE_PROTOTYPES_CMN(bs3CpuInstr2_div); 40 40 BS3TESTMODE_PROTOTYPES_CMN(bs3CpuInstr2_idiv); 41 BS3TESTMODE_PROTOTYPES_CMN_64(bs3CpuInstr2_cmpxchg16b); 41 42 42 43 … … 46 47 static const BS3TESTMODEENTRY g_aModeTests[] = 47 48 { 49 #if 0 48 50 BS3TESTMODEENTRY_CMN("mul", bs3CpuInstr2_mul), 49 51 BS3TESTMODEENTRY_CMN("imul", bs3CpuInstr2_imul), 50 52 BS3TESTMODEENTRY_CMN("div", bs3CpuInstr2_div), 51 53 BS3TESTMODEENTRY_CMN("idiv", bs3CpuInstr2_idiv), 54 #endif 55 BS3TESTMODEENTRY_CMN_64("cmpxchg16b", bs3CpuInstr2_cmpxchg16b), 52 56 }; 53 57 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.h
r65366 r65507 3107 3107 FNBS3TESTDOMODE /*BS3_FAR_CODE*/ RT_CONCAT(a_BaseNm, _c64) 3108 3108 3109 /** @def BS3TESTMODEENTRY_CMN_64 3110 * Produces a BS3TESTMODEENTRY initializer for common 64-bit test functions. */ 3111 #define BS3TESTMODEENTRY_CMN_64(a_szTest, a_BaseNm) \ 3112 { /*pszSubTest =*/ a_szTest, \ 3113 /*RM*/ NULL, \ 3114 /*PE16*/ NULL, \ 3115 /*PE16_32*/ NULL, \ 3116 /*PE16_V86*/ NULL, \ 3117 /*PE32*/ NULL, \ 3118 /*PE32_16*/ NULL, \ 3119 /*PEV86*/ NULL, \ 3120 /*PP16*/ NULL, \ 3121 /*PP16_32*/ NULL, \ 3122 /*PP16_V86*/ NULL, \ 3123 /*PP32*/ NULL, \ 3124 /*PP32_16*/ NULL, \ 3125 /*PPV86*/ NULL, \ 3126 /*PAE16*/ NULL, \ 3127 /*PAE16_32*/ NULL, \ 3128 /*PAE16_V86*/ NULL, \ 3129 /*PAE32*/ NULL, \ 3130 /*PAE32_16*/ NULL, \ 3131 /*PAEV86*/ NULL, \ 3132 /*LM16*/ NULL, \ 3133 /*LM32*/ NULL, \ 3134 /*LM64*/ RT_CONCAT(a_BaseNm, _c64), \ 3135 } 3136 3137 /** @def BS3TESTMODE_PROTOTYPES_CMN 3138 * Standard protype to go with #BS3TESTMODEENTRY_CMN_64. */ 3139 #define BS3TESTMODE_PROTOTYPES_CMN_64(a_BaseNm) \ 3140 FNBS3TESTDOMODE /*BS3_FAR_CODE*/ RT_CONCAT(a_BaseNm, _c64) 3141 3109 3142 /** @def BS3TESTMODEENTRY_MODE 3110 3143 * Produces a BS3TESTMODEENTRY initializer for a full set of mode test
Note:
See TracChangeset
for help on using the changeset viewer.