- Timestamp:
- Feb 18, 2012 9:19:07 PM (13 years ago)
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/IEMAll.cpp
r40169 r40174 6113 6113 6114 6114 /** The instruction allows no lock prefixing (in this encoding), throw #UD if 6115 * lock prefixed. */ 6115 * lock prefixed. 6116 * @deprecated IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX */ 6116 6117 #define IEMOP_HLP_NO_LOCK_PREFIX() \ 6117 6118 do \ … … 6138 6139 } while (0) 6139 6140 6141 /** 6142 * Done decoding. 6143 */ 6144 #define IEMOP_HLP_DONE_DECODING() \ 6145 do \ 6146 { \ 6147 /*nothing for now, maybe later... */ \ 6148 } while (0) 6149 6150 /** 6151 * Done decoding, raise \#UD exception if lock prefix present. 6152 */ 6153 #define IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX() \ 6154 do \ 6155 { \ 6156 if (pIemCpu->fPrefixes & IEM_OP_PRF_LOCK) \ 6157 return IEMOP_RAISE_INVALID_LOCK_PREFIX(); \ 6158 } while (0) 6140 6159 6141 6160 -
trunk/src/VBox/VMM/VMMAll/IEMAllInstructions.cpp.h
r40169 r40174 1074 1074 pIemCpu->enmEffOpSize = pIemCpu->enmDefOpSize = IEMMODE_32BIT; 1075 1075 1076 /** @todo Verify that the the invalid lock sequence exception (\#UD) is raised1077 * before the privilege level violation (\#GP). */1078 1076 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm); 1079 1077 uint8_t iCrReg = ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pIemCpu->uRexReg; … … 1082 1080 /* The lock prefix can be used to encode CR8 accesses on some CPUs. */ 1083 1081 if (!IEM_IS_AMD_CPUID_FEATURE_PRESENT_ECX(X86_CPUID_AMD_FEATURE_ECX_CR8L)) 1084 return IEMOP_RAISE_INVALID_LOCK_PREFIX(); 1082 return IEMOP_RAISE_INVALID_LOCK_PREFIX(); /* #UD takes precedence over #GP(), see test. */ 1085 1083 iCrReg |= 8; 1086 1084 } … … 1092 1090 return IEMOP_RAISE_INVALID_OPCODE(); 1093 1091 } 1092 IEMOP_HLP_DONE_DECODING(); 1094 1093 1095 1094 return IEM_MC_DEFER_TO_CIMPL_2(iemCImpl_mov_Rd_Cd, (X86_MODRM_RM_MASK & bRm) | pIemCpu->uRexB, iCrReg); … … 1121 1120 pIemCpu->enmEffOpSize = pIemCpu->enmDefOpSize = IEMMODE_32BIT; 1122 1121 1123 /** @todo Verify that the the invalid lock sequence exception (\#UD) is raised1124 * before the privilege level violation (\#GP). */1125 1122 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm); 1126 1123 uint8_t iCrReg = ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pIemCpu->uRexReg; … … 1129 1126 /* The lock prefix can be used to encode CR8 accesses on some CPUs. */ 1130 1127 if (!IEM_IS_AMD_CPUID_FEATURE_PRESENT_ECX(X86_CPUID_AMD_FEATURE_ECX_CR8L)) 1131 return IEMOP_RAISE_INVALID_LOCK_PREFIX(); 1128 return IEMOP_RAISE_INVALID_LOCK_PREFIX(); /* #UD takes precedence over #GP(), see test. */ 1132 1129 iCrReg |= 8; 1133 1130 } … … 1139 1136 return IEMOP_RAISE_INVALID_OPCODE(); 1140 1137 } 1138 IEMOP_HLP_DONE_DECODING(); 1141 1139 1142 1140 return IEM_MC_DEFER_TO_CIMPL_2(iemCImpl_mov_Cd_Rd, iCrReg, (X86_MODRM_RM_MASK & bRm) | pIemCpu->uRexB); … … 1149 1147 IEMOP_MNEMONIC("mov Dd,Rd"); 1150 1148 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm); 1151 IEMOP_HLP_ NO_LOCK_PREFIX();1149 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX(); 1152 1150 if (pIemCpu->fPrefixes & IEM_OP_PRF_REX_R) 1153 1151 return IEMOP_RAISE_INVALID_OPCODE(); … … 1162 1160 { 1163 1161 IEMOP_MNEMONIC("mov Rd,Td"); 1164 /** @todo Is the invalid opcode raise before parsing any R/M byte?*/1162 /* The RM byte is not considered, see testcase. */ 1165 1163 return IEMOP_RAISE_INVALID_OPCODE(); 1166 1164 } 1167 1168 1165 1169 1166 … … 1172 1169 { 1173 1170 IEMOP_MNEMONIC("mov Td,Rd"); 1171 /* The RM byte is not considered, see testcase. */ 1174 1172 return IEMOP_RAISE_INVALID_OPCODE(); 1175 1173 } … … 12581 12579 /* Registers? How?? */ 12582 12580 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT)) 12583 { 12584 /** @todo How the heck does a 'callf eax' work? Probably just have to 12585 * search the docs... */ 12586 AssertFailedReturn(VERR_IEM_ASPECT_NOT_IMPLEMENTED); 12587 } 12581 return IEMOP_RAISE_INVALID_OPCODE(); /* callf eax is not legal */ 12588 12582 12589 12583 /* Far pointer loaded from memory. */ … … 12730 12724 implementation. */ 12731 12725 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT)) 12732 { 12733 /** @todo How the heck does a 'callf eax' work? Probably just have to 12734 * search the docs... */ 12735 AssertFailedReturn(VERR_IEM_ASPECT_NOT_IMPLEMENTED); 12736 } 12726 return IEMOP_RAISE_INVALID_OPCODE(); /* jmpf eax is not legal */ 12737 12727 12738 12728 /* Far pointer loaded from memory. */ -
trunk/src/VBox/VMM/testcase/tstIEMCheckMc.cpp
r40169 r40174 91 91 #define IEMOP_HLP_NO_64BIT() do { } while (0) 92 92 #define IEMOP_HLP_DEFAULT_64BIT_OP_SIZE() do { } while (0) 93 #define IEMOP_HLP_DONE_DECODING() do { } while (0) 94 #define IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX() do { } while (0) 93 95 #define IEMOP_RAISE_DIVIDE_ERROR() VERR_TRPM_ACTIVE_TRAP 94 96 #define IEMOP_RAISE_INVALID_OPCODE() VERR_TRPM_ACTIVE_TRAP -
trunk/src/VBox/VMM/testcase/tstX86-1.cpp
r40138 r40174 72 72 DECLASM(int32_t) x861_Test5(void); 73 73 DECLASM(int32_t) x861_Test6(void); 74 DECLASM(int32_t) x861_Test7(void); 74 75 DECLASM(int32_t) x861_TestFPUInstr1(void); 75 76 … … 241 242 if (rc != 0) 242 243 RTTestFailed(hTest, "x861_Test4 -> %d", rc); 243 244 #endif 245 246 RTTestSub(hTest, "Odd encodings and odd ends"); 247 rc = x861_Test5(); 248 if (rc != 0) 249 RTTestFailed(hTest, "x861_Test5 -> %d", rc); 250 251 #if 0 244 252 RTTestSub(hTest, "Odd floating point encodings"); 245 rc = x861_Test 5();253 rc = x861_Test6(); 246 254 if (rc != 0) 247 255 RTTestFailed(hTest, "x861_Test5 -> %d", rc); 248 256 249 257 RTTestSub(hTest, "Floating point exceptions ++"); 250 rc = x861_Test 6();258 rc = x861_Test7(); 251 259 if (rc != 0) 252 260 RTTestFailed(hTest, "x861_Test6 -> %d", rc); 253 #endif254 261 255 262 rc = x861_TestFPUInstr1(); 256 263 if (rc != 0) 257 264 RTTestFailed(hTest, "x861_TestFPUInstr1 -> %d", rc); 265 #endif 258 266 } 259 267 -
trunk/src/VBox/VMM/testcase/tstX86-1A.asm
r40164 r40174 180 180 iend 181 181 BEGINCODE 182 %%resume: 183 %endmacro 184 185 ;; 186 ; Macro for recording a trapping instruction in the exec page. 187 ; 188 ; @uses xAX, xDX 189 ; @param 1 The trap number. 190 ; @param 2 The offset into the exec page. 191 %macro ShouldTrapExecPage 2 192 lea xDX, [REF(NAME(g_aTrapInfoExecPage))] 193 lea xAX, [REF(%%resume)] 194 mov byte [xDX + TRAPINFO.cbInstr], PAGE_SIZE - (%2) 195 mov byte [xDX + TRAPINFO.u8TrapNo], %1 196 mov [xDX + TRAPINFO.uResumePC], xAX 197 mov xAX, [REF_EXTERN(g_pbEfExecPage)] 198 lea xAX, [xAX + (%2)] 199 mov [xDX + TRAPINFO.uTrapPC], xAX 200 jmp xAX 182 201 %%resume: 183 202 %endmacro … … 1706 1725 ret 1707 1726 ENDPROC x861_Test4 1727 1728 1729 ;; 1730 ; Tests various odd/weird/bad encodings. 1731 ; 1732 BEGINPROC x861_Test5 1733 SAVE_ALL_PROLOGUE 1734 call x861_ClearRegisters 1735 1736 %if 0 1737 ; callf eax... 1738 ShouldTrap X86_XCPT_UD, db 0xff, 11011000b 1739 ShouldTrap X86_XCPT_UD, db 0xff, 11011001b 1740 ShouldTrap X86_XCPT_UD, db 0xff, 11011010b 1741 ShouldTrap X86_XCPT_UD, db 0xff, 11011011b 1742 ShouldTrap X86_XCPT_UD, db 0xff, 11011100b 1743 ShouldTrap X86_XCPT_UD, db 0xff, 11011101b 1744 ShouldTrap X86_XCPT_UD, db 0xff, 11011110b 1745 ShouldTrap X86_XCPT_UD, db 0xff, 11011111b 1746 1747 ; jmpf eax... 1748 ShouldTrap X86_XCPT_UD, db 0xff, 11101000b 1749 ShouldTrap X86_XCPT_UD, db 0xff, 11101001b 1750 ShouldTrap X86_XCPT_UD, db 0xff, 11101010b 1751 ShouldTrap X86_XCPT_UD, db 0xff, 11101011b 1752 ShouldTrap X86_XCPT_UD, db 0xff, 11101100b 1753 ShouldTrap X86_XCPT_UD, db 0xff, 11101101b 1754 ShouldTrap X86_XCPT_UD, db 0xff, 11101110b 1755 ShouldTrap X86_XCPT_UD, db 0xff, 11101111b 1756 1757 ; #GP(0) vs #UD. 1758 ShouldTrap X86_XCPT_GP, mov xAX, cr0 1759 ShouldTrap X86_XCPT_UD, lock mov xAX, cr0 1760 ShouldTrap X86_XCPT_GP, mov cr0, xAX 1761 ShouldTrap X86_XCPT_UD, lock mov cr0, xAX 1762 ShouldTrap X86_XCPT_UD, db 0x0f, 0x20,11001000b ; mov xAX, cr1 1763 ShouldTrap X86_XCPT_UD, db 0x0f, 0x20,11101000b ; mov xAX, cr5 1764 ShouldTrap X86_XCPT_UD, db 0x0f, 0x20,11110000b ; mov xAX, cr6 1765 ShouldTrap X86_XCPT_UD, db 0x0f, 0x20,11111000b ; mov xAX, cr7 1766 ShouldTrap X86_XCPT_GP, mov xAX, dr7 1767 ShouldTrap X86_XCPT_UD, lock mov xAX, dr7 1768 1769 ; The MOD is ignored by MOV CRx,GReg and MOV GReg,CRx 1770 ShouldTrap X86_XCPT_GP, db 0x0f, 0x20,00000000b ; mov xAX, cr0 1771 ShouldTrap X86_XCPT_GP, db 0x0f, 0x20,01000000b ; mov xAX, cr0 1772 ShouldTrap X86_XCPT_GP, db 0x0f, 0x20,10000000b ; mov xAX, cr0 1773 ShouldTrap X86_XCPT_GP, db 0x0f, 0x20,11000000b ; mov xAX, cr0 1774 ShouldTrap X86_XCPT_GP, db 0x0f, 0x22,00000000b ; mov cr0, xAX 1775 ShouldTrap X86_XCPT_GP, db 0x0f, 0x22,01000000b ; mov cr0, xAX 1776 ShouldTrap X86_XCPT_GP, db 0x0f, 0x22,10000000b ; mov cr0, xAX 1777 ShouldTrap X86_XCPT_GP, db 0x0f, 0x22,11000000b ; mov cr0, xAX 1778 %endif 1779 1780 ; mov eax, tr0, 0x0f 0x24 1781 ShouldTrap X86_XCPT_UD, db 0x0f, 0x24, 0xc0 ; mov xAX, tr1 1782 1783 mov xAX, [REF_EXTERN(g_pbEfExecPage)] 1784 add xAX, PAGE_SIZE - 3 1785 mov byte [xAX ], 0x0f 1786 mov byte [xAX + 1], 0x24 1787 mov byte [xAX + 2], 0xc0 1788 ShouldTrapExecPage X86_XCPT_UD, PAGE_SIZE - 3 1789 1790 mov xAX, [REF_EXTERN(g_pbEfExecPage)] 1791 add xAX, PAGE_SIZE - 2 1792 mov byte [xAX ], 0x0f 1793 mov byte [xAX + 1], 0x24 1794 ShouldTrapExecPage X86_XCPT_UD, PAGE_SIZE - 2 1795 1796 .success: 1797 xor eax, eax 1798 .return: 1799 SAVE_ALL_EPILOGUE 1800 ret 1801 ENDPROC x861_Test5 1708 1802 1709 1803 … … 1955 2049 ; Tests some odd floating point instruction encodings. 1956 2050 ; 1957 BEGINPROC x861_Test 52051 BEGINPROC x861_Test6 1958 2052 SAVE_ALL_PROLOGUE 1959 2053 … … 2167 2261 ret 2168 2262 2169 ENDPROC x861_Test 52263 ENDPROC x861_Test6 2170 2264 2171 2265 … … 2175 2269 ; 2176 2270 ; 2177 BEGINPROC x861_Test 62271 BEGINPROC x861_Test7 2178 2272 SAVE_ALL_PROLOGUE 2179 2273 sub xSP, 2048 … … 2292 2386 SAVE_ALL_EPILOGUE 2293 2387 ret 2294 ENDPROC x861_Test 62388 ENDPROC x861_Test7 2295 2389 2296 2390 … … 2854 2948 ; Terminate the trap info array with a NIL entry. 2855 2949 BEGINDATA 2950 GLOBALNAME g_aTrapInfoExecPage 2951 istruc TRAPINFO 2952 at TRAPINFO.uTrapPC, RTCCPTR_DEF 1 2953 at TRAPINFO.uResumePC, RTCCPTR_DEF 1 2954 at TRAPINFO.u8TrapNo, db 16 2955 at TRAPINFO.cbInstr, db 3 2956 iend 2856 2957 GLOBALNAME g_aTrapInfoEnd 2857 2958 istruc TRAPINFO
Note:
See TracChangeset
for help on using the changeset viewer.