VirtualBox

Changeset 62134 in vbox for trunk


Ignore:
Timestamp:
Jul 8, 2016 10:52:42 AM (9 years ago)
Author:
vboxsync
Message:

IEMExecLots: Made it do more than a single loop.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/IEMAll.cpp

    r62109 r62134  
    10361036    pVCpu->iem.s.uRexIndex          = 0;
    10371037    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
    10441045        pVCpu->iem.s.cbOpcode       = 0;
    10451046    pVCpu->iem.s.offOpcode          = 0;
     
    81258126    else
    81268127    {
    8127         PCPUMSELREGHID pSel   = iemSRegGetHid(pVCpu, iSegReg);
     8128        PCPUMSELREGHID pSel = iemSRegGetHid(pVCpu, iSegReg);
    81288129        if (      (pSel->Attr.u & (X86DESCATTR_P | X86DESCATTR_UNUSABLE | X86_SEL_TYPE_CODE | X86_SEL_TYPE_DOWN))
    81298130               == X86DESCATTR_P /* data, expand up */
     
    81508151            iemRaiseSelectorInvalidAccessJmp(pVCpu, iSegReg, IEM_ACCESS_DATA_R);
    81518152        iemRaiseSelectorBoundsJmp(pVCpu, iSegReg, IEM_ACCESS_DATA_R);
     8153    }
     8154    iemRaiseGeneralProtectionFault0Jmp(pVCpu);
     8155}
     8156
     8157
     8158IEM_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);
    81528205    }
    81538206    iemRaiseGeneralProtectionFault0Jmp(pVCpu);
     
    1306813121        {
    1306913122            /*
    13070              * The run loop.  We limit ourselves to 2048 instructions right now.
     13123             * The run loop.  We limit ourselves to 4096 instructions right now.
    1307113124             */
    1307213125            PVM         pVM    = pVCpu->CTX_SUFF(pVM);
    13073             uint32_t    cInstr = 2048;
     13126            uint32_t    cInstr = 4096;
    1307413127            for (;;)
    1307513128            {
     
    1309213145                    if (RT_LIKELY(pVCpu->iem.s.rcPassUp == VINF_SUCCESS))
    1309313146                    {
    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) ))
    1309713162                        {
    13098                             iemReInitDecoder(pVCpu);
    13099                             continue;
     13163                            if (cInstr-- > 0)
     13164                            {
     13165                                Assert(pVCpu->iem.s.cActiveMappings == 0);
     13166                                iemReInitDecoder(pVCpu);
     13167                                continue;
     13168                            }
    1310013169                        }
    1310113170                    }
     13171                    Assert(pVCpu->iem.s.cActiveMappings == 0);
    1310213172                }
    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);
    1310513175                rcStrict = iemExecStatusCodeFiddling(pVCpu, rcStrict);
    1310613176                break;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette