Index: /trunk/src/VBox/Devices/EFI/Firmware/OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.c
===================================================================
--- /trunk/src/VBox/Devices/EFI/Firmware/OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.c	(revision 58171)
+++ /trunk/src/VBox/Devices/EFI/Firmware/OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.c	(revision 58172)
@@ -25,5 +25,9 @@
 // PIIX4 Power Management Base Address
 //
+#ifndef VBOX
 UINT32 mPmba = 0x400;
+#else
+UINT32 mPmba = 0x4000;
+#endif
 
 #define PCI_BAR_IO             0x1
@@ -41,4 +45,5 @@
 
 **/
+#ifndef VBOX
 RETURN_STATUS
 EFIAPI
@@ -68,4 +73,40 @@
   return RETURN_SUCCESS;
 }
+#else
+RETURN_STATUS
+EFIAPI
+AcpiTimerLibConstructor (
+  VOID
+  )
+{
+  UINT8     u8Device = 7;
+  UINT16    u16VendorID = 0;
+  UINT16    u16DeviceID = 0;
+  u16VendorID = PciRead16(PCI_LIB_ADDRESS(0, u8Device, 0, 0));
+  u16DeviceID = PciRead16(PCI_LIB_ADDRESS(0, u8Device, 0, 2));
+  if (   u16VendorID != 0x8086
+      || u16DeviceID != 0x7113)
+    return RETURN_ABORTED;
+
+  if (PciRead8 (PCI_LIB_ADDRESS (0,u8Device,0,0x80)) & 1) {
+    mPmba = PciRead32 (PCI_LIB_ADDRESS (0, u8Device, 0, 0x40));
+    ASSERT (mPmba & PCI_BAR_IO);
+    DEBUG((DEBUG_INFO, "%a:%d mPmba:%x\n", __FUNCTION__, __LINE__, mPmba));
+    mPmba &= ~PCI_BAR_IO;
+    DEBUG((DEBUG_INFO, "%a:%d mPmba:%x\n", __FUNCTION__, __LINE__, mPmba));
+  } else {
+    PciAndThenOr32 (PCI_LIB_ADDRESS (0,u8Device,0,0x40),
+                    (UINT32) ~0xfc0, mPmba);
+    PciOr8         (PCI_LIB_ADDRESS (0,u8Device,0,0x04), 0x01);
+    DEBUG((DEBUG_INFO, "%a:%d mPmba:%x\n", __FUNCTION__, __LINE__, mPmba));
+  }
+
+  //
+  // ACPI Timer enable is in Bus 0, Device ?, Function 3
+  //
+  PciOr8         (PCI_LIB_ADDRESS (0,u8Device,0,0x80), 0x01);
+  return RETURN_SUCCESS;
+}
+#endif
 
 /**
Index: /trunk/src/VBox/Devices/EFI/Firmware/OvmfPkg/OvmfPkgIa32.dsc
===================================================================
--- /trunk/src/VBox/Devices/EFI/Firmware/OvmfPkg/OvmfPkgIa32.dsc	(revision 58171)
+++ /trunk/src/VBox/Devices/EFI/Firmware/OvmfPkg/OvmfPkgIa32.dsc	(revision 58172)
@@ -67,9 +67,5 @@
 [LibraryClasses]
   PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
-!ifndef $(VBOX)
   TimerLib|OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.inf
-!else
-  TimerLib|VBoxPkg/Library/AcpiTimerLib/AcpiTimerLib.inf
-!endif
   PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
   BaseMemoryLib|MdePkg/Library/BaseMemoryLibRepStr/BaseMemoryLibRepStr.inf
@@ -389,27 +385,15 @@
   MdeModulePkg/Universal/Metronome/Metronome.inf {
     <LibraryClasses>
-!ifndef $(VBOX)
       TimerLib|OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.inf
-!else
-      TimerLib|VBoxPkg/Library/AcpiTimerLib/AcpiTimerLib.inf
-!endif
   }
 
   PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf {
     <LibraryClasses>
-!ifndef $(VBOX)
       TimerLib|OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.inf
-!else
-      TimerLib|VBoxPkg/Library/AcpiTimerLib/AcpiTimerLib.inf
-!endif
   }
 
   IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf {
     <LibraryClasses>
-!ifndef $(VBOX)
       TimerLib|OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.inf
-!else
-      TimerLib|VBoxPkg/Library/AcpiTimerLib/AcpiTimerLib.inf
-!endif
 !ifdef $(CSM_ENABLE)
       NULL|OvmfPkg/Csm/CsmSupportLib/CsmSupportLib.inf
Index: /trunk/src/VBox/Devices/EFI/Firmware/OvmfPkg/OvmfPkgX64.dsc
===================================================================
--- /trunk/src/VBox/Devices/EFI/Firmware/OvmfPkg/OvmfPkgX64.dsc	(revision 58171)
+++ /trunk/src/VBox/Devices/EFI/Firmware/OvmfPkg/OvmfPkgX64.dsc	(revision 58172)
@@ -66,9 +66,5 @@
 [LibraryClasses]
   PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
-!ifndef $(VBOX)
   TimerLib|OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.inf
-!else
-  TimerLib|VBoxPkg/Library/AcpiTimerLib/AcpiTimerLib.inf
-!endif
   PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
   BaseMemoryLib|MdePkg/Library/BaseMemoryLibRepStr/BaseMemoryLibRepStr.inf
@@ -389,27 +385,15 @@
   MdeModulePkg/Universal/Metronome/Metronome.inf {
     <LibraryClasses>
-!ifndef $(VBOX)
       TimerLib|OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.inf
-!else
-      TimerLib|VBoxPkg/Library/AcpiTimerLib/AcpiTimerLib.inf
-!endif
   }
 
   PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf {
     <LibraryClasses>
-!ifndef $(VBOX)
       TimerLib|OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.inf
-!else
-      TimerLib|VBoxPkg/Library/AcpiTimerLib/AcpiTimerLib.inf
-!endif
   }
 
   IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf {
     <LibraryClasses>
-!ifndef $(VBOX)
       TimerLib|OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.inf
-!else
-      TimerLib|VBoxPkg/Library/AcpiTimerLib/AcpiTimerLib.inf
-!endif
 !ifdef $(CSM_ENABLE)
       NULL|OvmfPkg/Csm/CsmSupportLib/CsmSupportLib.inf
