VirtualBox

Ignore:
Timestamp:
Dec 2, 2021 12:37:40 PM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
148596
Message:

SUP: Added SUPR3INIT_F_DRIVERLESS as a forced driverless option and an associated SUPR3IsDriverless(). The SUPR3INIT_F_DRIVERLESS flag requires the host specific init code to allow driverless, only done so on linux thus far. Started adjusting some of the SUPR3 APIs for driverless operation. bugref:10138

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

Legend:

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

    r92613 r92697  
    100100{
    101101    /*.hDevice              = */    SUP_HDEVICE_NIL,
    102     /*.fUnrestricted        = */    true
     102    /*.fUnrestricted        = */    true,
     103    /*.fDriverless          = */    false
    103104#if   defined(RT_OS_DARWIN)
    104105    ,/* .uConnection        = */    0
     
    263264    SUPINITOP enmWhat = kSupInitOp_Driver;
    264265    int rc = suplibOsInit(&g_supLibData, g_fPreInited, fFlags, &enmWhat, NULL);
    265     if (RT_SUCCESS(rc))
     266    if (RT_SUCCESS(rc) && !g_supLibData.fDriverless)
    266267    {
    267268        /*
     
    390391        suplibOsTerm(&g_supLibData);
    391392    }
     393    else if (RT_SUCCESS(rc))
     394    {
     395        /*
     396         * Driverless initialization.
     397         */
     398        Assert(fFlags & SUPR3INIT_F_DRIVERLESS_MASK);
     399        LogRel(("SUP: In driverless mode.\n"));
     400        return VINF_SUCCESS;
     401    }
     402
    392403    g_cInits--;
    393404
     
    560571            return rc;
    561572
    562         g_u32Cookie         = 0;
    563         g_u32SessionCookie  = 0;
    564         g_cInits            = 0;
     573        g_supLibData.hDevice       = SUP_HDEVICE_NIL;
     574        g_supLibData.fUnrestricted = true;
     575        g_supLibData.fDriverless   = false;
     576        g_u32Cookie                = 0;
     577        g_u32SessionCookie         = 0;
     578        g_cInits                   = 0;
    565579    }
    566580    else
     
    571585
    572586
     587SUPR3DECL(bool) SUPR3IsDriverless(void)
     588{
     589    Assert(g_cInits > 0);
     590    return g_supLibData.fDriverless;
     591}
     592
     593
    573594SUPR3DECL(SUPPAGINGMODE) SUPR3GetPagingMode(void)
    574595{
    575     /* fake */
    576     if (RT_UNLIKELY(g_uSupFakeMode))
    577 #ifdef RT_ARCH_AMD64
     596    /*
     597     * Deal with driverless first.
     598     */
     599    if (g_supLibData.fDriverless)
     600#if defined(RT_ARCH_AMD64)
    578601        return SUPPAGINGMODE_AMD64_GLOBAL_NX;
     602#elif defined(RT_ARCH_X86)
     603        return SUPPAGINGMODE_32_BIT_GLOBAL;
    579604#else
    580         return SUPPAGINGMODE_32_BIT_GLOBAL;
     605        return SUPPAGINGMODE_INVALID;
    581606#endif
    582607
     
    10991124    AssertReturn(!fFlags, VERR_INVALID_FLAGS);
    11001125
    1101     /* fake */
    1102     if (RT_UNLIKELY(g_uSupFakeMode))
    1103     {
    1104         void *pv = RTMemPageAllocZ(cPages * PAGE_SIZE);
    1105         if (!pv)
    1106             return VERR_NO_MEMORY;
    1107         *ppvPages = pv;
     1126    /*
     1127     * Deal with driverless mode first.
     1128     */
     1129    if (g_supLibData.fDriverless)
     1130    {
     1131        int rc = SUPR3PageAlloc(cPages * PAGE_SIZE, 0 /*fFlags*/, ppvPages);
    11081132        if (pR0Ptr)
    1109             *pR0Ptr = (RTR0PTR)pv;
     1133            *pR0Ptr = NIL_RTR0PTR;
    11101134        if (paPages)
    11111135            for (size_t iPage = 0; iPage < cPages; iPage++)
    11121136            {
    11131137                paPages[iPage].uReserved = 0;
    1114                 paPages[iPage].Phys = (iPage + 4321) << PAGE_SHIFT;
    1115                 Assert(!(paPages[iPage].Phys & ~X86_PTE_PAE_PG_MASK));
     1138                paPages[iPage].Phys      = NIL_RTHCPHYS;
    11161139            }
    1117         return VINF_SUCCESS;
     1140        return rc;
    11181141    }
    11191142
     
    16821705    *pfCaps = 0;
    16831706
    1684     /* fake */
    1685     if (RT_UNLIKELY(g_uSupFakeMode))
    1686         return VINF_SUCCESS;
    1687 
    1688     /*
    1689      * Issue IOCtl to the SUPDRV kernel module.
    1690      */
    1691     SUPVTCAPS Req;
    1692     Req.Hdr.u32Cookie = g_u32Cookie;
    1693     Req.Hdr.u32SessionCookie = g_u32SessionCookie;
    1694     Req.Hdr.cbIn = SUP_IOCTL_VT_CAPS_SIZE_IN;
    1695     Req.Hdr.cbOut = SUP_IOCTL_VT_CAPS_SIZE_OUT;
    1696     Req.Hdr.fFlags = SUPREQHDR_FLAGS_DEFAULT;
    1697     Req.Hdr.rc = VERR_INTERNAL_ERROR;
    1698     Req.u.Out.fCaps = 0;
    1699     int rc = suplibOsIOCtl(&g_supLibData, SUP_IOCTL_VT_CAPS, &Req, SUP_IOCTL_VT_CAPS_SIZE);
    1700     if (RT_SUCCESS(rc))
    1701     {
    1702         rc = Req.Hdr.rc;
     1707    int rc;
     1708    if (!g_supLibData.fDriverless)
     1709    {
     1710        /*
     1711         * Issue IOCtl to the SUPDRV kernel module.
     1712         */
     1713        SUPVTCAPS Req;
     1714        Req.Hdr.u32Cookie = g_u32Cookie;
     1715        Req.Hdr.u32SessionCookie = g_u32SessionCookie;
     1716        Req.Hdr.cbIn = SUP_IOCTL_VT_CAPS_SIZE_IN;
     1717        Req.Hdr.cbOut = SUP_IOCTL_VT_CAPS_SIZE_OUT;
     1718        Req.Hdr.fFlags = SUPREQHDR_FLAGS_DEFAULT;
     1719        Req.Hdr.rc = VERR_INTERNAL_ERROR;
     1720        Req.u.Out.fCaps = 0;
     1721        rc = suplibOsIOCtl(&g_supLibData, SUP_IOCTL_VT_CAPS, &Req, SUP_IOCTL_VT_CAPS_SIZE);
    17031722        if (RT_SUCCESS(rc))
    1704             *pfCaps = Req.u.Out.fCaps;
    1705     }
     1723        {
     1724            rc = Req.Hdr.rc;
     1725            if (RT_SUCCESS(rc))
     1726                *pfCaps = Req.u.Out.fCaps;
     1727        }
     1728    }
     1729    /*
     1730     * Fail this call in driverless mode.
     1731     */
     1732    else
     1733        rc = VERR_SUP_DRIVERLESS;
    17061734    return rc;
    17071735}
     
    17241752    *uMicrocodeRev = 0;
    17251753
    1726     /* fake */
    1727     if (RT_UNLIKELY(g_uSupFakeMode))
    1728         return VINF_SUCCESS;
    1729 
    1730     /*
    1731      * Issue IOCtl to the SUPDRV kernel module.
    1732      */
    1733     SUPUCODEREV Req;
    1734     Req.Hdr.u32Cookie = g_u32Cookie;
    1735     Req.Hdr.u32SessionCookie = g_u32SessionCookie;
    1736     Req.Hdr.cbIn = SUP_IOCTL_UCODE_REV_SIZE_IN;
    1737     Req.Hdr.cbOut = SUP_IOCTL_UCODE_REV_SIZE_OUT;
    1738     Req.Hdr.fFlags = SUPREQHDR_FLAGS_DEFAULT;
    1739     Req.Hdr.rc = VERR_INTERNAL_ERROR;
    1740     Req.u.Out.MicrocodeRev = 0;
    1741     int rc = suplibOsIOCtl(&g_supLibData, SUP_IOCTL_UCODE_REV, &Req, SUP_IOCTL_UCODE_REV_SIZE);
    1742     if (RT_SUCCESS(rc))
    1743     {
    1744         rc = Req.Hdr.rc;
     1754    int rc;
     1755    if (!g_supLibData.fDriverless)
     1756    {
     1757        /*
     1758         * Issue IOCtl to the SUPDRV kernel module.
     1759         */
     1760        SUPUCODEREV Req;
     1761        Req.Hdr.u32Cookie = g_u32Cookie;
     1762        Req.Hdr.u32SessionCookie = g_u32SessionCookie;
     1763        Req.Hdr.cbIn = SUP_IOCTL_UCODE_REV_SIZE_IN;
     1764        Req.Hdr.cbOut = SUP_IOCTL_UCODE_REV_SIZE_OUT;
     1765        Req.Hdr.fFlags = SUPREQHDR_FLAGS_DEFAULT;
     1766        Req.Hdr.rc = VERR_INTERNAL_ERROR;
     1767        Req.u.Out.MicrocodeRev = 0;
     1768        rc = suplibOsIOCtl(&g_supLibData, SUP_IOCTL_UCODE_REV, &Req, SUP_IOCTL_UCODE_REV_SIZE);
    17451769        if (RT_SUCCESS(rc))
    1746             *uMicrocodeRev = Req.u.Out.MicrocodeRev;
    1747     }
     1770        {
     1771            rc = Req.Hdr.rc;
     1772            if (RT_SUCCESS(rc))
     1773                *uMicrocodeRev = Req.u.Out.MicrocodeRev;
     1774        }
     1775    }
     1776    /*
     1777     * Just fail the call in driverless mode.
     1778     */
     1779    else
     1780        rc = VERR_SUP_DRIVERLESS;
    17481781    return rc;
    17491782}
  • trunk/src/VBox/HostDrivers/Support/SUPLibInternal.h

    r92613 r92697  
    256256     * support device. */
    257257    bool                fUnrestricted;
     258    /** Set if we're in driverless mode. */
     259    bool                fDriverless;
    258260#if   defined(RT_OS_DARWIN)
    259261    /** The connection to the VBoxSupDrv service. */
  • trunk/src/VBox/HostDrivers/Support/linux/SUPLib-linux.cpp

    r92613 r92697  
    9595    pThis->fSysMadviseWorks = (0 == madvise(pv, PAGE_SIZE, MADV_DONTFORK));
    9696    munmap(pv, PAGE_SIZE);
     97
     98    /*
     99     * Driverless?
     100     */
     101    if (fFlags & SUPR3INIT_F_DRIVERLESS)
     102    {
     103        pThis->fDriverless = true;
     104        return VINF_SUCCESS;
     105    }
    97106
    98107    /*
     
    118127                case ENOENT:    rc = VERR_VM_DRIVER_NOT_INSTALLED; break;
    119128                default:        rc = VERR_VM_DRIVER_OPEN_ERROR; break;
     129            }
     130            if (fFlags & SUPR3INIT_F_DRIVERLESS_MASK)
     131            {
     132                LogRel(("Failed to open \"%s\", errno=%d, rc=%Rrc - Switching to driverless mode.\n", pszDeviceNm, errno, rc));
     133                pThis->fDriverless = true;
     134                return VINF_SUCCESS;
    120135            }
    121136            LogRel(("Failed to open \"%s\", errno=%d, rc=%Rrc\n", pszDeviceNm, errno, rc));
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