VirtualBox

Changeset 91083 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Sep 2, 2021 8:51:54 AM (3 years ago)
Author:
vboxsync
Message:

Devices/DevACPI,vboxtpm.dsl: Add support for TPM 1.2 operation, bugref:10075

Location:
trunk/src/VBox/Devices/PC
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/PC/DevACPI.cpp

    r90908 r91083  
    968968#define ACPITBL_TPM20_START_METHOD_CRB      UINT16_C(7)
    969969/** @} */
     970
     971
     972/**
     973 * TPM: The ACPI table for a TPM 1.2 device
     974  * (from: https://trustedcomputinggroup.org/wp-content/uploads/TCG_ACPIGeneralSpecification_v1.20_r8.pdf).
     975 */
     976typedef struct ACPITBLTCPA
     977{
     978    /** The common ACPI table header. */
     979    ACPITBLHEADER       Hdr;
     980    /** The platform class. */
     981    uint16_t            u16PlatCls;
     982    /** Log Area Minimum Length. */
     983    uint32_t            u32Laml;
     984    /** Log Area Start Address. */
     985    uint64_t            u64Lasa;
     986} ACPITBLTCPA;
     987AssertCompileSize(ACPITBLTCPA, 50);
     988
     989/** Revision of the TPM1.2 ACPI table. */
     990#define ACPI_TCPA_REVISION                  2
     991/** LAML region size. */
     992#define ACPI_TCPA_LAML_SZ                   _16K
     993
     994
     995/** @name Possible values for the ACPITBLTCPA::u16PlatCls member.
     996 * @{ */
     997/** Client platform. */
     998#define ACPI_TCPA_PLAT_CLS_CLIENT           UINT16_C(0)
     999/** @} */
    9701000#endif
    9711001
     
    35023532static void acpiR3SetupTpm(PPDMDEVINS pDevIns, PACPISTATE pThis, RTGCPHYS32 addr)
    35033533{
    3504     ACPITBLTPM20 Tpm2Tbl;
    3505     RT_ZERO(Tpm2Tbl);
    3506 
    3507     acpiR3PrepareHeader(pThis, &Tpm2Tbl.Hdr, "TPM2", sizeof(ACPITBLTPM20), ACPI_TPM20_REVISION);
    3508 
    3509     switch (pThis->enmTpmMode)
    3510     {
    3511         case ACPITPMMODE_CRB_2_0:
    3512             Tpm2Tbl.u32StartMethod       = ACPITBL_TPM20_START_METHOD_CRB;
    3513             Tpm2Tbl.u64BaseAddrCrbOrFifo = pThis->GCPhysTpmMmio;
    3514             break;
    3515         case ACPITPMMODE_TIS_1_2:
    3516         case ACPITPMMODE_FIFO_2_0:
    3517             Tpm2Tbl.u32StartMethod = ACPITBL_TPM20_START_METHOD_TIS12;
    3518             break;
    3519         case ACPITPMMODE_DISABLED: /* Should never be called with the TPM disabled. */
    3520         default:
    3521             AssertFailed();
    3522     }
    3523 
    3524     Tpm2Tbl.u16PlatCls = ACPITBL_TPM20_PLAT_CLS_CLIENT;
    3525 
    3526     /* Finally, compute checksum. */
    3527     Tpm2Tbl.Hdr.u8Checksum = acpiR3Checksum(&Tpm2Tbl, sizeof(Tpm2Tbl));
    3528 
    3529     /* Plant the ACPI table. */
    3530     acpiR3PhysCopy(pDevIns, addr, (const uint8_t *)&Tpm2Tbl, sizeof(Tpm2Tbl));
     3534    if (pThis->enmTpmMode == ACPITPMMODE_TIS_1_2)
     3535    {
     3536        ACPITBLTCPA TcpaTbl;
     3537        RT_ZERO(TcpaTbl);
     3538
     3539        acpiR3PrepareHeader(pThis, &TcpaTbl.Hdr, "TCPA", sizeof(TcpaTbl), ACPI_TCPA_REVISION);
     3540
     3541        TcpaTbl.u16PlatCls = ACPI_TCPA_PLAT_CLS_CLIENT;
     3542        TcpaTbl.u32Laml    = ACPI_TCPA_LAML_SZ;
     3543        TcpaTbl.u64Lasa    = addr + sizeof(TcpaTbl);
     3544
     3545        /* Finally, compute checksum. */
     3546        TcpaTbl.Hdr.u8Checksum = acpiR3Checksum(&TcpaTbl, sizeof(TcpaTbl));
     3547
     3548        /* Plant the ACPI table. */
     3549        acpiR3PhysCopy(pDevIns, addr, (const uint8_t *)&TcpaTbl, sizeof(TcpaTbl));
     3550    }
     3551    else
     3552    {
     3553        ACPITBLTPM20 Tpm2Tbl;
     3554        RT_ZERO(Tpm2Tbl);
     3555
     3556        acpiR3PrepareHeader(pThis, &Tpm2Tbl.Hdr, "TPM2", sizeof(ACPITBLTPM20), ACPI_TPM20_REVISION);
     3557
     3558        switch (pThis->enmTpmMode)
     3559        {
     3560            case ACPITPMMODE_CRB_2_0:
     3561                Tpm2Tbl.u32StartMethod       = ACPITBL_TPM20_START_METHOD_CRB;
     3562                Tpm2Tbl.u64BaseAddrCrbOrFifo = pThis->GCPhysTpmMmio;
     3563                break;
     3564            case ACPITPMMODE_FIFO_2_0:
     3565                Tpm2Tbl.u32StartMethod = ACPITBL_TPM20_START_METHOD_TIS12;
     3566                break;
     3567            case ACPITPMMODE_TIS_1_2: /* Handled above. */
     3568            case ACPITPMMODE_DISABLED: /* Should never be called with the TPM disabled. */
     3569            default:
     3570                AssertFailed();
     3571        }
     3572
     3573        Tpm2Tbl.u16PlatCls = ACPITBL_TPM20_PLAT_CLS_CLIENT;
     3574
     3575        /* Finally, compute checksum. */
     3576        Tpm2Tbl.Hdr.u8Checksum = acpiR3Checksum(&Tpm2Tbl, sizeof(Tpm2Tbl));
     3577
     3578        /* Plant the ACPI table. */
     3579        acpiR3PhysCopy(pDevIns, addr, (const uint8_t *)&Tpm2Tbl, sizeof(Tpm2Tbl));
     3580    }
    35313581}
    35323582#endif
     
    37973847    {
    37983848        GCPhysTpm = GCPhysCur;
    3799         GCPhysCur = RT_ALIGN_32(GCPhysCur + sizeof(ACPITBLTPM20), 16); /** @todo TPM1.2 */
     3849
     3850        if (pThis->enmTpmMode == ACPITPMMODE_TIS_1_2)
     3851            GCPhysCur = RT_ALIGN_32(GCPhysCur + sizeof(ACPITBLTCPA) + ACPI_TCPA_LAML_SZ, 16);
     3852        else
     3853            GCPhysCur = RT_ALIGN_32(GCPhysCur + sizeof(ACPITBLTPM20), 16);
    38003854
    38013855        rc = acpiPrepareTpmSsdt(pDevIns, &pvSsdtTpmCode, &cbSsdtTpm);
  • trunk/src/VBox/Devices/PC/vbox-tpm.dsl

    r90908 r91083  
    2222        Device (TPM)
    2323        {
    24             Name (_HID, "MSFT0101")
    25             Name (_CID, "MSFT0101")
    26             Name (_STR, Unicode ("TPM 2.0 Device"))
     24            Method (_HID, 0, NotSerialized)
     25            {
     26                If (LEqual(IFID, One))
     27                {
     28                    Return ("PNP0C31")
     29                }
     30                Else
     31                {
     32                    Return ("MSFT0101")
     33                }
     34            }
     35
     36            Method (_CID, 0, NotSerialized)
     37            {
     38                If (LEqual(IFID, One))
     39                {
     40                    Return ("PNP0C31")
     41                }
     42                Else
     43                {
     44                    Return ("MSFT0101")
     45                }
     46            }
     47
     48            Method (_STR, 0, NotSerialized)
     49            {
     50                If (LEqual(IFID, One))
     51                {
     52                    Return (Unicode ("TPM 1.2 Device"))
     53                }
     54                Else
     55                {
     56                    Return (Unicode ("TPM 2.0 Device"))
     57                }
     58            }
    2759
    2860            Method (_STA, 0, NotSerialized)
     
    3264
    3365            OperationRegion (TPMR, SystemMemory, 0xFED40000, 0x5000)
     66            Field(TPMR, AnyAcc, NoLock, Preserve)
     67            {
     68                Offset(0x30),
     69                IFID,       1,
     70            }
    3471
    3572            Name(RES, ResourceTemplate()
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