- 時間撮記:
- 2016-3-27 下午11:38:25 (9 年 以前)
- 檔案:
-
- 修改 1 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-basic-2-template.c
r60213 r60214 465 465 466 466 #if TMPL_MODE == BS3_MODE_PE16 || TMPL_MODE == BS3_MODE_PE16_32 467 467 468 /** 468 469 * Worker for bs3CpuBasic2_TssGateEsp that tests the INT 80 from outer rings. … … 518 519 } 519 520 } 520 #endif 521 522 523 BS3_DECL(uint8_t) TMPL_NM(bs3CpuBasic2_TssGateEsp)(uint8_t bMode) 524 { 525 uint8_t bRet = 0; 521 522 #define bs3CpuBasic2_TssGateEspCommon BS3_CMN_NM(bs3CpuBasic2_TssGateEspCommon) 523 void bs3CpuBasic2_TssGateEspCommon(uint8_t const bMode, const char * const pszMode, bool const f16BitSys, 524 PX86DESC const paIdt, unsigned const cIdteShift) 525 { 526 526 BS3TRAPFRAME TrapCtx; 527 BS3REGCTX Ctx, Ctx2; 527 BS3REGCTX Ctx; 528 BS3REGCTX Ctx2; 529 # if TMPL_BITS == 16 528 530 uint8_t *pbTmp; 531 # endif 529 532 unsigned uLine; 530 const char *pszMode = BS3_DATA_NM(TMPL_NM(g_szBs3ModeName));531 bool const f16BitSys = BS3_MODE_IS_16BIT_SYS(TMPL_MODE);532 533 pbTmp = NULL; NOREF(pbTmp); uLine = 0; NOREF(uLine); NOREF(pszMode); NOREF(f16BitSys);534 533 535 534 /* make sure they're allocated */ … … 537 536 Bs3MemZero(&Ctx2, sizeof(Ctx2)); 538 537 Bs3MemZero(&TrapCtx, sizeof(TrapCtx)); 539 540 #if TMPL_MODE == BS3_MODE_PE16 \541 || TMPL_MODE == BS3_MODE_PE16_32 \542 || TMPL_MODE == BS3_MODE_PP16 \543 || TMPL_MODE == BS3_MODE_PP16_32 \544 || TMPL_MODE == BS3_MODE_PAE16 \545 || TMPL_MODE == BS3_MODE_PAE16_32 \546 || TMPL_MODE == BS3_MODE_PE32547 538 548 539 Bs3RegCtxSave(&Ctx); … … 558 549 * the DPLs. 559 550 */ 560 MyBs3Idt[0x80].Gate.u2Dpl = 3;561 MyBs3Idt[0x81].Gate.u2Dpl = 0;551 paIdt[0x80 << cIdteShift].Gate.u2Dpl = 3; 552 paIdt[0x81 << cIdteShift].Gate.u2Dpl = 0; 562 553 563 554 /* … … 606 597 607 598 /* Different rings but switch the SS bitness in the TSS. */ 599 if (f16BitSys) 600 { 601 Bs3Tss16.ss0 = BS3_SEL_R0_SS32; 602 bs3CpuBasic2_TssGateEsp_AltStackOuterRing(&Ctx, 1, pbAltStack, cbAltStack, 603 false, f16BitSys, f16BitSys, pszMode, __LINE__); 604 Bs3Tss16.ss0 = BS3_SEL_R0_SS16; 605 } 606 else 607 { 608 Bs3Tss32.ss0 = BS3_SEL_R0_SS16; 609 bs3CpuBasic2_TssGateEsp_AltStackOuterRing(&Ctx, 1, pbAltStack, cbAltStack, 610 true, f16BitSys, f16BitSys, pszMode, __LINE__); 611 Bs3Tss32.ss0 = BS3_SEL_R0_SS32; 612 } 613 614 Bs3MemFree(pbAltStack, cbAltStack); 615 } 616 else 617 Bs3TestPrintf("%s: Skipping ESP check, alloc failed\n", pszMode); 618 } 619 else 620 Bs3TestPrintf("%s: Skipping ESP check, CPU too old\n", pszMode); 621 } 622 623 #endif 624 625 626 BS3_DECL(uint8_t) TMPL_NM(bs3CpuBasic2_TssGateEsp)(uint8_t bMode) 627 { 628 uint8_t bRet = 0; 629 #if 0 630 BS3TRAPFRAME TrapCtx; 631 BS3REGCTX Ctx, Ctx2; 632 uint8_t *pbTmp; 633 unsigned uLine; 634 const char *pszMode = BS3_DATA_NM(TMPL_NM(g_szBs3ModeName)); 635 bool const f16BitSys = BS3_MODE_IS_16BIT_SYS(TMPL_MODE); 636 637 pbTmp = NULL; NOREF(pbTmp); uLine = 0; NOREF(uLine); NOREF(pszMode); NOREF(f16BitSys); 638 639 /* make sure they're allocated */ 640 Bs3MemZero(&Ctx, sizeof(Ctx)); 641 Bs3MemZero(&Ctx2, sizeof(Ctx2)); 642 Bs3MemZero(&TrapCtx, sizeof(TrapCtx)); 643 #endif 644 645 #if TMPL_MODE == BS3_MODE_PE16 \ 646 || TMPL_MODE == BS3_MODE_PE16_32 \ 647 || TMPL_MODE == BS3_MODE_PP16 \ 648 || TMPL_MODE == BS3_MODE_PP16_32 \ 649 || TMPL_MODE == BS3_MODE_PAE16 \ 650 || TMPL_MODE == BS3_MODE_PAE16_32 \ 651 || TMPL_MODE == BS3_MODE_PE32 652 653 #if 1 654 bs3CpuBasic2_TssGateEspCommon(bMode, 655 BS3_DATA_NM(TMPL_NM(g_szBs3ModeName)), 656 BS3_MODE_IS_16BIT_SYS(TMPL_MODE), 657 (PX86DESC)MyBs3Idt, 658 BS3_MODE_IS_64BIT_SYS(TMPL_MODE) ? 1 : 0); 659 #else 660 661 Bs3RegCtxSave(&Ctx); 662 Ctx.rsp.u -= 0x80; 663 Ctx.rip.u = (uintptr_t)BS3_FP_OFF(&TMPL_NM(bs3CpuBasic2_Int80)); 664 # if TMPL_BITS == 32 665 BS3_DATA_NM(g_uBs3TrapEipHint) = Ctx.rip.u32; 666 # endif 667 668 /* 669 * We'll be using IDT entry 80 and 81 here. The first one will be 670 * accessible from all DPLs, the latter not. So, start with setting 671 * the DPLs. 672 */ 673 MyBs3Idt[0x80].Gate.u2Dpl = 3; 674 MyBs3Idt[0x81].Gate.u2Dpl = 0; 675 676 /* 677 * Check that the basic stuff works first. 678 */ 679 Bs3TrapSetJmpAndRestore(&Ctx, &TrapCtx); 680 bs3CpuBasic2_CompareTrapCtx1(&TrapCtx, &Ctx, 2 /*int 80h*/, 0x80 /*bXcpt*/, pszMode, __LINE__); 681 682 bs3CpuBasic2_TssGateEsp_AltStackOuterRing(&Ctx, 1, NULL, 0, f16BitSys, f16BitSys, f16BitSys, pszMode, __LINE__); 683 bs3CpuBasic2_TssGateEsp_AltStackOuterRing(&Ctx, 2, NULL, 0, f16BitSys, f16BitSys, f16BitSys, pszMode, __LINE__); 684 bs3CpuBasic2_TssGateEsp_AltStackOuterRing(&Ctx, 3, NULL, 0, f16BitSys, f16BitSys, f16BitSys, pszMode, __LINE__); 685 686 /* 687 * Check that the upper part of ESP is preserved when doing . 688 */ 689 if ((BS3_DATA_NM(g_uBs3CpuDetected) & BS3CPU_TYPE_MASK) >= BS3CPU_80386) 690 { 691 size_t const cbAltStack = _8K; 692 uint8_t *pbAltStack = Bs3MemAllocZ(BS3MEMKIND_TILED, cbAltStack); 693 if (pbAltStack) 694 { 695 /* same ring */ 696 uLine = __LINE__; 697 Bs3MemCpy(&Ctx2, &Ctx, sizeof(Ctx2)); 698 Ctx2.rsp.u = Bs3SelPtrToFlat(pbAltStack + 0x1980); 699 if (Bs3TrapSetJmp(&TrapCtx)) 700 Bs3RegCtxRestore(&Ctx2, 0); /* (does not return) */ 701 bs3CpuBasic2_CompareTrapCtx1(&TrapCtx, &Ctx2, 2 /*int 80h*/, 0x80 /*bXcpt*/, pszMode, uLine); 702 # if TMPL_BITS == 16 703 if ((pbTmp = (uint8_t *)ASMMemFirstNonZero(pbAltStack, cbAltStack)) != NULL) 704 Bs3TestFailedF("%u - %s: someone touched the alt stack (%p) with SS:ESP=%04x:%#RX32: %p=%02x\n", 705 uLine, pszMode, pbAltStack, Ctx2.ss, Ctx2.rsp.u32, pbTmp, *pbTmp); 706 # else 707 if (ASMMemIsZero(pbAltStack, cbAltStack)) 708 Bs3TestFailedF("%u - %s: alt stack wasn't used despite SS:ESP=%04x:%#RX32\n", 709 uLine, pszMode, Ctx2.ss, Ctx2.rsp.u32); 710 # endif 711 712 /* Different rings (load SS0:SP0 from TSS). */ 713 bs3CpuBasic2_TssGateEsp_AltStackOuterRing(&Ctx, 1, pbAltStack, cbAltStack, 714 f16BitSys, f16BitSys, f16BitSys, pszMode, __LINE__); 715 bs3CpuBasic2_TssGateEsp_AltStackOuterRing(&Ctx, 2, pbAltStack, cbAltStack, 716 f16BitSys, f16BitSys, f16BitSys, pszMode, __LINE__); 717 bs3CpuBasic2_TssGateEsp_AltStackOuterRing(&Ctx, 3, pbAltStack, cbAltStack, 718 f16BitSys, f16BitSys, f16BitSys, pszMode, __LINE__); 719 720 /* Different rings but switch the SS bitness in the TSS. */ 608 721 # if BS3_MODE_IS_16BIT_SYS(TMPL_MODE) 609 722 Bs3Tss16.ss0 = BS3_SEL_R0_SS32; … … 625 738 else 626 739 Bs3TestPrintf("%s: Skipping ESP check, CPU too old\n", pszMode); 627 740 #endif 628 741 #else 629 742 bRet = BS3TESTDOMODE_SKIPPED;
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器