Changeset 92613 in vbox for trunk/src/VBox/HostDrivers/Support
- Timestamp:
- Nov 26, 2021 9:53:47 PM (3 years ago)
- svn:sync-xref-src-repo-rev:
- 148505
- Location:
- trunk/src/VBox/HostDrivers/Support
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/Support/SUPLib.cpp
r92556 r92613 210 210 211 211 212 SUPR3DECL(int) SUPR3InitEx( bool fUnrestricted, PSUPDRVSESSION *ppSession)212 SUPR3DECL(int) SUPR3InitEx(uint32_t fFlags, PSUPDRVSESSION *ppSession) 213 213 { 214 214 /* … … 230 230 if (g_cInits++ > 0) 231 231 { 232 if ( fUnrestricted&& !g_supLibData.fUnrestricted)232 if ((fFlags & SUPR3INIT_F_UNRESTRICTED) && !g_supLibData.fUnrestricted) 233 233 { 234 234 g_cInits--; … … 262 262 */ 263 263 SUPINITOP enmWhat = kSupInitOp_Driver; 264 int rc = suplibOsInit(&g_supLibData, g_fPreInited, f Unrestricted, &enmWhat, NULL);264 int rc = suplibOsInit(&g_supLibData, g_fPreInited, fFlags, &enmWhat, NULL); 265 265 if (RT_SUCCESS(rc)) 266 266 { … … 398 398 SUPR3DECL(int) SUPR3Init(PSUPDRVSESSION *ppSession) 399 399 { 400 return SUPR3InitEx( true, ppSession);400 return SUPR3InitEx(SUPR3INIT_F_UNRESTRICTED, ppSession); 401 401 } 402 402 -
trunk/src/VBox/HostDrivers/Support/SUPLibAll.cpp
r87702 r92613 328 328 329 329 /** 330 * SLow path in SUPGetGipCpuPtr, don't call directly. 331 * 332 * @returns Pointer to the CPU entry for the caller, NULL on failure. 333 * @param pGip The GIP. 334 */ 335 SUPDECL(PSUPGIPCPU) SUPGetGipCpuPtrForAsyncMode(PSUPGLOBALINFOPAGE pGip) 336 { 337 uint16_t iGipCpu = supGetGipCpuIndex(pGip); 338 if (RT_LIKELY(iGipCpu < pGip->cCpus)) 339 return &pGip->aCPUs[iGipCpu]; 340 AssertFailed(); 341 return NULL; 342 } 343 344 345 /** 330 346 * Slow path in SUPGetCpuHzFromGip, don't call directly. 331 347 * -
trunk/src/VBox/HostDrivers/Support/SUPLibInternal.h
r92556 r92613 360 360 DECLHIDDEN(int) suplibOsInstall(void); 361 361 DECLHIDDEN(int) suplibOsUninstall(void); 362 DECLHIDDEN(int) suplibOsInit(PSUPLIBDATA pThis, bool fPreInited, bool fUnrestricted, SUPINITOP *penmWhat, PRTERRINFO pErrInfo);362 DECLHIDDEN(int) suplibOsInit(PSUPLIBDATA pThis, bool fPreInited, uint32_t fFlags, SUPINITOP *penmWhat, PRTERRINFO pErrInfo); 363 363 DECLHIDDEN(int) suplibOsTerm(PSUPLIBDATA pThis); 364 364 DECLHIDDEN(int) suplibOsHardenedVerifyInit(void); -
trunk/src/VBox/HostDrivers/Support/SUPR3HardenedMain.cpp
r87593 r92613 550 550 /** The program name. */ 551 551 static const char *g_pszSupLibHardenedProgName; 552 /** The flags passed to SUPR3HardenedMain . */552 /** The flags passed to SUPR3HardenedMain - SUPSECMAIN_FLAGS_XXX. */ 553 553 static uint32_t g_fSupHardenedMain; 554 554 … … 1864 1864 RTERRINFOSTATIC ErrInfo; 1865 1865 SUPINITOP enmWhat = kSupInitOp_Driver; 1866 int rc = suplibOsInit(&g_SupPreInitData.Data, false /*fPreInit*/, true /*fUnrestricted*/, 1867 &enmWhat, RTErrInfoInitStatic(&ErrInfo)); 1866 uint32_t fFlags = SUPR3INIT_F_UNRESTRICTED; 1867 if (g_fSupHardenedMain & SUPSECMAIN_FLAGS_DRIVERLESS_IEM_ALLOWED) 1868 fFlags |= SUPR3INIT_F_DRIVERLESS_IEM_ALLOWED; 1869 #ifdef VBOX_WITH_DRIVERLESS_NEM_FALLBACK 1870 if (g_fSupHardenedMain & SUPSECMAIN_FLAGS_DRIVERLESS_NEM_FALLBACK) 1871 fFlags |= SUPR3INIT_F_DRIVERLESS_NEM_FALLBACK; 1872 #endif 1873 int rc = suplibOsInit(&g_SupPreInitData.Data, false /*fPreInit*/, fFlags, &enmWhat, RTErrInfoInitStatic(&ErrInfo)); 1868 1874 if (RT_SUCCESS(rc)) 1869 1875 return; … … 2334 2340 supR3HardenedFatalMsg("supR3HardenedMainInitRuntime", kSupInitOp_IPRT, rc, 2335 2341 "supR3PreInit failed with rc=%d", rc); 2342 2343 /* Get the executable path for the IPRT init on linux if /proc/self/exe isn't accessible. */ 2336 2344 const char *pszExePath = NULL; 2337 2345 #ifdef RT_OS_LINUX … … 2339 2347 pszExePath = g_szSupLibHardenedExePath; 2340 2348 #endif 2341 rc = pfnRTInitEx(RTR3INIT_VER_1, 2342 fFlags & SUPSECMAIN_FLAGS_DONT_OPEN_DEV ? 0 : RTR3INIT_FLAGS_SUPLIB, 2349 2350 /* Assemble the IPRT init flags. We could probably just pass RTR3INIT_FLAGS_TRY_SUPLIB 2351 here and be done with it, but it's not too much hazzle to convert fFlags 1:1. */ 2352 uint32_t fRtInit = 0; 2353 if (!(fFlags & SUPSECMAIN_FLAGS_DONT_OPEN_DEV)) 2354 { 2355 if (fFlags & SUPSECMAIN_FLAGS_DRIVERLESS_IEM_ALLOWED) 2356 fRtInit |= (SUPR3INIT_F_DRIVERLESS_IEM_ALLOWED << RTR3INIT_FLAGS_SUPLIB_SHIFT) | RTR3INIT_FLAGS_TRY_SUPLIB; 2357 #ifdef VBOX_WITH_DRIVERLESS_NEM_FALLBACK 2358 if (fFlags & SUPSECMAIN_FLAGS_DRIVERLESS_NEM_FALLBACK) 2359 fRtInit |= (SUPR3INIT_F_DRIVERLESS_NEM_FALLBACK << RTR3INIT_FLAGS_SUPLIB_SHIFT) | RTR3INIT_FLAGS_TRY_SUPLIB; 2360 #endif 2361 if (!(fRtInit & RTR3INIT_FLAGS_TRY_SUPLIB)) 2362 fRtInit |= RTR3INIT_FLAGS_SUPLIB; 2363 } 2364 2365 /* Now do the IPRT init. */ 2366 rc = pfnRTInitEx(RTR3INIT_VER_CUR, fFlags & SUPSECMAIN_FLAGS_DONT_OPEN_DEV ? 0 : RTR3INIT_FLAGS_SUPLIB, 2343 2367 0 /*cArgs*/, NULL /*papszArgs*/, pszExePath); 2344 2368 if (RT_FAILURE(rc)) 2345 2369 supR3HardenedFatalMsg("supR3HardenedMainInitRuntime", kSupInitOp_IPRT, rc, 2346 "RTR3InitEx failed with rc=%d ", rc);2370 "RTR3InitEx failed with rc=%d (fRtFlags=%#x)", rc, fRtInit); 2347 2371 2348 2372 #if defined(RT_OS_WINDOWS) -
trunk/src/VBox/HostDrivers/Support/darwin/SUPLib-darwin.cpp
r92556 r92613 187 187 188 188 189 DECLHIDDEN(int) suplibOsInit(PSUPLIBDATA pThis, bool fPreInited, bool fUnrestricted, SUPINITOP *penmWhat, PRTERRINFO pErrInfo)189 DECLHIDDEN(int) suplibOsInit(PSUPLIBDATA pThis, bool fPreInited, uint32_t fFlags, SUPINITOP *penmWhat, PRTERRINFO pErrInfo) 190 190 { 191 191 RT_NOREF(penmWhat, pErrInfo); … … 204 204 if (RT_SUCCESS(rc)) 205 205 { 206 rc = suplibDarwinOpenDevice(pThis, fUnrestricted);206 rc = suplibDarwinOpenDevice(pThis, RT_BOOL(fFlags & SUPR3INIT_F_UNRESTRICTED)); 207 207 if (RT_FAILURE(rc)) 208 208 { -
trunk/src/VBox/HostDrivers/Support/freebsd/SUPLib-freebsd.cpp
r92556 r92613 68 68 69 69 70 DECLHIDDEN(int) suplibOsInit(PSUPLIBDATA pThis, bool fPreInited, bool fUnrestricted, SUPINITOP *penmWhat, PRTERRINFO pErrInfo)70 DECLHIDDEN(int) suplibOsInit(PSUPLIBDATA pThis, bool fPreInited, uint32_t fFlags, SUPINITOP *penmWhat, PRTERRINFO pErrInfo) 71 71 { 72 72 /* … … 79 79 * Try open the BSD device. 80 80 */ 81 int hDevice = open(fUnrestricted ? DEVICE_NAME_SYS : DEVICE_NAME_USR, O_RDWR, 0); 81 const char * const *pszDeviceNm = fFlags & SUPR3INIT_F_UNRESTRICTED ? DEVICE_NAME_SYS : DEVICE_NAME_USR; 82 int hDevice = open(pszDeviceNm, O_RDWR, 0); 82 83 if (hDevice < 0) 83 84 { … … 91 92 default: rc = VERR_VM_DRIVER_OPEN_ERROR; break; 92 93 } 93 LogRel(("Failed to open \"%s\", errno=%d, rc=%Rrc\n", fUnrestricted ? DEVICE_NAME_SYS : DEVICE_NAME_USR, errno, rc));94 LogRel(("Failed to open \"%s\", errno=%d, rc=%Rrc\n", pszDeviceNm, errno, rc)); 94 95 return rc; 95 96 } … … 115 116 */ 116 117 pThis->hDevice = hDevice; 117 pThis->fUnrestricted = fUnrestricted;118 pThis->fUnrestricted = RT_BOOL(fFlags & SUPR3INIT_F_UNRESTRICTED); 118 119 return VINF_SUCCESS; 119 120 } -
trunk/src/VBox/HostDrivers/Support/linux/SUPLib-linux.cpp
r92557 r92613 76 76 77 77 78 DECLHIDDEN(int) suplibOsInit(PSUPLIBDATA pThis, bool fPreInited, bool fUnrestricted, SUPINITOP *penmWhat, PRTERRINFO pErrInfo)78 DECLHIDDEN(int) suplibOsInit(PSUPLIBDATA pThis, bool fPreInited, uint32_t fFlags, SUPINITOP *penmWhat, PRTERRINFO pErrInfo) 79 79 { 80 80 RT_NOREF2(penmWhat, pErrInfo); … … 99 99 * Try open the device. 100 100 */ 101 const char *pszDeviceNm = f Unrestricted? DEVICE_NAME_SYS : DEVICE_NAME_USR;101 const char *pszDeviceNm = fFlags & SUPR3INIT_F_UNRESTRICTED ? DEVICE_NAME_SYS : DEVICE_NAME_USR; 102 102 int hDevice = open(pszDeviceNm, O_RDWR, 0); 103 103 if (hDevice < 0) … … 141 141 */ 142 142 pThis->hDevice = hDevice; 143 pThis->fUnrestricted = fUnrestricted;143 pThis->fUnrestricted = RT_BOOL(fFlags & SUPR3INIT_F_UNRESTRICTED); 144 144 return VINF_SUCCESS; 145 145 } -
trunk/src/VBox/HostDrivers/Support/os2/SUPLib-os2.cpp
r92556 r92613 65 65 66 66 67 DECLHIDDEN(int) suplibOsInit(PSUPLIBDATA pThis, bool fPreInited, bool fUnrestricted, SUPINITOP *penmWhat, PRTERRINFO pErrInfo)67 DECLHIDDEN(int) suplibOsInit(PSUPLIBDATA pThis, bool fPreInited, uint32_t fFlags, SUPINITOP *penmWhat, PRTERRINFO pErrInfo) 68 68 { 69 69 /* … … 101 101 pThis->hDevice = hDevice; 102 102 pThis->fUnrestricted = true; 103 RT_NOREF(fFlags); 103 104 return VINF_SUCCESS; 104 105 } -
trunk/src/VBox/HostDrivers/Support/solaris/SUPLib-solaris.cpp
r92556 r92613 79 79 80 80 81 DECLHIDDEN(int) suplibOsInit(PSUPLIBDATA pThis, bool fPreInited, bool fUnrestricted, SUPINITOP *penmWhat, PRTERRINFO pErrInfo)81 DECLHIDDEN(int) suplibOsInit(PSUPLIBDATA pThis, bool fPreInited, uint32_t fFlags, SUPINITOP *penmWhat, PRTERRINFO pErrInfo) 82 82 { 83 83 /* … … 113 113 const char *pszDeviceNm; 114 114 if (getzoneid() == GLOBAL_ZONEID) 115 pszDeviceNm = f Unrestricted? DEVICE_NAME_SYS : DEVICE_NAME_USR;115 pszDeviceNm = fFlags & SUPR3INIT_F_UNRESTRICTED ? DEVICE_NAME_SYS : DEVICE_NAME_USR; 116 116 else 117 pszDeviceNm = f Unrestricted? DEVICE_NAME_SYS_ZONE : DEVICE_NAME_USR_ZONE;117 pszDeviceNm = fFlags & SUPR3INIT_F_UNRESTRICTED ? DEVICE_NAME_SYS_ZONE : DEVICE_NAME_USR_ZONE; 118 118 int hDevice = open(pszDeviceNm, O_RDWR, 0); 119 119 if (hDevice < 0) … … 149 149 150 150 pThis->hDevice = hDevice; 151 pThis->fUnrestricted = fUnrestricted;151 pThis->fUnrestricted = RT_BOOL(fFlags & SUPR3INIT_F_UNRESTRICTED); 152 152 return VINF_SUCCESS; 153 153 } -
trunk/src/VBox/HostDrivers/Support/testcase/SUPLoggerCtl.cpp
r82968 r92613 59 59 int main(int argc, char **argv) 60 60 { 61 RTR3InitExe(argc, &argv, RTR3INIT_FLAGS_ SUPLIB);61 RTR3InitExe(argc, &argv, RTR3INIT_FLAGS_TRY_SUPLIB); 62 62 63 63 /* … … 151 151 152 152 /* 153 * Do the requested job.153 * Make sure the support library is initialized. 154 154 */ 155 int rc ;156 switch (enmWhat)155 int rc = SUPR3Init(NULL /*ppSession*/); 156 if (RT_SUCCESS(rc)) 157 157 { 158 case kSupLoggerCtl_Set: 159 rc = SUPR3LoggerSettings(enmWhich, pszFlags, pszGroups, pszDest); 160 break; 161 case kSupLoggerCtl_Create: 162 rc = SUPR3LoggerCreate(enmWhich, pszFlags, pszGroups, pszDest); 163 break; 164 case kSupLoggerCtl_Destroy: 165 rc = SUPR3LoggerDestroy(enmWhich); 166 break; 167 default: 168 rc = VERR_INTERNAL_ERROR; 169 break; 158 /* 159 * Do the requested job. 160 */ 161 switch (enmWhat) 162 { 163 case kSupLoggerCtl_Set: 164 rc = SUPR3LoggerSettings(enmWhich, pszFlags, pszGroups, pszDest); 165 break; 166 case kSupLoggerCtl_Create: 167 rc = SUPR3LoggerCreate(enmWhich, pszFlags, pszGroups, pszDest); 168 break; 169 case kSupLoggerCtl_Destroy: 170 rc = SUPR3LoggerDestroy(enmWhich); 171 break; 172 default: 173 rc = VERR_INTERNAL_ERROR; 174 break; 175 } 176 if (RT_SUCCESS(rc)) 177 RTPrintf("SUPLoggerCtl: Success\n"); 178 else 179 RTStrmPrintf(g_pStdErr, "SUPLoggerCtl: error: rc=%Rrc\n", rc); 170 180 } 171 if (RT_SUCCESS(rc))172 RTPrintf("SUPLoggerCtl: Success\n");173 181 else 174 RTStrmPrintf(g_pStdErr, "SUP LoggerCtl: error: rc=%Rrc\n", rc);182 RTStrmPrintf(g_pStdErr, "SUPR3Init: error: rc=%Rrc\n", rc); 175 183 176 184 return RT_SUCCESS(rc) ? 0 : 1; -
trunk/src/VBox/HostDrivers/Support/testcase/tstPage.cpp
r92556 r92613 40 40 int cErrors = 0; 41 41 42 RTR3InitExe(argc, &argv, RTR3INIT_FLAGS_ SUPLIB);42 RTR3InitExe(argc, &argv, RTR3INIT_FLAGS_TRY_SUPLIB); 43 43 int rc = SUPR3Init(NULL); 44 44 cErrors += rc != 0; -
trunk/src/VBox/HostDrivers/Support/testcase/tstPin.cpp
r92556 r92613 46 46 RTHCPHYS HCPhys; 47 47 48 RTR3InitExe(argc, &argv, RTR3INIT_FLAGS_ SUPLIB);48 RTR3InitExe(argc, &argv, RTR3INIT_FLAGS_TRY_SUPLIB); 49 49 rc = SUPR3Init(NULL); 50 50 RTPrintf("SUPR3Init -> rc=%d\n", rc); -
trunk/src/VBox/HostDrivers/Support/testcase/tstSupSem-Zombie.cpp
r86397 r92613 95 95 * Init. 96 96 */ 97 int rc = RTR3InitExeNoArguments(RTR3INIT_FLAGS_ SUPLIB);97 int rc = RTR3InitExeNoArguments(RTR3INIT_FLAGS_TRY_SUPLIB); 98 98 if (RT_FAILURE(rc)) 99 99 { -
trunk/src/VBox/HostDrivers/Support/testcase/tstSupSem.cpp
r82968 r92613 80 80 * Init. 81 81 */ 82 int rc = RTR3InitExe(argc, &argv, RTR3INIT_FLAGS_ SUPLIB);82 int rc = RTR3InitExe(argc, &argv, RTR3INIT_FLAGS_TRY_SUPLIB); 83 83 if (RT_FAILURE(rc)) 84 84 return RTMsgInitFailure(rc); -
trunk/src/VBox/HostDrivers/Support/win/SUPLib-win.cpp
r92556 r92613 117 117 118 118 119 DECLHIDDEN(int) suplibOsInit(PSUPLIBDATA pThis, bool fPreInited, bool fUnrestricted, SUPINITOP *penmWhat, PRTERRINFO pErrInfo)119 DECLHIDDEN(int) suplibOsInit(PSUPLIBDATA pThis, bool fPreInited, uint32_t fFlags, SUPINITOP *penmWhat, PRTERRINFO pErrInfo) 120 120 { 121 121 /* … … 156 156 UNICODE_STRING NtName; 157 157 NtName.Buffer = (PWSTR)s_wszName; 158 NtName.Length = sizeof(s_wszName) - sizeof(WCHAR) * (f Unrestricted? 2 : 1);158 NtName.Length = sizeof(s_wszName) - sizeof(WCHAR) * (fFlags & SUPR3INIT_F_UNRESTRICTED ? 2 : 1); 159 159 NtName.MaximumLength = NtName.Length; 160 160 … … 183 183 */ 184 184 pThis->hDevice = hDevice; 185 pThis->fUnrestricted = fUnrestricted;185 pThis->fUnrestricted = RT_BOOL(fFlags & SUPR3INIT_F_UNRESTRICTED); 186 186 return VINF_SUCCESS; 187 187 }
Note:
See TracChangeset
for help on using the changeset viewer.