VirtualBox

儲存庫 vbox 的更動 19015


忽略:
時間撮記:
2009-4-20 上午07:54:29 (16 年 以前)
作者:
vboxsync
訊息:

Split up TRPM. (guest SMP)

位置:
trunk
檔案:
修改 26 筆資料

圖例:

未更動
新增
刪除
  • trunk/include/VBox/trpm.h

    r18927 r19015  
    7474#define TRPM_INVALID_HANDLER        0
    7575
    76 VMMDECL(int)        TRPMQueryTrap(PVM pVM, uint8_t *pu8TrapNo, PTRPMEVENT pEnmType);
    77 VMMDECL(uint8_t)    TRPMGetTrapNo(PVM pVM);
    78 VMMDECL(RTGCUINT)   TRPMGetErrorCode(PVM pVM);
    79 VMMDECL(RTGCUINTPTR) TRPMGetFaultAddress(PVM pVM);
    80 VMMDECL(int)        TRPMResetTrap(PVM pVM);
    81 VMMDECL(int)        TRPMAssertTrap(PVM pVM, uint8_t u8TrapNo, TRPMEVENT enmType);
    82 VMMDECL(void)       TRPMSetErrorCode(PVM pVM, RTGCUINT uErrorCode);
    83 VMMDECL(void)       TRPMSetFaultAddress(PVM pVM, RTGCUINTPTR uCR2);
    84 VMMDECL(bool)       TRPMIsSoftwareInterrupt(PVM pVM);
    85 VMMDECL(bool)       TRPMHasTrap(PVM pVM);
    86 VMMDECL(int)        TRPMQueryTrapAll(PVM pVM, uint8_t *pu8TrapNo, PTRPMEVENT pEnmType, PRTGCUINT puErrorCode, PRTGCUINTPTR puCR2);
    87 VMMDECL(void)       TRPMSaveTrap(PVM pVM);
    88 VMMDECL(void)       TRPMRestoreTrap(PVM pVM);
    89 VMMDECL(int)        TRPMForwardTrap(PVM pVM, PCPUMCTXCORE pRegFrame, uint32_t iGate, uint32_t opsize, TRPMERRORCODE enmError, TRPMEVENT enmType, int32_t iOrgTrap);
    90 VMMDECL(int)        TRPMRaiseXcpt(PVM pVM, PCPUMCTXCORE pCtxCore, X86XCPT enmXcpt);
    91 VMMDECL(int)        TRPMRaiseXcptErr(PVM pVM, PCPUMCTXCORE pCtxCore, X86XCPT enmXcpt, uint32_t uErr);
    92 VMMDECL(int)        TRPMRaiseXcptErrCR2(PVM pVM, PCPUMCTXCORE pCtxCore, X86XCPT enmXcpt, uint32_t uErr, RTGCUINTPTR uCR2);
     76VMMDECL(int)        TRPMQueryTrap(PVMCPU pVCpu, uint8_t *pu8TrapNo, PTRPMEVENT pEnmType);
     77VMMDECL(uint8_t)    TRPMGetTrapNo(PVMCPU pVCpu);
     78VMMDECL(RTGCUINT)   TRPMGetErrorCode(PVMCPU pVCpu);
     79VMMDECL(RTGCUINTPTR) TRPMGetFaultAddress(PVMCPU pVCpu);
     80VMMDECL(int)        TRPMResetTrap(PVMCPU pVCpu);
     81VMMDECL(int)        TRPMAssertTrap(PVMCPU pVCpu, uint8_t u8TrapNo, TRPMEVENT enmType);
     82VMMDECL(void)       TRPMSetErrorCode(PVMCPU pVCpu, RTGCUINT uErrorCode);
     83VMMDECL(void)       TRPMSetFaultAddress(PVMCPU pVCpu, RTGCUINTPTR uCR2);
     84VMMDECL(bool)       TRPMIsSoftwareInterrupt(PVMCPU pVCpu);
     85VMMDECL(bool)       TRPMHasTrap(PVMCPU pVCpu);
     86VMMDECL(int)        TRPMQueryTrapAll(PVMCPU pVCpu, uint8_t *pu8TrapNo, PTRPMEVENT pEnmType, PRTGCUINT puErrorCode, PRTGCUINTPTR puCR2);
     87VMMDECL(void)       TRPMSaveTrap(PVMCPU pVCpu);
     88VMMDECL(void)       TRPMRestoreTrap(PVMCPU pVCpu);
     89VMMDECL(int)        TRPMForwardTrap(PVMCPU pVCpu, PCPUMCTXCORE pRegFrame, uint32_t iGate, uint32_t opsize, TRPMERRORCODE enmError, TRPMEVENT enmType, int32_t iOrgTrap);
     90VMMDECL(int)        TRPMRaiseXcpt(PVMCPU pVCpu, PCPUMCTXCORE pCtxCore, X86XCPT enmXcpt);
     91VMMDECL(int)        TRPMRaiseXcptErr(PVMCPU pVCpu, PCPUMCTXCORE pCtxCore, X86XCPT enmXcpt, uint32_t uErr);
     92VMMDECL(int)        TRPMRaiseXcptErrCR2(PVMCPU pVCpu, PCPUMCTXCORE pCtxCore, X86XCPT enmXcpt, uint32_t uErr, RTGCUINTPTR uCR2);
    9393
    9494
  • trunk/include/VBox/vm.h

    r18927 r19015  
    150150        char                padding[2048];        /* multiple of 64 */
    151151    } em;
     152
     153    /** TRPM part. */
     154    union
     155    {
     156#ifdef ___TRPMInternal_h
     157        struct TRPMCPU      s;
     158#endif
     159        char                padding[64];        /* multiple of 64 */
     160    } trpm;
    152161
    153162    /** TM part. */
  • trunk/src/VBox/VMM/EM.cpp

    r19006 r19015  
    15521552    RTGCUINT        uErrorCode;
    15531553    RTGCUINTPTR     uCR2;
    1554     int rc = TRPMQueryTrapAll(pVM, &u8TrapNo, &enmType, &uErrorCode, &uCR2);
     1554    int rc = TRPMQueryTrapAll(pVCpu, &u8TrapNo, &enmType, &uErrorCode, &uCR2);
    15551555    if (RT_FAILURE(rc))
    15561556    {
     
    16091609                                   ? TRPM_TRAP_HAS_ERRORCODE
    16101610                                   : TRPM_TRAP_NO_ERRORCODE;
    1611             rc = TRPMForwardTrap(pVM, CPUMCTX2CORE(pCtx), u8TrapNo, uErrorCode, enmError, TRPM_TRAP, -1);
     1611            rc = TRPMForwardTrap(pVCpu, CPUMCTX2CORE(pCtx), u8TrapNo, uErrorCode, enmError, TRPM_TRAP, -1);
    16121612            if (rc == VINF_SUCCESS /* Don't use RT_SUCCESS */)
    16131613            {
    1614                 TRPMResetTrap(pVM);
     1614                TRPMResetTrap(pVCpu);
    16151615                return VINF_EM_RESCHEDULE_RAW;
    16161616            }
     
    16471647            if (u32ExtFeatures & X86_CPUID_FEATURE_ECX_MONITOR)
    16481648            {
    1649                 rc = TRPMResetTrap(pVM);
     1649                rc = TRPMResetTrap(pVCpu);
    16501650                AssertRC(rc);
    16511651
     
    16811681             * lazy approach really makes things worse.
    16821682             */
    1683             rc = TRPMResetTrap(pVM);
     1683            rc = TRPMResetTrap(pVCpu);
    16841684            AssertRC(rc);
    16851685            return emR3RawExecuteInstruction(pVM, pVCpu, "IO Guest Trap: ");
     
    18061806    else
    18071807    {
    1808         rc = TRPMQueryTrapAll(pVM, &u8TrapNo, &enmType, &uErrorCode, &uCR2);
     1808        rc = TRPMQueryTrapAll(pVCpu, &u8TrapNo, &enmType, &uErrorCode, &uCR2);
    18091809        if (RT_FAILURE(rc))
    18101810        {
     
    18131813        }
    18141814        /* Reset the trap as we'll execute the original instruction again. */
    1815         TRPMResetTrap(pVM);
     1815        TRPMResetTrap(pVCpu);
    18161816    }
    18171817
     
    23872387        case VINF_EM_RAW_INTERRUPT_PENDING:
    23882388        case VINF_EM_RAW_RING_SWITCH_INT:
    2389             Assert(TRPMHasTrap(pVM));
     2389            Assert(TRPMHasTrap(pVCpu));
    23902390            Assert(!PATMIsPatchGCAddr(pVM, (RTGCPTR)pCtx->eip));
    23912391
    2392             if (TRPMHasTrap(pVM))
     2392            if (TRPMHasTrap(pVCpu))
    23932393            {
    23942394                /* If the guest gate is marked unpatched, then we will check again if we can patch it. */
    2395                 uint8_t u8Interrupt = TRPMGetTrapNo(pVM);
     2395                uint8_t u8Interrupt = TRPMGetTrapNo(pVCpu);
    23962396                if (TRPMR3GetGuestTrapHandler(pVM, u8Interrupt) == TRPM_INVALID_HANDLER)
    23972397                {
     
    29652965         * Log important stuff before entering GC.
    29662966         */
    2967         if (TRPMHasTrap(pVM))
    2968             Log(("Pending hardware interrupt=0x%x cs:rip=%04X:%RGv\n", TRPMGetTrapNo(pVM), pCtx->cs, (RTGCPTR)pCtx->rip));
     2967        if (TRPMHasTrap(pVCpu))
     2968            Log(("Pending hardware interrupt=0x%x cs:rip=%04X:%RGv\n", TRPMGetTrapNo(pVCpu), pCtx->cs, (RTGCPTR)pCtx->rip));
    29692969
    29702970        uint32_t cpl = CPUMGetGuestCPL(pVCpu, CPUMCTX2CORE(pCtx));
     
    33873387        if (    !VM_FF_ISPENDING(pVM, VM_FF_INHIBIT_INTERRUPTS | VM_FF_PGM_NO_MEMORY)
    33883388            &&  (!rc || rc >= VINF_EM_RESCHEDULE_HWACC)
    3389             &&  !TRPMHasTrap(pVM) /* an interrupt could already be scheduled for dispatching in the recompiler. */
     3389            &&  !TRPMHasTrap(pVCpu) /* an interrupt could already be scheduled for dispatching in the recompiler. */
    33903390            &&  PATMAreInterruptsEnabled(pVM)
    33913391            &&  !HWACCMR3IsEventPending(pVM))
  • trunk/src/VBox/VMM/PDMLdr.cpp

    r18431 r19015  
    336336        else if (!strcmp(pszSymbol, "g_TRPM"))
    337337            *pValue = VM_RC_ADDR(pVM, &pVM->trpm);
     338        else if (!strcmp(pszSymbol, "g_TRPMCPU"))
     339            *pValue = VM_RC_ADDR(pVM, &pVM->aCpus[0].trpm);
    338340        else if (   !strncmp(pszSymbol, "VMM", 3)
    339341                 || !strcmp(pszSymbol, "g_Logger")
  • trunk/src/VBox/VMM/TRPM.cpp

    r18927 r19015  
    431431
    432432/** TRPM saved state version. */
    433 #define TRPM_SAVED_STATE_VERSION    8
     433#define TRPM_SAVED_STATE_VERSION        9
     434#define TRPM_SAVED_STATE_VERSION_UNI    8   /* SMP support bumped the version */
    434435
    435436
     
    464465     */
    465466    pVM->trpm.s.offVM              = RT_OFFSETOF(VM, trpm);
    466     pVM->trpm.s.uActiveVector      = ~0;
     467    pVM->trpm.s.offTRPMCPU         = RT_OFFSETOF(VM, aCpus[0].trpm) - RT_OFFSETOF(VM, trpm);
     468
     469    for (unsigned i=0;i<pVM->cCPUs;i++)
     470    {
     471        PVMCPU pVCpu = &pVM->aCpus[i];
     472
     473        pVCpu->trpm.s.offVM         = RT_OFFSETOF(VM, aCpus[i].trpm);
     474        pVCpu->trpm.s.uActiveVector = ~0;
     475    }
     476
    467477    pVM->trpm.s.GuestIdtr.pIdt     = RTRCPTR_MAX;
    468478    pVM->trpm.s.pvMonShwIdtRC            = RTRCPTR_MAX;
     
    731741     * Reinitialize other members calling the relocator to get things right.
    732742     */
    733     pVM->trpm.s.uActiveVector  = ~0;
     743    for (unsigned i=0;i<pVM->cCPUs;i++)
     744    {
     745        PVMCPU pVCpu = &pVM->aCpus[i];
     746        pVCpu->trpm.s.uActiveVector = ~0;
     747    }
    734748    memcpy(&pVM->trpm.s.aIdt[0], &g_aIdt[0], sizeof(pVM->trpm.s.aIdt));
    735749    memset(pVM->trpm.s.aGuestTrapHandler, 0, sizeof(pVM->trpm.s.aGuestTrapHandler));
     
    752766static DECLCALLBACK(int) trpmR3Save(PVM pVM, PSSMHANDLE pSSM)
    753767{
     768    PTRPM pTrpm = &pVM->trpm.s;
    754769    LogFlow(("trpmR3Save:\n"));
    755770
     
    757772     * Active and saved traps.
    758773     */
    759     PTRPM pTrpm = &pVM->trpm.s;
    760     SSMR3PutUInt(pSSM,      pTrpm->uActiveVector);
    761     SSMR3PutUInt(pSSM,      pTrpm->enmActiveType);
    762     SSMR3PutGCUInt(pSSM,    pTrpm->uActiveErrorCode);
    763     SSMR3PutGCUIntPtr(pSSM, pTrpm->uActiveCR2);
    764     SSMR3PutGCUInt(pSSM,    pTrpm->uSavedVector);
    765     SSMR3PutUInt(pSSM,      pTrpm->enmSavedType);
    766     SSMR3PutGCUInt(pSSM,    pTrpm->uSavedErrorCode);
    767     SSMR3PutGCUIntPtr(pSSM, pTrpm->uSavedCR2);
    768     SSMR3PutGCUInt(pSSM,    pTrpm->uPrevVector);
    769 #if 0  /** @todo Enable this (+ load change) on the next version change. */
     774    for (unsigned i=0;i<pVM->cCPUs;i++)
     775    {
     776        PTRPMCPU pTrpmCpu = &pVM->aCpus[i].trpm.s;
     777
     778        SSMR3PutUInt(pSSM,      pTrpmCpu->uActiveVector);
     779        SSMR3PutUInt(pSSM,      pTrpmCpu->enmActiveType);
     780        SSMR3PutGCUInt(pSSM,    pTrpmCpu->uActiveErrorCode);
     781        SSMR3PutGCUIntPtr(pSSM, pTrpmCpu->uActiveCR2);
     782        SSMR3PutGCUInt(pSSM,    pTrpmCpu->uSavedVector);
     783        SSMR3PutUInt(pSSM,      pTrpmCpu->enmSavedType);
     784        SSMR3PutGCUInt(pSSM,    pTrpmCpu->uSavedErrorCode);
     785        SSMR3PutGCUIntPtr(pSSM, pTrpmCpu->uSavedCR2);
     786        SSMR3PutGCUInt(pSSM,    pTrpmCpu->uPrevVector);
     787    }
    770788    SSMR3PutBool(pSSM,      pTrpm->fDisableMonitoring);
    771 #else
    772     SSMR3PutGCUInt(pSSM,    pTrpm->fDisableMonitoring);
    773 #endif
    774789    SSMR3PutUInt(pSSM,      VM_FF_ISSET(pVM, VM_FF_TRPM_SYNC_IDT));
    775790    SSMR3PutMem(pSSM,       &pTrpm->au32IdtPatched[0], sizeof(pTrpm->au32IdtPatched));
     
    808823     * Validate version.
    809824     */
    810     if (u32Version != TRPM_SAVED_STATE_VERSION)
     825    if (    u32Version != TRPM_SAVED_STATE_VERSION
     826        &&  u32Version != TRPM_SAVED_STATE_VERSION_UNI)
    811827    {
    812828        AssertMsgFailed(("trpmR3Load: Invalid version u32Version=%d!\n", u32Version));
     
    823839     */
    824840    PTRPM pTrpm = &pVM->trpm.s;
    825     SSMR3GetUInt(pSSM,      &pTrpm->uActiveVector);
    826     SSMR3GetUInt(pSSM,      (uint32_t *)&pTrpm->enmActiveType);
    827     SSMR3GetGCUInt(pSSM,    &pTrpm->uActiveErrorCode);
    828     SSMR3GetGCUIntPtr(pSSM, &pTrpm->uActiveCR2);
    829     SSMR3GetGCUInt(pSSM,    &pTrpm->uSavedVector);
    830     SSMR3GetUInt(pSSM,      (uint32_t *)&pTrpm->enmSavedType);
    831     SSMR3GetGCUInt(pSSM,    &pTrpm->uSavedErrorCode);
    832     SSMR3GetGCUIntPtr(pSSM, &pTrpm->uSavedCR2);
    833     SSMR3GetGCUInt(pSSM,    &pTrpm->uPrevVector);
    834 #if 0 /** @todo Enable this + the corresponding save code on the next version change. */
    835     SSMR3GetBool(pSSM,      &pTrpm->fDisableMonitoring);
    836 #else
    837     RTGCUINT fDisableMonitoring;
    838     SSMR3GetGCUInt(pSSM,    &fDisableMonitoring);
    839     pTrpm->fDisableMonitoring = !!fDisableMonitoring;
    840 #endif
     841
     842    if (u32Version == TRPM_SAVED_STATE_VERSION)
     843    {
     844        for (unsigned i=0;i<pVM->cCPUs;i++)
     845        {
     846            PTRPMCPU pTrpmCpu = &pVM->aCpus[i].trpm.s;
     847            SSMR3GetUInt(pSSM,      &pTrpmCpu->uActiveVector);
     848            SSMR3GetUInt(pSSM,      (uint32_t *)&pTrpmCpu->enmActiveType);
     849            SSMR3GetGCUInt(pSSM,    &pTrpmCpu->uActiveErrorCode);
     850            SSMR3GetGCUIntPtr(pSSM, &pTrpmCpu->uActiveCR2);
     851            SSMR3GetGCUInt(pSSM,    &pTrpmCpu->uSavedVector);
     852            SSMR3GetUInt(pSSM,      (uint32_t *)&pTrpmCpu->enmSavedType);
     853            SSMR3GetGCUInt(pSSM,    &pTrpmCpu->uSavedErrorCode);
     854            SSMR3GetGCUIntPtr(pSSM, &pTrpmCpu->uSavedCR2);
     855            SSMR3GetGCUInt(pSSM,    &pTrpmCpu->uPrevVector);
     856        }
     857
     858        SSMR3GetBool(pSSM,      &pVM->trpm.s.fDisableMonitoring);
     859    }
     860    else
     861    {
     862        PTRPMCPU pTrpmCpu = &pVM->aCpus[0].trpm.s;
     863        SSMR3GetUInt(pSSM,      &pTrpmCpu->uActiveVector);
     864        SSMR3GetUInt(pSSM,      (uint32_t *)&pTrpmCpu->enmActiveType);
     865        SSMR3GetGCUInt(pSSM,    &pTrpmCpu->uActiveErrorCode);
     866        SSMR3GetGCUIntPtr(pSSM, &pTrpmCpu->uActiveCR2);
     867        SSMR3GetGCUInt(pSSM,    &pTrpmCpu->uSavedVector);
     868        SSMR3GetUInt(pSSM,      (uint32_t *)&pTrpmCpu->enmSavedType);
     869        SSMR3GetGCUInt(pSSM,    &pTrpmCpu->uSavedErrorCode);
     870        SSMR3GetGCUIntPtr(pSSM, &pTrpmCpu->uSavedCR2);
     871        SSMR3GetGCUInt(pSSM,    &pTrpmCpu->uPrevVector);
     872
     873        RTGCUINT fDisableMonitoring;
     874        SSMR3GetGCUInt(pSSM,    &fDisableMonitoring);
     875        pTrpm->fDisableMonitoring = !!fDisableMonitoring;
     876    }
    841877
    842878    RTUINT fSyncIDT;
     
    14171453            if (HWACCMR3IsActive(pVM))
    14181454            {
    1419                 rc = TRPMAssertTrap(pVM, u8Interrupt, enmEvent);
     1455                rc = TRPMAssertTrap(pVCpu, u8Interrupt, enmEvent);
    14201456                AssertRC(rc);
    14211457                STAM_COUNTER_INC(&pVM->trpm.s.paStatForwardedIRQR3[u8Interrupt]);
     
    14361472                {
    14371473                    /* There's a handler -> let's execute it in raw mode */
    1438                     rc = TRPMForwardTrap(pVM, CPUMCTX2CORE(pCtx), u8Interrupt, 0, TRPM_TRAP_NO_ERRORCODE, enmEvent, -1);
     1474                    rc = TRPMForwardTrap(pVCpu, CPUMCTX2CORE(pCtx), u8Interrupt, 0, TRPM_TRAP_NO_ERRORCODE, enmEvent, -1);
    14391475                    if (rc == VINF_SUCCESS /* Don't use RT_SUCCESS */)
    14401476                    {
  • trunk/src/VBox/VMM/TRPMInternal.h

    r14515 r19015  
    7474#define TRPM2VM(pTRPM)          ( (PVM)((char*)pTRPM - pTRPM->offVM) )
    7575
     76/**
     77 * Converts a TRPMCPU pointer into a VM pointer.
     78 * @returns Pointer to the VM structure the TRPMCPU is part of.
     79 * @param   pTRPM   Pointer to TRPMCPU instance data.
     80 */
     81#define TRPMCPU2VM(pTrpmCpu)    ( (PVM)((char*)pTrpmCpu - pTrpmCpu->offVM) )
     82
     83/**
     84 * Converts a TRPM pointer into a TRPMCPU pointer.
     85 * @returns Pointer to the VM structure the TRPMCPU is part of.
     86 * @param   pTRPM   Pointer to TRPMCPU instance data.
     87 */
     88#define TRPM2TRPMCPU(pTrpmCpu)     ( (PTRPMCPU)((char*)pTrpmCpu + pTrpmCpu->offTRPMCPU) )
    7689
    7790/**
     
    8699     * See TRPM2VM(). */
    87100    RTINT                   offVM;
    88 
    89     /** Active Interrupt or trap vector number.
    90      * If not ~0U this indicates that we're currently processing
    91      * a interrupt, trap, fault, abort, whatever which have arrived
    92      * at that vector number.
    93      */
    94     RTUINT                  uActiveVector;
    95 
    96     /** Active trap type. */
    97     TRPMEVENT               enmActiveType;
    98 
    99     /** Errorcode for the active interrupt/trap. */
    100     RTGCUINT                uActiveErrorCode; /**< @todo don't use RTGCUINT */
    101 
    102     /** CR2 at the time of the active exception. */
    103     RTGCUINTPTR             uActiveCR2;
    104 
    105     /** Saved trap vector number. */
    106     RTGCUINT                uSavedVector; /**< @todo don't use RTGCUINT */
    107 
    108     /** Saved trap type. */
    109     TRPMEVENT               enmSavedType;
    110 
    111     /** Saved errorcode. */
    112     RTGCUINT                uSavedErrorCode;
    113 
    114     /** Saved cr2. */
    115     RTGCUINTPTR             uSavedCR2;
    116 
    117     /** Previous trap vector # - for debugging. */
    118     RTGCUINT                uPrevVector;
     101    /** Offset to the TRPMCPU structure.
     102     * See TRPM2TRPMCPU(). */
     103    RTINT                   offTRPMCPU;
    119104
    120105    /** IDT monitoring and sync flag (HWACC). */
     
    136121
    137122    /** Padding to get the IDTs at a 16 byte alignement. */
    138 #if GC_ARCH_BITS == 32
    139123    uint8_t                 abPadding1[6];
    140 #else
    141     uint8_t                 abPadding1[14];
    142 #endif
    143124    /** IDTs. Aligned at 16 byte offset for speed. */
    144125    VBOXIDTE                aIdt[256];
     
    190171#endif
    191172} TRPM;
    192 #pragma pack()
    193173
    194174/** Pointer to TRPM Data. */
    195175typedef TRPM *PTRPM;
     176
     177
     178typedef struct TRPMCPU
     179{
     180    /** Offset to the VM structure.
     181     * See TRPMCPU2VM(). */
     182    RTINT                   offVM;
     183    /** Active Interrupt or trap vector number.
     184     * If not ~0U this indicates that we're currently processing
     185     * a interrupt, trap, fault, abort, whatever which have arrived
     186     * at that vector number.
     187     */
     188    RTUINT                  uActiveVector;
     189
     190    /** Active trap type. */
     191    TRPMEVENT               enmActiveType;
     192
     193    /** Errorcode for the active interrupt/trap. */
     194    RTGCUINT                uActiveErrorCode; /**< @todo don't use RTGCUINT */
     195
     196    /** CR2 at the time of the active exception. */
     197    RTGCUINTPTR             uActiveCR2;
     198
     199    /** Saved trap vector number. */
     200    RTGCUINT                uSavedVector; /**< @todo don't use RTGCUINT */
     201
     202    /** Saved trap type. */
     203    TRPMEVENT               enmSavedType;
     204
     205    /** Saved errorcode. */
     206    RTGCUINT                uSavedErrorCode;
     207
     208    /** Saved cr2. */
     209    RTGCUINTPTR             uSavedCR2;
     210
     211    /** Previous trap vector # - for debugging. */
     212    RTGCUINT                uPrevVector;
     213} TRPMCPU;
     214
     215/** Pointer to TRPMCPU Data. */
     216typedef TRPMCPU *PTRPMCPU;
     217
     218#pragma pack()
     219
    196220
    197221VMMRCDECL(int) trpmRCGuestIDTWriteHandler(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, RTGCPTR pvRange, uintptr_t offRange);
  • trunk/src/VBox/VMM/TRPMInternal.mac

    r14351 r19015  
    3434struc TRPM
    3535    .offVM              resd 1
    36     .uActiveVector      resd 1
    37     .enmActiveType      resd 1
    38     .uActiveErrorCode   RTGCPTR_RES 1
    39     .uActiveCR2         RTGCPTR_RES 1
    40     .uSavedVector       RTGCPTR_RES 1
    41     .enmSavedType       resd 1
    42     .uSavedErrorCode    RTGCPTR_RES 1
    43     .uSavedCR2          RTGCPTR_RES 1
    44     .uPrevVector        RTGCPTR_RES 1
     36    .offTRPMCPU         resd 1
    4537    .fDisableMonitoring resb 1
    4638    .fSafeToDropGuestIDTMonitoring resb 1
    47 %if GC_ARCH_BITS == 32
    4839    .abPadding1         resb 6
    49 %else
    50     .abPadding1         resb 14
    51 %endif
    5240    .aIdt               resd 512
    5341    .au32IdtPatched     resd 8
     
    8068    .paStatForwardedIRQRC  RTRCPTR_RES 1
    8169%endif
     70endstruc
     71
     72struc TRPMCPU
     73    .offVM              resd 1
     74    .uActiveVector      resd 1
     75    .enmActiveType      resd 1
     76    .uActiveErrorCode   RTGCPTR_RES 1
     77    .uActiveCR2         RTGCPTR_RES 1
     78    .uSavedVector       RTGCPTR_RES 1
     79    .enmSavedType       resd 1
     80    .uSavedErrorCode    RTGCPTR_RES 1
     81    .uSavedCR2          RTGCPTR_RES 1
     82    .uPrevVector        RTGCPTR_RES 1
    8283endstruc
    8384
  • trunk/src/VBox/VMM/VMMAll/EMAll.cpp

    r18992 r19015  
    451451
    452452#ifdef IN_RC
    453     if (TRPMHasTrap(pVM))
    454     {
    455         if (TRPMGetErrorCode(pVM) & X86_TRAP_PF_RW)
     453    if (TRPMHasTrap(pVCpu))
     454    {
     455        if (TRPMGetErrorCode(pVCpu) & X86_TRAP_PF_RW)
    456456        {
    457457#endif
     
    580580
    581581#ifdef IN_RC
    582     if (TRPMHasTrap(pVM))
    583     {
    584         if (TRPMGetErrorCode(pVM) & X86_TRAP_PF_RW)
     582    if (TRPMHasTrap(pVCpu))
     583    {
     584        if (TRPMGetErrorCode(pVCpu) & X86_TRAP_PF_RW)
    585585        {
    586586#endif
     
    648648
    649649#ifdef IN_RC
    650     if (TRPMHasTrap(pVM))
    651     {
    652         if (TRPMGetErrorCode(pVM) & X86_TRAP_PF_RW)
     650    if (TRPMHasTrap(pVCpu))
     651    {
     652        if (TRPMGetErrorCode(pVCpu) & X86_TRAP_PF_RW)
    653653        {
    654654#endif
     
    733733
    734734#ifdef IN_RC
    735     if (TRPMHasTrap(pVM))
    736     {
    737         if (TRPMGetErrorCode(pVM) & X86_TRAP_PF_RW)
     735    if (TRPMHasTrap(pVCpu))
     736    {
     737        if (TRPMGetErrorCode(pVCpu) & X86_TRAP_PF_RW)
    738738        {
    739739#endif
     
    845845#ifdef IN_RC
    846846    /* Safety check (in theory it could cross a page boundary and fault there though) */
    847     Assert(   TRPMHasTrap(pVM)
    848            && (TRPMGetErrorCode(pVM) & X86_TRAP_PF_RW));
     847    Assert(   TRPMHasTrap(pVCpu)
     848           && (TRPMGetErrorCode(pVCpu) & X86_TRAP_PF_RW));
    849849    EM_ASSERT_FAULT_RETURN(GCPtrPar1 == pvFault, VERR_EM_INTERPRETER);
    850850#endif
     
    911911
    912912#ifdef IN_RC
    913     if (TRPMHasTrap(pVM))
    914     {
    915         if (TRPMGetErrorCode(pVM) & X86_TRAP_PF_RW)
     913    if (TRPMHasTrap(pVCpu))
     914    {
     915        if (TRPMGetErrorCode(pVCpu) & X86_TRAP_PF_RW)
    916916        {
    917917#endif
     
    10151015
    10161016#ifdef IN_RC
    1017     if (TRPMHasTrap(pVM))
    1018     {
    1019         if (TRPMGetErrorCode(pVM) & X86_TRAP_PF_RW)
     1017    if (TRPMHasTrap(pVCpu))
     1018    {
     1019        if (TRPMGetErrorCode(pVCpu) & X86_TRAP_PF_RW)
    10201020        {
    10211021#endif
     
    11111111    GCPtrPar1 = emConvertToFlatAddr(pVM, pRegFrame, pDISState, &pDISState->param1, GCPtrPar1);
    11121112#ifdef IN_RC
    1113     Assert(TRPMHasTrap(pVM));
     1113    Assert(TRPMHasTrap(pVCpu));
    11141114    EM_ASSERT_FAULT_RETURN((RTGCPTR)((RTGCUINTPTR)GCPtrPar1 & ~(RTGCUINTPTR)3) == pvFault, VERR_EM_INTERPRETER);
    11151115#endif
     
    11691169
    11701170#ifdef IN_RC
    1171     if (TRPMHasTrap(pVM))
    1172     {
    1173         if (TRPMGetErrorCode(pVM) & X86_TRAP_PF_RW)
     1171    if (TRPMHasTrap(pVCpu))
     1172    {
     1173        if (TRPMGetErrorCode(pVCpu) & X86_TRAP_PF_RW)
    11741174        {
    11751175#else
     
    15821582        return VERR_EM_INTERPRETER;
    15831583
    1584     if (TRPMHasTrap(pVM))
    1585     {
    1586         if (TRPMGetErrorCode(pVM) & X86_TRAP_PF_RW)
     1584    if (TRPMHasTrap(pVCpu))
     1585    {
     1586        if (TRPMGetErrorCode(pVCpu) & X86_TRAP_PF_RW)
    15871587        {
    15881588            RTRCPTR pParam1;
     
    16541654        return VERR_EM_INTERPRETER;
    16551655
    1656     if (TRPMHasTrap(pVM))
    1657     {
    1658         if (TRPMGetErrorCode(pVM) & X86_TRAP_PF_RW)
     1656    if (TRPMHasTrap(pVCpu))
     1657    {
     1658        if (TRPMGetErrorCode(pVCpu) & X86_TRAP_PF_RW)
    16591659        {
    16601660            RTRCPTR pParam1;
     
    17251725        return VERR_EM_INTERPRETER;
    17261726
    1727     if (TRPMHasTrap(pVM))
    1728     {
    1729         if (TRPMGetErrorCode(pVM) & X86_TRAP_PF_RW)
     1727    if (TRPMHasTrap(pVCpu))
     1728    {
     1729        if (TRPMGetErrorCode(pVCpu) & X86_TRAP_PF_RW)
    17301730        {
    17311731            RTRCPTR pParam1;
  • trunk/src/VBox/VMM/VMMAll/IOMAll.cpp

    r18927 r19015  
    736736        {
    737737            Log(("iomInterpretCheckPortIOAccess: Port=%RTiop cb=%d %Rrc -> #GP(0)\n", Port, cb, rc));
    738             return TRPMRaiseXcptErr(pVM, pCtxCore, X86_XCPT_GP, 0);
     738            return TRPMRaiseXcptErr(pVCpu, pCtxCore, X86_XCPT_GP, 0);
    739739        }
    740740
     
    744744            Log(("iomInterpretCheckPortIOAccess: Port=%RTiop cb=%d cbTss=%#x fCanHaveIOBitmap=%RTbool -> #GP(0)\n",
    745745                 Port, cb, cbTss, fCanHaveIOBitmap));
    746             return TRPMRaiseXcptErr(pVM, pCtxCore, X86_XCPT_GP, 0);
     746            return TRPMRaiseXcptErr(pVCpu, pCtxCore, X86_XCPT_GP, 0);
    747747        }
    748748
     
    767767            Log(("iomInterpretCheckPortIOAccess: Port=%RTiop cb=%d offTss=%#x cbTss=%#x -> #GP(0)\n",
    768768                 Port, cb, offTss, cbTss));
    769             return TRPMRaiseXcptErr(pVM, pCtxCore, X86_XCPT_GP, 0);
     769            return TRPMRaiseXcptErr(pVCpu, pCtxCore, X86_XCPT_GP, 0);
    770770        }
    771771        uint16_t u16;
     
    785785            Log(("iomInterpretCheckPortIOAccess: Port=%RTiop cb=%d u16=%#x -> #GP(0)\n",
    786786                 Port, cb, u16, offTss));
    787             return TRPMRaiseXcptErr(pVM, pCtxCore, X86_XCPT_GP, 0);
     787            return TRPMRaiseXcptErr(pVCpu, pCtxCore, X86_XCPT_GP, 0);
    788788        }
    789789        LogFlow(("iomInterpretCheckPortIOAccess: Port=%RTiop cb=%d offTss=%#x cbTss=%#x u16=%#x -> OK\n",
  • trunk/src/VBox/VMM/VMMAll/PGMAllBth.h

    r18992 r19015  
    101101    {
    102102        uErr &= ~X86_TRAP_PF_ID;
    103         TRPMSetErrorCode(pVM, uErr);
     103        TRPMSetErrorCode(pVCpu, uErr);
    104104    }
    105105#  endif
     
    140140#    endif
    141141        STAM_STATS({ pVCpu->pgm.s.CTX_SUFF(pStatTrap0eAttribution) = &pVCpu->pgm.s.StatRZTrap0eTime2GuestTrap; });
    142         TRPMSetErrorCode(pVM, uErr);
     142        TRPMSetErrorCode(pVCpu, uErr);
    143143        return VINF_EM_RAW_GUEST_TRAP;
    144144    }
     
    329329                 * Pretend we're not here and let the guest handle the trap.
    330330                 */
    331                 TRPMSetErrorCode(pVM, uErr & ~X86_TRAP_PF_P);
     331                TRPMSetErrorCode(pVCpu, uErr & ~X86_TRAP_PF_P);
    332332                STAM_COUNTER_INC(&pVCpu->pgm.s.StatRZTrap0eGuestPFMapping);
    333333                LogFlow(("PGM: Mapping access -> route trap to recompiler!\n"));
     
    22012201             */
    22022202            if (pPdeSrc->n.u1Present && pPteSrc->n.u1Present)
    2203                 TRPMSetErrorCode(pVM, uErr | X86_TRAP_PF_P); /* page-level protection violation */
     2203                TRPMSetErrorCode(pVCpu, uErr | X86_TRAP_PF_P); /* page-level protection violation */
    22042204
    22052205            STAM_PROFILE_STOP(&pVCpu->pgm.s.CTX_MID_Z(Stat,DirtyBitTracking), a);
     
    23282328        if (pPdeSrc->b.u1Size && fBigPagesSupported)
    23292329        {
    2330             TRPMSetErrorCode(pVM, uErr | X86_TRAP_PF_P); /* page-level protection violation */
     2330            TRPMSetErrorCode(pVCpu, uErr | X86_TRAP_PF_P); /* page-level protection violation */
    23312331        }
    23322332        else
     
    23422342                const GSTPTE    PteSrc = *pPteSrc;
    23432343                if (pPteSrc->n.u1Present)
    2344                     TRPMSetErrorCode(pVM, uErr | X86_TRAP_PF_P); /* page-level protection violation */
     2344                    TRPMSetErrorCode(pVCpu, uErr | X86_TRAP_PF_P); /* page-level protection violation */
    23452345            }
    23462346            AssertRC(rc);
  • trunk/src/VBox/VMM/VMMAll/PGMAllPhys.cpp

    r18988 r19015  
    27562756    }
    27572757    Log(("PGMPhysInterpretedRead: GCPtrSrc=%RGv cb=%#x -> #PF(%#x)\n", GCPtrSrc, cb, uErr));
    2758     return TRPMRaiseXcptErrCR2(pVM, pCtxCore, X86_XCPT_PF, uErr, GCPtrSrc);
     2758    return TRPMRaiseXcptErrCR2(pVCpu, pCtxCore, X86_XCPT_PF, uErr, GCPtrSrc);
    27592759}
    27602760
     
    29482948    {
    29492949        Log(("PGMPhysInterpretedReadNoHandlers: GCPtrSrc=%RGv cb=%#x -> Raised #PF(%#x)\n", GCPtrSrc, cb, uErr));
    2950         return TRPMRaiseXcptErrCR2(pVM, pCtxCore, X86_XCPT_PF, uErr, GCPtrSrc);
     2950        return TRPMRaiseXcptErrCR2(pVCpu, pCtxCore, X86_XCPT_PF, uErr, GCPtrSrc);
    29512951    }
    29522952    Log(("PGMPhysInterpretedReadNoHandlers: GCPtrSrc=%RGv cb=%#x -> #PF(%#x) [!raised]\n", GCPtrSrc, cb, uErr));
     
    31513151    {
    31523152        Log(("PGMPhysInterpretedWriteNoHandlers: GCPtrDst=%RGv cb=%#x -> Raised #PF(%#x)\n", GCPtrDst, cb, uErr));
    3153         return TRPMRaiseXcptErrCR2(pVM, pCtxCore, X86_XCPT_PF, uErr, GCPtrDst);
     3153        return TRPMRaiseXcptErrCR2(pVCpu, pCtxCore, X86_XCPT_PF, uErr, GCPtrDst);
    31543154    }
    31553155    Log(("PGMPhysInterpretedWriteNoHandlers: GCPtrDst=%RGv cb=%#x -> #PF(%#x) [!raised]\n", GCPtrDst, cb, uErr));
  • trunk/src/VBox/VMM/VMMAll/TRPMAll.cpp

    r18992 r19015  
    4949 *
    5050 * @returns VBox status code.
    51  * @param   pVM                     The virtual machine.
     51 * @param   pVCpu                   VMCPU handle.
    5252 * @param   pu8TrapNo               Where to store the trap number.
    5353 * @param   pEnmType                Where to store the trap type
    5454 */
    55 VMMDECL(int)  TRPMQueryTrap(PVM pVM, uint8_t *pu8TrapNo, TRPMEVENT *pEnmType)
     55VMMDECL(int)  TRPMQueryTrap(PVMCPU pVCpu, uint8_t *pu8TrapNo, TRPMEVENT *pEnmType)
    5656{
    5757    /*
    5858     * Check if we have a trap at present.
    5959     */
    60     if (pVM->trpm.s.uActiveVector != ~0U)
     60    if (pVCpu->trpm.s.uActiveVector != ~0U)
    6161    {
    6262        if (pu8TrapNo)
    63             *pu8TrapNo = (uint8_t)pVM->trpm.s.uActiveVector;
     63            *pu8TrapNo = (uint8_t)pVCpu->trpm.s.uActiveVector;
    6464        if (pEnmType)
    65             *pEnmType = pVM->trpm.s.enmActiveType;
     65            *pEnmType = pVCpu->trpm.s.enmActiveType;
    6666        return VINF_SUCCESS;
    6767    }
     
    7878 *
    7979 * @returns The current trap number.
    80  * @param   pVM         VM handle.
    81  */
    82 VMMDECL(uint8_t)  TRPMGetTrapNo(PVM pVM)
    83 {
    84     AssertMsg(pVM->trpm.s.uActiveVector != ~0U, ("No active trap!\n"));
    85     return (uint8_t)pVM->trpm.s.uActiveVector;
     80 * @param   pVCpu                   VMCPU handle.
     81 */
     82VMMDECL(uint8_t)  TRPMGetTrapNo(PVMCPU pVCpu)
     83{
     84    AssertMsg(pVCpu->trpm.s.uActiveVector != ~0U, ("No active trap!\n"));
     85    return (uint8_t)pVCpu->trpm.s.uActiveVector;
    8686}
    8787
     
    9494 *
    9595 * @returns Error code.
    96  * @param   pVM         VM handle.
    97  */
    98 VMMDECL(RTGCUINT)  TRPMGetErrorCode(PVM pVM)
    99 {
    100     AssertMsg(pVM->trpm.s.uActiveVector != ~0U, ("No active trap!\n"));
     96 * @param   pVCpu                   VMCPU handle.
     97 */
     98VMMDECL(RTGCUINT)  TRPMGetErrorCode(PVMCPU pVCpu)
     99{
     100    AssertMsg(pVCpu->trpm.s.uActiveVector != ~0U, ("No active trap!\n"));
    101101#ifdef VBOX_STRICT
    102     switch (pVM->trpm.s.uActiveVector)
     102    switch (pVCpu->trpm.s.uActiveVector)
    103103    {
    104104        case 0x0a:
     
    111111            break;
    112112        default:
    113             AssertMsgFailed(("This trap (%#x) doesn't have any error code\n", pVM->trpm.s.uActiveVector));
     113            AssertMsgFailed(("This trap (%#x) doesn't have any error code\n", pVCpu->trpm.s.uActiveVector));
    114114            break;
    115115    }
    116116#endif
    117     return pVM->trpm.s.uActiveErrorCode;
     117    return pVCpu->trpm.s.uActiveErrorCode;
    118118}
    119119
     
    126126 *
    127127 * @returns Fault address associated with the trap.
    128  * @param   pVM         VM handle.
    129  */
    130 VMMDECL(RTGCUINTPTR) TRPMGetFaultAddress(PVM pVM)
    131 {
    132     AssertMsg(pVM->trpm.s.uActiveVector != ~0U, ("No active trap!\n"));
    133     AssertMsg(pVM->trpm.s.uActiveVector == 0xe, ("Not trap 0e!\n"));
    134     return pVM->trpm.s.uActiveCR2;
     128 * @param   pVCpu                   VMCPU handle.
     129 */
     130VMMDECL(RTGCUINTPTR) TRPMGetFaultAddress(PVMCPU pVCpu)
     131{
     132    AssertMsg(pVCpu->trpm.s.uActiveVector != ~0U, ("No active trap!\n"));
     133    AssertMsg(pVCpu->trpm.s.uActiveVector == 0xe, ("Not trap 0e!\n"));
     134    return pVCpu->trpm.s.uActiveCR2;
    135135}
    136136
     
    143143 *
    144144 * @returns VBox status code.
    145  * @param   pVM         The virtual machine handle.
    146  */
    147 VMMDECL(int) TRPMResetTrap(PVM pVM)
     145 * @param   pVCpu                   VMCPU handle.
     146 */
     147VMMDECL(int) TRPMResetTrap(PVMCPU pVCpu)
    148148{
    149149    /*
    150150     * Cannot reset non-existing trap!
    151151     */
    152     if (pVM->trpm.s.uActiveVector == ~0U)
     152    if (pVCpu->trpm.s.uActiveVector == ~0U)
    153153    {
    154154        AssertMsgFailed(("No active trap!\n"));
     
    159159     * Reset it.
    160160     */
    161     pVM->trpm.s.uActiveVector = ~0U;
     161    pVCpu->trpm.s.uActiveVector = ~0U;
    162162    return VINF_SUCCESS;
    163163}
     
    171171 *
    172172 * @returns VBox status code.
    173  * @param   pVM                 The virtual machine.
     173 * @param   pVCpu               VMCPU handle.
    174174 * @param   u8TrapNo            The trap vector to assert.
    175175 * @param   enmType             Trap type.
    176176 */
    177 VMMDECL(int)  TRPMAssertTrap(PVM pVM, uint8_t u8TrapNo, TRPMEVENT enmType)
     177VMMDECL(int)  TRPMAssertTrap(PVMCPU pVCpu, uint8_t u8TrapNo, TRPMEVENT enmType)
    178178{
    179179    Log2(("TRPMAssertTrap: u8TrapNo=%02x type=%d\n", u8TrapNo, enmType));
     
    182182     * Cannot assert a trap when one is already active.
    183183     */
    184     if (pVM->trpm.s.uActiveVector != ~0U)
     184    if (pVCpu->trpm.s.uActiveVector != ~0U)
    185185    {
    186         AssertMsgFailed(("Active trap %#x\n", pVM->trpm.s.uActiveVector));
     186        AssertMsgFailed(("Active trap %#x\n", pVCpu->trpm.s.uActiveVector));
    187187        return VERR_TRPM_ACTIVE_TRAP;
    188188    }
    189189
    190     pVM->trpm.s.uActiveVector               = u8TrapNo;
    191     pVM->trpm.s.enmActiveType               = enmType;
    192     pVM->trpm.s.uActiveErrorCode            = ~0;
    193     pVM->trpm.s.uActiveCR2                  = 0xdeadface;
     190    pVCpu->trpm.s.uActiveVector               = u8TrapNo;
     191    pVCpu->trpm.s.enmActiveType               = enmType;
     192    pVCpu->trpm.s.uActiveErrorCode            = ~0;
     193    pVCpu->trpm.s.uActiveCR2                  = 0xdeadface;
    194194    return VINF_SUCCESS;
    195195}
     
    203203 * which takes an errorcode when making this request.
    204204 *
    205  * @param   pVM         The virtual machine.
    206  * @param   uErrorCode  The new error code.
    207  */
    208 VMMDECL(void)  TRPMSetErrorCode(PVM pVM, RTGCUINT uErrorCode)
     205 * @param   pVCpu               VMCPU handle.
     206 * @param   uErrorCode          The new error code.
     207 */
     208VMMDECL(void)  TRPMSetErrorCode(PVMCPU pVCpu, RTGCUINT uErrorCode)
    209209{
    210210    Log2(("TRPMSetErrorCode: uErrorCode=%RGv\n", uErrorCode)); /** @todo RTGCUINT mess! */
    211     AssertMsg(pVM->trpm.s.uActiveVector != ~0U, ("No active trap!\n"));
    212     pVM->trpm.s.uActiveErrorCode = uErrorCode;
     211    AssertMsg(pVCpu->trpm.s.uActiveVector != ~0U, ("No active trap!\n"));
     212    pVCpu->trpm.s.uActiveErrorCode = uErrorCode;
    213213#ifdef VBOX_STRICT
    214     switch (pVM->trpm.s.uActiveVector)
     214    switch (pVCpu->trpm.s.uActiveVector)
    215215    {
    216216        case 0x0a: case 0x0b: case 0x0c: case 0x0d: case 0x0e:
    217             AssertMsg(uErrorCode != ~(RTGCUINT)0, ("Invalid uErrorCode=%#x u8TrapNo=%d\n", uErrorCode, pVM->trpm.s.uActiveVector));
     217            AssertMsg(uErrorCode != ~(RTGCUINT)0, ("Invalid uErrorCode=%#x u8TrapNo=%d\n", uErrorCode, pVCpu->trpm.s.uActiveVector));
    218218            break;
    219219        case 0x11: case 0x08:
    220             AssertMsg(uErrorCode == 0,              ("Invalid uErrorCode=%#x u8TrapNo=%d\n", uErrorCode, pVM->trpm.s.uActiveVector));
     220            AssertMsg(uErrorCode == 0,              ("Invalid uErrorCode=%#x u8TrapNo=%d\n", uErrorCode, pVCpu->trpm.s.uActiveVector));
    221221            break;
    222222        default:
    223             AssertMsg(uErrorCode == ~(RTGCUINT)0, ("Invalid uErrorCode=%#x u8TrapNo=%d\n", uErrorCode, pVM->trpm.s.uActiveVector));
     223            AssertMsg(uErrorCode == ~(RTGCUINT)0, ("Invalid uErrorCode=%#x u8TrapNo=%d\n", uErrorCode, pVCpu->trpm.s.uActiveVector));
    224224            break;
    225225    }
     
    235235 * when making this request.
    236236 *
    237  * @param   pVM         The virtual machine.
    238  * @param   uCR2        The new fault address (cr2 register).
    239  */
    240 VMMDECL(void)  TRPMSetFaultAddress(PVM pVM, RTGCUINTPTR uCR2)
     237 * @param   pVCpu               VMCPU handle.
     238 * @param   uCR2                The new fault address (cr2 register).
     239 */
     240VMMDECL(void)  TRPMSetFaultAddress(PVMCPU pVCpu, RTGCUINTPTR uCR2)
    241241{
    242242    Log2(("TRPMSetFaultAddress: uCR2=%RGv\n", uCR2));
    243     AssertMsg(pVM->trpm.s.uActiveVector != ~0U, ("No active trap!\n"));
    244     AssertMsg(pVM->trpm.s.uActiveVector == 0xe, ("Not trap 0e!\n"));
    245     pVM->trpm.s.uActiveCR2 = uCR2;
     243    AssertMsg(pVCpu->trpm.s.uActiveVector != ~0U, ("No active trap!\n"));
     244    AssertMsg(pVCpu->trpm.s.uActiveVector == 0xe, ("Not trap 0e!\n"));
     245    pVCpu->trpm.s.uActiveCR2 = uCR2;
    246246}
    247247
     
    256256 * @returns true if software interrupt, false if not.
    257257 *
    258  * @param   pVM         VM handle.
    259  */
    260 VMMDECL(bool) TRPMIsSoftwareInterrupt(PVM pVM)
    261 {
    262     AssertMsg(pVM->trpm.s.uActiveVector != ~0U, ("No active trap!\n"));
    263     return (pVM->trpm.s.enmActiveType == TRPM_SOFTWARE_INT);
     258 * @param   pVCpu               VMCPU handle.
     259 */
     260VMMDECL(bool) TRPMIsSoftwareInterrupt(PVMCPU pVCpu)
     261{
     262    AssertMsg(pVCpu->trpm.s.uActiveVector != ~0U, ("No active trap!\n"));
     263    return (pVCpu->trpm.s.enmActiveType == TRPM_SOFTWARE_INT);
    264264}
    265265
     
    269269 *
    270270 * @returns true if trap active, false if not.
    271  * @param   pVM         The virtual machine.
    272  */
    273 VMMDECL(bool)  TRPMHasTrap(PVM pVM)
    274 {
    275     return pVM->trpm.s.uActiveVector != ~0U;
     271 * @param   pVCpu               VMCPU handle.
     272 */
     273VMMDECL(bool)  TRPMHasTrap(PVMCPU pVCpu)
     274{
     275    return pVCpu->trpm.s.uActiveVector != ~0U;
    276276}
    277277
     
    282282 *
    283283 * @returns VBox status code.
    284  * @param   pVM                     The virtual machine.
     284 * @param   pVCpu                   VMCPU handle.
    285285 * @param   pu8TrapNo               Where to store the trap number.
    286286 * @param   pEnmType                Where to store the trap type
     
    289289 * @param   puCR2                   Where to store the CR2 associated with a trap 0E.
    290290 */
    291 VMMDECL(int)  TRPMQueryTrapAll(PVM pVM, uint8_t *pu8TrapNo, TRPMEVENT *pEnmType, PRTGCUINT puErrorCode, PRTGCUINTPTR puCR2)
     291VMMDECL(int)  TRPMQueryTrapAll(PVMCPU pVCpu, uint8_t *pu8TrapNo, TRPMEVENT *pEnmType, PRTGCUINT puErrorCode, PRTGCUINTPTR puCR2)
    292292{
    293293    /*
    294294     * Check if we have a trap at present.
    295295     */
    296     if (pVM->trpm.s.uActiveVector == ~0U)
     296    if (pVCpu->trpm.s.uActiveVector == ~0U)
    297297        return VERR_TRPM_NO_ACTIVE_TRAP;
    298298
    299299    if (pu8TrapNo)
    300         *pu8TrapNo      = (uint8_t)pVM->trpm.s.uActiveVector;
     300        *pu8TrapNo      = (uint8_t)pVCpu->trpm.s.uActiveVector;
    301301    if (pEnmType)
    302         *pEnmType       = pVM->trpm.s.enmActiveType;
     302        *pEnmType       = pVCpu->trpm.s.enmActiveType;
    303303    if (puErrorCode)
    304         *puErrorCode    = pVM->trpm.s.uActiveErrorCode;
     304        *puErrorCode    = pVCpu->trpm.s.uActiveErrorCode;
    305305    if (puCR2)
    306         *puCR2          = pVM->trpm.s.uActiveCR2;
     306        *puCR2          = pVCpu->trpm.s.uActiveCR2;
    307307
    308308    return VINF_SUCCESS;
     
    319319 * @param   pVM     VM handle.
    320320 */
    321 VMMDECL(void) TRPMSaveTrap(PVM pVM)
    322 {
    323     pVM->trpm.s.uSavedVector        = pVM->trpm.s.uActiveVector;
    324     pVM->trpm.s.enmSavedType        = pVM->trpm.s.enmActiveType;
    325     pVM->trpm.s.uSavedErrorCode     = pVM->trpm.s.uActiveErrorCode;
    326     pVM->trpm.s.uSavedCR2           = pVM->trpm.s.uActiveCR2;
     321VMMDECL(void) TRPMSaveTrap(PVMCPU pVCpu)
     322{
     323    pVCpu->trpm.s.uSavedVector        = pVCpu->trpm.s.uActiveVector;
     324    pVCpu->trpm.s.enmSavedType        = pVCpu->trpm.s.enmActiveType;
     325    pVCpu->trpm.s.uSavedErrorCode     = pVCpu->trpm.s.uActiveErrorCode;
     326    pVCpu->trpm.s.uSavedCR2           = pVCpu->trpm.s.uActiveCR2;
    327327}
    328328
     
    335335 * @param   pVM     VM handle.
    336336 */
    337 VMMDECL(void) TRPMRestoreTrap(PVM pVM)
    338 {
    339     pVM->trpm.s.uActiveVector       = pVM->trpm.s.uSavedVector;
    340     pVM->trpm.s.enmActiveType       = pVM->trpm.s.enmSavedType;
    341     pVM->trpm.s.uActiveErrorCode    = pVM->trpm.s.uSavedErrorCode;
    342     pVM->trpm.s.uActiveCR2          = pVM->trpm.s.uSavedCR2;
     337VMMDECL(void) TRPMRestoreTrap(PVMCPU pVCpu)
     338{
     339    pVCpu->trpm.s.uActiveVector       = pVCpu->trpm.s.uSavedVector;
     340    pVCpu->trpm.s.enmActiveType       = pVCpu->trpm.s.enmSavedType;
     341    pVCpu->trpm.s.uActiveErrorCode    = pVCpu->trpm.s.uSavedErrorCode;
     342    pVCpu->trpm.s.uActiveCR2          = pVCpu->trpm.s.uSavedCR2;
    343343}
    344344
     
    361361 * @internal
    362362 */
    363 VMMDECL(int) TRPMForwardTrap(PVM pVM, PCPUMCTXCORE pRegFrame, uint32_t iGate, uint32_t opsize, TRPMERRORCODE enmError, TRPMEVENT enmType, int32_t iOrgTrap)
     363VMMDECL(int) TRPMForwardTrap(PVMCPU pVCpu, PCPUMCTXCORE pRegFrame, uint32_t iGate, uint32_t opsize, TRPMERRORCODE enmError, TRPMEVENT enmType, int32_t iOrgTrap)
    364364{
    365365#ifdef TRPM_FORWARD_TRAPS_IN_GC
     366    PVM pVM = pVCpu->CTX_SUFF(pVM);
    366367    X86EFLAGS eflags;
    367368    Assert(pVM->cCPUs == 1);
    368     PVMCPU    pVCpu = &pVM->aCpus[0];
    369369
    370370    STAM_PROFILE_ADV_START(&pVM->trpm.s.CTX_SUFF_Z(StatForwardProf), a);
     
    378378    switch (iGate) {
    379379    case 14:
    380         if (pRegFrame->eip == pVM->trpm.s.uActiveCR2)
     380        if (pRegFrame->eip == pVCpu->trpm.s.uActiveCR2)
    381381        {
    382382            int rc;
     
    608608                    if (eflags.Bits.u1VM)
    609609                    {
    610                         Log(("TRAP%02X: (VM) Handler %04X:%RGv Stack %04X:%08X RPL=%d CR2=%08X\n", iGate, GuestIdte.Gen.u16SegSel, pHandler, ss_r0, esp_r0, (pRegFrame->ss & X86_SEL_RPL), pVM->trpm.s.uActiveCR2));
     610                        Log(("TRAP%02X: (VM) Handler %04X:%RGv Stack %04X:%08X RPL=%d CR2=%08X\n", iGate, GuestIdte.Gen.u16SegSel, pHandler, ss_r0, esp_r0, (pRegFrame->ss & X86_SEL_RPL), pVCpu->trpm.s.uActiveCR2));
    611611                        pTrapStack[--idx] = pRegFrame->gs;
    612612                        pTrapStack[--idx] = pRegFrame->fs;
     
    618618                    }
    619619                    else
    620                         Log(("TRAP%02X: Handler %04X:%RGv Stack %04X:%08X RPL=%d CR2=%08X\n", iGate, GuestIdte.Gen.u16SegSel, pHandler, ss_r0, esp_r0, (pRegFrame->ss & X86_SEL_RPL), pVM->trpm.s.uActiveCR2));
     620                        Log(("TRAP%02X: Handler %04X:%RGv Stack %04X:%08X RPL=%d CR2=%08X\n", iGate, GuestIdte.Gen.u16SegSel, pHandler, ss_r0, esp_r0, (pRegFrame->ss & X86_SEL_RPL), pVCpu->trpm.s.uActiveCR2));
    621621
    622622                    if (!fConforming && dpl < cpl)
     
    649649                    if (enmError == TRPM_TRAP_HAS_ERRORCODE)
    650650                    {
    651                         pTrapStack[--idx] = pVM->trpm.s.uActiveErrorCode;
     651                        pTrapStack[--idx] = pVCpu->trpm.s.uActiveErrorCode;
    652652                    }
    653653
     
    674674
    675675                    /* Make sure the internal guest context structure is up-to-date. */
    676                     CPUMSetGuestCR2(pVCpu, pVM->trpm.s.uActiveCR2);
     676                    CPUMSetGuestCR2(pVCpu, pVCpu->trpm.s.uActiveCR2);
    677677
    678678#ifdef IN_RC
    679679                    /* Note: shouldn't be necessary */
    680                     ASMSetCR2(pVM->trpm.s.uActiveCR2);
     680                    ASMSetCR2(pVCpu->trpm.s.uActiveCR2);
    681681
    682682                    /* Turn off interrupts for interrupt gates. */
     
    757757 * @param   enmXcpt     The exception.
    758758 */
    759 VMMDECL(int) TRPMRaiseXcpt(PVM pVM, PCPUMCTXCORE pCtxCore, X86XCPT enmXcpt)
     759VMMDECL(int) TRPMRaiseXcpt(PVMCPU pVCpu, PCPUMCTXCORE pCtxCore, X86XCPT enmXcpt)
    760760{
    761761    LogFlow(("TRPMRaiseXcptErr: cs:eip=%RTsel:%RX32 enmXcpt=%#x\n", pCtxCore->cs, pCtxCore->eip, enmXcpt));
    762762/** @todo dispatch the trap. */
    763     pVM->trpm.s.uActiveVector            = enmXcpt;
    764     pVM->trpm.s.enmActiveType            = TRPM_TRAP;
    765     pVM->trpm.s.uActiveErrorCode         = 0xdeadbeef;
    766     pVM->trpm.s.uActiveCR2               = 0xdeadface;
     763    pVCpu->trpm.s.uActiveVector            = enmXcpt;
     764    pVCpu->trpm.s.enmActiveType            = TRPM_TRAP;
     765    pVCpu->trpm.s.uActiveErrorCode         = 0xdeadbeef;
     766    pVCpu->trpm.s.uActiveCR2               = 0xdeadface;
    767767    return VINF_EM_RAW_GUEST_TRAP;
    768768}
     
    784784 * @param   uErr        The error code.
    785785 */
    786 VMMDECL(int) TRPMRaiseXcptErr(PVM pVM, PCPUMCTXCORE pCtxCore, X86XCPT enmXcpt, uint32_t uErr)
     786VMMDECL(int) TRPMRaiseXcptErr(PVMCPU pVCpu, PCPUMCTXCORE pCtxCore, X86XCPT enmXcpt, uint32_t uErr)
    787787{
    788788    LogFlow(("TRPMRaiseXcptErr: cs:eip=%RTsel:%RX32 enmXcpt=%#x uErr=%RX32\n", pCtxCore->cs, pCtxCore->eip, enmXcpt, uErr));
    789789/** @todo dispatch the trap. */
    790     pVM->trpm.s.uActiveVector            = enmXcpt;
    791     pVM->trpm.s.enmActiveType            = TRPM_TRAP;
    792     pVM->trpm.s.uActiveErrorCode         = uErr;
    793     pVM->trpm.s.uActiveCR2               = 0xdeadface;
     790    pVCpu->trpm.s.uActiveVector            = enmXcpt;
     791    pVCpu->trpm.s.enmActiveType            = TRPM_TRAP;
     792    pVCpu->trpm.s.uActiveErrorCode         = uErr;
     793    pVCpu->trpm.s.uActiveCR2               = 0xdeadface;
    794794    return VINF_EM_RAW_GUEST_TRAP;
    795795}
     
    812812 * @param   uCR2        The CR2 value.
    813813 */
    814 VMMDECL(int) TRPMRaiseXcptErrCR2(PVM pVM, PCPUMCTXCORE pCtxCore, X86XCPT enmXcpt, uint32_t uErr, RTGCUINTPTR uCR2)
     814VMMDECL(int) TRPMRaiseXcptErrCR2(PVMCPU pVCpu, PCPUMCTXCORE pCtxCore, X86XCPT enmXcpt, uint32_t uErr, RTGCUINTPTR uCR2)
    815815{
    816816    LogFlow(("TRPMRaiseXcptErr: cs:eip=%RTsel:%RX32 enmXcpt=%#x uErr=%RX32 uCR2=%RGv\n", pCtxCore->cs, pCtxCore->eip, enmXcpt, uErr, uCR2));
    817817/** @todo dispatch the trap. */
    818     pVM->trpm.s.uActiveVector            = enmXcpt;
    819     pVM->trpm.s.enmActiveType            = TRPM_TRAP;
    820     pVM->trpm.s.uActiveErrorCode         = uErr;
    821     pVM->trpm.s.uActiveCR2               = uCR2;
     818    pVCpu->trpm.s.uActiveVector            = enmXcpt;
     819    pVCpu->trpm.s.enmActiveType            = TRPM_TRAP;
     820    pVCpu->trpm.s.uActiveErrorCode         = uErr;
     821    pVCpu->trpm.s.uActiveCR2               = uCR2;
    822822    return VINF_EM_RAW_GUEST_TRAP;
    823823}
  • trunk/src/VBox/VMM/VMMGC/MMRamGC.cpp

    r18988 r19015  
    103103VMMRCDECL(int) MMGCRamRead(PVM pVM, void *pDst, void *pSrc, size_t cb)
    104104{
    105     int rc;
    106 
    107     TRPMSaveTrap(pVM);  /* save the current trap info, because it will get trashed if our access failed. */
     105    int    rc;
     106    PVMCPU pVCpu = VMMGetCpu0(pVM);
     107
     108    TRPMSaveTrap(pVCpu);  /* save the current trap info, because it will get trashed if our access failed. */
    108109
    109110    MMGCRamRegisterTrapHandler(pVM);
     
    111112    MMGCRamDeregisterTrapHandler(pVM);
    112113    if (RT_FAILURE(rc))
    113         TRPMRestoreTrap(pVM);
     114        TRPMRestoreTrap(pVCpu);
    114115
    115116    return rc;
     
    128129VMMRCDECL(int) MMGCRamWrite(PVM pVM, void *pDst, void *pSrc, size_t cb)
    129130{
    130     TRPMSaveTrap(pVM);  /* save the current trap info, because it will get trashed if our access failed. */
     131    PVMCPU pVCpu = VMMGetCpu0(pVM);
     132    TRPMSaveTrap(pVCpu);  /* save the current trap info, because it will get trashed if our access failed. */
    131133
    132134    MMGCRamRegisterTrapHandler(pVM);
     
    134136    MMGCRamDeregisterTrapHandler(pVM);
    135137    if (RT_FAILURE(rc))
    136         TRPMRestoreTrap(pVM);
     138        TRPMRestoreTrap(pVCpu);
    137139
    138140    /*
     
    159161    {
    160162        /* Must be a read violation. */
    161         AssertReturn(!(TRPMGetErrorCode(pVM) & X86_TRAP_PF_RW), VERR_INTERNAL_ERROR);
     163        AssertReturn(!(TRPMGetErrorCode(VMMGetCpu0(pVM)) & X86_TRAP_PF_RW), VERR_INTERNAL_ERROR);
    162164        pRegFrame->eip = (uintptr_t)&MMGCRamRead_Error;
    163165        return VINF_SUCCESS;
     
    171173    {
    172174        /* Must be a write violation. */
    173         AssertReturn(TRPMGetErrorCode(pVM) & X86_TRAP_PF_RW, VERR_INTERNAL_ERROR);
     175        AssertReturn(TRPMGetErrorCode(VMMGetCpu0(pVM)) & X86_TRAP_PF_RW, VERR_INTERNAL_ERROR);
    174176        pRegFrame->eip = (uintptr_t)&MMGCRamWrite_Error;
    175177        return VINF_SUCCESS;
  • trunk/src/VBox/VMM/VMMGC/TRPMGC.cpp

    r18927 r19015  
    8888
    8989    LogFlow(("TRPMGCHyperReturnToHost: rc=%Rrc\n", rc));
    90     TRPMResetTrap(pVM);
     90    TRPMResetTrap(pVCpu);
    9191    CPUMHyperSetCtxCore(pVCpu, NULL);
    9292    VMMGCGuestToHost(pVM, rc);
  • trunk/src/VBox/VMM/VMMGC/TRPMGCHandlers.cpp

    r18992 r19015  
    136136{
    137137    PVMCPU   pVCpu = VMMGetCpu0(pVM);
    138     uint32_t uOldActiveVector = pVM->trpm.s.uActiveVector;
     138    uint32_t uOldActiveVector = pVCpu->trpm.s.uActiveVector;
    139139    NOREF(uOldActiveVector);
    140140
     
    142142    if (    rc != VINF_EM_RAW_GUEST_TRAP
    143143        &&  rc != VINF_EM_RAW_RING_SWITCH_INT)
    144         pVM->trpm.s.uActiveVector = ~0;
     144        pVCpu->trpm.s.uActiveVector = ~0;
    145145
    146146#ifdef VBOX_HIGH_RES_TIMERS_HACK
     
    210210            Log(("trpmGCExitTrap: u8Interrupt=%d (%#x) rc=%Rrc\n", u8Interrupt, u8Interrupt, rc));
    211211            AssertFatalMsgRC(rc, ("PDMGetInterrupt failed with %Rrc\n", rc));
    212             rc = TRPMForwardTrap(pVM, pRegFrame, (uint32_t)u8Interrupt, 0, TRPM_TRAP_NO_ERRORCODE, TRPM_HARDWARE_INT, uOldActiveVector);
     212            rc = TRPMForwardTrap(pVCpu, pRegFrame, (uint32_t)u8Interrupt, 0, TRPM_TRAP_NO_ERRORCODE, TRPM_HARDWARE_INT, uOldActiveVector);
    213213            /* can't return if successful */
    214214            Assert(rc != VINF_SUCCESS);
     
    219219
    220220            /* Assert the trap and go to the recompiler to dispatch it. */
    221             TRPMAssertTrap(pVM, u8Interrupt, TRPM_HARDWARE_INT);
     221            TRPMAssertTrap(pVCpu, u8Interrupt, TRPM_HARDWARE_INT);
    222222
    223223            STAM_PROFILE_ADV_START(&pVM->trpm.s.aStatGCTraps[uOldActiveVector], a);
     
    253253 *          other codes are passed execution to host context.
    254254 *
    255  * @param   pTrpm       Pointer to TRPM data (within VM).
     255 * @param   pTrpmCpu    Pointer to TRPMCPU data (within VM).
    256256 * @param   pRegFrame   Pointer to the register frame for the trap.
    257257 * @internal
    258258 */
    259 DECLASM(int) TRPMGCTrap01Handler(PTRPM pTrpm, PCPUMCTXCORE pRegFrame)
     259DECLASM(int) TRPMGCTrap01Handler(PTRPMCPU pTrpmCpu, PCPUMCTXCORE pRegFrame)
    260260{
    261261    RTGCUINTREG uDr6 = ASMGetAndClearDR6();
    262     PVM         pVM = TRPM2VM(pTrpm);
     262    PVM         pVM = TRPM2VM(pTrpmCpu);
    263263    PVMCPU      pVCpu = VMMGetCpu0(pVM);
    264264
     
    298298 *          other codes are passed execution to host context.
    299299 *
    300  * @param   pTrpm       Pointer to TRPM data (within VM).
     300 * @param   pTrpmCpu    Pointer to TRPMCPU data (within VM).
    301301 * @param   pRegFrame   Pointer to the register frame for the trap.
    302302 * @internal
    303303 * @remark  This is not hooked up unless you're building with VBOX_WITH_NMI defined.
    304304 */
    305 DECLASM(int) TRPMGCTrap02Handler(PTRPM pTrpm, PCPUMCTXCORE pRegFrame)
     305DECLASM(int) TRPMGCTrap02Handler(PTRPMCPU pTrpmCpu, PCPUMCTXCORE pRegFrame)
    306306{
    307307    LogFlow(("TRPMGCTrap02Handler: cs:eip=%04x:%08x\n", pRegFrame->cs, pRegFrame->eip));
     
    318318 *          other codes are passed execution to host context.
    319319 *
    320  * @param   pTrpm       Pointer to TRPM data (within VM).
     320 * @param   pTrpmCpu    Pointer to TRPMCPU data (within VM).
    321321 * @param   pRegFrame   Pointer to the register frame for the trap.
    322322 * @internal
    323323 */
    324 DECLASM(int) TRPMGCTrap03Handler(PTRPM pTrpm, PCPUMCTXCORE pRegFrame)
     324DECLASM(int) TRPMGCTrap03Handler(PTRPMCPU pTrpmCpu, PCPUMCTXCORE pRegFrame)
    325325{
    326326    LogFlow(("TRPMGC03: %04x:%08x\n", pRegFrame->cs, pRegFrame->eip));
    327     PVM pVM = TRPM2VM(pTrpm);
     327    PVM pVM = TRPM2VM(pTrpmCpu);
    328328    int rc;
    329329
     
    358358 *          other codes are passed execution to host context.
    359359 *
    360  * @param   pTrpm       Pointer to TRPM data (within VM).
     360 * @param   pTrpmCpu    Pointer to TRPMCPU data (within VM).
    361361 * @param   pRegFrame   Pointer to the register frame for the trap.
    362362 * @internal
    363363 */
    364 DECLASM(int) TRPMGCTrap06Handler(PTRPM pTrpm, PCPUMCTXCORE pRegFrame)
     364DECLASM(int) TRPMGCTrap06Handler(PTRPMCPU pTrpmCpu, PCPUMCTXCORE pRegFrame)
    365365{
    366366    LogFlow(("TRPMGC06: %04x:%08x efl=%x\n", pRegFrame->cs, pRegFrame->eip, pRegFrame->eflags.u32));
    367     PVM     pVM = TRPM2VM(pTrpm);
     367    PVM     pVM = TRPM2VM(pTrpmCpu);
    368368    PVMCPU  pVCpu = VMMGetCpu0(pVM);
    369369    int     rc;
     
    422422#ifdef DTRACE_EXPERIMENT /** @todo fix/remove/permanent-enable this when DIS/PATM handles invalid lock sequences. */
    423423            Assert(!PATMIsPatchGCAddr(pVM, (RTRCPTR)pRegFrame->eip));
    424             rc = TRPMForwardTrap(pVM, pRegFrame, 0x6, 0, TRPM_TRAP_NO_ERRORCODE, TRPM_TRAP, 0x6);
     424            rc = TRPMForwardTrap(pVCpu, pRegFrame, 0x6, 0, TRPM_TRAP_NO_ERRORCODE, TRPM_TRAP, 0x6);
    425425            Assert(rc == VINF_EM_RAW_GUEST_TRAP);
    426426#else
     
    444444    else
    445445    {
    446         rc = TRPMForwardTrap(pVM, pRegFrame, 0x6, 0, TRPM_TRAP_NO_ERRORCODE, TRPM_TRAP, 0x6);
     446        rc = TRPMForwardTrap(pVCpu, pRegFrame, 0x6, 0, TRPM_TRAP_NO_ERRORCODE, TRPM_TRAP, 0x6);
    447447        Assert(rc == VINF_EM_RAW_GUEST_TRAP);
    448448    }
     
    463463 *          other codes are passed execution to host context.
    464464 *
    465  * @param   pTrpm       Pointer to TRPM data (within VM).
     465 * @param   pTrpmCpu    Pointer to TRPMCPU data (within VM).
    466466 * @param   pRegFrame   Pointer to the register frame for the trap.
    467467 * @internal
    468468 */
    469 DECLASM(int) TRPMGCTrap07Handler(PTRPM pTrpm, PCPUMCTXCORE pRegFrame)
     469DECLASM(int) TRPMGCTrap07Handler(PTRPMCPU pTrpmCpu, PCPUMCTXCORE pRegFrame)
    470470{
    471471    LogFlow(("TRPMGC07: %04x:%08x\n", pRegFrame->cs, pRegFrame->eip));
    472     PVM     pVM   = TRPM2VM(pTrpm);
     472    PVM     pVM   = TRPM2VM(pTrpmCpu);
    473473    PVMCPU  pVCpu = VMMGetCpu0(pVM);
    474474
     
    487487 *          other codes are passed execution to host context.
    488488 *
    489  * @param   pTrpm       Pointer to TRPM data (within VM).
     489 * @param   pTrpmCpu    Pointer to TRPMCPU data (within VM).
    490490 * @param   pRegFrame   Pointer to the register frame for the trap.
    491491 * @internal
    492492 */
    493 DECLASM(int) TRPMGCTrap0bHandler(PTRPM pTrpm, PCPUMCTXCORE pRegFrame)
     493DECLASM(int) TRPMGCTrap0bHandler(PTRPMCPU pTrpmCpu, PCPUMCTXCORE pRegFrame)
    494494{
    495495    LogFlow(("TRPMGC0b: %04x:%08x\n", pRegFrame->cs, pRegFrame->eip));
    496     PVM pVM = TRPM2VM(pTrpm);
     496    PVM pVM = TRPM2VM(pTrpmCpu);
    497497
    498498    /*
     
    564564             * starting from the instruction which caused the trap.
    565565             */
    566             pTrpm->uActiveVector = ~0;
     566            pTrpmCpu->uActiveVector = ~0;
    567567            Log6(("TRPMGC0b: %Rrc (%04x:%08x) (CG)\n", VINF_EM_RAW_RING_SWITCH, pRegFrame->cs, pRegFrame->eip));
    568568            return VINF_EM_RAW_RING_SWITCH;
     
    620620                }
    621621            }
    622             rc = TRPMForwardTrap(pVM, pRegFrame, (uint32_t)pCpu->param1.parval, pCpu->opsize, TRPM_TRAP_NO_ERRORCODE, TRPM_SOFTWARE_INT, 0xd);
     622            rc = TRPMForwardTrap(pVCpu, pRegFrame, (uint32_t)pCpu->param1.parval, pCpu->opsize, TRPM_TRAP_NO_ERRORCODE, TRPM_SOFTWARE_INT, 0xd);
    623623            if (RT_SUCCESS(rc) && rc != VINF_EM_RAW_GUEST_TRAP)
    624624                return trpmGCExitTrap(pVM, VINF_SUCCESS, pRegFrame);
    625625
    626             pVM->trpm.s.uActiveVector = (pVM->trpm.s.uActiveErrorCode & X86_TRAP_ERR_SEL_MASK) >> X86_TRAP_ERR_SEL_SHIFT;
    627             pVM->trpm.s.enmActiveType = TRPM_SOFTWARE_INT;
     626            pVCpu->trpm.s.uActiveVector = (pVCpu->trpm.s.uActiveErrorCode & X86_TRAP_ERR_SEL_MASK) >> X86_TRAP_ERR_SEL_SHIFT;
     627            pVCpu->trpm.s.enmActiveType = TRPM_SOFTWARE_INT;
    628628            return trpmGCExitTrap(pVM, VINF_EM_RAW_RING_SWITCH_INT, pRegFrame);
    629629        }
     
    716716        {
    717717            Assert(pCpu->param1.flags & USE_IMMEDIATE8);
    718             rc = TRPMForwardTrap(pVM, pRegFrame, (uint32_t)pCpu->param1.parval, pCpu->opsize, TRPM_TRAP_NO_ERRORCODE, TRPM_SOFTWARE_INT, 0xd);
     718            rc = TRPMForwardTrap(pVCpu, pRegFrame, (uint32_t)pCpu->param1.parval, pCpu->opsize, TRPM_TRAP_NO_ERRORCODE, TRPM_SOFTWARE_INT, 0xd);
    719719            if (RT_SUCCESS(rc) && rc != VINF_EM_RAW_GUEST_TRAP)
    720720                return trpmGCExitTrap(pVM, VINF_SUCCESS, pRegFrame);
    721721
    722             pVM->trpm.s.uActiveVector = (pVM->trpm.s.uActiveErrorCode & X86_TRAP_ERR_SEL_MASK) >> X86_TRAP_ERR_SEL_SHIFT;
    723             pVM->trpm.s.enmActiveType = TRPM_SOFTWARE_INT;
     722            pVCpu->trpm.s.uActiveVector = (pVCpu->trpm.s.uActiveErrorCode & X86_TRAP_ERR_SEL_MASK) >> X86_TRAP_ERR_SEL_SHIFT;
     723            pVCpu->trpm.s.enmActiveType = TRPM_SOFTWARE_INT;
    724724            return trpmGCExitTrap(pVM, VINF_EM_RAW_RING_SWITCH_INT, pRegFrame);
    725725        }
     
    738738        case OP_BOUND:
    739739        case OP_INTO:
    740             pVM->trpm.s.uActiveVector = ~0;
     740            pVCpu->trpm.s.uActiveVector = ~0;
    741741            return trpmGCExitTrap(pVM, VINF_EM_RAW_RING_SWITCH, pRegFrame);
    742742
     
    814814 *
    815815 * @param   pVM         The VM handle.
    816  * @param   pTrpm       Pointer to TRPM data (within VM).
    817  * @param   pRegFrame   Pointer to the register frame for the trap.
    818  */
    819 static int trpmGCTrap0dHandler(PVM pVM, PTRPM pTrpm, PCPUMCTXCORE pRegFrame)
     816 * @param   pTrpmCpu    Pointer to TRPMCPU data (within VM).
     817 * @param   pRegFrame   Pointer to the register frame for the trap.
     818 */
     819static int trpmGCTrap0dHandler(PVM pVM, PTRPMCPU pTrpmCpu, PCPUMCTXCORE pRegFrame)
    820820{
    821821    PVMCPU pVCpu = VMMGetCpu0(pVM);
    822822
    823     LogFlow(("trpmGCTrap0dHandler: cs:eip=%RTsel:%08RX32 uErr=%RGv\n", pRegFrame->ss, pRegFrame->eip, pTrpm->uActiveErrorCode));
     823    LogFlow(("trpmGCTrap0dHandler: cs:eip=%RTsel:%08RX32 uErr=%RGv\n", pRegFrame->ss, pRegFrame->eip, pTrpmCpu->uActiveErrorCode));
    824824
    825825    /*
     
    870870     * Deal with I/O port access.
    871871     */
    872     if (    pVM->trpm.s.uActiveErrorCode == 0
     872    if (    pVCpu->trpm.s.uActiveErrorCode == 0
    873873        &&  (Cpu.pCurInstr->optype & OPTYPE_PORTIO))
    874874    {
     
    905905        Assert(eflags.Bits.u2IOPL == 0);
    906906
    907         int rc = TRPMForwardTrap(pVM, pRegFrame, 0xD, 0, TRPM_TRAP_HAS_ERRORCODE, TRPM_TRAP, 0xd);
     907        int rc = TRPMForwardTrap(pVCpu, pRegFrame, 0xD, 0, TRPM_TRAP_HAS_ERRORCODE, TRPM_TRAP, 0xd);
    908908        Assert(rc == VINF_EM_RAW_GUEST_TRAP);
    909909        return trpmGCExitTrap(pVM, rc, pRegFrame);
     
    920920 *          other codes are passed execution to host context.
    921921 *
    922  * @param   pTrpm       Pointer to TRPM data (within VM).
     922 * @param   pTrpmCpu    Pointer to TRPMCPU data (within VM).
    923923 * @param   pRegFrame   Pointer to the register frame for the trap.
    924924 * @internal
    925925 */
    926 DECLASM(int) TRPMGCTrap0dHandler(PTRPM pTrpm, PCPUMCTXCORE pRegFrame)
    927 {
    928     LogFlow(("TRPMGC0d: %04x:%08x err=%x\n", pRegFrame->cs, pRegFrame->eip, (uint32_t)pTrpm->uActiveErrorCode));
    929     PVM pVM = TRPM2VM(pTrpm);
    930 
    931     int rc = trpmGCTrap0dHandler(pVM, pTrpm, pRegFrame);
     926DECLASM(int) TRPMGCTrap0dHandler(PTRPMCPU pTrpmCpu, PCPUMCTXCORE pRegFrame)
     927{
     928    PVM pVM = TRPM2VM(pTrpmCpu);
     929    PVMCPU pVCpu = VMMGetCpu0(pVM);
     930
     931    LogFlow(("TRPMGC0d: %04x:%08x err=%x\n", pRegFrame->cs, pRegFrame->eip, (uint32_t)pVCpu->trpm.s.uActiveErrorCode));
     932
     933    int rc = trpmGCTrap0dHandler(pVM, pTrpmCpu, pRegFrame);
    932934    switch (rc)
    933935    {
     
    939941
    940942        case VINF_EM_RAW_INTERRUPT_PENDING:
    941             Assert(TRPMHasTrap(pVM));
     943            Assert(TRPMHasTrap(pVCpu));
    942944            /* no break; */
    943945        case VINF_PGM_SYNC_CR3: /** @todo Check this with Sander. */
     
    976978 *          other codes are passed execution to host context.
    977979 *
    978  * @param   pTrpm       Pointer to TRPM data (within VM).
     980 * @param   pTrpmCpu    Pointer to TRPMCPU data (within VM).
    979981 * @param   pRegFrame   Pointer to the register frame for the trap.
    980982 * @internal
    981983 */
    982 DECLASM(int) TRPMGCTrap0eHandler(PTRPM pTrpm, PCPUMCTXCORE pRegFrame)
    983 {
    984     LogFlow(("TRPMGC0e: %04x:%08x err=%x cr2=%08x\n", pRegFrame->cs, pRegFrame->eip, (uint32_t)pTrpm->uActiveErrorCode, (uint32_t)pTrpm->uActiveCR2));
    985     PVM     pVM = TRPM2VM(pTrpm);
     984DECLASM(int) TRPMGCTrap0eHandler(PTRPMCPU pTrpmCpu, PCPUMCTXCORE pRegFrame)
     985{
     986    PVM     pVM = TRPM2VM(pTrpmCpu);
    986987    PVMCPU  pVCpu = VMMGetCpu0(pVM);
    987988
     989    LogFlow(("TRPMGC0e: %04x:%08x err=%x cr2=%08x\n", pRegFrame->cs, pRegFrame->eip, (uint32_t)pVCpu->trpm.s.uActiveErrorCode, (uint32_t)pVCpu->trpm.s.uActiveCR2));
    988990
    989991    /*
    990992     * This is all PGM stuff.
    991993     */
    992     int rc = PGMTrap0eHandler(pVCpu, pTrpm->uActiveErrorCode, pRegFrame, (RTGCPTR)pTrpm->uActiveCR2);
     994    int rc = PGMTrap0eHandler(pVCpu, pVCpu->trpm.s.uActiveErrorCode, pRegFrame, (RTGCPTR)pVCpu->trpm.s.uActiveCR2);
    993995    switch (rc)
    994996    {
     
    10071009                return VINF_PATM_PATCH_TRAP_PF;
    10081010
    1009             rc = TRPMForwardTrap(pVM, pRegFrame, 0xE, 0, TRPM_TRAP_HAS_ERRORCODE, TRPM_TRAP, 0xe);
     1011            rc = TRPMForwardTrap(pVCpu, pRegFrame, 0xE, 0, TRPM_TRAP_HAS_ERRORCODE, TRPM_TRAP, 0xe);
    10101012            Assert(rc == VINF_EM_RAW_GUEST_TRAP);
    10111013            break;
    10121014
    10131015        case VINF_EM_RAW_INTERRUPT_PENDING:
    1014             Assert(TRPMHasTrap(pVM));
     1016            Assert(TRPMHasTrap(pVCpu));
    10151017            /* no break; */
    10161018        case VINF_IOM_HC_MMIO_READ:
     
    10891091 *          other codes are passed back to host context.
    10901092 *
    1091  * @param   pTrpm       Pointer to TRPM data (within VM).
     1093 * @param   pTrpmCpu    Pointer to TRPMCPU data (within VM).
    10921094 * @param   pRegFrame   Pointer to the register frame for the trap.
    10931095 * @internal
    10941096 */
    1095 DECLASM(int) TRPMGCHyperTrap0bHandler(PTRPM pTrpm, PCPUMCTXCORE pRegFrame)
    1096 {
    1097     return trpmGCHyperGeneric(TRPM2VM(pTrpm), pRegFrame, g_aTrap0bHandlers, g_aTrap0bHandlersEnd);
     1097DECLASM(int) TRPMGCHyperTrap0bHandler(PTRPMCPU pTrpmCpu, PCPUMCTXCORE pRegFrame)
     1098{
     1099    return trpmGCHyperGeneric(TRPM2VM(pTrpmCpu), pRegFrame, g_aTrap0bHandlers, g_aTrap0bHandlersEnd);
    10981100}
    10991101
     
    11081110 *          other codes are passed back to host context.
    11091111 *
    1110  * @param   pTrpm       Pointer to TRPM data (within VM).
     1112 * @param   pTrpmCpu    Pointer to TRPMCPU data (within VM).
    11111113 * @param   pRegFrame   Pointer to the register frame for the trap.
    11121114 * @internal
    11131115 */
    1114 DECLASM(int) TRPMGCHyperTrap0dHandler(PTRPM pTrpm, PCPUMCTXCORE pRegFrame)
    1115 {
    1116     return trpmGCHyperGeneric(TRPM2VM(pTrpm), pRegFrame, g_aTrap0dHandlers, g_aTrap0dHandlersEnd);
     1116DECLASM(int) TRPMGCHyperTrap0dHandler(PTRPMCPU pTrpmCpu, PCPUMCTXCORE pRegFrame)
     1117{
     1118    return trpmGCHyperGeneric(TRPM2VM(pTrpmCpu), pRegFrame, g_aTrap0dHandlers, g_aTrap0dHandlersEnd);
    11171119}
    11181120
     
    11271129 *          other codes are passed back to host context.
    11281130 *
    1129  * @param   pTrpm       Pointer to TRPM data (within VM).
     1131 * @param   pTrpmCpu    Pointer to TRPMCPU data (within VM).
    11301132 * @param   pRegFrame   Pointer to the register frame for the trap.
    11311133 * @internal
    11321134 */
    1133 DECLASM(int) TRPMGCHyperTrap0eHandler(PTRPM pTrpm, PCPUMCTXCORE pRegFrame)
    1134 {
    1135     return trpmGCHyperGeneric(TRPM2VM(pTrpm), pRegFrame, g_aTrap0dHandlers, g_aTrap0dHandlersEnd);
     1135DECLASM(int) TRPMGCHyperTrap0eHandler(PTRPMCPU pTrpmCpu, PCPUMCTXCORE pRegFrame)
     1136{
     1137    return trpmGCHyperGeneric(TRPM2VM(pTrpmCpu), pRegFrame, g_aTrap0dHandlers, g_aTrap0dHandlersEnd);
    11361138}
    11371139
  • trunk/src/VBox/VMM/VMMGC/TRPMGCHandlersA.asm

    r18927 r19015  
    3737extern IMPNAME(g_CPUM)                  ; These IMPNAME(g_*) symbols resolve to the import table
    3838extern IMPNAME(g_TRPM)                  ; where there is a pointer to the real symbol. PE imports
    39 extern IMPNAME(g_VM)                    ; are a bit confusing at first... :-)
     39extern IMPNAME(g_TRPMCPU)               ; are a bit confusing at first... :-)
     40extern IMPNAME(g_VM)                   
    4041extern NAME(CPUMGCRestoreInt)
    4142extern NAME(cpumHandleLazyFPUAsm)
     
    338339    ; Store the information about the active trap/interrupt.
    339340    ;
    340     mov     eax, IMP(g_TRPM)
     341    mov     eax, IMP(g_TRPMCPU)
    341342    movzx   edx, byte [esp + 0h + ESPOFF]  ; vector number
    342     mov     [eax + TRPM.uActiveVector], edx
     343    mov     [eax + TRPMCPU.uActiveVector], edx
    343344    mov     edx, [esp + 4h + ESPOFF]       ; error code
    344     mov     [eax + TRPM.uActiveErrorCode], edx
    345     mov     dword [eax + TRPM.enmActiveType], TRPM_TRAP
     345    mov     [eax + TRPMCPU.uActiveErrorCode], edx
     346    mov     dword [eax + TRPMCPU.enmActiveType], TRPM_TRAP
    346347    mov     edx, cr2                       ;; @todo Check how expensive cr2 reads are!
    347     mov     dword [eax + TRPM.uActiveCR2], edx
     348    mov     dword [eax + TRPMCPU.uActiveCR2], edx
    348349
    349350%if GC_ARCH_BITS == 64
    350351    ; zero out the high dword
    351     mov     dword [eax + TRPM.uActiveErrorCode + 4], 0
    352     mov     dword [eax + TRPM.uActiveCR2 + 4], 0
     352    mov     dword [eax + TRPMCPU.uActiveErrorCode + 4], 0
     353    mov     dword [eax + TRPMCPU.uActiveCR2 + 4], 0
    353354%endif
    354355
     
    389390gt_HaveHandler:
    390391    push    esp                         ; Param 2 - CPUMCTXCORE pointer.
    391     push    dword IMP(g_TRPM)           ; Param 1 - Pointer to TRPM
     392    push    dword IMP(g_TRPMCPU)        ; Param 1 - Pointer to TRPMCPU
    392393    call    eax
    393394    add     esp, byte 8                 ; cleanup stack (cdecl)
     
    537538    ; Trap in Hypervisor, try to handle it.
    538539    ;
    539     ;   (eax = pTRPM)
     540    ;   (eax = pTRPMCPU)
    540541    ;
    541542ALIGNCODE(16)
     
    557558
    558559    ; check for temporary handler.
    559     movzx   ebx, byte [eax + TRPM.uActiveVector]
     560    movzx   ebx, byte [eax + TRPMCPU.uActiveVector]
     561    mov     eax, IMP(g_TRPM)
    560562    xor     ecx, ecx
    561563    xchg    ecx, [eax + TRPM.aTmpTrapHandlers + ebx * 4]    ; ecx = Temp handler pointer or 0
     
    826828    ; Store the information about the active trap/interrupt.
    827829    ;
    828     mov     eax, IMP(g_TRPM)
     830    mov     eax, IMP(g_TRPMCPU)
    829831    movzx   edx, byte [esp + 0h + ESPOFF]  ; vector number
    830     mov     [eax + TRPM.uActiveVector], edx
     832    mov     [eax + TRPMCPU.uActiveVector], edx
    831833    xor     edx, edx
    832     mov     dword [eax + TRPM.enmActiveType], TRPM_HARDWARE_INT
     834    mov     dword [eax + TRPMCPU.enmActiveType], TRPM_HARDWARE_INT
    833835    dec     edx
    834     mov     [eax + TRPM.uActiveErrorCode], edx
    835     mov     [eax + TRPM.uActiveCR2], edx
     836    mov     [eax + TRPMCPU.uActiveErrorCode], edx
     837    mov     [eax + TRPMCPU.uActiveCR2], edx
    836838%if GC_ARCH_BITS == 64
    837839    ; zero out the high dword
    838     mov     dword [eax + TRPM.uActiveErrorCode + 4], 0
    839     mov     dword [eax + TRPM.uActiveCR2 + 4], 0
     840    mov     dword [eax + TRPMCPU.uActiveErrorCode + 4], 0
     841    mov     dword [eax + TRPMCPU.uActiveCR2 + 4], 0
    840842%endif
    841843
     
    873875    ;
    874876    ; Reset TRPM state
    875     mov     eax, IMP(g_TRPM)
     877    mov     eax, IMP(g_TRPMCPU)
    876878    xor     edx, edx
    877879    dec     edx                         ; edx = 0ffffffffh
    878     xchg    [eax + TRPM.uActiveVector], edx
    879     mov     [eax + TRPM.uPrevVector], edx
     880    xchg    [eax + TRPMCPU.uActiveVector], edx
     881    mov     [eax + TRPMCPU.uPrevVector], edx
    880882
    881883    ; Enable WP
     
    925927    ;
    926928    ; Reset TRPM state - don't record this.
    927     mov     eax, IMP(g_TRPM)
    928     mov     dword [eax + TRPM.uActiveVector], 0ffffffffh
     929    mov     eax, IMP(g_TRPMCPU)
     930    mov     dword [eax + TRPMCPU.uActiveVector], 0ffffffffh
    929931
    930932    ;
  • trunk/src/VBox/VMM/VMMGC/VMMGCBuiltin.def

    r13813 r19015  
    2525    g_CPUM                          DATA
    2626    g_TRPM                          DATA
     27    g_TRPMCPU                       DATA
    2728    g_Logger                        DATA
    2829    g_RelLogger                     DATA
  • trunk/src/VBox/VMM/VMMGuruMeditation.cpp

    r18927 r19015  
    265265            RTGCUINT        uErrorCode = 0xdeadface;
    266266            RTGCUINTPTR     uCR2       = 0xdeadface;
    267             int rc2 = TRPMQueryTrapAll(pVM, &u8TrapNo, &enmType, &uErrorCode, &uCR2);
     267            int rc2 = TRPMQueryTrapAll(pVCpu, &u8TrapNo, &enmType, &uErrorCode, &uCR2);
    268268            if (!HWACCMR3IsActive(pVM))
    269269            {
  • trunk/src/VBox/VMM/VMMR0/HWSVMR0.cpp

    r18992 r19015  
    427427
    428428    /* When external interrupts are pending, we should exit the VM when IF is set. */
    429     if (    !TRPMHasTrap(pVM)
     429    if (    !TRPMHasTrap(pVCpu)
    430430        &&  VM_FF_ISPENDING(pVM, (VM_FF_INTERRUPT_APIC|VM_FF_INTERRUPT_PIC)))
    431431    {
     
    454454            if (RT_SUCCESS(rc))
    455455            {
    456                 rc = TRPMAssertTrap(pVM, u8Interrupt, TRPM_HARDWARE_INT);
     456                rc = TRPMAssertTrap(pVCpu, u8Interrupt, TRPM_HARDWARE_INT);
    457457                AssertRC(rc);
    458458            }
     
    468468
    469469#ifdef VBOX_STRICT
    470     if (TRPMHasTrap(pVM))
     470    if (TRPMHasTrap(pVCpu))
    471471    {
    472472        uint8_t     u8Vector;
    473         rc = TRPMQueryTrapAll(pVM, &u8Vector, 0, 0, 0);
     473        rc = TRPMQueryTrapAll(pVCpu, &u8Vector, 0, 0, 0);
    474474        AssertRC(rc);
    475475    }
     
    478478    if (    pCtx->eflags.u32 & X86_EFL_IF
    479479        && (!VM_FF_ISSET(pVM, VM_FF_INHIBIT_INTERRUPTS))
    480         && TRPMHasTrap(pVM)
     480        && TRPMHasTrap(pVCpu)
    481481       )
    482482    {
     
    490490
    491491        /* If a new event is pending, then dispatch it now. */
    492         rc = TRPMQueryTrapAll(pVM, &u8Vector, &enmType, &u32ErrorCode, 0);
     492        rc = TRPMQueryTrapAll(pVCpu, &u8Vector, &enmType, &u32ErrorCode, 0);
    493493        AssertRC(rc);
    494494        Assert(pCtx->eflags.Bits.u1IF == 1 || enmType == TRPM_TRAP);
     
    496496
    497497        /* Clear the pending trap. */
    498         rc = TRPMResetTrap(pVM);
     498        rc = TRPMResetTrap(pVCpu);
    499499        AssertRC(rc);
    500500
     
    14081408            Log2(("Page fault at %RGv cr2=%RGv error code %x\n", (RTGCPTR)pCtx->rip, uFaultAddress, errCode));
    14091409            /* Exit qualification contains the linear address of the page fault. */
    1410             TRPMAssertTrap(pVM, X86_XCPT_PF, TRPM_TRAP);
    1411             TRPMSetErrorCode(pVM, errCode);
    1412             TRPMSetFaultAddress(pVM, uFaultAddress);
     1410            TRPMAssertTrap(pVCpu, X86_XCPT_PF, TRPM_TRAP);
     1411            TRPMSetErrorCode(pVCpu, errCode);
     1412            TRPMSetFaultAddress(pVCpu, uFaultAddress);
    14131413
    14141414            /* Forward it to our trap handler first, in case our shadow pages are out of sync. */
     
    14201420                STAM_COUNTER_INC(&pVCpu->hwaccm.s.StatExitShadowPF);
    14211421
    1422                 TRPMResetTrap(pVM);
     1422                TRPMResetTrap(pVCpu);
    14231423
    14241424                STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatExit1, x);
     
    14331433                STAM_COUNTER_INC(&pVCpu->hwaccm.s.StatExitGuestPF);
    14341434                /* The error code might have been changed. */
    1435                 errCode = TRPMGetErrorCode(pVM);
    1436 
    1437                 TRPMResetTrap(pVM);
     1435                errCode = TRPMGetErrorCode(pVCpu);
     1436
     1437                TRPMResetTrap(pVCpu);
    14381438
    14391439                /* Now we must update CR2. */
     
    14571457#endif
    14581458            /* Need to go back to the recompiler to emulate the instruction. */
    1459             TRPMResetTrap(pVM);
     1459            TRPMResetTrap(pVCpu);
    14601460            break;
    14611461        }
     
    15461546        Log(("Nested page fault at %RGv cr2=%RGp error code %x\n", (RTGCPTR)pCtx->rip, uFaultAddress, errCode));
    15471547        /* Exit qualification contains the linear address of the page fault. */
    1548         TRPMAssertTrap(pVM, X86_XCPT_PF, TRPM_TRAP);
    1549         TRPMSetErrorCode(pVM, errCode);
    1550         TRPMSetFaultAddress(pVM, uFaultAddress);
     1548        TRPMAssertTrap(pVCpu, X86_XCPT_PF, TRPM_TRAP);
     1549        TRPMSetErrorCode(pVCpu, errCode);
     1550        TRPMSetFaultAddress(pVCpu, uFaultAddress);
    15511551
    15521552        /* Handle the pagefault trap for the nested shadow table. */
     
    15651565            STAM_COUNTER_INC(&pVCpu->hwaccm.s.StatExitShadowPF);
    15661566
    1567             TRPMResetTrap(pVM);
     1567            TRPMResetTrap(pVCpu);
    15681568
    15691569            STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatExit1, x);
     
    15761576#endif
    15771577        /* Need to go back to the recompiler to emulate the instruction. */
    1578         TRPMResetTrap(pVM);
     1578        TRPMResetTrap(pVCpu);
    15791579        break;
    15801580    }
  • trunk/src/VBox/VMM/VMMR0/HWVMXR0.cpp

    r18992 r19015  
    736736
    737737    /* When external interrupts are pending, we should exit the VM when IF is set. */
    738     if (    !TRPMHasTrap(pVM)
     738    if (    !TRPMHasTrap(pVCpu)
    739739        &&  VM_FF_ISPENDING(pVM, (VM_FF_INTERRUPT_APIC|VM_FF_INTERRUPT_PIC)))
    740740    {
     
    759759            if (RT_SUCCESS(rc))
    760760            {
    761                 rc = TRPMAssertTrap(pVM, u8Interrupt, TRPM_HARDWARE_INT);
     761                rc = TRPMAssertTrap(pVCpu, u8Interrupt, TRPM_HARDWARE_INT);
    762762                AssertRC(rc);
    763763            }
     
    775775
    776776#ifdef VBOX_STRICT
    777     if (TRPMHasTrap(pVM))
     777    if (TRPMHasTrap(pVCpu))
    778778    {
    779779        uint8_t     u8Vector;
    780         rc = TRPMQueryTrapAll(pVM, &u8Vector, 0, 0, 0);
     780        rc = TRPMQueryTrapAll(pVCpu, &u8Vector, 0, 0, 0);
    781781        AssertRC(rc);
    782782    }
     
    785785    if (    pCtx->eflags.u32 & X86_EFL_IF
    786786        && (!VM_FF_ISSET(pVM, VM_FF_INHIBIT_INTERRUPTS))
    787         && TRPMHasTrap(pVM)
     787        && TRPMHasTrap(pVCpu)
    788788       )
    789789    {
     
    795795
    796796        /* If a new event is pending, then dispatch it now. */
    797         rc = TRPMQueryTrapAll(pVM, &u8Vector, &enmType, &errCode, 0);
     797        rc = TRPMQueryTrapAll(pVCpu, &u8Vector, &enmType, &errCode, 0);
    798798        AssertRC(rc);
    799799        Assert(pCtx->eflags.Bits.u1IF == 1 || enmType == TRPM_TRAP);
     
    801801
    802802        /* Clear the pending trap. */
    803         rc = TRPMResetTrap(pVM);
     803        rc = TRPMResetTrap(pVCpu);
    804804        AssertRC(rc);
    805805
     
    23842384                Log2(("Page fault at %RGv error code %x\n", exitQualification, errCode));
    23852385                /* Exit qualification contains the linear address of the page fault. */
    2386                 TRPMAssertTrap(pVM, X86_XCPT_PF, TRPM_TRAP);
    2387                 TRPMSetErrorCode(pVM, errCode);
    2388                 TRPMSetFaultAddress(pVM, exitQualification);
     2386                TRPMAssertTrap(pVCpu, X86_XCPT_PF, TRPM_TRAP);
     2387                TRPMSetErrorCode(pVCpu, errCode);
     2388                TRPMSetFaultAddress(pVCpu, exitQualification);
    23892389
    23902390                /* Forward it to our trap handler first, in case our shadow pages are out of sync. */
     
    23962396                    STAM_COUNTER_INC(&pVCpu->hwaccm.s.StatExitShadowPF);
    23972397
    2398                     TRPMResetTrap(pVM);
     2398                    TRPMResetTrap(pVCpu);
    23992399
    24002400                    STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatExit2Sub3, y3);
     
    24102410                    STAM_COUNTER_INC(&pVCpu->hwaccm.s.StatExitGuestPF);
    24112411                    /* The error code might have been changed. */
    2412                     errCode = TRPMGetErrorCode(pVM);
    2413 
    2414                     TRPMResetTrap(pVM);
     2412                    errCode = TRPMGetErrorCode(pVCpu);
     2413
     2414                    TRPMResetTrap(pVCpu);
    24152415
    24162416                    /* Now we must update CR2. */
     
    24272427#endif
    24282428                /* Need to go back to the recompiler to emulate the instruction. */
    2429                 TRPMResetTrap(pVM);
     2429                TRPMResetTrap(pVCpu);
    24302430                break;
    24312431            }
     
    28492849
    28502850        /* GCPhys contains the guest physical address of the page fault. */
    2851         TRPMAssertTrap(pVM, X86_XCPT_PF, TRPM_TRAP);
    2852         TRPMSetErrorCode(pVM, errCode);
    2853         TRPMSetFaultAddress(pVM, GCPhys);
     2851        TRPMAssertTrap(pVCpu, X86_XCPT_PF, TRPM_TRAP);
     2852        TRPMSetErrorCode(pVCpu, errCode);
     2853        TRPMSetFaultAddress(pVCpu, GCPhys);
    28542854
    28552855        /* Handle the pagefault trap for the nested shadow table. */
     
    28612861            STAM_COUNTER_INC(&pVCpu->hwaccm.s.StatExitReasonNPF);
    28622862
    2863             TRPMResetTrap(pVM);
     2863            TRPMResetTrap(pVCpu);
    28642864
    28652865            goto ResumeExecution;
     
    28712871#endif
    28722872        /* Need to go back to the recompiler to emulate the instruction. */
    2873         TRPMResetTrap(pVM);
     2873        TRPMResetTrap(pVCpu);
    28742874        break;
    28752875    }
  • trunk/src/VBox/VMM/VMMR0/TRPMR0.cpp

    r15414 r19015  
    2828#include "TRPMInternal.h"
    2929#include <VBox/vm.h>
     30#include <VBox/vmm.h>
    3031#include <VBox/err.h>
    3132#include <VBox/log.h>
     
    4243VMMR0DECL(void) TRPMR0DispatchHostInterrupt(PVM pVM)
    4344{
    44     RTUINT uActiveVector = pVM->trpm.s.uActiveVector;
    45     pVM->trpm.s.uActiveVector = ~0;
     45    PVMCPU pVCpu = VMMGetCpu0(pVM);
     46    RTUINT uActiveVector = pVCpu->trpm.s.uActiveVector;
     47
     48    pVCpu->trpm.s.uActiveVector = ~0;
    4649    AssertMsgReturnVoid(uActiveVector < 256, ("uActiveVector=%#x is invalid! (More assertions to come, please enjoy!)\n", uActiveVector));
    4750
  • trunk/src/VBox/VMM/VMMTests.cpp

    r18992 r19015  
    127127             &&  u8Trap != 3 /* guest only, we're not in guest. */
    128128             &&  u8Trap != 1 /* guest only, we're not in guest. */
    129              &&  u8Trap != TRPMGetTrapNo(pVM))
    130     {
    131         RTPrintf("VMM: FAILURE - Trap %#x expected %#x\n", TRPMGetTrapNo(pVM), u8Trap);
     129             &&  u8Trap != TRPMGetTrapNo(pVCpu))
     130    {
     131        RTPrintf("VMM: FAILURE - Trap %#x expected %#x\n", TRPMGetTrapNo(pVCpu), u8Trap);
    132132        fDump = true;
    133133    }
  • trunk/src/VBox/VMM/testcase/tstVMStructGC.cpp

    r18984 r19015  
    853853
    854854    GEN_CHECK_SIZE(TRPM); // has .mac
     855    GEN_CHECK_SIZE(TRPMCPU); // has .mac
    855856    GEN_CHECK_SIZE(VM);  // has .mac
    856857    GEN_CHECK_SIZE(VMM);
  • trunk/src/VBox/VMM/testcase/tstVMStructSize.cpp

    r18927 r19015  
    160160    CHECK_PADDING_VMCPU(em);
    161161    CHECK_PADDING_VMCPU(hwaccm);
     162    CHECK_PADDING_VMCPU(trpm);
    162163    CHECK_PADDING_VMCPU(tm);
    163164    CHECK_PADDING_VMCPU(vmm);
  • trunk/src/recompiler_new/VBoxREMWrapper.cpp

    r18992 r19015  
    910910static const REMPARMDESC g_aArgsTRPMAssertTrap[] =
    911911{
    912     { REMPARMDESC_FLAGS_INT,        sizeof(PVM), NULL },
     912    { REMPARMDESC_FLAGS_INT,        sizeof(PVMCPU), NULL },
    913913    { REMPARMDESC_FLAGS_INT,        sizeof(uint8_t), NULL },
    914914    { REMPARMDESC_FLAGS_INT,        sizeof(TRPMEVENT), NULL }
     
    916916static const REMPARMDESC g_aArgsTRPMQueryTrap[] =
    917917{
    918     { REMPARMDESC_FLAGS_INT,        sizeof(PVM), NULL },
     918    { REMPARMDESC_FLAGS_INT,        sizeof(PVMCPU), NULL },
    919919    { REMPARMDESC_FLAGS_INT,        sizeof(uint8_t *), NULL },
    920920    { REMPARMDESC_FLAGS_INT,        sizeof(TRPMEVENT *), NULL }
     
    922922static const REMPARMDESC g_aArgsTRPMSetErrorCode[] =
    923923{
    924     { REMPARMDESC_FLAGS_INT,        sizeof(PVM), NULL },
     924    { REMPARMDESC_FLAGS_INT,        sizeof(PVMCPU), NULL },
    925925    { REMPARMDESC_FLAGS_GCPTR,      sizeof(RTGCUINT), NULL }
    926926};
    927927static const REMPARMDESC g_aArgsTRPMSetFaultAddress[] =
    928928{
    929     { REMPARMDESC_FLAGS_INT,        sizeof(PVM), NULL },
     929    { REMPARMDESC_FLAGS_INT,        sizeof(PVMCPU), NULL },
    930930    { REMPARMDESC_FLAGS_GCPTR,      sizeof(RTGCUINT), NULL }
    931931};
  • trunk/src/recompiler_new/VBoxRecompiler.c

    r18992 r19015  
    21152115     */
    21162116    pVM->rem.s.Env.exception_index = -1; /** @todo this won't work :/ */
    2117     rc = TRPMQueryTrap(pVM, &u8TrapNo, &enmType);
     2117    rc = TRPMQueryTrap(pVCpu, &u8TrapNo, &enmType);
    21182118    if (RT_SUCCESS(rc))
    21192119    {
     
    21592159        {
    21602160            case 0x0e:
    2161                 pVM->rem.s.Env.cr[2] = TRPMGetFaultAddress(pVM);
     2161                pVM->rem.s.Env.cr[2] = TRPMGetFaultAddress(pVCpu);
    21622162                /* fallthru */
    21632163            case 0x0a: case 0x0b: case 0x0c: case 0x0d:
    2164                 pVM->rem.s.Env.error_code = TRPMGetErrorCode(pVM);
     2164                pVM->rem.s.Env.error_code = TRPMGetErrorCode(pVCpu);
    21652165                break;
    21662166
     
    21742174         * We can now reset the active trap since the recompiler is gonna have a go at it.
    21752175         */
    2176         rc = TRPMResetTrap(pVM);
     2176        rc = TRPMResetTrap(pVCpu);
    21772177        AssertRC(rc);
    21782178        Log2(("REMR3State: trap=%02x errcd=%RGv cr2=%RGv nexteip=%RGv%s\n", pVM->rem.s.Env.exception_index, (RTGCPTR)pVM->rem.s.Env.error_code,
     
    24252425
    24262426        Log(("REMR3StateBack: Pending trap %x %d\n", pVM->rem.s.Env.exception_index, pVM->rem.s.Env.exception_is_int));
    2427         rc = TRPMAssertTrap(pVM, pVM->rem.s.Env.exception_index, (pVM->rem.s.Env.exception_is_int) ? TRPM_SOFTWARE_INT : TRPM_HARDWARE_INT);
     2427        rc = TRPMAssertTrap(pVCpu, pVM->rem.s.Env.exception_index, (pVM->rem.s.Env.exception_is_int) ? TRPM_SOFTWARE_INT : TRPM_HARDWARE_INT);
    24282428        AssertRC(rc);
    24292429        switch (pVM->rem.s.Env.exception_index)
    24302430        {
    24312431            case 0x0e:
    2432                 TRPMSetFaultAddress(pVM, pCtx->cr2);
     2432                TRPMSetFaultAddress(pVCpu, pCtx->cr2);
    24332433                /* fallthru */
    24342434            case 0x0a: case 0x0b: case 0x0c: case 0x0d:
    24352435            case 0x11: case 0x08: /* 0 */
    2436                 TRPMSetErrorCode(pVM, pVM->rem.s.Env.error_code);
     2436                TRPMSetErrorCode(pVCpu, pVM->rem.s.Env.error_code);
    24372437                break;
    24382438        }
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

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