Changeset 95303 in vbox
- Timestamp:
- Jun 17, 2022 11:36:25 PM (2 years ago)
- Location:
- trunk/src/VBox/ValidationKit/bootsectors
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-instr-2-template.c
r95296 r95303 68 68 extern FNBS3FAR BS3_CMN_NM(bs3CpuInstr2_rorx_EBX_EDX_2_icebp_V1); 69 69 extern FNBS3FAR BS3_CMN_NM(bs3CpuInstr2_rorx_EBX_EDX_2_icebp_V15); 70 extern FNBS3FAR BS3_CMN_NM(bs3CpuInstr2_rorx_RBX_DSxDI_68_icebp); 71 extern FNBS3FAR BS3_CMN_NM(bs3CpuInstr2_rorx_EBX_DSxDI_36_icebp); 70 72 # if ARCH_BITS == 64 71 73 extern FNBS3FAR BS3_CMN_NM(bs3CpuInstr2_cmpxchg16b_rdi_ud2); … … 103 105 static BS3CI2FSGSBASE const s_aWrFsBaseWorkers[] = 104 106 { 105 { "wrfsbase rbx", true, BS3_CMN_NM(bs3CpuInstr2_wrfsbase_rbx_ud2), 5, BS3_CMN_NM(bs3CpuInstr2_wrfsbase_rbx_rdfsbase_rcx_ud2), 1 3},106 { "wrfsbase ebx", false, BS3_CMN_NM(bs3CpuInstr2_wrfsbase_ebx_ud2), 4, BS3_CMN_NM(bs3CpuInstr2_wrfsbase_ebx_rdfsbase_ecx_ud2), 1 0},107 { "wrfsbase rbx", true, BS3_CMN_NM(bs3CpuInstr2_wrfsbase_rbx_ud2), 5, BS3_CMN_NM(bs3CpuInstr2_wrfsbase_rbx_rdfsbase_rcx_ud2), 15 }, 108 { "wrfsbase ebx", false, BS3_CMN_NM(bs3CpuInstr2_wrfsbase_ebx_ud2), 4, BS3_CMN_NM(bs3CpuInstr2_wrfsbase_ebx_rdfsbase_ecx_ud2), 13 }, 107 109 }; 108 110 109 111 static BS3CI2FSGSBASE const s_aWrGsBaseWorkers[] = 110 112 { 111 { "wrgsbase rbx", true, BS3_CMN_NM(bs3CpuInstr2_wrgsbase_rbx_ud2), 5, BS3_CMN_NM(bs3CpuInstr2_wrgsbase_rbx_rdgsbase_rcx_ud2), 1 3},112 { "wrgsbase ebx", false, BS3_CMN_NM(bs3CpuInstr2_wrgsbase_ebx_ud2), 4, BS3_CMN_NM(bs3CpuInstr2_wrgsbase_ebx_rdgsbase_ecx_ud2), 1 0},113 { "wrgsbase rbx", true, BS3_CMN_NM(bs3CpuInstr2_wrgsbase_rbx_ud2), 5, BS3_CMN_NM(bs3CpuInstr2_wrgsbase_rbx_rdgsbase_rcx_ud2), 15 }, 114 { "wrgsbase ebx", false, BS3_CMN_NM(bs3CpuInstr2_wrgsbase_ebx_ud2), 4, BS3_CMN_NM(bs3CpuInstr2_wrgsbase_ebx_rdgsbase_ecx_ud2), 13 }, 113 115 }; 114 116 115 117 static BS3CI2FSGSBASE const s_aRdFsBaseWorkers[] = 116 118 { 117 { "rdfsbase rbx", true, BS3_CMN_NM(bs3CpuInstr2_rdfsbase_rbx_ud2), 5, BS3_CMN_NM(bs3CpuInstr2_wrfsbase_rbx_rdfsbase_rcx_ud2), 1 3},118 { "rdfsbase ebx", false, BS3_CMN_NM(bs3CpuInstr2_rdfsbase_ebx_ud2), 4, BS3_CMN_NM(bs3CpuInstr2_wrfsbase_ebx_rdfsbase_ecx_ud2), 1 0},119 { "rdfsbase rbx", true, BS3_CMN_NM(bs3CpuInstr2_rdfsbase_rbx_ud2), 5, BS3_CMN_NM(bs3CpuInstr2_wrfsbase_rbx_rdfsbase_rcx_ud2), 15 }, 120 { "rdfsbase ebx", false, BS3_CMN_NM(bs3CpuInstr2_rdfsbase_ebx_ud2), 4, BS3_CMN_NM(bs3CpuInstr2_wrfsbase_ebx_rdfsbase_ecx_ud2), 13 }, 119 121 }; 120 122 121 123 static BS3CI2FSGSBASE const s_aRdGsBaseWorkers[] = 122 124 { 123 { "rdgsbase rbx", true, BS3_CMN_NM(bs3CpuInstr2_rdgsbase_rbx_ud2), 5, BS3_CMN_NM(bs3CpuInstr2_wrgsbase_rbx_rdgsbase_rcx_ud2), 1 3},124 { "rdgsbase ebx", false, BS3_CMN_NM(bs3CpuInstr2_rdgsbase_ebx_ud2), 4, BS3_CMN_NM(bs3CpuInstr2_wrgsbase_ebx_rdgsbase_ecx_ud2), 1 0},125 { "rdgsbase rbx", true, BS3_CMN_NM(bs3CpuInstr2_rdgsbase_rbx_ud2), 5, BS3_CMN_NM(bs3CpuInstr2_wrgsbase_rbx_rdgsbase_rcx_ud2), 15 }, 126 { "rdgsbase ebx", false, BS3_CMN_NM(bs3CpuInstr2_rdgsbase_ebx_ud2), 4, BS3_CMN_NM(bs3CpuInstr2_wrgsbase_ebx_rdgsbase_ecx_ud2), 13 }, 125 127 }; 126 128 # endif … … 608 610 { 609 611 FPFNBS3FAR pfnWorker; 612 bool fMemSrc; 610 613 bool fOkay; 611 614 RTCCUINTXREG uIn; … … 613 616 } s_aTests[] = 614 617 { 615 { BS3_CMN_NM(bs3CpuInstr2_rorx_RBX_RDX_2_icebp), true, // #0 618 /* 64 bits register width (32 bits in 32- and 16-bit modes): */ 619 { BS3_CMN_NM(bs3CpuInstr2_rorx_RBX_RDX_2_icebp), false, true, // #0 616 620 0, /* -> */ 0 }, 617 { BS3_CMN_NM(bs3CpuInstr2_rorx_RBX_RDX_2_icebp), true, // #1621 { BS3_CMN_NM(bs3CpuInstr2_rorx_RBX_RDX_2_icebp), false, true, // #1 618 622 ~(RTCCUINTXREG)2, /* -> */ ~(RTCCUINTXREG)0 >> 1 }, 619 { BS3_CMN_NM(bs3CpuInstr2_rorx_ EBX_EDX_2_icebp),true, // #2623 { BS3_CMN_NM(bs3CpuInstr2_rorx_RBX_DSxDI_68_icebp), true, true, // #2 620 624 0, /* -> */ 0 }, 621 { BS3_CMN_NM(bs3CpuInstr2_rorx_EBX_EDX_2_icebp), true, // #3 625 { BS3_CMN_NM(bs3CpuInstr2_rorx_RBX_DSxDI_68_icebp), true, true, // #3 626 ~(RTCCUINTXREG)2, /* -> */ (RTCCUINTXREG_MAX >> 4) | (~(RTCCUINTXREG)2 << (sizeof(RTCCUINTXREG) * 8 - 4)) }, 627 628 /* 32 bits register width: */ 629 { BS3_CMN_NM(bs3CpuInstr2_rorx_EBX_EDX_2_icebp), false, true, // #4 630 0, /* -> */ 0 }, 631 { BS3_CMN_NM(bs3CpuInstr2_rorx_EBX_EDX_2_icebp), false, true, // #5 622 632 ~(RTCCUINTXREG)2, /* -> */ (RTCCUINTXREG)(~(uint32_t)0 >> 1) }, 623 624 { BS3_CMN_NM(bs3CpuInstr2_rorx_EBX_EDX_2_icebp_L1), false, // #4 633 { BS3_CMN_NM(bs3CpuInstr2_rorx_EBX_DSxDI_36_icebp), true, true, // #6 634 0, /* -> */ 0 }, 635 { BS3_CMN_NM(bs3CpuInstr2_rorx_EBX_DSxDI_36_icebp), true, true, // #7 636 ~(RTCCUINTXREG)2, /* -> */ (RTCCUINTXREG)UINT32_C(0xdfffffff) }, 637 638 /* encoding tests: */ 639 { BS3_CMN_NM(bs3CpuInstr2_rorx_EBX_EDX_2_icebp_L1), false, false, // #8 625 640 RTCCUINTXREG_MAX, /* -> */ 0 }, 626 { BS3_CMN_NM(bs3CpuInstr2_rorx_EBX_EDX_2_icebp_V1), false, // #5641 { BS3_CMN_NM(bs3CpuInstr2_rorx_EBX_EDX_2_icebp_V1), false, false, // #9 627 642 RTCCUINTXREG_MAX, /* -> */ 0 }, 628 { BS3_CMN_NM(bs3CpuInstr2_rorx_EBX_EDX_2_icebp_V15), false, // #6643 { BS3_CMN_NM(bs3CpuInstr2_rorx_EBX_EDX_2_icebp_V15), false, false, // #10 629 644 RTCCUINTXREG_MAX, /* -> */ 0 }, 630 645 # if ARCH_BITS == 64 /* The VEX.X=0 encoding mean LES instruction in 32-bit and 16-bit mode. */ 631 { BS3_CMN_NM(bs3CpuInstr2_rorx_EBX_EDX_2_icebp_X1), true, // #7646 { BS3_CMN_NM(bs3CpuInstr2_rorx_EBX_EDX_2_icebp_X1), false, true, // #11 632 647 UINT32_C(0xf1e2d3c5), /* -> */ (RTCCUINTXREG)UINT32_C(0x7c78b4f1) }, 633 648 # endif … … 637 652 BS3TRAPFRAME TrapFrame; 638 653 unsigned i, j; 654 uint32_t uStdExtFeatEbx = 0; 655 bool fSupportsRorX; 656 657 if (g_uBs3CpuDetected & BS3CPU_F_CPUID) 658 ASMCpuIdExSlow(7, 0, 0, 0, NULL, &uStdExtFeatEbx, NULL, NULL); 659 fSupportsRorX = RT_BOOL(uStdExtFeatEbx & X86_CPUID_STEXT_FEATURE_EBX_BMI2); 639 660 640 661 /* Ensure the structures are allocated before we sample the stack pointer. */ … … 656 677 for (i = 0; i < RT_ELEMENTS(s_aTests); i++) 657 678 { 658 bool const fOkay = !BS3_MODE_IS_RM_OR_V86(bMode) && s_aTests[i].fOkay; 659 uint64_t uExpectRbx; 660 uint64_t uExpectRip; 679 bool const fOkay = !BS3_MODE_IS_RM_OR_V86(bMode) && s_aTests[i].fOkay && fSupportsRorX; 680 uint8_t const bExpectXcpt = fOkay ? X86_XCPT_DB : X86_XCPT_UD; 681 uint64_t uExpectRbx, uExpectRip; 682 RTCCUINTXREG uMemSrc, uMemSrcExpect; 661 683 Ctx.rbx.uCcXReg = RTCCUINTXREG_MAX * 1019; 662 Ctx.rdx.uCcXReg = s_aTests[i].uIn; 684 if (!s_aTests[i].fMemSrc) 685 { 686 Ctx.rdx.uCcXReg = s_aTests[i].uIn; 687 uMemSrcExpect = uMemSrc = ~s_aTests[i].uIn; 688 } 689 else 690 { 691 Ctx.rdx.uCcXReg = ~s_aTests[i].uIn; 692 uMemSrcExpect = uMemSrc = s_aTests[i].uIn; 693 Bs3RegCtxSetGrpDsFromCurPtr(&Ctx, &Ctx.rdi, &uMemSrc); 694 } 663 695 Bs3RegCtxSetRipCsFromCurPtr(&Ctx, s_aTests[i].pfnWorker); 664 696 uExpectRbx = fOkay ? s_aTests[i].uOut : Ctx.rbx.u; 665 uExpectRip = Ctx.rip.u + (fOkay ? 6 : 0);697 uExpectRip = Ctx.rip.u + (fOkay ? 6 + 1 : 0); 666 698 Bs3TrapSetJmpAndRestore(&Ctx, &TrapFrame); 667 699 668 if ( TrapFrame.bXcpt != X86_XCPT_UD700 if ( TrapFrame.bXcpt != bExpectXcpt 669 701 || TrapFrame.Ctx.rip.u != uExpectRip 670 702 || TrapFrame.Ctx.rdx.u != Ctx.rdx.u … … 678 710 || TrapFrame.Ctx.rsi.u != Ctx.rsi.u 679 711 || TrapFrame.Ctx.rdi.u != Ctx.rdi.u 680 ) 712 || uMemSrc != uMemSrcExpect 713 ) 681 714 { 682 715 Bs3TestFailedF("test #%i failed: input %#" RTCCUINTXREG_XFMT, i, s_aTests[i].uIn); 683 if (TrapFrame.bXcpt != X86_XCPT_UD)684 Bs3TestFailedF("Expected bXcpt = %#x, got %#x", X86_XCPT_UD, TrapFrame.bXcpt);716 if (TrapFrame.bXcpt != bExpectXcpt) 717 Bs3TestFailedF("Expected bXcpt = %#x, got %#x", bExpectXcpt, TrapFrame.bXcpt); 685 718 if (TrapFrame.Ctx.rip.u != uExpectRip) 686 Bs3TestFailedF("Expected RIP = %#06RX 16, got %#06RX16 (src)", uExpectRip, TrapFrame.Ctx.rip.u);719 Bs3TestFailedF("Expected RIP = %#06RX64, got %#06RX64", uExpectRip, TrapFrame.Ctx.rip.u); 687 720 if (TrapFrame.Ctx.rdx.u != Ctx.rdx.u) 688 Bs3TestFailedF("Expected RDX = %#06RX 16, got %#06RX16(src)", Ctx.rdx.u, TrapFrame.Ctx.rdx.u);721 Bs3TestFailedF("Expected RDX = %#06RX64, got %#06RX64 (src)", Ctx.rdx.u, TrapFrame.Ctx.rdx.u); 689 722 if (TrapFrame.Ctx.rbx.u != uExpectRbx) 690 Bs3TestFailedF("Expected RBX = %#06RX 16, got %#06RX16(dst)", uExpectRbx, TrapFrame.Ctx.rbx.u);723 Bs3TestFailedF("Expected RBX = %#06RX64, got %#06RX64 (dst)", uExpectRbx, TrapFrame.Ctx.rbx.u); 691 724 692 725 if ((TrapFrame.Ctx.rflags.u16 & X86_EFL_STATUS_BITS) != (Ctx.rflags.u16 & X86_EFL_STATUS_BITS)) 693 Bs3TestFailedF("Expected EFLAGS = %#06RX 16, got %#06RX16",726 Bs3TestFailedF("Expected EFLAGS = %#06RX64, got %#06RX64", 694 727 Ctx.rflags.u16 & X86_EFL_STATUS_BITS, TrapFrame.Ctx.rflags.u16 & X86_EFL_STATUS_BITS); 695 728 if (TrapFrame.Ctx.rax.u != Ctx.rax.u) 696 Bs3TestFailedF("Expected RAX = %#06RX 16, got %#06RX16", Ctx.rax.u, TrapFrame.Ctx.rax.u);729 Bs3TestFailedF("Expected RAX = %#06RX64, got %#06RX64", Ctx.rax.u, TrapFrame.Ctx.rax.u); 697 730 if (TrapFrame.Ctx.rcx.u != Ctx.rcx.u) 698 Bs3TestFailedF("Expected RCX = %#06RX 16, got %#06RX16", Ctx.rcx.u, TrapFrame.Ctx.rcx.u);731 Bs3TestFailedF("Expected RCX = %#06RX64, got %#06RX64", Ctx.rcx.u, TrapFrame.Ctx.rcx.u); 699 732 if (TrapFrame.Ctx.rsp.u != Ctx.rsp.u) 700 Bs3TestFailedF("Expected RSP = %#06RX 16, got %#06RX16", Ctx.rsp.u, TrapFrame.Ctx.rsp.u);733 Bs3TestFailedF("Expected RSP = %#06RX64, got %#06RX64", Ctx.rsp.u, TrapFrame.Ctx.rsp.u); 701 734 if (TrapFrame.Ctx.rbp.u != Ctx.rbp.u) 702 Bs3TestFailedF("Expected RBP = %#06RX 16, got %#06RX16", Ctx.rbp.u, TrapFrame.Ctx.rbp.u);735 Bs3TestFailedF("Expected RBP = %#06RX64, got %#06RX64", Ctx.rbp.u, TrapFrame.Ctx.rbp.u); 703 736 if (TrapFrame.Ctx.rsi.u != Ctx.rsi.u) 704 Bs3TestFailedF("Expected RSI = %#06RX 16, got %#06RX16", Ctx.rsi.u, TrapFrame.Ctx.rsi.u);737 Bs3TestFailedF("Expected RSI = %#06RX64, got %#06RX64", Ctx.rsi.u, TrapFrame.Ctx.rsi.u); 705 738 if (TrapFrame.Ctx.rdi.u != Ctx.rdi.u) 706 Bs3TestFailedF("Expected RDI = %#06RX16, got %#06RX16", Ctx.rdi.u, TrapFrame.Ctx.rdi.u); 739 Bs3TestFailedF("Expected RDI = %#06RX64, got %#06RX64", Ctx.rdi.u, TrapFrame.Ctx.rdi.u); 740 if (uMemSrc != uMemSrcExpect) 741 Bs3TestFailedF("Expected uMemSrc = %#06RX64, got %#06RX64", (uint64_t)uMemSrcExpect, (uint64_t)uMemSrc); 707 742 } 708 743 } … … 933 968 if (fGP && pTrapFrame->bXcpt != X86_XCPT_GP) 934 969 Bs3TestFailedF("Expected #GP, got %#x (%#x)", pTrapFrame->bXcpt, pTrapFrame->uErrCd); 970 else 971 Bs3TestFailedF("iValue=%u\n", iValue); 935 972 fPassed = false; 936 973 break; … … 954 991 0 /*fExtraEfl*/, "lm64", 0 /*idTestStep*/)) 955 992 { 993 Bs3TestFailedF("iValue=%u\n", iValue); 956 994 fPassed = false; 957 995 break; -
trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-instr-2-template.mac
r95296 r95303 86 86 ; RORX - VEX instruction with a couple of questions about non-standard encodings. 87 87 ; 88 %define icebp ud288 ;;%define icebp ud2 89 89 BS3_PROC_BEGIN_CMN bs3CpuInstr2_rorx_EBX_EDX_2_icebp, BS3_PBC_NEAR 90 %if TMPL_BITS != 1691 90 rorx ebx, edx, 2 92 %else93 db 0C4h,0E3h,07Bh,0F0h,0DAh,002h ; wrong nasm mode, whatever94 %endif95 91 .again: 96 92 icebp … … 102 98 rorx rbx, rdx, 2 103 99 %else 104 db 0C4h,0E3h,0FBh,0F0h,0DAh,002h ; 32-bit ignores VEX.W=1 (10980xe)100 db 0C4h,0E3h,0FBh,0F0h,0DAh,002h ; 32-bit ignores VEX.W=1 (10980xe) 105 101 %endif 106 102 .again: … … 139 135 %endif 140 136 137 ; A couple of memory variants 138 BS3_PROC_BEGIN_CMN bs3CpuInstr2_rorx_EBX_DSxDI_36_icebp, BS3_PBC_NEAR 139 rorx ebx, [xDI], 36 140 .again: 141 icebp 142 jmp .again 143 BS3_PROC_END_CMN bs3CpuInstr2_rorx_EBX_DSxDI_36_icebp 144 145 BS3_PROC_BEGIN_CMN bs3CpuInstr2_rorx_RBX_DSxDI_68_icebp, BS3_PBC_NEAR 146 %if TMPL_BITS == 64 147 rorx rbx, [xDI], 68 148 %elif TMPL_BITS == 32 149 db 0C4h,0E3h,07Bh,0F0h,01Fh,044h ; 16-bit ignores VEX.W=1 (10980xe) 150 %else 151 db 0C4h,0E3h,0FBh,0F0h,01Dh,044h ; 16-bit ignores VEX.W=1 (10980xe) 152 %endif 153 .again: 154 icebp 155 jmp .again 156 BS3_PROC_END_CMN bs3CpuInstr2_rorx_RBX_DSxDI_68_icebp 157 141 158 142 159 ; … … 256 273 BS3_PROC_BEGIN_CMN bs3CpuInstr2_wrfsbase_rbx_rdfsbase_rcx_ud2, BS3_PBC_NEAR 257 274 wrfsbase rbx 258 xor rbx, rbx275 mov ebx, 0 259 276 rdfsbase rcx 260 277 .again: 261 278 ud2 262 279 jmp .again 263 AssertCompile(.again - BS3_LAST_LABEL == 1 3)280 AssertCompile(.again - BS3_LAST_LABEL == 15) 264 281 BS3_PROC_END_CMN bs3CpuInstr2_wrfsbase_rbx_rdfsbase_rcx_ud2 265 282 … … 267 284 BS3_PROC_BEGIN_CMN bs3CpuInstr2_wrfsbase_ebx_rdfsbase_ecx_ud2, BS3_PBC_NEAR 268 285 wrfsbase ebx 269 xor ebx, ebx286 mov ebx, 0 270 287 rdfsbase ecx 271 288 .again: 272 289 ud2 273 290 jmp .again 274 AssertCompile(.again - BS3_LAST_LABEL == 1 0)291 AssertCompile(.again - BS3_LAST_LABEL == 13) 275 292 BS3_PROC_END_CMN bs3CpuInstr2_wrfsbase_ebx_rdfsbase_ecx_ud2 276 293 … … 278 295 BS3_PROC_BEGIN_CMN bs3CpuInstr2_wrgsbase_rbx_rdgsbase_rcx_ud2, BS3_PBC_NEAR 279 296 wrgsbase rbx 280 xor rbx, rbx297 mov ebx, 0 281 298 rdgsbase rcx 282 299 .again: 283 300 ud2 284 301 jmp .again 285 AssertCompile(.again - BS3_LAST_LABEL == 1 3)302 AssertCompile(.again - BS3_LAST_LABEL == 15) 286 303 BS3_PROC_END_CMN bs3CpuInstr2_wrgsbase_rbx_rdgsbase_rcx_ud2 287 304 … … 289 306 BS3_PROC_BEGIN_CMN bs3CpuInstr2_wrgsbase_ebx_rdgsbase_ecx_ud2, BS3_PBC_NEAR 290 307 wrgsbase ebx 291 xor ebx, ebx308 mov ebx, 0 292 309 rdgsbase ecx 293 310 .again: 294 311 ud2 295 312 jmp .again 296 AssertCompile(.again - BS3_LAST_LABEL == 1 0)313 AssertCompile(.again - BS3_LAST_LABEL == 13) 297 314 BS3_PROC_END_CMN bs3CpuInstr2_wrfgbase_ebx_rdgsbase_ecx_ud2 298 315
Note:
See TracChangeset
for help on using the changeset viewer.