VirtualBox

Ignore:
Timestamp:
Feb 22, 2018 9:15:09 AM (7 years ago)
Author:
vboxsync
Message:

VMM/IEM: Nested Hw.virt: Implement SVM decode-assist and NRIP.

File:
1 edited

Legend:

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

    r71069 r71093  
    956956            && !(uErr & X86_TRAP_PF_ID))
    957957        {
    958             /** @todo Nested-guest SVM - figure out fetching op-code bytes from IEM. */
    959958            PSVMVMCBCTRL  pVmcbCtrl = &pCtx->hwvirt.svm.CTX_SUFF(pVmcb)->ctrl;
    960959#ifdef IEM_WITH_CODE_TLB
    961             uint8_t const cbCurrent   = pVCpu->iem.s.cbInstrBuf;
    962960            uint8_t const *pbInstrBuf = pVCpu->iem.s.pbInstrBuf;
     961            uint8_t const  cbInstrBuf = pVCpu->iem.s.cbInstrBuf;
     962            pVmcbCtrl->cbInstrFetched = RT_MIN(cbInstrBuf, SVM_CTRL_GUEST_INSTR_BYTES_MAX);
    963963            if (   pbInstrBuf
    964                 && cbCurrent >= SVM_CTRL_GUEST_INSTR_BYTES_MAX)
    965             {
    966                 pVmcbCtrl->cbInstrFetched = SVM_CTRL_GUEST_INSTR_BYTES_MAX;
    967                 memcpy(&pVmcbCtrl->abInstr[0], pbInstrBuf, SVM_CTRL_GUEST_INSTR_BYTES_MAX);
    968             }
    969             else
    970             { AssertReleaseFailedReturn(VERR_IEM_IPE_5); /** @todo */ }
     964                && cbInstrBuf > 0)
     965                memcpy(&pVmcbCtrl->abInstr[0], pbInstrBuf, pVmcbCtrl->cbInstrFetched);
    971966#else
    972             uint8_t const offOpCode = pVCpu->iem.s.offOpcode;
    973             uint8_t const cbCurrent = pVCpu->iem.s.cbOpcode - offOpCode;
    974             if (cbCurrent >= SVM_CTRL_GUEST_INSTR_BYTES_MAX)
    975             {
    976                 pVmcbCtrl->cbInstrFetched = SVM_CTRL_GUEST_INSTR_BYTES_MAX;
    977                 memcpy(&pVmcbCtrl->abInstr[0], &pVCpu->iem.s.abOpcode[offOpCode], SVM_CTRL_GUEST_INSTR_BYTES_MAX);
    978             }
    979             else
    980             { AssertReleaseFailedReturn(VERR_IEM_IPE_5); /** @todo */ }
     967            uint8_t const cbOpcode    = pVCpu->iem.s.cbOpcode;
     968            pVmcbCtrl->cbInstrFetched = RT_MIN(cbOpcode, SVM_CTRL_GUEST_INSTR_BYTES_MAX);
     969            if (cbOpcode > 0)
     970                memcpy(&pVmcbCtrl->abInstr[0], &pVCpu->iem.s.abOpcode[0], pVmcbCtrl->cbInstrFetched);
    981971#endif
    982972        }
     973        if (u8Vector == X86_XCPT_BR)
     974            IEM_SVM_UPDATE_NRIP(pVCpu);
    983975        Log2(("iemHandleSvmNstGstEventIntercept: Xcpt intercept u32InterceptXcpt=%#RX32 u8Vector=%#x "
    984976              "uExitInfo1=%#RX64 uExitInfo2=%#RX64 -> #VMEXIT\n", pCtx->hwvirt.svm.CTX_SUFF(pVmcb)->ctrl.u32InterceptXcpt,
     
    996988        uint64_t const uExitInfo1 = IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fSvmDecodeAssists ? u8Vector : 0;
    997989        Log2(("iemHandleSvmNstGstEventIntercept: Software INT intercept (u8Vector=%#x) -> #VMEXIT\n", u8Vector));
     990        IEM_SVM_UPDATE_NRIP(pVCpu);
    998991        IEM_RETURN_SVM_VMEXIT(pVCpu, SVM_EXIT_SWINT, uExitInfo1, 0 /* uExitInfo2 */);
    999992    }
     
    10431036    {
    10441037        Log3(("iemSvmHandleIOIntercept: u16Port=%#x (%u) -> #VMEXIT\n", u16Port, u16Port));
     1038        IEM_SVM_UPDATE_NRIP(pVCpu);
    10451039        return iemSvmVmexit(pVCpu, pCtx, SVM_EXIT_IOIO, IoExitInfo.u, pCtx->rip + cbInstr);
    10461040    }
     
    10701064 * @param   fWrite      Whether this is an MSR write access, @c false implies an
    10711065 *                      MSR read.
     1066 * @param   cbInstr     The length of the MSR read/write instruction in bytes.
    10721067 */
    10731068IEM_STATIC VBOXSTRICTRC iemSvmHandleMsrIntercept(PVMCPU pVCpu, PCPUMCTX pCtx, uint32_t idMsr, bool fWrite)
     
    11001095        pbMsrpm += offMsrpm;
    11011096        if (ASMBitTest(pbMsrpm, uMsrpmBit))
     1097        {
     1098            IEM_SVM_UPDATE_NRIP(pVCpu);
    11021099            return iemSvmVmexit(pVCpu, pCtx, SVM_EXIT_MSR, uExitInfo1, 0 /* uExitInfo2 */);
     1100        }
    11031101    }
    11041102    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