VirtualBox

Changeset 92613 in vbox


Ignore:
Timestamp:
Nov 26, 2021 9:53:47 PM (3 years ago)
Author:
vboxsync
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
Files:
35 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/sup.h

    r92556 r92613  
    653653
    654654/** @internal  */
     655SUPDECL(PSUPGIPCPU) SUPGetGipCpuPtrForAsyncMode(PSUPGLOBALINFOPAGE pGip);
    655656SUPDECL(uint64_t) SUPGetCpuHzFromGipForAsyncMode(PSUPGLOBALINFOPAGE pGip);
    656657SUPDECL(bool)     SUPIsTscFreqCompatible(uint64_t uCpuHz, uint64_t *puGipCpuHz, bool fRelax);
    657658SUPDECL(bool)     SUPIsTscFreqCompatibleEx(uint64_t uBaseCpuHz, uint64_t uCpuHz, bool fRelax);
    658659
     660
     661/**
     662 * Gets CPU entry of the calling CPU.
     663 *
     664 * @returns Pointer to the CPU entry on success, NULL on failure.
     665 * @param   pGip        The GIP pointer.
     666 */
     667DECLINLINE(PSUPGIPCPU) SUPGetGipCpuPtr(PSUPGLOBALINFOPAGE pGip)
     668{
     669    if (RT_LIKELY(   pGip
     670                  && pGip->u32Magic == SUPGLOBALINFOPAGE_MAGIC))
     671    {
     672        switch (pGip->u32Mode)
     673        {
     674            case SUPGIPMODE_INVARIANT_TSC:
     675            case SUPGIPMODE_SYNC_TSC:
     676                return &pGip->aCPUs[0];
     677            case SUPGIPMODE_ASYNC_TSC:
     678                return SUPGetGipCpuPtrForAsyncMode(pGip);
     679            default: break; /* shut up gcc */
     680        }
     681    }
     682    AssertFailed();
     683    return NULL;
     684}
    659685
    660686/**
     
    12021228 * @param   pszProgName     The program name. This will be used to figure out which
    12031229 *                          DLL/SO/DYLIB to load and execute.
    1204  * @param   fFlags          Flags.
     1230 * @param   fFlags          SUPSECMAIN_FLAGS_XXX.
    12051231 * @param   argc            The argument count.
    12061232 * @param   argv            The argument vector.
     
    12091235DECLHIDDEN(int) SUPR3HardenedMain(const char *pszProgName, uint32_t fFlags, int argc, char **argv, char **envp);
    12101236
    1211 /** @name SUPR3HardenedMain flags.
     1237/** @name SUPSECMAIN_FLAGS_XXX - SUPR3HardenedMain flags.
    12121238 * @{ */
    12131239/** Don't open the device. (Intended for VirtualBox without -startvm.) */
    1214 #define SUPSECMAIN_FLAGS_DONT_OPEN_DEV      RT_BIT_32(0)
     1240#define SUPSECMAIN_FLAGS_DONT_OPEN_DEV              RT_BIT_32(0)
    12151241/** The hardened DLL has a "TrustedError" function (see FNSUPTRUSTEDERROR). */
    1216 #define SUPSECMAIN_FLAGS_TRUSTED_ERROR      RT_BIT_32(1)
     1242#define SUPSECMAIN_FLAGS_TRUSTED_ERROR              RT_BIT_32(1)
    12171243/** Hack for making VirtualBoxVM use VirtualBox.dylib on Mac OS X.
    12181244 * @note Not used since 6.0  */
    1219 #define SUPSECMAIN_FLAGS_OSX_VM_APP         RT_BIT_32(2)
     1245#define SUPSECMAIN_FLAGS_OSX_VM_APP                 RT_BIT_32(2)
     1246/** The first process.
     1247 * @internal  */
     1248#define SUPSECMAIN_FLAGS_FIRST_PROCESS              RT_BIT_32(3)
    12201249/** Program binary location mask. */
    1221 #define SUPSECMAIN_FLAGS_LOC_MASK           UINT32_C(0x00000030)
     1250#define SUPSECMAIN_FLAGS_LOC_MASK                   UINT32_C(0x00000030)
    12221251/** Default binary location is the application binary directory.  Does
    12231252 * not need to be given explicitly (it's 0).  */
    1224 #define SUPSECMAIN_FLAGS_LOC_APP_BIN        UINT32_C(0x00000000)
     1253#define SUPSECMAIN_FLAGS_LOC_APP_BIN                UINT32_C(0x00000000)
    12251254/** The binary is located in the testcase directory instead of the
    12261255 * default application binary directory. */
    1227 #define SUPSECMAIN_FLAGS_LOC_TESTCASE       UINT32_C(0x00000010)
     1256#define SUPSECMAIN_FLAGS_LOC_TESTCASE               UINT32_C(0x00000010)
    12281257/** The binary is located in a nested application bundle under Resources/ in the
    12291258 * main Mac OS X application (think Resources/VirtualBoxVM.app).  */
    1230 #define SUPSECMAIN_FLAGS_LOC_OSX_HLP_APP    UINT32_C(0x00000020)
    1231 /** The first process.
    1232  * @internal  */
    1233 #define SUPSECMAIN_FLAGS_FIRST_PROCESS      UINT32_C(0x00000100)
     1259#define SUPSECMAIN_FLAGS_LOC_OSX_HLP_APP            UINT32_C(0x00000020)
     1260/** Driverless IEM-only mode is allowed, so don't fail fatally just because
     1261 * the VBox support driver is unavailable. */
     1262#define SUPSECMAIN_FLAGS_DRIVERLESS_IEM_ALLOWED     RT_BIT_32(8)
     1263#ifdef VBOX_WITH_DRIVERLESS_NEM_FALLBACK
     1264/** Driverless NEM is a fallback posibility, so don't fail fatally just
     1265 * because the VBox support driver is unavailable.
     1266 * This may imply checking NEM requirements, depending on the host.
     1267 * @note Not supported on Windows. */
     1268# define SUPSECMAIN_FLAGS_DRIVERLESS_NEM_FALLBACK   RT_BIT_32(9)
     1269#endif
     1270
    12341271/** @} */
    12351272
     
    12521289 *
    12531290 * @returns VBox status code.
    1254  * @param   fUnrestricted   The desired access.
     1291 * @param   fFlags          SUPR3INIT_F_XXX
    12551292 * @param   ppSession       Where to store the session handle. Defaults to NULL.
    12561293 */
    1257 SUPR3DECL(int) SUPR3InitEx(bool fUnrestricted, PSUPDRVSESSION *ppSession);
     1294SUPR3DECL(int) SUPR3InitEx(uint32_t fFlags, PSUPDRVSESSION *ppSession);
     1295/** @name SUPR3INIT_F_XXX - Flags for SUPR3InitEx
     1296 * @{ */
     1297/** Unrestricted access. */
     1298#define SUPR3INIT_F_UNRESTRICTED                RT_BIT_32(0)
     1299/** Limited access (for Main). */
     1300#define SUPR3INIT_F_LIMITED                     RT_BIT_32(1)
     1301/** Allow driverless IEM mode if the VBox support driver is unavailable.
     1302 * @see SUPSECMAIN_FLAGS_DRIVERLESS_IEM_ALLOWED */
     1303#define SUPR3INIT_F_DRIVERLESS_IEM_ALLOWED      RT_BIT_32(2)
     1304#ifdef VBOX_WITH_DRIVERLESS_NEM_FALLBACK
     1305/** Allow driverless NEM mode as fallback if the VBox support driver is unavailable.
     1306 * @see SUPSECMAIN_FLAGS_DRIVERLESS_NEM_FALLBACK */
     1307# define SUPR3INIT_F_DRIVERLESS_NEM_FALLBACK    RT_BIT_32(3)
     1308#endif
     1309/** @} */
    12581310
    12591311/**
  • trunk/include/iprt/initterm.h

    r92562 r92613  
    5151#ifdef IN_RING3
    5252
    53 /** @name RTR3Init flags (RTR3INIT_XXX).
     53/** @name RTR3INIT_FLAGS_XXX - RTR3Init* flags.
     54 * @see RTR3InitExeNoArguments, RTR3InitExe, RTR3InitDll, RTR3InitEx
    5455 * @{ */
    55 /** Try initialize SUPLib. */
    56 # define RTR3INIT_FLAGS_SUPLIB       RT_BIT(0)
    5756/** Initializing IPRT from a DLL. */
    58 # define RTR3INIT_FLAGS_DLL          RT_BIT(1)
    59 /** We are sharing a process space, so we need to behave. */
    60 # define RTR3INIT_FLAGS_UNOBTRUSIVE  RT_BIT(2)
     57# define RTR3INIT_FLAGS_DLL             RT_BIT(0)
    6158/** The caller ensures that the argument vector is UTF-8. */
    62 # define RTR3INIT_FLAGS_UTF8_ARGV    RT_BIT(3)
     59# define RTR3INIT_FLAGS_UTF8_ARGV       RT_BIT(1)
    6360/** Indicates that this is a standalone application without any additional
    6461 * shared libraries in the application directory. Mainly windows loader mess. */
    65 # define RTR3INIT_FLAGS_STANDALONE_APP RT_BIT(4)
     62# define RTR3INIT_FLAGS_STANDALONE_APP  RT_BIT(2)
     63/** We are sharing a process space, so we need to behave. */
     64# define RTR3INIT_FLAGS_UNOBTRUSIVE     RT_BIT(3)
     65
     66/** Initialize SUPLib (must not fail). */
     67# define RTR3INIT_FLAGS_SUPLIB          RT_BIT(16)
     68/** Try initialize SUPLib and ignore failures. */
     69# define RTR3INIT_FLAGS_TRY_SUPLIB      RT_BIT(17)
     70/** Shift count for passing thru SUPR3INIT_F_XXX flags.   */
     71# define RTR3INIT_FLAGS_SUPLIB_SHIFT    18
     72/** The mask covering the passthru SUPR3INIT_F_XXX flags. */
     73# define RTR3INIT_FLAGS_SUPLIB_MASK     UINT32_C(0xfffc0000)
     74
     75/** Valid flag mask. */
     76# define RTR3INIT_FLAGS_VALID_MASK      UINT32_C(0xffff000f)
    6677/** @} */
    6778
     
    6980 * @{ */
    7081/** Version 1. */
    71 # define RTR3INIT_VER_1              UINT32_C(1)
     82# define RTR3INIT_VER_1                 UINT32_C(1)
     83/** Version 2 - new flags, rearranged a bit. */
     84# define RTR3INIT_VER_2                 UINT32_C(2)
    7285/** The current version. */
    73 # define RTR3INIT_VER_CUR            RTR3INIT_VER_1
     86# define RTR3INIT_VER_CUR               RTR3INIT_VER_2
    7487/** @} */
    7588
     
    7891 *
    7992 * @returns iprt status code.
    80  * @param   fFlags          Flags, see RTR3INIT_XXX.
     93 * @param   fFlags          Flags, see RTR3INIT_FLAGS_XXX.
    8194 */
    8295RTR3DECL(int) RTR3InitExeNoArguments(uint32_t fFlags);
     
    88101 * @param   cArgs           Pointer to the argument count.
    89102 * @param   ppapszArgs      Pointer to the argument vector pointer.
    90  * @param   fFlags          Flags, see RTR3INIT_XXX.
     103 * @param   fFlags          Flags, see RTR3INIT_FLAGS_XXX.
    91104 */
    92105RTR3DECL(int) RTR3InitExe(int cArgs, char ***ppapszArgs, uint32_t fFlags);
     
    96109 *
    97110 * @returns iprt status code.
    98  * @param   fFlags          Flags, see RTR3INIT_XXX.
     111 * @param   fFlags          Flags, see RTR3INIT_FLAGS_XXX.
    99112 */
    100113RTR3DECL(int) RTR3InitDll(uint32_t fFlags);
     
    107120 * @returns IPRT status code.
    108121 * @param   iVersion        The interface version. Must be 0 atm.
    109  * @param   fFlags          Flags, see RTR3INIT_XXX.
     122 * @param   fFlags          Flags, see RTR3INIT_FLAGS_XXX.
    110123 * @param   cArgs           Pointer to the argument count.
    111124 * @param   ppapszArgs      Pointer to the argument vector pointer. NULL
  • trunk/src/VBox/Debugger/testcase/tstVBoxDbg.cpp

    r90520 r92613  
    3939    int     cErrors = 0;                  /* error count. */
    4040
    41     RTR3InitExe(argc, &argv, RTR3INIT_FLAGS_SUPLIB);
     41    RTR3InitExe(argc, &argv, RTR3INIT_FLAGS_TRY_SUPLIB);
    4242    RTPrintf(TESTCASE ": TESTING...\n");
    4343
  • trunk/src/VBox/Frontends/VBoxHeadless/VBoxHeadless.cpp

    r92067 r92613  
    15821582int main(int argc, char **argv, char **envp)
    15831583{
    1584     // initialize VBox Runtime
    1585     int rc = RTR3InitExe(argc, &argv, RTR3INIT_FLAGS_SUPLIB);
    1586     if (RT_FAILURE(rc))
    1587     {
    1588         RTPrintf("VBoxHeadless: Runtime Error:\n"
    1589                  " %Rrc -- %Rrf\n", rc, rc);
    1590         switch (rc)
    1591         {
    1592             case VERR_VM_DRIVER_NOT_INSTALLED:
    1593                 RTPrintf("Cannot access the kernel driver. Make sure the kernel module has been \n"
    1594                         "loaded successfully. Aborting ...\n");
    1595                 break;
    1596             default:
    1597                 break;
    1598         }
    1599         return 1;
    1600     }
    1601 
    1602     return TrustedMain(argc, argv, envp);
     1584    int rc = RTR3InitExe(argc, &argv, RTR3INIT_FLAGS_TRY_SUPLIB);
     1585    if (RT_SUCCESS(rc))
     1586        return TrustedMain(argc, argv, envp);
     1587    RTPrintf("VBoxHeadless: Runtime initialization failed: %Rrc - %Rrf\n", rc, rc);
     1588    return RTEXITCODE_FAILURE;
    16031589}
    16041590#endif /* !VBOX_WITH_HARDENING */
  • trunk/src/VBox/Frontends/VBoxHeadless/VBoxHeadlessHardened.cpp

    r82968 r92613  
    2121int main(int argc, char **argv, char **envp)
    2222{
     23#ifdef VBOX_WITH_DRIVERLESS_NEM_FALLBACK
     24    return SUPR3HardenedMain("VBoxHeadless", SUPSECMAIN_FLAGS_DRIVERLESS_NEM_FALLBACK, argc, argv, envp);
     25#else
    2326    return SUPR3HardenedMain("VBoxHeadless", 0, argc, argv, envp);
     27#endif
    2428}
    2529
  • trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp

    r91363 r92613  
    32203220     * Before we do *anything*, we initialize the runtime.
    32213221     */
    3222     int rc = RTR3InitExe(argc, &argv, RTR3INIT_FLAGS_SUPLIB);
     3222    int rc = RTR3InitExe(argc, &argv, RTR3INIT_FLAGS_TRY_SUPLIB);
    32233223    if (RT_FAILURE(rc))
    32243224        return RTMsgInitFailure(rc);
  • trunk/src/VBox/Frontends/VirtualBox/src/hardenedmain.cpp

    r83033 r92613  
    4242int main(int argc, char **argv, char **envp)
    4343{
    44     /* First check whether we're about to start a VM: */
    45     bool fStartVM = false;
    46     /* In separate process: */
    47     bool fSeparateProcess = false;
    48     for (int i = 1; i < argc && !(fStartVM && fSeparateProcess); ++i)
     44    /*
     45     * Do partial option parsing to see if we're starting a VM and how we're
     46     * going about that.
     47     *
     48     * Note! This must must match the corresponding parsing in main.cpp and
     49     *       UICommon.cpp exactly, otherwise there will be weird error messages.
     50     *
     51     * Note! ASSUMES that argv is in an ASCII compatible codeset.
     52     */
     53    unsigned cOptionsLeft     = 3;
     54    bool     fStartVM         = false;
     55    bool     fSeparateProcess = false;
     56    bool     fExecuteAllInIem = false;
     57    for (int i = 1; i < argc && cOptionsLeft > 0; ++i)
    4958    {
    50         /* NOTE: the check here must match the corresponding check for the
    51          * options to start a VM in main.cpp and UICommon.cpp exactly,
    52          * otherwise there will be weird error messages. */
    5359        if (   !MyStrCmp(argv[i], "--startvm")
    5460            || !MyStrCmp(argv[i], "-startvm"))
    5561        {
     62            cOptionsLeft -= fStartVM == false;
    5663            fStartVM = true;
     64            i++;
    5765        }
    5866        else if (   !MyStrCmp(argv[i], "--separate")
    5967                 || !MyStrCmp(argv[i], "-separate"))
    6068        {
     69            cOptionsLeft -= fSeparateProcess == false;
    6170            fSeparateProcess = true;
     71        }
     72        else if (!MyStrCmp(argv[i], "--execute-all-in-iem"))
     73        {
     74            cOptionsLeft -= fExecuteAllInIem == false;
     75            fExecuteAllInIem = true;
    6276        }
    6377    }
    6478
    65     uint32_t fFlags = (fStartVM && !fSeparateProcess) ? 0 : SUPSECMAIN_FLAGS_DONT_OPEN_DEV;
     79    /*
     80     * Convert the command line options to SUPSECMAIN_FLAGS_XXX flags
     81     * and call the hardened main code.
     82     */
     83    uint32_t fFlags = SUPSECMAIN_FLAGS_TRUSTED_ERROR;
    6684#ifdef RT_OS_DARWIN
    6785    fFlags |= SUPSECMAIN_FLAGS_LOC_OSX_HLP_APP;
    6886#endif
     87    if (!fStartVM || fSeparateProcess)
     88        fFlags |= SUPSECMAIN_FLAGS_DONT_OPEN_DEV;
     89    else
     90    {
     91        if (fExecuteAllInIem)
     92            fFlags |= SUPSECMAIN_FLAGS_DRIVERLESS_IEM_ALLOWED;
     93#ifdef VBOX_WITH_DRIVERLESS_NEM_FALLBACK
     94        else
     95            fFlags |= SUPSECMAIN_FLAGS_DRIVERLESS_NEM_FALLBACK;
     96#endif
     97    }
    6998
    70     return SUPR3HardenedMain("VirtualBoxVM",
    71                              fFlags | SUPSECMAIN_FLAGS_TRUSTED_ERROR,
    72                              argc, argv, envp);
     99    return SUPR3HardenedMain("VirtualBoxVM", fFlags, argc, argv, envp);
    73100}
    74101
  • trunk/src/VBox/Frontends/VirtualBox/src/main.cpp

    r90520 r92613  
    3939#include <VBox/err.h>
    4040#include <VBox/version.h>
    41 #ifdef VBOX_WITH_HARDENING
    42 # include <VBox/sup.h>
    43 #endif
     41#include <VBox/sup.h>
    4442#if !defined(VBOX_WITH_HARDENING) || !defined(VBOX_RUNTIME_UI)
    4543# include <iprt/initterm.h>
     
    651649# endif /* VBOX_WS_X11 */
    652650
     651    /*
     652     * Determin the IPRT/SUPLib initialization flags if runtime UI process.
     653     * Only initialize SUPLib if about to start a VM in this process.
     654     *
     655     * Note! This must must match the corresponding parsing in hardenedmain.cpp
     656     *       and UICommon.cpp exactly, otherwise there will be weird error messages.
     657     */
     658    /** @todo r=bird: We should consider just postponing this stuff till VM
     659     *        creation, it shouldn't make too much of a difference GIP-wise. */
     660    uint32_t fFlags = 0;
     661# ifdef VBOX_RUNTIME_UI
     662    unsigned cOptionsLeft     = 3;
     663    bool     fStartVM         = false;
     664    bool     fSeparateProcess = false;
     665    bool     fExecuteAllInIem = false;
     666    for (int i = 1; i < argc && cOptionsLeft > 0; ++i)
     667    {
     668        if (   !strcmp(argv[i], "--startvm")
     669            || !strcmp(argv[i], "-startvm"))
     670        {
     671            cOptionsLeft -= fStartVM == false;
     672            fStartVM = true;
     673            i++;
     674        }
     675        else if (   !strcmp(argv[i], "--separate")
     676                 || !strcmp(argv[i], "-separate"))
     677        {
     678            cOptionsLeft -= fSeparateProcess == false;
     679            fSeparateProcess = true;
     680        }
     681        else if (!strcmp(argv[i], "--execute-all-in-iem"))
     682        {
     683            cOptionsLeft -= fExecuteAllInIem == false;
     684            fExecuteAllInIem = true;
     685        }
     686    }
     687    if (fStartVM && !fSeparateProcess)
     688    {
     689        fFlags |= RTR3INIT_FLAGS_TRY_SUPLIB;
     690        if (fExecuteAllInIem)
     691            fFlags |= SUPR3INIT_F_DRIVERLESS_IEM_ALLOWED << RTR3INIT_FLAGS_SUPLIB_SHIFT;
     692    }
     693# endif
     694
    653695    /* Initialize VBox Runtime: */
    654 # ifdef VBOX_RUNTIME_UI
    655     /* Initialize the SUPLib as well only if we are really about to start a VM.
    656      * Don't do this if we are only starting the selector window or a separate VM process. */
    657     bool fStartVM = false;
    658     bool fSeparateProcess = false;
    659     for (int i = 1; i < argc && !(fStartVM && fSeparateProcess); ++i)
    660     {
    661         /* NOTE: the check here must match the corresponding check for the
    662          * options to start a VM in hardenedmain.cpp and UICommon.cpp exactly,
    663          * otherwise there will be weird error messages. */
    664         if (   !::strcmp(argv[i], "--startvm")
    665             || !::strcmp(argv[i], "-startvm"))
    666             fStartVM = true;
    667         else if (   !::strcmp(argv[i], "--separate")
    668                  || !::strcmp(argv[i], "-separate"))
    669             fSeparateProcess = true;
    670     }
    671 
    672     uint32_t fFlags = fStartVM && !fSeparateProcess ? RTR3INIT_FLAGS_SUPLIB : 0;
    673 # ifdef RT_OS_DARWIN
     696# if defined(RT_OS_DARWIN) && defined(VBOX_RUNTIME_UI)
    674697    int rc = initIprtForDarwinHelperApp(argc, &argv, fFlags);
    675698# else
    676699    int rc = RTR3InitExe(argc, &argv, fFlags);
    677700# endif
    678 # else
    679     int rc = RTR3InitExe(argc, &argv, 0 /*fFlags*/);
    680 # endif
    681 
    682     /* Initialization failed: */
    683701    if (RT_FAILURE(rc))
    684702    {
     703        /* Initialization failed: */
     704
    685705        /* We have to create QApplication anyway
    686706         * just to show the only one error-message: */
  • 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        }
  • trunk/src/VBox/Main/src-server/HostImpl.cpp

    r91503 r92613  
    11811181{
    11821182    /* Perhaps the driver is available now... */
    1183     int rc = SUPR3InitEx(false /*fUnrestricted*/, NULL);
     1183    int rc = SUPR3InitEx(SUPR3INIT_F_LIMITED, NULL);
    11841184    if (RT_SUCCESS(rc))
    11851185    {
  • trunk/src/VBox/NetworkServices/Dhcpd/VBoxNetDhcpd.cpp

    r87745 r92613  
    776776    VBoxNetDhcpd Dhcpd;
    777777    int rc = Dhcpd.main(argc, argv);
    778 
    779778    return RT_SUCCESS(rc) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE;
    780779}
     
    786785{
    787786    int rc = RTR3InitExe(argc, &argv, RTR3INIT_FLAGS_SUPLIB);
    788     if (RT_FAILURE(rc))
    789         return RTMsgInitFailure(rc);
    790 
    791     return TrustedMain(argc, argv);
     787    if (RT_SUCCESS(rc))
     788        return TrustedMain(argc, argv);
     789    return RTMsgInitFailure(rc);
    792790}
    793791
  • trunk/src/VBox/NetworkServices/NAT/VBoxNetLwipNAT.cpp

    r91916 r92613  
    21992199extern "C" DECLEXPORT(int) TrustedMain(int argc, char **argv, char **envp)
    22002200{
    2201     int rc;
    2202 
    22032201    LogFlowFuncEnter();
    2204 
    22052202    NOREF(envp);
    22062203
    22072204#ifdef RT_OS_WINDOWS
    2208     WSADATA wsaData;
    2209     int err;
    2210 
    2211     err = WSAStartup(MAKEWORD(2,2), &wsaData);
     2205    WSADATA WsaData = {0};
     2206    int err = WSAStartup(MAKEWORD(2,2), &WsaData);
    22122207    if (err)
    22132208    {
     
    22262221    }
    22272222
    2228     rc = NAT.init();
     2223    int rc = NAT.init();
    22292224    if (RT_FAILURE(rc))
    22302225        return RTEXITCODE_INIT;
     
    22422237{
    22432238    int rc = RTR3InitExe(argc, &argv, RTR3INIT_FLAGS_SUPLIB);
    2244     if (RT_FAILURE(rc))
    2245         return RTMsgInitFailure(rc);
    2246 
    2247     return TrustedMain(argc, argv, envp);
     2239    if (RT_SUCCESS(rc))
     2240        return TrustedMain(argc, argv, envp);
     2241    return RTMsgInitFailure(rc);
    22482242}
    22492243
  • trunk/src/VBox/Runtime/r3/init.cpp

    r85124 r92613  
    437437     * (improves accuracy for the first client).
    438438     */
    439     if (fFlags & RTR3INIT_FLAGS_SUPLIB)
    440     {
    441         rc = SUPR3Init(NULL);
    442         AssertMsgRCReturn(rc, ("Failed to initialize the support library, rc=%Rrc!\n", rc), rc);
     439    if (fFlags & (RTR3INIT_FLAGS_SUPLIB | RTR3INIT_FLAGS_TRY_SUPLIB))
     440    {
     441        rc = SUPR3InitEx(  fFlags >> RTR3INIT_FLAGS_SUPLIB_SHIFT
     442                         ? fFlags >> RTR3INIT_FLAGS_SUPLIB_SHIFT : SUPR3INIT_F_UNRESTRICTED, NULL /*ppSession*/);
     443        AssertMsgReturn(RT_SUCCESS(rc) || (fFlags & RTR3INIT_FLAGS_TRY_SUPLIB),
     444                        ("Failed to initialize the support library, rc=%Rrc!\n", rc), rc);
    443445    }
    444446#endif
     
    452454#if !defined(IN_GUEST) && !defined(RT_NO_GIP)
    453455    /*
    454      * The threading is initialized we can safely sleep a bit if GIP
    455      * needs some time to update itself updating.
    456      */
    457     if ((fFlags & RTR3INIT_FLAGS_SUPLIB) && g_pSUPGlobalInfoPage)
    458     {
    459         RTThreadSleep(20);
    460         RTTimeNanoTS();
     456     * The threading is initialized, so we can safely sleep a bit if GIP
     457     * needs some time to start updating itself.  Currently limited to
     458     * the first mapping of GIP (u32TransactionId <= 4), quite possible we
     459     * could just ditch this now.
     460     */
     461    /** @todo consider dropping this... */
     462    PSUPGLOBALINFOPAGE pGip;
     463    if (   (fFlags & (RTR3INIT_FLAGS_SUPLIB | RTR3INIT_FLAGS_TRY_SUPLIB))
     464        && (pGip = g_pSUPGlobalInfoPage) != NULL
     465        && pGip->u32Magic == SUPGLOBALINFOPAGE_MAGIC)
     466    {
     467        PSUPGIPCPU pGipCpu = SUPGetGipCpuPtr(pGip);
     468        if (   pGipCpu
     469            && pGipCpu->u32TransactionId <= 4)
     470        {
     471            RTThreadSleep(pGip->u32UpdateIntervalNS / RT_NS_1MS + 2);
     472            RTTimeNanoTS();
     473        }
    461474    }
    462475#endif
     
    550563{
    551564    /* no entry log flow, because prefixes and thread may freak out. */
    552     Assert(!(fFlags & ~(  RTR3INIT_FLAGS_DLL
    553                         | RTR3INIT_FLAGS_SUPLIB
    554                         | RTR3INIT_FLAGS_UNOBTRUSIVE
    555                         | RTR3INIT_FLAGS_UTF8_ARGV
    556                         | RTR3INIT_FLAGS_STANDALONE_APP)));
     565    Assert(!(fFlags & ~RTR3INIT_FLAGS_VALID_MASK));
    557566    Assert(!(fFlags & RTR3INIT_FLAGS_DLL) || cArgs == 0);
    558567
     
    568577        AssertMsg(cUsers > 1, ("%d\n", cUsers));
    569578        Assert(!g_fInitializing);
     579
    570580#if !defined(IN_GUEST) && !defined(RT_NO_GIP)
    571         if (fFlags & RTR3INIT_FLAGS_SUPLIB)
     581        /* Initialize the support library if requested. We've always ignored the
     582           status code here for some reason, making the two flags same. */
     583        if (fFlags & (RTR3INIT_FLAGS_SUPLIB | RTR3INIT_FLAGS_TRY_SUPLIB))
    572584        {
    573             SUPR3Init(NULL);
    574             g_fInitFlags |= RTR3INIT_FLAGS_SUPLIB;
     585            SUPR3InitEx(  fFlags >> RTR3INIT_FLAGS_SUPLIB_SHIFT
     586                        ? fFlags >> RTR3INIT_FLAGS_SUPLIB_SHIFT : SUPR3INIT_F_UNRESTRICTED, NULL /*ppSession*/);
     587            g_fInitFlags |= fFlags & (RTR3INIT_FLAGS_SUPLIB | RTR3INIT_FLAGS_TRY_SUPLIB | RTR3INIT_FLAGS_SUPLIB_MASK);
    575588        }
    576589#endif
     
    595608        return rc;
    596609    }
     610
     611    /*
     612     * Do the initialization.
     613     */
    597614    ASMAtomicWriteBool(&g_fInitializing, true);
    598 
    599     /*
    600      * Do the initialization.
    601      */
    602615    int rc = rtR3InitBody(fFlags, cArgs, ppapszArgs, pszProgramPath);
     616    ASMAtomicWriteBool(&g_fInitializing, false);
    603617    if (RT_FAILURE(rc))
    604618    {
    605619        /* failure */
    606         ASMAtomicWriteBool(&g_fInitializing, false);
    607620        ASMAtomicDecS32(&g_cUsers);
    608621        return rc;
     
    611624    /* success */
    612625    LogFlow(("rtR3Init: returns VINF_SUCCESS\n"));
    613     ASMAtomicWriteBool(&g_fInitializing, false);
    614626    return VINF_SUCCESS;
    615627}
  • trunk/src/VBox/VMM/testcase/tstAnimate.cpp

    r85121 r92613  
    621621    int rcRet = 1;
    622622    int rc;
    623     RTR3InitExe(argc, &argv, RTR3INIT_FLAGS_SUPLIB);
     623    RTR3InitExe(argc, &argv, RTR3INIT_FLAGS_TRY_SUPLIB);
    624624
    625625    /*
  • trunk/src/VBox/VMM/testcase/tstCFGM.cpp

    r92556 r92613  
    153153     */
    154154    RTTEST hTest;
    155     RTR3InitExeNoArguments(RTR3INIT_FLAGS_SUPLIB);
     155    RTR3InitExeNoArguments(RTR3INIT_FLAGS_TRY_SUPLIB);
    156156    RTEXITCODE rcExit = RTTestInitAndCreate("tstCFGM", &hTest);
    157157    if (rcExit != RTEXITCODE_SUCCESS)
  • trunk/src/VBox/VMM/testcase/tstPDMAsyncCompletion.cpp

    r82968 r92613  
    8383    PPDMASYNCCOMPLETIONENDPOINT pEndpointSrc, pEndpointDst;
    8484
    85     RTR3InitExe(argc, &argv, RTR3INIT_FLAGS_SUPLIB);
     85    RTR3InitExe(argc, &argv, RTR3INIT_FLAGS_TRY_SUPLIB);
    8686
    8787    if (argc != 3)
  • trunk/src/VBox/VMM/testcase/tstPDMAsyncCompletionStress.cpp

    r82968 r92613  
    578578    int rcRet = 0; /* error count */
    579579
    580     RTR3InitExe(argc, &argv, RTR3INIT_FLAGS_SUPLIB);
     580    RTR3InitExe(argc, &argv, RTR3INIT_FLAGS_TRY_SUPLIB);
    581581
    582582    PVM pVM;
  • trunk/src/VBox/VMM/testcase/tstVMM-HM.cpp

    r82968 r92613  
    6767int main(int argc, char **argv)
    6868{
    69     RTR3InitExe(argc, &argv, RTR3INIT_FLAGS_SUPLIB);
     69    RTR3InitExe(argc, &argv, RTR3INIT_FLAGS_TRY_SUPLIB);
    7070
    7171    /*
  • trunk/src/VBox/VMM/testcase/tstVMMFork.cpp

    r82968 r92613  
    4949     * Initialize the runtime.
    5050     */
    51     RTR3InitExe(argc, &argv, RTR3INIT_FLAGS_SUPLIB);
     51    RTR3InitExe(argc, &argv, RTR3INIT_FLAGS_TRY_SUPLIB);
    5252
    5353#ifndef AUTO_TEST_ARGS
  • trunk/src/VBox/VMM/testcase/tstVMREQ.cpp

    r82968 r92613  
    222222{
    223223    RT_NOREF1(envp);
    224     RTR3InitExe(argc, &argv, RTR3INIT_FLAGS_SUPLIB);
     224    RTR3InitExe(argc, &argv, RTR3INIT_FLAGS_TRY_SUPLIB);
    225225    RTPrintf(TESTCASE ": TESTING...\n");
    226226    RTStrmFlush(g_pStdOut);
  • trunk/src/VBox/VMM/tools/VBoxVMMPreload.cpp

    r82968 r92613  
    217217{
    218218    int rc = RTR3InitExe(argc, &argv, RTR3INIT_FLAGS_SUPLIB);
    219     if (RT_FAILURE(rc))
    220         return RTMsgInitFailure(rc);
    221     return TrustedMain(argc, argv, envp);
     219    if (RT_SUCCESS(rc))
     220        return TrustedMain(argc, argv, envp);
     221    return RTMsgInitFailure(rc);
    222222}
    223223#endif /* !VBOX_WITH_HARDENING */
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