Changeset 103584 in vbox
- Timestamp:
- Feb 27, 2024 10:35:22 AM (9 months ago)
- Location:
- trunk/src/VBox/ValidationKit/bootsectors
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-instr-2-template.c
r103223 r103584 226 226 extern FNBS3FAR BS3_CMN_NM(bs3CpuInstr2_adox_RAX_RBX_icebp); 227 227 extern FNBS3FAR BS3_CMN_NM(bs3CpuInstr2_adox_RAX_qword_FSxBX_icebp); 228 229 extern FNBS3FAR BS3_CMN_NM(bs3CpuInstr2_movbe_AX_word_FSxBX_icebp); 230 extern FNBS3FAR BS3_CMN_NM(bs3CpuInstr2_movbe_EAX_dword_FSxBX_icebp); 231 extern FNBS3FAR BS3_CMN_NM(bs3CpuInstr2_movbe_RAX_qword_FSxBX_icebp); 232 extern FNBS3FAR BS3_CMN_NM(bs3CpuInstr2_movbe_word_FSxBX_AX_icebp); 233 extern FNBS3FAR BS3_CMN_NM(bs3CpuInstr2_movbe_dword_FSxBX_EAX_icebp); 234 extern FNBS3FAR BS3_CMN_NM(bs3CpuInstr2_movbe_qword_FSxBX_RAX_icebp); 228 235 229 236 extern FNBS3FAR BS3_CMN_NM(bs3CpuInstr2_cmpxchg8b_FSxDI_icebp); … … 2958 2965 if (uMemSrc != uMemSrcExpect) 2959 2966 Bs3TestFailedF("Expected uMemSrc = %#06RX64, got %#06RX64", (uint64_t)uMemSrcExpect, (uint64_t)uMemSrc); 2967 } 2968 } 2969 } 2970 Ctx.rflags.u16 &= ~X86_EFL_STATUS_BITS; 2971 } 2972 2973 return 0; 2974 } 2975 2976 2977 2978 /* 2979 * MOVBE 2980 */ 2981 BS3_DECL_FAR(uint8_t) BS3_CMN_NM(bs3CpuInstr2_movbe)(uint8_t bMode) 2982 { 2983 const char BS3_FAR * const pszMode = Bs3GetModeName(bMode); 2984 2985 typedef struct BS3CPUINSTR2_MOVBE_VALUES_T 2986 { 2987 RTCCUINTXREG uDstOut; 2988 RTCCUINTXREG uDstIn; 2989 RTCCUINTXREG uSrc; 2990 } BS3CPUINSTR2_MOVBE_VALUES_T; 2991 static const BS3CPUINSTR2_MOVBE_VALUES_T s_aValues2[] = 2992 { 2993 { UINT64_C(0xc0dedeaddead3412), UINT64_C(0xc0dedeaddeadc0de), UINT16_C(0x1234) } 2994 }; 2995 static const BS3CPUINSTR2_MOVBE_VALUES_T s_aValues4MemSrc[] = 2996 { 2997 { UINT64_C(0x78563412), UINT64_C(0xc0dedeaddeadc0de), UINT32_C(0x12345678) } 2998 }; 2999 static const BS3CPUINSTR2_MOVBE_VALUES_T s_aValues4MemDst[] = 3000 { 3001 { UINT64_C(0xc0dedead78563412), UINT64_C(0xc0dedeaddeadc0de), UINT32_C(0x12345678) } 3002 }; 3003 #if ARCH_BITS >= 64 3004 static const BS3CPUINSTR2_MOVBE_VALUES_T s_aValues8[] = 3005 { 3006 { UINT64_C(0xf0debc9a78563412), UINT64_C(0xc0dedeaddeadc0de), UINT64_C(0x123456789abcdef0) } 3007 }; 3008 #endif 3009 static const struct 3010 { 3011 FPFNBS3FAR pfnWorker; 3012 bool fMemSrc; 3013 uint8_t offIcebp; 3014 uint8_t cValues; 3015 BS3CPUINSTR2_MOVBE_VALUES_T const BS3_FAR *paValues; 3016 } s_aTests[] = 3017 { 3018 /* 16-bit register width */ 3019 { BS3_CMN_NM(bs3CpuInstr2_movbe_AX_word_FSxBX_icebp), true, 6 + (ARCH_BITS != 16), RT_ELEMENTS(s_aValues2), s_aValues2 }, 3020 { BS3_CMN_NM(bs3CpuInstr2_movbe_word_FSxBX_AX_icebp), false, 6 + (ARCH_BITS != 16), RT_ELEMENTS(s_aValues2), s_aValues2 }, 3021 /* 32-bit register width */ 3022 { BS3_CMN_NM(bs3CpuInstr2_movbe_EAX_dword_FSxBX_icebp), true, 6 + (ARCH_BITS == 16), RT_ELEMENTS(s_aValues4MemSrc), s_aValues4MemSrc }, 3023 { BS3_CMN_NM(bs3CpuInstr2_movbe_dword_FSxBX_EAX_icebp), false, 6 + (ARCH_BITS == 16), RT_ELEMENTS(s_aValues4MemDst), s_aValues4MemDst }, 3024 #if ARCH_BITS >= 64 3025 /* 64-bit register width */ 3026 { BS3_CMN_NM(bs3CpuInstr2_movbe_RAX_qword_FSxBX_icebp), true, 7, RT_ELEMENTS(s_aValues8), s_aValues8 }, 3027 { BS3_CMN_NM(bs3CpuInstr2_movbe_qword_FSxBX_RAX_icebp), false, 7, RT_ELEMENTS(s_aValues8), s_aValues8 }, 3028 #endif 3029 }; 3030 3031 BS3REGCTX Ctx; 3032 BS3REGCTX ExpectCtx; 3033 BS3TRAPFRAME TrapFrame; 3034 unsigned i, j; 3035 bool fSupportsMovBe = false; 3036 3037 if ( (g_uBs3CpuDetected & BS3CPU_F_CPUID) 3038 && ASMCpuId_EAX(0) >= 1) 3039 { 3040 uint32_t fEcx = 0; 3041 ASMCpuIdExSlow(1, 0, 0, 0, NULL, NULL, &fEcx, NULL); 3042 fSupportsMovBe = RT_BOOL(fEcx & X86_CPUID_FEATURE_ECX_MOVBE); 3043 } 3044 3045 /* Ensure the structures are allocated before we sample the stack pointer. */ 3046 Bs3MemSet(&Ctx, 0, sizeof(Ctx)); 3047 Bs3MemSet(&TrapFrame, 0, sizeof(TrapFrame)); 3048 Bs3MemSet(&ExpectCtx, 0, sizeof(ExpectCtx)); 3049 3050 /* 3051 * Create test context. 3052 */ 3053 Bs3RegCtxSaveEx(&Ctx, bMode, 512); 3054 3055 /* 3056 * Do the tests twice, first with all flags set, then once again with 3057 * flags cleared. The flags are not supposed to be touched at all. 3058 */ 3059 g_usBs3TestStep = 0; 3060 for (j = 0; j < 2; j++) 3061 { 3062 for (i = 0; i < RT_ELEMENTS(s_aTests); i++) 3063 { 3064 unsigned const cValues = s_aTests[i].cValues; 3065 BS3CPUINSTR2_MOVBE_VALUES_T const BS3_FAR *paValues = s_aTests[i].paValues; 3066 unsigned iValue; 3067 bool const fOkay = fSupportsMovBe; 3068 uint8_t const bExpectXcpt = fOkay ? X86_XCPT_DB : X86_XCPT_UD; 3069 uint64_t uExpectRip; 3070 3071 Bs3RegCtxSetRipCsFromCurPtr(&Ctx, s_aTests[i].pfnWorker); 3072 uExpectRip = Ctx.rip.u + (fOkay ? ((uint8_t const BS3_FAR *)s_aTests[i].pfnWorker)[-1] + 1 : 0); 3073 3074 for (iValue = 0; iValue < cValues; iValue++) 3075 { 3076 uint64_t const uExpectRax = fOkay ? paValues[iValue].uDstOut : paValues[iValue].uDstIn; 3077 uint64_t uMem, uMemExpect; 3078 3079 Bs3MemCpy(&ExpectCtx, &Ctx, sizeof(ExpectCtx)); 3080 3081 if (!s_aTests[i].fMemSrc) 3082 { 3083 /* Memory is destination */ 3084 Ctx.rax.u64 = paValues[iValue].uSrc; 3085 ExpectCtx.rax.u64 = paValues[iValue].uSrc; 3086 uMem = paValues[iValue].uDstIn; 3087 uMemExpect = paValues[iValue].uDstOut; 3088 Bs3RegCtxSetGrpSegFromCurPtr(&Ctx, &Ctx.rbx, &Ctx.fs, &uMem); 3089 Bs3RegCtxSetGrpSegFromCurPtr(&ExpectCtx, &ExpectCtx.rbx, &ExpectCtx.fs, &uMem); 3090 } 3091 else 3092 { 3093 /* Memory is source */ 3094 uMemExpect = uMem = paValues[iValue].uSrc; 3095 Ctx.rax.u64 = paValues[iValue].uDstIn; 3096 ExpectCtx.rax.u64 = paValues[iValue].uDstOut; 3097 Bs3RegCtxSetGrpSegFromCurPtr(&Ctx, &Ctx.rbx, &Ctx.fs, &uMem); 3098 Bs3RegCtxSetGrpSegFromCurPtr(&ExpectCtx, &ExpectCtx.rbx, &ExpectCtx.fs, &uMem); 3099 } 3100 3101 Bs3TrapSetJmpAndRestore(&Ctx, &TrapFrame); 3102 g_usBs3TestStep++; 3103 3104 if ( !Bs3TestCheckRegCtxEx(&TrapFrame.Ctx, &ExpectCtx, bExpectXcpt == X86_XCPT_DB ? s_aTests[i].offIcebp : 0 /*cbPcAdjust*/, 3105 0 /*cbSpAcjust*/, 0 /*fExtraEfl*/, pszMode, g_usBs3TestStep) 3106 || TrapFrame.bXcpt != bExpectXcpt 3107 || uMem != uMemExpect 3108 ) 3109 { 3110 if (TrapFrame.bXcpt != bExpectXcpt) 3111 Bs3TestFailedF("Expected bXcpt=#%x, got %#x (%#x)", bExpectXcpt, TrapFrame.bXcpt, TrapFrame.uErrCd); 3112 if (uMem != uMemExpect) 3113 Bs3TestFailedF("Expected uMem = %#06RX64, got %#06RX64", (uint64_t)uMemExpect, (uint64_t)uMem); 3114 Bs3TestFailedF("^^^ iCfg=%u iWorker=%d iValue=%d\n", 3115 j, i, iValue); 2960 3116 } 2961 3117 } -
trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-instr-2-template.mac
r103208 r103584 713 713 714 714 ; 715 ; MOVBE 716 ; 717 BS3CPUINSTR2_PROC_BEGIN_CMN bs3CpuInstr2_movbe_AX_word_FSxBX_icebp 718 movbe ax, word [fs:xBX] 719 .again: 720 icebp 721 jmp .again 722 BS3_PROC_END_CMN bs3CpuInstr2_movbe_AX_word_FSxBX_icebp 723 724 BS3CPUINSTR2_PROC_BEGIN_CMN bs3CpuInstr2_movbe_word_FSxBX_AX_icebp 725 movbe word [fs:xBX], ax 726 .again: 727 icebp 728 jmp .again 729 BS3_PROC_END_CMN bs3CpuInstr2_movbe_word_FSxBX_AX_icebp 730 731 BS3CPUINSTR2_PROC_BEGIN_CMN bs3CpuInstr2_movbe_EAX_dword_FSxBX_icebp 732 movbe eax, dword [fs:xBX] 733 .again: 734 icebp 735 jmp .again 736 BS3_PROC_END_CMN bs3CpuInstr2_movbe_EAX_dword_FSxBX_icebp 737 738 BS3CPUINSTR2_PROC_BEGIN_CMN bs3CpuInstr2_movbe_dword_FSxBX_EAX_icebp 739 movbe dword [fs:xBX], eax 740 .again: 741 icebp 742 jmp .again 743 BS3_PROC_END_CMN bs3CpuInstr2_movbe_dword_FSxBX_EAX_icebp 744 745 %if TMPL_BITS == 64 746 BS3CPUINSTR2_PROC_BEGIN_CMN bs3CpuInstr2_movbe_RAX_qword_FSxBX_icebp 747 movbe rax, qword [fs:xBX] 748 .again: 749 icebp 750 jmp .again 751 BS3_PROC_END_CMN bs3CpuInstr2_movbe_RAX_qword_FSxBX_icebp 752 753 BS3CPUINSTR2_PROC_BEGIN_CMN bs3CpuInstr2_movbe_qword_FSxBX_RAX_icebp 754 movbe qword [fs:xBX], rax 755 .again: 756 icebp 757 jmp .again 758 BS3_PROC_END_CMN bs3CpuInstr2_movbe_qword_FSxBX_RAX_icebp 759 %endif 760 761 762 ; 715 763 ; CMPXCHG8B 716 764 ; -
trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-instr-2.c
r103208 r103584 67 67 BS3TESTMODE_PROTOTYPES_CMN(bs3CpuInstr2_crc32); 68 68 BS3TESTMODE_PROTOTYPES_CMN(bs3CpuInstr2_adcx_adox); 69 BS3TESTMODE_PROTOTYPES_CMN(bs3CpuInstr2_movbe); 69 70 BS3TESTMODE_PROTOTYPES_CMN(bs3CpuInstr2_cmpxchg8b); 70 71 BS3TESTMODE_PROTOTYPES_CMN_64(bs3CpuInstr2_cmpxchg16b); … … 111 112 BS3TESTMODEENTRY_CMN("crc32", bs3CpuInstr2_crc32), /* SSE4.2 */ 112 113 BS3TESTMODEENTRY_CMN("adcx/adox", bs3CpuInstr2_adcx_adox), /* ADX */ 114 BS3TESTMODEENTRY_CMN("movbe", bs3CpuInstr2_movbe), /* MOVBE */ 113 115 BS3TESTMODEENTRY_CMN("cmpxchg8b", bs3CpuInstr2_cmpxchg8b), 114 116 #endif
Note:
See TracChangeset
for help on using the changeset viewer.