Changeset 72778 in vbox for trunk/src/VBox/VMM/VMMR0
- Timestamp:
- Jun 29, 2018 8:02:35 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 123320
- Location:
- trunk/src/VBox/VMM/VMMR0
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR0/GVMMR0.cpp
r72428 r72778 1913 1913 * Search the handles in a linear fashion as we don't dare to take the lock (assert). 1914 1914 */ 1915 /** @todo introduce some pid hash table here, please. */ 1915 1916 for (unsigned i = 1; i < RT_ELEMENTS(pGVMM->aHandles); i++) 1916 1917 { … … 1927 1928 PGVM pGVM = pGVMM->aHandles[i].pGVM; 1928 1929 VMCPUID const cCpus = pGVM->cCpus; 1930 ASMCompilerBarrier(); 1929 1931 if ( cCpus < 1 1930 1932 || cCpus > VMM_MAX_CPU_COUNT) … … 1933 1935 if (pGVM->aCpus[idCpu].hEMT == hEMT) 1934 1936 return pGVMM->aHandles[i].pVM; 1937 } 1938 } 1939 return NULL; 1940 } 1941 1942 1943 /** 1944 * Looks up the GVMCPU belonging to the specified EMT thread. 1945 * 1946 * This is used by the assertion machinery in VMMR0.cpp to avoid causing 1947 * unnecessary kernel panics when the EMT thread hits an assertion. The 1948 * call may or not be an EMT thread. 1949 * 1950 * @returns Pointer to the VM on success, NULL on failure. 1951 * @param hEMT The native thread handle of the EMT. 1952 * NIL_RTNATIVETHREAD means the current thread 1953 */ 1954 GVMMR0DECL(PGVMCPU) GVMMR0GetGVCpuByEMT(RTNATIVETHREAD hEMT) 1955 { 1956 /* 1957 * No Assertions here as we're usually called in a AssertMsgN, 1958 * RTAssert*, Log and LogRel contexts. 1959 */ 1960 PGVMM pGVMM = g_pGVMM; 1961 if ( !VALID_PTR(pGVMM) 1962 || pGVMM->u32Magic != GVMM_MAGIC) 1963 return NULL; 1964 1965 if (hEMT == NIL_RTNATIVETHREAD) 1966 hEMT = RTThreadNativeSelf(); 1967 RTPROCESS ProcId = RTProcSelf(); 1968 1969 /* 1970 * Search the handles in a linear fashion as we don't dare to take the lock (assert). 1971 */ 1972 /** @todo introduce some pid hash table here, please. */ 1973 for (unsigned i = 1; i < RT_ELEMENTS(pGVMM->aHandles); i++) 1974 { 1975 if ( pGVMM->aHandles[i].iSelf == i 1976 && pGVMM->aHandles[i].ProcId == ProcId 1977 && VALID_PTR(pGVMM->aHandles[i].pvObj) 1978 && VALID_PTR(pGVMM->aHandles[i].pVM) 1979 && VALID_PTR(pGVMM->aHandles[i].pGVM)) 1980 { 1981 PGVM pGVM = pGVMM->aHandles[i].pGVM; 1982 if (pGVMM->aHandles[i].hEMT0 == hEMT) 1983 return &pGVM->aCpus[0]; 1984 1985 /* This is fearly safe with the current process per VM approach. */ 1986 VMCPUID const cCpus = pGVM->cCpus; 1987 ASMCompilerBarrier(); 1988 ASMCompilerBarrier(); 1989 if ( cCpus < 1 1990 || cCpus > VMM_MAX_CPU_COUNT) 1991 continue; 1992 for (VMCPUID idCpu = 1; idCpu < cCpus; idCpu++) 1993 if (pGVM->aCpus[idCpu].hEMT == hEMT) 1994 return &pGVM->aCpus[idCpu]; 1935 1995 } 1936 1996 } -
trunk/src/VBox/VMM/VMMR0/VMMR0.cpp
r72642 r72778 390 390 return rc; 391 391 392 393 392 #ifdef LOG_ENABLED 394 393 /* … … 2345 2344 } 2346 2345 2347 /**2348 * Internal R0 logger worker: Custom prefix.2349 *2350 * @returns Number of chars written.2351 *2352 * @param pLogger The logger instance.2353 * @param pchBuf The output buffer.2354 * @param cchBuf The size of the buffer.2355 * @param pvUser User argument (ignored).2356 */2357 VMMR0DECL(size_t) vmmR0LoggerPrefix(PRTLOGGER pLogger, char *pchBuf, size_t cchBuf, void *pvUser)2358 {2359 NOREF(pvUser);2360 #ifdef LOG_ENABLED2361 PVMMR0LOGGER pR0Logger = (PVMMR0LOGGER)((uintptr_t)pLogger - RT_OFFSETOF(VMMR0LOGGER, Logger));2362 if ( !VALID_PTR(pR0Logger)2363 || !VALID_PTR(pR0Logger + 1)2364 || pLogger->u32Magic != RTLOGGER_MAGIC2365 || cchBuf < 2)2366 return 0;2367 2368 static const char s_szHex[17] = "0123456789abcdef";2369 VMCPUID const idCpu = pR0Logger->idCpu;2370 pchBuf[1] = s_szHex[ idCpu & 15];2371 pchBuf[0] = s_szHex[(idCpu >> 4) & 15];2372 2373 return 2;2374 #else2375 NOREF(pLogger); NOREF(pchBuf); NOREF(cchBuf);2376 return 0;2377 #endif2378 }2379 2380 2346 #ifdef LOG_ENABLED 2381 2347 … … 2389 2355 if (pVCpu->vmm.s.pR0LoggerR0) 2390 2356 pVCpu->vmm.s.pR0LoggerR0->fFlushingDisabled = true; 2357 if (pVCpu->vmm.s.pR0RelLoggerR0) 2358 pVCpu->vmm.s.pR0RelLoggerR0->fFlushingDisabled = true; 2391 2359 } 2392 2360 … … 2401 2369 if (pVCpu->vmm.s.pR0LoggerR0) 2402 2370 pVCpu->vmm.s.pR0LoggerR0->fFlushingDisabled = false; 2371 if (pVCpu->vmm.s.pR0RelLoggerR0) 2372 pVCpu->vmm.s.pR0RelLoggerR0->fFlushingDisabled = false; 2403 2373 } 2404 2374 … … 2413 2383 if (pVCpu->vmm.s.pR0LoggerR0) 2414 2384 return pVCpu->vmm.s.pR0LoggerR0->fFlushingDisabled; 2385 if (pVCpu->vmm.s.pR0RelLoggerR0) 2386 return pVCpu->vmm.s.pR0RelLoggerR0->fFlushingDisabled; 2415 2387 return true; 2416 2388 } 2389 2417 2390 #endif /* LOG_ENABLED */ 2391 2392 /** 2393 * Override RTLogRelGetDefaultInstanceEx so we can do LogRel to VBox.log from EMTs in ring-0. 2394 */ 2395 DECLEXPORT(PRTLOGGER) RTLogRelGetDefaultInstanceEx(uint32_t fFlagsAndGroup) 2396 { 2397 PGVMCPU pGVCpu = GVMMR0GetGVCpuByEMT(NIL_RTNATIVETHREAD); 2398 if (pGVCpu) 2399 { 2400 PVMCPU pVCpu = pGVCpu->pVCpu; 2401 if (RT_VALID_PTR(pVCpu)) 2402 { 2403 PVMMR0LOGGER pVmmLogger = pVCpu->vmm.s.pR0RelLoggerR0; 2404 if (RT_VALID_PTR(pVmmLogger)) 2405 { 2406 if ( pVmmLogger->fCreated 2407 && pVmmLogger->pVM == pGVCpu->pVM) 2408 { 2409 if (pVmmLogger->Logger.fFlags & RTLOGFLAGS_DISABLED) 2410 return NULL; 2411 uint16_t const fFlags = RT_LO_U16(fFlagsAndGroup); 2412 uint16_t const iGroup = RT_HI_U16(fFlagsAndGroup); 2413 if ( iGroup != UINT16_MAX 2414 && ( ( pVmmLogger->Logger.afGroups[iGroup < pVmmLogger->Logger.cGroups ? iGroup : 0] 2415 & (fFlags | (uint32_t)RTLOGGRPFLAGS_ENABLED)) 2416 != (fFlags | (uint32_t)RTLOGGRPFLAGS_ENABLED))) 2417 return NULL; 2418 return &pVmmLogger->Logger; 2419 } 2420 } 2421 } 2422 } 2423 return SUPR0GetDefaultLogRelInstanceEx(fFlagsAndGroup); 2424 } 2425 2418 2426 2419 2427 /**
Note:
See TracChangeset
for help on using the changeset viewer.