VirtualBox

Changeset 97200 in vbox


Ignore:
Timestamp:
Oct 18, 2022 11:38:42 AM (2 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
154175
Message:

VMM/IEM,EM: More CPUMCTXCORE elimination and trimming of interpret functions.

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vmm/em.h

    r97197 r97200  
    272272                                                      PDISCPUSTATE pDISState, unsigned *pcbInstr);
    273273VMM_INT_DECL(VBOXSTRICTRC)      EMInterpretInstruction(PVMCPUCC pVCpu);
    274 VMM_INT_DECL(VBOXSTRICTRC)      EMInterpretInstructionEx(PVMCPUCC pVCpu, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, uint32_t *pcbWritten);
    275 VMM_INT_DECL(VBOXSTRICTRC)      EMInterpretInstructionDisasState(PVMCPUCC pVCpu, PDISCPUSTATE pDis, PCPUMCTXCORE pCoreCtx,
    276                                                                  RTGCPTR pvFault, EMCODETYPE enmCodeType);
     274VMM_INT_DECL(VBOXSTRICTRC)      EMInterpretInstructionDisasState(PVMCPUCC pVCpu, PDISCPUSTATE pDis, uint64_t rip);
    277275VMM_INT_DECL(int)               EMInterpretRdpmc(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame);
    278276VMM_INT_DECL(int)               EMInterpretDRxWrite(PVMCC pVM, PVMCPUCC pVCpu, PCPUMCTXCORE pRegFrame, uint32_t DestRegDrx, uint32_t SrcRegGen);
  • trunk/include/VBox/vmm/iem.h

    r97197 r97200  
    289289
    290290VMMDECL(VBOXSTRICTRC)       IEMExecOne(PVMCPUCC pVCpu);
    291 VMMDECL(VBOXSTRICTRC)       IEMExecOneEx(PVMCPUCC pVCpu, PCPUMCTXCORE pCtxCore, uint32_t *pcbWritten);
    292 VMMDECL(VBOXSTRICTRC)       IEMExecOneWithPrefetchedByPC(PVMCPUCC pVCpu, PCPUMCTXCORE pCtxCore, uint64_t OpcodeBytesPC,
     291VMMDECL(VBOXSTRICTRC)       IEMExecOneEx(PVMCPUCC pVCpu, uint32_t *pcbWritten);
     292VMMDECL(VBOXSTRICTRC)       IEMExecOneWithPrefetchedByPC(PVMCPUCC pVCpu, uint64_t OpcodeBytesPC,
    293293                                                         const void *pvOpcodeBytes, size_t cbOpcodeBytes);
    294294VMMDECL(VBOXSTRICTRC)       IEMExecOneBypassEx(PVMCPUCC pVCpu, uint32_t *pcbWritten);
    295 VMMDECL(VBOXSTRICTRC)       IEMExecOneBypassWithPrefetchedByPC(PVMCPUCC pVCpu, PCPUMCTXCORE pCtxCore, uint64_t OpcodeBytesPC,
     295VMMDECL(VBOXSTRICTRC)       IEMExecOneBypassWithPrefetchedByPC(PVMCPUCC pVCpu, uint64_t OpcodeBytesPC,
    296296                                                               const void *pvOpcodeBytes, size_t cbOpcodeBytes);
    297 VMMDECL(VBOXSTRICTRC)       IEMExecOneBypassWithPrefetchedByPCWritten(PVMCPUCC pVCpu, PCPUMCTXCORE pCtxCore, uint64_t OpcodeBytesPC,
    298                                                                       const void *pvOpcodeBytes, size_t cbOpcodeBytes,
    299                                                                       uint32_t *pcbWritten);
    300297VMMDECL(VBOXSTRICTRC)       IEMExecOneIgnoreLock(PVMCPUCC pVCpu);
    301298VMMDECL(VBOXSTRICTRC)       IEMExecLots(PVMCPUCC pVCpu, uint32_t cMaxInstructions, uint32_t cPollRate, uint32_t *pcInstructions);
  • trunk/src/VBox/VMM/VMMAll/DBGFAllBp.cpp

    r97196 r97200  
    194194                /* Replace the int3 with the original instruction byte. */
    195195                abInstr[0] = pBp->Pub.u.Int3.bOrg;
    196                 rcStrict = IEMExecOneWithPrefetchedByPC(pVCpu, CPUMCTX2CORE(&pVCpu->cpum.GstCtx), GCPtrInstr, &abInstr[0], sizeof(abInstr));
     196                rcStrict = IEMExecOneWithPrefetchedByPC(pVCpu, GCPtrInstr, &abInstr[0], sizeof(abInstr));
    197197                if (   rcStrict == VINF_SUCCESS
    198198                    && DBGF_BP_PUB_IS_EXEC_AFTER(&pBp->Pub))
  • trunk/src/VBox/VMM/VMMAll/EMAll.cpp

    r97197 r97200  
    993993 * @param   pDis        The disassembler cpu state for the instruction to be
    994994 *                      interpreted.
    995  * @param   pRegFrame   The register frame. IP/EIP/RIP *IS* changed!
    996  * @param   pvFault     The fault address (CR2).
    997  * @param   enmCodeType Code type (user/supervisor)
     995 * @param   rip         The instruction pointer value.
    998996 *
    999997 * @remark  Invalid opcode exceptions have a higher priority than GP (see Intel
     
    10041002 *          Make sure this can't happen!! (will add some assertions/checks later)
    10051003 */
    1006 VMM_INT_DECL(VBOXSTRICTRC) EMInterpretInstructionDisasState(PVMCPUCC pVCpu, PDISCPUSTATE pDis, PCPUMCTXCORE pRegFrame,
    1007                                                             RTGCPTR pvFault, EMCODETYPE enmCodeType)
    1008 {
    1009     LogFlow(("EMInterpretInstructionDisasState %RGv fault %RGv\n", (RTGCPTR)pRegFrame->rip, pvFault));
    1010     Assert(pRegFrame == CPUMGetGuestCtxCore(pVCpu));
    1011     NOREF(pDis); NOREF(pvFault); NOREF(enmCodeType);
    1012 
    1013     VBOXSTRICTRC rc = IEMExecOneBypassWithPrefetchedByPC(pVCpu, pRegFrame, pRegFrame->rip, pDis->abInstr, pDis->cbCachedInstr);
     1004VMM_INT_DECL(VBOXSTRICTRC) EMInterpretInstructionDisasState(PVMCPUCC pVCpu, PDISCPUSTATE pDis, uint64_t rip)
     1005{
     1006    LogFlow(("EMInterpretInstructionDisasState %RGv\n", (RTGCPTR)rip));
     1007
     1008    VBOXSTRICTRC rc = IEMExecOneBypassWithPrefetchedByPC(pVCpu, rip, pDis->abInstr, pDis->cbCachedInstr);
    10141009    if (RT_UNLIKELY(   rc == VERR_IEM_ASPECT_NOT_IMPLEMENTED
    10151010                    || rc == VERR_IEM_INSTR_NOT_IMPLEMENTED))
  • trunk/src/VBox/VMM/VMMAll/IEMAll.cpp

    r97197 r97200  
    97979797
    97989798
    9799 VMMDECL(VBOXSTRICTRC) IEMExecOneEx(PVMCPUCC pVCpu, PCPUMCTXCORE pCtxCore, uint32_t *pcbWritten)
    9800 {
    9801     AssertReturn(CPUMCTX2CORE(IEM_GET_CTX(pVCpu)) == pCtxCore, VERR_IEM_IPE_3);
    9802 
     9799VMMDECL(VBOXSTRICTRC) IEMExecOneEx(PVMCPUCC pVCpu, uint32_t *pcbWritten)
     9800{
    98039801    uint32_t const cbOldWritten = pVCpu->iem.s.cbWritten;
    98049802    VBOXSTRICTRC rcStrict = iemInitDecoderAndPrefetchOpcodes(pVCpu, false, false);
     
    98169814
    98179815
    9818 VMMDECL(VBOXSTRICTRC) IEMExecOneWithPrefetchedByPC(PVMCPUCC pVCpu, PCPUMCTXCORE pCtxCore, uint64_t OpcodeBytesPC,
     9816VMMDECL(VBOXSTRICTRC) IEMExecOneWithPrefetchedByPC(PVMCPUCC pVCpu, uint64_t OpcodeBytesPC,
    98199817                                                   const void *pvOpcodeBytes, size_t cbOpcodeBytes)
    98209818{
    9821     AssertReturn(CPUMCTX2CORE(IEM_GET_CTX(pVCpu)) == pCtxCore, VERR_IEM_IPE_3);
    9822 
    98239819    VBOXSTRICTRC rcStrict;
    98249820    if (   cbOpcodeBytes
     
    98669862
    98679863
    9868 VMMDECL(VBOXSTRICTRC) IEMExecOneBypassWithPrefetchedByPC(PVMCPUCC pVCpu, PCPUMCTXCORE pCtxCore, uint64_t OpcodeBytesPC,
     9864VMMDECL(VBOXSTRICTRC) IEMExecOneBypassWithPrefetchedByPC(PVMCPUCC pVCpu, uint64_t OpcodeBytesPC,
    98699865                                                         const void *pvOpcodeBytes, size_t cbOpcodeBytes)
    98709866{
    9871     AssertReturn(CPUMCTX2CORE(IEM_GET_CTX(pVCpu)) == pCtxCore, VERR_IEM_IPE_3);
    9872 
    98739867    VBOXSTRICTRC rcStrict;
    98749868    if (   cbOpcodeBytes
     
    98929886    if (rcStrict == VINF_SUCCESS)
    98939887        rcStrict = iemExecOneInner(pVCpu, false, "IEMExecOneBypassWithPrefetchedByPC");
    9894     else if (pVCpu->iem.s.cActiveMappings > 0)
    9895         iemMemRollback(pVCpu);
    9896 
    9897     return rcStrict;
    9898 }
    9899 
    9900 
    9901 /**
    9902  * For debugging DISGetParamSize, may come in handy.
    9903  *
    9904  * @returns Strict VBox status code.
    9905  * @param   pVCpu           The cross context virtual CPU structure of the
    9906  *                          calling EMT.
    9907  * @param   pCtxCore        The context core structure.
    9908  * @param   OpcodeBytesPC   The PC of the opcode bytes.
    9909  * @param   pvOpcodeBytes   Prefeched opcode bytes.
    9910  * @param   cbOpcodeBytes   Number of prefetched bytes.
    9911  * @param   pcbWritten      Where to return the number of bytes written.
    9912  *                          Optional.
    9913  */
    9914 VMMDECL(VBOXSTRICTRC) IEMExecOneBypassWithPrefetchedByPCWritten(PVMCPUCC pVCpu, PCPUMCTXCORE pCtxCore, uint64_t OpcodeBytesPC,
    9915                                                                 const void *pvOpcodeBytes, size_t cbOpcodeBytes,
    9916                                                                 uint32_t *pcbWritten)
    9917 {
    9918     AssertReturn(CPUMCTX2CORE(IEM_GET_CTX(pVCpu)) == pCtxCore, VERR_IEM_IPE_3);
    9919 
    9920     uint32_t const cbOldWritten = pVCpu->iem.s.cbWritten;
    9921     VBOXSTRICTRC rcStrict;
    9922     if (   cbOpcodeBytes
    9923         && pVCpu->cpum.GstCtx.rip == OpcodeBytesPC)
    9924     {
    9925         iemInitDecoder(pVCpu, true, false);
    9926 #ifdef IEM_WITH_CODE_TLB
    9927         pVCpu->iem.s.uInstrBufPc      = OpcodeBytesPC;
    9928         pVCpu->iem.s.pbInstrBuf       = (uint8_t const *)pvOpcodeBytes;
    9929         pVCpu->iem.s.cbInstrBufTotal  = (uint16_t)RT_MIN(X86_PAGE_SIZE, cbOpcodeBytes);
    9930         pVCpu->iem.s.offCurInstrStart = 0;
    9931         pVCpu->iem.s.offInstrNextByte = 0;
    9932 #else
    9933         pVCpu->iem.s.cbOpcode = (uint8_t)RT_MIN(cbOpcodeBytes, sizeof(pVCpu->iem.s.abOpcode));
    9934         memcpy(pVCpu->iem.s.abOpcode, pvOpcodeBytes, pVCpu->iem.s.cbOpcode);
    9935 #endif
    9936         rcStrict = VINF_SUCCESS;
    9937     }
    9938     else
    9939         rcStrict = iemInitDecoderAndPrefetchOpcodes(pVCpu, true, false);
    9940     if (rcStrict == VINF_SUCCESS)
    9941     {
    9942         rcStrict = iemExecOneInner(pVCpu, false, "IEMExecOneBypassWithPrefetchedByPCWritten");
    9943         if (pcbWritten)
    9944             *pcbWritten = pVCpu->iem.s.cbWritten - cbOldWritten;
    9945     }
    99469888    else if (pVCpu->iem.s.cActiveMappings > 0)
    99479889        iemMemRollback(pVCpu);
  • trunk/src/VBox/VMM/VMMAll/NEMAllNativeTemplate-win.cpp.h

    r97178 r97200  
    15441544        //    Log4(("InstructionByteCount=%#x %.16Rhxs\n", pMsg->InstructionByteCount, pMsg->InstructionBytes));
    15451545        if (pExit->MemoryAccess.InstructionByteCount > 0)
    1546             rcStrict = IEMExecOneWithPrefetchedByPC(pVCpu, CPUMCTX2CORE(&pVCpu->cpum.GstCtx), pExit->VpContext.Rip,
    1547                                                     pExit->MemoryAccess.InstructionBytes, pExit->MemoryAccess.InstructionByteCount);
     1546            rcStrict = IEMExecOneWithPrefetchedByPC(pVCpu, pExit->VpContext.Rip, pExit->MemoryAccess.InstructionBytes, pExit->MemoryAccess.InstructionByteCount);
    15481547        else
    15491548            rcStrict = IEMExecOne(pVCpu);
     
    21742173                                                     pExit->VpContext.ExecutionState.EferLma && pExit->VpContext.Cs.Long ))
    21752174            {
    2176                 rcStrict = IEMExecOneWithPrefetchedByPC(pVCpu, CPUMCTX2CORE(&pVCpu->cpum.GstCtx), pExit->VpContext.Rip,
     2175                rcStrict = IEMExecOneWithPrefetchedByPC(pVCpu, pExit->VpContext.Rip,
    21772176                                                        pExit->VpException.InstructionBytes,
    21782177                                                        pExit->VpException.InstructionByteCount);
     
    22032202            {
    22042203#if 1 /** @todo Need to emulate instruction or we get a triple fault when trying to inject the \#GP... */
    2205                 rcStrict = IEMExecOneWithPrefetchedByPC(pVCpu, CPUMCTX2CORE(&pVCpu->cpum.GstCtx), pExit->VpContext.Rip,
     2204                rcStrict = IEMExecOneWithPrefetchedByPC(pVCpu, pExit->VpContext.Rip,
    22062205                                                        pExit->VpException.InstructionBytes,
    22072206                                                        pExit->VpException.InstructionByteCount);
  • trunk/src/VBox/VMM/VMMAll/PGMAllPool.cpp

    r97199 r97200  
    901901     */
    902902    int rc = VINF_SUCCESS;
    903     VBOXSTRICTRC rc2 = EMInterpretInstructionDisasState(pVCpu, pDis, CPUMCTX2CORE(pCtx), pvFault, EMCODETYPE_ALL);
     903    VBOXSTRICTRC rc2 = EMInterpretInstructionDisasState(pVCpu, pDis, pCtx->rip);
    904904    if (rc2 == VINF_SUCCESS)
    905905    { /* do nothing */ }
     
    10361036     * Interpret the instruction.
    10371037     */
    1038     VBOXSTRICTRC rc = EMInterpretInstructionDisasState(pVCpu, pDis, CPUMCTX2CORE(pCtx), pvFault, EMCODETYPE_ALL);
     1038    VBOXSTRICTRC rc = EMInterpretInstructionDisasState(pVCpu, pDis, pCtx->rip);
    10391039    if (RT_SUCCESS(rc))
    10401040        AssertMsg(rc == VINF_SUCCESS, ("%Rrc\n", VBOXSTRICTRC_VAL(rc))); /* ASSUMES no complicated stuff here. */
  • trunk/src/VBox/VMM/VMMR0/HMSVMR0.cpp

    r97197 r97200  
    84638463                                                | CPUMCTX_EXTRN_SREG_MASK /* without ES+DS+GS the app will #GP later - go figure */);
    84648464                Log6(("hmR0SvmExitXcptUD: sysenter/sysexit: %.*Rhxs at %#llx CPL=%u\n", cbInstr, abInstr, GCPtrInstr, uCpl));
    8465                 rcStrict = IEMExecOneWithPrefetchedByPC(pVCpu, CPUMCTX2CORE(&pVCpu->cpum.GstCtx), GCPtrInstr, abInstr, cbInstr);
     8465                rcStrict = IEMExecOneWithPrefetchedByPC(pVCpu, GCPtrInstr, abInstr, cbInstr);
    84668466                Log6(("hmR0SvmExitXcptUD: sysenter/sysexit: rcStrict=%Rrc %04x:%08RX64 %08RX64 %04x:%08RX64\n",
    84678467                     VBOXSTRICTRC_VAL(rcStrict), pVCpu->cpum.GstCtx.cs.Sel, pVCpu->cpum.GstCtx.rip, pVCpu->cpum.GstCtx.rflags.u,
  • trunk/src/VBox/VMM/VMMR3/DBGFR3Bp.cpp

    r96407 r97200  
    19871987                    /* Replace the int3 with the original instruction byte. */
    19881988                    abInstr[0] = pBp->Pub.u.Int3.bOrg;
    1989                     rcStrict = IEMExecOneWithPrefetchedByPC(pVCpu, CPUMCTX2CORE(&pVCpu->cpum.GstCtx), GCPtrInstr,
    1990                                                             &abInstr[0], sizeof(abInstr));
     1989                    rcStrict = IEMExecOneWithPrefetchedByPC(pVCpu, GCPtrInstr, &abInstr[0], sizeof(abInstr));
    19911990                    if (   rcStrict == VINF_SUCCESS
    19921991                        && DBGF_BP_PUB_IS_EXEC_AFTER(&pBp->Pub))
Note: See TracChangeset for help on using the changeset viewer.

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