- Timestamp:
- Jul 8, 2016 10:52:42 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/IEMAll.cpp
r62109 r62134 1036 1036 pVCpu->iem.s.uRexIndex = 0; 1037 1037 pVCpu->iem.s.iEffSeg = X86_SREG_DS; 1038 if (pVCpu->iem.s.cbOpcode > pVCpu->iem.s.offOpcode) /* No need to check RIP here because branch instructions will update cbOpcode. */ 1039 { 1040 pVCpu->iem.s.cbOpcode -= pVCpu->iem.s.offOpcode; 1041 memmove(&pVCpu->iem.s.abOpcode[0], &pVCpu->iem.s.abOpcode[pVCpu->iem.s.offOpcode], pVCpu->iem.s.cbOpcode); 1042 } 1043 else 1038 // busted and need rewrite: 1039 //if (pVCpu->iem.s.cbOpcode > pVCpu->iem.s.offOpcode) /* No need to check RIP here because branch instructions will update cbOpcode. */ 1040 //{ 1041 // pVCpu->iem.s.cbOpcode -= pVCpu->iem.s.offOpcode; 1042 // memmove(&pVCpu->iem.s.abOpcode[0], &pVCpu->iem.s.abOpcode[pVCpu->iem.s.offOpcode], pVCpu->iem.s.cbOpcode); 1043 //} 1044 //else 1044 1045 pVCpu->iem.s.cbOpcode = 0; 1045 1046 pVCpu->iem.s.offOpcode = 0; … … 8125 8126 else 8126 8127 { 8127 PCPUMSELREGHID pSel 8128 PCPUMSELREGHID pSel = iemSRegGetHid(pVCpu, iSegReg); 8128 8129 if ( (pSel->Attr.u & (X86DESCATTR_P | X86DESCATTR_UNUSABLE | X86_SEL_TYPE_CODE | X86_SEL_TYPE_DOWN)) 8129 8130 == X86DESCATTR_P /* data, expand up */ … … 8150 8151 iemRaiseSelectorInvalidAccessJmp(pVCpu, iSegReg, IEM_ACCESS_DATA_R); 8151 8152 iemRaiseSelectorBoundsJmp(pVCpu, iSegReg, IEM_ACCESS_DATA_R); 8153 } 8154 iemRaiseGeneralProtectionFault0Jmp(pVCpu); 8155 } 8156 8157 8158 IEM_STATIC RTGCPTR iemMemApplySegmentToWriteJmp(PVMCPU pVCpu, uint8_t iSegReg, size_t cbMem, RTGCPTR GCPtrMem) 8159 { 8160 Assert(cbMem >= 1); 8161 Assert(iSegReg < X86_SREG_COUNT); 8162 8163 /* 8164 * 64-bit mode is simpler. 8165 */ 8166 if (pVCpu->iem.s.enmCpuMode == IEMMODE_64BIT) 8167 { 8168 if (iSegReg >= X86_SREG_FS) 8169 { 8170 PCPUMSELREGHID pSel = iemSRegGetHid(pVCpu, iSegReg); 8171 GCPtrMem += pSel->u64Base; 8172 } 8173 8174 if (RT_LIKELY(X86_IS_CANONICAL(GCPtrMem) && X86_IS_CANONICAL(GCPtrMem + cbMem - 1))) 8175 return GCPtrMem; 8176 } 8177 /* 8178 * 16-bit and 32-bit segmentation. 8179 */ 8180 else 8181 { 8182 PCPUMSELREGHID pSel = iemSRegGetHid(pVCpu, iSegReg); 8183 uint32_t const fRelevantAttrs = pSel->Attr.u & ( X86DESCATTR_P | X86DESCATTR_UNUSABLE 8184 | X86_SEL_TYPE_CODE | X86_SEL_TYPE_WRITE | X86_SEL_TYPE_DOWN); 8185 if (fRelevantAttrs == (X86DESCATTR_P | X86_SEL_TYPE_WRITE)) /* data, expand up */ 8186 { 8187 /* expand up */ 8188 uint32_t GCPtrLast32 = (uint32_t)GCPtrMem + (uint32_t)cbMem; 8189 if (RT_LIKELY( GCPtrLast32 > pSel->u32Limit 8190 && GCPtrLast32 > (uint32_t)GCPtrMem)) 8191 return (uint32_t)GCPtrMem + (uint32_t)pSel->u64Base; 8192 } 8193 else if (fRelevantAttrs == (X86DESCATTR_P | X86_SEL_TYPE_WRITE | X86_SEL_TYPE_DOWN)) /* data, expand up */ 8194 { 8195 /* expand down */ 8196 uint32_t GCPtrLast32 = (uint32_t)GCPtrMem + (uint32_t)cbMem; 8197 if (RT_LIKELY( (uint32_t)GCPtrMem > pSel->u32Limit 8198 && GCPtrLast32 <= (pSel->Attr.n.u1DefBig ? UINT32_MAX : UINT32_C(0xffff)) 8199 && GCPtrLast32 > (uint32_t)GCPtrMem)) 8200 return (uint32_t)GCPtrMem + (uint32_t)pSel->u64Base; 8201 } 8202 else 8203 iemRaiseSelectorInvalidAccessJmp(pVCpu, iSegReg, IEM_ACCESS_DATA_W); 8204 iemRaiseSelectorBoundsJmp(pVCpu, iSegReg, IEM_ACCESS_DATA_W); 8152 8205 } 8153 8206 iemRaiseGeneralProtectionFault0Jmp(pVCpu); … … 13068 13121 { 13069 13122 /* 13070 * The run loop. We limit ourselves to 2048instructions right now.13123 * The run loop. We limit ourselves to 4096 instructions right now. 13071 13124 */ 13072 13125 PVM pVM = pVCpu->CTX_SUFF(pVM); 13073 uint32_t cInstr = 2048;13126 uint32_t cInstr = 4096; 13074 13127 for (;;) 13075 13128 { … … 13092 13145 if (RT_LIKELY(pVCpu->iem.s.rcPassUp == VINF_SUCCESS)) 13093 13146 { 13094 if (RT_LIKELY( !VMCPU_FF_IS_PENDING(pVCpu, VMCPU_FF_ALL_MASK & ~VMCPU_FF_INHIBIT_INTERRUPTS) 13095 && !VM_FF_IS_PENDING(pVM, VM_FF_ALL_MASK) 13096 && cInstr-- > 0 )) 13147 uint32_t fCpu = pVCpu->fLocalForcedActions 13148 & ( VMCPU_FF_ALL_MASK & ~( VMCPU_FF_PGM_SYNC_CR3 13149 | VMCPU_FF_PGM_SYNC_CR3_NON_GLOBAL 13150 | VMCPU_FF_TLB_FLUSH 13151 | VMCPU_FF_TRPM_SYNC_IDT 13152 | VMCPU_FF_SELM_SYNC_TSS 13153 | VMCPU_FF_SELM_SYNC_GDT 13154 | VMCPU_FF_SELM_SYNC_LDT 13155 | VMCPU_FF_INHIBIT_INTERRUPTS 13156 | VMCPU_FF_BLOCK_NMIS )); 13157 13158 if (RT_LIKELY( ( !fCpu 13159 || ( !(fCpu & ~(VMCPU_FF_INTERRUPT_APIC | VMCPU_FF_INTERRUPT_PIC)) 13160 && !pCtx->rflags.Bits.u1IF) ) 13161 && !VM_FF_IS_PENDING(pVM, VM_FF_ALL_MASK) )) 13097 13162 { 13098 iemReInitDecoder(pVCpu); 13099 continue; 13163 if (cInstr-- > 0) 13164 { 13165 Assert(pVCpu->iem.s.cActiveMappings == 0); 13166 iemReInitDecoder(pVCpu); 13167 continue; 13168 } 13100 13169 } 13101 13170 } 13171 Assert(pVCpu->iem.s.cActiveMappings == 0); 13102 13172 } 13103 else if (pVCpu->iem.s.cActiveMappings > 0) /** @todo This should only happen when rcStrict != VINF_SUCCESS! */13104 iemMemRollback(pVCpu);13173 else if (pVCpu->iem.s.cActiveMappings > 0) 13174 iemMemRollback(pVCpu); 13105 13175 rcStrict = iemExecStatusCodeFiddling(pVCpu, rcStrict); 13106 13176 break;
Note:
See TracChangeset
for help on using the changeset viewer.