Changeset 66457 in vbox for trunk/src/VBox/ValidationKit/bootsectors
- Timestamp:
- Apr 6, 2017 10:44:30 AM (8 years ago)
- svn:sync-xref-src-repo-rev:
- 114437
- Location:
- trunk/src/VBox/ValidationKit/bootsectors
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-generated-1-template.c
r66450 r66457 98 98 } BS3CG1OPLOC; 99 99 100 100 101 /** 101 102 * The state. … … 151 152 /** Target mode (g_bBs3CurrentMode). */ 152 153 uint8_t bMode; 154 /** The CPU vendor (BS3CPUVENDOR). */ 155 uint8_t bCpuVendor; 153 156 /** First ring being tested. */ 154 157 uint8_t iFirstRing; … … 166 169 uint8_t offCurImm; 167 170 /** Buffer for assembling the current instruction. */ 168 uint8_t abCurInstr[2 4];171 uint8_t abCurInstr[23]; 169 172 170 173 /** Set if the encoding can't be tested in the same ring as this test code. … … 2467 2470 CASE_PRED(BS3CG1PRED_PAGING_ON, BS3_MODE_IS_PAGED(pThis->bMode)); 2468 2471 CASE_PRED(BS3CG1PRED_PAGING_OFF, !BS3_MODE_IS_PAGED(pThis->bMode)); 2472 CASE_PRED(BS3CG1PRED_VENDOR_AMD, pThis->bCpuVendor == BS3CPUVENDOR_AMD); 2473 CASE_PRED(BS3CG1PRED_VENDOR_INTEL, pThis->bCpuVendor == BS3CPUVENDOR_INTEL); 2474 CASE_PRED(BS3CG1PRED_VENDOR_VIA, pThis->bCpuVendor == BS3CPUVENDOR_VIA); 2469 2475 2470 2476 #undef CASE_PRED … … 2905 2911 * 2906 2912 * @returns true if successful, false if not. 2907 * @param pThis The state. 2908 * @param bTestXcptExpected The exception causing the test code to stop 2909 * executing. 2910 * @param iEncoding For error reporting. 2913 * @param pThis The state. 2914 * @param bTestXcptExpected The exception causing the test code to stop 2915 * executing. 2916 * @param fInvalidEncodingPgFault Set if we've cut the instruction a byte 2917 * short and is expecting a \#PF on the page 2918 * boundrary rather than a \#UD. Only set if 2919 * fInvalidEncoding is also set. 2920 * @param iEncoding For error reporting. 2911 2921 */ 2912 static bool BS3_NEAR_CODE Bs3Cg1CheckResult(PBS3CG1STATE pThis, uint8_t bTestXcptExpected, unsigned iEncoding) 2922 static bool BS3_NEAR_CODE Bs3Cg1CheckResult(PBS3CG1STATE pThis, uint8_t bTestXcptExpected, 2923 bool fInvalidEncodingPgFault, unsigned iEncoding) 2913 2924 { 2914 2925 unsigned iOperand; … … 2937 2948 { 2938 2949 cbAdjustPc = 0; 2939 bExpectedXcpt = X86_XCPT_UD; 2950 if (!fInvalidEncodingPgFault) 2951 bExpectedXcpt = X86_XCPT_UD; 2952 else 2953 { 2954 bExpectedXcpt = X86_XCPT_PF; 2955 pThis->Ctx.cr2.u = pThis->uCodePgFlat + X86_PAGE_SIZE; 2956 } 2940 2957 } 2941 2958 if (RT_LIKELY( pThis->TrapFrame.bXcpt == bExpectedXcpt … … 2958 2975 if (pThis->aOperands[iOperand].enmLocation == BS3CG1OPLOC_MEM_RW) 2959 2976 { 2960 BS3PTRUNION PtrUnion; 2961 PtrUnion.pb = &pThis->pbDataPg[X86_PAGE_SIZE - pThis->aOperands[iOperand].off]; 2962 switch (pThis->aOperands[iOperand].cbOp) 2977 if (pThis->aOperands[iOperand].off) 2963 2978 { 2964 case 1: 2965 if (*PtrUnion.pu8 == pThis->MemOp.ab[0]) 2966 continue; 2967 Bs3TestFailedF("op%u: Wrote %#04RX8, expected %#04RX8", iOperand, *PtrUnion.pu8, pThis->MemOp.ab[0]); 2968 break; 2969 case 2: 2970 if (*PtrUnion.pu16 == pThis->MemOp.au16[0]) 2971 continue; 2972 Bs3TestFailedF("op%u: Wrote %#06RX16, expected %#06RX16", 2973 iOperand, *PtrUnion.pu16, pThis->MemOp.au16[0]); 2974 break; 2975 case 4: 2976 if (*PtrUnion.pu32 == pThis->MemOp.au32[0]) 2977 continue; 2978 Bs3TestFailedF("op%u: Wrote %#010RX32, expected %#010RX32", 2979 iOperand, *PtrUnion.pu32, pThis->MemOp.au32[0]); 2980 break; 2981 case 8: 2982 if (*PtrUnion.pu64 == pThis->MemOp.au64[0]) 2983 continue; 2984 Bs3TestFailedF("op%u: Wrote %#018RX64, expected %#018RX64", 2985 iOperand, *PtrUnion.pu64, pThis->MemOp.au64[0]); 2986 break; 2987 default: 2988 if (Bs3MemCmp(PtrUnion.pb, pThis->MemOp.ab, pThis->aOperands[iOperand].cbOp) == 0) 2989 continue; 2990 Bs3TestFailedF("op%u: Wrote %.*Rhxs, expected %.*Rhxs", 2991 iOperand, 2992 pThis->aOperands[iOperand].cbOp, PtrUnion.pb, 2993 pThis->aOperands[iOperand].cbOp, pThis->MemOp.ab); 2994 break; 2979 BS3PTRUNION PtrUnion; 2980 PtrUnion.pb = &pThis->pbDataPg[X86_PAGE_SIZE - pThis->aOperands[iOperand].off]; 2981 switch (pThis->aOperands[iOperand].cbOp) 2982 { 2983 case 1: 2984 if (*PtrUnion.pu8 == pThis->MemOp.ab[0]) 2985 continue; 2986 Bs3TestFailedF("op%u: Wrote %#04RX8, expected %#04RX8", 2987 iOperand, *PtrUnion.pu8, pThis->MemOp.ab[0]); 2988 break; 2989 case 2: 2990 if (*PtrUnion.pu16 == pThis->MemOp.au16[0]) 2991 continue; 2992 Bs3TestFailedF("op%u: Wrote %#06RX16, expected %#06RX16", 2993 iOperand, *PtrUnion.pu16, pThis->MemOp.au16[0]); 2994 break; 2995 case 4: 2996 if (*PtrUnion.pu32 == pThis->MemOp.au32[0]) 2997 continue; 2998 Bs3TestFailedF("op%u: Wrote %#010RX32, expected %#010RX32", 2999 iOperand, *PtrUnion.pu32, pThis->MemOp.au32[0]); 3000 break; 3001 case 8: 3002 if (*PtrUnion.pu64 == pThis->MemOp.au64[0]) 3003 continue; 3004 Bs3TestFailedF("op%u: Wrote %#018RX64, expected %#018RX64", 3005 iOperand, *PtrUnion.pu64, pThis->MemOp.au64[0]); 3006 break; 3007 default: 3008 if (Bs3MemCmp(PtrUnion.pb, pThis->MemOp.ab, pThis->aOperands[iOperand].cbOp) == 0) 3009 continue; 3010 Bs3TestFailedF("op%u: Wrote %.*Rhxs, expected %.*Rhxs", 3011 iOperand, 3012 pThis->aOperands[iOperand].cbOp, PtrUnion.pb, 3013 pThis->aOperands[iOperand].cbOp, pThis->MemOp.ab); 3014 break; 3015 } 2995 3016 } 3017 else 3018 Bs3TestFailedF("op%u: off is zero\n", iOperand); 2996 3019 fOkay = false; 2997 3020 } … … 3056 3079 * Report failure. 3057 3080 */ 3058 Bs3TestFailedF("%RU32[%u]: encoding#%u: %.*Rhxs", 3059 pThis->iInstr, pThis->iTest, iEncoding, pThis->cbCurInstr, pThis->abCurInstr); 3081 Bs3TestFailedF("ins#%RU32/test#%u: encoding #%u: %.*Rhxs%s", 3082 pThis->iInstr, pThis->iTest, iEncoding, pThis->cbCurInstr, pThis->abCurInstr, 3083 fInvalidEncodingPgFault ? " (cut short)" : ""); 3060 3084 } 3061 3085 else 3062 Bs3TestFailedF(" %RU32[%u]: bXcpt=%#x expected %#x; rip=%RX64 expected %RX64; encoding#%u: %.*Rhxs",3086 Bs3TestFailedF("ins#%RU32/test#%u: bXcpt=%#x expected %#x; rip=%RX64 expected %RX64; encoding#%u: %.*Rhxs%s", 3063 3087 pThis->iInstr, pThis->iTest, 3064 3088 pThis->TrapFrame.bXcpt, bExpectedXcpt, 3065 3089 pThis->TrapFrame.Ctx.rip.u, pThis->Ctx.rip.u + cbAdjustPc, 3066 iEncoding, pThis->cbCurInstr, pThis->abCurInstr );3090 iEncoding, pThis->cbCurInstr, pThis->abCurInstr, fInvalidEncodingPgFault ? " (cut short)" : ""); 3067 3091 Bs3TestPrintf("cpl=%u cbOperands=%u\n", pThis->uCpl, pThis->cbOperand); 3068 3092 … … 3117 3141 case BS3CG1OPLOC_MEM: 3118 3142 case BS3CG1OPLOC_MEM_RW: 3119 PtrUnion.pb = &pThis->pbDataPg[X86_PAGE_SIZE - pThis->aOperands[iOperand].off]; 3120 switch (pThis->aOperands[iOperand].cbOp) 3143 if (pThis->aOperands[iOperand].off) 3121 3144 { 3122 case 1: Bs3TestPrintf("op%u: result mem08: %#04RX8\n", iOperand, *PtrUnion.pu8); break; 3123 case 2: Bs3TestPrintf("op%u: result mem16: %#06RX16\n", iOperand, *PtrUnion.pu16); break; 3124 case 4: Bs3TestPrintf("op%u: result mem32: %#010RX32\n", iOperand, *PtrUnion.pu32); break; 3125 case 8: Bs3TestPrintf("op%u: result mem64: %#018RX64\n", iOperand, *PtrUnion.pu64); break; 3126 default: 3127 Bs3TestPrintf("op%u: result mem%u: %.*Rhxs\n", iOperand, pThis->aOperands[iOperand].cbOp * 8, 3128 pThis->aOperands[iOperand].cbOp, PtrUnion.pb); 3129 break; 3130 } 3131 if (pThis->aOperands[iOperand].enmLocation == BS3CG1OPLOC_MEM_RW) 3132 { 3133 PtrUnion.pb = pThis->MemOp.ab; 3145 PtrUnion.pb = &pThis->pbDataPg[X86_PAGE_SIZE - pThis->aOperands[iOperand].off]; 3134 3146 switch (pThis->aOperands[iOperand].cbOp) 3135 3147 { 3136 case 1: Bs3TestPrintf("op%u: expect mem08: %#04RX8\n", iOperand, *PtrUnion.pu8); break;3137 case 2: Bs3TestPrintf("op%u: expect mem16: %#06RX16\n", iOperand, *PtrUnion.pu16); break;3138 case 4: Bs3TestPrintf("op%u: expect mem32: %#010RX32\n", iOperand, *PtrUnion.pu32); break;3139 case 8: Bs3TestPrintf("op%u: expect mem64: %#018RX64\n", iOperand, *PtrUnion.pu64); break;3148 case 1: Bs3TestPrintf("op%u: result mem08: %#04RX8\n", iOperand, *PtrUnion.pu8); break; 3149 case 2: Bs3TestPrintf("op%u: result mem16: %#06RX16\n", iOperand, *PtrUnion.pu16); break; 3150 case 4: Bs3TestPrintf("op%u: result mem32: %#010RX32\n", iOperand, *PtrUnion.pu32); break; 3151 case 8: Bs3TestPrintf("op%u: result mem64: %#018RX64\n", iOperand, *PtrUnion.pu64); break; 3140 3152 default: 3141 Bs3TestPrintf("op%u: expect mem%u: %.*Rhxs\n", iOperand, pThis->aOperands[iOperand].cbOp * 8,3153 Bs3TestPrintf("op%u: result mem%u: %.*Rhxs\n", iOperand, pThis->aOperands[iOperand].cbOp * 8, 3142 3154 pThis->aOperands[iOperand].cbOp, PtrUnion.pb); 3143 3155 break; 3144 3156 } 3157 if (pThis->aOperands[iOperand].enmLocation == BS3CG1OPLOC_MEM_RW) 3158 { 3159 PtrUnion.pb = pThis->MemOp.ab; 3160 switch (pThis->aOperands[iOperand].cbOp) 3161 { 3162 case 1: Bs3TestPrintf("op%u: expect mem08: %#04RX8\n", iOperand, *PtrUnion.pu8); break; 3163 case 2: Bs3TestPrintf("op%u: expect mem16: %#06RX16\n", iOperand, *PtrUnion.pu16); break; 3164 case 4: Bs3TestPrintf("op%u: expect mem32: %#010RX32\n", iOperand, *PtrUnion.pu32); break; 3165 case 8: Bs3TestPrintf("op%u: expect mem64: %#018RX64\n", iOperand, *PtrUnion.pu64); break; 3166 default: 3167 Bs3TestPrintf("op%u: expect mem%u: %.*Rhxs\n", iOperand, pThis->aOperands[iOperand].cbOp * 8, 3168 pThis->aOperands[iOperand].cbOp, PtrUnion.pb); 3169 break; 3170 } 3171 } 3145 3172 } 3173 else 3174 Bs3TestPrintf("op%u: mem%u: zero off value!!\n", iOperand, pThis->aOperands[iOperand].cbOp * 8); 3146 3175 break; 3147 3176 } … … 3153 3182 Bs3TestPrintf("-- Expected context:\n"); 3154 3183 Bs3RegCtxPrint(&pThis->Ctx); 3184 if (pThis->fWorkExtCtx) 3185 Bs3TestPrintf("xcr0=%RX64\n", pThis->pExtCtx->fXcr0Saved); 3155 3186 Bs3TestPrintf("-- Actual context:\n"); 3156 3187 Bs3TrapPrintFrame(&pThis->TrapFrame); 3188 if (pThis->fWorkExtCtx) 3189 Bs3TestPrintf("xcr0=%RX64\n", pThis->pResultExtCtx->fXcr0Saved); 3157 3190 Bs3TestPrintf("\n"); 3158 3191 return false; … … 3215 3248 pThis->pszMode = Bs3GetModeName(bMode); 3216 3249 pThis->pszModeShort = Bs3GetModeNameShortLower(bMode); 3250 pThis->bCpuVendor = Bs3GetCpuVendor(); 3217 3251 pThis->pchMnemonic = g_achBs3Cg1Mnemonics; 3218 3252 pThis->pabOperands = g_abBs3Cg1Operands; … … 3566 3600 pThis->Ctx.rflags.u32 &= ~X86_EFL_RF; 3567 3601 pThis->Ctx.rflags.u32 |= pThis->TrapFrame.Ctx.rflags.u32 & X86_EFL_RF; 3568 pThis->bValueXcpt = UINT8_MAX; 3602 pThis->bValueXcpt = UINT8_MAX; //??? 3569 3603 if ( pThis->fInvalidEncoding 3570 3604 || pThis->bAlignmentXcpt != UINT8_MAX … … 3574 3608 &pThis->TrapFrame.Ctx, NULL /*pbCode*/)) 3575 3609 { 3576 Bs3Cg1CheckResult(pThis, bTestXcptExpected, iEncoding); 3610 Bs3Cg1CheckResult(pThis, bTestXcptExpected, false /*fInvalidEncodingPgFault*/, iEncoding); 3611 } 3612 3613 /* 3614 * If this is an invalid encoding or instruction, check that we 3615 * get a page fault when shortening it by one byte. 3616 * (Since we didn't execute the output context modifier, we don't 3617 * need to re-initialize the start context.) 3618 */ 3619 if ( pThis->fInvalidEncoding 3620 && BS3_MODE_IS_PAGED(pThis->bMode) 3621 && pThis->cbCurInstr) 3622 { 3623 pbCode += 1; 3624 offCode += 1; 3625 pThis->Ctx.rip.u = pThis->CodePgRip + offCode; 3626 Bs3MemCpy(pbCode, pThis->abCurInstr, pThis->cbCurInstr - 1); 3627 3628 /* Run the instruction. */ 3629 BS3CG1_DPRINTF(("dbg: Running test #%u (cut short #PF)\n", pThis->iTest)); 3630 //Bs3RegCtxPrint(&pThis->Ctx); 3631 if (pThis->fWorkExtCtx) 3632 Bs3ExtCtxRestore(pThis->pExtCtx); 3633 Bs3TrapSetJmpAndRestore(&pThis->Ctx, &pThis->TrapFrame); 3634 if (pThis->fWorkExtCtx) 3635 Bs3ExtCtxSave(pThis->pResultExtCtx); 3636 BS3CG1_DPRINTF(("dbg: bXcpt=%#x rip=%RX64 -> %RX64 (cut short #PF)\n", 3637 pThis->TrapFrame.bXcpt, pThis->Ctx.rip.u, pThis->TrapFrame.Ctx.rip.u)); 3638 3639 /* Check it */ 3640 pThis->Ctx.rflags.u32 &= ~X86_EFL_RF; 3641 pThis->Ctx.rflags.u32 |= pThis->TrapFrame.Ctx.rflags.u32 & X86_EFL_RF; 3642 Bs3Cg1CheckResult(pThis, X86_XCPT_PF, true /*fInvalidEncodingPgFault*/, iEncoding); 3577 3643 } 3578 3644 } … … 3614 3680 #if 0 3615 3681 /* (for debugging) */ 3616 if (bMode >= BS3_MODE_PE16)3682 if (bMode != BS3_MODE_PPV86) 3617 3683 return BS3TESTDOMODE_SKIPPED; 3618 3684 #endif -
trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-generated-1.h
r66450 r66457 575 575 typedef enum BS3CG1PRED 576 576 { 577 BS3CG1PRED_INVALID = 0, 578 579 /* Operand size. */ 580 BS3CG1PRED_SIZE_O16, 581 BS3CG1PRED_SIZE_O32, 582 BS3CG1PRED_SIZE_O64, 583 /* Execution ring. */ 584 BS3CG1PRED_RING_0, 585 BS3CG1PRED_RING_1, 586 BS3CG1PRED_RING_2, 587 BS3CG1PRED_RING_3, 588 BS3CG1PRED_RING_0_THRU_2, 589 BS3CG1PRED_RING_1_THRU_3, 590 /* Basic code mode. */ 591 BS3CG1PRED_CODE_64BIT, 592 BS3CG1PRED_CODE_32BIT, 593 BS3CG1PRED_CODE_16BIT, 594 /* CPU modes. */ 595 BS3CG1PRED_MODE_REAL, 596 BS3CG1PRED_MODE_PROT, 597 BS3CG1PRED_MODE_LONG, 598 BS3CG1PRED_MODE_V86, 599 BS3CG1PRED_MODE_SMM, 600 BS3CG1PRED_MODE_VMX, 601 BS3CG1PRED_MODE_SVM, 602 /* Paging on/off */ 603 BS3CG1PRED_PAGING_ON, 604 BS3CG1PRED_PAGING_OFF, 605 606 BS3CG1PRED_END 577 BS3CG1PRED_INVALID = 0, 578 579 /* Operand size. */ 580 BS3CG1PRED_SIZE_O16, 581 BS3CG1PRED_SIZE_O32, 582 BS3CG1PRED_SIZE_O64, 583 /* Execution ring. */ 584 BS3CG1PRED_RING_0, 585 BS3CG1PRED_RING_1, 586 BS3CG1PRED_RING_2, 587 BS3CG1PRED_RING_3, 588 BS3CG1PRED_RING_0_THRU_2, 589 BS3CG1PRED_RING_1_THRU_3, 590 /* Basic code mode. */ 591 BS3CG1PRED_CODE_64BIT, 592 BS3CG1PRED_CODE_32BIT, 593 BS3CG1PRED_CODE_16BIT, 594 /* CPU modes. */ 595 BS3CG1PRED_MODE_REAL, 596 BS3CG1PRED_MODE_PROT, 597 BS3CG1PRED_MODE_LONG, 598 BS3CG1PRED_MODE_V86, 599 BS3CG1PRED_MODE_SMM, 600 BS3CG1PRED_MODE_VMX, 601 BS3CG1PRED_MODE_SVM, 602 /* Paging on/off */ 603 BS3CG1PRED_PAGING_ON, 604 BS3CG1PRED_PAGING_OFF, 605 /* CPU Vendors. */ 606 BS3CG1PRED_VENDOR_AMD, 607 BS3CG1PRED_VENDOR_INTEL, 608 BS3CG1PRED_VENDOR_VIA, 609 610 BS3CG1PRED_END 607 611 } BS3CG1PRED; 608 612
Note:
See TracChangeset
for help on using the changeset viewer.