Index: trunk/src/VBox/Main/src-client/ConsoleImplConfigArmV8.cpp
===================================================================
--- trunk/src/VBox/Main/src-client/ConsoleImplConfigArmV8.cpp	(revision 106957)
+++ trunk/src/VBox/Main/src-client/ConsoleImplConfigArmV8.cpp	(revision 106960)
@@ -453,5 +453,4 @@
         PCFGMNODE pCfg = NULL;          /* /Devices/Dev/.../Config/ */
         PCFGMNODE pLunL0 = NULL;        /* /Devices/Dev/0/LUN#0/ */
-        PCFGMNODE pLunL1 = NULL;        /* /Devices/Dev/0/LUN#0/AttachedDriver/ */
 
         InsertConfigNode(pRoot, "Devices", &pDevices);
@@ -756,45 +755,12 @@
         TpmType_T enmTpmType = TpmType_None;
 
-        hrc = pMachine->COMGETTER(TrustedPlatformModule)(ptrTpm.asOutParam());              H();
-        hrc = ptrTpm->COMGETTER(Type)(&enmTpmType);                                         H();
+        hrc = pMachine->COMGETTER(TrustedPlatformModule)(ptrTpm.asOutParam());                  H();
+        hrc = ptrTpm->COMGETTER(Type)(&enmTpmType);                                             H();
         if (enmTpmType != TpmType_None)
         {
-            hrc = pResMgr->assignSingleInterrupt("tpm", &iIrq);                               H();
-
-            InsertConfigNode(pDevices, "tpm", &pDev);
-            InsertConfigNode(pDev,     "0", &pInst);
-            InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
-            InsertConfigNode(pInst,    "Config", &pCfg);
-            InsertConfigInteger(pCfg,  "MmioBase", GCPhysTpm);
-            InsertConfigInteger(pCfg,  "Irq",      iIrq);
-            InsertConfigInteger(pCfg,  "Crb",      1); /* boolean */
-
-            InsertConfigNode(pInst,    "LUN#0", &pLunL0);
-
-            switch (enmTpmType)
-            {
-                case TpmType_v1_2:
-                case TpmType_v2_0:
-                    InsertConfigString(pLunL0, "Driver",               "TpmEmuTpms");
-                    InsertConfigNode(pLunL0,   "Config", &pCfg);
-                    InsertConfigInteger(pCfg, "TpmVersion", enmTpmType == TpmType_v1_2 ? 1 : 2);
-                    InsertConfigNode(pLunL0, "AttachedDriver", &pLunL1);
-                    InsertConfigString(pLunL1, "Driver", "NvramStore");
-                    break;
-                case TpmType_Host:
-#if defined(RT_OS_LINUX) || defined(RT_OS_WINDOWS)
-                    InsertConfigString(pLunL0, "Driver",               "TpmHost");
-                    InsertConfigNode(pLunL0,   "Config", &pCfg);
-#endif
-                    break;
-                case TpmType_Swtpm:
-                    hrc = ptrTpm->COMGETTER(Location)(bstr.asOutParam());                   H();
-                    InsertConfigString(pLunL0, "Driver",               "TpmEmu");
-                    InsertConfigNode(pLunL0,   "Config", &pCfg);
-                    InsertConfigString(pCfg,   "Location", bstr);
-                    break;
-                default:
-                    AssertFailedBreak();
-            }
+            hrc = pResMgr->assignSingleInterrupt("tpm", &iIrq);                                 H();
+
+            vrc = i_configTpm(ptrTpm, enmTpmType, pDevices, GCPhysTpm, iIrq /*uIrq*/,
+                              GCPhysTpm + 0x5000, true /*fCrb*/);                               VRC();
 
             vrc = RTFdtNodeAddF(hFdt, "tpm@%RGp", GCPhysTpm);                                   VRC();
@@ -809,11 +775,4 @@
                 VRC();
             }
-
-            /* Add the device for the physical presence interface. */
-            InsertConfigNode(   pDevices, "tpm-ppi",  &pDev);
-            InsertConfigNode(   pDev,     "0",        &pInst);
-            InsertConfigInteger(pInst,    "Trusted",  1); /* boolean */
-            InsertConfigNode(   pInst,    "Config",   &pCfg);
-            InsertConfigInteger(pCfg,     "MmioBase", GCPhysTpm + 0x5000);
         }
 #endif
Index: trunk/src/VBox/Main/src-client/ConsoleImplConfigCommon.cpp
===================================================================
--- trunk/src/VBox/Main/src-client/ConsoleImplConfigCommon.cpp	(revision 106957)
+++ trunk/src/VBox/Main/src-client/ConsoleImplConfigCommon.cpp	(revision 106960)
@@ -5178,4 +5178,78 @@
 }
 
+
+#if defined(VBOX_WITH_TPM)
+int Console::i_configTpm(ComPtr<ITrustedPlatformModule> pTpm, TpmType_T enmTpmType, PCFGMNODE pDevices,
+                         RTGCPHYS GCPhysTpmMmio, uint32_t uIrq, RTGCPHYS GCPhysTpmPpi, bool fCrb)
+{
+    Assert(enmTpmType != TpmType_None);
+
+    // InsertConfig* throws
+    try
+    {
+        HRESULT hrc;
+        Bstr    bstr;
+        PCFGMNODE pDev = NULL;          /* /Devices/Dev/ */
+        PCFGMNODE pInst = NULL;         /* /Devices/Dev/0/ */
+        PCFGMNODE pCfg = NULL;          /* /Devices/Dev/.../Config/ */
+        PCFGMNODE pLunL0 = NULL;        /* /Devices/Dev/0/LUN#0/ */
+        PCFGMNODE pLunL1 = NULL;        /* /Devices/Dev/0/LUN#0/AttachedDriver */
+
+        InsertConfigNode(pDevices, "tpm", &pDev);
+        InsertConfigNode(pDev,     "0", &pInst);
+        InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
+        InsertConfigNode(pInst,    "Config", &pCfg);
+        InsertConfigInteger(pCfg,  "MmioBase", GCPhysTpmMmio);
+        InsertConfigInteger(pCfg,  "Irq",      uIrq);
+        InsertConfigInteger(pCfg,  "Crb",      fCrb ? 1 : 0); /* boolean */
+
+        InsertConfigNode(pInst,    "LUN#0", &pLunL0);
+
+        switch (enmTpmType)
+        {
+            case TpmType_v1_2:
+            case TpmType_v2_0:
+                InsertConfigString(pLunL0, "Driver",               "TpmEmuTpms");
+                InsertConfigNode(pLunL0,   "Config", &pCfg);
+                InsertConfigInteger(pCfg, "TpmVersion", enmTpmType == TpmType_v1_2 ? 1 : 2);
+                InsertConfigNode(pLunL0, "AttachedDriver", &pLunL1);
+                InsertConfigString(pLunL1, "Driver", "NvramStore");
+                break;
+            case TpmType_Host:
+#if defined(RT_OS_LINUX) || defined(RT_OS_WINDOWS)
+                InsertConfigString(pLunL0, "Driver",               "TpmHost");
+                InsertConfigNode(pLunL0,   "Config", &pCfg);
+#endif
+                break;
+            case TpmType_Swtpm:
+                hrc = pTpm->COMGETTER(Location)(bstr.asOutParam());                   H();
+                InsertConfigString(pLunL0, "Driver",               "TpmEmu");
+                InsertConfigNode(pLunL0,   "Config", &pCfg);
+                InsertConfigString(pCfg,   "Location", bstr);
+                break;
+            default:
+                AssertFailedBreak();
+        }
+
+        if (GCPhysTpmPpi != RTGCPHYS_MAX)
+        {
+            /* Add the device for the physical presence interface. */
+            InsertConfigNode(   pDevices, "tpm-ppi",  &pDev);
+            InsertConfigNode(   pDev,     "0",        &pInst);
+            InsertConfigInteger(pInst,    "Trusted",  1); /* boolean */
+            InsertConfigNode(   pInst,    "Config",   &pCfg);
+            InsertConfigInteger(pCfg,     "MmioBase", GCPhysTpmPpi);
+        }
+    }
+    catch (ConfigError &x)
+    {
+        // InsertConfig threw something:
+        return x.m_vrc;
+    }
+
+    return VINF_SUCCESS;
+}
+#endif /* VBOX_WITH_TPM */
+
 #undef H
 #undef VRC
Index: trunk/src/VBox/Main/src-client/ConsoleImplConfigX86.cpp
===================================================================
--- trunk/src/VBox/Main/src-client/ConsoleImplConfigX86.cpp	(revision 106957)
+++ trunk/src/VBox/Main/src-client/ConsoleImplConfigX86.cpp	(revision 106960)
@@ -92,4 +92,6 @@
 #endif
 
+/** The TPM MMIO base default. */
+#define TPM_MMIO_BASE_DEFAULT UINT64_C(0xfed40000)
 /** The TPM PPI MMIO base default (compatible with qemu). */
 #define TPM_PPI_MMIO_BASE_DEFAULT UINT64_C(0xfed45000)
@@ -1462,42 +1464,6 @@
         if (enmTpmType != TpmType_None)
         {
-            InsertConfigNode(pDevices, "tpm", &pDev);
-            InsertConfigNode(pDev,     "0", &pInst);
-            InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
-            InsertConfigNode(pInst,    "Config", &pCfg);
-            InsertConfigNode(pInst,    "LUN#0", &pLunL0);
-
-            switch (enmTpmType)
-            {
-                case TpmType_v1_2:
-                case TpmType_v2_0:
-                    InsertConfigString(pLunL0, "Driver",               "TpmEmuTpms");
-                    InsertConfigNode(pLunL0,   "Config", &pCfg);
-                    InsertConfigInteger(pCfg, "TpmVersion", enmTpmType == TpmType_v1_2 ? 1 : 2);
-                    InsertConfigNode(pLunL0, "AttachedDriver", &pLunL1);
-                    InsertConfigString(pLunL1, "Driver", "NvramStore");
-                    break;
-                case TpmType_Host:
-#if defined(RT_OS_LINUX) || defined(RT_OS_WINDOWS)
-                    InsertConfigString(pLunL0, "Driver",               "TpmHost");
-                    InsertConfigNode(pLunL0,   "Config", &pCfg);
-#endif
-                    break;
-                case TpmType_Swtpm:
-                    hrc = ptrTpm->COMGETTER(Location)(bstr.asOutParam());                   H();
-                    InsertConfigString(pLunL0, "Driver",               "TpmEmu");
-                    InsertConfigNode(pLunL0,   "Config", &pCfg);
-                    InsertConfigString(pCfg,   "Location", bstr);
-                    break;
-                default:
-                    AssertFailedBreak();
-            }
-
-            /* Add the device for the physical presence interface. */
-            InsertConfigNode(   pDevices, "tpm-ppi",  &pDev);
-            InsertConfigNode(   pDev,     "0",        &pInst);
-            InsertConfigInteger(pInst,    "Trusted",  1); /* boolean */
-            InsertConfigNode(   pInst,    "Config",   &pCfg);
-            InsertConfigInteger(pCfg,     "MmioBase", TPM_PPI_MMIO_BASE_DEFAULT);
+            vrc = i_configTpm(ptrTpm, enmTpmType, pDevices, TPM_MMIO_BASE_DEFAULT, 10 /*uIrq*/,
+                              TPM_PPI_MMIO_BASE_DEFAULT, false /*fCrb*/);                   VRC();
         }
 #endif
