VirtualBox

Changeset 20838 in vbox


Ignore:
Timestamp:
Jun 23, 2009 2:15:46 PM (15 years ago)
Author:
vboxsync
Message:

NMI updates

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/hwaccm.h

    r20374 r20838  
    118118 * @{
    119119 */
    120 VMMR3DECL(bool) HWACCMR3IsEventPending(PVM pVM);
     120VMMR3DECL(bool) HWACCMR3IsEventPending(PVMCPU pVCpu);
    121121VMMR3DECL(int)  HWACCMR3Init(PVM pVM);
    122122VMMR3DECL(int)  HWACCMR3InitCPU(PVM pVM);
  • trunk/include/VBox/vm.h

    r20835 r20838  
    302302#define VMCPU_FF_TIMER                      RT_BIT_32(2)
    303303/** This action forces the VM to check any pending NMIs. */
    304 #define VMCPU_FF_INTERRUPT_NMI              RT_BIT_32(3)
     304#define VMCPU_FF_INTERRUPT_NMI_BIT          3
     305#define VMCPU_FF_INTERRUPT_NMI              RT_BIT_32(VMCPU_FF_INTERRUPT_NMI_BIT)
    305306/** This action forces the VM to check any pending SMIs. */
    306 #define VMCPU_FF_INTERRUPT_SMI              RT_BIT_32(4)
     307#define VMCPU_FF_INTERRUPT_SMI_BIT          4
     308#define VMCPU_FF_INTERRUPT_SMI              RT_BIT_32(VMCPU_FF_INTERRUPT_SMI_BIT)
    307309/** PDM critical section unlocking is pending, process promptly upon return to R3. */
    308310#define VMCPU_FF_PDM_CRITSECT               RT_BIT_32(5)
  • trunk/src/VBox/VMM/EM.cpp

    r20671 r20838  
    35153515            &&  !TRPMHasTrap(pVCpu) /* an interrupt could already be scheduled for dispatching in the recompiler. */
    35163516            &&  PATMAreInterruptsEnabled(pVM)
    3517             &&  !HWACCMR3IsEventPending(pVM))
     3517            &&  !HWACCMR3IsEventPending(pVCpu))
    35183518        {
    35193519            Assert(pVCpu->em.s.enmState != EMSTATE_WAIT_SIPI);
  • trunk/src/VBox/VMM/HWACCM.cpp

    r20228 r20838  
    16281628 * @param   pVM         The VM to operate on.
    16291629 */
    1630 VMMR3DECL(bool) HWACCMR3IsEventPending(PVM pVM)
    1631 {
    1632     /* @todo SMP */
    1633     return HWACCMIsEnabled(pVM) && pVM->aCpus[0].hwaccm.s.Event.fPending;
    1634 }
    1635 
    1636 
    1637 /**
    1638  * Inject an NMI into a running VM
     1630VMMR3DECL(bool) HWACCMR3IsEventPending(PVMCPU pVCpu)
     1631{
     1632    return HWACCMIsEnabled(pVCpu->pVMR3) && pVCpu->hwaccm.s.Event.fPending;
     1633}
     1634
     1635
     1636/**
     1637 * Inject an NMI into a running VM (only VCPU 0!)
    16391638 *
    16401639 * @returns boolean
     
    16431642VMMR3DECL(int)  HWACCMR3InjectNMI(PVM pVM)
    16441643{
    1645     pVM->hwaccm.s.fInjectNMI = true;
     1644    VMCPU_FF_SET(&pVM->aCpus[0], VMCPU_FF_INTERRUPT_NMI);
    16461645    return VINF_SUCCESS;
    16471646}
  • trunk/src/VBox/VMM/HWACCMInternal.h

    r20530 r20838  
    197197    bool                        fAllowNestedPaging;
    198198
    199     /** Set if we're supposed to inject an NMI. */
    200     bool                        fInjectNMI;
    201 
    202199    /** Set if we can support 64-bit guests or not. */
    203200    bool                        fAllow64BitGuests;
     
    208205    /** Explicit alignment padding to make 32-bit gcc align u64RegisterMask
    209206     *  naturally. */
    210     bool                        padding[1];
     207    bool                        padding[2];
    211208
    212209    /** And mask for copying register contents. */
  • trunk/src/VBox/VMM/PDM.cpp

    r20187 r20838  
    280280*******************************************************************************/
    281281/** The PDM saved state version. */
    282 #define PDM_SAVED_STATE_VERSION     3
     282#define PDM_SAVED_STATE_VERSION             4
     283#define PDM_SAVED_STATE_VERSION_PRE_NMI_FF  3
    283284
    284285
     
    635636     * Save interrupt and DMA states.
    636637     */
    637     for (unsigned idCpu=0;idCpu<pVM->cCPUs;idCpu++)
     638    for (unsigned idCpu = 0; idCpu < pVM->cCPUs; idCpu++)
    638639    {
    639640        PVMCPU pVCpu = &pVM->aCpus[idCpu];
    640641        SSMR3PutUInt(pSSM, VMCPU_FF_ISSET(pVCpu, VMCPU_FF_INTERRUPT_APIC));
    641642        SSMR3PutUInt(pSSM, VMCPU_FF_ISSET(pVCpu, VMCPU_FF_INTERRUPT_PIC));
     643        SSMR3PutUInt(pSSM, VMCPU_FF_ISSET(pVCpu, VMCPU_FF_INTERRUPT_NMI));
     644        SSMR3PutUInt(pSSM, VMCPU_FF_ISSET(pVCpu, VMCPU_FF_INTERRUPT_SMI));
    642645    }
    643646    SSMR3PutUInt(pSSM, VM_FF_ISSET(pVM, VM_FF_PDM_DMA));
     
    699702        VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_INTERRUPT_APIC);
    700703        VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_INTERRUPT_PIC);
     704        VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_INTERRUPT_NMI);
     705        VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_INTERRUPT_SMI);
    701706    }
    702707    VM_FF_CLEAR(pVM, VM_FF_PDM_DMA);
     
    723728     * Validate version.
    724729     */
    725     if (u32Version != PDM_SAVED_STATE_VERSION)
     730    if (    u32Version != PDM_SAVED_STATE_VERSION
     731        &&  u32Version != PDM_SAVED_STATE_VERSION_PRE_NMI_FF)
    726732    {
    727733        AssertMsgFailed(("pdmR3Load: Invalid version u32Version=%d!\n", u32Version));
     
    732738     * Load the interrupt and DMA states.
    733739     */
    734     for (unsigned idCpu=0;idCpu<pVM->cCPUs;idCpu++)
     740    for (unsigned idCpu = 0; idCpu < pVM->cCPUs; idCpu++)
    735741    {
    736742        PVMCPU pVCpu = &pVM->aCpus[idCpu];
     
    763769        if (fInterruptPending)
    764770            VMCPU_FF_SET(pVCpu, VMCPU_FF_INTERRUPT_PIC);
     771
     772        if (u32Version > PDM_SAVED_STATE_VERSION_PRE_NMI_FF)
     773        {
     774            /* NMI interrupt */
     775            RTUINT fInterruptPending = 0;
     776            rc = SSMR3GetUInt(pSSM, &fInterruptPending);
     777            if (RT_FAILURE(rc))
     778                return rc;
     779            if (fInterruptPending & ~1)
     780            {
     781                AssertMsgFailed(("fInterruptPending=%#x (NMI)\n", fInterruptPending));
     782                return VERR_SSM_DATA_UNIT_FORMAT_CHANGED;
     783            }
     784            AssertRelease(!VMCPU_FF_ISSET(pVCpu, VMCPU_FF_INTERRUPT_NMI));
     785            if (fInterruptPending)
     786                VMCPU_FF_SET(pVCpu, VMCPU_FF_INTERRUPT_NMI);
     787
     788            /* SMI interrupt */
     789            fInterruptPending = 0;
     790            rc = SSMR3GetUInt(pSSM, &fInterruptPending);
     791            if (RT_FAILURE(rc))
     792                return rc;
     793            if (fInterruptPending & ~1)
     794            {
     795                AssertMsgFailed(("fInterruptPending=%#x (SMI)\n", fInterruptPending));
     796                return VERR_SSM_DATA_UNIT_FORMAT_CHANGED;
     797            }
     798            AssertRelease(!VMCPU_FF_ISSET(pVCpu, VMCPU_FF_INTERRUPT_SMI));
     799            if (fInterruptPending)
     800                VMCPU_FF_SET(pVCpu, VMCPU_FF_INTERRUPT_SMI);
     801        }
    765802    }
    766803
     
    925962        VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_INTERRUPT_APIC);
    926963        VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_INTERRUPT_PIC);
     964        VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_INTERRUPT_NMI);
     965        VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_INTERRUPT_SMI);
    927966    }
    928967    VM_FF_CLEAR(pVM, VM_FF_PDM_DMA);
  • trunk/src/VBox/VMM/VMMR0/HWSVMR0.cpp

    r20769 r20838  
    426426    }
    427427
    428     if (pVM->hwaccm.s.fInjectNMI)
     428    if (VMCPU_FF_TESTANDCLEAR(pVCpu, VMCPU_FF_INTERRUPT_NMI_BIT))
    429429    {
    430430        SVM_EVENT Event;
    431431
     432        Log(("CPU%d: injecting #NMI\n", pVCpu->idCpu));
    432433        Event.n.u8Vector     = X86_XCPT_NMI;
    433434        Event.n.u1Valid      = 1;
     
    436437
    437438        SVMR0InjectEvent(pVCpu, pVMCB, pCtx, &Event);
    438         pVM->hwaccm.s.fInjectNMI = false;
    439439        return VINF_SUCCESS;
    440440    }
     441
     442    /* @todo SMI interrupts. */
    441443
    442444    /* When external interrupts are pending, we should exit the VM when IF is set. */
  • trunk/src/VBox/VMM/VMMR0/HWVMXR0.cpp

    r20769 r20838  
    754754    }
    755755
    756     if (pVM->hwaccm.s.fInjectNMI)
     756    if (VMCPU_FF_TESTANDCLEAR(pVCpu, VMCPU_FF_INTERRUPT_NMI_BIT))
    757757    {
    758758        RTGCUINTPTR intInfo;
     759
     760        Log(("CPU%d: injecting #NMI\n", pVCpu->idCpu));
    759761
    760762        intInfo  = X86_XCPT_NMI;
     
    765767        AssertRC(rc);
    766768
    767         pVM->hwaccm.s.fInjectNMI = false;
    768769        return VINF_SUCCESS;
    769770    }
     771
     772    /* @todo SMI interrupts. */
    770773
    771774    /* When external interrupts are pending, we should exit the VM when IF is set. */
Note: See TracChangeset for help on using the changeset viewer.

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