VirtualBox

Changeset 106259 in vbox for trunk/src


Ignore:
Timestamp:
Oct 9, 2024 4:09:15 PM (7 weeks ago)
Author:
vboxsync
Message:

Devices/Security: Query the buffer size of the device above and use that to set the buffer size in libtpms, bugref:10772

Location:
trunk/src/VBox/Devices/Security
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Security/DevTpm.cpp

    r106061 r106259  
    544544    /** The base interface for LUN\#0. */
    545545    PDMIBASE                        IBase;
     546    /** The base interface for LUN\#0. */
     547    PDMITPMPORT                     ITpmPort;
    546548    /** The base interface below. */
    547549    R3PTRTYPE(PPDMIBASE)            pDrvBase;
     
    16271629    PDEVTPMCC pThisCC = RT_FROM_MEMBER(pInterface, DEVTPMCC, IBase);
    16281630    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThisCC->IBase);
    1629     //PDMIBASE_RETURN_INTERFACE(pszIID, PDMITPMPORT, &pThisCC->ITpmPort);
     1631    PDMIBASE_RETURN_INTERFACE(pszIID, PDMITPMPORT, &pThisCC->ITpmPort);
    16301632    return NULL;
     1633}
     1634
     1635
     1636/* -=-=-=-=-=-=-=-=- PDMITPMPORT -=-=-=-=-=-=-=-=- */
     1637
     1638/**
     1639 * @interface_method_impl{PDMITPMPORT,pfnGetMaxBufferSize}
     1640 */
     1641static DECLCALLBACK(uint32_t) tpmR3TpmPortGetMaxBufferSize(PPDMITPMPORT pInterface)
     1642{
     1643        RT_NOREF(pInterface);
     1644    return TPM_DATA_BUFFER_SIZE_MAX;
    16311645}
    16321646
     
    16941708    /* IBase */
    16951709    pThisCC->IBase.pfnQueryInterface = tpmR3QueryInterface;
     1710
     1711    /* ITpmPort */
     1712    pThisCC->ITpmPort.pfnGetMaxBufferSize = tpmR3TpmPortGetMaxBufferSize;
     1713
    16961714
    16971715    /*
  • trunk/src/VBox/Devices/Security/DrvTpmEmu.cpp

    r106061 r106259  
    292292    /** Pointer to the driver instance. */
    293293    PPDMDRVINS          pDrvIns;
     294    /** Pointer to the TPM port interface above. */
     295    PPDMITPMPORT        pTpmPort;
    294296
    295297    /** Socket handle for the control connection. */
     
    854856
    855857    /*
     858     * Query the TPM port interface of the device above.
     859     */
     860    pThis->pTpmPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMITPMPORT);
     861    if (!pThis->pTpmPort)
     862    {
     863        AssertMsgFailed(("Configuration error: the above device/driver didn't export the TPM port interface!\n"));
     864        return PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_MISSING_INTERFACE_ABOVE,
     865                                N_("No TPM port interface above"));
     866    }
     867
     868    /*
    856869     * Validate and read the configuration.
    857870     */
     
    946959        return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS,
    947960                                   N_("Configuration error: querying \"BufferSize\" resulted in %Rrc"), rc);
     961
     962    /* Limit to the maximum buffer size of the device above. */
     963    pThis->cbBuffer = RT_MIN(pThis->cbBuffer, pThis->pTpmPort->pfnGetMaxBufferSize(pThis->pTpmPort));
    948964
    949965    /* Set the buffer size. */
  • trunk/src/VBox/Devices/Security/DrvTpmEmuTpms.cpp

    r106061 r106259  
    7979    /** The VFS interface of the driver below for NVRAM/TPM state loading and storing. */
    8080    PPDMIVFSCONNECTOR   pDrvVfs;
     81    /** Pointer to the TPM port interface above. */
     82    PPDMITPMPORT        pTpmPort;
    8183
    8284    /** The TPM version we are emulating. */
     
    480482
    481483    /*
     484     * Query the TPM port interface of the device above.
     485     */
     486    pThis->pTpmPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMITPMPORT);
     487    if (!pThis->pTpmPort)
     488    {
     489        AssertMsgFailed(("Configuration error: the above device/driver didn't export the TPM port interface!\n"));
     490        return PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_MISSING_INTERFACE_ABOVE,
     491                                N_("No TPM port interface above"));
     492    }
     493
     494    /*
    482495     * Try attach the VFS driver below and query it's VFS interface.
    483496     */
     
    529542        return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS,
    530543                                   N_("Configuration error: querying \"BufferSize\" resulted in %Rrc"), rc);
     544
     545    /* Limit to the buffer size of the device above. */
     546    pThis->cbBuffer = RT_MIN(pThis->cbBuffer, pThis->pTpmPort->pfnGetMaxBufferSize(pThis->pTpmPort));
    531547
    532548    uint32_t cbBufferMin = 0;
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