VirtualBox

Changeset 68568 in vbox for trunk/src/VBox/Additions/common


Ignore:
Timestamp:
Aug 31, 2017 12:10:33 PM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
117785
Message:

merging vbglioc r117733: Moved the ldi_open_by_name stuff to the IDC client code as it's simpler to manage from there, and probably safer.

Location:
trunk/src/VBox/Additions/common
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-solaris.c

    r68566 r68568  
    190190/** The IRQ high-level Mutex. */
    191191static kmutex_t             g_HighLevelIrqMtx;
    192 /** Layered device handle for kernel keep-attached opens */
    193 static ldi_handle_t         g_LdiHandle = NULL;
    194 /** Ref counting for IDCOpen calls */
    195 static uint64_t             g_cLdiOpens = 0;
    196 /** The Mutex protecting the LDI handle in IDC opens */
    197 static kmutex_t             g_LdiMtx;
    198192/** Whether soft-ints are setup. */
    199193static bool                 g_fSoftIntRegistered = false;
     
    220214            cmn_err(CE_NOTE, "failed to initialize driver logging rc=%d!\n", rc);
    221215
    222         mutex_init(&g_LdiMtx, NULL, MUTEX_DRIVER, NULL);
    223 
    224216        /*
    225217         * Prevent module autounloading.
     
    260252
    261253    if (!rc)
    262     {
    263         mutex_destroy(&g_LdiMtx);
    264254        RTR0Term();
    265     }
    266255    return rc;
    267256}
     
    786775        else if (uReq == VBGL_IOCTL_IDC_CONNECT)
    787776        {
    788             /* Reference ourselves to make sure we don't go away.
    789                Note! Would be better if the IDC code did this. */
    790             mutex_enter(&g_LdiMtx);
    791             if (g_LdiHandle)
    792             {
    793                 ++g_cLdiOpens;
    794                 rc = VINF_SUCCESS;
    795             }
    796             else
    797             {
    798                 ldi_ident_t DevIdent = ldi_ident_from_anon();
    799                 rc = ldi_open_by_name(VBOXGUEST_DEVICE_NAME, FREAD, kcred, &g_LdiHandle, DevIdent);
    800                 ldi_ident_release(DevIdent);
    801                 if (!rc)
    802                     ++g_cLdiOpens;
    803                 else
    804                 {
    805                     LogRel(("VBoxGuestIDCOpen: ldi_open_by_name failed. rc=%d\n", rc));
    806                     rc = VERR_OPEN_FAILED;
    807                 }
    808             }
    809             mutex_exit(&g_LdiMtx);
    810 
     777            rc = VGDrvCommonCreateKernelSession(&g_DevExt, &pSession);
    811778            if (RT_SUCCESS(rc))
    812779            {
    813                 rc = VGDrvCommonCreateKernelSession(&g_DevExt, &pSession);
    814                 if (RT_SUCCESS(rc))
    815                 {
    816                     rc = VGDrvCommonIoCtl(uReq, &g_DevExt, pSession, pReqHdr, cbReq);
    817                     if (RT_FAILURE(rc))
    818                         VGDrvCommonCloseSession(&g_DevExt, pSession);
    819                 }
     780                rc = VGDrvCommonIoCtl(uReq, &g_DevExt, pSession, pReqHdr, cbReq);
     781                if (RT_FAILURE(rc))
     782                    VGDrvCommonCloseSession(&g_DevExt, pSession);
    820783            }
    821784        }
    822785        else
    823786            rc = VERR_INVALID_HANDLE;
    824 
    825         /*
    826          * Dereference the driver on disconnect and failed connect.
    827          */
    828         if (RT_UNLIKELY(   (   uReq == VBGL_IOCTL_IDC_CONNECT
    829                             && RT_FAILURE(rc))
    830                         || (   uReq == VBGL_IOCTL_IDC_DISCONNECT
    831                             && RT_SUCCESS(rc)) ))
    832         {
    833             mutex_enter(&g_LdiMtx);
    834             if (g_cLdiOpens > 0)
    835                 --g_cLdiOpens;
    836             if (   g_cLdiOpens == 0
    837                 && g_LdiHandle)
    838             {
    839                 ldi_close(g_LdiHandle, FREAD, kcred);
    840                 g_LdiHandle = NULL;
    841             }
    842             mutex_exit(&g_LdiMtx);
    843         }
    844787    }
    845788    else
  • trunk/src/VBox/Additions/common/VBoxGuestLib/Makefile.kmk

    r68561 r68568  
    7373        HGCM.cpp \
    7474        VbglR0CanUsePhysPageList.cpp
    75 VBoxGuestR0Lib_SOURCES.win = VBoxGuestR0LibIdc-win.cpp
    76 VBoxGuestR0Lib_SOURCES.os2 = VBoxGuestR0LibIdc-os2.cpp
    77 ifn1of ($(KBUILD_TARGET), win os2)
    78  VBoxGuestR0Lib_SOURCES += VBoxGuestR0LibIdc-unix.cpp
     75VBoxGuestR0Lib_SOURCES.os2     = VBoxGuestR0LibIdc-os2.cpp
     76VBoxGuestR0Lib_SOURCES.solaris = VBoxGuestR0LibIdc-solaris.cpp
     77VBoxGuestR0Lib_SOURCES.win     = VBoxGuestR0LibIdc-win.cpp
     78ifn1of ($(KBUILD_TARGET), os2 solaris win)
     79 VBoxGuestR0Lib_SOURCES       += VBoxGuestR0LibIdc-unix.cpp
    7980endif
    8081
  • trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR0LibIdc-win.cpp

    r68561 r68568  
    138138         */
    139139        rc = vbglR0IdcNtCallInternal(pDeviceObject, pFileObject, VBGL_IOCTL_IDC_CONNECT, &pReq->Hdr);
    140         if (RT_SUCCESS(rc))
     140        if (RT_SUCCESS(rc) && RT_SUCCESS(pReq->Hdr.rc))
    141141        {
    142142            pHandle->s.pDeviceObject = pDeviceObject;
     
    161161    PFILE_OBJECT pFileObject = pHandle->s.pFileObject;
    162162    int rc = vbglR0IdcNtCallInternal(pHandle->s.pDeviceObject, pFileObject, VBGL_IOCTL_IDC_DISCONNECT, &pReq->Hdr);
    163     if (RT_SUCCESS(rc))
     163    if (RT_SUCCESS(rc) && RT_SUCCESS(pReq->Hdr.rc))
    164164    {
    165165        pHandle->s.pDeviceObject = NULL;
  • trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR0LibInternal.h

    r68550 r68568  
    3333#ifdef RT_OS_WINDOWS
    3434# include <iprt/nt/ntddk.h>
     35#elif defined(RT_OS_SOLARIS)
     36# include <sys/conf.h>
     37# include <sys/sunldi.h>
     38# include <sys/file.h>
     39# undef u /* /usr/include/sys/user.h:249:1 is where this is defined to (curproc->p_user). very cool. */
    3540#endif
    3641
     
    4348    /** Pointer to the session handle. */
    4449    void           *pvSession;
    45 # ifdef RT_OS_WINDOWS
     50#ifdef RT_OS_WINDOWS
    4651    /** Pointer to the NT device object. */
    4752    PDEVICE_OBJECT  pDeviceObject;
    4853    /** Pointer to the NT file object. */
    4954    PFILE_OBJECT    pFileObject;
    50 # endif
     55#elif defined(RT_OS_SOLARIS)
     56    /** LDI device handle to keep the device attached. */
     57    ldi_handle_t    hDev;
     58#endif
    5159};
    5260/** Indicate that the structure is present. */
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