VirtualBox

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


Ignore:
Timestamp:
Aug 8, 2015 1:18:40 AM (9 years ago)
Author:
vboxsync
Message:

GVMMR0,VMMR0: More AC != 0 checks to try pinpoint the problem.

Location:
trunk/src/VBox/VMM/VMMR0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR0/GVMMR0.cpp

    r56287 r57249  
    8989# define GVMM_SCHED_WITH_PPT
    9090#endif
     91
     92
     93/** @def GVMM_CHECK_SMAP_SETUP
     94 * SMAP check setup. */
     95/** @def GVMM_CHECK_SMAP_CHECK
     96 * Checks that the AC flag is set if SMAP is enabled. If AC is not set,
     97 * it will be logged and @a a_BadExpr is executed. */
     98/** @def GVMM_CHECK_SMAP_CHECK2
     99 * Checks that the AC flag is set if SMAP is enabled.  If AC is not set, it will
     100 * be logged, written to the VMs assertion text buffer, and @a a_BadExpr is
     101 * executed. */
     102#if defined(VBOX_STRICT) || 1
     103# define GVMM_CHECK_SMAP_SETUP() uint32_t const fKernelFeatures = SUPR0GetKernelFeatures()
     104# define GVMM_CHECK_SMAP_CHECK(a_BadExpr) \
     105    do { \
     106        if (fKernelFeatures & SUPKERNELFEATURES_SMAP) \
     107        { \
     108            RTCCUINTREG fEflCheck = ASMGetFlags(); \
     109            if (RT_LIKELY(fEflCheck & X86_EFL_AC)) \
     110            { /* likely */ } \
     111            else \
     112            { \
     113                SUPR0Printf("%s, line %d: EFLAGS.AC is clear! (%#x)\n", __FUNCTION__, __LINE__, (uint32_t)fEflCheck); \
     114                a_BadExpr; \
     115            } \
     116        } \
     117    } while (0)
     118# define GVMM_CHECK_SMAP_CHECK2(a_pVM, a_BadExpr) \
     119    do { \
     120        if (fKernelFeatures & SUPKERNELFEATURES_SMAP) \
     121        { \
     122            RTCCUINTREG fEflCheck = ASMGetFlags(); \
     123            if (RT_LIKELY(fEflCheck & X86_EFL_AC)) \
     124            { /* likely */ } \
     125            else \
     126            { \
     127                SUPR0BadContext((a_pVM) ? (a_pVM)->pSession : NULL, __FILE__, __LINE__, "EFLAGS.AC is zero!"); \
     128                a_BadExpr; \
     129            } \
     130        } \
     131    } while (0)
     132#else
     133# define GVMM_CHECK_SMAP_SETUP()           uint32_t const fKernelFeatures = 0
     134# define GVMM_CHECK_SMAP_CHECK(a_BadExpr)           NOREF(fKernelFeatures)
     135# define GVMM_CHECK_SMAP_CHECK2(a_pVM, a_BadExpr)   NOREF(fKernelFeatures)
     136#endif
     137
    91138
    92139
     
    17771824{
    17781825    LogFlow(("GVMMR0SchedHalt: pVM=%p\n", pVM));
     1826    GVMM_CHECK_SMAP_SETUP();
     1827    GVMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING);
    17791828
    17801829    /*
     
    17871836        return rc;
    17881837    pGVM->gvmm.s.StatsSched.cHaltCalls++;
     1838    GVMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING);
    17891839
    17901840    PGVMCPU pCurGVCpu = &pGVM->aCpus[idCpu];
     
    17981848    rc = gvmmR0UsedLock(pGVMM);
    17991849    AssertRC(rc);
     1850    GVMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING);
    18001851
    18011852    pCurGVCpu->gvmm.s.iCpuEmt = ASMGetApicId();
     
    18071858    const uint64_t u64NowSys = RTTimeSystemNanoTS();
    18081859    const uint64_t u64NowGip = RTTimeNanoTS();
     1860    GVMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING);
    18091861    pGVM->gvmm.s.StatsSched.cHaltWakeUps += gvmmR0SchedDoWakeUps(pGVMM, u64NowGip);
     1862    GVMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING);
    18101863
    18111864    /*
     
    18271880        ASMAtomicIncU32(&pGVMM->cHaltedEMTs);
    18281881        gvmmR0UsedUnlock(pGVMM);
     1882        GVMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING);
    18291883
    18301884        rc = RTSemEventMultiWaitEx(pCurGVCpu->gvmm.s.HaltEventMulti,
    18311885                                   RTSEMWAIT_FLAGS_ABSOLUTE | RTSEMWAIT_FLAGS_NANOSECS | RTSEMWAIT_FLAGS_INTERRUPTIBLE,
    18321886                                   u64NowGip > u64NowSys ? u64ExpireGipTime : u64NowSys + cNsInterval);
     1887        GVMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING);
    18331888
    18341889        ASMAtomicWriteU64(&pCurGVCpu->gvmm.s.u64HaltExpire, 0);
     
    18371892        /* Reset the semaphore to try prevent a few false wake-ups. */
    18381893        if (rc == VINF_SUCCESS)
     1894        {
    18391895            RTSemEventMultiReset(pCurGVCpu->gvmm.s.HaltEventMulti);
     1896            GVMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING);
     1897        }
    18401898        else if (rc == VERR_TIMEOUT)
    18411899        {
     
    18481906        pGVM->gvmm.s.StatsSched.cHaltNotBlocking++;
    18491907        gvmmR0UsedUnlock(pGVMM);
     1908        GVMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING);
    18501909        RTSemEventMultiReset(pCurGVCpu->gvmm.s.HaltEventMulti);
     1910        GVMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING);
    18511911    }
    18521912
     
    19111971GVMMR0DECL(int) GVMMR0SchedWakeUpEx(PVM pVM, VMCPUID idCpu, bool fTakeUsedLock)
    19121972{
     1973    GVMM_CHECK_SMAP_SETUP();
     1974    GVMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING);
     1975
    19131976    /*
    19141977     * Validate input and take the UsedLock.
     
    19171980    PGVMM pGVMM;
    19181981    int rc = gvmmR0ByVM(pVM, &pGVM, &pGVMM, fTakeUsedLock);
     1982    GVMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING);
    19191983    if (RT_SUCCESS(rc))
    19201984    {
     
    19251989             */
    19261990            rc = gvmmR0SchedWakeUpOne(pGVM, &pGVM->aCpus[idCpu]);
     1991            GVMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING);
    19271992
    19281993            if (fTakeUsedLock)
     
    19341999                const uint64_t u64Now = RTTimeNanoTS(); /* (GIP time) */
    19352000                pGVM->gvmm.s.StatsSched.cWakeUpWakeUps += gvmmR0SchedDoWakeUps(pGVMM, u64Now);
     2001                GVMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING);
    19362002            }
    19372003        }
     
    19432009            int rc2 = gvmmR0UsedUnlock(pGVMM);
    19442010            AssertRC(rc2);
     2011            GVMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING);
    19452012        }
    19462013    }
     
    20622129    AssertPtrReturn(pSleepSet, VERR_INVALID_POINTER);
    20632130    AssertPtrReturn(pPokeSet, VERR_INVALID_POINTER);
     2131    GVMM_CHECK_SMAP_SETUP();
     2132    GVMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING);
    20642133    RTNATIVETHREAD hSelf = RTThreadNativeSelf();
    20652134
     
    20702139    PGVMM pGVMM;
    20712140    int rc = gvmmR0ByVM(pVM, &pGVM, &pGVMM, true /* fTakeUsedLock */);
     2141    GVMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING);
    20722142    if (RT_SUCCESS(rc))
    20732143    {
     
    20822152            /* just ignore errors for now. */
    20832153            if (VMCPUSET_IS_PRESENT(pSleepSet, idCpu))
     2154            {
    20842155                gvmmR0SchedWakeUpOne(pGVM, &pGVM->aCpus[idCpu]);
     2156                GVMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING);
     2157            }
    20852158            else if (VMCPUSET_IS_PRESENT(pPokeSet, idCpu))
     2159            {
    20862160                gvmmR0SchedPokeOne(pGVM, &pVM->aCpus[idCpu]);
     2161                GVMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING);
     2162            }
    20872163        }
    20882164
    20892165        int rc2 = gvmmR0UsedUnlock(pGVMM);
    20902166        AssertRC(rc2);
     2167        GVMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING);
    20912168    }
    20922169
  • trunk/src/VBox/VMM/VMMR0/VMMR0.cpp

    r57247 r57249  
    6565*   Defined Constants And Macros                                               *
    6666*******************************************************************************/
    67 /** SMAP check setup. */
    68 #define VMM_CHECK_SMAP_SETUP() uint32_t const fKernelFeatures = SUPR0GetKernelFeatures()
    69 /** Checks that the AC flag is set if SMAP is enabled.  If AC is not set, it
    70  * will be logged and @a a_BadExpr is executed. */
    71 #define VMM_CHECK_SMAP_CHECK(a_BadExpr) \
     67/** @def VMM_CHECK_SMAP_SETUP
     68 * SMAP check setup. */
     69/** @def VMM_CHECK_SMAP_CHECK
     70 * Checks that the AC flag is set if SMAP is enabled. If AC is not set,
     71 * it will be logged and @a a_BadExpr is executed. */
     72/** @def VMM_CHECK_SMAP_CHECK2
     73 * Checks that the AC flag is set if SMAP is enabled.  If AC is not set, it will
     74 * be logged, written to the VMs assertion text buffer, and @a a_BadExpr is
     75 * executed. */
     76#if defined(VBOX_STRICT) || 1
     77# define VMM_CHECK_SMAP_SETUP() uint32_t const fKernelFeatures = SUPR0GetKernelFeatures()
     78# define VMM_CHECK_SMAP_CHECK(a_BadExpr) \
    7279    do { \
    7380        if (fKernelFeatures & SUPKERNELFEATURES_SMAP) \
     
    8390        } \
    8491    } while (0)
    85 /** Checks that the AC flag is set if SMAP is enabled.  If AC is not set, it
    86  * will be logged, written to the VMs assertion text buffer, and @a a_BadExpr is
    87  * executed. */
    88 #define VMM_CHECK_SMAP_CHECK2(a_pVM, a_BadExpr) \
     92# define VMM_CHECK_SMAP_CHECK2(a_pVM, a_BadExpr) \
    8993    do { \
    9094        if (fKernelFeatures & SUPKERNELFEATURES_SMAP) \
     
    102106        } \
    103107    } while (0)
     108#else
     109# define VMM_CHECK_SMAP_SETUP()            uint32_t const fKernelFeatures = 0
     110# define VMM_CHECK_SMAP_CHECK(a_BadExpr)            NOREF(fKernelFeatures)
     111# define VMM_CHECK_SMAP_CHECK2(a_pVM, a_BadExpr)    NOREF(fKernelFeatures)
     112#endif
    104113
    105114
     
    13741383            if (pReqHdr)
    13751384                return VERR_INVALID_PARAMETER;
     1385            VMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING);
    13761386            rc = GVMMR0SchedHalt(pVM, idCpu, u64Arg);
    13771387            VMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING);
     
    13811391            if (pReqHdr || u64Arg)
    13821392                return VERR_INVALID_PARAMETER;
     1393            VMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING);
    13831394            rc = GVMMR0SchedWakeUp(pVM, idCpu);
    13841395            VMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING);
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