VirtualBox

Changeset 78208 in vbox for trunk/src/VBox/VMM


Ignore:
Timestamp:
Apr 18, 2019 3:54:40 PM (6 years ago)
Author:
vboxsync
Message:

PDM,APIC,PIC: Don't use AssertRelease on VMCPU_FF_INTERRUPT_PIC, VMCPU_FF_INTERRUPT_APIC and friends during restore. Instead added debug assertions in the relevant functions causing these to be set by misbehaving device state loaders. ticketref:18331 ticketref:18265

Location:
trunk/src/VBox/VMM
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/APICAll.cpp

    r78206 r78208  
    29792979static void apicSetInterruptFF(PVMCPU pVCpu, PDMAPICIRQ enmType)
    29802980{
     2981#ifdef IN_RING3
     2982    /* IRQ state should be loaded as-is by "LoadExec". Changes can be made from LoadDone. */
     2983    Assert(pVCpu->pVMR3->enmVMState != VMSTATE_LOADING || PDMR3HasLoadedState(pVCpu->pVMR3));
     2984#endif
     2985
    29812986    switch (enmType)
    29822987    {
     
    30353040VMM_INT_DECL(void) apicClearInterruptFF(PVMCPU pVCpu, PDMAPICIRQ enmType)
    30363041{
     3042#ifdef IN_RING3
     3043    /* IRQ state should be loaded as-is by "LoadExec". Changes can be made from LoadDone. */
     3044    Assert(pVCpu->pVMR3->enmVMState != VMSTATE_LOADING || PDMR3HasLoadedState(pVCpu->pVMR3));
     3045#endif
     3046
    30373047    /* NMI/SMI can't be cleared. */
    30383048    switch (enmType)
  • trunk/src/VBox/VMM/VMMR3/APIC.cpp

    r77098 r78208  
    10261026    }
    10271027
     1028    /*
     1029     * Restore per CPU state.
     1030     *
     1031     * Note! PDM will restore the VMCPU_FF_INTERRUPT_APIC flag for us.
     1032     *       This code doesn't touch it.  No devices should make us touch
     1033     *       it later during the restore either, only during the 'done' phase.
     1034     */
    10281035    for (VMCPUID idCpu = 0; idCpu < pVM->cCpus; idCpu++)
    10291036    {
  • trunk/src/VBox/VMM/VMMR3/PDM.cpp

    r77348 r78208  
    830830
    831831/**
     832 * For APIC assertions.
     833 *
     834 * @returns true if we've loaded state.
     835 * @param   pVM             The cross context VM structure.
     836 */
     837VMMR3_INT_DECL(bool)    PDMR3HasLoadedState(PVM pVM)
     838{
     839    return pVM->pdm.s.fStateLoaded;
     840}
     841
     842
     843/**
    832844 * Bits that are saved in pass 0 and in the final pass.
    833845 *
     
    975987        /*
    976988         * Load the interrupt and DMA states.
     989         *
     990         * The APIC, PIC and DMA devices does not restore these, we do.  In the
     991         * APIC and PIC cases, it is possible that some devices is incorrectly
     992         * setting IRQs during restore.  We'll warn when this happens.  (There
     993         * are debug assertions in PDMDevMiscHlp.cpp and APICAll.cpp for
     994         * catching the buggy device.)
    977995         */
    978996        for (VMCPUID idCpu = 0; idCpu < pVM->cCpus; idCpu++)
     
    9901008                return VERR_SSM_DATA_UNIT_FORMAT_CHANGED;
    9911009            }
    992             AssertRelease(!VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_INTERRUPT_APIC)); /** @todo r=bird: bogus assertion, see @ticketref{18331} */
     1010            AssertLogRelMsg(!VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_INTERRUPT_APIC),
     1011                            ("VCPU%03u: VMCPU_FF_INTERRUPT_APIC set! Devices shouldn't set interrupts during state restore...\n", idCpu));
    9931012            if (fInterruptPending)
    9941013                VMCPU_FF_SET(pVCpu, VMCPU_FF_INTERRUPT_APIC);
     
    10041023                return VERR_SSM_DATA_UNIT_FORMAT_CHANGED;
    10051024            }
    1006             AssertRelease(!VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_INTERRUPT_PIC)); /** @todo r=bird: bogus assertion, see @ticketref{18331} */
     1025            AssertLogRelMsg(!VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_INTERRUPT_PIC),
     1026                            ("VCPU%03u: VMCPU_FF_INTERRUPT_PIC set!  Devices shouldn't set interrupts during state restore...\n", idCpu));
    10071027            if (fInterruptPending)
    10081028                VMCPU_FF_SET(pVCpu, VMCPU_FF_INTERRUPT_PIC);
     
    10201040                    return VERR_SSM_DATA_UNIT_FORMAT_CHANGED;
    10211041                }
    1022                 AssertRelease(!VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_INTERRUPT_NMI));
     1042                AssertLogRelMsg(!VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_INTERRUPT_NMI), ("VCPU%3u: VMCPU_FF_INTERRUPT_NMI set!\n", idCpu));
    10231043                if (fInterruptPending)
    10241044                    VMCPU_FF_SET(pVCpu, VMCPU_FF_INTERRUPT_NMI);
     
    10341054                    return VERR_SSM_DATA_UNIT_FORMAT_CHANGED;
    10351055                }
    1036                 AssertRelease(!VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_INTERRUPT_SMI));
     1056                AssertLogRelMsg(!VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_INTERRUPT_SMI), ("VCPU%3u: VMCPU_FF_INTERRUPT_SMI set!\n", idCpu));
    10371057                if (fInterruptPending)
    10381058                    VMCPU_FF_SET(pVCpu, VMCPU_FF_INTERRUPT_SMI);
     
    11251145                                        pDevIns->pReg->szName, pDevIns->iInstance);
    11261146        }
     1147
     1148
     1149    /*
     1150     * Indicate that we've been called (for assertions).
     1151     */
     1152    pVM->pdm.s.fStateLoaded = true;
    11271153
    11281154    return VINF_SUCCESS;
  • trunk/src/VBox/VMM/VMMR3/PDMDevMiscHlp.cpp

    r76553 r78208  
    5454    PVM    pVM = pDevIns->Internal.s.pVMR3;
    5555    PVMCPU pVCpu = &pVM->aCpus[0];  /* for PIC we always deliver to CPU 0, MP use APIC */
     56
     57    /* IRQ state should be loaded as-is by "LoadExec". Changes can be made from LoadDone. */
     58    Assert(pVM->enmVMState != VMSTATE_LOADING || pVM->pdm.s.fStateLoaded);
     59
    5660    APICLocalInterrupt(pVCpu, 0 /* u8Pin */, 1 /* u8Level */, VINF_SUCCESS /* rcRZ */);
    5761}
     
    6468    PVM pVM = pDevIns->Internal.s.pVMR3;
    6569    PVMCPU pVCpu = &pVM->aCpus[0];  /* for PIC we always deliver to CPU 0, MP use APIC */
     70
     71    /* IRQ state should be loaded as-is by "LoadExec". Changes can be made from LoadDone. */
     72    Assert(pVM->enmVMState != VMSTATE_LOADING || pVM->pdm.s.fStateLoaded);
     73
    6674    APICLocalInterrupt(pVCpu, 0 /* u8Pin */,  0 /* u8Level */, VINF_SUCCESS /* rcRZ */);
    6775}
  • trunk/src/VBox/VMM/include/PDMInternal.h

    r76585 r78208  
    10801080    /** Pending reset flags (PDMVMRESET_F_XXX). */
    10811081    uint32_t volatile               fResetFlags;
     1082
     1083    /** Set by pdmR3LoadExec for use in assertions. */
     1084    bool                            fStateLoaded;
    10821085    /** Alignment padding. */
    1083     uint32_t volatile               u32Padding;
     1086    bool                            afPadding[3];
    10841087
    10851088    /** The tracing ID of the next device instance.
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