VirtualBox

Ignore:
Timestamp:
Jun 14, 2018 9:28:31 PM (7 years ago)
Author:
vboxsync
Message:

EM,NEM,HM: Started on generic exit history, only hooked up to NEM/win. bugref:9044

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/NEMAllNativeTemplate-win.cpp.h

    r72551 r72555  
    19091909     * Emulate the memory access, either access handler or special memory.
    19101910     */
     1911    EMHistoryAddExit(pVCpu,
     1912                       pMsg->Header.InterceptAccessType == HV_INTERCEPT_ACCESS_WRITE
     1913                     ? EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_EM, EMEXITTYPE_MMIO_WRITE)
     1914                     : EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_EM, EMEXITTYPE_MMIO_READ),
     1915                     pMsg->Header.Rip + pMsg->Header.CsSegment.Base, ASMReadTSC());
    19111916    nemHCWinCopyStateFromX64Header(pVCpu, pCtx, &pMsg->Header);
    19121917    VBOXSTRICTRC rcStrict;
     
    19982003     * Emulate the memory access, either access handler or special memory.
    19992004     */
     2005    EMHistoryAddExit(pVCpu,
     2006                       pExit->MemoryAccess.AccessInfo.AccessType == WHvMemoryAccessWrite
     2007                     ? EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_EM, EMEXITTYPE_MMIO_WRITE)
     2008                     : EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_EM, EMEXITTYPE_MMIO_READ),
     2009                     pExit->VpContext.Rip + pExit->VpContext.Cs.Base, ASMReadTSC());
     2010
    20002011    nemR3WinCopyStateFromX64Header(pVCpu, pCtx, &pExit->VpContext);
    20012012    rc = nemHCWinCopyStateFromHyperV(pVM, pVCpu, pCtx, NEM_WIN_CPUMCTX_EXTRN_MASK_FOR_IEM | CPUMCTX_EXTRN_DS | CPUMCTX_EXTRN_ES);
     
    20522063         * Simple port I/O.
    20532064         */
     2065        EMHistoryAddExit(pVCpu,
     2066                           pMsg->Header.InterceptAccessType == HV_INTERCEPT_ACCESS_WRITE
     2067                         ? EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_EM, EMEXITTYPE_IO_PORT_WRITE)
     2068                         : EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_EM, EMEXITTYPE_IO_PORT_READ),
     2069                         pMsg->Header.Rip + pMsg->Header.CsSegment.Base, ASMReadTSC());
     2070
    20542071        static uint32_t const s_fAndMask[8] =
    20552072        {   UINT32_MAX, UINT32_C(0xff), UINT32_C(0xffff), UINT32_MAX,   UINT32_MAX, UINT32_MAX, UINT32_MAX, UINT32_MAX   };
     
    21252142         * the opcode bytes for possible evil prefixes.
    21262143         */
     2144        EMHistoryAddExit(pVCpu,
     2145                           pMsg->Header.InterceptAccessType == HV_INTERCEPT_ACCESS_WRITE
     2146                         ? EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_EM, EMEXITTYPE_IO_PORT_STR_WRITE)
     2147                         : EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_EM, EMEXITTYPE_IO_PORT_STR_READ),
     2148                         pMsg->Header.Rip + pMsg->Header.CsSegment.Base, ASMReadTSC());
     2149
    21272150        nemHCWinCopyStateFromX64Header(pVCpu, pCtx, &pMsg->Header);
    21282151        pCtx->fExtrn &= ~(  CPUMCTX_EXTRN_RAX | CPUMCTX_EXTRN_RCX | CPUMCTX_EXTRN_RDI | CPUMCTX_EXTRN_RSI
     
    21962219         * Simple port I/O.
    21972220         */
     2221        EMHistoryAddExit(pVCpu,
     2222                           pExit->MemoryAccess.AccessInfo.AccessType == WHvMemoryAccessWrite
     2223                         ? EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_EM, EMEXITTYPE_IO_PORT_WRITE)
     2224                         : EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_EM, EMEXITTYPE_IO_PORT_READ),
     2225                         pExit->VpContext.Rip + pExit->VpContext.Cs.Base, ASMReadTSC());
     2226
    21982227        static uint32_t const s_fAndMask[8] =
    21992228        {   UINT32_MAX, UINT32_C(0xff), UINT32_C(0xffff), UINT32_MAX,   UINT32_MAX, UINT32_MAX, UINT32_MAX, UINT32_MAX   };
     
    22492278         * the opcode bytes for possible evil prefixes.
    22502279         */
     2280        EMHistoryAddExit(pVCpu,
     2281                           pExit->MemoryAccess.AccessInfo.AccessType == WHvMemoryAccessWrite
     2282                         ? EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_EM, EMEXITTYPE_IO_PORT_STR_WRITE)
     2283                         : EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_EM, EMEXITTYPE_IO_PORT_STR_READ),
     2284                         pExit->VpContext.Rip + pExit->VpContext.Cs.Base, ASMReadTSC());
     2285
    22512286        nemR3WinCopyStateFromX64Header(pVCpu, pCtx, &pExit->VpContext);
    22522287        pCtx->fExtrn &= ~(  CPUMCTX_EXTRN_RAX | CPUMCTX_EXTRN_RCX | CPUMCTX_EXTRN_RDI | CPUMCTX_EXTRN_RSI
     
    23202355     * Just copy the state we've got and handle it in the loop for now.
    23212356     */
     2357    EMHistoryAddExit(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_NEM, NEMEXITTYPE_INTTERRUPT_WINDOW),
     2358                     pMsg->Header.Rip + pMsg->Header.CsSegment.Base, ASMReadTSC());
     2359
    23222360    nemHCWinCopyStateFromX64Header(pVCpu, pCtx, &pMsg->Header);
    23232361    Log4(("IntWinExit/%u: %04x:%08RX64/%s: %u IF=%d InterruptShadow=%d\n",
     
    23542392     * Just copy the state we've got and handle it in the loop for now.
    23552393     */
     2394    EMHistoryAddExit(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_NEM, NEMEXITTYPE_INTTERRUPT_WINDOW),
     2395                     pExit->VpContext.Rip + pExit->VpContext.Cs.Base, ASMReadTSC());
     2396
    23562397    nemR3WinCopyStateFromX64Header(pVCpu, pCtx, &pExit->VpContext);
    23572398    Log4(("IntWinExit/%u: %04x:%08RX64/%s: %u IF=%d InterruptShadow=%d\n",
     
    23742415 * @param   pMsg            The message.
    23752416 * @param   pCtx            The register context.
     2417 * @sa      nemR3WinHandleExitCpuId
    23762418 */
    23772419NEM_TMPL_STATIC VBOXSTRICTRC nemHCWinHandleMessageCpuId(PVMCPU pVCpu, HV_X64_CPUID_INTERCEPT_MESSAGE const *pMsg, PCPUMCTX pCtx)
     
    23852427     *       function and make everyone use it.
    23862428     */
     2429    EMHistoryAddExit(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_EM, EMEXITTYPE_CPUID),
     2430                     pMsg->Header.Rip + pMsg->Header.CsSegment.Base, ASMReadTSC());
     2431
    23872432    /** @todo Combine implementations into IEMExecDecodedCpuId as this will
    23882433     *        only get weirder with nested VT-x and AMD-V support. */
     
    24192464 * @param   pExit           The VM exit information to handle.
    24202465 * @param   pCtx            The register context.
    2421  * @sa      nemHCWinHandleMessageInterruptWindow
     2466 * @sa      nemHCWinHandleMessageCpuId
    24222467 */
    24232468NEM_TMPL_STATIC VBOXSTRICTRC
     
    24322477     *       function and make everyone use it.
    24332478     */
     2479    EMHistoryAddExit(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_EM, EMEXITTYPE_CPUID),
     2480                     pExit->VpContext.Rip + pExit->VpContext.Cs.Base, ASMReadTSC());
     2481
    24342482    /** @todo Combine implementations into IEMExecDecodedCpuId as this will
    24352483     *        only get weirder with nested VT-x and AMD-V support. */
     
    24872535    if (pMsg->Header.ExecutionState.Cpl == 0)
    24882536    {
     2537        EMHistoryAddExit(pVCpu,
     2538                           pMsg->Header.InterceptAccessType == HV_INTERCEPT_ACCESS_WRITE
     2539                         ? EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_EM, EMEXITTYPE_MSR_WRITE)
     2540                         : EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_EM, EMEXITTYPE_MSR_READ),
     2541                         pMsg->Header.Rip + pMsg->Header.CsSegment.Base, ASMReadTSC());
     2542
    24892543        /*
    24902544         * Get all the MSR state.  Since we're getting EFER, we also need to
     
    26132667         * get CR0, CR4 and CR3.
    26142668         */
     2669        EMHistoryAddExit(pVCpu,
     2670                           pExit->MsrAccess.AccessInfo.IsWrite
     2671                         ? EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_EM, EMEXITTYPE_MSR_WRITE)
     2672                         : EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_EM, EMEXITTYPE_MSR_READ),
     2673                         pExit->VpContext.Rip + pExit->VpContext.Cs.Base, ASMReadTSC());
     2674
    26152675        nemR3WinCopyStateFromX64Header(pVCpu, pCtx, &pExit->VpContext);
    26162676        rcStrict = nemHCWinImportStateIfNeededStrict(pVCpu, NULL, pCtx,
     
    28732933        case X86_XCPT_UD:
    28742934            STAM_REL_COUNTER_INC(&pVCpu->nem.s.StatExitExceptionUd);
     2935            EMHistoryAddExit(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_NEM, NEMEXITTYPE_XCPT_UD),
     2936                             pMsg->Header.Rip + pMsg->Header.CsSegment.Base, ASMReadTSC());
     2937
    28752938            if (nemHcWinIsInterestingUndefinedOpcode(pMsg->InstructionByteCount, pMsg->InstructionBytes,
    28762939                                                     pMsg->Header.ExecutionState.EferLma && pMsg->Header.CsSegment.Long ))
     
    28932956        case X86_XCPT_DB:
    28942957            STAM_REL_COUNTER_INC(&pVCpu->nem.s.StatExitExceptionDb);
     2958            EMHistoryAddExit(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_NEM, NEMEXITTYPE_XCPT_DB),
     2959                             pMsg->Header.Rip + pMsg->Header.CsSegment.Base, ASMReadTSC());
    28952960            Log4(("XcptExit/%u: %04x:%08RX64/%s: #DB - TODO\n",
    28962961                  pVCpu->idCpu, pMsg->Header.CsSegment.Selector, pMsg->Header.Rip, nemHCWinExecStateToLogStr(&pMsg->Header) ));
     
    28992964        case X86_XCPT_BP:
    29002965            STAM_REL_COUNTER_INC(&pVCpu->nem.s.StatExitExceptionBp);
     2966            EMHistoryAddExit(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_NEM, NEMEXITTYPE_XCPT_BP),
     2967                             pMsg->Header.Rip + pMsg->Header.CsSegment.Base, ASMReadTSC());
    29012968            Log4(("XcptExit/%u: %04x:%08RX64/%s: #BP - TODO - %u\n", pVCpu->idCpu, pMsg->Header.CsSegment.Selector,
    29022969                  pMsg->Header.Rip, nemHCWinExecStateToLogStr(&pMsg->Header), pMsg->Header.InstructionLength));
     
    29713038        case X86_XCPT_UD:
    29723039            STAM_REL_COUNTER_INC(&pVCpu->nem.s.StatExitExceptionUd);
     3040            EMHistoryAddExit(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_NEM, NEMEXITTYPE_XCPT_UD),
     3041                             pExit->VpContext.Rip + pExit->VpContext.Cs.Base, ASMReadTSC());
    29733042            if (nemHcWinIsInterestingUndefinedOpcode(pExit->VpException.InstructionByteCount, pExit->VpException.InstructionBytes,
    29743043                                                     pExit->VpContext.ExecutionState.EferLma && pExit->VpContext.Cs.Long ))
     
    29943063        case X86_XCPT_DB:
    29953064            STAM_REL_COUNTER_INC(&pVCpu->nem.s.StatExitExceptionDb);
     3065            EMHistoryAddExit(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_NEM, NEMEXITTYPE_XCPT_DB),
     3066                             pExit->VpContext.Rip + pExit->VpContext.Cs.Base, ASMReadTSC());
    29963067            Log4(("XcptExit/%u: %04x:%08RX64/%s: #DB - TODO\n",
    29973068                  pVCpu->idCpu, pExit->VpContext.Cs.Selector, pExit->VpContext.Rip, nemR3WinExecStateToLogStr(&pExit->VpContext) ));
     
    30003071        case X86_XCPT_BP:
    30013072            STAM_REL_COUNTER_INC(&pVCpu->nem.s.StatExitExceptionBp);
     3073            EMHistoryAddExit(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_NEM, NEMEXITTYPE_XCPT_BP),
     3074                             pExit->VpContext.Rip + pExit->VpContext.Cs.Base, ASMReadTSC());
    30023075            Log4(("XcptExit/%u: %04x:%08RX64/%s: #BP - TODO - %u\n", pVCpu->idCpu, pExit->VpContext.Cs.Selector,
    30033076                  pExit->VpContext.Rip, nemR3WinExecStateToLogStr(&pExit->VpContext), pExit->VpContext.InstructionLength));
     
    30573130     * Let IEM decide whether this is really it.
    30583131     */
     3132    EMHistoryAddExit(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_NEM, NEMEXITTYPE_UNRECOVERABLE_EXCEPTION),
     3133                     pMsgHdr->Rip + pMsgHdr->CsSegment.Base, ASMReadTSC());
    30593134    nemHCWinCopyStateFromX64Header(pVCpu, pCtx, pMsgHdr);
    30603135    VBOXSTRICTRC rcStrict = nemHCWinImportStateIfNeededStrict(pVCpu, pGVCpu, pCtx,
     
    31123187     * Let IEM decide whether this is really it.
    31133188     */
     3189    EMHistoryAddExit(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_NEM, NEMEXITTYPE_UNRECOVERABLE_EXCEPTION),
     3190                     pExit->VpContext.Rip + pExit->VpContext.Cs.Base, ASMReadTSC());
    31143191    nemR3WinCopyStateFromX64Header(pVCpu, pCtx, &pExit->VpContext);
    31153192    VBOXSTRICTRC rcStrict = nemHCWinImportStateIfNeededStrict(pVCpu, NULL, pCtx,
     
    31813258            case HvMessageTypeX64Halt:
    31823259                STAM_REL_COUNTER_INC(&pVCpu->nem.s.StatExitHalt);
     3260                EMHistoryAddExit(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_NEM, NEMEXITTYPE_HALT),
     3261                                 pMsg->X64InterceptHeader.Rip + pMsg->X64InterceptHeader.CsSegment.Base, ASMReadTSC());
    31833262                Log4(("HaltExit\n"));
    31843263                return VINF_EM_HALT;
     
    32633342        case WHvRunVpExitReasonX64Halt:
    32643343            STAM_REL_COUNTER_INC(&pVCpu->nem.s.StatExitHalt);
     3344            EMHistoryAddExit(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_NEM, NEMEXITTYPE_HALT),
     3345                             pExit->VpContext.Rip + pExit->VpContext.Cs.Base, ASMReadTSC());
    32653346            Log4(("HaltExit\n"));
    32663347            return VINF_EM_HALT;
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