VirtualBox

Changeset 13883

Show
Ignore:
Timestamp:
11/05/08 18:04:48 (2 months ago)
Author:
vboxsync
Message:

Moved more data around.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/include/VBox/hwacc_svm.h

    r12989 r13883  
    697697 
    698698#ifdef IN_RING0 
    699 VMMR0DECL(int) SVMR0InvalidatePage(PVM pVM, RTGCPTR GCVirt); 
    700 VMMR0DECL(int) SVMR0InvalidatePhysPage(PVM pVM, RTGCPHYS GCPhys); 
     699VMMR0DECL(int) SVMR0InvalidatePage(PVM pVM, PVMCPU pVCpu, RTGCPTR GCVirt); 
     700VMMR0DECL(int) SVMR0InvalidatePhysPage(PVM pVM, PVMCPU pVCpu, RTGCPHYS GCPhys); 
    701701#endif /* IN_RING0 */ 
    702702 
  • trunk/include/VBox/hwacc_vmx.h

    r13718 r13883  
    15541554 
    15551555#ifdef IN_RING0 
    1556 VMMR0DECL(int) VMXR0InvalidatePage(PVM pVM, RTGCPTR GCVirt); 
    1557 VMMR0DECL(int) VMXR0InvalidatePhysPage(PVM pVM, RTGCPHYS GCPhys); 
     1556VMMR0DECL(int) VMXR0InvalidatePage(PVM pVM, PVMCPU pVCpu, RTGCPTR GCVirt); 
     1557VMMR0DECL(int) VMXR0InvalidatePhysPage(PVM pVM, PVMCPU pVCpu, RTGCPHYS GCPhys); 
    15581558#endif /* IN_RING0 */ 
    15591559 
  • trunk/src/VBox/VMM/HWACCM.cpp

    r13879 r13883  
    103103    pVM->hwaccm.s.fActive        = false; 
    104104    pVM->hwaccm.s.fNestedPaging  = false; 
    105  
    106     /* On first entry we'll sync everything. */ 
    107     pVM->hwaccm.s.fContextUseFlags = HWACCM_CHANGED_ALL; 
    108105 
    109106    /* 
     
    874871        hwaccmR3DisableRawMode(pVM); 
    875872 
    876     /* On first entry we'll sync everything. */ 
    877     pVM->hwaccm.s.fContextUseFlags = HWACCM_CHANGED_ALL; 
    878  
    879873    for (unsigned i=0;i<pVM->cCPUs;i++) 
    880874    { 
     875        /* On first entry we'll sync everything. */ 
     876        pVM->aCpus[i].hwaccm.s.fContextUseFlags = HWACCM_CHANGED_ALL; 
     877 
    881878        pVM->aCpus[i].hwaccm.s.vmx.cr0_mask = 0; 
    882879        pVM->aCpus[i].hwaccm.s.vmx.cr4_mask = 0; 
    883     } 
    884  
    885     pVM->hwaccm.s.Event.fPending = false; 
     880 
     881        pVM->aCpus[i].hwaccm.s.Event.fPending = false; 
     882    } 
    886883 
    887884    /* Reset state information for real-mode emulation in VT-x. */ 
     
    10501047VMMR3DECL(bool) HWACCMR3IsEventPending(PVM pVM) 
    10511048{ 
    1052     return HWACCMIsEnabled(pVM) && pVM->hwaccm.s.Event.fPending; 
     1049    /* @todo SMP */ 
     1050    return HWACCMIsEnabled(pVM) && pVM->aCpus[0].hwaccm.s.Event.fPending; 
    10531051} 
    10541052 
     
    10701068 
    10711069        case VERR_VMX_INVALID_VMCS_PTR: 
    1072             LogRel(("VERR_VMX_INVALID_VMCS_PTR: CPU%d Current pointer %RGp vs %RGp\n", i, pVM->hwaccm.s.vmx.lasterror.u64VMCSPhys, pVM->aCpus[i].hwaccm.s.vmx.pVMCSPhys)); 
    1073             LogRel(("VERR_VMX_INVALID_VMCS_PTR: CPU%d Current VMCS version %x\n", i, pVM->hwaccm.s.vmx.lasterror.ulVMCSRevision)); 
     1070            LogRel(("VERR_VMX_INVALID_VMCS_PTR: CPU%d Current pointer %RGp vs %RGp\n", i, pVM->aCpus[i].hwaccm.s.vmx.lasterror.u64VMCSPhys, pVM->aCpus[i].hwaccm.s.vmx.pVMCSPhys)); 
     1071            LogRel(("VERR_VMX_INVALID_VMCS_PTR: CPU%d Current VMCS version %x\n", i, pVM->aCpus[i].hwaccm.s.vmx.lasterror.ulVMCSRevision)); 
    10741072            break; 
    10751073 
    10761074        case VERR_VMX_UNABLE_TO_START_VM: 
    1077             LogRel(("VERR_VMX_UNABLE_TO_START_VM: CPU%d instruction error %x\n", i, pVM->hwaccm.s.vmx.lasterror.ulLastInstrError)); 
    1078             LogRel(("VERR_VMX_UNABLE_TO_START_VM: CPU%d exit reason       %x\n", i, pVM->hwaccm.s.vmx.lasterror.ulLastExitReason)); 
     1075            LogRel(("VERR_VMX_UNABLE_TO_START_VM: CPU%d instruction error %x\n", i, pVM->aCpus[i].hwaccm.s.vmx.lasterror.ulLastInstrError)); 
     1076            LogRel(("VERR_VMX_UNABLE_TO_START_VM: CPU%d exit reason       %x\n", i, pVM->aCpus[i].hwaccm.s.vmx.lasterror.ulLastExitReason)); 
    10791077            break; 
    10801078 
    10811079        case VERR_VMX_UNABLE_TO_RESUME_VM: 
    1082             LogRel(("VERR_VMX_UNABLE_TO_RESUME_VM: CPU%d instruction error %x\n", i, pVM->hwaccm.s.vmx.lasterror.ulLastInstrError)); 
    1083             LogRel(("VERR_VMX_UNABLE_TO_RESUME_VM: CPU%d exit reason       %x\n", i, pVM->hwaccm.s.vmx.lasterror.ulLastExitReason)); 
     1080            LogRel(("VERR_VMX_UNABLE_TO_RESUME_VM: CPU%d instruction error %x\n", i, pVM->aCpus[i].hwaccm.s.vmx.lasterror.ulLastInstrError)); 
     1081            LogRel(("VERR_VMX_UNABLE_TO_RESUME_VM: CPU%d exit reason       %x\n", i, pVM->aCpus[i].hwaccm.s.vmx.lasterror.ulLastExitReason)); 
    10841082            break; 
    10851083 
     
    11031101    Log(("hwaccmR3Save:\n")); 
    11041102 
    1105     /* 
    1106      * Save the basic bits - fortunately all the other things can be resynced on load. 
    1107      */ 
    1108     rc = SSMR3PutU32(pSSM, pVM->hwaccm.s.Event.fPending); 
    1109     AssertRCReturn(rc, rc); 
    1110     rc = SSMR3PutU32(pSSM, pVM->hwaccm.s.Event.errCode); 
    1111     AssertRCReturn(rc, rc); 
    1112     rc = SSMR3PutU64(pSSM, pVM->hwaccm.s.Event.intInfo); 
    1113     AssertRCReturn(rc, rc); 
     1103    for (unsigned i=0;i<pVM->cCPUs;i++) 
     1104    { 
     1105        /* 
     1106         * Save the basic bits - fortunately all the other things can be resynced on load. 
     1107         */ 
     1108        rc = SSMR3PutU32(pSSM, pVM->aCpus[i].hwaccm.s.Event.fPending); 
     1109        AssertRCReturn(rc, rc); 
     1110        rc = SSMR3PutU32(pSSM, pVM->aCpus[i].hwaccm.s.Event.errCode); 
     1111        AssertRCReturn(rc, rc); 
     1112        rc = SSMR3PutU64(pSSM, pVM->aCpus[i].hwaccm.s.Event.intInfo); 
     1113        AssertRCReturn(rc, rc); 
     1114    } 
    11141115 
    11151116    return VINF_SUCCESS; 
     
    11381139        return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION; 
    11391140    } 
    1140     rc = SSMR3GetU32(pSSM, &pVM->hwaccm.s.Event.fPending); 
    1141     AssertRCReturn(rc, rc); 
    1142     rc = SSMR3GetU32(pSSM, &pVM->hwaccm.s.Event.errCode); 
    1143     AssertRCReturn(rc, rc); 
    1144     rc = SSMR3GetU64(pSSM, &pVM->hwaccm.s.Event.intInfo); 
    1145     AssertRCReturn(rc, rc); 
    1146  
     1141    for (unsigned i=0;i<pVM->cCPUs;i++) 
     1142    { 
     1143        rc = SSMR3GetU32(pSSM, &pVM->aCpus[i].hwaccm.s.Event.fPending); 
     1144        AssertRCReturn(rc, rc); 
     1145        rc = SSMR3GetU32(pSSM, &pVM->aCpus[i].hwaccm.s.Event.errCode); 
     1146        AssertRCReturn(rc, rc); 
     1147        rc = SSMR3GetU64(pSSM, &pVM->aCpus[i].hwaccm.s.Event.intInfo); 
     1148        AssertRCReturn(rc, rc); 
     1149    } 
    11471150    return VINF_SUCCESS; 
    11481151} 
  • trunk/src/VBox/VMM/HWACCMInternal.h

    r13880 r13883  
    188188    bool                        fAllowVPID; 
    189189 
    190     /** Set if we need to flush the TLB during the world switch. */ 
    191     bool                        fForceTLBFlush; 
    192  
    193     /** Old style FPU reporting trap mask override performed (optimization) */ 
    194     bool                        fFPUOldStyleOverride; 
    195  
    196190    /** Explicit alignment padding to make 32-bit gcc align u64RegisterMask 
    197191     *  naturally. */ 
    198192    bool                        padding[1]; 
    199193 
    200     /** HWACCM_CHANGED_* flags. */ 
    201     RTUINT                      fContextUseFlags; 
    202  
    203     /* Id of the last cpu we were executing code on (NIL_RTCPUID for the first time) */ 
    204     RTCPUID                     idLastCpu; 
    205  
    206     /* TLB flush count */ 
    207     RTUINT                      cTLBFlushes; 
    208  
    209     /* Current ASID in use by the VM */ 
    210     RTUINT                      uCurrentASID; 
    211  
    212194    /** Maximum ASID allowed. */ 
    213195    RTUINT                      uMaxASID; 
     
    222204        /** Set when we've enabled VMX. */ 
    223205        bool                        fEnabled; 
    224  
    225         /** Set if we can use VMXResume to execute guest code. */ 
    226         bool                        fResumeVM; 
    227206 
    228207        /** Set if VPID is supported. */ 
     
    271250 
    272251        /** Ring 0 handlers for VT-x. */ 
    273         DECLR0CALLBACKMEMBER(void, pfnSetupTaggedTLB, (PVM pVM)); 
     252        DECLR0CALLBACKMEMBER(void, pfnSetupTaggedTLB, (PVM pVM, PVMCPU pVCpu)); 
    274253 
    275254        /** Host CR4 value (set by ring-0 VMX init) */ 
     
    304283        VMX_FLUSH                   enmFlushPage; 
    305284        VMX_FLUSH                   enmFlushContext; 
    306  
    307         /** Real-mode emulation state. */ 
    308         struct 
    309         { 
    310             X86EFLAGS                   eflags; 
    311             uint32_t                    fValid; 
    312         } RealMode; 
    313  
    314         struct 
    315         { 
    316             uint64_t                u64VMCSPhys; 
    317             uint32_t                ulVMCSRevision; 
    318             uint32_t                ulLastInstrError; 
    319             uint32_t                ulLastExitReason; 
    320             uint32_t                padding; 
    321         } lasterror; 
    322285    } vmx; 
    323286 
     
    328291        /** Set when we've enabled SVM. */ 
    329292        bool                        fEnabled; 
    330         /** Set if we don't have to flush the TLB on VM entry. */ 
    331         bool                        fResumeVM; 
    332293        /** Set if erratum 170 affects the AMD cpu. */ 
    333294        bool                        fAlwaysFlushTLB; 
     295        /** Explicit alignment padding to make 32-bit gcc align u64RegisterMask 
     296         *  naturally. */ 
     297        bool                        padding[1]; 
    334298 
    335299        /** R0 memory object for the host VM control block (VMCB). */ 
     
    366330        uint32_t                    u32AMDFeatureEDX; 
    367331    } cpuid; 
    368  
    369 #if HC_ARCH_BITS == 32 
    370     uint32_t                        Alignment1; 
    371 #endif 
    372  
    373     /** Event injection state. */ 
    374     struct 
    375     { 
    376         uint32_t                    fPending; 
    377         uint32_t                    errCode; 
    378         uint64_t                    intInfo; 
    379     } Event; 
    380332 
    381333    /** Saved error from detection */ 
     
    469421typedef struct HWACCMCPU 
    470422{ 
    471     /** Offset to the VM structure. 
    472      * See HWACCMCPU2VM(). */ 
    473     RTUINT                      offVMCPU; 
     423    /** Old style FPU reporting trap mask override performed (optimization) */ 
     424    bool                        fFPUOldStyleOverride; 
     425 
     426    /** Set if we don't have to flush the TLB on VM entry. */ 
     427    bool                        fResumeVM; 
     428 
     429    /** Set if we need to flush the TLB during the world switch. */ 
     430    bool                        fForceTLBFlush; 
     431 
     432    /** Explicit alignment padding to make 32-bit gcc align u64RegisterMask 
     433     *  naturally. */ 
     434    bool                        padding[1]; 
     435 
     436    /** HWACCM_CHANGED_* flags. */ 
     437    RTUINT                      fContextUseFlags; 
     438 
     439    /* Id of the last cpu we were executing code on (NIL_RTCPUID for the first time) */ 
     440    RTCPUID                     idLastCpu; 
     441 
     442    /* TLB flush count */ 
     443    RTUINT                      cTLBFlushes; 
     444 
     445    /* Current ASID in use by the VM */ 
     446    RTUINT                      uCurrentASID; 
    474447 
    475448    struct 
     
    495468        /** Current EPTP. */ 
    496469        RTHCPHYS                    GCPhysEPTP; 
     470 
     471        /** Real-mode emulation state. */ 
     472        struct 
     473        { 
     474            X86EFLAGS                   eflags; 
     475            uint32_t                    fValid; 
     476        } RealMode; 
     477 
     478        struct 
     479        { 
     480            uint64_t                u64VMCSPhys; 
     481            uint32_t                ulVMCSRevision; 
     482            uint32_t                ulLastInstrError; 
     483            uint32_t                ulLastExitReason; 
     484            uint32_t                padding; 
     485        } lasterror; 
     486 
    497487    } vmx; 
    498488 
     
    510500 
    511501    } svm; 
     502 
     503    /** Event injection state. */ 
     504    struct 
     505    { 
     506        uint32_t                    fPending; 
     507        uint32_t                    errCode; 
     508        uint64_t                    intInfo; 
     509    } Event; 
    512510 
    513511} HWACCMCPU; 
  • trunk/src/VBox/VMM/VMMAll/HWACCMAll.cpp

    r13832 r13883  
    5454{ 
    5555#ifdef IN_RING0 
     56    PVMCPU pVCpu = &pVM->aCpus[HWACCMGetVMCPUId(pVM)]; 
    5657    if (pVM->hwaccm.s.vmx.fSupported) 
    57         return VMXR0InvalidatePage(pVM, GCVirt); 
     58        return VMXR0InvalidatePage(pVM, pVCpu, GCVirt); 
    5859 
    5960    Assert(pVM->hwaccm.s.svm.fSupported); 
    60     return SVMR0InvalidatePage(pVM, GCVirt); 
     61    return SVMR0InvalidatePage(pVM, pVCpu, GCVirt); 
    6162#endif 
    6263 
     
    7475    LogFlow(("HWACCMFlushTLB\n")); 
    7576 
    76     pVM->hwaccm.s.fForceTLBFlush = true; 
     77    pVM->aCpus[HWACCMGetVMCPUId(pVM)].hwaccm.s.fForceTLBFlush = true; 
    7778    STAM_COUNTER_INC(&pVM->hwaccm.s.StatFlushTLBManual); 
    7879    return VINF_SUCCESS; 
     
    120121 
    121122#ifdef IN_RING0 
     123    PVMCPU pVCpu = &pVM->aCpus[HWACCMGetVMCPUId(pVM)]; 
    122124    if (pVM->hwaccm.s.vmx.fSupported) 
    123         return VMXR0InvalidatePhysPage(pVM, GCPhys); 
     125        return VMXR0InvalidatePhysPage(pVM, pVCpu, GCPhys); 
    124126 
    125127    Assert(pVM->hwaccm.s.svm.fSupported); 
    126     SVMR0InvalidatePhysPage(pVM, GCPhys); 
     128    SVMR0InvalidatePhysPage(pVM, pVCpu, GCPhys); 
    127129#else 
    128130    HWACCMFlushTLB(pVM); 
     
    139141VMMDECL(bool) HWACCMHasPendingIrq(PVM pVM) 
    140142{ 
    141     return !!pVM->hwaccm.s.Event.fPending; 
     143    /* @todo SMP */ 
     144    return !!pVM->aCpus[0].hwaccm.s.Event.fPending; 
    142145} 
    143146 
  • trunk/src/VBox/VMM/VMMR0/HWACCMR0.cpp

    r13879 r13883  
    780780    pVM->hwaccm.s.uMaxASID                  = HWACCMR0Globals.uMaxASID; 
    781781 
    782     /* Invalidate the last cpu we were running on. */ 
    783     pVM->hwaccm.s.idLastCpu                 = NIL_RTCPUID; 
    784  
    785     /* we'll aways increment this the first time (host uses ASID 0) */ 
    786     pVM->hwaccm.s.uCurrentASID              = 0; 
     782    for (unsigned i=0;i<pVM->cCPUs;i++) 
     783    { 
     784        /* Invalidate the last cpu we were running on. */ 
     785        pVM->aCpus[i].hwaccm.s.idLastCpu                 = NIL_RTCPUID; 
     786 
     787        /* we'll aways increment this the first time (host uses ASID 0) */ 
     788        pVM->aCpus[i].hwaccm.s.uCurrentASID              = 0; 
     789    } 
    787790 
    788791    ASMAtomicWriteBool(&pCpu->fInUse, true); 
     
    850853 
    851854    ASMAtomicWriteBool(&pCpu->fInUse, true); 
     855 
     856    for (unsigned i=0;i<pVM->cCPUs;i++) 
     857    { 
     858        /* On first entry we'll sync everything. */ 
     859        pVM->aCpus[i].hwaccm.s.fContextUseFlags = HWACCM_CHANGED_ALL; 
     860    } 
    852861 
    853862    /* Setup VT-x or AMD-V. */ 
     
    887896 
    888897    /* Always reload the host context and the guest's CR0 register. (!!!!) */ 
    889     pVM->hwaccm.s.fContextUseFlags |= HWACCM_CHANGED_GUEST_CR0 | HWACCM_CHANGED_HOST_CONTEXT; 
     898    pVCpu->hwaccm.s.fContextUseFlags |= HWACCM_CHANGED_GUEST_CR0 | HWACCM_CHANGED_HOST_CONTEXT; 
    890899 
    891900    /* Setup the register and mask according to the current execution mode. */ 
     
    943952        CPUMR0SaveGuestFPU(pVM, pCtx); 
    944953 
    945         pVM->hwaccm.s.fContextUseFlags |= HWACCM_CHANGED_GUEST_CR0; 
     954        pVCpu->hwaccm.s.fContextUseFlags |= HWACCM_CHANGED_GUEST_CR0; 
    946955    } 
    947956 
  • trunk/src/VBox/VMM/VMMR0/HWSVMR0.cpp

    r13879 r13883  
    391391 * @returns VBox status code. 
    392392 * @param   pVM         The VM to operate on. 
     393 * @param   pVCpu       The VM CPU to operate on. 
    393394 * @param   pVMCB       SVM control block 
    394395 * @param   pCtx        CPU Context 
    395396 */ 
    396 static int SVMR0CheckPendingInterrupt(PVM pVM, SVM_VMCB *pVMCB, CPUMCTX *pCtx) 
     397static int SVMR0CheckPendingInterrupt(PVM pVM, PVMCPU pVCpu, SVM_VMCB *pVMCB, CPUMCTX *pCtx) 
    397398{ 
    398399    int rc; 
    399400 
    400401    /* Dispatch any pending interrupts. (injected before, but a VM exit occurred prematurely) */ 
    401     if (pVM->hwaccm.s.Event.fPending) 
     402    if (pVCpu->hwaccm.s.Event.fPending) 
    402403    { 
    403404        SVM_EVENT Event; 
    404405 
    405         Log(("Reinjecting event %08x %08x at %RGv\n", pVM->hwaccm.s.Event.intInfo, pVM->hwaccm.s.Event.errCode, (RTGCPTR)pCtx->rip)); 
     406        Log(("Reinjecting event %08x %08x at %RGv\n", pVCpu->hwaccm.s.Event.intInfo, pVCpu->hwaccm.s.Event.errCode, (RTGCPTR)pCtx->rip)); 
    406407        STAM_COUNTER_INC(&pVM->hwaccm.s.StatIntReinject); 
    407         Event.au64[0] = pVM->hwaccm.s.Event.intInfo; 
     408        Event.au64[0] = pVCpu->hwaccm.s.Event.intInfo; 
    408409        SVMR0InjectEvent(pVM, pVMCB, pCtx, &Event); 
    409410 
    410         pVM->hwaccm.s.Event.fPending = false; 
     411        pVCpu->hwaccm.s.Event.fPending = false; 
    411412        return VINF_SUCCESS; 
    412413    } 
     
    525526 * @returns VBox status code. 
    526527 * @param   pVM         The VM to operate on. 
    527  * @param   pVMCPU      The VM CPU to operate on. 
     528 * @param   pVCpu       The VM CPU to operate on. 
    528529 */ 
    529530VMMR0DECL(int) SVMR0SaveHostState(PVM pVM, PVMCPU pVCpu) 
     
    542543 * @returns VBox status code. 
    543544 * @param   pVM         The VM to operate on. 
    544  * @param   pVMCPU      The VM CPU to operate on. 
     545 * @param   pVCpu       The VM CPU to operate on. 
    545546 * @param   pCtx        Guest context 
    546547 */ 
     
    560561 
    561562    /* Guest CPU context: ES, CS, SS, DS, FS, GS. */ 
    562     if (pVM->hwaccm.s.fContextUseFlags & HWACCM_CHANGED_GUEST_SEGMENT_REGS) 
     563    if (pVCpu->hwaccm.s.fContextUseFlags & HWACCM_CHANGED_GUEST_SEGMENT_REGS) 
    563564    { 
    564565        SVM_WRITE_SELREG(CS, cs); 
     
    571572 
    572573    /* Guest CPU context: LDTR. */ 
    573     if (pVM->hwaccm.s.fContextUseFlags & HWACCM_CHANGED_GUEST_LDTR) 
     574    if (pVCpu->hwaccm.s.fContextUseFlags & HWACCM_CHANGED_GUEST_LDTR) 
    574575    { 
    575576        SVM_WRITE_SELREG(LDTR, ldtr); 
     
    577578 
    578579    /* Guest CPU context: TR. */ 
    579     if (pVM->hwaccm.s.fContextUseFlags & HWACCM_CHANGED_GUEST_TR) 
     580    if (pVCpu->hwaccm.s.fContextUseFlags & HWACCM_CHANGED_GUEST_TR) 
    580581    { 
    581582        SVM_WRITE_SELREG(TR, tr); 
     
    583584 
    584585    /* Guest CPU context: GDTR. */ 
    585     if (pVM->hwaccm.s.fContextUseFlags & HWACCM_CHANGED_GUEST_GDTR) 
     586    if (pVCpu->hwaccm.s.fContextUseFlags & HWACCM_CHANGED_GUEST_GDTR) 
    586587    { 
    587588        pVMCB->guest.GDTR.u32Limit = pCtx->gdtr.cbGdt; 
     
    590591 
    591592    /* Guest CPU context: IDTR. */ 
    592     if (pVM->hwaccm.s.fContextUseFlags & HWACCM_CHANGED_GUEST_IDTR) 
     593    if (pVCpu->hwaccm.s.fContextUseFlags & HWACCM_CHANGED_GUEST_IDTR) 
    593594    { 
    594595        pVMCB->guest.IDTR.u32Limit = pCtx->idtr.cbIdt; 
     
    604605 
    605606    /* Control registers */ 
    606     if (pVM->hwaccm.s.fContextUseFlags & HWACCM_CHANGED_GUEST_CR0) 
     607    if (pVCpu->hwaccm.s.fContextUseFlags & HWACCM_CHANGED_GUEST_CR0) 
    607608    { 
    608609        val = pCtx->cr0; 
     
    620621 
    621622                /* Also catch floating point exceptions as we need to report them to the guest in a different way. */ 
    622                 if (!pVM->hwaccm.s.fFPUOldStyleOverride) 
     623                if (!pVCpu->hwaccm.s.fFPUOldStyleOverride) 
    623624                { 
    624625                    pVMCB->ctrl.u32InterceptException |= RT_BIT(X86_XCPT_MF); 
    625                     pVM->hwaccm.s.fFPUOldStyleOverride = true; 
     626                    pVCpu->hwaccm.s.fFPUOldStyleOverride = true; 
    626627                } 
    627628            } 
     
    643644    pVMCB->guest.u64CR2 = pCtx->cr2; 
    644645 
    645     if (pVM->hwaccm.s.fContextUseFlags & HWACCM_CHANGED_GUEST_CR3) 
     646    if (pVCpu->hwaccm.s.fContextUseFlags & HWACCM_CHANGED_GUEST_CR3) 
    646647    { 
    647648        /* Save our shadow CR3 register. */ 
     
    659660    } 
    660661 
    661     if (pVM->hwaccm.s.fContextUseFlags & HWACCM_CHANGED_GUEST_CR4) 
     662    if (pVCpu->hwaccm.s.fContextUseFlags & HWACCM_CHANGED_GUEST_CR4) 
    662663    { 
    663664        val = pCtx->cr4; 
     
    698699 
    699700    /* Debug registers. */ 
    700     if (pVM->hwaccm.s.fContextUseFlags & HWACCM_CHANGED_GUEST_DEBUG) 
     701    if (pVCpu->hwaccm.s.fContextUseFlags & HWACCM_CHANGED_GUEST_DEBUG) 
    701702    { 
    702703        pCtx->dr[6] |= X86_DR6_INIT_VAL;                                          /* set all reserved bits to 1. */ 
     
    789790 
    790791    /* Done. */ 
    791     pVM->hwaccm.s.fContextUseFlags &= ~HWACCM_CHANGED_ALL_GUEST; 
     792    pVCpu->hwaccm.s.fContextUseFlags &= ~HWACCM_CHANGED_ALL_GUEST; 
    792793 
    793794    return VINF_SUCCESS; 
     
    800801 * @returns VBox status code. 
    801802 * @param   pVM         The VM to operate on. 
    802  * @param   pVMCPU      The VM CPU to operate on. 
     803 * @param   pVCpu       The VM CPU to operate on. 
    803804 * @param   pCtx        Guest context 
    804805 */ 
     
    882883    /* When external interrupts are pending, we should exit the VM when IF is set. */ 
    883884    /* Note! *After* VM_FF_INHIBIT_INTERRUPTS check!!! */ 
    884     rc = SVMR0CheckPendingInterrupt(pVM, pVMCB, pCtx); 
     885    rc = SVMR0CheckPendingInterrupt(pVM, pVCpu, pVMCB, pCtx); 
    885886    if (RT_FAILURE(rc)) 
    886887    { 
     
    923924#ifdef LOG_ENABLED 
    924925    pCpu = HWACCMR0GetCurrentCpu(); 
    925     if (    pVM->hwaccm.s.idLastCpu   != pCpu->idCpu 
    926         ||  pVM->hwaccm.s.cTLBFlushes != pCpu->cTLBFlushes) 
    927     { 
    928         if (pVM->hwaccm.s.idLastCpu != pCpu->idCpu) 
    929             Log(("Force TLB flush due to rescheduling to a different cpu (%d vs %d)\n", pVM->hwaccm.s.idLastCpu, pCpu->idCpu)); 
     926    if (    pVCpu->hwaccm.s.idLastCpu   != pCpu->idCpu 
     927        ||  pVCpu->hwaccm.s.cTLBFlushes != pCpu->cTLBFlushes) 
     928    { 
     929        if (pVCpu->hwaccm.s.idLastCpu != pCpu->idCpu) 
     930            Log(("Force TLB flush due to rescheduling to a different cpu (%d vs %d)\n", pVCpu->hwaccm.s.idLastCpu, pCpu->idCpu)); 
    930931        else 
    931             Log(("Force TLB flush due to changed TLB flush count (%x vs %x)\n", pVM->hwaccm.s.cTLBFlushes, pCpu->cTLBFlushes)); 
     932            Log(("Force TLB flush due to changed TLB flush count (%x vs %x)\n", pVCpu->hwaccm.s.cTLBFlushes, pCpu->cTLBFlushes)); 
    932933    } 
    933934    if (pCpu->fFlushTLB) 
     
    955956    /* Force a TLB flush for the first world switch if the current cpu differs from the one we ran on last. */ 
    956957    /* Note that this can happen both for start and resume due to long jumps back to ring 3. */ 
    957     if (    pVM->hwaccm.s.idLastCpu != pCpu->idCpu 
     958    if (    pVCpu->hwaccm.s.idLastCpu != pCpu->idCpu 
    958959            /* if the tlb flush count has changed, another VM has flushed the TLB of this cpu, so we can't use our current ASID anymore. */ 
    959         ||  pVM->hwaccm.s.cTLBFlushes != pCpu->cTLBFlushes) 
     960        ||  pVCpu->hwaccm.s.cTLBFlushes != pCpu->cTLBFlushes) 
    960961    { 
    961962        /* Force a TLB flush on VM entry. */ 
    962         pVM->hwaccm.s.fForceTLBFlush = true; 
     963        pVCpu->hwaccm.s.fForceTLBFlush = true; 
    963964    } 
    964965    else 
    965966        Assert(!pCpu->fFlushTLB || pVM->hwaccm.s.svm.fAlwaysFlushTLB); 
    966967 
    967     pVM->hwaccm.s.idLastCpu = pCpu->idCpu; 
     968    pVCpu->hwaccm.s.idLastCpu = pCpu->idCpu; 
    968969 
    969970    /* Make sure we flush the TLB when required. Switch ASID to achieve the same thing, but without actually flushing the whole TLB (which is expensive). */ 
    970     if (    pVM->hwaccm.s.fForceTLBFlush 
     971    if (    pVCpu->hwaccm.s.fForceTLBFlush 
    971972        && !pVM->hwaccm.s.svm.fAlwaysFlushTLB) 
    972973    { 
     
    982983            STAM_COUNTER_INC(&pVM->hwaccm.s.StatFlushASID); 
    983984 
    984         pVM->hwaccm.s.cTLBFlushes  = pCpu->cTLBFlushes; 
    985         pVM->hwaccm.s.uCurrentASID = pCpu->uCurrentASID; 
     985        pVCpu->hwaccm.s.cTLBFlushes  = pCpu->cTLBFlushes; 
     986        pVCpu->hwaccm.s.uCurrentASID = pCpu->uCurrentASID; 
    986987    } 
    987988    else 
     
    990991 
    991992        /* We never increase uCurrentASID in the fAlwaysFlushTLB (erratum 170) case. */ 
    992         if (!pCpu->uCurrentASID || !pVM->hwaccm.s.uCurrentASID) 
    993             pVM->hwaccm.s.uCurrentASID = pCpu->uCurrentASID = 1; 
    994  
    995         Assert(!pVM->hwaccm.s.svm.fAlwaysFlushTLB || pVM->hwaccm.s.fForceTLBFlush); 
    996         pVMCB->ctrl.TLBCtrl.n.u1TLBFlush = pVM->hwaccm.s.fForceTLBFlush; 
    997     } 
    998     AssertMsg(pVM->hwaccm.s.cTLBFlushes == pCpu->cTLBFlushes, ("Flush count mismatch for cpu %d (%x vs %x)\n", pCpu->idCpu, pVM->hwaccm.s.cTLBFlushes, pCpu->cTLBFlushes)); 
     993        if (!pCpu->uCurrentASID || !pVCpu->hwaccm.s.uCurrentASID) 
     994            pVCpu->hwaccm.s.uCurrentASID = pCpu->uCurrentASID = 1; 
     995 
     996        Assert(!pVM->hwaccm.s.svm.fAlwaysFlushTLB || pVCpu->hwaccm.s.fForceTLBFlush); 
     997        pVMCB->ctrl.TLBCtrl.n.u1TLBFlush = pVCpu->hwaccm.s.fForceTLBFlush; 
     998    } 
     999    AssertMsg(pVCpu->hwaccm.s.cTLBFlushes == pCpu->cTLBFlushes, ("Flush count mismatch for cpu %d (%x vs %x)\n", pCpu->idCpu, pVCpu->hwaccm.s.cTLBFlushes, pCpu->cTLBFlushes)); 
    9991000    AssertMsg(pCpu->uCurrentASID >= 1 && pCpu->uCurrentASID < pVM->hwaccm.s.uMaxASID, ("cpu%d uCurrentASID = %x\n", pCpu->idCpu, pCpu->uCurrentASID)); 
    1000     AssertMsg(pVM->hwaccm.s.uCurrentASID >= 1 && pVM->hwaccm.s.uCurrentASID < pVM->hwaccm.s.uMaxASID, ("cpu%d VM uCurrentASID = %x\n", pCpu->idCpu, pVM->hwaccm.s.uCurrentASID)); 
    1001     pVMCB->ctrl.TLBCtrl.n.u32ASID = pVM->hwaccm.s.uCurrentASID; 
     1001    AssertMsg(pVCpu->hwaccm.s.uCurrentASID >= 1 && pVCpu->hwaccm.s.uCurrentASID < pVM->hwaccm.s.uMaxASID, ("cpu%d VM uCurrentASID = %x\n", pCpu->idCpu, pVCpu->hwaccm.s.uCurrentASID)); 
     1002    pVMCB->ctrl.TLBCtrl.n.u32ASID = pVCpu->hwaccm.s.uCurrentASID; 
    10021003 
    10031004#ifdef VBOX_WITH_STATISTICS 
     
    10091010 
    10101011    /* In case we execute a goto ResumeExecution later on. */ 
    1011     pVM->hwaccm.s.svm.fResumeVM      = true; 
    1012     pVM->hwaccm.s.fForceTLBFlush = pVM->hwaccm.s.svm.fAlwaysFlushTLB; 
     1012    pVCpu->hwaccm.s.fResumeVM      = true; 
     1013    pVCpu->hwaccm.s.fForceTLBFlush = pVM->hwaccm.s.svm.fAlwaysFlushTLB; 
    10131014 
    10141015    Assert(sizeof(pVCpu->hwaccm.s.svm.pVMCBPhys) == 8); 
     
    12371238 
    12381239    /* Check if an injected event was interrupted prematurely. */ 
    1239     pVM->hwaccm.s.Event.intInfo = pVMCB->ctrl.ExitIntInfo.au64[0]; 
     1240    pVCpu->hwaccm.s.Event.intInfo = pVMCB->ctrl.ExitIntInfo.au64[0]; 
    12401241    if (    pVMCB->ctrl.ExitIntInfo.n.u1Valid 
    12411242        &&  pVMCB->ctrl.ExitIntInfo.n.u3Type != SVM_EVENT_SOFTWARE_INT /* we don't care about 'int xx' as the instruction will be restarted. */) 
    12421243    { 
    1243         Log(("Pending inject %RX64 at %RGv exit=%08x\n", pVM->hwaccm.s.Event.intInfo, (RTGCPTR)pCtx->rip, exitCode)); 
     1244        Log(("Pending inject %RX64 at %RGv exit=%08x\n", pVCpu->hwaccm.s.Event.intInfo, (RTGCPTR)pCtx->rip, exitCode)); 
    12441245 
    12451246#ifdef LOG_ENABLED 
    12461247        SVM_EVENT Event; 
    1247         Event.au64[0] = pVM->hwaccm.s.Event.intInfo; 
     1248        Event.au64[0] = pVCpu->hwaccm.s.Event.intInfo; 
    12481249 
    12491250        if (    exitCode == SVM_EXIT_EXCEPTION_E 
     
    12541255#endif 
    12551256 
    1256         pVM->hwaccm.s.Event.fPending = true; 
     1257        pVCpu->hwaccm.s.Event.fPending = true; 
    12571258        /* Error code present? (redundant) */ 
    12581259        if (pVMCB->ctrl.ExitIntInfo.n.u1ErrorCodeValid) 
    12591260        { 
    1260             pVM->hwaccm.s.Event.errCode  = pVMCB->ctrl.ExitIntInfo.n.u32ErrorCode; 
     1261            pVCpu->hwaccm.s.Event.errCode  = pVMCB->ctrl.ExitIntInfo.n.u32ErrorCode; 
    12611262        } 
    12621263        else 
    1263             pVM->hwaccm.s.Event.errCode  = 0; 
     1264            pVCpu->hwaccm.s.Event.errCode  = 0; 
    12641265    } 
    12651266#ifdef VBOX_WITH_STATISTICS 
     
    13361337                /* Continue execution. */ 
    13371338                STAM_PROFILE_ADV_STOP(&pVM->hwaccm.s.StatExit, x); 
    1338                 pVM->hwaccm.s.fContextUseFlags |= HWACCM_CHANGED_GUEST_CR0; 
     1339                pVCpu->hwaccm.s.fContextUseFlags |= HWACCM_CHANGED_GUEST_CR0; 
    13391340 
    13401341                goto ResumeExecution; 
     
    16411642        { 
    16421643        case 0: 
    1643             pVM->hwaccm.s.fContextUseFlags |= HWACCM_CHANGED_GUEST_CR0; 
     1644            pVCpu->hwaccm.s.fContextUseFlags |= HWACCM_CHANGED_GUEST_CR0; 
    16441645            break; 
    16451646        case 2: 
     
    16471648        case 3: 
    16481649            Assert(!pVM->hwaccm.s.fNestedPaging); 
    1649             pVM->hwaccm.s.fContextUseFlags |= HWACCM_CHANGED_GUEST_CR3; 
     1650            pVCpu->hwaccm.s.fContextUseFlags |= HWACCM_CHANGED_GUEST_CR3; 
    16501651            break; 
    16511652        case 4: 
    1652             pVM->hwaccm.s.fContextUseFlags |= HWACCM_CHANGED_GUEST_CR4; 
     1653            pVCpu->hwaccm.s.fContextUseFlags |= HWACCM_CHANGED_GUEST_CR4; 
    16531654            break; 
    16541655        case 8: 
     
    16671668 
    16681669            /* Must be set by PGMSyncCR3 */ 
    1669             Assert(PGMGetGuestMode(pVM) <= PGMMODE_PROTECTED || pVM->hwaccm.s.fForceTLBFlush); 
     1670            Assert(PGMGetGuestMode(pVM) <= PGMMODE_PROTECTED || pVCpu->hwaccm.s.fForceTLBFlush); 
    16701671        } 
    16711672        if (rc == VINF_SUCCESS) 
     
    17331734        { 
    17341735            /* EIP has been updated already. */ 
    1735             pVM->hwaccm.s.fContextUseFlags |= HWACCM_CHANGED_GUEST_DEBUG; 
     1736            pVCpu->hwaccm.s.fContextUseFlags |= HWACCM_CHANGED_GUEST_DEBUG; 
    17361737 
    17371738            /* Only resume if successful. */ 
     
    20362037        STAM_COUNTER_INC(&pVM->hwaccm.s.StatPendingHostIrq); 
    20372038        /* On the next entry we'll only sync the host context. */ 
    2038         pVM->hwaccm.s.fContextUseFlags |= HWACCM_CHANGED_HOST_CONTEXT; 
     2039        pVCpu->hwaccm.s.fContextUseFlags |= HWACCM_CHANGED_HOST_CONTEXT; 
    20392040    } 
    20402041    else 
     
    20432044        /** @todo we can do better than this */ 
    20442045        /* Not in the VINF_PGM_CHANGE_MODE though! */ 
    2045         pVM->hwaccm.s.fContextUseFlags |= HWACCM_CHANGED_ALL; 
     2046        pVCpu->hwaccm.s.fContextUseFlags |= HWACCM_CHANGED_ALL; 
    20462047    } 
    20472048 
     
    20662067    Assert(pVM->hwaccm.s.svm.fSupported); 
    20672068 
    2068     LogFlow(("SVMR0Enter cpu%d last=%d asid=%d\n", pCpu->idCpu, pVM->hwaccm.s.idLastCpu, pVM->hwaccm.s.uCurrentASID)); 
    2069     pVM->hwaccm.s.svm.fResumeVM = false; 
     2069    LogFlow(("SVMR0Enter cpu%d last=%d asid=%d\n", pCpu->idCpu, pVCpu->hwaccm.s.idLastCpu, pVCpu->hwaccm.s.uCurrentASID)); 
     2070    pVCpu->hwaccm.s.fResumeVM = false; 
    20702071 
    20712072    /* Force to reload LDTR, so we'll execute VMLoad to load additional guest state. */ 
    2072     pVM->hwaccm.s.fContextUseFlags |= HWACCM_CHANGED_GUEST_LDTR; 
     2073    pVCpu->hwaccm.s.fContextUseFlags |= HWACCM_CHANGED_GUEST_LDTR; 
    20732074 
    20742075    return VINF_SUCCESS; 
     
    21002101 
    21012102        /* Resync the debug registers the next time. */ 
    2102         pVM->hwaccm.s.fContextUseFlags |= HWACCM_CHANGED_GUEST_DEBUG; 
     2103        pVCpu->hwaccm.s.fContextUseFlags |= HWACCM_CHANGED_GUEST_DEBUG; 
    21032104    } 
    21042105    else 
     
    21992200 * @returns VBox status code. 
    22002201 * @param   pVM         The VM to operate on. 
     2202 * @param   pVCpu       The VM CPU to operate on. 
    22012203 * @param   GCVirt      Page to invalidate 
    22022204 */ 
    2203 VMMR0DECL(int) SVMR0InvalidatePage(PVM pVM, RTGCPTR GCVirt) 
     2205VMMR0DECL(int) SVMR0InvalidatePage(PVM pVM, PVMCPU pVCpu, RTGCPTR GCVirt) 
    22042206{ 
    2205     bool fFlushPending = pVM->hwaccm.s.svm.fAlwaysFlushTLB | pVM->hwaccm.s.fForceTLBFlush; 
     2207    bool fFlushPending = pVM->hwaccm.s.svm.fAlwaysFlushTLB | pVCpu->hwaccm.s.fForceTLBFlush; 
    22062208 
    22072209    /* Skip it if a TLB flush is already pending. */ 
     
    22302232 * @returns VBox status code. 
    22312233 * @param   pVM         The VM to operate on. 
     2234 * @param   pVCpu       The VM CPU to operate on. 
    22322235 * @param   GCPhys      Page to invalidate 
    22332236 */ 
    2234 VMMR0DECL(int) SVMR0InvalidatePhysPage(PVM pVM, RTGCPHYS GCPhys) 
     2237VMMR0DECL(int) SVMR0InvalidatePhysPage(PVM pVM, PVMCPU pVCpu, RTGCPHYS GCPhys) 
    22352238{ 
    22362239    Assert(pVM->hwaccm.s.fNestedPaging); 
    22372240    /* invlpga only invalidates TLB entries for guest virtual addresses; we have no choice but to force a TLB flush here. */ 
    2238     pVM->hwaccm.s.fForceTLBFlush = true; 
     2241    pVCpu->hwaccm.s.fForceTLBFlush = true; 
    22392242    STAM_COUNTER_INC(&pVM->hwaccm.s.StatFlushTLBInvlpga); 
    22402243    return VINF_SUCCESS; 
  • trunk/src/VBox/VMM/VMMR0/HWSVMR0.h

    r13879 r13883  
    4747 * @returns VBox status code. 
    4848 * @param   pVM         The VM to operate on. 
    49  * @param   pVCpu      VPCPU id
     49 * @param   pVCpu      The VMCPU to operate on
    5050 * @param   pCpu        CPU info struct 
    5151 */ 
     
    5757 * @returns VBox status code. 
    5858 * @param   pVM         The VM to operate on. 
    59  * @param   pVCpu      VPCPU id
     59 * @param   pVCpu      The VMCPU to operate on
    6060 * @param   pCtx        CPU context 
    6161 */ 
     
    113113 * @returns VBox status code. 
    114114 * @param   pVM         The VM to operate on. 
    115  * @param   pVCpu      VPCPU id
     115 * @param   pVCpu      The VMCPU to operate on
    116116 * @param   pCtx        Guest context 
    117117 */ 
     
    124124 * @returns VBox status code. 
    125125 * @param   pVM         The VM to operate on. 
    126  * @param   pVCpu      VPCPU id
     126 * @param   pVCpu      The VMCPU to operate on
    127127 */ 
    128128VMMR0DECL(int) SVMR0SaveHostState(PVM pVM, PVMCPU pVCpu); 
     
    133133 * @returns VBox status code. 
    134134 * @param   pVM         The VM to operate on. 
    135  * @param   pVCpu      VPCPU id
     135 * @param   pVCpu      The VMCPU to operate on
    136136 * @param   pCtx        Guest context 
    137137 */ 
  • trunk/src/VBox/VMM/VMMR0/HWVMXR0.cpp

    r13879 r13883  
    5151*   Local Functions                                                            * 
    5252*******************************************************************************/ 
    53 static void VMXR0ReportWorldSwitchError(PVM pVM, int rc, PCPUMCTX pCtx); 
    54 static void vmxR0SetupTLBEPT(PVM pVM); 
    55 static void vmxR0SetupTLBVPID(PVM pVM); 
    56 static void vmxR0SetupTLBDummy(PVM pVM); 
    57 static void vmxR0FlushEPT(PVM pVM, VMX_FLUSH enmFlush, RTGCPHYS GCPhys); 
    58 static void vmxR0FlushVPID(PVM pVM, VMX_FLUSH enmFlush, RTGCPTR GCPtr); 
    59 static void vmxR0UpdateExceptionBitmap(PVM pVM, PCPUMCTX pCtx); 
     53static void VMXR0ReportWorldSwitchError(PVM pVM, PVMCPU pVCpu, int rc, PCPUMCTX pCtx); 
     54static void vmxR0SetupTLBEPT(PVM pVM, PVMCPU pVCpu); 
     55static void vmxR0SetupTLBVPID(PVM pVM, PVMCPU pVCpu); 
     56static void vmxR0SetupTLBDummy(PVM pVM, PVMCPU pVCpu); 
     57static void vmxR0FlushEPT(PVM pVM, PVMCPU pVCpu, VMX_FLUSH enmFlush, RTGCPHYS GCPhys); 
     58static void vmxR0FlushVPID(PVM pVM, PVMCPU pVCpu, VMX_FLUSH enmFlush, RTGCPTR GCPtr); 
     59static void vmxR0UpdateExceptionBitmap(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx); 
    6060 
    6161 
     
    533533 * @returns VBox status code. 
    534534 * @param   pVM         The VM to operate on. 
     535 * @param   pVCpu       The VMCPU to operate on. 
    535536 * @param   pCtx        CPU Context 
    536537 * @param   intInfo     VMX interrupt info 
     
    538539 * @param   errCode     Error code (optional) 
    539540 */ 
    540 static int VMXR0InjectEvent(PVM pVM, CPUMCTX *pCtx, uint32_t intInfo, uint32_t cbInstr, uint32_t errCode) 
     541static int VMXR0InjectEvent(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx, uint32_t intInfo, uint32_t cbInstr, uint32_t errCode) 
    541542{ 
    542543    int         rc; 
     
    583584                intInfo |= (VMX_EXIT_INTERRUPTION_INFO_TYPE_HWEXCPT << VMX_EXIT_INTERRUPTION_INFO_TYPE_SHIFT); 
    584585 
    585                 return VMXR0InjectEvent(pVM, pCtx, intInfo, 0, 0 /* no error code according to the Intel docs */); 
     586                return VMXR0InjectEvent(pVM, pVCpu, pCtx, intInfo, 0, 0 /* no error code according to the Intel docs */); 
    586587            } 
    587588            Log(("Triple fault -> reset the VM!\n")); 
     
    622623        pCtx->eflags.u     &= ~(X86_EFL_IF|X86_EFL_TF|X86_EFL_RF|X86_EFL_AC); 
    623624 
    624         pVM->hwaccm.s.fContextUseFlags |= HWACCM_CHANGED_GUEST_SEGMENT_REGS; 
     625        pVCpu->hwaccm.s.fContextUseFlags |= HWACCM_CHANGED_GUEST_SEGMENT_REGS; 
    625626        return VINF_SUCCESS; 
    626627    } 
     
    643644 * @returns VBox status code. 
    644645 * @param   pVM         The VM to operate on. 
    645  * @param   idVCpu      VMCPU id
     646 * @param   pVCpu       The VMCPU to operate on
    646647 * @param   pCtx        CPU Context 
    647648 */ 
     
    651652 
    652653    /* Dispatch any pending interrupts. (injected before, but a VM exit occurred prematurely) */ 
    653     if (pVM->hwaccm.s.Event.fPending) 
    654     { 
    655         Log(("Reinjecting event %RX64 %08x at %RGv cr2=%RX64\n", pVM->hwaccm.s.Event.intInfo, pVM->hwaccm.s.Event.errCode, (RTGCPTR)pCtx->rip, pCtx->cr2)); 
     654    if (pVCpu->hwaccm.s.Event.fPending) 
     655    { 
     656        Log(("Reinjecting event %RX64 %08x at %RGv cr2=%RX64\n", pVCpu->hwaccm.s.Event.intInfo, pVCpu->hwaccm.s.Event.errCode, (RTGCPTR)pCtx->rip, pCtx->cr2)); 
    656657        STAM_COUNTER_INC(&pVM->hwaccm.s.StatIntReinject); 
    657         rc = VMXR0InjectEvent(pVM, pCtx, pVM->hwaccm.s.Event.intInfo, 0, pVM->hwaccm.s.Event.errCode); 
    658         AssertRC(rc); 
    659  
    660         pVM->hwaccm.s.Event.fPending = false; 
     658        rc = VMXR0InjectEvent(pVM, pVCpu, pCtx, pVCpu->hwaccm.s.Event.intInfo, 0, pVCpu->hwaccm.s.Event.errCode); 
     659        AssertRC(rc); 
     660 
     661        pVCpu->hwaccm.s.Event.fPending = false; 
    661662        return VINF_SUCCESS; 
    662