VirtualBox

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


Ignore:
Timestamp:
Jun 27, 2024 8:54:21 AM (10 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
163661
Message:

Main/ConsoleImplConfigX86.cpp: Configure the TPM PPI area, bugref:10701

File:
1 edited

Legend:

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

    r104844 r105043  
    9292#endif
    9393
     94/** The TPM PPI MMIO base default (compatible with qemu). */
     95#define TPM_PPI_MMIO_BASE_DEFAULT UINT64_C(0xfed45000)
    9496
    9597/*********************************************************************************************************************************
     
    14481450        }
    14491451
     1452#if defined(VBOX_WITH_TPM)
     1453        /*
     1454         * Configure the Trusted Platform Module.
     1455         */
     1456        ComObjPtr<ITrustedPlatformModule> ptrTpm;
     1457        TpmType_T enmTpmType = TpmType_None;
     1458
     1459        hrc = pMachine->COMGETTER(TrustedPlatformModule)(ptrTpm.asOutParam());              H();
     1460        hrc = ptrTpm->COMGETTER(Type)(&enmTpmType);                                         H();
     1461        if (enmTpmType != TpmType_None)
     1462        {
     1463            InsertConfigNode(pDevices, "tpm", &pDev);
     1464            InsertConfigNode(pDev,     "0", &pInst);
     1465            InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
     1466            InsertConfigNode(pInst,    "Config", &pCfg);
     1467            InsertConfigNode(pInst,    "LUN#0", &pLunL0);
     1468
     1469            switch (enmTpmType)
     1470            {
     1471                case TpmType_v1_2:
     1472                case TpmType_v2_0:
     1473                    InsertConfigString(pLunL0, "Driver",               "TpmEmuTpms");
     1474                    InsertConfigNode(pLunL0,   "Config", &pCfg);
     1475                    InsertConfigInteger(pCfg, "TpmVersion", enmTpmType == TpmType_v1_2 ? 1 : 2);
     1476                    InsertConfigNode(pLunL0, "AttachedDriver", &pLunL1);
     1477                    InsertConfigString(pLunL1, "Driver", "NvramStore");
     1478                    break;
     1479                case TpmType_Host:
     1480#if defined(RT_OS_LINUX) || defined(RT_OS_WINDOWS)
     1481                    InsertConfigString(pLunL0, "Driver",               "TpmHost");
     1482                    InsertConfigNode(pLunL0,   "Config", &pCfg);
     1483#endif
     1484                    break;
     1485                case TpmType_Swtpm:
     1486                    hrc = ptrTpm->COMGETTER(Location)(bstr.asOutParam());                   H();
     1487                    InsertConfigString(pLunL0, "Driver",               "TpmEmu");
     1488                    InsertConfigNode(pLunL0,   "Config", &pCfg);
     1489                    InsertConfigString(pCfg,   "Location", bstr);
     1490                    break;
     1491                default:
     1492                    AssertFailedBreak();
     1493            }
     1494
     1495            /* Add the device for the physical presence interface. */
     1496            InsertConfigNode(   pDevices, "tpm-ppi",  &pDev);
     1497            InsertConfigNode(   pDev,     "0",        &pInst);
     1498            InsertConfigInteger(pInst,    "Trusted",  1); /* boolean */
     1499            InsertConfigNode(   pInst,    "Config",   &pCfg);
     1500            InsertConfigInteger(pCfg,     "MmioBase", TPM_PPI_MMIO_BASE_DEFAULT);
     1501        }
     1502#endif
     1503
    14501504        /*
    14511505         * Firmware.
     
    16451699            }
    16461700
     1701            if (enmTpmType != TpmType_None)
     1702                InsertConfigInteger(pCfg, "TpmPpiBase", TPM_PPI_MMIO_BASE_DEFAULT);
     1703
    16471704            /* Attach the NVRAM storage driver. */
    16481705            InsertConfigNode(pInst,    "LUN#0",     &pLunL0);
     
    18081865        vrc = i_configAudioCtrl(virtualBox, pMachine, pBusMgr, pDevices,
    18091866                                fOsXGuest, &fAudioEnabled);                                     VRC();
    1810 
    1811 #if defined(VBOX_WITH_TPM)
    1812         /*
    1813          * Configure the Trusted Platform Module.
    1814          */
    1815         ComObjPtr<ITrustedPlatformModule> ptrTpm;
    1816         TpmType_T enmTpmType = TpmType_None;
    1817 
    1818         hrc = pMachine->COMGETTER(TrustedPlatformModule)(ptrTpm.asOutParam());              H();
    1819         hrc = ptrTpm->COMGETTER(Type)(&enmTpmType);                                         H();
    1820         if (enmTpmType != TpmType_None)
    1821         {
    1822             InsertConfigNode(pDevices, "tpm", &pDev);
    1823             InsertConfigNode(pDev,     "0", &pInst);
    1824             InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
    1825             InsertConfigNode(pInst,    "Config", &pCfg);
    1826             InsertConfigNode(pInst,    "LUN#0", &pLunL0);
    1827 
    1828             switch (enmTpmType)
    1829             {
    1830                 case TpmType_v1_2:
    1831                 case TpmType_v2_0:
    1832                     InsertConfigString(pLunL0, "Driver",               "TpmEmuTpms");
    1833                     InsertConfigNode(pLunL0,   "Config", &pCfg);
    1834                     InsertConfigInteger(pCfg, "TpmVersion", enmTpmType == TpmType_v1_2 ? 1 : 2);
    1835                     InsertConfigNode(pLunL0, "AttachedDriver", &pLunL1);
    1836                     InsertConfigString(pLunL1, "Driver", "NvramStore");
    1837                     break;
    1838                 case TpmType_Host:
    1839 #if defined(RT_OS_LINUX) || defined(RT_OS_WINDOWS)
    1840                     InsertConfigString(pLunL0, "Driver",               "TpmHost");
    1841                     InsertConfigNode(pLunL0,   "Config", &pCfg);
    1842 #endif
    1843                     break;
    1844                 case TpmType_Swtpm:
    1845                     hrc = ptrTpm->COMGETTER(Location)(bstr.asOutParam());                   H();
    1846                     InsertConfigString(pLunL0, "Driver",               "TpmEmu");
    1847                     InsertConfigNode(pLunL0,   "Config", &pCfg);
    1848                     InsertConfigString(pCfg,   "Location", bstr);
    1849                     break;
    1850                 default:
    1851                     AssertFailedBreak();
    1852             }
    1853         }
    1854 #endif
    18551867
    18561868        /*
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