VirtualBox

Ignore:
Timestamp:
Nov 26, 2021 9:53:47 PM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
148505
Message:

SUP,IPRT,++: Adding SUPSECMAIN_FLAGS_DRIVERLESS_IEM_ALLOWED and SUPR3INIT_F_DRIVERLESS_NEM_FALLBACK to SUPLib and RTR3INIT_FLAGS_TRY_SUPLIB to RTR3Init*, the latter probably reflects the actual state there a lot better. Currently only the TRY_SUPLIB option works, the other two aren't really implemented in SUPLib yet. bugref:10138

Location:
trunk/src/VBox/HostDrivers/Support
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/Support/SUPLib.cpp

    r92556 r92613  
    210210
    211211
    212 SUPR3DECL(int) SUPR3InitEx(bool fUnrestricted, PSUPDRVSESSION *ppSession)
     212SUPR3DECL(int) SUPR3InitEx(uint32_t fFlags, PSUPDRVSESSION *ppSession)
    213213{
    214214    /*
     
    230230    if (g_cInits++ > 0)
    231231    {
    232         if (fUnrestricted && !g_supLibData.fUnrestricted)
     232        if ((fFlags & SUPR3INIT_F_UNRESTRICTED) && !g_supLibData.fUnrestricted)
    233233        {
    234234            g_cInits--;
     
    262262     */
    263263    SUPINITOP enmWhat = kSupInitOp_Driver;
    264     int rc = suplibOsInit(&g_supLibData, g_fPreInited, fUnrestricted, &enmWhat, NULL);
     264    int rc = suplibOsInit(&g_supLibData, g_fPreInited, fFlags, &enmWhat, NULL);
    265265    if (RT_SUCCESS(rc))
    266266    {
     
    398398SUPR3DECL(int) SUPR3Init(PSUPDRVSESSION *ppSession)
    399399{
    400     return SUPR3InitEx(true, ppSession);
     400    return SUPR3InitEx(SUPR3INIT_F_UNRESTRICTED, ppSession);
    401401}
    402402
  • trunk/src/VBox/HostDrivers/Support/SUPLibAll.cpp

    r87702 r92613  
    328328
    329329/**
     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 */
     335SUPDECL(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/**
    330346 * Slow path in SUPGetCpuHzFromGip, don't call directly.
    331347 *
  • trunk/src/VBox/HostDrivers/Support/SUPLibInternal.h

    r92556 r92613  
    360360DECLHIDDEN(int)     suplibOsInstall(void);
    361361DECLHIDDEN(int)     suplibOsUninstall(void);
    362 DECLHIDDEN(int)     suplibOsInit(PSUPLIBDATA pThis, bool fPreInited, bool fUnrestricted, SUPINITOP *penmWhat, PRTERRINFO pErrInfo);
     362DECLHIDDEN(int)     suplibOsInit(PSUPLIBDATA pThis, bool fPreInited, uint32_t fFlags, SUPINITOP *penmWhat, PRTERRINFO pErrInfo);
    363363DECLHIDDEN(int)     suplibOsTerm(PSUPLIBDATA pThis);
    364364DECLHIDDEN(int)     suplibOsHardenedVerifyInit(void);
  • trunk/src/VBox/HostDrivers/Support/SUPR3HardenedMain.cpp

    r87593 r92613  
    550550/** The program name. */
    551551static const char      *g_pszSupLibHardenedProgName;
    552 /** The flags passed to SUPR3HardenedMain. */
     552/** The flags passed to SUPR3HardenedMain - SUPSECMAIN_FLAGS_XXX. */
    553553static uint32_t         g_fSupHardenedMain;
    554554
     
    18641864    RTERRINFOSTATIC ErrInfo;
    18651865    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));
    18681874    if (RT_SUCCESS(rc))
    18691875        return;
     
    23342340        supR3HardenedFatalMsg("supR3HardenedMainInitRuntime", kSupInitOp_IPRT, rc,
    23352341                              "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. */
    23362344    const char *pszExePath = NULL;
    23372345#ifdef RT_OS_LINUX
     
    23392347        pszExePath = g_szSupLibHardenedExePath;
    23402348#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,
    23432367                     0 /*cArgs*/, NULL /*papszArgs*/, pszExePath);
    23442368    if (RT_FAILURE(rc))
    23452369        supR3HardenedFatalMsg("supR3HardenedMainInitRuntime", kSupInitOp_IPRT, rc,
    2346                               "RTR3InitEx failed with rc=%d", rc);
     2370                              "RTR3InitEx failed with rc=%d (fRtFlags=%#x)", rc, fRtInit);
    23472371
    23482372#if defined(RT_OS_WINDOWS)
  • trunk/src/VBox/HostDrivers/Support/darwin/SUPLib-darwin.cpp

    r92556 r92613  
    187187
    188188
    189 DECLHIDDEN(int) suplibOsInit(PSUPLIBDATA pThis, bool fPreInited, bool fUnrestricted, SUPINITOP *penmWhat, PRTERRINFO pErrInfo)
     189DECLHIDDEN(int) suplibOsInit(PSUPLIBDATA pThis, bool fPreInited, uint32_t fFlags, SUPINITOP *penmWhat, PRTERRINFO pErrInfo)
    190190{
    191191    RT_NOREF(penmWhat, pErrInfo);
     
    204204    if (RT_SUCCESS(rc))
    205205    {
    206         rc = suplibDarwinOpenDevice(pThis, fUnrestricted);
     206        rc = suplibDarwinOpenDevice(pThis, RT_BOOL(fFlags & SUPR3INIT_F_UNRESTRICTED));
    207207        if (RT_FAILURE(rc))
    208208        {
  • trunk/src/VBox/HostDrivers/Support/freebsd/SUPLib-freebsd.cpp

    r92556 r92613  
    6868
    6969
    70 DECLHIDDEN(int) suplibOsInit(PSUPLIBDATA pThis, bool fPreInited, bool fUnrestricted, SUPINITOP *penmWhat, PRTERRINFO pErrInfo)
     70DECLHIDDEN(int) suplibOsInit(PSUPLIBDATA pThis, bool fPreInited, uint32_t fFlags, SUPINITOP *penmWhat, PRTERRINFO pErrInfo)
    7171{
    7272    /*
     
    7979     * Try open the BSD device.
    8080     */
    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);
    8283    if (hDevice < 0)
    8384    {
     
    9192            default:        rc = VERR_VM_DRIVER_OPEN_ERROR; break;
    9293        }
    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));
    9495        return rc;
    9596    }
     
    115116     */
    116117    pThis->hDevice       = hDevice;
    117     pThis->fUnrestricted = fUnrestricted;
     118    pThis->fUnrestricted = RT_BOOL(fFlags & SUPR3INIT_F_UNRESTRICTED);
    118119    return VINF_SUCCESS;
    119120}
  • trunk/src/VBox/HostDrivers/Support/linux/SUPLib-linux.cpp

    r92557 r92613  
    7676
    7777
    78 DECLHIDDEN(int) suplibOsInit(PSUPLIBDATA pThis, bool fPreInited, bool fUnrestricted, SUPINITOP *penmWhat, PRTERRINFO pErrInfo)
     78DECLHIDDEN(int) suplibOsInit(PSUPLIBDATA pThis, bool fPreInited, uint32_t fFlags, SUPINITOP *penmWhat, PRTERRINFO pErrInfo)
    7979{
    8080    RT_NOREF2(penmWhat, pErrInfo);
     
    9999     * Try open the device.
    100100     */
    101     const char *pszDeviceNm = fUnrestricted ? DEVICE_NAME_SYS : DEVICE_NAME_USR;
     101    const char *pszDeviceNm = fFlags & SUPR3INIT_F_UNRESTRICTED ? DEVICE_NAME_SYS : DEVICE_NAME_USR;
    102102    int hDevice = open(pszDeviceNm, O_RDWR, 0);
    103103    if (hDevice < 0)
     
    141141     */
    142142    pThis->hDevice       = hDevice;
    143     pThis->fUnrestricted = fUnrestricted;
     143    pThis->fUnrestricted = RT_BOOL(fFlags & SUPR3INIT_F_UNRESTRICTED);
    144144    return VINF_SUCCESS;
    145145}
  • trunk/src/VBox/HostDrivers/Support/os2/SUPLib-os2.cpp

    r92556 r92613  
    6565
    6666
    67 DECLHIDDEN(int) suplibOsInit(PSUPLIBDATA pThis, bool fPreInited, bool fUnrestricted, SUPINITOP *penmWhat, PRTERRINFO pErrInfo)
     67DECLHIDDEN(int) suplibOsInit(PSUPLIBDATA pThis, bool fPreInited, uint32_t fFlags, SUPINITOP *penmWhat, PRTERRINFO pErrInfo)
    6868{
    6969    /*
     
    101101    pThis->hDevice = hDevice;
    102102    pThis->fUnrestricted = true;
     103    RT_NOREF(fFlags);
    103104    return VINF_SUCCESS;
    104105}
  • trunk/src/VBox/HostDrivers/Support/solaris/SUPLib-solaris.cpp

    r92556 r92613  
    7979
    8080
    81 DECLHIDDEN(int) suplibOsInit(PSUPLIBDATA pThis, bool fPreInited, bool fUnrestricted, SUPINITOP *penmWhat, PRTERRINFO pErrInfo)
     81DECLHIDDEN(int) suplibOsInit(PSUPLIBDATA pThis, bool fPreInited, uint32_t fFlags, SUPINITOP *penmWhat, PRTERRINFO pErrInfo)
    8282{
    8383    /*
     
    113113    const char *pszDeviceNm;
    114114    if (getzoneid() == GLOBAL_ZONEID)
    115         pszDeviceNm = fUnrestricted ? DEVICE_NAME_SYS : DEVICE_NAME_USR;
     115        pszDeviceNm = fFlags & SUPR3INIT_F_UNRESTRICTED ? DEVICE_NAME_SYS : DEVICE_NAME_USR;
    116116    else
    117         pszDeviceNm = fUnrestricted ? DEVICE_NAME_SYS_ZONE : DEVICE_NAME_USR_ZONE;
     117        pszDeviceNm = fFlags & SUPR3INIT_F_UNRESTRICTED ? DEVICE_NAME_SYS_ZONE : DEVICE_NAME_USR_ZONE;
    118118    int hDevice = open(pszDeviceNm, O_RDWR, 0);
    119119    if (hDevice < 0)
     
    149149
    150150    pThis->hDevice       = hDevice;
    151     pThis->fUnrestricted = fUnrestricted;
     151    pThis->fUnrestricted = RT_BOOL(fFlags & SUPR3INIT_F_UNRESTRICTED);
    152152    return VINF_SUCCESS;
    153153}
  • trunk/src/VBox/HostDrivers/Support/testcase/SUPLoggerCtl.cpp

    r82968 r92613  
    5959int main(int argc, char **argv)
    6060{
    61     RTR3InitExe(argc, &argv, RTR3INIT_FLAGS_SUPLIB);
     61    RTR3InitExe(argc, &argv, RTR3INIT_FLAGS_TRY_SUPLIB);
    6262
    6363    /*
     
    151151
    152152    /*
    153      * Do the requested job.
     153     * Make sure the support library is initialized.
    154154     */
    155     int rc;
    156     switch (enmWhat)
     155    int rc = SUPR3Init(NULL /*ppSession*/);
     156    if (RT_SUCCESS(rc))
    157157    {
    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);
    170180    }
    171     if (RT_SUCCESS(rc))
    172         RTPrintf("SUPLoggerCtl: Success\n");
    173181    else
    174         RTStrmPrintf(g_pStdErr, "SUPLoggerCtl: error: rc=%Rrc\n", rc);
     182        RTStrmPrintf(g_pStdErr, "SUPR3Init: error: rc=%Rrc\n", rc);
    175183
    176184    return RT_SUCCESS(rc) ? 0 : 1;
  • trunk/src/VBox/HostDrivers/Support/testcase/tstPage.cpp

    r92556 r92613  
    4040    int cErrors = 0;
    4141
    42     RTR3InitExe(argc, &argv, RTR3INIT_FLAGS_SUPLIB);
     42    RTR3InitExe(argc, &argv, RTR3INIT_FLAGS_TRY_SUPLIB);
    4343    int rc = SUPR3Init(NULL);
    4444    cErrors += rc != 0;
  • trunk/src/VBox/HostDrivers/Support/testcase/tstPin.cpp

    r92556 r92613  
    4646    RTHCPHYS    HCPhys;
    4747
    48     RTR3InitExe(argc, &argv, RTR3INIT_FLAGS_SUPLIB);
     48    RTR3InitExe(argc, &argv, RTR3INIT_FLAGS_TRY_SUPLIB);
    4949    rc = SUPR3Init(NULL);
    5050    RTPrintf("SUPR3Init -> rc=%d\n", rc);
  • trunk/src/VBox/HostDrivers/Support/testcase/tstSupSem-Zombie.cpp

    r86397 r92613  
    9595     * Init.
    9696     */
    97     int rc = RTR3InitExeNoArguments(RTR3INIT_FLAGS_SUPLIB);
     97    int rc = RTR3InitExeNoArguments(RTR3INIT_FLAGS_TRY_SUPLIB);
    9898    if (RT_FAILURE(rc))
    9999    {
  • trunk/src/VBox/HostDrivers/Support/testcase/tstSupSem.cpp

    r82968 r92613  
    8080     * Init.
    8181     */
    82     int rc = RTR3InitExe(argc, &argv, RTR3INIT_FLAGS_SUPLIB);
     82    int rc = RTR3InitExe(argc, &argv, RTR3INIT_FLAGS_TRY_SUPLIB);
    8383    if (RT_FAILURE(rc))
    8484        return RTMsgInitFailure(rc);
  • trunk/src/VBox/HostDrivers/Support/win/SUPLib-win.cpp

    r92556 r92613  
    117117
    118118
    119 DECLHIDDEN(int) suplibOsInit(PSUPLIBDATA pThis, bool fPreInited, bool fUnrestricted, SUPINITOP *penmWhat, PRTERRINFO pErrInfo)
     119DECLHIDDEN(int) suplibOsInit(PSUPLIBDATA pThis, bool fPreInited, uint32_t fFlags, SUPINITOP *penmWhat, PRTERRINFO pErrInfo)
    120120{
    121121    /*
     
    156156        UNICODE_STRING      NtName;
    157157        NtName.Buffer        = (PWSTR)s_wszName;
    158         NtName.Length        = sizeof(s_wszName) - sizeof(WCHAR) * (fUnrestricted ? 2 : 1);
     158        NtName.Length        = sizeof(s_wszName) - sizeof(WCHAR) * (fFlags & SUPR3INIT_F_UNRESTRICTED ? 2 : 1);
    159159        NtName.MaximumLength = NtName.Length;
    160160
     
    183183             */
    184184            pThis->hDevice       = hDevice;
    185             pThis->fUnrestricted = fUnrestricted;
     185            pThis->fUnrestricted = RT_BOOL(fFlags & SUPR3INIT_F_UNRESTRICTED);
    186186            return VINF_SUCCESS;
    187187        }
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette