diff --git a/repos/ports/lib/mk/virtualbox5-bios.mk b/repos/ports/lib/mk/virtualbox5-bios.mk
index 585304944b..ccc6897479 100644
--- a/repos/ports/lib/mk/virtualbox5-bios.mk
+++ b/repos/ports/lib/mk/virtualbox5-bios.mk
@@ -4,27 +4,29 @@ ifeq ($(shell which yasm),)
 REQUIRES += installation_of_yasm
 endif
 
-SRC_O += VBoxPcBiosBin.o VBoxVgaBiosBin.o VBoxBiosLogoBin.o
+SRC_O += VBoxPcBiosBinary8086.o  VBoxPcBiosBinary286.o  VBoxPcBiosBinary386.o
+SRC_O += VBoxVgaBiosBinary8086.o VBoxVgaBiosBinary286.o VBoxVgaBiosBinary386.o
+SRC_O += XVBoxBiosLogoBin.o
 
-VBox%Bin.o : VBox%Bin.rom
+VBox%.o : VBox%.rom
 	$(MSG_CONVERT)$@
-	$(VERBOSE)echo ".global g_ab$*Binary, g_cb$*Binary;" \
+	$(VERBOSE)echo ".global g_ab$*, g_cb$*;" \
 	               ".data;" \
-	               "g_cb$*Binary:; .long g_ab$*BinaryEnd - g_ab$*Binary;" \
+	               "g_cb$*:; .long g_ab$*End - g_ab$*;" \
 	               ".align 4096;" \
-	               "g_ab$*Binary:; .incbin \"$<\";" \
-	               "g_ab$*BinaryEnd:;" | \
+	               "g_ab$*:; .incbin \"$<\";" \
+	               "g_ab$*End:;" | \
 		$(AS) $(AS_OPT) -f -o $@ -
 
-VBoxPcBiosBin.rom: Devices/PC/BIOS/VBoxBiosAlternative.asm
+VBoxPcBiosBinary%.rom: Devices/PC/BIOS/VBoxBiosAlternative%.asm
 	$(MSG_ASSEM)
 	$(VERBOSE)yasm -f bin -o $@ $<
 
-VBoxVgaBiosBin.rom: Devices/Graphics/BIOS/VBoxVgaBiosAlternative.asm
+VBoxVgaBiosBinary%.rom: Devices/Graphics/BIOS/VBoxVgaBiosAlternative%.asm
 	$(MSG_ASSEM)
 	$(VERBOSE)yasm -f bin -o $@ $<
 
-VBoxBiosLogoBin.o: Devices/Graphics/BIOS/ose_logo.bmp
+XVBoxBiosLogoBin.o: Devices/Graphics/BIOS/ose_logo.bmp
 	$(MSG_CONVERT)$@
 	$(VERBOSE)echo ".global g_abVgaDefBiosLogo, g_cbVgaDefBiosLogo;" \
 	               ".data;" \
diff --git a/repos/ports/lib/mk/virtualbox5-common.inc b/repos/ports/lib/mk/virtualbox5-common.inc
index afa1758cfc..2a278cc46f 100644
--- a/repos/ports/lib/mk/virtualbox5-common.inc
+++ b/repos/ports/lib/mk/virtualbox5-common.inc
@@ -43,7 +43,9 @@ VBOX_CC_OPT += -DRTLOG_REL_ENABLED -DRT_STRICT -DVBOX_STRICT
 
 VBOX_CC_OPT += -DVBOX_WITH_USB -DVBOX_WITH_VUSB
 
-# Enable Intel Network model E1000
+VBOX_CC_OPT += -DVBOX_WITH_NEW_APIC
+VBOX_CC_OPT += -DVBOX_WITH_NEW_IOAPIC
+
 VBOX_CC_OPT += -DVBOX_WITH_E1000
 
 VBOX_CC_OPT += -DVBOX_WITH_AHCI
diff --git a/repos/ports/lib/mk/virtualbox5-devices.mk b/repos/ports/lib/mk/virtualbox5-devices.mk
index d74100a413..e7ed8e6821 100644
--- a/repos/ports/lib/mk/virtualbox5-devices.mk
+++ b/repos/ports/lib/mk/virtualbox5-devices.mk
@@ -8,6 +8,7 @@ SRC_CC += Devices/PC/ACPI/VBoxAcpi.cpp
 SRC_C  += Devices/PC/DevPcArch.c
 SRC_CC += Devices/Input/DevPS2.cpp
 SRC_CC += Devices/Input/PS2K.cpp
+SRC_CC += Devices/Input/PS2M.cpp
 SRC_CC += Devices/PC/DevPit-i8254.cpp
 SRC_CC += Devices/PC/DevPIC.cpp
 SRC_CC += Devices/PC/DevRTC.cpp
@@ -23,7 +24,8 @@ SRC_CC += Devices/Storage/ATAPIPassthrough.cpp
 SRC_CC += Devices/Storage/DevAHCI.cpp
 SRC_CC += Devices/Storage/DevATA.cpp
 SRC_CC += Devices/Storage/Debug.cpp
-SRC_CC += Devices/Storage/DevFdc.c
+SRC_C  += Devices/Storage/DevFdc.c
+SRC_CC += Devices/Storage/IOBufMgmt.cpp
 SRC_CC += Devices/Network/DevE1000.cpp
 SRC_CC += Devices/Network/DevE1000Phy.cpp
 SRC_CC += Devices/Network/DevEEPROM.cpp
@@ -41,18 +43,20 @@ SRC_CC += Devices/Audio/DevIchHdaCodec.cpp
 SRC_CC += Devices/Audio/DrvAudioCommon.cpp
 SRC_CC += Devices/USB/DevOHCI.cpp
 SRC_CC += Devices/USB/USBProxyDevice.cpp
+SRC_CC += Devices/USB/VUSBBufferedPipe.cpp
 SRC_CC += Devices/USB/VUSBDevice.cpp
-SRC_CC += Devices/USB/VUSBReadAhead.cpp
 SRC_CC += Devices/USB/VUSBSniffer.cpp
+SRC_CC += Devices/USB/VUSBSnifferPcapNg.cpp
+SRC_CC += Devices/USB/VUSBSnifferUsbMon.cpp
+SRC_CC += Devices/USB/VUSBSnifferVmx.cpp
 SRC_CC += Devices/USB/VUSBUrb.cpp
+SRC_CC += Devices/USB/VUSBUrbPool.cpp
+SRC_CC += Devices/USB/VUSBUrbTrace.cpp
 SRC_CC += Devices/Input/UsbMouse.cpp
 SRC_CC += Devices/Input/UsbKbd.cpp
 
 SRC_CC += Devices/build/VBoxDD.cpp
 
-SRC_CC += devxhci.cc
-vpath devxhci.cc $(REP_DIR)/src/virtualbox
-
 SRC_CC += GuestHost/HGSMI/HGSMICommon.cpp
 SRC_CC += GuestHost/HGSMI/HGSMIMemAlloc.cpp
 
diff --git a/repos/ports/lib/mk/virtualbox5-drivers.mk b/repos/ports/lib/mk/virtualbox5-drivers.mk
index 6731bb6a89..fa6526727d 100644
--- a/repos/ports/lib/mk/virtualbox5-drivers.mk
+++ b/repos/ports/lib/mk/virtualbox5-drivers.mk
@@ -9,15 +9,13 @@ VBOX_CC_OPT += -include base/log.h
 SRC_CC += Devices/Input/DrvKeyboardQueue.cpp
 SRC_CC += Devices/Input/DrvMouseQueue.cpp
 SRC_CC += Devices/USB/DrvVUSBRootHub.cpp
-SRC_CC += Devices/Storage/DrvBlock.cpp
-SRC_CC += Devices/Storage/DrvMediaISO.cpp
 SRC_CC += Devices/Storage/DrvVD.cpp
-SRC_CC += Devices/Storage/DrvRawImage.cpp
 SRC_CC += Devices/PC/DrvACPI.cpp
 SRC_CC += Devices/Serial/DrvChar.cpp
 SRC_CC += Devices/Serial/DrvRawFile.cpp
 SRC_CC += Devices/Serial/DrvHostSerial.cpp
 SRC_CC += Devices/Audio/DrvAudio.cpp
+SRC_CC += Devices/Audio/DrvHostNullAudio.cpp
 
 #SRC_CC += audiodrv.cpp
 SRC_CC += network.cpp
diff --git a/repos/ports/lib/mk/virtualbox5-main.mk b/repos/ports/lib/mk/virtualbox5-main.mk
index fac4c9efb0..6619d42dcd 100644
--- a/repos/ports/lib/mk/virtualbox5-main.mk
+++ b/repos/ports/lib/mk/virtualbox5-main.mk
@@ -23,6 +23,7 @@ SRC_CC += Main/src-all/PCIDeviceAttachmentImpl.cpp
 SRC_CC += Main/src-all/ProgressImpl.cpp
 SRC_CC += Main/src-all/SecretKeyStore.cpp
 SRC_CC += Main/src-all/SharedFolderImpl.cpp
+SRC_CC += Main/src-all/ThreadTask.cpp
 SRC_CC += Main/src-all/VirtualBoxBase.cpp
 
 SRC_CC += Main/src-client/AdditionsFacilityImpl.cpp
@@ -43,13 +44,14 @@ SRC_CC += Main/src-client/HGCMThread.cpp
 SRC_CC += Main/src-client/KeyboardImpl.cpp
 SRC_CC += Main/src-client/MachineDebuggerImpl.cpp
 SRC_CC += Main/src-client/MouseImpl.cpp
+SRC_CC += Main/src-client/Nvram.cpp
 SRC_CC += Main/src-client/RemoteUSBBackend.cpp
 SRC_CC += Main/src-client/RemoteUSBDeviceImpl.cpp
 SRC_CC += Main/src-client/SessionImpl.cpp
+SRC_CC += Main/src-client/USBDeviceImpl.cpp
 SRC_CC += Main/src-client/UsbWebcamInterface.cpp
 SRC_CC += Main/src-client/VBoxDriversRegister.cpp
 SRC_CC += Main/src-client/VMMDevInterface.cpp
-SRC_CC += Main/src-client/USBDeviceImpl.cpp
 
 SRC_CC += Main/src-server/AudioAdapterImpl.cpp
 SRC_CC += Main/src-server/BandwidthControlImpl.cpp
diff --git a/repos/ports/lib/mk/virtualbox5-runtime.mk b/repos/ports/lib/mk/virtualbox5-runtime.mk
index 7c82683ae1..74c01a201d 100644
--- a/repos/ports/lib/mk/virtualbox5-runtime.mk
+++ b/repos/ports/lib/mk/virtualbox5-runtime.mk
@@ -10,6 +10,8 @@ GENERIC_SRC_CC = $(notdir $(wildcard $(VBOX_DIR)/Runtime/generic/*.cpp))
 
 FILTERED_OUT_SRC_CC = fs-stubs-generic.cpp \
                       http-curl.cpp \
+                      mppresent-generic.cpp \
+                      mppresent-generic-online.cpp \
                       semrw-lockless-generic.cpp \
                       tls-generic.cpp \
                       RTDirExists-generic.cpp \
@@ -52,6 +54,7 @@ SRC_CC += Runtime/common/log/logformat.cpp
 SRC_CC += Runtime/common/misc/assert.cpp
 SRC_CC += Runtime/common/misc/buildconfig.cpp
 SRC_CC += Runtime/common/misc/cidr.cpp
+SRC_CC += Runtime/common/misc/circbuf.cpp
 SRC_CC += Runtime/common/misc/lockvalidator.cpp
 SRC_CC += Runtime/common/misc/once.cpp
 SRC_CC += Runtime/common/misc/req.cpp
@@ -71,6 +74,7 @@ SRC_CC += Runtime/common/path/RTPathAbsDup.cpp
 SRC_CC += Runtime/common/path/RTPathAbsEx.cpp
 SRC_CC += Runtime/common/path/RTPathAppendEx.cpp
 SRC_CC += Runtime/common/path/RTPathCalcRelative.cpp
+SRC_CC += Runtime/common/path/RTPathEnsureTrailingSeparator.cpp
 SRC_CC += Runtime/common/path/RTPathExt.cpp
 SRC_CC += Runtime/common/path/RTPathFilename.cpp
 SRC_CC += Runtime/common/path/RTPathHasPath.cpp
@@ -161,6 +165,7 @@ SRC_S  += Runtime/common/asm/ASMAtomicUoReadU64.as
 SRC_S  += Runtime/common/asm/ASMAtomicXchgU64.asm
 SRC_S  += Runtime/common/asm/ASMCpuIdExSlow.asm
 SRC_S  += Runtime/common/asm/ASMGetXcr0.asm
+SRC_S  += Runtime/common/asm/ASMMemFirstMismatchingU8.asm
 
 SRC_CC += Runtime/common/err/errmsg.cpp
 Runtime/common/err/errmsg.o: errmsgdata.h
diff --git a/repos/ports/lib/mk/virtualbox5-vmm.mk b/repos/ports/lib/mk/virtualbox5-vmm.mk
index 8aed3edce6..c9fce78e7c 100644
--- a/repos/ports/lib/mk/virtualbox5-vmm.mk
+++ b/repos/ports/lib/mk/virtualbox5-vmm.mk
@@ -85,6 +85,9 @@ SRC_CC += VMM/VMMR3/IOM.cpp
 SRC_CC += VMM/VMMAll/IOMAll.cpp
 SRC_CC += VMM/VMMAll/IOMAllMMIO.cpp
 
+SRC_CC += VMM/VMMR3/APIC.cpp
+SRC_CC += VMM/VMMAll/APICAll.cpp
+
 CC_OPT += -DVBOX_IN_VMM
 
 # definitions needed by SSM.cpp
diff --git a/repos/ports/ports/virtualbox5.hash b/repos/ports/ports/virtualbox5.hash
index 56b7e78913..0e83ec78e1 100644
--- a/repos/ports/ports/virtualbox5.hash
+++ b/repos/ports/ports/virtualbox5.hash
@@ -1 +1 @@
-7ebd52c12b8c8d332d348cea047c38640cb57c81
+6c256743d02114e0e47001386465def6e01e0c03
diff --git a/repos/ports/ports/virtualbox5.port b/repos/ports/ports/virtualbox5.port
index f8fb9fdff6..3e9360fb3a 100644
--- a/repos/ports/ports/virtualbox5.port
+++ b/repos/ports/ports/virtualbox5.port
@@ -1,17 +1,17 @@
 LICENSE         := GPLv2
-VERSION         := 5.0.26
+VERSION         := 5.1.8
 DOWNLOADS       := virtualbox.archive virtualbox_sdk.archive
 
 VIRTUALBOX_TBZ2    := VirtualBox-$(VERSION).tar.bz2
-VIRTUALBOX_SDK_ZIP := VirtualBoxSDK-$(VERSION)-108824.zip
+VIRTUALBOX_SDK_ZIP := VirtualBoxSDK-$(VERSION)-111374.zip
 
 URL(virtualbox) := http://download.virtualbox.org/virtualbox/$(VERSION)/$(VIRTUALBOX_TBZ2)
 DIR(virtualbox) := src/app/virtualbox
-SHA(virtualbox) := 5e58c952f010b679a80ba3ce7ccb2641895f515f
+SHA(virtualbox) := fe968ecbe9f8945220dbd388971cd1ce596cfd22
 
 URL(virtualbox_sdk) := http://download.virtualbox.org/virtualbox/$(VERSION)/$(VIRTUALBOX_SDK_ZIP)
 DIR(virtualbox_sdk) := src/app/virtualbox_sdk
-SHA(virtualbox_sdk) := 8c03425d13095a951725d763a8a3a6f51a64ed67
+SHA(virtualbox_sdk) := c7ffc8d179b43ffc7e05011a22c44577da4fde4a
 
 PATCHES_DIR       := src/virtualbox5/patches
 PATCHES_DIR_VBOX4 := src/virtualbox/patches
@@ -27,7 +27,7 @@ VBOX_MAIN_GLUE := AutoLock EventQueue string xpcom/helpers
 
 VBOX_MAIN_ALL := AuthLibrary AutoCaller DisplayResampleImage DisplayUtils EventImpl Global HashedPw
 VBOX_MAIN_ALL += PCIDeviceAttachmentImpl ProgressImpl SharedFolderImpl SecretKeyStore
-VBOX_MAIN_ALL += VirtualBoxBase
+VBOX_MAIN_ALL += ThreadTask VirtualBoxBase
 
 VBOX_MAIN_CLI := AdditionsFacilityImpl BusAssignmentManager
 VBOX_MAIN_CLI += ConsoleImpl ConsoleImpl2 ConsoleVRDPServer
@@ -36,6 +36,7 @@ VBOX_MAIN_CLI += DrvAudioVRDE EmulatedUSBImpl GuestCtrlImpl GuestImpl
 VBOX_MAIN_CLI += HGCM HGCMThread HGCMObjects
 VBOX_MAIN_CLI += KeyboardImpl SessionImpl VMMDevInterface
 VBOX_MAIN_CLI += MouseImpl MachineDebuggerImpl
+VBOX_MAIN_CLI += Nvram
 VBOX_MAIN_CLI += USBDeviceImpl UsbWebcamInterface VBoxDriversRegister
 VBOX_MAIN_CLI += RemoteUSBDeviceImpl RemoteUSBBackend 
 
@@ -72,6 +73,8 @@ VBOX_MAIN_INC += USBIdDatabase USBProxyService VirtualBoxImpl VRDEServerImpl Gue
 VBOX_MAIN_INC += USBDeviceImpl HostUSBDeviceImpl Matching Wrapper
 VBOX_MAIN_INC += RemoteUSBDeviceImpl RemoteUSBBackend ConsoleVRDPServer
 VBOX_MAIN_INC += MachineDebuggerImpl EmulatedUSBImpl
+VBOX_MAIN_INC += ThreadTask USBProxyBackend
+
 
 VBOX_SRC_VBOX := VMM Devices Runtime GuestHost/HGSMI Storage Disassembler
 VBOX_SRC_VBOX += HostServices/SharedFolders Main/xml/Settings.cpp
diff --git a/repos/ports/src/virtualbox/include/VBox/com/defs.h b/repos/ports/src/virtualbox/include/VBox/com/defs.h
index 8cce7b58e4..0327faf56a 100644
--- a/repos/ports/src/virtualbox/include/VBox/com/defs.h
+++ b/repos/ports/src/virtualbox/include/VBox/com/defs.h
@@ -3,6 +3,7 @@
 
 #include <iprt/types.h>
 
+#include <xpcom/nsISupports.h>
 #include <nsID.h>
 
 #define ATL_NO_VTABLE
diff --git a/repos/ports/src/virtualbox/patches/series b/repos/ports/src/virtualbox/patches/series
index a98c5b8df5..c46eef6011 100644
--- a/repos/ports/src/virtualbox/patches/series
+++ b/repos/ports/src/virtualbox/patches/series
@@ -7,6 +7,8 @@ vga_vbva.patch
 vmmdev.patch
 usb.patch
 vbox_dd.patch
+ide.patch
+rem_irq.patch
 force_ioapic.patch
 vbox-cpuhotplug.dsl.patch
 dev_e1000.patch
diff --git a/repos/ports/src/virtualbox/patches/series_common b/repos/ports/src/virtualbox/patches/series_common
index f44738f684..f838bcb62c 100644
--- a/repos/ports/src/virtualbox/patches/series_common
+++ b/repos/ports/src/virtualbox/patches/series_common
@@ -8,7 +8,6 @@ network.patch
 pdm_driver.patch
 poke.patch
 posix.patch
-rem_irq.patch
 serial.patch
 sharedfolder_pagelist.patch
 time-log-deadlock.patch
diff --git a/repos/ports/src/virtualbox5/devices.cc b/repos/ports/src/virtualbox5/devices.cc
new file mode 100644
index 0000000000..b65f0060f6
--- /dev/null
+++ b/repos/ports/src/virtualbox5/devices.cc
@@ -0,0 +1,90 @@
+/*
+ * \brief  VirtualBox device models
+ * \author Norman Feske
+ * \date   2013-08-20
+ */
+
+/*
+ * Copyright (C) 2013 Genode Labs GmbH
+ *
+ * This file is distributed under the terms of the GNU General Public License
+ * version 2.
+ */
+
+/* Genode includes */
+#include <os/attached_rom_dataspace.h>
+
+/* VirtualBox includes */
+#include <VBoxDD.h>
+#include <VBoxDD2.h>
+
+
+#define REGISTER(device)                                       \
+	do {                                                       \
+		rc = pCallbacks->pfnRegister(pCallbacks, &g_##device); \
+		if (RT_FAILURE(rc))                                    \
+			return rc;                                         \
+	} while (0)
+
+
+extern "C" int VBoxDevicesRegister(PPDMDEVREGCB pCallbacks, uint32_t u32Version)
+{
+	int rc = 0;
+
+	/* platform */
+	REGISTER(DevicePcArch);
+	REGISTER(DevicePcBios);
+	REGISTER(DeviceI8254);
+	REGISTER(DeviceI8259);
+	REGISTER(DeviceDMA);
+	REGISTER(DeviceMC146818);
+	REGISTER(DeviceACPI);
+	REGISTER(DevicePCI);
+	REGISTER(DevicePCIBridge);
+
+	/* devices */
+	REGISTER(DevicePS2KeyboardMouse);
+	REGISTER(DeviceVga);
+	REGISTER(DeviceFloppyController);
+	REGISTER(DeviceSerialPort);
+	REGISTER(DevicePIIX3IDE);
+	REGISTER(DeviceAHCI);
+	REGISTER(DevicePCNet);
+	REGISTER(DeviceE1000);
+	REGISTER(DeviceVMMDev);
+	REGISTER(DeviceOHCI);
+	REGISTER(DeviceICHAC97);
+	REGISTER(DeviceICH6_HDA);
+
+	return VINF_SUCCESS;
+}
+
+/*
+ * The virtual PCI model delivers IRQs to the PIC by default and to the IOAPIC
+ * only if the guest operating system selected the IOAPIC with the '_PIC' ACPI
+ * method and if it called the '_PRT' ACPI method afterwards. When running a
+ * guest operating system which uses the IOAPIC, but does not call these ACPI
+ * methods (for example Genode/NOVA), IRQ delivery to the IOAPIC can be
+ * enforced with the 'force_ioapic' configuration option.
+ *
+ * References:
+ *   - 'pciSetIrqInternal()' in DevPCI.cpp
+ *   - '_PIC' and '_PRT' ACPI methods in vbox.dsl
+ */
+
+static bool read_force_ioapic_from_config()
+{
+	try {
+		Genode::Attached_rom_dataspace config("config");
+		return config.xml().attribute_value("force_ioapic", false);
+	} catch (Genode::Rom_connection::Rom_connection_failed) {
+		return false;
+	}
+}
+
+bool force_ioapic()
+{
+	/* read only once from config ROM */
+	static bool force = read_force_ioapic_from_config();
+	return force;
+}
diff --git a/repos/ports/src/virtualbox5/drivers.cc b/repos/ports/src/virtualbox5/drivers.cc
new file mode 100644
index 0000000000..dbf92d3a74
--- /dev/null
+++ b/repos/ports/src/virtualbox5/drivers.cc
@@ -0,0 +1,46 @@
+/*
+ * \brief  VirtualBox host drivers
+ * \author Norman Feske
+ * \date   2013-08-20
+ */
+
+/*
+ * Copyright (C) 2013-2016 Genode Labs GmbH
+ *
+ * This file is distributed under the terms of the GNU General Public License
+ * version 2.
+ */
+
+/* VirtualBox includes */
+#include <VBoxDD.h>
+
+
+extern "C" int VBoxDriversRegister(PCPDMDRVREGCB pCallbacks, uint32_t u32Version)
+{
+	PDMDRVREG const *drvs[] = {
+		&g_DrvKeyboardQueue,
+		&g_DrvMouseQueue,
+//		&g_DrvBlock,
+//		&g_DrvMediaISO,
+		&g_DrvACPI,
+		&g_DrvChar,
+//		&g_DrvRawImage,
+		&g_DrvRawFile,
+		&g_DrvHostSerial,
+		&g_DrvVD,
+		&g_DrvHostInterface,
+		&g_DrvVUSBRootHub,
+		&g_DrvAUDIO,
+		&g_DrvHostNullAudio,
+		0
+	};
+
+	for (unsigned i = 0; drvs[i]; i++) {
+		int rc = pCallbacks->pfnRegister(pCallbacks, drvs[i]);
+		if (RT_FAILURE(rc))
+			return rc;
+	}
+
+	return VINF_SUCCESS;
+}
+
diff --git a/repos/ports/src/virtualbox5/dummies.cc b/repos/ports/src/virtualbox5/dummies.cc
index 84934a60e4..d2721d00a9 100644
--- a/repos/ports/src/virtualbox5/dummies.cc
+++ b/repos/ports/src/virtualbox5/dummies.cc
@@ -113,6 +113,7 @@ int  FTMSetCheckpoint(PVM, FTMCHECKPOINTTYPE)
 int  FTMR3Term(PVM)                                                             TRACE(VINF_SUCCESS)
 
 int  GIMR3Init(PVM)                                                             TRACE(VINF_SUCCESS)
+int  GIMR3Term(PVM)                                                             TRACE(VINF_SUCCESS)
 void GIMR3Reset(PVM)                                                            TRACE()
 bool GIMIsEnabled(PVM)                                                          TRACE(false)
 bool GIMIsParavirtTscEnabled(PVM)                                               TRACE(false)
diff --git a/repos/ports/src/virtualbox5/frontend/VirtualBoxBase.h b/repos/ports/src/virtualbox5/frontend/VirtualBoxBase.h
index a7a0eb806f..5b51be035a 100644
--- a/repos/ports/src/virtualbox5/frontend/VirtualBoxBase.h
+++ b/repos/ports/src/virtualbox5/frontend/VirtualBoxBase.h
@@ -1,7 +1,7 @@
 #ifndef ____H_VIRTUALBOXBASEIMPL
 #define ____H_VIRTUALBOXBASEIMPL
 
-#include <base/log.h>
+//#include <base/log.h>
 
 #include <iprt/cdefs.h>
 #include <iprt/thread.h>
@@ -58,6 +58,9 @@ class VirtualBoxBase : public VirtualBoxTranslatable
 		/** Primary state of this object */
 		ObjectState mState;
 
+		/** Slot of this object in the saFactoryStats array */
+		uint32_t iFactoryStat;
+
 		/** Thread that caused the last state change */
 		RTTHREAD mStateChangeThread;
 		/** Total number of active calls to this object */
@@ -78,9 +81,8 @@ class VirtualBoxBase : public VirtualBoxTranslatable
 
 	protected:
 
-		HRESULT   BaseFinalConstruct() { return S_OK; }
-
-		void   BaseFinalRelease() { }
+		HRESULT BaseFinalConstruct();
+		void BaseFinalRelease();
 
 	public:
 
@@ -463,6 +465,26 @@ class Backupable : public Shareable<T>
   #define VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(cls, iface) \
     VIRTUALBOXBASE_ADD_VIRTUAL_COMPONENT_METHODS(cls, iface)
 
+#define VBOX_TWEAK_INTERFACE_ENTRY(iface)
+
+/** Structure for counting the currently existing and ever created objects
+ * for each component name. */
+typedef struct CLASSFACTORY_STAT
+{
+    const char *psz;
+    uint64_t current;
+    uint64_t overall;
+} CLASSFACTORY_STAT;
+
+/** Maximum number of component names to deal with. There will be debug
+ * assertions if the value is too low. Since the table is global and its
+ * entries are reasonably small, it's not worth squeezing out the last bit. */
+#define CLASSFACTORYSTATS_MAX 128
+
+/* global variables (defined in VirtualBoxBase.cpp) */
+extern CLASSFACTORY_STAT g_aClassFactoryStats[CLASSFACTORYSTATS_MAX];
+extern RWLockHandle *g_pClassFactoryStatsLock;
+
 #include "GenodeImpl.h"
 
 #endif // !____H_VIRTUALBOXBASEIMPL
diff --git a/repos/ports/src/virtualbox5/frontend/dummy/host.cc b/repos/ports/src/virtualbox5/frontend/dummy/host.cc
index 12c88850d0..a746227016 100644
--- a/repos/ports/src/virtualbox5/frontend/dummy/host.cc
+++ b/repos/ports/src/virtualbox5/frontend/dummy/host.cc
@@ -189,3 +189,11 @@ HRESULT Host::findUSBDeviceByAddress(const com::Utf8Str &,
 	DUMMY(E_FAIL)
 HRESULT Host::findUSBDeviceById(const com::Guid &, ComPtr<IHostUSBDevice> &)
 	DUMMY(E_FAIL)
+
+HRESULT Host::addUSBDeviceSource(const com::Utf8Str &, const com::Utf8Str &,
+                                 const com::Utf8Str &,
+                                 const std::vector<com::Utf8Str> &,
+                                 const std::vector<com::Utf8Str> &)
+	DUMMY(E_FAIL)
+HRESULT Host::removeUSBDeviceSource(const com::Utf8Str &aId)
+	DUMMY(E_FAIL)
diff --git a/repos/ports/src/virtualbox5/hm.cc b/repos/ports/src/virtualbox5/hm.cc
index 616dd0e13f..bbc621b3a4 100644
--- a/repos/ports/src/virtualbox5/hm.cc
+++ b/repos/ports/src/virtualbox5/hm.cc
@@ -83,17 +83,17 @@ VMMR3_INT_DECL(int) HMR3InitCompleted(PVM pVM, VMINITCOMPLETED enmWhat)
 	int rc = SUPR3CallVMMR0Ex(pVM->pVMR0, 0 /*idCpu*/, VMMR0_DO_HM_SETUP_VM, 0, NULL);
 
 	if (rc == VINF_SUCCESS) {
-		CPUMSetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_SEP);
+		CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_SEP);
 
 		/* nova kernel supports solely on 64bit the following features */
 		if (sizeof(void *) > 4 && enable_pae_nx) {
-			CPUMSetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_PAE);
-			CPUMSetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_NX);
+			CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_PAE);
+			CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_NX);
 		}
 		if (sizeof(void *) > 4 && enable_64bit) {
-			CPUMSetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_LONG_MODE);
-			CPUMSetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_SYSCALL);
-	        CPUMSetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_LAHF);
+			CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_LONG_MODE);
+			CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_SYSCALL);
+	        CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_LAHF);
 		}
 	}
 
@@ -110,7 +110,7 @@ VMMDECL(bool) HMIsEnabledNotMacro(PVM pVM)
 VMMR3DECL(bool) HMR3IsVmxPreemptionTimerUsed(PVM pVM)
 {
 	if (VERBOSE_HM)
-		Genode::log(__func__, "called");
+		Genode::log(__func__, " called");
 
 	return false;
 }
@@ -200,9 +200,23 @@ VMMR3_INT_DECL(void) HMR3PagingModeChanged(PVM pVM, PVMCPU pVCpu, PGMMODE enmSha
 VMM_INT_DECL(int) HMFlushTLBOnAllVCpus(PVM pVM)
 {
 	if (VERBOSE_HM)
-		Genode::log(__func__, "called");
+		Genode::log(__func__, " called");
 	return VINF_SUCCESS;
 }
 
 VBOXSTRICTRC HMR3RestartPendingIOInstr(PVM, PVMCPU, PCPUMCTX) {
 	return VERR_NOT_FOUND; }
+
+
+VMMR3DECL(bool) HMR3IsPostedIntrsEnabled(PUVM pUVM)
+{
+	Genode::log(__func__, " called");
+	return false;
+}
+
+
+VMMR3DECL(bool) HMR3IsVirtApicRegsEnabled(PUVM pUVM)
+{
+	Genode::log(__func__, " called");
+	return false;
+}
diff --git a/repos/ports/src/virtualbox5/mm.cc b/repos/ports/src/virtualbox5/mm.cc
index b65170b2e5..22e5f40c8c 100644
--- a/repos/ports/src/virtualbox5/mm.cc
+++ b/repos/ports/src/virtualbox5/mm.cc
@@ -23,6 +23,7 @@
 #include <VBox/vmm/cfgm.h>
 #include <VBox/err.h>
 #include <VBox/vmm/gmm.h>
+#include "MMInternal.h"
 #include <VBox/vmm/vm.h>
 #include <VBox/vmm/pgm.h>
 #include <iprt/err.h>
@@ -165,14 +166,14 @@ int MMR3HeapAllocZEx(PVM pVM, MMTAG enmTag, size_t cbSize, void **ppv)
 
 int MMR3HyperInitFinalize(PVM)
 {
-	Genode::log(__func__, "called");
+	Genode::log(__func__, " called");
 	return VINF_SUCCESS;
 }
 
 
 int MMR3HyperSetGuard(PVM, void* ptr, size_t, bool)
 {
-	Genode::log(__func__, "called ", ptr);
+	Genode::log(__func__, " called ", ptr);
 	return VINF_SUCCESS;
 }
 
@@ -238,7 +239,7 @@ int MMHyperDupMem(PVM pVM, const void *pvSrc, size_t cb,
 
 bool MMHyperIsInsideArea(PVM, RTGCPTR ptr)
 {
-	Genode::log(__func__, "called");
+	Genode::log(__func__, " called");
 
 	return false;
 }
@@ -361,12 +362,18 @@ int MMR3InitPaging(PVM pVM)
      */
     if (cbRam > offRamHole)
     {
+        pVM->mm.s.cbRamBelow4GB = offRamHole;
         rc = PGMR3PhysRegisterRam(pVM, 0, offRamHole, "Base RAM");
         if (RT_SUCCESS(rc))
+        {
+            pVM->mm.s.cbRamAbove4GB = cbRam - offRamHole;
             rc = PGMR3PhysRegisterRam(pVM, _4G, cbRam - offRamHole, "Above 4GB Base RAM");
-    }
-    else
+        }
+    } else {
+        pVM->mm.s.cbRamBelow4GB = cbRam;
+        pVM->mm.s.cbRamAbove4GB = 0;
         rc = PGMR3PhysRegisterRam(pVM, 0, RT_MIN(cbRam, offRamHole), "Base RAM");
+    }
 
     LogFlow(("MMR3InitPaging: returns %Rrc\n", rc));
     return rc;
@@ -460,6 +467,20 @@ VMMDECL(uint32_t) MMHyperHeapPtrToOffset(PVM pVM, void *pv)
 }
 
 
+VMMR3DECL(uint32_t) MMR3PhysGetRamSizeBelow4GB(PVM pVM)
+{
+	VM_ASSERT_VALID_EXT_RETURN(pVM, UINT32_MAX);
+	return pVM->mm.s.cbRamBelow4GB;
+}
+
+
+VMMR3DECL(uint64_t) MMR3PhysGetRamSizeAbove4GB(PVM pVM)
+{
+	VM_ASSERT_VALID_EXT_RETURN(pVM, UINT64_MAX);
+	return pVM->mm.s.cbRamAbove4GB;
+}
+
+
 extern "C" {
 
 char * MMR3HeapAPrintf(PVM pVM, MMTAG enmTag, const char *pszFormat, ...)
diff --git a/repos/ports/src/virtualbox5/patches/iem_wip.patch b/repos/ports/src/virtualbox5/patches/iem_wip.patch
index 8bdc0a233e..d2e1b40bd5 100644
--- a/repos/ports/src/virtualbox5/patches/iem_wip.patch
+++ b/repos/ports/src/virtualbox5/patches/iem_wip.patch
@@ -1,15 +1,17 @@
 --- a/src/app/virtualbox/src/VBox/VMM/VMMR3/PGM.cpp
 +++ b/src/app/virtualbox/src/VBox/VMM/VMMR3/PGM.cpp
-@@ -2159,7 +2159,7 @@
+@@ -2165,8 +2165,8 @@
+  */
  VMMR3DECL(int) PGMR3InitFinalize(PVM pVM)
  {
-     int rc;
+-    int rc = VERR_IPE_UNINITIALIZED_STATUS; /* (MSC incorrectly thinks it can be usused uninitialized) */
 -
++    int rc = VINF_SUCCESS; //VERR_IPE_UNINITIALIZED_STATUS; /* (MSC incorrectly thinks it can be usused uninitialized) */
 +#if 0
      /*
       * Reserve space for the dynamic mappings.
       * Initialize the dynamic mapping pages with dummy pages to simply the cache.
-@@ -2180,6 +2180,7 @@
+@@ -2187,6 +2187,7 @@
          rc = PGMMap(pVM, pVM->pgm.s.pbDynPageMapBaseGC + offDynMap, HCPhysDummy, PAGE_SIZE, 0);
          AssertRCReturn(rc, rc);
      }
@@ -17,7 +19,7 @@
  
      /*
       * Determine the max physical address width (MAXPHYADDR) and apply it to
-@@ -2377,7 +2378,7 @@
+@@ -2384,7 +2385,7 @@
       * (One or more of them have changed, that's why we're here.)
       */
      pVM->pgm.s.pMappingsRC = MMHyperR3ToRC(pVM, pVM->pgm.s.pMappingsR3);
@@ -26,7 +28,7 @@
          pCur->pNextRC = MMHyperR3ToRC(pVM, pCur->pNextR3);
  
      /* Relocate GC addresses of Page Tables. */
-@@ -2390,6 +2391,7 @@
+@@ -2397,6 +2398,7 @@
          }
      }
  
@@ -34,7 +36,7 @@
      /*
       * Dynamic page mapping area.
       */
-@@ -2412,6 +2414,7 @@
+@@ -2419,6 +2421,7 @@
              paPages[iPage].uPte.pPae    += offDelta;
          }
      }
diff --git a/repos/ports/src/virtualbox5/patches/series b/repos/ports/src/virtualbox5/patches/series
index cab29de2b3..3117dada34 100644
--- a/repos/ports/src/virtualbox5/patches/series
+++ b/repos/ports/src/virtualbox5/patches/series
@@ -7,3 +7,4 @@ vmm.patch
 iem_wip.patch
 dbg.patch
 dev_e1000.patch
+tm_tpr_vbox5.patch
diff --git a/repos/ports/src/virtualbox5/patches/tm_tpr_vbox5.patch b/repos/ports/src/virtualbox5/patches/tm_tpr_vbox5.patch
new file mode 100644
index 0000000000..7175e813ae
--- /dev/null
+++ b/repos/ports/src/virtualbox5/patches/tm_tpr_vbox5.patch
@@ -0,0 +1,11 @@
+--- a/src/app/virtualbox/src/VBox/VMM/VMMAll/APICAll.cpp
++++ b/src/app/virtualbox/src/VBox/VMM/VMMAll/APICAll.cpp
+@@ -2264,7 +2264,7 @@
+ APICBOTHCBDECL(uint8_t) apicGetTpr(PPDMDEVINS pDevIns, PVMCPU pVCpu, bool *pfPending, uint8_t *pu8PendingIntr)
+ {
+     RT_NOREF_PV(pDevIns);
+-    VMCPU_ASSERT_EMT(pVCpu);
++    //VMCPU_ASSERT_EMT(pVCpu);
+     PCXAPICPAGE pXApicPage = VMCPU_TO_CXAPICPAGE(pVCpu);
+ 
+     if (pfPending)
diff --git a/repos/ports/src/virtualbox5/patches/usb.patch b/repos/ports/src/virtualbox5/patches/usb.patch
index 677ea0e490..ae7298678e 100644
--- a/repos/ports/src/virtualbox5/patches/usb.patch
+++ b/repos/ports/src/virtualbox5/patches/usb.patch
@@ -4,21 +4,14 @@ diff --git a/src/app/virtualbox/src/VBox/Devices/USB/USBProxyDevice.cpp b/src/ap
 index a51bc36..bed42e8 100644
 --- a/src/app/virtualbox/src/VBox/Devices/USB/USBProxyDevice.cpp
 +++ b/src/app/virtualbox/src/VBox/Devices/USB/USBProxyDevice.cpp
-@@ -843,10 +843,14 @@ static DECLCALLBACK(int) usbProxyConstruct(PPDMUSBINS pUsbIns, int iInstance, PC
+@@ -843,6 +843,7 @@ static DECLCALLBACK(int) usbProxyConstruct(PPDMUSBINS pUsbIns, int iInstance, PC
      /*
       * Select backend and open the device.
       */
-+
 +    return PDMUSB_SET_ERROR(pUsbIns, VERR_NOT_SUPPORTED, N_("USBProxy: not supported on Genode"));
-+#if 0
-     if (!fRemote)
-         pThis->pOps = &g_USBProxyDeviceHost;
-     else
-         pThis->pOps = &g_USBProxyDeviceVRDP;
-+#endif /* if 0 */
- 
-     pThis->pvInstanceDataR3 = RTMemAllocZ(pThis->pOps->cbBackend);
-     if (!pThis->pvInstanceDataR3)
+     rc = VERR_NOT_FOUND;
+     for (unsigned i = 0; i < RT_ELEMENTS(g_aUsbProxies); i++)
+     {
 diff --git a/src/app/virtualbox/src/VBox/Devices/USB/VUSBDevice.cpp b/src/app/virtualbox/src/VBox/Devices/USB/VUSBDevice.cpp
 index 4790fcb..d649ad6 100644
 --- a/src/app/virtualbox/src/VBox/Devices/USB/VUSBDevice.cpp
@@ -29,7 +22,7 @@ index 4790fcb..d649ad6 100644
          /* Process any URBs waiting to be cancelled first. */
 -        int rc = RTReqQueueProcess(pDev->hReqQueueSync, 0); /* Don't wait if there is nothing to do. */
 +        int rc = RTReqQueueProcess(pDev->hReqQueueSync, pDev->enmState == VUSB_DEVICE_STATE_RESET ? 5 : 0); /* if in reset state (takes 10ms) sleep a bit - otherwise this thread consumes in this loop a lot of cpu time */
-         Assert(RT_SUCCESS(rc) || rc == VERR_TIMEOUT);
+         Assert(RT_SUCCESS(rc) || rc == VERR_TIMEOUT); NOREF(rc);
      }
  
 diff --git a/src/app/virtualbox/src/VBox/Devices/build/VBoxDD.cpp b/src/app/virtualbox/src/VBox/Devices/build/VBoxDD.cpp
@@ -87,11 +80,73 @@ index 2f01f69..9b13e37 100644
  #ifdef VBOX_WITH_USB
      HRESULT rc = mUSBDeviceFilters->i_notifyProxy(false /* aInsertFilters */);
      AssertComRC(rc);
-diff --git a/src/app/virtualbox/src/VBox/Main/src-server/USBDeviceFiltersImpl.cpp b/src/app/virtualbox/src/VBox/Main/src-server/USBDeviceFiltersImpl.cpp
-index 09b42f5..c179ca6 100644
 --- a/src/app/virtualbox/src/VBox/Main/src-server/USBDeviceFiltersImpl.cpp
 +++ b/src/app/virtualbox/src/VBox/Main/src-server/USBDeviceFiltersImpl.cpp
-@@ -1037,13 +1037,10 @@ HRESULT USBDeviceFilters::notifyProxy(bool aInsertFilters)
+@@ -386,7 +386,7 @@
+         ComAssertRet(pProxySvc, E_FAIL);
+ 
+         ComAssertRet(pFilter->i_getId() == NULL, E_FAIL);
+-        pFilter->i_getId() = pProxySvc->insertFilter(&pFilter->i_getData().mUSBFilter);
++//        pFilter->i_getId() = pProxySvc->insertFilter(&pFilter->i_getData().mUSBFilter);
+     }
+ 
+     alock.release();
+@@ -452,7 +452,7 @@
+         ComAssertRet(pProxySvc, E_FAIL);
+ 
+         ComAssertRet(pFilter->i_getId() != NULL, E_FAIL);
+-        pProxySvc->removeFilter(pFilter->i_getId());
++//        pProxySvc->removeFilter(pFilter->i_getId());
+         pFilter->i_getId() = NULL;
+     }
+ 
+@@ -606,7 +606,7 @@
+                 {
+                     USBDeviceFilter *pFilter = *it;
+                     Assert(pFilter->i_getId() != NULL);
+-                    pProxySvc->removeFilter(pFilter->i_getId());
++//                    pProxySvc->removeFilter(pFilter->i_getId());
+                     pFilter->i_getId() = NULL;
+                 }
+ 
+@@ -631,7 +631,7 @@
+                     {
+                         USBDeviceFilter *pFilter = *it; /* resolve ambiguity */
+                         Assert(pFilter->i_getId() == NULL);
+-                        pFilter->i_getId() = pProxySvc->insertFilter(&pFilter->i_getData().mUSBFilter);
++//                        pFilter->i_getId() = pProxySvc->insertFilter(&pFilter->i_getData().mUSBFilter);
+                     }
+                 }
+                 ++it;
+@@ -841,12 +841,12 @@
+                 if (aFilter->i_getData().mData.fActive)
+                 {
+                     ComAssertRet(aFilter->i_getId() == NULL, E_FAIL);
+-                    aFilter->i_getId() = pProxySvc->insertFilter(&aFilter->i_getData().mUSBFilter);
++//                    aFilter->i_getId() = pProxySvc->insertFilter(&aFilter->i_getData().mUSBFilter);
+                 }
+                 else
+                 {
+                     ComAssertRet(aFilter->i_getId() != NULL, E_FAIL);
+-                    pProxySvc->removeFilter(aFilter->i_getId());
++//                    pProxySvc->removeFilter(aFilter->i_getId());
+                     aFilter->i_getId() = NULL;
+                 }
+             }
+@@ -857,10 +857,10 @@
+             {
+                 /* update the filter in the proxy */
+                 ComAssertRet(aFilter->i_getId() != NULL, E_FAIL);
+-                pProxySvc->removeFilter(aFilter->i_getId());
++//                pProxySvc->removeFilter(aFilter->i_getId());
+                 if (aFilter->i_getData().mRemote.isMatch(false))
+                 {
+-                    aFilter->i_getId() = pProxySvc->insertFilter(&aFilter->i_getData().mUSBFilter);
++//                    aFilter->i_getId() = pProxySvc->insertFilter(&aFilter->i_getData().mUSBFilter);
+                 }
+             }
+         }
+@@ -1027,13 +1027,10 @@
      LogFlowThisFunc(("aInsertFilters=%RTbool\n", aInsertFilters));
  
      AutoCaller autoCaller(this);
@@ -106,8 +161,8 @@ index 09b42f5..c179ca6 100644
      DeviceFilterList::const_iterator it = m->llDeviceFilters->begin();
      while (it != m->llDeviceFilters->end())
      {
-@@ -1054,6 +1051,9 @@ HRESULT USBDeviceFilters::notifyProxy(bool aInsertFilters)
-             && pFilter->getData().mRemote.isMatch(false) /* and if the filter is NOT remote */
+@@ -1044,10 +1041,13 @@
+             && pFilter->i_getData().mRemote.isMatch(false) /* and if the filter is NOT remote */
             )
          {
 +            USBProxyService *pProxySvc = m->pHost->i_usbProxyService();
@@ -115,4 +170,18 @@ index 09b42f5..c179ca6 100644
 +
              if (aInsertFilters)
              {
-                 AssertReturn(pFilter->getId() == NULL, E_FAIL);
+                 AssertReturn(pFilter->i_getId() == NULL, E_FAIL);
+-                pFilter->i_getId() = pProxySvc->insertFilter(&pFilter->i_getData().mUSBFilter);
++//                pFilter->i_getId() = pProxySvc->insertFilter(&pFilter->i_getData().mUSBFilter);
+             }
+             else
+             {
+@@ -1056,7 +1056,7 @@
+                  * process crash for example. So, don't assert that ID != NULL. */
+                 if (pFilter->i_getId() != NULL)
+                 {
+-                    pProxySvc->removeFilter(pFilter->i_getId());
++//                    pProxySvc->removeFilter(pFilter->i_getId());
+                     pFilter->i_getId() = NULL;
+                 }
+             }
diff --git a/repos/ports/src/virtualbox5/patches/vbox_inc.patch b/repos/ports/src/virtualbox5/patches/vbox_inc.patch
index 8145e07fe9..752c2d2fd6 100644
--- a/repos/ports/src/virtualbox5/patches/vbox_inc.patch
+++ b/repos/ports/src/virtualbox5/patches/vbox_inc.patch
@@ -1,20 +1,5 @@
 vbox_inc.patch
 
-diff --git a/src/app/virtualbox/include/VBox/com/ErrorInfo.h b/src/app/virtualbox/include/VBox/com/ErrorInfo.h
-index 869b998..c6adf70 100644
---- a/src/app/virtualbox/include/VBox/com/ErrorInfo.h
-+++ b/src/app/virtualbox/include/VBox/com/ErrorInfo.h
-@@ -31,8 +31,8 @@
-  * @{
-  */
- 
--COM_STRUCT_OR_CLASS(IProgress);
--COM_STRUCT_OR_CLASS(IVirtualBoxErrorInfo);
-+//COM_STRUCT_OR_CLASS(IProgress);
-+//COM_STRUCT_OR_CLASS(IVirtualBoxErrorInfo);
- 
- namespace com
- {
 diff --git a/src/app/virtualbox/include/VBox/com/array.h b/src/app/virtualbox/include/VBox/com/array.h
 index 77f9d60..dcbad41 100644
 --- a/src/app/virtualbox/include/VBox/com/array.h
diff --git a/repos/ports/src/virtualbox5/patches/vbox_main.patch b/repos/ports/src/virtualbox5/patches/vbox_main.patch
index df746159c5..9a8777d45d 100644
--- a/repos/ports/src/virtualbox5/patches/vbox_main.patch
+++ b/repos/ports/src/virtualbox5/patches/vbox_main.patch
@@ -277,36 +277,20 @@ index 7fa0f99..d85976d 100644
  {
      LogFlow(("VBoxDriversRegister: u32Version=%#x\n", u32Version));
      AssertReleaseMsg(u32Version == VBOX_VERSION, ("u32Version=%#x VBOX_VERSION=%#x\n", u32Version, VBOX_VERSION));
-@@ -67,6 +69,7 @@ extern "C" DECLEXPORT(int) VBoxDriversRegister(PCPDMDRVREGCB pCallbacks, uint32_
+@@ -79,11 +79,11 @@
+     rc = pCallbacks->pfnRegister(pCallbacks, &Nvram::DrvReg);
      if (RT_FAILURE(rc))
          return rc;
- 
+-
 +#if 0
-     rc = pCallbacks->pfnRegister(pCallbacks, &AudioVRDE::DrvReg);
-     if (RT_FAILURE(rc))
-         return rc;
-@@ -78,6 +81,7 @@ extern "C" DECLEXPORT(int) VBoxDriversRegister(PCPDMDRVREGCB pCallbacks, uint32_
      rc = pCallbacks->pfnRegister(pCallbacks, &EmWebcam::DrvReg);
      if (RT_FAILURE(rc))
          return rc;
+-
 +#endif
- 
  #ifdef VBOX_WITH_USB_CARDREADER
      rc = pCallbacks->pfnRegister(pCallbacks, &UsbCardReader::DrvReg);
-diff --git a/src/app/virtualbox/src/VBox/Main/src-client/VMMDevInterface.cpp b/src/app/virtualbox/src/VBox/Main/src-client/VMMDevInterface.cpp
-index b4f4da4..a341e45 100644
---- a/src/app/virtualbox/src/VBox/Main/src-client/VMMDevInterface.cpp
-+++ b/src/app/virtualbox/src/VBox/Main/src-client/VMMDevInterface.cpp
-@@ -553,7 +553,9 @@ DECLCALLBACK(int) vmmdevIsPageFusionEnabled(PPDMIVMMDEVCONNECTOR pInterface, boo
- {
-     PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
-     Console *pConsole = pDrv->pVMMDev->getParent();
-+#if 0
-     BOOL           val = 0;
-+#endif
- 
-     if (!pfPageFusionEnabled)
-         return VERR_INVALID_POINTER;
+     if (RT_FAILURE(rc))
 diff --git a/src/app/virtualbox/src/VBox/Main/src-server/ClientToken.cpp b/src/app/virtualbox/src/VBox/Main/src-server/ClientToken.cpp
 index be0afb8..54d5ba4 100644
 --- a/src/app/virtualbox/src/VBox/Main/src-server/ClientToken.cpp
@@ -395,7 +379,7 @@ index a717aff..3d52b9f 100644
  RT_C_DECLS_END
  #endif
  
--#if !defined(RT_OS_LINUX) || !defined(_GNU_SOURCE)
+-#if (!defined(RT_OS_LINUX) || !defined(_GNU_SOURCE)) && !defined(RT_OS_FREEBSD) && !defined(RT_OS_NETBSD)
 -RT_C_DECLS_BEGIN
 -void *memrchr(const char *pv, int ch, size_t cb);
 -RT_C_DECLS_END
@@ -440,45 +424,6 @@ index a717aff..3d52b9f 100644
      void i_onStateChange(MachineState_T aMachineState);
      void i_onAdditionsStateChange();
      void i_onAdditionsOutdated();
---- a/src/app/virtualbox/src/VBox/Main/src-server/MediumImpl.cpp
-+++ b/src/app/virtualbox/src/VBox/Main/src-server/MediumImpl.cpp
-@@ -43,7 +43,7 @@
- #include <algorithm>
- #include <list>
- 
--#include <openssl/rand.h>
-+//#include <openssl/rand.h>
- 
- typedef std::list<Guid> GuidList;
- 
-@@ -787,7 +787,7 @@
-     delete pTask;
- 
-     /* complete the progress if run asynchronously */
--    if (!pProgress.isNull())
-+    if (pProgress && !pProgress.isNull())
-         pProgress->i_notifyComplete(rc);
- 
-     LogFlowFunc(("rc=%Rhrc\n", rc));
-@@ -2530,7 +2530,7 @@
- 
-         pProgress.createObject();
-         rc = pProgress->init(m->pVirtualBox,
--                             static_cast<IMedium*>(this),
-+                             nullptr,
-                              (mediumVariantFlags & MediumVariant_Fixed)
-                                ? BstrFmt(tr("Creating fixed medium storage unit '%s'"), m->strLocationFull.c_str()).raw()
-                                : BstrFmt(tr("Creating dynamic medium storage unit '%s'"), m->strLocationFull.c_str()).raw(),
---- a/src/app/virtualbox/src/VBox/HostServices/SharedFolders/vbsf.cpp
-+++ b/src/app/virtualbox/src/VBox/HostServices/SharedFolders/vbsf.cpp
-@@ -1865,7 +1865,6 @@
- 
-     char *pszFullNewPath = NULL;
-     char *pszFullOldPath = NULL;
--    const char *pszOldPath = (const char *)pOldPath->String.utf8;
- 
-     /* XXX: no support for UCS2 at the moment. */
-     if (!BIT_FLAG(pClient->fu32Flags, SHFL_CF_UTF8))
 --- a/src/app/virtualbox/src/VBox/Main/src-client/ConsoleVRDPServer.cpp
 +++ b/src/app/virtualbox/src/VBox/Main/src-client/ConsoleVRDPServer.cpp
 @@ -43,7 +43,9 @@
@@ -986,15 +931,6 @@ index a717aff..3d52b9f 100644
          if (pMedium)
          {
              BOOL fHostDrive;
-@@ -4134,7 +4144,7 @@
-     // InsertConfig* throws
-     try
-     {
--        int rc = VINF_SUCCESS;
-+//        int rc = VINF_SUCCESS;
-         HRESULT hrc;
-         Bstr bstr;
-         PCFGMNODE pLunL1 = NULL;
 @@ -5440,6 +5450,9 @@
 
  #undef H
@@ -1057,9 +993,9 @@ index a717aff..3d52b9f 100644
 @@ -3830,7 +3838,9 @@
      pHdrUnconst->y -= (int16_t)pFBInfo->yOrigin;
  
-     /* @todo new SendUpdate entry which can get a separate cmd header or coords. */
+     /** @todo new SendUpdate entry which can get a separate cmd header or coords. */
 +#if 0
-     pThis->mParent->i_consoleVRDPServer()->SendUpdate(uScreenId, pCmd, (uint32_t)cbCmd);
+     pThis->mParent->i_consoleVRDPServer()->SendUpdate(uScreenId, pHdrUnconst, (uint32_t)cbCmd);
 +#endif
  
      *pHdrUnconst = hdrSaved;
@@ -1087,3 +1023,18 @@ index a717aff..3d52b9f 100644
      int rc = RTLogGroupSettings(RTLogRelGetDefaultInstance(), useLoggingLevel.c_str());
      //  If failed and not the default logging level - try to use the default logging level.
      if (RT_FAILURE(rc))
+--- a/src/app/virtualbox/src/VBox/Runtime/r3/posix/semevent-posix.cpp
++++ b/src/app/virtualbox/src/VBox/Runtime/r3/posix/semevent-posix.cpp
+@@ -49,10 +49,12 @@
+ # define pthread_yield() pthread_yield_np()
+ #endif
+ 
++#if 0
+ #if defined(RT_OS_SOLARIS) || defined(RT_OS_HAIKU) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+ # include <sched.h>
+ # define pthread_yield() sched_yield()
+ #endif
++#endif
+ 
+ 
+ /*********************************************************************************************************************************
diff --git a/repos/ports/src/virtualbox5/patches/vmmdev.patch b/repos/ports/src/virtualbox5/patches/vmmdev.patch
index d4cd48032f..f3dac5907c 100644
--- a/repos/ports/src/virtualbox5/patches/vmmdev.patch
+++ b/repos/ports/src/virtualbox5/patches/vmmdev.patch
@@ -29,14 +29,3 @@ index 8ce46a8..a6b84b0 100644
      int rc = pThis->pDrv->pfnIsPageFusionEnabled(pThis->pDrv, &pReq->fEnabled);
      if (RT_FAILURE(rc))
          pReq->fEnabled = false;
-+++ a/src/app/virtualbox/src/VBox/VMM/VMMR3/VM.cpp
-+++ b/src/app/virtualbox/src/VBox/VMM/VMMR3/VM.cpp
-@@ -2805,7 +2805,7 @@
-          * Debug logging.
-          */
-         RTLogPrintf("\n\nThe VM was reset:\n");
--        DBGFR3Info(pVM->pUVM, "cpum", "verbose", NULL);
-+//        DBGFR3Info(pVM->pUVM, "cpum", "verbose", NULL);
- #endif
- 
-         /*
diff --git a/repos/ports/src/virtualbox5/spec/nova/sup.cc b/repos/ports/src/virtualbox5/spec/nova/sup.cc
index 5d5f25f7f4..87b8aad905 100644
--- a/repos/ports/src/virtualbox5/spec/nova/sup.cc
+++ b/repos/ports/src/virtualbox5/spec/nova/sup.cc
@@ -115,6 +115,8 @@ int SUPR3PageAllocEx(::size_t cPages, uint32_t fFlags, void **ppvPages,
 	using Genode::Attached_ram_dataspace;
 	Attached_ram_dataspace * ds = new Attached_ram_dataspace(Genode::env()->ram_session(), cPages * 4096); /* XXX PAGE_SIZE ? */
 	*ppvPages = ds->local_addr<void>();
+	if (pR0Ptr)
+		*pR0Ptr = reinterpret_cast<RTR0PTR>(*ppvPages);
 
 	Genode::log(__func__, " cPages ", cPages, " alloc=", *ppvPages, " done");
 
diff --git a/repos/ports/src/virtualbox5/spec/nova/vcpu.h b/repos/ports/src/virtualbox5/spec/nova/vcpu.h
index 2c0903e44f..90f31721ba 100644
--- a/repos/ports/src/virtualbox5/spec/nova/vcpu.h
+++ b/repos/ports/src/virtualbox5/spec/nova/vcpu.h
@@ -557,7 +557,7 @@ class Vcpu_handler : public Vmm::Vcpu_dispatcher<pthread>,
 
 			/* tell rem compiler that FPU register changed XXX optimizations ? */
 			CPUMSetChangedFlags(pVCpu, CPUM_CHANGED_FPU_REM); /* redundant ? XXX */
-			pVCpu->cpum.s.fUseFlags |=  (CPUM_USED_FPU | CPUM_USED_FPU_SINCE_REM); /* redundant ? XXX */
+			pVCpu->cpum.s.fUseFlags |=  (CPUM_USED_FPU_GUEST | CPUM_USED_FPU_SINCE_REM); /* redundant ? XXX */
 			
 			if (utcb->intr_state != 0) {
 				Assert(utcb->intr_state == BLOCKING_BY_STI ||
diff --git a/repos/ports/src/virtualbox5/target.mk b/repos/ports/src/virtualbox5/target.mk
index f56706fcee..6ff303307d 100644
--- a/repos/ports/src/virtualbox5/target.mk
+++ b/repos/ports/src/virtualbox5/target.mk
@@ -15,8 +15,6 @@ SRC_CC = frontend/main.cc frontend/console.cc \
          hm.cc thread.cc dynlib.cc unimpl.cc
 
 # use implementation of VBOX 4
-vpath devices.cc $(REP_DIR)/src/virtualbox
-vpath drivers.cc $(REP_DIR)/src/virtualbox
 vpath dynlib.cc  $(REP_DIR)/src/virtualbox
 vpath libc.cc    $(REP_DIR)/src/virtualbox
 vpath logger.cc  $(REP_DIR)/src/virtualbox
diff --git a/repos/ports/src/virtualbox5/unimpl.cc b/repos/ports/src/virtualbox5/unimpl.cc
index d7e7fd7f9f..0617794f33 100644
--- a/repos/ports/src/virtualbox5/unimpl.cc
+++ b/repos/ports/src/virtualbox5/unimpl.cc
@@ -124,10 +124,14 @@ DUMMY(RTMemDupExTag)
 DUMMY(RTMemDupTag)
 DUMMY(RTMemExecFree)
 
+DUMMY(RTMpGetPresentCount)
+
 DUMMY(SELMR3GetSelectorInfo)
 DUMMY(SELMR3GetShadowSelectorInfo)
 
 DUMMY(SUPReadTscWithDelta)
+DUMMY(SUPR3ContAlloc)
+DUMMY(SUPR3ContFree)
 DUMMY(SUPR3HardenedLdrLoadPlugIn)
 DUMMY(SUPR3PageAlloc)
 DUMMY(SUPR3PageFree)
@@ -197,6 +201,7 @@ DUMMY(RTTimeLocalExplode)
 DUMMY(RTSymlinkCreate)
 DUMMY(RTSymlinkRead)
 DUMMY(RTSymlinkDelete)
+DUMMY(RTSystemQueryAvailableRam)
 
 DUMMY(RTNetIPv6PseudoChecksumEx)
 
@@ -208,8 +213,8 @@ DUMMY(RTZipXarFsStreamFromIoStream)
 DUMMY(FTMR3CancelStandby)
 DUMMY(FTMR3PowerOn)
 
+DUMMY(GIMExecHypercallInstr)
 DUMMY(GIMReadMsr)
-DUMMY(GIMR3Term)
 DUMMY(GIMWriteMsr)
 
 } /* extern "C" */