Changeset 95406 in vbox for trunk/src/VBox
- Timestamp:
- Jun 28, 2022 12:23:51 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-basic-2-x0.c
r93115 r95406 1518 1518 1519 1519 1520 static void bs3CpuBasic2_RaiseXcpt11Worker(uint8_t bMode, uint8_t *pbBuf, unsigned cbCacheLine, bool fAm, 1521 BS3CPUBASIC2PFTTSTCMNMODE const BS3_FAR *pCmn)1520 static void bs3CpuBasic2_RaiseXcpt11Worker(uint8_t bMode, uint8_t *pbBuf, unsigned cbCacheLine, bool fAm, bool fPf, 1521 RTCCUINTXREG uFlatBufPtr, BS3CPUBASIC2PFTTSTCMNMODE const BS3_FAR *pCmn) 1522 1522 { 1523 1523 BS3TRAPFRAME TrapCtx; … … 1540 1540 * one also using xDX, so make sure they make some sense. 1541 1541 */ 1542 Bs3RegCtxSaveEx(&Ctx, bMode, 0);1542 Bs3RegCtxSaveEx(&Ctx, bMode, 256); 1543 1543 1544 1544 for (iRing = 0; iRing < cRings; iRing++) … … 1549 1549 Bs3RegCtxConvertToRingX(&Ctx, iRing); 1550 1550 1551 Bs3RegCtxSetGrpDsFromCurPtr(&Ctx, &Ctx.rbx, pbBuf); 1551 if (!fPf || BS3_MODE_IS_32BIT_CODE(bMode) || BS3_MODE_IS_64BIT_CODE(bMode)) 1552 Bs3RegCtxSetGrpDsFromCurPtr(&Ctx, &Ctx.rbx, pbBuf); 1553 else 1554 { 1555 /* Bs3RegCtxSetGrpDsFromCurPtr barfs when trying to output a sel:off address for the aliased buffer. */ 1556 Ctx.ds = BS3_FP_SEG(pbBuf); 1557 Ctx.rbx.u32 = BS3_FP_OFF(pbBuf); 1558 } 1552 1559 uEbx = Ctx.rbx.u32; 1553 1560 … … 1583 1590 CtxUdExpected.cs = Ctx.cs; 1584 1591 CtxUdExpected.rflags = Ctx.rflags; 1585 if (bMode == BS3_MODE_RM) CtxUdExpected.rflags.u32 &= ~X86_EFL_AC; /** @todo investigate. automatically cleared, or is it just our code? */1592 if (bMode == BS3_MODE_RM) CtxUdExpected.rflags.u32 &= ~X86_EFL_AC; /** @todo investigate. automatically cleared, or is it just our code? Observed with bs3-cpu-instr-3 too (10980xe). */ 1586 1593 CtxUdExpected.rdx = Ctx.rdx; 1587 1594 CtxUdExpected.rax = Ctx.rax; … … 1610 1617 for (offMem = 0; offMem < cbMax; offMem++) 1611 1618 { 1612 unsigned offBuf = cbMax + cbMem * 2; 1619 bool const fMisaligned = (offMem & (cbMem - 1)) != 0; /** @todo assumes cbMem is a power of two! */ 1620 unsigned offBuf = cbMax + cbMem * 2; 1613 1621 while (offBuf-- > 0) 1614 1622 pbBuf[offBuf] = 1; /* byte-by-byte to make sure it doesn't trigger AC. */ … … 1618 1626 g_uBs3TrapEipHint = Ctx.rip.u32; 1619 1627 1620 //Bs3TestPrintf("iRing=%d iTest=%d cs:rip=%04RX16:%08RX32 ds:rbx=%04RX16:%08RX32\n", 1621 // iRing, iTest, Ctx.cs, Ctx.rip.u32, Ctx.ds, Ctx.rbx.u32); 1628 //if (iRing == 3 && fPf && fAm) 1629 // Bs3TestPrintf("iRing=%d iTest=%d cs:rip=%04RX16:%08RX32 ds:rbx=%04RX16:%08RX32 bXcpt=%#x errcd=%#x fAm=%d fAc=%d\n", 1630 // iRing, iTest, Ctx.cs, Ctx.rip.u32, Ctx.ds, Ctx.rbx.u32, TrapCtx.bXcpt, (unsigned)TrapCtx.uErrCd, fAm, fAc); 1622 1631 1623 1632 Bs3TrapSetJmpAndRestore(&Ctx, &TrapCtx); 1624 1633 1625 if (!fAm || iRing != 3 || !fAc || !(offMem & (cbMem - 1))) /** @todo assumes cbMem is a power of two! */ 1634 if (fPf && iRing == 3 && (!fAm || !fAc || !fMisaligned)) /* #AC beats #PF */ 1635 bs3CpuBasic2_ComparePfCtx(&TrapCtx, &Ctx, 1636 X86_TRAP_PF_P | X86_TRAP_PF_US 1637 | (pCmn->paEntries[iTest].fOp & MYOP_ST ? X86_TRAP_PF_RW : 0), 1638 uFlatBufPtr + offMem); 1639 else if (!fAm || iRing != 3 || !fAc || !fMisaligned) 1626 1640 { 1627 1641 if (fOp & MYOP_EFL) … … 1638 1652 } 1639 1653 else 1640 {1641 1654 bs3CpuBasic2_CompareAcCtx(&TrapCtx, &Ctx); 1642 }1643 1655 1644 1656 g_usBs3TestStep++; … … 1682 1694 pbBuf = abBuf; 1683 1695 if (BS3_FP_OFF(pbBuf) & (cbCacheLine - 1)) 1684 pbBuf = &abBuf[cbCacheLine - BS3_FP_OFF(pbBuf) & (cbCacheLine - 1)]; 1696 pbBuf = &abBuf[cbCacheLine - (BS3_FP_OFF(pbBuf) & (cbCacheLine - 1))]; 1697 BS3_ASSERT(pbBuf - abBuf <= cbCacheLine); 1685 1698 //Bs3TestPrintf("pbBuf=%p\n", pbBuf); 1686 1699 … … 1691 1704 //Bs3TestPrintf("idxCmnModes=%d bMode=%#x\n", idxCmnModes, bMode); 1692 1705 1693 /* First round is w/o alig ment checks enabled. */1706 /* First round is w/o alignment checks enabled. */ 1694 1707 fCr0 = Bs3RegGetCr0(); 1695 1708 BS3_ASSERT(!(fCr0 & X86_CR0_AM)); 1696 1709 Bs3RegSetCr0(fCr0 & ~X86_CR0_AM); 1697 bs3CpuBasic2_RaiseXcpt11Worker(bMode, pbBuf, cbCacheLine, false /*fAm*/, &g_aCmnModes[idxCmnModes]);1698 1699 1710 #if 1 1711 bs3CpuBasic2_RaiseXcpt11Worker(bMode, pbBuf, cbCacheLine, false /*fAm*/, false /*fPf*/, 0, &g_aCmnModes[idxCmnModes]); 1712 #endif 1713 1700 1714 /* The second round is with aligment checks enabled. */ 1715 #if 1 1701 1716 Bs3RegSetCr0(Bs3RegGetCr0() | X86_CR0_AM); 1702 bs3CpuBasic2_RaiseXcpt11Worker(bMode, pbBuf, cbCacheLine, true /*fAm*/, &g_aCmnModes[idxCmnModes]); 1717 bs3CpuBasic2_RaiseXcpt11Worker(bMode, pbBuf, cbCacheLine, true /*fAm*/, false /*fPf*/, 0, &g_aCmnModes[idxCmnModes]); 1718 #endif 1719 1720 #if 1 1721 /* The third and fourth round access the buffer via a page alias that's not 1722 accessible from ring-3. The third round has ACs disabled and the fourth 1723 has them enabled. */ 1724 if (BS3_MODE_IS_PAGED(bMode) && !BS3_MODE_IS_V86(bMode)) //&& (BS3_MODE_IS_32BIT_CODE(bMode) || BS3_MODE_IS_64BIT_CODE(bMode))) 1725 { 1726 /* Alias the buffer as system memory so ring-3 access with AC+AM will cause #PF: */ 1727 int rc; 1728 RTCCUINTXREG uFlatBufPtr = Bs3SelPtrToFlat(pbBuf); 1729 uint64_t const uAliasPgPtr = bMode & BS3_MODE_CODE_64 ? UINT64_C(0x0000648680000000) : UINT32_C(0x80000000); 1730 rc = Bs3PagingAlias(uAliasPgPtr, uFlatBufPtr & ~(uint64_t)X86_PAGE_OFFSET_MASK, X86_PAGE_SIZE * 2, 1731 X86_PTE_P | X86_PTE_RW); 1732 if (RT_SUCCESS(rc)) 1733 { 1734 RTCCUINTXREG uAliasBufPtr = (RTCCUINTXREG)uAliasPgPtr + (uFlatBufPtr & X86_PAGE_OFFSET_MASK); 1735 uint8_t BS3_FAR *pbBufAlias = BS3_FP_MAKE(BS3_SEL_SPARE_00 | 3, uFlatBufPtr & X86_PAGE_OFFSET_MASK);; 1736 Bs3SelSetup16BitData(&Bs3GdteSpare00, uAliasPgPtr); 1737 1738 Bs3TestPrintf("round three\n"); 1739 Bs3RegSetCr0(Bs3RegGetCr0() & ~X86_CR0_AM); 1740 bs3CpuBasic2_RaiseXcpt11Worker(bMode, pbBufAlias, cbCacheLine, false /*fAm*/, 1741 true /*fPf*/, uAliasBufPtr, &g_aCmnModes[idxCmnModes]); 1742 1743 Bs3TestPrintf("round four\n"); 1744 Bs3RegSetCr0(Bs3RegGetCr0() | X86_CR0_AM); 1745 bs3CpuBasic2_RaiseXcpt11Worker(bMode, pbBufAlias, cbCacheLine, true /*fAm*/, 1746 true /*fPf*/, uAliasBufPtr, &g_aCmnModes[idxCmnModes]); 1747 Bs3TestPrintf("done\n"); 1748 1749 Bs3PagingUnalias(uAliasPgPtr, X86_PAGE_SIZE * 2); 1750 } 1751 else 1752 Bs3TestFailedF("Bs3PagingAlias failed with %Rrc", rc); 1753 } 1703 1754 #endif 1704 1755
Note:
See TracChangeset
for help on using the changeset viewer.