VirtualBox

Changeset 17196 in vbox


Ignore:
Timestamp:
Feb 27, 2009 11:57:04 AM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
43488
Message:

Additions, VBoxGuestR3Lib: 32-bit ioctl handling for 64-bit guest driver. This fixes broken additions on S10 u6.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/include/VBox/VBoxGuest.h

    r15810 r17196  
    3636# include <iprt/stdarg.h>
    3737#endif
     38#include <iprt/assert.h>
    3839#include <VBox/err.h>
    3940#include <VBox/ostypes.h>
     
    238239    uint32_t reserved2;
    239240} VMMDevRequestHeader;
     241AssertCompileSize(VMMDevRequestHeader, 24);
    240242
    241243/** mouse status request structure */
     
    640642    int32_t result;
    641643} VMMDevHGCMRequestHeader;
     644AssertCompileSize(VMMDevHGCMRequestHeader, 24+8);
    642645
    643646/** HGCM service location types. */
     
    12271230    /** The user address of the data buffer. */
    12281231    RTR3PTR     pvDataR3;
     1232#if HC_ARCH_BITS == 32
     1233    uint32_t    u32Padding;
     1234#endif   
    12291235} VBGLBIGREQ;
    12301236/** Pointer to a request wrapper for solaris guests. */
     
    12871293#endif /* RT_ARCH_AMD64 */
    12881294
    1289 /** IOCTL to VBoxGuest to query the VMMDev IO port region start. */
     1295/** IOCTL to VBoxGuest to query the VMMDev IO port region start.
     1296 * @remarks Ring-0 only. */
    12901297#define VBOXGUEST_IOCTL_GETVMMDEVPORT   VBOXGUEST_IOCTL_CODE(1, sizeof(VBoxGuestPortInfo))
    12911298
     
    12981305
    12991306/** IOCTL to VBoxGuest to wait for a VMMDev host notification */
    1300 #define VBOXGUEST_IOCTL_WAITEVENT       VBOXGUEST_IOCTL_CODE(2, sizeof(VBoxGuestWaitEventInfo))
     1307#define VBOXGUEST_IOCTL_WAITEVENT       VBOXGUEST_IOCTL_CODE_(2, sizeof(VBoxGuestWaitEventInfo))
    13011308
    13021309/** IOCTL to VBoxGuest to interrupt (cancel) any pending WAITEVENTs and return.
    13031310 * Handled inside the guest additions and not seen by the host at all.
    13041311 * @see VBOXGUEST_IOCTL_WAITEVENT */
    1305 #define VBOXGUEST_IOCTL_CANCEL_ALL_WAITEVENTS       VBOXGUEST_IOCTL_CODE(5, 0)
     1312#define VBOXGUEST_IOCTL_CANCEL_ALL_WAITEVENTS       VBOXGUEST_IOCTL_CODE_(5, 0)
    13061313
    13071314/** @name Result codes for VBoxGuestWaitEventInfo::u32Result
     
    13301337    uint32_t u32EventFlagsOut;
    13311338} VBoxGuestWaitEventInfo;
     1339AssertCompileSize(VBoxGuestWaitEventInfo, 16);
    13321340
    13331341/** IOCTL to VBoxGuest to perform a VMM request
    13341342 * @remark  The data buffer for this IOCtl has an variable size, keep this in mind
    13351343 *          on systems where this matters. */
    1336 #define VBOXGUEST_IOCTL_VMMREQUEST(Size)            VBOXGUEST_IOCTL_CODE(3, (Size))
     1344#define VBOXGUEST_IOCTL_VMMREQUEST(Size)            VBOXGUEST_IOCTL_CODE_(3, (Size))
    13371345
    13381346/** Input and output buffer layout of the IOCTL_VBOXGUEST_CTL_FILTER_MASK. */
     
    13421350    uint32_t u32NotMask;
    13431351} VBoxGuestFilterMaskInfo;
     1352AssertCompileSize(VBoxGuestFilterMaskInfo, 8);
    13441353#pragma pack()
    13451354
    13461355/** IOCTL to VBoxGuest to control event filter mask. */
    1347 #define VBOXGUEST_IOCTL_CTL_FILTER_MASK             VBOXGUEST_IOCTL_CODE(4, sizeof(VBoxGuestFilterMaskInfo))
     1356#define VBOXGUEST_IOCTL_CTL_FILTER_MASK             VBOXGUEST_IOCTL_CODE_(4, sizeof(VBoxGuestFilterMaskInfo))
    13481357
    13491358/** IOCTL to VBoxGuest to check memory ballooning. */
    1350 #define VBOXGUEST_IOCTL_CTL_CHECK_BALLOON_MASK      VBOXGUEST_IOCTL_CODE(7, 100)
     1359#define VBOXGUEST_IOCTL_CTL_CHECK_BALLOON_MASK      VBOXGUEST_IOCTL_CODE_(7, 100)
    13511360
    13521361/** IOCTL to VBoxGuest to perform backdoor logging. */
    1353 #define VBOXGUEST_IOCTL_LOG(Size)                   VBOXGUEST_IOCTL_CODE(6, (Size))
     1362#define VBOXGUEST_IOCTL_LOG(Size)                   VBOXGUEST_IOCTL_CODE_(6, (Size))
    13541363
    13551364
     
    13651374    uint32_t u32ClientID;     /**< OUT */
    13661375} VBoxGuestHGCMConnectInfo;
     1376AssertCompileSize(VBoxGuestHGCMConnectInfo, 4+4+128+4);
    13671377
    13681378typedef struct _VBoxGuestHGCMDisconnectInfo
     
    13711381    uint32_t u32ClientID;     /**< IN */
    13721382} VBoxGuestHGCMDisconnectInfo;
     1383AssertCompileSize(VBoxGuestHGCMDisconnectInfo, 8);
    13731384
    13741385typedef struct _VBoxGuestHGCMCallInfo
     
    13801391    /* Parameters follow in form HGCMFunctionParameter aParms[cParms] */
    13811392} VBoxGuestHGCMCallInfo;
     1393AssertCompileSize(VBoxGuestHGCMCallInfo, 16);
    13821394
    13831395typedef struct _VBoxGuestHGCMCallInfoTimed
     
    13891401    /* Parameters follow in form HGCMFunctionParameter aParms[cParms] */
    13901402} VBoxGuestHGCMCallInfoTimed;
     1403AssertCompileSize(VBoxGuestHGCMCallInfoTimed, 8+16);
    13911404# pragma pack()
    13921405
     
    13951408# define VBOXGUEST_IOCTL_HGCM_CALL(Size)          VBOXGUEST_IOCTL_CODE(18, (Size))
    13961409# define VBOXGUEST_IOCTL_HGCM_CALL_TIMED(Size)    VBOXGUEST_IOCTL_CODE(20, (Size))
    1397 # define VBOXGUEST_IOCTL_CLIPBOARD_CONNECT        VBOXGUEST_IOCTL_CODE(19, sizeof(uint32_t))
    1398 #ifdef RT_ARCH_AMD64
     1410# define VBOXGUEST_IOCTL_CLIPBOARD_CONNECT        VBOXGUEST_IOCTL_CODE_(19, sizeof(uint32_t))
     1411# ifdef RT_ARCH_AMD64
    13991412/* Following HGCM IOCtls can be used by a 32 bit application on a 64 bit guest (Windows OpenGL guest driver). */
    1400 # define VBOXGUEST_IOCTL_HGCM_CONNECT_32          VBOXGUEST_IOCTL_CODE_32(16, sizeof(VBoxGuestHGCMConnectInfo))
    1401 # define VBOXGUEST_IOCTL_HGCM_DISCONNECT_32       VBOXGUEST_IOCTL_CODE_32(17, sizeof(VBoxGuestHGCMDisconnectInfo))
    1402 # define VBOXGUEST_IOCTL_HGCM_CALL_32(Size)       VBOXGUEST_IOCTL_CODE_32(18, (Size))
    1403 #endif /* RT_ARCH_AMD64 */
     1413#  define VBOXGUEST_IOCTL_HGCM_CONNECT_32         VBOXGUEST_IOCTL_CODE_32(16, sizeof(VBoxGuestHGCMConnectInfo))
     1414#  define VBOXGUEST_IOCTL_HGCM_DISCONNECT_32      VBOXGUEST_IOCTL_CODE_32(17, sizeof(VBoxGuestHGCMDisconnectInfo))
     1415#  define VBOXGUEST_IOCTL_HGCM_CALL_32(Size)      VBOXGUEST_IOCTL_CODE_32(18, (Size))
     1416#  define VBOXGUEST_IOCTL_HGCM_CALL_TIMED_32(Size) VBOXGUEST_IOCTL_CODE_32(20, (Size))
     1417# endif /* RT_ARCH_AMD64 */
    14041418
    14051419# define VBOXGUEST_HGCM_CALL_PARMS(a)       ((HGCMFunctionParameter *)((uint8_t *)(a) + sizeof (VBoxGuestHGCMCallInfo)))
  • TabularUnified trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest.cpp

    r14462 r17196  
    11121112
    11131113
     1114#ifdef RT_ARCH_AMD64
     1115/** The 32-bit version HGCM call for 64-bit driver. */
     1116static int VBoxGuestCommonIOCtl_HGCMCall32(PVBOXGUESTDEVEXT pDevExt,
     1117                                           PVBOXGUESTSESSION pSession,
     1118                                           VBoxGuestHGCMCallInfo *pInfo,
     1119                                           uint32_t cMillies, bool fInterruptible,
     1120                                           size_t cbExtra, size_t cbData, size_t *pcbDataReturned)
     1121{
     1122    /*
     1123     * Some more validations.
     1124     */
     1125    if (pInfo->cParms > 4096) /* (Just make sure it doesn't overflow the next check.) */
     1126    {
     1127        Log(("VBoxGuestCommonIOCtl: HGCM_CALL: cParm=%RX32 is not sane\n", pInfo->cParms));
     1128        return VERR_INVALID_PARAMETER;
     1129    }
     1130    const size_t cbActual = cbExtra + sizeof(*pInfo) + pInfo->cParms * sizeof(HGCMFunctionParameter32);
     1131    if (cbData < cbActual)
     1132    {
     1133        Log(("VBoxGuestCommonIOCtl: HGCM_CALL: cbData=%#zx (%zu) required size is %#zx (%zu)\n",
     1134             cbData, cbActual));
     1135        return VERR_INVALID_PARAMETER;
     1136    }
     1137
     1138    /*
     1139     * Validate the client id.
     1140     */
     1141    const uint32_t u32ClientId = pInfo->u32ClientID;
     1142    unsigned i;
     1143    RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
     1144    RTSpinlockAcquireNoInts(pDevExt->SessionSpinlock, &Tmp);
     1145    for (i = 0; i < RT_ELEMENTS(pSession->aHGCMClientIds); i++)
     1146        if (pSession->aHGCMClientIds[i] == u32ClientId)
     1147            break;
     1148    RTSpinlockReleaseNoInts(pDevExt->SessionSpinlock, &Tmp);
     1149    if (RT_UNLIKELY(i >= RT_ELEMENTS(pSession->aHGCMClientIds)))
     1150    {
     1151        static unsigned s_cErrors = 0;
     1152        if (s_cErrors++ > 32)
     1153            LogRel(("VBoxGuestCommonIOCtl: HGCM_CALL: Invalid handle. u32Client=%RX32\n", u32ClientId));
     1154        return VERR_INVALID_HANDLE;
     1155    }
     1156
     1157    /*
     1158     * The VbglHGCMCall call will invoke the callback if the HGCM
     1159     * call is performed in an ASYNC fashion. This function can
     1160     * deal with cancelled requests, so we let user more requests
     1161     * be interruptible (should add a flag for this later I guess).
     1162     */
     1163    Log(("VBoxGuestCommonIOCtl: HGCM_CALL: u32Client=%RX32\n", pInfo->u32ClientID));
     1164    int rc;
     1165    if (fInterruptible)
     1166        rc = VbglHGCMCall32(pInfo, VBoxGuestHGCMAsyncWaitCallbackInterruptible, pDevExt, cMillies);
     1167    else
     1168        rc = VbglHGCMCall32(pInfo, VBoxGuestHGCMAsyncWaitCallback, pDevExt, cMillies);
     1169    if (RT_SUCCESS(rc))
     1170    {
     1171        Log(("VBoxGuestCommonIOCtl: HGCM_CALL: result=%Rrc\n", pInfo->result));
     1172        if (pcbDataReturned)
     1173            *pcbDataReturned = cbActual;
     1174    }
     1175    Log(("VBoxGuestCommonIOCtl: HGCM_CALL: Failed. rc=%Rrc.\n", rc));
     1176    return rc;
     1177}
     1178#endif
     1179
     1180
    11141181/**
    11151182 * @returns VBox status code. Unlike the other HGCM IOCtls this will combine
     
    12731340                                           RT_OFFSETOF(VBoxGuestHGCMCallInfoTimed, info), cbData, pcbDataReturned);
    12741341    }
     1342# ifdef RT_ARCH_AMD64
     1343    else if (VBOXGUEST_IOCTL_STRIP_SIZE(iFunction) == VBOXGUEST_IOCTL_STRIP_SIZE(VBOXGUEST_IOCTL_HGCM_CALL_32(0)))
     1344    {
     1345        CHECKRET_MIN_SIZE("HGCM_CALL", sizeof(VBoxGuestHGCMCallInfo));
     1346        bool fInterruptible = pSession->R0Process != NIL_RTR0PROCESS;
     1347        rc = VBoxGuestCommonIOCtl_HGCMCall32(pDevExt, pSession, (VBoxGuestHGCMCallInfo *)pvData, RT_INDEFINITE_WAIT,
     1348                                             fInterruptible,
     1349                                             0, cbData, pcbDataReturned);
     1350    }
     1351    else if (VBOXGUEST_IOCTL_STRIP_SIZE(iFunction) == VBOXGUEST_IOCTL_STRIP_SIZE(VBOXGUEST_IOCTL_HGCM_CALL_TIMED_32(0)))
     1352    {
     1353        CHECKRET_MIN_SIZE("HGCM_CALL_TIMED", sizeof(VBoxGuestHGCMCallInfoTimed));
     1354        VBoxGuestHGCMCallInfoTimed *pInfo = (VBoxGuestHGCMCallInfoTimed *)pvData;
     1355        rc = VBoxGuestCommonIOCtl_HGCMCall32(pDevExt, pSession, &pInfo->info, pInfo->u32Timeout,
     1356                                             !!pInfo->fInterruptible || pSession->R0Process != NIL_RTR0PROCESS,
     1357                                             RT_OFFSETOF(VBoxGuestHGCMCallInfoTimed, info), cbData, pcbDataReturned);
     1358    }   
     1359# endif   
    12751360#endif /* VBOX_WITH_HGCM */
    12761361    else if (VBOXGUEST_IOCTL_STRIP_SIZE(iFunction) == VBOXGUEST_IOCTL_STRIP_SIZE(VBOXGUEST_IOCTL_LOG(0)))
     
    13021387#ifdef VBOX_WITH_HGCM
    13031388            case VBOXGUEST_IOCTL_HGCM_CONNECT:
     1389# ifdef RT_ARCH_AMD64
     1390            case VBOXGUEST_IOCTL_HGCM_CONNECT_32:
     1391# endif             
    13041392                CHECKRET_MIN_SIZE("HGCM_CONNECT", sizeof(VBoxGuestHGCMConnectInfo));
    13051393                rc = VBoxGuestCommonIOCtl_HGCMConnect(pDevExt, pSession, (VBoxGuestHGCMConnectInfo *)pvData, pcbDataReturned);
     
    13071395
    13081396            case VBOXGUEST_IOCTL_HGCM_DISCONNECT:
     1397# ifdef RT_ARCH_AMD64
     1398            case VBOXGUEST_IOCTL_HGCM_DISCONNECT_32:
     1399# endif             
    13091400                CHECKRET_MIN_SIZE("HGCM_DISCONNECT", sizeof(VBoxGuestHGCMDisconnectInfo));
    13101401                rc = VBoxGuestCommonIOCtl_HGCMDisconnect(pDevExt, pSession, (VBoxGuestHGCMDisconnectInfo *)pvData, pcbDataReturned);
     
    13151406                rc = VBoxGuestCommonIOCtl_HGCMClipboardReConnect(pDevExt, (uint32_t *)pvData, pcbDataReturned);
    13161407                break;
     1408               
    13171409#endif /* VBOX_WITH_HGCM */
    13181410
  • TabularUnified trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3Lib.cpp

    r14217 r17196  
    337337    Hdr.cbData = cbData;
    338338    Hdr.pvDataR3 = pvData;
     339# if HC_ARCH_BITS == 32
     340    Hdr.u32Padding = 0;
     341# endif
    339342
    340343/** @todo test status code passing! */
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