Changeset 66404 in vbox
- Timestamp:
- Apr 3, 2017 3:21:56 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/disopcode.h
r66391 r66404 1059 1059 #define OP_PARM_UqHi OP_PARM_Uq 1060 1060 #define OP_PARM_WqZxReg OP_PARM_Wq /**< Annotates that register targets get their upper bits cleared. */ 1061 #define OP_PARM_MbRO OP_PARM_Mb /**< Annotates readonly memory byte operand. */ 1061 #define OP_PARM_MbRO OP_PARM_Mb /**< Annotates read only memory byte operand. */ 1062 #define OP_PARM_MdRO OP_PARM_Md /**< Annotates read only memory byte operand. */ 1062 1063 #define OP_PARM_MdWO OP_PARM_Md /**< Annotates write only memory byte operand. */ 1063 1064 -
trunk/src/VBox/VMM/VMMAll/IEMAllCImpl.cpp.h
r66391 r66404 7090 7090 7091 7091 /** 7092 * Implements 'LDMXCSR'. 7093 * 7094 * @param GCPtrEff The address of the image. 7095 */ 7096 IEM_CIMPL_DEF_2(iemCImpl_ldmxcsr, uint8_t, iEffSeg, RTGCPTR, GCPtrEff) 7097 { 7098 PCPUMCTX pCtx = IEM_GET_CTX(pVCpu); 7099 7100 /* 7101 * Raise exceptions. 7102 */ 7103 /** @todo testcase - order of LDMXCSR faults. Does \#PF, \#GP and \#SS 7104 * happen after or before \#UD and \#EM? */ 7105 if ( !(pCtx->cr0 & X86_CR0_EM) 7106 && (pCtx->cr4 & X86_CR4_OSFXSR)) 7107 { 7108 if (!(pCtx->cr0 & X86_CR0_TS)) 7109 { 7110 /* 7111 * Do the job. 7112 */ 7113 uint32_t fNewMxCsr; 7114 VBOXSTRICTRC rcStrict = iemMemFetchDataU32(pVCpu, &fNewMxCsr, iEffSeg, GCPtrEff); 7115 if (rcStrict == VINF_SUCCESS) 7116 { 7117 uint32_t const fMxCsrMask = CPUMGetGuestMxCsrMask(pVCpu->CTX_SUFF(pVM)); 7118 if (!(fNewMxCsr & ~fMxCsrMask)) 7119 { 7120 pCtx->CTX_SUFF(pXState)->x87.MXCSR = fNewMxCsr; 7121 iemRegAddToRipAndClearRF(pVCpu, cbInstr); 7122 return VINF_SUCCESS; 7123 } 7124 Log(("lddmxcsr: New MXCSR=%#RX32 & ~MASK=%#RX32 = %#RX32 -> #GP(0)\n", 7125 fNewMxCsr, fMxCsrMask, fNewMxCsr & ~fMxCsrMask)); 7126 return iemRaiseGeneralProtectionFault0(pVCpu); 7127 } 7128 return rcStrict; 7129 } 7130 return iemRaiseDeviceNotAvailable(pVCpu); 7131 } 7132 return iemRaiseUndefinedOpcode(pVCpu); 7133 } 7134 7135 7136 /** 7092 7137 * Commmon routine for fnstenv and fnsave. 7093 7138 * -
trunk/src/VBox/VMM/VMMAll/IEMAllInstructionsPython.py
r66391 r66404 123 123 }; 124 124 125 ## Constants and values for CR0. 126 g_kdX86Cr0Constants = { 127 'X86_CR0_PE': 0x00000001, # RT_BIT_32(0) 128 'X86_CR0_MP': 0x00000002, # RT_BIT_32(1) 129 'X86_CR0_EM': 0x00000004, # RT_BIT_32(2) 130 'X86_CR0_TS': 0x00000008, # RT_BIT_32(3) 131 'X86_CR0_ET': 0x00000010, # RT_BIT_32(4) 132 'X86_CR0_NE': 0x00000020, # RT_BIT_32(5) 133 'X86_CR0_WP': 0x00010000, # RT_BIT_32(16) 134 'X86_CR0_AM': 0x00040000, # RT_BIT_32(18) 135 'X86_CR0_NW': 0x20000000, # RT_BIT_32(29) 136 'X86_CR0_CD': 0x40000000, # RT_BIT_32(30) 137 'X86_CR0_PG': 0x80000000, # RT_BIT_32(31) 138 }; 139 140 ## Constants and values for CR4. 141 g_kdX86Cr4Constants = { 142 'X86_CR4_VME': 0x00000001, # RT_BIT_32(0) 143 'X86_CR4_PVI': 0x00000002, # RT_BIT_32(1) 144 'X86_CR4_TSD': 0x00000004, # RT_BIT_32(2) 145 'X86_CR4_DE': 0x00000008, # RT_BIT_32(3) 146 'X86_CR4_PSE': 0x00000010, # RT_BIT_32(4) 147 'X86_CR4_PAE': 0x00000020, # RT_BIT_32(5) 148 'X86_CR4_MCE': 0x00000040, # RT_BIT_32(6) 149 'X86_CR4_PGE': 0x00000080, # RT_BIT_32(7) 150 'X86_CR4_PCE': 0x00000100, # RT_BIT_32(8) 151 'X86_CR4_OSFXSR': 0x00000200, # RT_BIT_32(9) 152 'X86_CR4_OSXMMEEXCPT': 0x00000400, # RT_BIT_32(10) 153 'X86_CR4_VMXE': 0x00002000, # RT_BIT_32(13) 154 'X86_CR4_SMXE': 0x00004000, # RT_BIT_32(14) 155 'X86_CR4_PCIDE': 0x00020000, # RT_BIT_32(17) 156 'X86_CR4_OSXSAVE': 0x00040000, # RT_BIT_32(18) 157 'X86_CR4_SMEP': 0x00100000, # RT_BIT_32(20) 158 'X86_CR4_SMAP': 0x00200000, # RT_BIT_32(21) 159 'X86_CR4_PKE': 0x00400000, # RT_BIT_32(22) 160 }; 161 125 162 ## \@op[1-4] locations 126 163 g_kdOpLocations = { … … 175 212 'Ma': ( 'IDX_UseModRM', 'rm', '%Ma', 'Ma', ), ##< Only used by BOUND. 176 213 'MbRO': ( 'IDX_UseModRM', 'rm', '%Mb', 'Mb', ), 214 'MdRO': ( 'IDX_UseModRM', 'rm', '%Md', 'Md', ), 177 215 'MdWO': ( 'IDX_UseModRM', 'rm', '%Md', 'Md', ), 178 216 'Mq': ( 'IDX_UseModRM', 'rm', '%Mq', 'Mq', ), … … 729 767 return False; 730 768 769 class TestTypeFromDict(TestType): 770 """ 771 Special value parsing for CR0. 772 """ 773 774 kdZeroValueFlags = { 'nv': 0, 'pl': 0, 'nz': 0, 'na': 0, 'pe': 0, 'nc': 0, 'di': 0, 'up': 0 }; 775 776 def __init__(self, sName, kdConstantsAndValues, sConstantPrefix): 777 TestType.__init__(self, sName, acbSizes = [1, 2, 4, 8], fUnsigned = True); 778 self.kdConstantsAndValues = kdConstantsAndValues; 779 self.sConstantPrefix = sConstantPrefix; 780 781 def get(self, sValue): 782 fValue = 0; 783 for sFlag in sValue.split(','): 784 fFlagValue = self.kdConstantsAndValues.get(self.sConstantPrefix + sFlag.upper(), None); 785 if fFlagValue is None: 786 raise self.BadValue('Unknown flag "%s" in "%s"' % (sFlag, sValue)) 787 fValue |= fFlagValue; 788 return TestType.get(self, '0x%x' % (fValue,)); 731 789 732 790 … … 751 809 'int': TestType('int'), 752 810 'efl': TestTypeEflags('efl'), 811 'cr0': TestTypeFromDict('cr0', g_kdX86Cr0Constants, 'X86_CR0_'), 812 'cr4': TestTypeFromDict('cr4', g_kdX86Cr4Constants, 'X86_CR4_'), 753 813 }; 754 814 ## CPU context fields. … … 848 908 'oz.r14': ( 'uint', 'both', ), 849 909 'oz.r15': ( 'uint', 'both', ), 910 # Control registers. 911 'cr0': ( 'cr0', 'both', ), 912 'cr4': ( 'cr4', 'both', ), 850 913 # FPU Registers 851 914 'fcw': ( 'uint', 'both', ), -
trunk/src/VBox/VMM/VMMAll/IEMAllInstructionsTwoByte0f.cpp.h
r66391 r66404 5825 5825 } 5826 5826 5827 5828 /** Opcode 0x0f 0xae mem/2. */ 5829 FNIEMOP_STUB_1(iemOp_Grp15_ldmxcsr, uint8_t, bRm); 5827 /** 5828 * @opmaps grp15 5829 * @opcode !11/2 5830 * @oppfx none 5831 * @opcpuid sse 5832 * @opgroup og_cachectl 5833 * @optest op1=0 -> mxcsr=0 5834 * @optest op1=0x2083 -> mxcsr=0x2083 5835 * @optest op1=0xfffffffe -> value.xcpt=0xd 5836 * @optest op1=0x2083 cr0|=ts -> value.xcpt=0x7 5837 * @optest op1=0x2083 cr0|=em -> value.xcpt=0x6 5838 * @optest op1=0x2083 cr0|=mp -> mxcsr=0x2083 5839 * @optest op1=0x2083 cr4&~=osfxsr -> value.xcpt=0x6 5840 * @optest op1=0x2083 cr0|=ts,em -> value.xcpt=0x6 5841 * @optest op1=0x2083 cr0|=em cr4&~=osfxsr -> value.xcpt=0x6 5842 * @optest op1=0x2083 cr0|=ts,em cr4&~=osfxsr -> value.xcpt=0x6 5843 * @optest op1=0x2083 cr0|=ts,em,mp cr4&~=osfxsr -> value.xcpt=0x6 5844 * @oponlytest 5845 */ 5846 FNIEMOP_DEF_1(iemOp_Grp15_ldmxcsr, uint8_t, bRm) 5847 { 5848 IEMOP_MNEMONIC1(M_MEM, LDMXCSR, ldmxcsr, MdRO, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZE); 5849 if (!IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fSse) 5850 return IEMOP_RAISE_INVALID_OPCODE(); 5851 5852 IEM_MC_BEGIN(2, 0); 5853 IEM_MC_ARG(uint8_t, iEffSeg, 0); 5854 IEM_MC_ARG(RTGCPTR, GCPtrEff, 1); 5855 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEff, bRm, 0); 5856 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX(); 5857 IEM_MC_ACTUALIZE_SSE_STATE_FOR_READ(); 5858 IEM_MC_ASSIGN(iEffSeg, pVCpu->iem.s.iEffSeg); 5859 IEM_MC_CALL_CIMPL_2(iemCImpl_ldmxcsr, iEffSeg, GCPtrEff); 5860 IEM_MC_END(); 5861 return VINF_SUCCESS; 5862 } 5830 5863 5831 5864 … … 5835 5868 * @oppfx none 5836 5869 * @opcpuid sse 5837 * @opgroup og_cachectl 5838 * @optest mxcsr=0 -> op1=0 5839 * @optest mxcsr=0x2083 -> op1=0x2083 5840 * @oponlytest 5870 * @opgroup og_sse_mxcsrsm 5871 * @optest mxcsr=0 op1=0x2083 -> mxcsr=0x2083 5841 5872 */ 5842 5873 FNIEMOP_DEF_1(iemOp_Grp15_stmxcsr, uint8_t, bRm) … … 5846 5877 return IEMOP_RAISE_INVALID_OPCODE(); 5847 5878 5848 IEM_MC_BEGIN(2, 1);5879 IEM_MC_BEGIN(2, 0); 5849 5880 IEM_MC_ARG(uint8_t, iEffSeg, 0); 5850 5881 IEM_MC_ARG(RTGCPTR, GCPtrEff, 1); -
trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-generated-1-template.c
r66392 r66404 395 395 /* [BS3CG1DST_OZ_R14] = */ BS3CG1DSTSIZE_OPERAND_SIZE_GRP, 396 396 /* [BS3CG1DST_OZ_R15] = */ BS3CG1DSTSIZE_OPERAND_SIZE_GRP, 397 398 /* [BS3CG1DST_CR0] = */ 4, 399 /* [BS3CG1DST_CR4] = */ 4, 397 400 398 401 /* [BS3CG1DST_FCW] = */ 2, … … 623 626 /* [BS3CG1DST_OZ_R15] = */ RT_OFFSETOF(BS3REGCTX, r15), 624 627 628 /* [BS3CG1DST_CR0] = */ RT_OFFSETOF(BS3REGCTX, cr0), 629 /* [BS3CG1DST_CR4] = */ RT_OFFSETOF(BS3REGCTX, cr4), 630 625 631 /* [BS3CG1DST_FCW] = */ sizeof(BS3REGCTX) + RT_OFFSETOF(BS3EXTCTX, Ctx.x87.FCW), 626 632 /* [BS3CG1DST_FSW] = */ sizeof(BS3REGCTX) + RT_OFFSETOF(BS3EXTCTX, Ctx.x87.FSW), … … 852 858 { "OZ_R15" }, 853 859 860 { "CR0" }, 861 { "CR4" }, 862 854 863 { "FCW" }, 855 864 { "FSW" }, … … 861 870 { "FPUDS" }, 862 871 { "MXCSR" }, 863 { "MXCSR_M" },864 872 { "ST0" }, 865 873 { "ST1" }, … … 977 985 { "VALXCPT" }, 978 986 }; 987 AssertCompile(RT_ELEMENTS(g_aszBs3Cg1DstFields) >= BS3CG1DST_END); 979 988 AssertCompile(RT_ELEMENTS(g_aszBs3Cg1DstFields) == BS3CG1DST_END); 980 989 … … 1556 1565 break; 1557 1566 1567 case BS3CG1ENC_MODRM_MdRO: 1568 if (iEncoding == 0) 1569 { 1570 off = Bs3Cg1InsertOpcodes(pThis, Bs3Cg1InsertReqPrefix(pThis, 0)) - 1; 1571 off = Bs3Cfg1EncodeMemMod0Disp(pThis, false, off, 1572 (pThis->abCurInstr[off] & X86_MODRM_REG_MASK) >> X86_MODRM_REG_SHIFT, 1573 4, 0, BS3CG1OPLOC_MEM); 1574 } 1575 else 1576 break; 1577 pThis->cbCurInstr = off; 1578 iEncoding++; 1579 break; 1580 1558 1581 case BS3CG1ENC_MODRM_MdWO: 1559 1582 if (iEncoding == 0) … … 1836 1859 pThis->iRmOp = 0; 1837 1860 pThis->aOperands[0].cbOp = 1; 1861 pThis->aOperands[0].enmLocation = BS3CG1OPLOC_MEM; 1862 break; 1863 1864 case BS3CG1ENC_MODRM_MdRO: 1865 pThis->iRmOp = 0; 1866 pThis->aOperands[0].cbOp = 4; 1838 1867 pThis->aOperands[0].enmLocation = BS3CG1OPLOC_MEM; 1839 1868 break; … … 2166 2195 case BS3CG1_CTXOP_AND: return "&="; 2167 2196 case BS3CG1_CTXOP_AND_INV: return "&~="; 2197 default: return "?WTF?"; 2168 2198 } 2169 2199 } … … 3284 3314 #if 0 3285 3315 /* (for debugging) */ 3286 if ( !BS3_MODE_IS_RM_OR_V86(bMode))3316 if (bMode != BS3_MODE_PPV86) 3287 3317 return BS3TESTDOMODE_SKIPPED; 3288 3318 #endif -
trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-generated-1.h
r66391 r66404 70 70 BS3CG1OP_Ma, 71 71 BS3CG1OP_MbRO, 72 BS3CG1OP_MdRO, 72 73 BS3CG1OP_MdWO, 73 74 BS3CG1OP_Mq, … … 104 105 BS3CG1ENC_MODRM_Vdq_Wdq, 105 106 BS3CG1ENC_MODRM_MbRO, 107 BS3CG1ENC_MODRM_MdRO, 106 108 BS3CG1ENC_MODRM_MdWO, 107 109 … … 410 412 BS3CG1DST_OZ_R14, 411 413 BS3CG1DST_OZ_R15, 414 415 /* Control registers.*/ 416 BS3CG1DST_CR0, 417 BS3CG1DST_CR4, 412 418 413 419 /* FPU registers. */ -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-RegCtxRestore.asm
r60774 r66404 309 309 je .skip_control_regs 310 310 %endif 311 test byte [xBX + BS3REGCTX.fbFlags], BS3REG_CTX_F_NO_TR_LDTR 312 jnz .skip_control_regs 311 313 312 314 ; LDTR -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-RegCtxSaveEx.asm
r66199 r66404 33 33 ;********************************************************************************************************************************* 34 34 BS3_EXTERN_DATA16 g_bBs3CurrentMode 35 %if ARCH_BITS != 64 36 BS3_EXTERN_DATA16 g_uBs3CpuDetected 37 %endif 35 38 36 39 TMPL_BEGIN_TEXT … … 97 100 push xBP 98 101 mov xBP, xSP 102 %if ARCH_BITS == 64 103 push rcx ; Save pRegCtx 104 %endif 99 105 100 106 ; … … 151 157 BS3_CALL_CONV_EPILOG 3 152 158 BS3_HYBRID_RET 153 154 159 155 160 ; … … 218 223 %endif 219 224 BS3_SET_BITS TMPL_BITS 220 jmp . return225 jmp .supplement_and_return 221 226 TMPL_BEGIN_TEXT 222 227 … … 256 261 call _Bs3SwitchTo%[TMPL_BITS]Bit_c16 257 262 BS3_SET_BITS TMPL_BITS 258 jmp . return263 jmp .supplement_and_return 259 264 TMPL_BEGIN_TEXT 260 265 %endif … … 292 297 call _Bs3SwitchTo16Bit_c32 293 298 BS3_SET_BITS TMPL_BITS 294 jmp . return299 jmp .supplement_and_return 295 300 .code_32_back_to_v86: 296 301 BS3_SET_BITS 32 297 302 call _Bs3SwitchTo16BitV86_c32 303 BS3_SET_BITS TMPL_BITS 304 jmp .return 298 305 %else 299 306 call _Bs3SwitchTo64Bit_c32 300 %endif301 BS3_SET_BITS TMPL_BITS302 jmp .return307 BS3_SET_BITS TMPL_BITS 308 jmp .supplement_and_return 309 %endif 303 310 %endif 304 311 … … 334 341 jmp .return 335 342 %endif 343 344 345 ; 346 ; Supplement the state out of the current context and then return. 347 ; 348 .supplement_and_return: 349 %if ARCH_BITS == 16 350 CPU 8086 351 ; Skip 286 and older. Also make 101% sure we not in real mode or v8086 mode. 352 cmp byte [BS3_DATA16_WRT(g_uBs3CpuDetected)], BS3CPU_80386 353 jb .return ; Just skip if 286 or older. 354 test byte [BS3_DATA16_WRT(g_bBs3CurrentMode)], BS3_MODE_CODE_V86 355 jnz .return 356 cmp byte [BS3_DATA16_WRT(g_bBs3CurrentMode)], BS3_MODE_RM 357 jne .return ; paranoia 358 CPU 386 359 %endif 360 361 ; Load the context pointer into a suitable register. 362 %if ARCH_BITS == 64 363 %define pRegCtx rcx 364 mov rcx, [xBP - xCB] 365 %elif ARCH_BITS == 32 366 %define pRegCtx ecx 367 mov ecx, [xBP + xCB + cbCurRetAddr] 368 %else 369 %define pRegCtx es:bx 370 push es 371 push bx 372 les bx, [xBP + xCB + cbCurRetAddr] 373 %endif 374 %if ARCH_BITS == 64 375 ; If we're in 64-bit mode we can capture and restore the high bits. 376 test byte [pRegCtx + BS3REGCTX.fbFlags], BS3REG_CTX_F_NO_AMD64 377 jz .supplemented_64bit_registers 378 mov [pRegCtx + BS3REGCTX.r8], r8 379 mov [pRegCtx + BS3REGCTX.r9], r9 380 mov [pRegCtx + BS3REGCTX.r10], r10 381 mov [pRegCtx + BS3REGCTX.r11], r11 382 mov [pRegCtx + BS3REGCTX.r12], r12 383 mov [pRegCtx + BS3REGCTX.r13], r13 384 mov [pRegCtx + BS3REGCTX.r14], r14 385 mov [pRegCtx + BS3REGCTX.r15], r15 386 shr rax, 32 387 mov [pRegCtx + BS3REGCTX.rax + 4], eax 388 mov rax, rbx 389 shr rax, 32 390 mov [pRegCtx + BS3REGCTX.rbx + 4], eax 391 mov rax, rcx 392 shr rax, 32 393 mov [pRegCtx + BS3REGCTX.rcx + 4], eax 394 mov rax, rdx 395 shr rax, 32 396 mov [pRegCtx + BS3REGCTX.rdx + 4], eax 397 mov rax, rsp 398 shr rax, 32 399 mov [pRegCtx + BS3REGCTX.rsp + 4], eax 400 mov rax, rbp 401 shr rax, 32 402 mov [pRegCtx + BS3REGCTX.rbp + 4], eax 403 mov rax, rsi 404 shr rax, 32 405 mov [pRegCtx + BS3REGCTX.rsi + 4], eax 406 mov rax, rdi 407 shr rax, 32 408 mov [pRegCtx + BS3REGCTX.rdi + 4], eax 409 ;and byte [pRegCtx + BS3REGCTX.fbFlags], ~BS3REG_CTX_F_NO_AMD64 - enable later. 410 .supplemented_64bit_registers: 411 %endif 412 ; The rest requires ring-0 (at least during restore). 413 mov ax, ss 414 test ax, 3 415 jnz .done_supplementing 416 417 ; Do control registers. 418 test byte [pRegCtx + BS3REGCTX.fbFlags], BS3REG_CTX_F_NO_CR2_CR3 | BS3REG_CTX_F_NO_CR0_IS_MSW | BS3REG_CTX_F_NO_CR4 419 jz .supplemented_control_registers 420 mov sAX, cr0 421 mov [pRegCtx + BS3REGCTX.cr0], sAX 422 mov sAX, cr2 423 mov [pRegCtx + BS3REGCTX.cr2], sAX 424 mov sAX, cr3 425 mov [pRegCtx + BS3REGCTX.cr3], sAX 426 and byte [pRegCtx + BS3REGCTX.fbFlags], ~(BS3REG_CTX_F_NO_CR2_CR3 | BS3REG_CTX_F_NO_CR0_IS_MSW) 427 428 %if ARCH_BITS != 64 429 test byte [1 + BS3_DATA16_WRT(g_uBs3CpuDetected)], (BS3CPU_F_CPUID >> 8) 430 jz .supplemented_control_registers 431 %endif 432 mov sAX, cr4 433 mov [pRegCtx + BS3REGCTX.cr4], sAX 434 and byte [pRegCtx + BS3REGCTX.fbFlags], ~BS3REG_CTX_F_NO_CR4 435 .supplemented_control_registers: 436 437 ; Supply tr and ldtr if necessary 438 test byte [pRegCtx + BS3REGCTX.fbFlags], BS3REG_CTX_F_NO_TR_LDTR 439 jz .done_supplementing 440 str [pRegCtx + BS3REGCTX.tr] 441 sldt [pRegCtx + BS3REGCTX.ldtr] 442 and byte [pRegCtx + BS3REGCTX.fbFlags], ~BS3REG_CTX_F_NO_TR_LDTR 443 444 .done_supplementing: 445 TONLY16 pop bx 446 TONLY16 pop es 447 jmp .return 448 %undef pRegCtx 336 449 BS3_PROC_END_CMN Bs3RegCtxSaveEx 337 450 338
Note:
See TracChangeset
for help on using the changeset viewer.