VirtualBox

Changeset 106960 in vbox for trunk/src/VBox/Main/src-client


Ignore:
Timestamp:
Nov 12, 2024 1:49:12 PM (3 months ago)
Author:
vboxsync
Message:

Main: Unify the TPM instantiation as much as possible between x86 and armv8 platforms, bugref:10732

Location:
trunk/src/VBox/Main/src-client
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-client/ConsoleImplConfigArmV8.cpp

    r106957 r106960  
    453453        PCFGMNODE pCfg = NULL;          /* /Devices/Dev/.../Config/ */
    454454        PCFGMNODE pLunL0 = NULL;        /* /Devices/Dev/0/LUN#0/ */
    455         PCFGMNODE pLunL1 = NULL;        /* /Devices/Dev/0/LUN#0/AttachedDriver/ */
    456455
    457456        InsertConfigNode(pRoot, "Devices", &pDevices);
     
    756755        TpmType_T enmTpmType = TpmType_None;
    757756
    758         hrc = pMachine->COMGETTER(TrustedPlatformModule)(ptrTpm.asOutParam());              H();
    759         hrc = ptrTpm->COMGETTER(Type)(&enmTpmType);                                         H();
     757        hrc = pMachine->COMGETTER(TrustedPlatformModule)(ptrTpm.asOutParam());                  H();
     758        hrc = ptrTpm->COMGETTER(Type)(&enmTpmType);                                             H();
    760759        if (enmTpmType != TpmType_None)
    761760        {
    762             hrc = pResMgr->assignSingleInterrupt("tpm", &iIrq);                               H();
    763 
    764             InsertConfigNode(pDevices, "tpm", &pDev);
    765             InsertConfigNode(pDev,     "0", &pInst);
    766             InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
    767             InsertConfigNode(pInst,    "Config", &pCfg);
    768             InsertConfigInteger(pCfg,  "MmioBase", GCPhysTpm);
    769             InsertConfigInteger(pCfg,  "Irq",      iIrq);
    770             InsertConfigInteger(pCfg,  "Crb",      1); /* boolean */
    771 
    772             InsertConfigNode(pInst,    "LUN#0", &pLunL0);
    773 
    774             switch (enmTpmType)
    775             {
    776                 case TpmType_v1_2:
    777                 case TpmType_v2_0:
    778                     InsertConfigString(pLunL0, "Driver",               "TpmEmuTpms");
    779                     InsertConfigNode(pLunL0,   "Config", &pCfg);
    780                     InsertConfigInteger(pCfg, "TpmVersion", enmTpmType == TpmType_v1_2 ? 1 : 2);
    781                     InsertConfigNode(pLunL0, "AttachedDriver", &pLunL1);
    782                     InsertConfigString(pLunL1, "Driver", "NvramStore");
    783                     break;
    784                 case TpmType_Host:
    785 #if defined(RT_OS_LINUX) || defined(RT_OS_WINDOWS)
    786                     InsertConfigString(pLunL0, "Driver",               "TpmHost");
    787                     InsertConfigNode(pLunL0,   "Config", &pCfg);
    788 #endif
    789                     break;
    790                 case TpmType_Swtpm:
    791                     hrc = ptrTpm->COMGETTER(Location)(bstr.asOutParam());                   H();
    792                     InsertConfigString(pLunL0, "Driver",               "TpmEmu");
    793                     InsertConfigNode(pLunL0,   "Config", &pCfg);
    794                     InsertConfigString(pCfg,   "Location", bstr);
    795                     break;
    796                 default:
    797                     AssertFailedBreak();
    798             }
     761            hrc = pResMgr->assignSingleInterrupt("tpm", &iIrq);                                 H();
     762
     763            vrc = i_configTpm(ptrTpm, enmTpmType, pDevices, GCPhysTpm, iIrq /*uIrq*/,
     764                              GCPhysTpm + 0x5000, true /*fCrb*/);                               VRC();
    799765
    800766            vrc = RTFdtNodeAddF(hFdt, "tpm@%RGp", GCPhysTpm);                                   VRC();
     
    809775                VRC();
    810776            }
    811 
    812             /* Add the device for the physical presence interface. */
    813             InsertConfigNode(   pDevices, "tpm-ppi",  &pDev);
    814             InsertConfigNode(   pDev,     "0",        &pInst);
    815             InsertConfigInteger(pInst,    "Trusted",  1); /* boolean */
    816             InsertConfigNode(   pInst,    "Config",   &pCfg);
    817             InsertConfigInteger(pCfg,     "MmioBase", GCPhysTpm + 0x5000);
    818777        }
    819778#endif
  • trunk/src/VBox/Main/src-client/ConsoleImplConfigCommon.cpp

    r105965 r106960  
    51785178}
    51795179
     5180
     5181#if defined(VBOX_WITH_TPM)
     5182int Console::i_configTpm(ComPtr<ITrustedPlatformModule> pTpm, TpmType_T enmTpmType, PCFGMNODE pDevices,
     5183                         RTGCPHYS GCPhysTpmMmio, uint32_t uIrq, RTGCPHYS GCPhysTpmPpi, bool fCrb)
     5184{
     5185    Assert(enmTpmType != TpmType_None);
     5186
     5187    // InsertConfig* throws
     5188    try
     5189    {
     5190        HRESULT hrc;
     5191        Bstr    bstr;
     5192        PCFGMNODE pDev = NULL;          /* /Devices/Dev/ */
     5193        PCFGMNODE pInst = NULL;         /* /Devices/Dev/0/ */
     5194        PCFGMNODE pCfg = NULL;          /* /Devices/Dev/.../Config/ */
     5195        PCFGMNODE pLunL0 = NULL;        /* /Devices/Dev/0/LUN#0/ */
     5196        PCFGMNODE pLunL1 = NULL;        /* /Devices/Dev/0/LUN#0/AttachedDriver */
     5197
     5198        InsertConfigNode(pDevices, "tpm", &pDev);
     5199        InsertConfigNode(pDev,     "0", &pInst);
     5200        InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
     5201        InsertConfigNode(pInst,    "Config", &pCfg);
     5202        InsertConfigInteger(pCfg,  "MmioBase", GCPhysTpmMmio);
     5203        InsertConfigInteger(pCfg,  "Irq",      uIrq);
     5204        InsertConfigInteger(pCfg,  "Crb",      fCrb ? 1 : 0); /* boolean */
     5205
     5206        InsertConfigNode(pInst,    "LUN#0", &pLunL0);
     5207
     5208        switch (enmTpmType)
     5209        {
     5210            case TpmType_v1_2:
     5211            case TpmType_v2_0:
     5212                InsertConfigString(pLunL0, "Driver",               "TpmEmuTpms");
     5213                InsertConfigNode(pLunL0,   "Config", &pCfg);
     5214                InsertConfigInteger(pCfg, "TpmVersion", enmTpmType == TpmType_v1_2 ? 1 : 2);
     5215                InsertConfigNode(pLunL0, "AttachedDriver", &pLunL1);
     5216                InsertConfigString(pLunL1, "Driver", "NvramStore");
     5217                break;
     5218            case TpmType_Host:
     5219#if defined(RT_OS_LINUX) || defined(RT_OS_WINDOWS)
     5220                InsertConfigString(pLunL0, "Driver",               "TpmHost");
     5221                InsertConfigNode(pLunL0,   "Config", &pCfg);
     5222#endif
     5223                break;
     5224            case TpmType_Swtpm:
     5225                hrc = pTpm->COMGETTER(Location)(bstr.asOutParam());                   H();
     5226                InsertConfigString(pLunL0, "Driver",               "TpmEmu");
     5227                InsertConfigNode(pLunL0,   "Config", &pCfg);
     5228                InsertConfigString(pCfg,   "Location", bstr);
     5229                break;
     5230            default:
     5231                AssertFailedBreak();
     5232        }
     5233
     5234        if (GCPhysTpmPpi != RTGCPHYS_MAX)
     5235        {
     5236            /* Add the device for the physical presence interface. */
     5237            InsertConfigNode(   pDevices, "tpm-ppi",  &pDev);
     5238            InsertConfigNode(   pDev,     "0",        &pInst);
     5239            InsertConfigInteger(pInst,    "Trusted",  1); /* boolean */
     5240            InsertConfigNode(   pInst,    "Config",   &pCfg);
     5241            InsertConfigInteger(pCfg,     "MmioBase", GCPhysTpmPpi);
     5242        }
     5243    }
     5244    catch (ConfigError &x)
     5245    {
     5246        // InsertConfig threw something:
     5247        return x.m_vrc;
     5248    }
     5249
     5250    return VINF_SUCCESS;
     5251}
     5252#endif /* VBOX_WITH_TPM */
     5253
    51805254#undef H
    51815255#undef VRC
  • trunk/src/VBox/Main/src-client/ConsoleImplConfigX86.cpp

    r105621 r106960  
    9292#endif
    9393
     94/** The TPM MMIO base default. */
     95#define TPM_MMIO_BASE_DEFAULT UINT64_C(0xfed40000)
    9496/** The TPM PPI MMIO base default (compatible with qemu). */
    9597#define TPM_PPI_MMIO_BASE_DEFAULT UINT64_C(0xfed45000)
     
    14621464        if (enmTpmType != TpmType_None)
    14631465        {
    1464             InsertConfigNode(pDevices, "tpm", &pDev);
    1465             InsertConfigNode(pDev,     "0", &pInst);
    1466             InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
    1467             InsertConfigNode(pInst,    "Config", &pCfg);
    1468             InsertConfigNode(pInst,    "LUN#0", &pLunL0);
    1469 
    1470             switch (enmTpmType)
    1471             {
    1472                 case TpmType_v1_2:
    1473                 case TpmType_v2_0:
    1474                     InsertConfigString(pLunL0, "Driver",               "TpmEmuTpms");
    1475                     InsertConfigNode(pLunL0,   "Config", &pCfg);
    1476                     InsertConfigInteger(pCfg, "TpmVersion", enmTpmType == TpmType_v1_2 ? 1 : 2);
    1477                     InsertConfigNode(pLunL0, "AttachedDriver", &pLunL1);
    1478                     InsertConfigString(pLunL1, "Driver", "NvramStore");
    1479                     break;
    1480                 case TpmType_Host:
    1481 #if defined(RT_OS_LINUX) || defined(RT_OS_WINDOWS)
    1482                     InsertConfigString(pLunL0, "Driver",               "TpmHost");
    1483                     InsertConfigNode(pLunL0,   "Config", &pCfg);
    1484 #endif
    1485                     break;
    1486                 case TpmType_Swtpm:
    1487                     hrc = ptrTpm->COMGETTER(Location)(bstr.asOutParam());                   H();
    1488                     InsertConfigString(pLunL0, "Driver",               "TpmEmu");
    1489                     InsertConfigNode(pLunL0,   "Config", &pCfg);
    1490                     InsertConfigString(pCfg,   "Location", bstr);
    1491                     break;
    1492                 default:
    1493                     AssertFailedBreak();
    1494             }
    1495 
    1496             /* Add the device for the physical presence interface. */
    1497             InsertConfigNode(   pDevices, "tpm-ppi",  &pDev);
    1498             InsertConfigNode(   pDev,     "0",        &pInst);
    1499             InsertConfigInteger(pInst,    "Trusted",  1); /* boolean */
    1500             InsertConfigNode(   pInst,    "Config",   &pCfg);
    1501             InsertConfigInteger(pCfg,     "MmioBase", TPM_PPI_MMIO_BASE_DEFAULT);
     1466            vrc = i_configTpm(ptrTpm, enmTpmType, pDevices, TPM_MMIO_BASE_DEFAULT, 10 /*uIrq*/,
     1467                              TPM_PPI_MMIO_BASE_DEFAULT, false /*fCrb*/);                   VRC();
    15021468        }
    15031469#endif
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