Changeset 42483 in vbox for trunk/src/VBox
- Timestamp:
- Jul 31, 2012 2:55:39 PM (12 years ago)
- Location:
- trunk/src/VBox/VMM/VMMAll
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/IEMAll.cpp
r42453 r42483 836 836 if (cbToTryRead > sizeof(pIemCpu->abOpcode)) 837 837 cbToTryRead = sizeof(pIemCpu->abOpcode); 838 /** @todo patch manager */ 838 /** @todo PATM: Read original, unpatched bytes? EMAll.cpp doesn't seem to be 839 * doing that. */ 839 840 if (!pIemCpu->fByPassHandlers) 840 841 rc = PGMPhysRead(IEMCPU_TO_VM(pIemCpu), GCPhys, pIemCpu->abOpcode, cbToTryRead); … … 3215 3216 * @param pCtx Where to get the current stack mode. 3216 3217 */ 3217 DECLINLINE(void) iemRegAddToRspEx(PRTUINT64U pTmpRsp, uint 8_t cbToAdd, PCCPUMCTX pCtx)3218 DECLINLINE(void) iemRegAddToRspEx(PRTUINT64U pTmpRsp, uint16_t cbToAdd, PCCPUMCTX pCtx) 3218 3219 { 3219 3220 if (pCtx->ss.Attr.n.u1Long) … … 3232 3233 * @param cbToSub The number of bytes to subtract. 3233 3234 * @param pCtx Where to get the current stack mode. 3234 */ 3235 DECLINLINE(void) iemRegSubFromRspEx(PRTUINT64U pTmpRsp, uint8_t cbToSub, PCCPUMCTX pCtx) 3235 * @remarks The @a cbToSub argument *MUST* be 16-bit, iemCImpl_enter is 3236 * expecting that. 3237 */ 3238 DECLINLINE(void) iemRegSubFromRspEx(PRTUINT64U pTmpRsp, uint16_t cbToSub, PCCPUMCTX pCtx) 3236 3239 { 3237 3240 if (pCtx->ss.Attr.n.u1Long) … … 4675 4678 rc = VINF_SUCCESS; 4676 4679 4677 #if def IEM_VERIFICATION_MODE4680 #if defined(IEM_VERIFICATION_MODE) && defined(IN_RING3) 4678 4681 /* 4679 4682 * Record the write(s). … … 4786 4789 } 4787 4790 4788 #if def IEM_VERIFICATION_MODE4791 #if defined(IEM_VERIFICATION_MODE) && defined(IN_RING3) 4789 4792 if ( !pIemCpu->fNoRem 4790 4793 && (fAccess & (IEM_ACCESS_TYPE_READ | IEM_ACCESS_TYPE_EXEC)) ) … … 4883 4886 } 4884 4887 4885 #if def IEM_VERIFICATION_MODE4888 #if defined(IEM_VERIFICATION_MODE) && defined(IN_RING3) 4886 4889 if ( !pIemCpu->fNoRem 4887 4890 && (fAccess & (IEM_ACCESS_TYPE_READ | IEM_ACCESS_TYPE_EXEC)) ) … … 5590 5593 5591 5594 5592 #ifdef SOME_UNUSED_FUNCTION5593 5595 /** 5594 5596 * Pushes a dword onto the stack, using a temporary stack pointer. … … 5621 5623 return rc; 5622 5624 } 5623 #endif5624 5625 5625 5626 … … 7160 7161 #endif 7161 7162 #if 1 /* Auto enable DSL - fstp st0 stuff. */ 7162 && pOrgCtx->cs == 0x237163 && pOrgCtx->cs.Sel == 0x23 7163 7164 && pOrgCtx->rip == 0x804aff7 7164 7165 #endif … … 7449 7450 7450 7451 char szInstr1[256]; 7451 DBGFR3DisasInstrEx(pVM, pVCpu->idCpu, pCtx->cs , pCtx->rip - pIemCpu->offOpcode,7452 DBGFR3DisasInstrEx(pVM, pVCpu->idCpu, pCtx->cs.Sel, pCtx->rip - pIemCpu->offOpcode, 7452 7453 DBGF_DISAS_FLAGS_DEFAULT_MODE, 7453 7454 szInstr1, sizeof(szInstr1), NULL); … … 7645 7646 do \ 7646 7647 { \ 7647 CHECK_FIELD(a_Sel); \ 7648 if ( pOrgCtx->a_Sel##Hid.Attr.u != pDebugCtx->a_Sel##Hid.Attr.u \ 7649 && (pOrgCtx->a_Sel##Hid.Attr.u | X86_SEL_TYPE_ACCESSED) != pDebugCtx->a_Sel##Hid.Attr.u) \ 7650 { \ 7651 RTAssertMsg2Weak(" %8sHid.Attr differs - iem=%02x - rem=%02x\n", #a_Sel, pDebugCtx->a_Sel##Hid.Attr.u, pOrgCtx->a_Sel##Hid.Attr.u); \ 7652 cDiffs++; \ 7653 } \ 7654 CHECK_FIELD(a_Sel##Hid.u64Base); \ 7655 CHECK_FIELD(a_Sel##Hid.u32Limit); \ 7648 CHECK_FIELD(a_Sel.Sel); \ 7649 CHECK_FIELD(a_Sel.Attr.u); \ 7650 CHECK_FIELD(a_Sel.u64Base); \ 7651 CHECK_FIELD(a_Sel.u32Limit); \ 7652 CHECK_FIELD(a_Sel.fFlags); \ 7656 7653 } while (0) 7657 7654 … … 7776 7773 CHECK_FIELD(idtr.cbIdt); 7777 7774 CHECK_FIELD(idtr.pIdt); 7778 CHECK_FIELD(ldtr); 7779 CHECK_FIELD(ldtrHid.u64Base); 7780 CHECK_FIELD(ldtrHid.u32Limit); 7781 CHECK_FIELD(ldtrHid.Attr.u); 7782 CHECK_FIELD(tr); 7783 CHECK_FIELD(trHid.u64Base); 7784 CHECK_FIELD(trHid.u32Limit); 7785 CHECK_FIELD(trHid.Attr.u); 7775 CHECK_SEL(ldtr); 7776 CHECK_SEL(tr); 7786 7777 CHECK_FIELD(SysEnter.cs); 7787 7778 CHECK_FIELD(SysEnter.eip); -
trunk/src/VBox/VMM/VMMAll/IEMAllCImpl.cpp.h
r42453 r42483 909 909 pCtx->cs.fFlags = CPUMSELREG_FLAGS_VALID; 910 910 pCtx->cs.u64Base = (uint32_t)uSel << 4; 911 /** @todo REM reset the accessed bit (see on jmp far16 after disabling912 * PE. Check with VT-x and AMD-V. */913 #ifdef IEM_VERIFICATION_MODE914 pCtx->cs.Attr.u &= ~X86_SEL_TYPE_ACCESSED;915 #endif916 911 return VINF_SUCCESS; 917 912 } … … 1092 1087 pCtx->cs.fFlags = CPUMSELREG_FLAGS_VALID; 1093 1088 pCtx->cs.u64Base = (uint32_t)uSel << 4; 1094 /** @todo Does REM reset the accessed bit here too? (See on jmp far161095 * after disabling PE.) Check with VT-x and AMD-V. */1096 #ifdef IEM_VERIFICATION_MODE1097 pCtx->cs.Attr.u &= ~X86_SEL_TYPE_ACCESSED;1098 #endif1099 1089 return VINF_SUCCESS; 1100 1090 } … … 1714 1704 1715 1705 /** 1706 * Implements enter. 1707 * 1708 * We're doing this in C because the instruction is insane, even for the 1709 * u8NestingLevel=0 case dealing with the stack is tedious. 1710 * 1711 * @param enmEffOpSize The effective operand size. 1712 */ 1713 IEM_CIMPL_DEF_3(iemCImpl_enter, IEMMODE, enmEffOpSize, uint16_t, cbFrame, uint8_t, cParameters) 1714 { 1715 PCPUMCTX pCtx = pIemCpu->CTX_SUFF(pCtx); 1716 1717 /* Push RBP, saving the old value in TmpRbp. */ 1718 RTUINT64U NewRsp; NewRsp.u = pCtx->rsp; 1719 RTUINT64U TmpRbp; TmpRbp.u = pCtx->rbp; 1720 RTUINT64U NewRbp; 1721 VBOXSTRICTRC rcStrict; 1722 if (enmEffOpSize == IEMMODE_64BIT) 1723 { 1724 rcStrict = iemMemStackPushU64Ex(pIemCpu, TmpRbp.u, &NewRsp); 1725 NewRbp = NewRsp; 1726 } 1727 else if (pCtx->ss.Attr.n.u1DefBig) 1728 { 1729 rcStrict = iemMemStackPushU32Ex(pIemCpu, TmpRbp.DWords.dw0, &NewRsp); 1730 NewRbp = NewRsp; 1731 } 1732 else 1733 { 1734 rcStrict = iemMemStackPushU16Ex(pIemCpu, TmpRbp.Words.w0, &NewRsp); 1735 NewRbp = NewRsp; 1736 } 1737 if (rcStrict != VINF_SUCCESS) 1738 return rcStrict; 1739 1740 /* Copy the parameters (aka nesting levels by Intel). */ 1741 cParameters &= 0x1f; 1742 if (cParameters > 0) 1743 { 1744 switch (enmEffOpSize) 1745 { 1746 case IEMMODE_16BIT: 1747 if (pCtx->ss.Attr.n.u1DefBig) 1748 TmpRbp.DWords.dw0 -= 2; 1749 else 1750 TmpRbp.Words.w0 -= 2; 1751 do 1752 { 1753 uint16_t u16Tmp; 1754 rcStrict = iemMemStackPopU16Ex(pIemCpu, &u16Tmp, &TmpRbp); 1755 if (rcStrict != VINF_SUCCESS) 1756 break; 1757 rcStrict = iemMemStackPushU16Ex(pIemCpu, u16Tmp, &NewRsp); 1758 } while (--cParameters > 0 && rcStrict == VINF_SUCCESS); 1759 break; 1760 1761 case IEMMODE_32BIT: 1762 if (pCtx->ss.Attr.n.u1DefBig) 1763 TmpRbp.DWords.dw0 -= 4; 1764 else 1765 TmpRbp.Words.w0 -= 4; 1766 do 1767 { 1768 uint32_t u32Tmp; 1769 rcStrict = iemMemStackPopU32Ex(pIemCpu, &u32Tmp, &TmpRbp); 1770 if (rcStrict != VINF_SUCCESS) 1771 break; 1772 rcStrict = iemMemStackPushU32Ex(pIemCpu, u32Tmp, &NewRsp); 1773 } while (--cParameters > 0 && rcStrict == VINF_SUCCESS); 1774 break; 1775 1776 case IEMMODE_64BIT: 1777 TmpRbp.u -= 8; 1778 do 1779 { 1780 uint64_t u64Tmp; 1781 rcStrict = iemMemStackPopU64Ex(pIemCpu, &u64Tmp, &TmpRbp); 1782 if (rcStrict != VINF_SUCCESS) 1783 break; 1784 rcStrict = iemMemStackPushU64Ex(pIemCpu, u64Tmp, &NewRsp); 1785 } while (--cParameters > 0 && rcStrict == VINF_SUCCESS); 1786 break; 1787 1788 IEM_NOT_REACHED_DEFAULT_CASE_RET(); 1789 } 1790 if (rcStrict != VINF_SUCCESS) 1791 return VINF_SUCCESS; 1792 1793 /* Push the new RBP */ 1794 if (enmEffOpSize == IEMMODE_64BIT) 1795 rcStrict = iemMemStackPushU64Ex(pIemCpu, NewRbp.u, &NewRsp); 1796 else if (pCtx->ss.Attr.n.u1DefBig) 1797 rcStrict = iemMemStackPushU32Ex(pIemCpu, NewRbp.DWords.dw0, &NewRsp); 1798 else 1799 rcStrict = iemMemStackPushU16Ex(pIemCpu, NewRbp.Words.w0, &NewRsp); 1800 if (rcStrict != VINF_SUCCESS) 1801 return rcStrict; 1802 1803 } 1804 1805 /* Recalc RSP. */ 1806 iemRegSubFromRspEx(&NewRsp, cbFrame, pCtx); 1807 1808 /** @todo Should probe write access at the new RSP according to AMD. */ 1809 1810 /* Commit it. */ 1811 pCtx->rbp = NewRbp.u; 1812 pCtx->rsp = NewRsp.u; 1813 iemRegAddToRip(pIemCpu, cbInstr); 1814 1815 return VINF_SUCCESS; 1816 } 1817 1818 1819 1820 /** 1716 1821 * Implements leave. 1717 1822 * … … 1728 1833 RTUINT64U NewRsp; 1729 1834 if (pCtx->ss.Attr.n.u1Long) 1835 NewRsp.u = pCtx->rbp; 1836 else if (pCtx->ss.Attr.n.u1DefBig) 1837 NewRsp.u = pCtx->ebp; 1838 else 1730 1839 { 1731 1840 /** @todo Check that LEAVE actually preserve the high EBP bits. */ … … 1733 1842 NewRsp.Words.w0 = pCtx->bp; 1734 1843 } 1735 else if (pCtx->ss.Attr.n.u1DefBig)1736 NewRsp.u = pCtx->ebp;1737 else1738 NewRsp.u = pCtx->rbp;1739 1844 1740 1845 /* Pop RBP according to the operand size. */ -
trunk/src/VBox/VMM/VMMAll/IEMAllInstructions.cpp.h
r42437 r42483 10252 10252 10253 10253 /** Opcode 0xc8. */ 10254 FNIEMOP_STUB(iemOp_enter_Iw_Ib); 10254 FNIEMOP_DEF(iemOp_enter_Iw_Ib) 10255 { 10256 IEMOP_MNEMONIC("enter Iw,Ib"); 10257 IEMOP_HLP_DEFAULT_64BIT_OP_SIZE(); 10258 IEMOP_HLP_NO_LOCK_PREFIX(); 10259 uint16_t cbFrame; IEM_OPCODE_GET_NEXT_U16(&cbFrame); 10260 uint8_t u8NestingLevel; IEM_OPCODE_GET_NEXT_U8(&u8NestingLevel); 10261 return IEM_MC_DEFER_TO_CIMPL_3(iemCImpl_enter, pIemCpu->enmEffOpSize, cbFrame, u8NestingLevel); 10262 } 10255 10263 10256 10264
Note:
See TracChangeset
for help on using the changeset viewer.