VirtualBox

Changeset 49002 in vbox


Ignore:
Timestamp:
Oct 9, 2013 1:15:43 PM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
89727
Message:

VMM/HMVMXR0: Use instruction info. for string IO VM-exits on CPUs that support it, rather than disassembling the instruction.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp

    r49000 r49002  
    124124#define HMVMX_UPDATED_TRANSIENT_EXIT_INTERRUPTION_INFO        RT_BIT(4)
    125125#define HMVMX_UPDATED_TRANSIENT_EXIT_INTERRUPTION_ERROR_CODE  RT_BIT(5)
     126#define HMVMX_UPDATED_TRANSIENT_EXIT_INSTR_INFO               RT_BIT(6)
    126127/** @} */
    127128
     
    237238        struct
    238239        {
    239             uint32_t    u6Reserved0 : 6;
     240            uint32_t    u6Reserved0 : 7;
    240241            /** The address size; 0=16-bit, 1=32-bit, 2=64-bit, rest undefined. */
    241242            uint32_t    u3AddrSize  : 3;
     
    660661DECLINLINE(int) hmR0VmxReadExitInstrInfoVmcs(PVMCPU pVCpu, PVMXTRANSIENT pVmxTransient)
    661662{
    662     if (!(pVmxTransient->fVmcsFieldsRead & HMVMX_UPDATED_TRANSIENT_EXIT_INSTR_LEN))
    663     {
    664         int rc = VMXReadVmcs32(VMX_VMCS32_RO_EXIT_INSTR_INFO, &pVmxTransient->cbInstr);
     663    if (!(pVmxTransient->fVmcsFieldsRead & HMVMX_UPDATED_TRANSIENT_EXIT_INSTR_INFO))
     664    {
     665        int rc = VMXReadVmcs32(VMX_VMCS32_RO_EXIT_INSTR_INFO, &pVmxTransient->ExitInstrInfo.u);
    665666        AssertRCReturn(rc, rc);
    666         pVmxTransient->fVmcsFieldsRead |= HMVMX_UPDATED_TRANSIENT_EXIT_INSTR_LEN;
     667        pVmxTransient->fVmcsFieldsRead |= HMVMX_UPDATED_TRANSIENT_EXIT_INSTR_INFO;
    667668    }
    668669    return VINF_SUCCESS;
     
    96359636                    Log4(("CRX CR0 write rc=%d CR0=%#RX64\n", rc, pMixedCtx->cr0));
    96369637                    break;
    9637                 case 2: /* C2 **/
     9638                case 2: /* CR2 */
    96389639                    /* Nothing to do here, CR2 it's not part of the VMCS. */
    96399640                    break;
     
    97719772         * interpreting the instruction.
    97729773         */
    9773 #if 0 /* Not quite ready, seem iSegReg assertion trigger once... Do we perhaps need to always read that in longjmp / preempt scenario? */
    97749774        Log4(("CS:RIP=%04x:%#RX64 %#06x/%u %c str\n", pMixedCtx->cs.Sel, pMixedCtx->rip, uIOPort, cbValue, fIOWrite ? 'w' : 'r'));
    97759775        AssertReturn(pMixedCtx->dx == uIOPort, VERR_HMVMX_IPE_2);
    97769776        if (MSR_IA32_VMX_BASIC_INFO_VMCS_INS_OUTS(pVM->hm.s.vmx.Msrs.u64BasicInfo))
    97779777        {
    9778             rc2  = hmR0VmxReadExitIntrInfoVmcs(pVCpu, pVmxTransient);
     9778            rc2  = hmR0VmxReadExitInstrInfoVmcs(pVCpu, pVmxTransient);
    97799779            /** @todo optimize this, IEM should request the additional state if it needs it (GP, PF, ++). */
    97809780            rc2 |= hmR0VmxSaveGuestState(pVCpu, pMixedCtx);
     
    97889788                rcStrict = IEMExecStringIoWrite(pVCpu, cbValue, enmAddrMode, fRep, cbInstr,
    97899789                                                pVmxTransient->ExitInstrInfo.StrIo.iSegReg);
    9790                 //if (rcStrict == VINF_IOM_R3_IOPORT_WRITE)
    9791                 //    hmR0SavePendingIOPortWriteStr(pVCpu, pMixedCtx->rip, cbValue, enmAddrMode, fRep, cbInstr,
    9792                 //                                  pVmxTransient->ExitInstrInfo.StrIo.iSegReg);
    97939790            }
    97949791            else
    97959792            {
    9796                 AssertMsgReturn(pVmxTransient->ExitInstrInfo.StrIo.iSegReg == X86_SREG_ES,
    9797                                 ("%#x (%#llx)\n", pVmxTransient->ExitInstrInfo.StrIo.iSegReg, pVmxTransient->ExitInstrInfo.u),
    9798                                 VERR_HMVMX_IPE_4);
     9793                /*
     9794                 * The segment prefix for INS cannot be overridden and is always ES. We can safely assume X86_SREG_ES.
     9795                 * Hence "iSegReg" field is undefined in the instruction-information field in VT-x for INS.
     9796                 * See Intel Instruction spec. for "INS".
     9797                 * See Intel spec. Table 27-8 "Format of the VM-Exit Instruction-Information Field as Used for INS and OUTS".
     9798                 */
    97999799                rcStrict = IEMExecStringIoRead(pVCpu, cbValue, enmAddrMode, fRep, cbInstr);
    9800                 //if (rcStrict == VINF_IOM_R3_IOPORT_READ)
    9801                 //    hmR0SavePendingIOPortReadStr(pVCpu, pMixedCtx->rip, cbValue, enmAddrMode, fRep, cbInstr);
    98029800            }
    98039801        }
     
    98129810        VMCPU_HMCF_SET(pVCpu, HM_CHANGED_GUEST_RIP);
    98139811        fUpdateRipAlready = true;
    9814 #else
    9815         PDISCPUSTATE pDis = &pVCpu->hm.s.DisState;
    9816         rcStrict = EMInterpretDisasCurrent(pVM, pVCpu, pDis, NULL);
    9817         if (RT_SUCCESS(rcStrict))
    9818         {
    9819             if (fIOWrite)
    9820             {
    9821                 rcStrict = IOMInterpretOUTSEx(pVM, pVCpu, CPUMCTX2CORE(pMixedCtx), uIOPort, pDis->fPrefix,
    9822                                               (DISCPUMODE)pDis->uAddrMode, cbValue);
    9823                 STAM_COUNTER_INC(&pVCpu->hm.s.StatExitIOStringWrite);
    9824             }
    9825             else
    9826             {
    9827                 rcStrict = IOMInterpretINSEx(pVM, pVCpu, CPUMCTX2CORE(pMixedCtx), uIOPort, pDis->fPrefix,
    9828                                              (DISCPUMODE)pDis->uAddrMode, cbValue);
    9829                 STAM_COUNTER_INC(&pVCpu->hm.s.StatExitIOStringRead);
    9830             }
    9831         }
    9832         else
    9833         {
    9834             AssertMsg(rcStrict == VERR_EM_INTERPRETER, ("rcStrict=%Rrc RIP %#RX64\n", VBOXSTRICTRC_VAL(rcStrict), pMixedCtx->rip));
    9835             rcStrict = VINF_EM_RAW_EMULATE_INSTR;
    9836         }
    9837 #endif
    98389812    }
    98399813    else
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