Changeset 60679 in vbox for trunk/src/VBox/ValidationKit/bootsectors
- Timestamp:
- Apr 24, 2016 3:55:00 PM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 106847
- Location:
- trunk/src/VBox/ValidationKit/bootsectors
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-basic-2-template.c
r60678 r60679 73 73 #endif 74 74 75 75 76 /********************************************************************************************************************************* 76 77 * Structures and Typedefs * … … 121 122 extern FNBS3FAR bs3CpuBasic2_sgdt_bx_ud2_c32; 122 123 extern FNBS3FAR bs3CpuBasic2_sgdt_bx_ud2_c64; 124 extern FNBS3FAR bs3CpuBasic2_sgdt_ss_bx_ud2_c16; 125 extern FNBS3FAR bs3CpuBasic2_sgdt_ss_bx_ud2_c32; 126 extern FNBS3FAR bs3CpuBasic2_sgdt_rexw_bx_ud2_c64; 123 127 extern FNBS3FAR bs3CpuBasic2_sgdt_opsize_bx_ud2_c16; 124 128 extern FNBS3FAR bs3CpuBasic2_sgdt_opsize_bx_ud2_c32; 125 129 extern FNBS3FAR bs3CpuBasic2_sgdt_opsize_bx_ud2_c64; 126 extern FNBS3FAR bs3CpuBasic2_ lidt_bx_ud2_c16;127 extern FNBS3FAR bs3CpuBasic2_ lidt_bx_ud2_c32;128 extern FNBS3FAR bs3CpuBasic2_ lidt_bx_ud2_c64;130 extern FNBS3FAR bs3CpuBasic2_sgdt_opsize_ss_bx_ud2_c16; 131 extern FNBS3FAR bs3CpuBasic2_sgdt_opsize_ss_bx_ud2_c32; 132 extern FNBS3FAR bs3CpuBasic2_sgdt_opsize_rexw_bx_ud2_c64; 129 133 #endif 130 134 … … 145 149 { 146 150 { bs3CpuBasic2_sidt_bx_ud2_c16, 3, false, BS3_MODE_CODE_16 | BS3_MODE_CODE_V86 }, 147 //{ bs3CpuBasic2_sidt_ss_bx_ud2_c16, 4, true, BS3_MODE_CODE_16 | BS3_MODE_CODE_V86 },151 { bs3CpuBasic2_sidt_ss_bx_ud2_c16, 4, true, BS3_MODE_CODE_16 | BS3_MODE_CODE_V86 }, 148 152 { bs3CpuBasic2_sidt_opsize_bx_ud2_c16, 4, false, BS3_MODE_CODE_16 | BS3_MODE_CODE_V86 }, 149 //{ bs3CpuBasic2_sidt_opsize_ss_bx_ud2_c16, 5, true, BS3_MODE_CODE_16 | BS3_MODE_CODE_V86 },153 { bs3CpuBasic2_sidt_opsize_ss_bx_ud2_c16, 5, true, BS3_MODE_CODE_16 | BS3_MODE_CODE_V86 }, 150 154 { bs3CpuBasic2_sidt_bx_ud2_c32, 3, false, BS3_MODE_CODE_32 }, 151 //{ bs3CpuBasic2_sidt_ss_bx_ud2_c32, 4, true, BS3_MODE_CODE_32 },155 { bs3CpuBasic2_sidt_ss_bx_ud2_c32, 4, true, BS3_MODE_CODE_32 }, 152 156 { bs3CpuBasic2_sidt_opsize_bx_ud2_c32, 4, false, BS3_MODE_CODE_32 }, 153 //{ bs3CpuBasic2_sidt_opsize_ss_bx_ud2_c32, 5, true, BS3_MODE_CODE_32 },157 { bs3CpuBasic2_sidt_opsize_ss_bx_ud2_c32, 5, true, BS3_MODE_CODE_32 }, 154 158 { bs3CpuBasic2_sidt_bx_ud2_c64, 3, false, BS3_MODE_CODE_64 }, 155 159 { bs3CpuBasic2_sidt_rexw_bx_ud2_c64, 4, false, BS3_MODE_CODE_64 }, … … 158 162 }; 159 163 160 #if 0 161 static BS3CB2SIDTSGDT const g_aSgdtNormal[3] = 162 { 163 { bs3CpuBasic2_sgdt_bx_ud2_c16, bs3CpuBasic2_sgdt_ss_bx_ud2_c16, BS3_MODE_CODE_16 | BS3_MODE_CODE_V86 }, 164 { bs3CpuBasic2_sgdt_bx_ud2_c32, bs3CpuBasic2_sgdt_ss_bx_ud2_c32, BS3_MODE_CODE_32 }, 165 { bs3CpuBasic2_sgdt_bx_ud2_c64, bs3CpuBasic2_sgdt_rexw_bx_ud2_c64, BS3_MODE_CODE_64 }, 164 165 static BS3CB2SIDTSGDT const g_aSgdtWorkers[] = 166 { 167 { bs3CpuBasic2_sgdt_bx_ud2_c16, 3, false, BS3_MODE_CODE_16 | BS3_MODE_CODE_V86 }, 168 { bs3CpuBasic2_sgdt_ss_bx_ud2_c16, 4, true, BS3_MODE_CODE_16 | BS3_MODE_CODE_V86 }, 169 { bs3CpuBasic2_sgdt_opsize_bx_ud2_c16, 4, false, BS3_MODE_CODE_16 | BS3_MODE_CODE_V86 }, 170 { bs3CpuBasic2_sgdt_opsize_ss_bx_ud2_c16, 5, true, BS3_MODE_CODE_16 | BS3_MODE_CODE_V86 }, 171 { bs3CpuBasic2_sgdt_bx_ud2_c32, 3, false, BS3_MODE_CODE_32 }, 172 { bs3CpuBasic2_sgdt_ss_bx_ud2_c32, 4, true, BS3_MODE_CODE_32 }, 173 { bs3CpuBasic2_sgdt_opsize_bx_ud2_c32, 4, false, BS3_MODE_CODE_32 }, 174 { bs3CpuBasic2_sgdt_opsize_ss_bx_ud2_c32, 5, true, BS3_MODE_CODE_32 }, 175 { bs3CpuBasic2_sgdt_bx_ud2_c64, 3, false, BS3_MODE_CODE_64 }, 176 { bs3CpuBasic2_sgdt_rexw_bx_ud2_c64, 4, false, BS3_MODE_CODE_64 }, 177 { bs3CpuBasic2_sgdt_opsize_bx_ud2_c64, 4, false, BS3_MODE_CODE_64 }, 178 { bs3CpuBasic2_sgdt_opsize_rexw_bx_ud2_c64, 5, false, BS3_MODE_CODE_64 }, 166 179 }; 167 168 static BS3CB2SIDTSGDT const g_aSgdtOpSize[3] =169 {170 { bs3CpuBasic2_sgdt_opsize_bx_ud2_c16, bs3CpuBasic2_sgdt_ss_bx_ud2_c16, BS3_MODE_CODE_16 | BS3_MODE_CODE_V86 },171 { bs3CpuBasic2_sgdt_opsize_bx_ud2_c32, bs3CpuBasic2_sgdt_ss_bx_ud2_c32, BS3_MODE_CODE_32 },172 { bs3CpuBasic2_sgdt_opsize_bx_ud2_c64, bs3CpuBasic2_sgdt_rexw_bx_ud2_c64, BS3_MODE_CODE_64 },173 };174 #endif175 180 176 181 … … 1388 1393 int off; 1389 1394 unsigned cb; 1390 uint8_t bDpl;1391 1395 uint8_t BS3_FAR *pbTest; 1392 1396 Bs3TestPrintf("bs3CpuBasic2_sidt_sgdt_One: %p bTestMode=%#x bRing=%d\n", pWorker, bTestMode, bRing); … … 1402 1406 at our SIDT [xBX] + UD2 combo, and point DS:xBX at abBuf. */ 1403 1407 Bs3RegCtxSaveEx(&Ctx, bTestMode, 256 /*cbExtraStack*/); 1404 Bs3RegCtxSetGrp DsFromCurPtr(&Ctx, &Ctx.rbx, abBuf);1408 Bs3RegCtxSetGrpSegFromCurPtr(&Ctx, &Ctx.rbx, pWorker->fSs ? &Ctx.ss : &Ctx.ds, abBuf); 1405 1409 Bs3RegCtxSetRipCsFromLnkPtr(&Ctx, pWorker->fpfnWorker); 1406 1410 if (BS3_MODE_IS_16BIT_SYS(bTestMode)) … … 1458 1462 { 1459 1463 pbBuf = &abBuf[off]; 1460 Bs3RegCtxSetGrp DsFromCurPtr(&Ctx, &Ctx.rbx, &abBuf[off]);1464 Bs3RegCtxSetGrpSegFromCurPtr(&Ctx, &Ctx.rbx, pWorker->fSs ? &Ctx.ss : &Ctx.ds, &abBuf[off]); 1461 1465 CtxUdExpected.rbx.u = Ctx.rbx.u; 1462 1466 … … 1497 1501 } 1498 1502 pbBuf = abBuf; 1499 Bs3RegCtxSetGrp DsFromCurPtr(&Ctx, &Ctx.rbx, abBuf);1503 Bs3RegCtxSetGrpSegFromCurPtr(&Ctx, &Ctx.rbx, pWorker->fSs ? &Ctx.ss : &Ctx.ds, abBuf); 1500 1504 CtxUdExpected.rbx.u = Ctx.rbx.u; 1501 1505 … … 1515 1519 Bs3GdteTestPage00.Gen.u8BaseHigh2 = (uint8_t)(uFlatBuf >> 24); 1516 1520 1517 CtxUdExpected.ds = Ctx.ds = BS3_SEL_TEST_PAGE_00 | bRing; 1521 if (pWorker->fSs) 1522 CtxUdExpected.ss = Ctx.ss = BS3_SEL_TEST_PAGE_00 | bRing; 1523 else 1524 CtxUdExpected.ds = Ctx.ds = BS3_SEL_TEST_PAGE_00 | bRing; 1518 1525 1519 1526 /* Expand up (normal). */ … … 1539 1546 else 1540 1547 { 1541 bs3CpuBasic2_CompareGpCtx(&TrapCtx, &Ctx, 0); 1548 if (pWorker->fSs) 1549 bs3CpuBasic2_CompareSsCtx(&TrapCtx, &Ctx, 0, false /*f486ResumeFlagHint*/); 1550 else 1551 bs3CpuBasic2_CompareGpCtx(&TrapCtx, &Ctx, 0); 1542 1552 if (off + 2 <= cbLimit + 1) 1543 1553 { … … 1596 1606 else 1597 1607 { 1598 bs3CpuBasic2_CompareGpCtx(&TrapCtx, &Ctx, 0); 1608 if (pWorker->fSs) 1609 bs3CpuBasic2_CompareSsCtx(&TrapCtx, &Ctx, 0, false /*f486ResumeFlagHint*/); 1610 else 1611 bs3CpuBasic2_CompareGpCtx(&TrapCtx, &Ctx, 0); 1599 1612 if (!ASMMemIsAllU8(abBuf, sizeof(abBuf), bFiller)) 1600 1613 Bs3TestFailedF("Bytes touched on #GP: cbIdtr=%u off=%u cbLimit=%u bFiller=%#x abBuf=%.*Rhxs\n", … … 1613 1626 } 1614 1627 1615 Bs3RegCtxSetGrpDsFromCurPtr(&Ctx, &Ctx.rbx, pbBuf); 1628 Bs3RegCtxSetGrpSegFromCurPtr(&Ctx, &Ctx.rbx, pWorker->fSs ? &Ctx.ss : &Ctx.ds, abBuf); 1629 CtxUdExpected.rbx.u = Ctx.rbx.u; 1630 CtxUdExpected.ss = Ctx.ss; 1631 CtxUdExpected.ds = Ctx.ds; 1616 1632 } 1617 1633 … … 1620 1636 */ 1621 1637 if ( BS3_MODE_IS_PAGED(bTestMode) 1638 && (!pWorker->fSs || bRing == 3) /* SS.DPL == CPL, we'll get some tiled ring-3 selector here. */ 1622 1639 && (pbTest = (uint8_t BS3_FAR *)Bs3MemGuardedTestPageAlloc(BS3MEMKIND_TILED)) != NULL) 1623 1640 { 1624 1641 RTCCUINTXREG uFlatTest = Bs3SelPtrToFlat(pbTest); 1642 Bs3TestPrintf("g_usBs3TestStep=%u line=%d\n", g_usBs3TestStep, __LINE__); 1625 1643 1626 1644 /* … … 1631 1649 { 1632 1650 Bs3MemSet(&pbTest[X86_PAGE_SIZE - cbIdtr * 2], bFiller, cbIdtr * 2); 1633 Bs3RegCtxSetGrpDsFromCurPtr(&Ctx, &Ctx.rbx, &pbTest[off]); 1651 Bs3RegCtxSetGrpSegFromCurPtr(&Ctx, &Ctx.rbx, pWorker->fSs ? &Ctx.ss : &Ctx.ds, &pbTest[off]); 1652 if (pWorker->fSs) 1653 Bs3RegCtxPrint(&Ctx); 1634 1654 Bs3TrapSetJmpAndRestore(&Ctx, &TrapCtx); 1635 1655 if (off + cbIdtr <= X86_PAGE_SIZE) 1636 1656 { 1637 1657 CtxUdExpected.rbx = Ctx.rbx; 1658 CtxUdExpected.ss = Ctx.ss; 1638 1659 CtxUdExpected.ds = Ctx.ds; 1639 1660 bs3CpuBasic2_CompareUdCtx(&TrapCtx, &CtxUdExpected); … … 1656 1677 Bs3TestPrintf("Wrote partial limit on #PF (#10): Expected %02x, got %02x\n", bFiller, pbTest[off]); 1657 1678 } 1658 } 1679 g_usBs3TestStep++; 1680 } 1681 Bs3TestPrintf("g_usBs3TestStep=%u line=%d\n", g_usBs3TestStep, __LINE__); 1659 1682 1660 1683 /* … … 1665 1688 { 1666 1689 Bs3MemSet(pbTest, bFiller, 32); 1667 Bs3RegCtxSetGrp DsFromCurPtr(&Ctx, &Ctx.rbx, &pbTest[off]);1690 Bs3RegCtxSetGrpSegFromCurPtr(&Ctx, &Ctx.rbx, pWorker->fSs ? &Ctx.ss : &Ctx.ds, &pbTest[off]); 1668 1691 Bs3TrapSetJmpAndRestore(&Ctx, &TrapCtx); 1669 1692 if (off >= 0) 1670 1693 { 1671 1694 CtxUdExpected.rbx = Ctx.rbx; 1695 CtxUdExpected.ss = Ctx.ss; 1672 1696 CtxUdExpected.ds = Ctx.ds; 1673 1697 bs3CpuBasic2_CompareUdCtx(&TrapCtx, &CtxUdExpected); … … 1686 1710 Bs3TestPrintf("Wrote beyond expected area (#13): bFiller=%#x, found %.16Rhxs; off=%d\n", 1687 1711 bFiller, &pbTest[RT_MAX(cbIdtr + off, 0)], off); 1712 g_usBs3TestStep++; 1688 1713 } 1689 1714 … … 1704 1729 Bs3GdteTestPage00.Gen.u8BaseHigh2 = (uint8_t)(uFlatTest >> 24); 1705 1730 1706 CtxUdExpected.ds = Ctx.ds = BS3_SEL_TEST_PAGE_00 | bRing; 1731 if (pWorker->fSs) 1732 CtxUdExpected.ss = Ctx.ss = BS3_SEL_TEST_PAGE_00 | bRing; 1733 else 1734 CtxUdExpected.ds = Ctx.ds = BS3_SEL_TEST_PAGE_00 | bRing; 1707 1735 1708 1736 /* Expand up (normal), approaching tail guard page. */ … … 1747 1775 if (off <= X86_PAGE_SIZE - 2) 1748 1776 { 1749 bs3CpuBasic2_CompareGpCtx(&TrapCtx, &Ctx, 0); 1777 if (pWorker->fSs) 1778 bs3CpuBasic2_CompareSsCtx(&TrapCtx, &Ctx, 0, false /*f486ResumeFlagHint*/); 1779 else 1780 bs3CpuBasic2_CompareGpCtx(&TrapCtx, &Ctx, 0); 1750 1781 if (Bs3MemCmp(&pbTest[off], pabExpected, 2) != 0) 1751 1782 Bs3TestPrintf("Mismatch (#16): Expected limit %.2Rhxs, got %.2Rhxs; off=%#x\n", … … 1769 1800 else 1770 1801 { 1771 /* #GP on limit. */ 1772 bs3CpuBasic2_CompareGpCtx(&TrapCtx, &Ctx, 0); 1802 /* #GP/#SS on limit. */ 1803 if (pWorker->fSs) 1804 bs3CpuBasic2_CompareSsCtx(&TrapCtx, &Ctx, 0, false /*f486ResumeFlagHint*/); 1805 else 1806 bs3CpuBasic2_CompareGpCtx(&TrapCtx, &Ctx, 0); 1773 1807 if ( off < X86_PAGE_SIZE 1774 1808 && !ASMMemIsAllU8(&pbTest[off], X86_PAGE_SIZE - off, bFiller)) … … 1785 1819 1786 1820 /* Set DS to 0 and check that we get #GP(0). */ 1787 Ctx.ds = 0; 1788 Bs3TrapSetJmpAndRestore(&Ctx, &TrapCtx); 1789 bs3CpuBasic2_CompareGpCtx(&TrapCtx, &Ctx, 0); 1790 g_usBs3TestStep++; 1791 Ctx.ds = BS3_SEL_TEST_PAGE_00 | bRing; 1821 if (!pWorker->fSs) 1822 { 1823 Ctx.ds = 0; 1824 Bs3TrapSetJmpAndRestore(&Ctx, &TrapCtx); 1825 bs3CpuBasic2_CompareGpCtx(&TrapCtx, &Ctx, 0); 1826 Ctx.ds = BS3_SEL_TEST_PAGE_00 | bRing; 1827 g_usBs3TestStep++; 1828 } 1792 1829 } 1793 1830 } … … 1826 1863 bs3CpuBasic2_ComparePfCtx(&TrapCtx, &Ctx, X86_TRAP_PF_RW | (Ctx.bCpl == 3 ? X86_TRAP_PF_US : 0), 1827 1864 uFlatTest + off); 1865 else if (pWorker->fSs) 1866 bs3CpuBasic2_CompareSsCtx(&TrapCtx, &Ctx, 0, false /*f486ResumeFlagHint*/); 1828 1867 else 1829 1868 bs3CpuBasic2_CompareGpCtx(&TrapCtx, &Ctx, 0); … … 1858 1897 { 1859 1898 unsigned idx; 1899 unsigned bRing; 1860 1900 unsigned iStep = 0; 1861 unsigned bRing = 0; 1862 1901 1902 /* Note! We skip the SS checks for ring-0 since we badly mess up SS in the 1903 test and don't want to bother with double faults. */ 1863 1904 for (bRing = 0; bRing <= 3; bRing++) 1864 1905 { 1865 1906 for (idx = 0; idx < cWorkers; idx++) 1866 if (paWorkers[idx].bMode & (bTestMode & BS3_MODE_CODE_MASK)) 1907 if ( (paWorkers[idx].bMode & (bTestMode & BS3_MODE_CODE_MASK)) 1908 && (!paWorkers[idx].fSs || bRing != 0)) 1867 1909 { 1868 1910 g_usBs3TestStep = iStep; … … 2155 2197 } 2156 2198 2199 2200 BS3_DECL_FAR(uint8_t) TMPL_NM(bs3CpuBasic2_gidt)(uint8_t bMode) 2201 { 2202 union 2203 { 2204 RTGDTR Gdtr; 2205 uint8_t ab[16]; 2206 } Expected; 2207 2208 g_pszTestMode = TMPL_NM(g_szBs3ModeName); 2209 g_bTestMode = bMode; 2210 g_f16BitSys = BS3_MODE_IS_16BIT_SYS(TMPL_MODE); 2211 2212 BS3_ASSERT(bMode == TMPL_MODE); 2213 2214 /* 2215 * Pass to common worker which is only compiled once per mode. 2216 */ 2217 Bs3MemZero(&Expected, sizeof(Expected)); 2218 ASMGetGDTR(&Expected.Gdtr); 2219 bs3CpuBasic2_sidt_sgdt_Common(bMode, g_aSgdtWorkers, RT_ELEMENTS(g_aSgdtWorkers), Expected.ab); 2220 2221 /* 2222 * Re-initialize the IDT. 2223 */ 2224 Bs3TrapInit(); 2225 return 0; 2226 } 2227 2157 2228 #endif /* BS3_INSTANTIATING_MODE */ 2158 2229 -
trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-basic-2-template.mac
r60676 r60679 172 172 AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sgdt_rexw_bx_ud2) == 4) 173 173 BS3_PROC_END_CMN bs3CpuBasic2_sgdt_rexw_bx_ud2 174 175 BS3_PROC_BEGIN_CMN bs3CpuBasic2_sgdt_opsize_rexw_bx_ud2, BS3_PBC_NEAR 176 db X86_OP_PRF_SIZE_OP 177 db X86_OP_REX_W 178 sgdt [xBX] 179 .again: ud2 180 jmp .again 181 AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sgdt_opsize_rexw_bx_ud2) == 5) 182 BS3_PROC_END_CMN bs3CpuBasic2_sgdt_opsize_rexw_bx_ud2 174 183 %endif 175 184 … … 181 190 AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sgdt_ss_bx_ud2) == 4) 182 191 BS3_PROC_END_CMN bs3CpuBasic2_sgdt_ss_bx_ud2 192 193 BS3_PROC_BEGIN_CMN bs3CpuBasic2_sgdt_opsize_ss_bx_ud2, BS3_PBC_NEAR 194 db X86_OP_PRF_SIZE_OP 195 sgdt [ss:xBX] 196 .again: ud2 197 jmp .again 198 AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sgdt_opsize_ss_bx_ud2) == 5) 199 BS3_PROC_END_CMN bs3CpuBasic2_sgdt_opsize_ss_bx_ud2 183 200 %endif 184 201 -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SelFlatDataToProtFar16.asm
r60657 r60679 56 56 57 57 ; 58 ; Check if we can use the protected mode stack or data selector. 59 ; The latter ensures the usability of this function for setting SS. 60 ; 61 %if TMPL_BITS == 16 62 mov ax, [xBP + xCB + cbCurRetAddr] 63 mov dx, [xBP + xCB + cbCurRetAddr + 2] 64 test dx, dx 65 jnz .not_stack 66 mov dx, BS3_SEL_R0_SS16 67 %else 68 mov eax, [xBP + xCB + cbCurRetAddr] 69 test eax, 0ffff0000h 70 jnz .not_stack 71 or eax, BS3_SEL_R0_SS16 << 16 72 %endif 73 jmp .return 74 75 .not_stack: 76 %if TMPL_BITS == 16 77 sub ax, BS3_ADDR_BS3DATA16 & 0xffff 78 sbb dx, BS3_ADDR_BS3DATA16 >> 16 79 jnz .do_tiled 80 mov dx, BS3_SEL_R0_DS16 81 %else 82 sub eax, BS3_ADDR_BS3DATA16 83 test eax, 0ffff0000h 84 jnz .do_tiled 85 or eax, BS3_SEL_R0_DS16 << 16 86 %endif 87 jmp .return 88 89 ; 58 90 ; Just translate the address to tiled. 59 91 ; 92 .do_tiled: 60 93 %if TMPL_BITS == 16 61 94 ; Convert upper 16-bit to a tiled selector. … … 95 128 %endif 96 129 130 .return: 97 131 pop xBP 98 132 BS3_HYBRID_RET
Note:
See TracChangeset
for help on using the changeset viewer.