Changeset 97689 in vbox for trunk/src/VBox/ValidationKit
- Timestamp:
- Nov 28, 2022 9:32:44 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-basic-2-x0.c
r97643 r97689 5296 5296 bool const fRmOrV86 = BS3_MODE_IS_RM_OR_V86(bMode); 5297 5297 5298 Bs3RegSetDr7(X86_DR7_INIT_VAL); 5298 5299 for (iTest = 0; iTest < RT_ELEMENTS(s_aTests); iTest++) 5299 5300 { … … 5302 5303 for (iSubTest = 0; iSubTest < RT_ELEMENTS(s_aSubTests); iSubTest++) 5303 5304 { 5304 g_usBs3TestStep = (iTest << 12) | (iSubTest << 1);5305 g_usBs3TestStep = (iTest << 12) | (iSubTest << 4); 5305 5306 if ( s_aSubTests[iSubTest].fRmOrV86 == fRmOrV86 5306 5307 && (s_aSubTests[iSubTest].offDst <= UINT16_MAX || s_aTests[iTest].fOpSizePfx)) … … 5309 5310 uint16_t const cbStkItem = s_aTests[iTest].fOpSizePfx ? 4 : 2; 5310 5311 uint16_t const cbFrame = (s_aSubTests[iSubTest].fInterPriv ? 4 : 2) * cbStkItem; 5312 uint32_t const uFlatDst = Bs3SelFar32ToFlat32(s_aSubTests[iSubTest].offDst, s_aSubTests[iSubTest].uDstCs) 5313 + (s_aSubTests[iSubTest].cDstBits == 64 && !BS3_MODE_IS_64BIT_SYS(bMode)); 5311 5314 RTSEL const uDstSs = s_aSubTests[iSubTest].uDstSs; 5312 5315 uint64_t uDstRspExpect, uDstRspPush; … … 5386 5389 else 5387 5390 bs3CpuBasic2_CompareGpCtx(&TrapCtx, &CtxExpected, s_aSubTests[iSubTest].uErrCd); 5388 g_usBs3TestStep++; 5389 5390 /* Again single stepping: */ 5391 g_usBs3TestStep++; /* 1 */ 5392 5393 /* Bad hw bp: Setup DR0-3 but use invalid length encodings (non-byte) */ 5394 //Bs3TestPrintf("hw bp: bad len\n"); 5395 Bs3RegSetDr0(uFlatDst); 5396 Bs3RegSetDr1(uFlatDst); 5397 Bs3RegSetDr2(uFlatDst); 5398 Bs3RegSetDr3(uFlatDst); 5399 Bs3RegSetDr6(X86_DR6_INIT_VAL); 5400 Bs3RegSetDr7(X86_DR7_INIT_VAL 5401 | X86_DR7_RW(0, X86_DR7_RW_EO) | X86_DR7_LEN(1, X86_DR7_LEN_WORD) | X86_DR7_L_G(1) 5402 | X86_DR7_RW(2, X86_DR7_RW_EO) | X86_DR7_LEN(2, X86_DR7_LEN_DWORD) | X86_DR7_L_G(2) 5403 | ( BS3_MODE_IS_64BIT_SYS(bMode) 5404 ? X86_DR7_RW(3, X86_DR7_RW_EO) | X86_DR7_LEN(3, X86_DR7_LEN_QWORD) | X86_DR7_L_G(3) : 0) ); 5405 bs3CpuBasic2_retf_PrepStack(StkPtr, cbStkItem, s_aSubTests[iSubTest].uDstCs, s_aSubTests[iSubTest].offDst, 5406 s_aSubTests[iSubTest].fInterPriv, s_aTests[iTest].cbImm, 5407 s_aSubTests[iSubTest].uDstSs, uDstRspPush); 5408 Bs3TrapSetJmpAndRestore(&Ctx, &TrapCtx); 5409 Bs3RegSetDr7(X86_DR7_INIT_VAL); 5410 if (s_aSubTests[iSubTest].iXcpt < 0) 5411 bs3CpuBasic2_CompareUdCtx(&TrapCtx, &CtxExpected); 5412 else 5413 bs3CpuBasic2_CompareGpCtx(&TrapCtx, &CtxExpected, s_aSubTests[iSubTest].uErrCd); 5414 bs3CpuBasic2_CheckDr6InitVal(); 5415 g_usBs3TestStep++; /* 2 */ 5416 5417 /* Bad hw bp: setup DR0-3 but don't enable them */ 5418 //Bs3TestPrintf("hw bp: disabled\n"); 5419 //Bs3RegSetDr0(uFlatDst); 5420 //Bs3RegSetDr1(uFlatDst); 5421 //Bs3RegSetDr2(uFlatDst); 5422 //Bs3RegSetDr3(uFlatDst); 5423 Bs3RegSetDr6(X86_DR6_INIT_VAL); 5424 Bs3RegSetDr7(X86_DR7_INIT_VAL); 5425 bs3CpuBasic2_retf_PrepStack(StkPtr, cbStkItem, s_aSubTests[iSubTest].uDstCs, s_aSubTests[iSubTest].offDst, 5426 s_aSubTests[iSubTest].fInterPriv, s_aTests[iTest].cbImm, 5427 s_aSubTests[iSubTest].uDstSs, uDstRspPush); 5428 Bs3TrapSetJmpAndRestore(&Ctx, &TrapCtx); 5429 Bs3RegSetDr7(X86_DR7_INIT_VAL); 5430 if (s_aSubTests[iSubTest].iXcpt < 0) 5431 bs3CpuBasic2_CompareUdCtx(&TrapCtx, &CtxExpected); 5432 else 5433 bs3CpuBasic2_CompareGpCtx(&TrapCtx, &CtxExpected, s_aSubTests[iSubTest].uErrCd); 5434 bs3CpuBasic2_CheckDr6InitVal(); 5435 g_usBs3TestStep++; /* 3 */ 5436 5437 /* Bad hw bp: Points at 2nd byte in the UD2. Docs says it only works when pointing at first byte. */ 5438 //Bs3TestPrintf("hw bp: byte 2\n"); 5439 Bs3RegSetDr0(uFlatDst + 1); 5440 Bs3RegSetDr1(uFlatDst + 1); 5441 //Bs3RegSetDr2(uFlatDst); 5442 //Bs3RegSetDr3(uFlatDst); 5443 Bs3RegSetDr6(X86_DR6_INIT_VAL); 5444 Bs3RegSetDr7(X86_DR7_INIT_VAL 5445 | X86_DR7_RW(0, X86_DR7_RW_EO) | X86_DR7_LEN(0, X86_DR7_LEN_BYTE) | X86_DR7_L_G(0) 5446 | X86_DR7_RW(1, X86_DR7_RW_EO) | X86_DR7_LEN(1, X86_DR7_LEN_BYTE) | X86_DR7_L_G(1)); 5447 bs3CpuBasic2_retf_PrepStack(StkPtr, cbStkItem, s_aSubTests[iSubTest].uDstCs, s_aSubTests[iSubTest].offDst, 5448 s_aSubTests[iSubTest].fInterPriv, s_aTests[iTest].cbImm, 5449 s_aSubTests[iSubTest].uDstSs, uDstRspPush); 5450 Bs3TrapSetJmpAndRestore(&Ctx, &TrapCtx); 5451 Bs3RegSetDr7(X86_DR7_INIT_VAL); 5452 if (s_aSubTests[iSubTest].iXcpt < 0) 5453 bs3CpuBasic2_CompareUdCtx(&TrapCtx, &CtxExpected); 5454 else 5455 bs3CpuBasic2_CompareGpCtx(&TrapCtx, &CtxExpected, s_aSubTests[iSubTest].uErrCd); 5456 bs3CpuBasic2_CheckDr6InitVal(); 5457 g_usBs3TestStep++; /* 4 */ 5458 5459 /* Again with two correctly hardware breakpoints and a disabled one that just matches the address: */ 5460 //Bs3TestPrintf("bp 1 + 3...\n"); 5461 Bs3RegSetDr0(uFlatDst); 5462 Bs3RegSetDr1(uFlatDst); 5463 Bs3RegSetDr2(0); 5464 Bs3RegSetDr3(uFlatDst); 5465 Bs3RegSetDr6(X86_DR6_INIT_VAL); 5466 Bs3RegSetDr7(X86_DR7_INIT_VAL 5467 | X86_DR7_RW(1, X86_DR7_RW_EO) | X86_DR7_LEN(1, X86_DR7_LEN_BYTE) | X86_DR7_L_G(1) 5468 | X86_DR7_RW(3, X86_DR7_RW_EO) | X86_DR7_LEN(3, X86_DR7_LEN_BYTE) | X86_DR7_L_G(3) ); 5469 bs3CpuBasic2_retf_PrepStack(StkPtr, cbStkItem, s_aSubTests[iSubTest].uDstCs, s_aSubTests[iSubTest].offDst, 5470 s_aSubTests[iSubTest].fInterPriv, s_aTests[iTest].cbImm, 5471 s_aSubTests[iSubTest].uDstSs, uDstRspPush); 5472 Bs3TrapSetJmpAndRestore(&Ctx, &TrapCtx); 5473 Bs3RegSetDr7(X86_DR7_INIT_VAL); 5474 if (s_aSubTests[iSubTest].iXcpt < 0) 5475 bs3CpuBasic2_CompareDbCtx(&TrapCtx, &CtxExpected, X86_DR6_B0 | X86_DR6_B1 | X86_DR6_B3); 5476 else 5477 bs3CpuBasic2_CompareGpCtx(&TrapCtx, &CtxExpected, s_aSubTests[iSubTest].uErrCd); 5478 g_usBs3TestStep++; /* 5 */ 5479 5480 /* Again with a single locally enabled breakpoint. */ 5481 //Bs3TestPrintf("bp 0/l...\n"); 5482 Bs3RegSetDr0(uFlatDst); 5483 Bs3RegSetDr1(0); 5484 Bs3RegSetDr2(0); 5485 Bs3RegSetDr3(0); 5486 Bs3RegSetDr6(X86_DR6_INIT_VAL | X86_DR6_B1 | X86_DR6_B2 | X86_DR6_B3 | X86_DR6_BS); 5487 Bs3RegSetDr7(X86_DR7_INIT_VAL 5488 | X86_DR7_RW(0, X86_DR7_RW_EO) | X86_DR7_LEN(0, X86_DR7_LEN_BYTE) | X86_DR7_L(0)); 5489 bs3CpuBasic2_retf_PrepStack(StkPtr, cbStkItem, s_aSubTests[iSubTest].uDstCs, s_aSubTests[iSubTest].offDst, 5490 s_aSubTests[iSubTest].fInterPriv, s_aTests[iTest].cbImm, 5491 s_aSubTests[iSubTest].uDstSs, uDstRspPush); 5492 Bs3TrapSetJmpAndRestore(&Ctx, &TrapCtx); 5493 Bs3RegSetDr7(X86_DR7_INIT_VAL); 5494 if (s_aSubTests[iSubTest].iXcpt < 0) 5495 bs3CpuBasic2_CompareDbCtx(&TrapCtx, &CtxExpected, X86_DR6_B0 | X86_DR6_BS); /* B0-B3 set, BS preserved */ 5496 else 5497 bs3CpuBasic2_CompareGpCtx(&TrapCtx, &CtxExpected, s_aSubTests[iSubTest].uErrCd); 5498 g_usBs3TestStep++; /* 6 */ 5499 5500 /* Again with a single globally enabled breakpoint. */ 5501 //Bs3TestPrintf("bp 2/g...\n"); 5502 Bs3RegSetDr0(0); 5503 //Bs3RegSetDr1(0); 5504 Bs3RegSetDr2(uFlatDst); 5505 //Bs3RegSetDr3(0); 5506 Bs3RegSetDr6(X86_DR6_INIT_VAL | X86_DR6_BS | X86_DR6_BD | X86_DR6_BT | X86_DR6_B2); 5507 Bs3RegSetDr7(X86_DR7_INIT_VAL 5508 | X86_DR7_RW(2, X86_DR7_RW_EO) | X86_DR7_LEN(2, X86_DR7_LEN_BYTE) | X86_DR7_G(2)); 5509 bs3CpuBasic2_retf_PrepStack(StkPtr, cbStkItem, s_aSubTests[iSubTest].uDstCs, s_aSubTests[iSubTest].offDst, 5510 s_aSubTests[iSubTest].fInterPriv, s_aTests[iTest].cbImm, 5511 s_aSubTests[iSubTest].uDstSs, uDstRspPush); 5512 Bs3TrapSetJmpAndRestore(&Ctx, &TrapCtx); 5513 Bs3RegSetDr7(X86_DR7_INIT_VAL); 5514 if (s_aSubTests[iSubTest].iXcpt < 0) 5515 bs3CpuBasic2_CompareDbCtx(&TrapCtx, &CtxExpected, X86_DR6_B2 | X86_DR6_BS | X86_DR6_BD | X86_DR6_BT); 5516 else 5517 bs3CpuBasic2_CompareGpCtx(&TrapCtx, &CtxExpected, s_aSubTests[iSubTest].uErrCd); 5518 g_usBs3TestStep++; /* 7 */ 5519 5520 5521 /* Now do single stepping: */ 5391 5522 //Bs3TestPrintf("stepping...\n"); 5392 5523 Bs3RegSetDr6(X86_DR6_INIT_VAL); … … 5408 5539 Ctx.rflags.u16 &= ~X86_EFL_TF; 5409 5540 CtxExpected.rflags.u16 = Ctx.rflags.u16; 5410 g_usBs3TestStep++; 5541 g_usBs3TestStep++; /* 8 */ 5542 5543 /* Single step with B0-B3 set to check that they're not preserved 5544 and with BD & BT to check that they are (checked on Intel 6700K): */ 5545 //Bs3TestPrintf("stepping b0-b3+bd+bt=1...\n"); 5546 Bs3RegSetDr6(X86_DR6_INIT_VAL | X86_DR6_B_MASK | X86_DR6_BD | X86_DR6_BT); 5547 Ctx.rflags.u16 |= X86_EFL_TF; 5548 CtxExpected.rflags.u16 = Ctx.rflags.u16; 5549 bs3CpuBasic2_retf_PrepStack(StkPtr, cbStkItem, s_aSubTests[iSubTest].uDstCs, s_aSubTests[iSubTest].offDst, 5550 s_aSubTests[iSubTest].fInterPriv, s_aTests[iTest].cbImm, 5551 s_aSubTests[iSubTest].uDstSs, uDstRspPush); 5552 Bs3TrapSetJmpAndRestore(&Ctx, &TrapCtx); 5553 if (s_aSubTests[iSubTest].iXcpt < 0) 5554 bs3CpuBasic2_CompareDbCtx(&TrapCtx, &CtxExpected, X86_DR6_BS | X86_DR6_BD | X86_DR6_BT); 5555 else 5556 bs3CpuBasic2_CompareGpCtx(&TrapCtx, &CtxExpected, s_aSubTests[iSubTest].uErrCd); 5557 Ctx.rflags.u16 &= ~X86_EFL_TF; 5558 CtxExpected.rflags.u16 = Ctx.rflags.u16; 5559 g_usBs3TestStep++; /* 9 */ 5560 5411 5561 } 5412 5562 }
Note:
See TracChangeset
for help on using the changeset viewer.