Index: trunk/src/VBox/Devices/PC/DevACPI.cpp
===================================================================
--- trunk/src/VBox/Devices/PC/DevACPI.cpp	(revision 82019)
+++ trunk/src/VBox/Devices/PC/DevACPI.cpp	(revision 82020)
@@ -281,5 +281,5 @@
 *********************************************************************************************************************************/
 /**
- * The ACPI device state.
+ * The shared ACPI device state.
  */
 typedef struct ACPISTATE
@@ -308,4 +308,5 @@
 
     uint32_t            uSystemInfoIndex;
+    uint32_t            u32Alignment0;
     uint64_t            u64RamSize;
     /** Offset of the 64-bit prefetchable memory window. */
@@ -345,8 +346,8 @@
     /** I/O port address of SMBus device. */
     RTIOPORT            uSMBusIoPortBase;
+    /** Which CPU to check for the locked status. */
+    uint32_t            idCpuLockCheck;
     /** Array of flags of attached CPUs */
     VMCPUSET            CpuSetAttached;
-    /** Which CPU to check for the locked status. */
-    uint32_t            idCpuLockCheck;
     /** Mask of locked CPUs (used by the guest). */
     VMCPUSET            CpuSetLocked;
@@ -361,4 +362,5 @@
     /** if the 64-bit prefetchable memory window is shown to the guest */
     bool                fPciPref64Enabled;
+    bool                afAlignment1;
     /** Primary NIC PCI address. */
     uint32_t            u32NicPciAddress;
@@ -401,28 +403,13 @@
     /** @name Parallel port config bits
      * @{ */
+    /** Parallel 0 IO port base */
+    RTIOPORT            uParallel0IoPortBase;
+    /** Parallel 1 IO port base */
+    RTIOPORT            uParallel1IoPortBase;
     /** Parallel 0 IRQ number */
     uint8_t             uParallel0Irq;
     /** Parallel 1 IRQ number */
     uint8_t             uParallel1Irq;
-    /** Parallel 0 IO port base */
-    RTIOPORT            uParallel0IoPortBase;
-    /** Parallel 1 IO port base */
-    RTIOPORT            uParallel1IoPortBase;
     /** @} */
-
-    uint32_t            Alignment2;
-
-    /** ACPI port base interface. */
-    PDMIBASE            IBase;
-    /** ACPI port interface. */
-    PDMIACPIPORT        IACPIPort;
-    /** Pointer to the device instance so we can get our bearings from
-     *  interface functions. */
-    PPDMDEVINSR3        pDevIns;
-
-    /** Pointer to the driver base interface. */
-    R3PTRTYPE(PPDMIBASE) pDrvBase;
-    /** Pointer to the driver connector interface. */
-    R3PTRTYPE(PPDMIACPICONNECTOR) pDrv;
 
     /** Number of custom ACPI tables */
@@ -432,4 +419,5 @@
     /** ACPI Crator ID */
     uint8_t             au8CreatorId[4];
+    uint8_t             abAlignment2[3];
     /** ACPI Crator Rev */
     uint32_t            u32CreatorRev;
@@ -438,10 +426,4 @@
     /** ACPI custom OEM Rev */
     uint32_t            u32OemRevision;
-    uint32_t            Alignment4;
-
-    /** Custom ACPI tables binary data. */
-    R3PTRTYPE(uint8_t *) apu8CustBin[MAX_CUST_TABLES];
-    /** The size of the custom table binary. */
-    uint64_t            acbCustBin[MAX_CUST_TABLES];
 
     /** SMBus Host Status Register */
@@ -461,14 +443,15 @@
     /** SMBus Slave Control Register */
     uint8_t             u8SMBusSlvCnt;
-    /** SMBus Shadow Command Register */
-    uint8_t             u8SMBusShdwCmd;
     /** SMBus Slave Event Register */
     uint16_t            u16SMBusSlvEvt;
     /** SMBus Slave Data Register */
     uint16_t            u16SMBusSlvDat;
+    /** SMBus Shadow Command Register */
+    uint8_t             u8SMBusShdwCmd;
+    /** SMBus Host Block Index */
+    uint8_t             u8SMBusBlkIdx;
+    uint8_t             abAlignment3[2];
     /** SMBus Host Block Data Buffer */
     uint8_t             au8SMBusBlkDat[32];
-    /** SMBus Host Block Index */
-    uint8_t             u8SMBusBlkIdx;
 
     /** @todo DEBUGGING */
@@ -514,4 +497,32 @@
 /** Pointer to the shared ACPI device state. */
 typedef ACPISTATE *PACPISTATE;
+
+
+/**
+ * The ring-3 ACPI device state.
+ */
+typedef struct ACPISTATER3
+{
+    /** ACPI port base interface. */
+    PDMIBASE            IBase;
+    /** ACPI port interface. */
+    PDMIACPIPORT        IACPIPort;
+    /** Pointer to the device instance so we can get our bearings from
+     *  interface functions. */
+    PPDMDEVINSR3        pDevIns;
+
+    /** Pointer to the driver base interface. */
+    R3PTRTYPE(PPDMIBASE) pDrvBase;
+    /** Pointer to the driver connector interface. */
+    R3PTRTYPE(PPDMIACPICONNECTOR) pDrv;
+
+    /** Custom ACPI tables binary data. */
+    R3PTRTYPE(uint8_t *) apu8CustBin[MAX_CUST_TABLES];
+    /** The size of the custom table binary. */
+    uint64_t            acbCustBin[MAX_CUST_TABLES];
+} ACPISTATER3;
+/** Pointer to the ring-3 ACPI device state. */
+typedef ACPISTATER3 *PACPISTATER3;
+
 
 #pragma pack(1)
@@ -801,5 +812,5 @@
 *********************************************************************************************************************************/
 #ifdef IN_RING3
-static int acpiR3PlantTables(PPDMDEVINS pDevIns, PACPISTATE pThis);
+static int acpiR3PlantTables(PPDMDEVINS pDevIns, PACPISTATE pThis, PACPISTATER3 pThisCC);
 #endif
 
@@ -944,6 +955,7 @@
 static DECLCALLBACK(int) acpiR3Port_PowerButtonPress(PPDMIACPIPORT pInterface)
 {
-    PACPISTATE pThis = RT_FROM_MEMBER(pInterface, ACPISTATE, IACPIPort);
-    PPDMDEVINS pDevIns = pThis->pDevIns;
+    PACPISTATER3 pThisCC = RT_FROM_MEMBER(pInterface, ACPISTATER3, IACPIPort);
+    PPDMDEVINS   pDevIns = pThisCC->pDevIns;
+    PACPISTATE   pThis   = PDMDEVINS_2_DATA(pDevIns, PACPISTATE);
     DEVACPI_LOCK_R3(pDevIns, pThis);
 
@@ -961,6 +973,7 @@
 static DECLCALLBACK(int) acpiR3Port_GetPowerButtonHandled(PPDMIACPIPORT pInterface, bool *pfHandled)
 {
-    PACPISTATE pThis = RT_FROM_MEMBER(pInterface, ACPISTATE, IACPIPort);
-    PPDMDEVINS pDevIns = pThis->pDevIns;
+    PACPISTATER3 pThisCC = RT_FROM_MEMBER(pInterface, ACPISTATER3, IACPIPort);
+    PPDMDEVINS   pDevIns = pThisCC->pDevIns;
+    PACPISTATE   pThis   = PDMDEVINS_2_DATA(pDevIns, PACPISTATE);
     DEVACPI_LOCK_R3(pDevIns, pThis);
 
@@ -977,6 +990,7 @@
 static DECLCALLBACK(int) acpiR3Port_GetGuestEnteredACPIMode(PPDMIACPIPORT pInterface, bool *pfEntered)
 {
-    PACPISTATE pThis = RT_FROM_MEMBER(pInterface, ACPISTATE, IACPIPort);
-    PPDMDEVINS pDevIns = pThis->pDevIns;
+    PACPISTATER3 pThisCC = RT_FROM_MEMBER(pInterface, ACPISTATER3, IACPIPort);
+    PPDMDEVINS   pDevIns = pThisCC->pDevIns;
+    PACPISTATE   pThis   = PDMDEVINS_2_DATA(pDevIns, PACPISTATE);
     DEVACPI_LOCK_R3(pDevIns, pThis);
 
@@ -992,6 +1006,7 @@
 static DECLCALLBACK(int) acpiR3Port_GetCpuStatus(PPDMIACPIPORT pInterface, unsigned uCpu, bool *pfLocked)
 {
-    PACPISTATE pThis = RT_FROM_MEMBER(pInterface, ACPISTATE, IACPIPort);
-    PPDMDEVINS pDevIns = pThis->pDevIns;
+    PACPISTATER3 pThisCC = RT_FROM_MEMBER(pInterface, ACPISTATER3, IACPIPort);
+    PPDMDEVINS   pDevIns = pThisCC->pDevIns;
+    PACPISTATE   pThis   = PDMDEVINS_2_DATA(pDevIns, PACPISTATE);
     DEVACPI_LOCK_R3(pDevIns, pThis);
 
@@ -1010,6 +1025,7 @@
 static DECLCALLBACK(int) acpiR3Port_SleepButtonPress(PPDMIACPIPORT pInterface)
 {
-    PACPISTATE pThis = RT_FROM_MEMBER(pInterface, ACPISTATE, IACPIPort);
-    PPDMDEVINS pDevIns = pThis->pDevIns;
+    PACPISTATER3 pThisCC = RT_FROM_MEMBER(pInterface, ACPISTATER3, IACPIPort);
+    PPDMDEVINS   pDevIns = pThisCC->pDevIns;
+    PACPISTATE   pThis   = PDMDEVINS_2_DATA(pDevIns, PACPISTATE);
     DEVACPI_LOCK_R3(pDevIns, pThis);
 
@@ -1029,6 +1045,7 @@
 static DECLCALLBACK(int) acpiR3Port_MonitorHotPlugEvent(PPDMIACPIPORT pInterface)
 {
-    PACPISTATE pThis = RT_FROM_MEMBER(pInterface, ACPISTATE, IACPIPort);
-    PPDMDEVINS pDevIns = pThis->pDevIns;
+    PACPISTATER3 pThisCC = RT_FROM_MEMBER(pInterface, ACPISTATER3, IACPIPort);
+    PPDMDEVINS   pDevIns = pThisCC->pDevIns;
+    PACPISTATE   pThis   = PDMDEVINS_2_DATA(pDevIns, PACPISTATE);
     DEVACPI_LOCK_R3(pDevIns, pThis);
 
@@ -1048,6 +1065,7 @@
 static DECLCALLBACK(int) acpiR3Port_BatteryStatusChangeEvent(PPDMIACPIPORT pInterface)
 {
-    PACPISTATE pThis = RT_FROM_MEMBER(pInterface, ACPISTATE, IACPIPort);
-    PPDMDEVINS pDevIns = pThis->pDevIns;
+    PACPISTATER3 pThisCC = RT_FROM_MEMBER(pInterface, ACPISTATER3, IACPIPort);
+    PPDMDEVINS   pDevIns = pThisCC->pDevIns;
+    PACPISTATE   pThis   = PDMDEVINS_2_DATA(pDevIns, PACPISTATE);
     DEVACPI_LOCK_R3(pDevIns, pThis);
 
@@ -1131,6 +1149,7 @@
  * @returns VINF_SUCCESS.
  * @param   pThis           The ACPI shared instance data.
- */
-static int acpiR3FetchBatteryStatus(PACPISTATE pThis)
+ * @param   pThisCC         The ACPI instance data for ring-3.
+ */
+static int acpiR3FetchBatteryStatus(PACPISTATE pThis, PACPISTATER3 pThisCC)
 {
     uint32_t           *p = pThis->au8BatteryInfo;
@@ -1141,8 +1160,8 @@
     int                rc;
 
-    if (!pThis->pDrv)
+    if (!pThisCC->pDrv)
         return VINF_SUCCESS;
-    rc = pThis->pDrv->pfnQueryBatteryStatus(pThis->pDrv, &fPresent, &hostRemainingCapacity,
-                                            &hostBatteryState, &hostPresentRate);
+    rc = pThisCC->pDrv->pfnQueryBatteryStatus(pThisCC->pDrv, &fPresent, &hostRemainingCapacity,
+                                              &hostBatteryState, &hostPresentRate);
     AssertRC(rc);
 
@@ -1191,7 +1210,7 @@
  *
  * @returns status mask or 0.
- * @param   pThis           The ACPI shared instance data.
- */
-static uint32_t acpiR3GetBatteryDeviceStatus(PACPISTATE pThis)
+ * @param   pThisCC         The ACPI instance data for ring-3.
+ */
+static uint32_t acpiR3GetBatteryDeviceStatus(PACPISTATER3 pThisCC)
 {
     bool               fPresent;              /* battery present? */
@@ -1201,17 +1220,17 @@
     int                rc;
 
-    if (!pThis->pDrv)
+    if (!pThisCC->pDrv)
         return 0;
-    rc = pThis->pDrv->pfnQueryBatteryStatus(pThis->pDrv, &fPresent, &hostRemainingCapacity,
-                                            &hostBatteryState, &hostPresentRate);
+    rc = pThisCC->pDrv->pfnQueryBatteryStatus(pThisCC->pDrv, &fPresent, &hostRemainingCapacity,
+                                              &hostBatteryState, &hostPresentRate);
     AssertRC(rc);
 
     return fPresent
-        ?   STA_DEVICE_PRESENT_MASK                     /* present */
-          | STA_DEVICE_ENABLED_MASK                     /* enabled and decodes its resources */
-          | STA_DEVICE_SHOW_IN_UI_MASK                  /* should be shown in UI */
-          | STA_DEVICE_FUNCTIONING_PROPERLY_MASK        /* functioning properly */
-          | STA_BATTERY_PRESENT_MASK                    /* battery is present */
-        : 0;                                            /* device not present */
+         ?   STA_DEVICE_PRESENT_MASK                     /* present */
+           | STA_DEVICE_ENABLED_MASK                     /* enabled and decodes its resources */
+           | STA_DEVICE_SHOW_IN_UI_MASK                  /* should be shown in UI */
+           | STA_DEVICE_FUNCTIONING_PROPERLY_MASK        /* functioning properly */
+           | STA_BATTERY_PRESENT_MASK                    /* battery is present */
+         : 0;                                            /* device not present */
 }
 
@@ -1220,14 +1239,14 @@
  *
  * @returns status.
- * @param   pThis           The ACPI shared instance data.
- */
-static uint32_t acpiR3GetPowerSource(PACPISTATE pThis)
+ * @param   pThisCC         The ACPI instance data for ring-3.
+ */
+static uint32_t acpiR3GetPowerSource(PACPISTATER3 pThisCC)
 {
     /* query the current power source from the host driver */
-    if (!pThis->pDrv)
+    if (!pThisCC->pDrv)
         return AC_ONLINE;
 
     PDMACPIPOWERSOURCE ps;
-    int rc = pThis->pDrv->pfnQueryPowerSource(pThis->pDrv, &ps);
+    int rc = pThisCC->pDrv->pfnQueryPowerSource(pThisCC->pDrv, &ps);
     AssertRC(rc);
     return ps == PDM_ACPI_POWER_SOURCE_BATTERY ? AC_OFFLINE : AC_ONLINE;
@@ -1270,5 +1289,6 @@
         return VERR_IOM_IOPORT_UNUSED;
 
-    PACPISTATE pThis = PDMDEVINS_2_DATA(pDevIns, PACPISTATE);
+    PACPISTATE   pThis   = PDMDEVINS_2_DATA(pDevIns, PACPISTATE);
+    PACPISTATER3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PACPISTATER3);
     DEVACPI_LOCK_R3(pDevIns, pThis);
 
@@ -1277,5 +1297,5 @@
     {
         case BAT_STATUS_STATE:
-            acpiR3FetchBatteryStatus(pThis);
+            acpiR3FetchBatteryStatus(pThis, pThisCC);
             RT_FALL_THRU();
         case BAT_STATUS_PRESENT_RATE:
@@ -1300,9 +1320,9 @@
 
         case BAT_DEVICE_STATUS:
-            *pu32 = acpiR3GetBatteryDeviceStatus(pThis);
+            *pu32 = acpiR3GetBatteryDeviceStatus(pThisCC);
             break;
 
         case BAT_POWER_SOURCE:
-            *pu32 = acpiR3GetPowerSource(pThis);
+            *pu32 = acpiR3GetPowerSource(pThisCC);
             break;
 
@@ -2107,7 +2127,8 @@
  * @param   pDevIns         The device instance.
  * @param   pThis           The ACPI shared instance data.
+ * @param   pThisCC         The ACPI instance data for ring-3.
  * @param   NewIoPortBase   The new base address of the I/O ports.
  */
-static int acpiR3UpdatePmHandlers(PPDMDEVINS pDevIns, PACPISTATE pThis, RTIOPORT NewIoPortBase)
+static int acpiR3UpdatePmHandlers(PPDMDEVINS pDevIns, PACPISTATE pThis, PACPISTATER3 pThisCC, RTIOPORT NewIoPortBase)
 {
     Log(("acpi: rebasing PM 0x%x -> 0x%x\n", pThis->uPmIoPortBase, NewIoPortBase));
@@ -2125,5 +2146,5 @@
 
         /* We have to update FADT table acccording to the new base */
-        rc = acpiR3PlantTables(pDevIns, pThis);
+        rc = acpiR3PlantTables(pDevIns, pThis, pThisCC);
         AssertRC(rc);
         if (RT_FAILURE(rc))
@@ -2532,6 +2553,7 @@
 static DECLCALLBACK(int) acpiR3LoadState(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)
 {
-    PACPISTATE      pThis = PDMDEVINS_2_DATA(pDevIns, PACPISTATE);
-    PCPDMDEVHLPR3   pHlp  = pDevIns->pHlpR3;
+    PACPISTATE      pThis   = PDMDEVINS_2_DATA(pDevIns, PACPISTATE);
+    PACPISTATER3    pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PACPISTATER3);
+    PCPDMDEVHLPR3   pHlp    = pDevIns->pHlpR3;
     Assert(uPass == SSM_PASS_FINAL); NOREF(uPass);
 
@@ -2580,5 +2602,5 @@
         rc = acpiR3MapSMBusIoPorts(pDevIns, pThis);
         AssertRCReturn(rc, rc);
-        rc = acpiR3FetchBatteryStatus(pThis);
+        rc = acpiR3FetchBatteryStatus(pThis, pThisCC);
         AssertRCReturn(rc, rc);
         rc = acpiR3FetchBatteryInfo(pThis);
@@ -2602,7 +2624,7 @@
 static DECLCALLBACK(void *) acpiR3QueryInterface(PPDMIBASE pInterface, const char *pszIID)
 {
-    PACPISTATE pThis = RT_FROM_MEMBER(pInterface, ACPISTATE, IBase);
-    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThis->IBase);
-    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIACPIPORT, &pThis->IACPIPort);
+    PACPISTATER3 pThisCC = RT_FROM_MEMBER(pInterface, ACPISTATER3, IBase);
+    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThisCC->IBase);
+    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIACPIPORT, &pThisCC->IACPIPort);
     return NULL;
 }
@@ -2816,11 +2838,10 @@
 {
     ACPITBLXSDT *xsdt;
-    const size_t size = sizeof(ACPITBLHEADER) + nb_entries * sizeof(xsdt->u64Entry[0]);
-
-    xsdt = (ACPITBLXSDT*)RTMemAllocZ(size);
+    const size_t cbXsdt = sizeof(ACPITBLHEADER) + nb_entries * sizeof(xsdt->u64Entry[0]);
+    xsdt = (ACPITBLXSDT *)RTMemAllocZ(cbXsdt);
     if (!xsdt)
         return VERR_NO_TMP_MEMORY;
 
-    acpiR3PrepareHeader(pThis, &xsdt->header, "XSDT", (uint32_t)size, 1 /* according to ACPI 3.0 specs */);
+    acpiR3PrepareHeader(pThis, &xsdt->header, "XSDT", (uint32_t)cbXsdt, 1 /* according to ACPI 3.0 specs */);
 
     if (pThis->cCustTbls > 0)
@@ -2832,6 +2853,7 @@
         Log(("Setup XSDT: [%d] = %RX64\n", i, xsdt->u64Entry[i]));
     }
-    xsdt->header.u8Checksum = acpiR3Checksum(xsdt, size);
-    acpiR3PhysCopy(pDevIns, addr, xsdt, size);
+    xsdt->header.u8Checksum = acpiR3Checksum(xsdt, cbXsdt);
+    acpiR3PhysCopy(pDevIns, addr, xsdt, cbXsdt);
+
     RTMemFree(xsdt);
     return VINF_SUCCESS;
@@ -3172,5 +3194,5 @@
  * Create the ACPI tables in guest memory.
  */
-static int acpiR3PlantTables(PPDMDEVINS pDevIns, PACPISTATE pThis)
+static int acpiR3PlantTables(PPDMDEVINS pDevIns, PACPISTATE pThis, PACPISTATER3 pThisCC)
 {
     int        rc;
@@ -3284,5 +3306,5 @@
     {
         aGCPhysCust[i] = GCPhysCur;
-        GCPhysCur = RT_ALIGN_32(GCPhysCur + pThis->acbCustBin[i], 16);
+        GCPhysCur = RT_ALIGN_32(GCPhysCur + pThisCC->acbCustBin[i], 16);
     }
 
@@ -3355,8 +3377,8 @@
     {
         Assert(i < MAX_CUST_TABLES);
-        acpiR3PhysCopy(pDevIns, aGCPhysCust[i] + addend, pThis->apu8CustBin[i], pThis->acbCustBin[i]);
+        acpiR3PhysCopy(pDevIns, aGCPhysCust[i] + addend, pThisCC->apu8CustBin[i], pThisCC->acbCustBin[i]);
         aGCPhysRsdt[iCust + i] = aGCPhysCust[i] + addend;
         aGCPhysXsdt[iCust + i] = aGCPhysCust[i] + addend;
-        uint8_t* pSig = pThis->apu8CustBin[i];
+        uint8_t* pSig = pThisCC->apu8CustBin[i];
         LogRel(("ACPI: Planted custom table '%c%c%c%c' at 0x%08X\n",
                pSig[0], pSig[1], pSig[2], pSig[3], aGCPhysCust[i] + addend));
@@ -3391,5 +3413,6 @@
                                                        uint32_t uAddress, unsigned cb, uint32_t u32Value)
 {
-    PACPISTATE pThis = PDMDEVINS_2_DATA(pDevIns, PACPISTATE);
+    PACPISTATE      pThis   = PDMDEVINS_2_DATA(pDevIns, PACPISTATE);
+    PACPISTATER3    pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PACPISTATER3);
 
     Log2(("acpi: PCI config write: 0x%x -> 0x%x (%d)\n", u32Value, uAddress, cb));
@@ -3418,5 +3441,5 @@
         }
 
-        int rc = acpiR3UpdatePmHandlers(pDevIns, pThis, NewIoPortBase);
+        int rc = acpiR3UpdatePmHandlers(pDevIns, pThis, pThisCC, NewIoPortBase);
         AssertRC(rc);
     }
@@ -3452,5 +3475,6 @@
 static DECLCALLBACK(int) acpiR3Attach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags)
 {
-    PACPISTATE pThis = PDMDEVINS_2_DATA(pDevIns, PACPISTATE);
+    PACPISTATE      pThis   = PDMDEVINS_2_DATA(pDevIns, PACPISTATE);
+    PACPISTATER3    pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PACPISTATER3);
     LogFlow(("acpiAttach: pDevIns=%p iLUN=%u fFlags=%#x\n", pDevIns, iLUN, fFlags));
 
@@ -3466,5 +3490,5 @@
     {
         PPDMIBASE IBaseTmp;
-        rc = PDMDevHlpDriverAttach(pDevIns, iLUN, &pThis->IBase, &IBaseTmp, "ACPI CPU");
+        rc = PDMDevHlpDriverAttach(pDevIns, iLUN, &pThisCC->IBase, &IBaseTmp, "ACPI CPU");
         if (RT_SUCCESS(rc))
         {
@@ -3543,7 +3567,8 @@
 static DECLCALLBACK(void) acpiR3MemSetup(PPDMDEVINS pDevIns, PDMDEVMEMSETUPCTX enmCtx)
 {
-    RT_NOREF1(enmCtx);
-    PACPISTATE pThis = PDMDEVINS_2_DATA(pDevIns, PACPISTATE);
-    acpiR3PlantTables(pDevIns, pThis);
+    RT_NOREF(enmCtx);
+    PACPISTATE      pThis = PDMDEVINS_2_DATA(pDevIns, PACPISTATE);
+    PACPISTATER3    pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PACPISTATER3);
+    acpiR3PlantTables(pDevIns, pThis, pThisCC);
 }
 
@@ -3553,5 +3578,6 @@
 static DECLCALLBACK(void) acpiR3Reset(PPDMDEVINS pDevIns)
 {
-    PACPISTATE pThis = PDMDEVINS_2_DATA(pDevIns, PACPISTATE);
+    PACPISTATE      pThis   = PDMDEVINS_2_DATA(pDevIns, PACPISTATE);
+    PACPISTATER3    pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PACPISTATER3);
 
     /* Play safe: make sure that the IRQ isn't stuck after a reset. */
@@ -3575,5 +3601,5 @@
     /* Real device behavior is resetting only the PM controller state,
      * but we're additionally doing the job of the BIOS. */
-    acpiR3UpdatePmHandlers(pDevIns, pThis, PM_PORT_BASE);
+    acpiR3UpdatePmHandlers(pDevIns, pThis, pThisCC, PM_PORT_BASE);
     acpiR3PmPCIBIOSFake(pDevIns, pThis);
 
@@ -3592,11 +3618,13 @@
 {
     PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);
-    PACPISTATE pThis = PDMDEVINS_2_DATA(pDevIns, PACPISTATE);
+    PACPISTATE      pThis = PDMDEVINS_2_DATA(pDevIns, PACPISTATE);
+    PACPISTATER3    pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PACPISTATER3);
+
     for (uint8_t i = 0; i < pThis->cCustTbls; i++)
     {
-        if (pThis->apu8CustBin[i])
+        if (pThisCC->apu8CustBin[i])
         {
-            PDMDevHlpMMHeapFree(pDevIns, pThis->apu8CustBin[i]);
-            pThis->apu8CustBin[i] = NULL;
+            PDMDevHlpMMHeapFree(pDevIns, pThisCC->apu8CustBin[i]);
+            pThisCC->apu8CustBin[i] = NULL;
         }
     }
@@ -3611,4 +3639,5 @@
     PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);
     PACPISTATE      pThis   = PDMDEVINS_2_DATA(pDevIns, PACPISTATE);
+    PACPISTATER3    pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PACPISTATER3);
     PCPDMDEVHLPR3   pHlp    = pDevIns->pHlpR3;
 
@@ -3618,5 +3647,5 @@
     /** @todo move more of the code up! */
 
-    pThis->pDevIns         = pDevIns;
+    pThisCC->pDevIns       = pDevIns;
     VMCPUSET_EMPTY(&pThis->CpuSetAttached);
     VMCPUSET_EMPTY(&pThis->CpuSetLocked);
@@ -3630,13 +3659,13 @@
 
     /* IBase */
-    pThis->IBase.pfnQueryInterface               = acpiR3QueryInterface;
+    pThisCC->IBase.pfnQueryInterface               = acpiR3QueryInterface;
     /* IACPIPort */
-    pThis->IACPIPort.pfnSleepButtonPress         = acpiR3Port_SleepButtonPress;
-    pThis->IACPIPort.pfnPowerButtonPress         = acpiR3Port_PowerButtonPress;
-    pThis->IACPIPort.pfnGetPowerButtonHandled    = acpiR3Port_GetPowerButtonHandled;
-    pThis->IACPIPort.pfnGetGuestEnteredACPIMode  = acpiR3Port_GetGuestEnteredACPIMode;
-    pThis->IACPIPort.pfnGetCpuStatus             = acpiR3Port_GetCpuStatus;
-    pThis->IACPIPort.pfnMonitorHotPlugEvent      = acpiR3Port_MonitorHotPlugEvent;
-    pThis->IACPIPort.pfnBatteryStatusChangeEvent = acpiR3Port_BatteryStatusChangeEvent;
+    pThisCC->IACPIPort.pfnSleepButtonPress         = acpiR3Port_SleepButtonPress;
+    pThisCC->IACPIPort.pfnPowerButtonPress         = acpiR3Port_PowerButtonPress;
+    pThisCC->IACPIPort.pfnGetPowerButtonHandled    = acpiR3Port_GetPowerButtonHandled;
+    pThisCC->IACPIPort.pfnGetGuestEnteredACPIMode  = acpiR3Port_GetGuestEnteredACPIMode;
+    pThisCC->IACPIPort.pfnGetCpuStatus             = acpiR3Port_GetCpuStatus;
+    pThisCC->IACPIPort.pfnMonitorHotPlugEvent      = acpiR3Port_MonitorHotPlugEvent;
+    pThisCC->IACPIPort.pfnBatteryStatusChangeEvent = acpiR3Port_BatteryStatusChangeEvent;
 
     /*
@@ -3851,5 +3880,5 @@
         {
             PPDMIBASE IBaseTmp;
-            rc = PDMDevHlpDriverAttach(pDevIns, i, &pThis->IBase, &IBaseTmp, "ACPI CPU");
+            rc = PDMDevHlpDriverAttach(pDevIns, i, &pThisCC->IBase, &IBaseTmp, "ACPI CPU");
 
             if (RT_SUCCESS(rc))
@@ -3908,5 +3937,5 @@
 
     static const char *s_apszCustTblConfigKeys[] = {"CustomTable0", "CustomTable1", "CustomTable2", "CustomTable3"};
-    AssertCompile(RT_ELEMENTS(s_apszCustTblConfigKeys) <= RT_ELEMENTS(pThis->apu8CustBin));
+    AssertCompile(RT_ELEMENTS(s_apszCustTblConfigKeys) <= RT_ELEMENTS(pThisCC->apu8CustBin));
     for (unsigned i = 0; i < RT_ELEMENTS(s_apszCustTblConfigKeys); ++i)
     {
@@ -3930,5 +3959,5 @@
         else if (!*pszCustBinFile)
         {
-            MMR3HeapFree(pszCustBinFile);
+            PDMDevHlpMMHeapFree(pDevIns, pszCustBinFile);
             pszCustBinFile = NULL;
         }
@@ -3940,16 +3969,16 @@
         {
             uint32_t idxCust = pThis->cCustTbls;
-            rc = acpiR3ReadCustomTable(pDevIns, &pThis->apu8CustBin[idxCust],
-                                       &pThis->acbCustBin[idxCust], pszCustBinFile, cbBufAvail);
+            rc = acpiR3ReadCustomTable(pDevIns, &pThisCC->apu8CustBin[idxCust],
+                                       &pThisCC->acbCustBin[idxCust], pszCustBinFile, cbBufAvail);
             LogRel(("ACPI: Reading custom ACPI table(%u) from file '%s' (%d bytes)\n",
-                    idxCust, pszCustBinFile, pThis->acbCustBin[idxCust]));
-            MMR3HeapFree(pszCustBinFile);
+                    idxCust, pszCustBinFile, pThisCC->acbCustBin[idxCust]));
+            PDMDevHlpMMHeapFree(pDevIns, pszCustBinFile);
             if (RT_FAILURE(rc))
                 return PDMDEV_SET_ERROR(pDevIns, rc, N_("Error reading custom ACPI table."));
-            cbBufAvail -= pThis->acbCustBin[idxCust];
+            cbBufAvail -= pThisCC->acbCustBin[idxCust];
 
             /* Update custom OEM attributes based on custom table */
             /** @todo is it intended for custom tables to overwrite user provided values above? */
-            ACPITBLHEADER *pTblHdr = (ACPITBLHEADER*)pThis->apu8CustBin[idxCust];
+            ACPITBLHEADER *pTblHdr = (ACPITBLHEADER*)pThisCC->apu8CustBin[idxCust];
             memcpy(&pThis->au8OemId[0], &pTblHdr->au8OemId[0], 6);
             memcpy(&pThis->au8OemTabId[0], &pTblHdr->au8OemTabId[0], 8);
@@ -3986,5 +4015,5 @@
         return PDMDEV_SET_ERROR(pDevIns, VERR_NO_MEMORY, N_("Can not find space for RSDP. ACPI is disabled"));
 
-    rc = acpiR3PlantTables(pDevIns, pThis);
+    rc = acpiR3PlantTables(pDevIns, pThis, pThisCC);
     AssertRCReturn(rc, rc);
 
@@ -4117,16 +4146,14 @@
     * Get the corresponding connector interface
     */
-   rc = PDMDevHlpDriverAttach(pDevIns, 0, &pThis->IBase, &pThis->pDrvBase, "ACPI Driver Port");
+   rc = PDMDevHlpDriverAttach(pDevIns, 0, &pThisCC->IBase, &pThisCC->pDrvBase, "ACPI Driver Port");
    if (RT_SUCCESS(rc))
    {
-       pThis->pDrv = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIACPICONNECTOR);
-       if (!pThis->pDrv)
-           return PDMDEV_SET_ERROR(pDevIns, VERR_PDM_MISSING_INTERFACE,
-                                   N_("LUN #0 doesn't have an ACPI connector interface"));
+       pThisCC->pDrv = PDMIBASE_QUERY_INTERFACE(pThisCC->pDrvBase, PDMIACPICONNECTOR);
+       if (!pThisCC->pDrv)
+           return PDMDEV_SET_ERROR(pDevIns, VERR_PDM_MISSING_INTERFACE, N_("LUN #0 doesn't have an ACPI connector interface"));
    }
    else if (rc == VERR_PDM_NO_ATTACHED_DRIVER)
    {
-       Log(("acpi: %s/%d: warning: no driver attached to LUN #0!\n",
-            pDevIns->pReg->szName, pDevIns->iInstance));
+       Log(("acpi: %s/%d: warning: no driver attached to LUN #0!\n", pDevIns->pReg->szName, pDevIns->iInstance));
        rc = VINF_SUCCESS;
    }
@@ -4174,5 +4201,5 @@
     /* .uSharedVersion = */         42,
     /* .cbInstanceShared = */       sizeof(ACPISTATE),
-    /* .cbInstanceCC = */           0,
+    /* .cbInstanceCC = */           CTX_EXPR(sizeof(ACPISTATER3), 0, 0),
     /* .cbInstanceRC = */           0,
     /* .cMaxPciDevices = */         1,
