VirtualBox

Changeset 106388 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Oct 16, 2024 2:16:39 PM (4 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
165201
Message:

Main: Enable the TPM if configured for an ARM VM, bugref:10777

File:
1 edited

Legend:

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

    r106384 r106388  
    398398        PCFGMNODE pCfg = NULL;          /* /Devices/Dev/.../Config/ */
    399399        PCFGMNODE pLunL0 = NULL;        /* /Devices/Dev/0/LUN#0/ */
     400        PCFGMNODE pLunL1 = NULL;        /* /Devices/Dev/0/LUN#0/AttachedDriver/ */
    400401
    401402        InsertConfigNode(pRoot, "Devices", &pDevices);
     
    748749            VRC();
    749750        }
     751
     752#if defined(VBOX_WITH_TPM)
     753        /*
     754         * Configure the Trusted Platform Module.
     755         */
     756        ComObjPtr<ITrustedPlatformModule> ptrTpm;
     757        TpmType_T enmTpmType = TpmType_None;
     758
     759        hrc = pMachine->COMGETTER(TrustedPlatformModule)(ptrTpm.asOutParam());              H();
     760        hrc = ptrTpm->COMGETTER(Type)(&enmTpmType);                                         H();
     761        if (enmTpmType != TpmType_None)
     762        {
     763            hrc = pResMgr->assignSingleInterrupt("tpm", &iIrq);                               H();
     764            hrc = pResMgr->assignMmioRegion("tpm", 5 * _1K, &GCPhysMmioStart, &cbMmio);       H();
     765
     766            InsertConfigNode(pDevices, "tpm", &pDev);
     767            InsertConfigNode(pDev,     "0", &pInst);
     768            InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
     769            InsertConfigNode(pInst,    "Config", &pCfg);
     770            InsertConfigInteger(pCfg,  "MmioBase", GCPhysMmioStart);
     771            InsertConfigInteger(pCfg,  "Irq",      iIrq);
     772            //InsertConfigInteger(pCfg,  "Crb",      1); /* boolean */
     773
     774            InsertConfigNode(pInst,    "LUN#0", &pLunL0);
     775
     776            switch (enmTpmType)
     777            {
     778                case TpmType_v1_2:
     779                case TpmType_v2_0:
     780                    InsertConfigString(pLunL0, "Driver",               "TpmEmuTpms");
     781                    InsertConfigNode(pLunL0,   "Config", &pCfg);
     782                    InsertConfigInteger(pCfg, "TpmVersion", enmTpmType == TpmType_v1_2 ? 1 : 2);
     783                    InsertConfigNode(pLunL0, "AttachedDriver", &pLunL1);
     784                    InsertConfigString(pLunL1, "Driver", "NvramStore");
     785                    break;
     786                case TpmType_Host:
     787#if defined(RT_OS_LINUX) || defined(RT_OS_WINDOWS)
     788                    InsertConfigString(pLunL0, "Driver",               "TpmHost");
     789                    InsertConfigNode(pLunL0,   "Config", &pCfg);
     790#endif
     791                    break;
     792                case TpmType_Swtpm:
     793                    hrc = ptrTpm->COMGETTER(Location)(bstr.asOutParam());                   H();
     794                    InsertConfigString(pLunL0, "Driver",               "TpmEmu");
     795                    InsertConfigNode(pLunL0,   "Config", &pCfg);
     796                    InsertConfigString(pCfg,   "Location", bstr);
     797                    break;
     798                default:
     799                    AssertFailedBreak();
     800            }
     801
     802            vrc = RTFdtNodeAddF(hFdt, "tpm@%RGp", GCPhysMmioStart);                           VRC();
     803            vrc = RTFdtNodePropertyAddCellsU32(hFdt, "interrupts", 3, 0x00, iIrq, 0x04);        VRC();
     804            vrc = RTFdtNodePropertyAddCellsU64(hFdt, "reg", 2, GCPhysMmioStart, cbMmio);        VRC();
     805            vrc = RTFdtNodePropertyAddStringList(hFdt, "compatible", 1, "tcg,tpm-tis-mmio");    VRC();
     806            vrc = RTFdtNodeFinalize(hFdt);                                                      VRC();
     807
     808            if (pSysTblsBldAcpi)
     809            {
     810                vrc = pSysTblsBldAcpi->configureTpm2(false /*fCrb*/, GCPhysMmioStart, cbMmio, iIrq);
     811                VRC();
     812            }
     813
     814#if 0
     815            /* Add the device for the physical presence interface. */
     816            InsertConfigNode(   pDevices, "tpm-ppi",  &pDev);
     817            InsertConfigNode(   pDev,     "0",        &pInst);
     818            InsertConfigInteger(pInst,    "Trusted",  1); /* boolean */
     819            InsertConfigNode(   pInst,    "Config",   &pCfg);
     820            InsertConfigInteger(pCfg,     "MmioBase", TPM_PPI_MMIO_BASE_DEFAULT);
     821#endif
     822        }
     823#endif
    750824
    751825        /*
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