Changeset 57249 in vbox for trunk/src/VBox/VMM
- Timestamp:
- Aug 8, 2015 1:18:40 AM (9 years ago)
- Location:
- trunk/src/VBox/VMM/VMMR0
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR0/GVMMR0.cpp
r56287 r57249 89 89 # define GVMM_SCHED_WITH_PPT 90 90 #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 91 138 92 139 … … 1777 1824 { 1778 1825 LogFlow(("GVMMR0SchedHalt: pVM=%p\n", pVM)); 1826 GVMM_CHECK_SMAP_SETUP(); 1827 GVMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING); 1779 1828 1780 1829 /* … … 1787 1836 return rc; 1788 1837 pGVM->gvmm.s.StatsSched.cHaltCalls++; 1838 GVMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING); 1789 1839 1790 1840 PGVMCPU pCurGVCpu = &pGVM->aCpus[idCpu]; … … 1798 1848 rc = gvmmR0UsedLock(pGVMM); 1799 1849 AssertRC(rc); 1850 GVMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING); 1800 1851 1801 1852 pCurGVCpu->gvmm.s.iCpuEmt = ASMGetApicId(); … … 1807 1858 const uint64_t u64NowSys = RTTimeSystemNanoTS(); 1808 1859 const uint64_t u64NowGip = RTTimeNanoTS(); 1860 GVMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING); 1809 1861 pGVM->gvmm.s.StatsSched.cHaltWakeUps += gvmmR0SchedDoWakeUps(pGVMM, u64NowGip); 1862 GVMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING); 1810 1863 1811 1864 /* … … 1827 1880 ASMAtomicIncU32(&pGVMM->cHaltedEMTs); 1828 1881 gvmmR0UsedUnlock(pGVMM); 1882 GVMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING); 1829 1883 1830 1884 rc = RTSemEventMultiWaitEx(pCurGVCpu->gvmm.s.HaltEventMulti, 1831 1885 RTSEMWAIT_FLAGS_ABSOLUTE | RTSEMWAIT_FLAGS_NANOSECS | RTSEMWAIT_FLAGS_INTERRUPTIBLE, 1832 1886 u64NowGip > u64NowSys ? u64ExpireGipTime : u64NowSys + cNsInterval); 1887 GVMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING); 1833 1888 1834 1889 ASMAtomicWriteU64(&pCurGVCpu->gvmm.s.u64HaltExpire, 0); … … 1837 1892 /* Reset the semaphore to try prevent a few false wake-ups. */ 1838 1893 if (rc == VINF_SUCCESS) 1894 { 1839 1895 RTSemEventMultiReset(pCurGVCpu->gvmm.s.HaltEventMulti); 1896 GVMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING); 1897 } 1840 1898 else if (rc == VERR_TIMEOUT) 1841 1899 { … … 1848 1906 pGVM->gvmm.s.StatsSched.cHaltNotBlocking++; 1849 1907 gvmmR0UsedUnlock(pGVMM); 1908 GVMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING); 1850 1909 RTSemEventMultiReset(pCurGVCpu->gvmm.s.HaltEventMulti); 1910 GVMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING); 1851 1911 } 1852 1912 … … 1911 1971 GVMMR0DECL(int) GVMMR0SchedWakeUpEx(PVM pVM, VMCPUID idCpu, bool fTakeUsedLock) 1912 1972 { 1973 GVMM_CHECK_SMAP_SETUP(); 1974 GVMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING); 1975 1913 1976 /* 1914 1977 * Validate input and take the UsedLock. … … 1917 1980 PGVMM pGVMM; 1918 1981 int rc = gvmmR0ByVM(pVM, &pGVM, &pGVMM, fTakeUsedLock); 1982 GVMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING); 1919 1983 if (RT_SUCCESS(rc)) 1920 1984 { … … 1925 1989 */ 1926 1990 rc = gvmmR0SchedWakeUpOne(pGVM, &pGVM->aCpus[idCpu]); 1991 GVMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING); 1927 1992 1928 1993 if (fTakeUsedLock) … … 1934 1999 const uint64_t u64Now = RTTimeNanoTS(); /* (GIP time) */ 1935 2000 pGVM->gvmm.s.StatsSched.cWakeUpWakeUps += gvmmR0SchedDoWakeUps(pGVMM, u64Now); 2001 GVMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING); 1936 2002 } 1937 2003 } … … 1943 2009 int rc2 = gvmmR0UsedUnlock(pGVMM); 1944 2010 AssertRC(rc2); 2011 GVMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING); 1945 2012 } 1946 2013 } … … 2062 2129 AssertPtrReturn(pSleepSet, VERR_INVALID_POINTER); 2063 2130 AssertPtrReturn(pPokeSet, VERR_INVALID_POINTER); 2131 GVMM_CHECK_SMAP_SETUP(); 2132 GVMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING); 2064 2133 RTNATIVETHREAD hSelf = RTThreadNativeSelf(); 2065 2134 … … 2070 2139 PGVMM pGVMM; 2071 2140 int rc = gvmmR0ByVM(pVM, &pGVM, &pGVMM, true /* fTakeUsedLock */); 2141 GVMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING); 2072 2142 if (RT_SUCCESS(rc)) 2073 2143 { … … 2082 2152 /* just ignore errors for now. */ 2083 2153 if (VMCPUSET_IS_PRESENT(pSleepSet, idCpu)) 2154 { 2084 2155 gvmmR0SchedWakeUpOne(pGVM, &pGVM->aCpus[idCpu]); 2156 GVMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING); 2157 } 2085 2158 else if (VMCPUSET_IS_PRESENT(pPokeSet, idCpu)) 2159 { 2086 2160 gvmmR0SchedPokeOne(pGVM, &pVM->aCpus[idCpu]); 2161 GVMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING); 2162 } 2087 2163 } 2088 2164 2089 2165 int rc2 = gvmmR0UsedUnlock(pGVMM); 2090 2166 AssertRC(rc2); 2167 GVMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING); 2091 2168 } 2092 2169 -
trunk/src/VBox/VMM/VMMR0/VMMR0.cpp
r57247 r57249 65 65 * Defined Constants And Macros * 66 66 *******************************************************************************/ 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) \ 72 79 do { \ 73 80 if (fKernelFeatures & SUPKERNELFEATURES_SMAP) \ … … 83 90 } \ 84 91 } 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) \ 89 93 do { \ 90 94 if (fKernelFeatures & SUPKERNELFEATURES_SMAP) \ … … 102 106 } \ 103 107 } 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 104 113 105 114 … … 1374 1383 if (pReqHdr) 1375 1384 return VERR_INVALID_PARAMETER; 1385 VMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING); 1376 1386 rc = GVMMR0SchedHalt(pVM, idCpu, u64Arg); 1377 1387 VMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING); … … 1381 1391 if (pReqHdr || u64Arg) 1382 1392 return VERR_INVALID_PARAMETER; 1393 VMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING); 1383 1394 rc = GVMMR0SchedWakeUp(pVM, idCpu); 1384 1395 VMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING);
Note:
See TracChangeset
for help on using the changeset viewer.